seofood/omnipay-sofort

SOFORT Überweisung gateway for Omnipay payment processing library

3.0.1 2018-11-27 18:56 UTC

This package is auto-updated.

Last update: 2024-04-28 06:39:00 UTC


README

Build Status

SOFORT Überweisung gateway for awesome Omnipay library.

API Notes

This gateway only provides 2 methods to place a successful transaction. The first one is authorize which initializes an authorization and returns a redirect url.

The second one is completeAuthorize. This method doesn't actually complete anything. Since SOFORT Überweisung doesn't have a capture functionality, the only way to know about a transaction is checking that transaction details. According to official docs, if there is no any successful or failed transactions, the API will return empty transactions XML object.

Installation

To install, simply add it to your composer.json file:

{
    "require": {
        "seofood/omnipay-sofort": "~3.0"
    }
}

and run composer update

Usage

For general usage instructions, please see the main Omnipay repository.

1. Authorize

$gateway = Omnipay::create('Sofort');
$gateway->initialize(array(
    'username' => 'your_account_id',
    'password' => 'password',
    'projectId' => 'sofort_project_id',
    'testMode' => true
));

$response = $gateway->authorize(array(
    'amount' => 199.00,
    'description' => 'Google Nexus 4',
))->send();

$transactionReference = $response->getTransactionReference();

if ($response->isRedirect()) {
    // redirect to offsite payment gateway
    $response->redirect();
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}

2. Complete Authorize

$gateway = Omnipay::create('Sofort');
$gateway->initialize(array(
    'username' => 'your_account_id',
    'password' => 'password',
    'projectId' => 'sofort_project_id',
    'testMode' => true
));

$response = $gateway->completeAuthorize(array(
    'transactionReference' => $transactionReference,
))->send();

if ($response->isSuccessful()) {
    // payment was successful
    print_r($response);
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}