PHP code example of jamesnuttall / omnipay-barclays-dl

1. Go to this page and download the library: Download jamesnuttall/omnipay-barclays-dl 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/ */

    

jamesnuttall / omnipay-barclays-dl example snippets


// Gateway initialization
$gateway = \Omnipay\Omnipay::create('BarclaysEpdqDl');
$gateway->setClientId('xxxxxx');
$gateway->setUserId('xxxx');
$gateway->setPassword('xxxxxxx');
$gateway->setShaIn('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
$gateway->setTestMode(true);

// Card data
$card = [
    'number' => 'xxxxxxxxxxxxxxxx',
    'expiryMonth' => 'xx',
    'expiryYear' => 'xxxx',
    'cvv' => 'xxx'
];

// Try to send purchase request
try {
    $response = $gateway->purchase(
        [
            'transactionId' => 'xxxxxxxxxx',
            'amount' => '25.00',
            'currency' => 'GBP',
            'card' => $card
        ]
    )->send();

    if ($response->isSuccessful()) {
        // Payment successful
        print($response->getTransactionReference());

    } else {
        // Payment failed
        print($response->getMessage());
    }
} catch (\Exception $e) {
    // Internal error, log exception and display a generic message to the customer
    exit("Error processing your payment. Please try again later.");
}