PHP code example of tanjarlan / omnipay-cmbpay

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

    

tanjarlan / omnipay-cmbpay example snippets


//gateways: CmbPay_H5, ...
$gateway    = Omnipay::create('CmbPay_H5');
$gateway->setBranchNo($config['branchNo']);
$gateway->setMerchantNo($config['merchantNo']);
$gateway->setMerchantKey($config['merchantKey']);

$order = [
    'orderNo' => '202104011000000002',
    'amount' => '0.01'
];

$request  = $gateway->purchase($order);
$response = $request->send();

if ($response->isSuccessful()) {
    return $response->redirect();
} else {
    return $response->getMessage();
}

$response = $gateway->refund([
    'orderNo' => '202104011000000002',
    'amount' => '0.01',
    'refundSerialNo' => 'RFD0002'
])->send();

if ($response->isSuccessful()) {
    return 'refund success';
}

return $response->getMessage();