PHP code example of meebio / omnipay-secure-trading

1. Go to this page and download the library: Download meebio/omnipay-secure-trading 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/ */

    

meebio / omnipay-secure-trading example snippets


$gateway = Omnipay::create('SecureTrading');
$gateway->setSiteReference('siteReference123');
$gateway->setUsername('username123');
$gateway->setPassword('password123');

$gateway->purchase([
    'amount'        => '10.00',
    'cardReference' => 'abc',
]);

$gateway = Omnipay::create('SecureTrading');
$gateway->setSiteReference('siteReference123');
$gateway->setUsername('username123');
$gateway->setPassword('password123');

$request = $gatewat->purchase([
    'transactionId'     => 'test-1234',
    'applyThreeDSecure' => true,
    'returnUrl'         => 'http://test-website.test/return-url',
    'amount'            => '2.99',
    'currency'          => 'GBP',
    'card'              => [
        'number'      => '4111111111111111',
        'expiryMonth' => '12',
        'expiryYear'  => '2020',
        'cvv'         => '123',
        'firstName'   => 'Forename',
        'lastName'    => 'Surname',
    ],
]);

$response = $request->send();
if ($response->isSuccessful()) {
    // card not enrolled or unknown enrollment
    // and payment is successful, no redirection needed
} elseif ($response->isRedirect()) {
    // redirect to offsite payment gateway
    $response->redirect();
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}
    
$gateway = Omnipay::create('SecureTrading');
$gateway->setSiteReference('siteReference123');
$gateway->setUsername('username123');
$gateway->setPassword('password123');
    
$request = $gateway->completePurchase([
    'md'    => $_POST['MD'],
    'paRes' => $_POST['PaRes'],
]);

$response = $request->send();
if ($response->isSuccessful()) {
    // payment is successful
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}