PHP code example of omni-psp / omni-pay
1. Go to this page and download the library: Download omni-psp/omni-pay 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/ */
omni-psp / omni-pay example snippets
use Omnipay\Api\Api;
$secret_key = 'dCtLbk5FYVFGMVYrbFNGZTdEdzVpbSt3TFlYOC9NczNLaDZ0ZFo1WHcwVT0=';
$api_user_name = 'psp_test.eaohcfml.ZWFvaGNmbWw=';
$api_password = 'L1VPcklHbnh6T3RyWkdEVWZhci9HR1hSaHlrb0MwVEN5R0VtcUxkWHMwWT0=';
$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'=>'Raj', '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
$param['trandata'] = $encripted_result['content']['apiResponse'];
$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);
//subscription
$parms = array('customer' =>array('name'=>'Raj','email'=>'[email protected] ', 'interval'=>'1','interval_type'=>'3','interval_count'=>''),'order'=>array('amount'=>'1','currency' => 'SAR'),'sourceOfFunds' => array('provided'=>array('card'=>array('number'=>'5123450000000008','expiry'=>array('month'=>'12','year'=>'2023'), 'cvv'=>'999')),'cardType' => 'C'));
$encripted_result = $api->encryptdecrypt->create($parms, $secret_key, 'encrypt');
$param['trandata'] = $encripted_result['content']['apiResponse'];
if(!empty($encripted_result['content']['apiResponse']) && $encripted_result['code'] == 200){
$result = $api->payment->subscription($param);
}
//subscription detail
$customer_id = "202130020209387";
$result = $api->payment->subscriptionDetail($customer_id);
//subscription cancel
$customer_id = "202130294267467";
$result = $api->payment->cancelSubscription($customer_id);