PHP code example of gentor / omnipay-sofort

1. Go to this page and download the library: Download gentor/omnipay-sofort library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gentor / omnipay-sofort example snippets


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

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

if ($response->isSuccessful() && $response->isRedirect()) {
    // redirect to offsite payment gateway
    $transactionReference = $response->getTransactionReference();
    $transactionStatus = $response->getTransactionStatus();
    $response->redirect();
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}


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

$response = $gateway->acceptNotification()->send();

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