You are on page 1of 1

SAMPLE CODE FOR HASHING AND JSON CALL

Hashing :
$string = collect([
$data['cust_code'], $data['merchant_outlet_id'], $data['terminal_id'],
$data['merchant_return_url'], $data['description'], $data['currency'],
$data['amount'],
$data['order_id'], $data['user_fullname']
])->implode('');

return strtoupper(hash_hmac($algorithm, $string, $data['secret_key']));

JSON CALL :
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://devapiportal.oisbizcraft.com/api/payments',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"cust_code": "001003",
"merchant_outlet_id": "01",
"terminal_id": "001",
"merchant_return_url": "https:\\/\\/example.com\\/ois_bizcraft\\/checkout\\/return\\/order_id\\/15322\\/",
"description": "Order:#1-000015134;Tax:SGD28.04;IP:1.54.162.156",
"currency": "SGD",
"amount": 7041,
"order_id": "1-000015163",
"user_fullname": "Test Tester",
"hash": "B04A25F15351E083CS48FCF7F251BD3C985041FB3",
"origin_call": "custom",
"merchant_failed_return_url": "https:\\/\\/example.com\\/ois_bizcraft\\/checkout\\/return\\/order_id\\/15322\\/"
}',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Content-Type: application/json'
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

You might also like