PHP code example of omnipay-psp / omnipay-php-library
1. Go to this page and download the library: Download omnipay-psp/omnipay-php-library 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/ */
omnipay-psp / omnipay-php-library example snippets
use Omnipay\Api\Api;
$secret_key = '89eb5f3beb06a663a81c0c5a392fdb97';
$api_user_name = 'psp_test.paasy3u5.cGFhc3kzdTU2NGViZA==';
$api_password = 'OVNHR3dHaDd5ZnpGN0ExcnByUmdPQVprNzliZUhMbmR3bVJCSUp3alFyUT0=';
$apiMode = 0; // 0=Test, 1=Live
$api = new Api($api_user_name, $api_password, $apiMode);
//$api->class->function() to access the API
//Example
//This is for encrypt decrypt before call API
//Create Payment
$paymentParm = array('customer' =>array('name'=>'Dharmraj Kumhar', 'email'=>'[email protected] ') ,'order'=>array('amount'=>'1', 'currency' => 'SAR'),'sourceOfFunds' => array('provided'=>array('card'=>array('number'=>'5123450000000008','expiry'=>array('month'=>'12','year'=>'2023'), 'cvv'=>'999')), 'cardType' => 'C'), 'remark'=>array('description'=>'This payment is done by card'));
$api->encryptdecrypt->create($paymentParm, $secret_key, 'encrypt');
// Payment API
//Alwase send $param['trandata'] in encrypted string
$result = $api->payment->createPayment($param);
//Refund Transaction
$refundParm = array('transaction' =>array('id'=>'nt8my581z620365207292e','amount'=>'1', 'currency' => 'SAR'), 'remark'=>array('description'=>'Refund transaction'));
$encripted_result = $api->encryptdecrypt->create($refundParm, $secret_key, 'encrypt');
$param['trandata'] = $encripted_result['content']['apiResponse'];
$result = $api->payment->refund($param);
//Retrive Transaction
$result = $api->payment->retriveTransaction($transactionId);
//Transaction List between two date range
$AllTransParm = array('transaction' =>array('startdate'=>'2022-01-15','enddate'=>'2022-02-09'));
$result = $api->payment->transactionList($AllTransParm);