PHP code example of coxeh / omnipay-barclays-epdq

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

    

coxeh / omnipay-barclays-epdq example snippets


// create a gateway instance using onminpay factory
$gateway = Omnipay::getFactory()->create('BarclaysEpdq\Essential');
$gateway->setClientId('reseller_pspid');
$gateway->setShaIn('sha_in_passphrase');
$gateway->setCurrency('GBP');

// create a purchase request
$purchase = $gateway->purchase();

$purchase->setTransactionId('ORDER-00001'); // Unique ID
$purchase->setAmount(5000); // 50£

/**
 * @var $request EssentialPurchaseResponse
 */
$response = $purchase->send();
 
// send the HTTP query with POST parameters
// you will be redirected to barclays payment server page
$response->redirect();

/**
 * var $gateway Omnipay\BarclaysEpdq\EssentialGateway
 */
$gateway = Omnipay::getFactory()->create('BarclaysEpdq\Essential');

/**
 * var $request Omnipay\BarclaysEpdq\Message\EssentialCompletePurchaseRequest
 */
$request = $gateway->completePurchase();
// if you get parameters back with GET request you need to use setCallbackMethod
$request->setCallbackMethod('GET');
// validates the SHASIGN then store the array containing
// feedback values for a later use like generating invoices
$data = $request->getData();

/**
 * @var $request EssentialPurchaseResponse
 */
$response = $purchase->send();

// additional parameters resent as feedback parameter after the payment
// resulting in a redirection with the feedback parameters:
// https://www.yourwebsite.com/payment_accepted.php?[…standard.parameters…]
// &COMPLUS=123456789123456789123456789&SessionID=126548354&ShopperID=73541312
$feedback = new Feedback();
$feedback->setComplus('123456789123456789123456789');
$feedback->setParamplus('SessionID=126548354&ShopperID=73541312');
$response->setFeedback($feedback);

// Payment page layout configuration
$layout = new PageLayout(); 
// logo URL must be absolute and store on a secure server accessible via HTTPS
$layout->setTitle('Secure payment with our partner');
$layout->setLogo('https://www.mycompany/images/payment/logo.png');
$layout->setTextColor('#006400');
$response->setPageLayout($layout);

// Delivery & Invoicing Data
$delivery = new Delivery(); 
$delivery->setInvoicingFirstName('John');
$delivery->setInvoicingLastName('Doe');
$response->setDelivery($delivery);

// send the HTTP query with POST parameters
// you will be redirected to barclays payment server page
$response->redirect();