// referenceID must be 15 digit unique number
$referenceID = 123456412250000;
$timestamp = date( "y/m/d H:m:s t" );
// referenceID must be 10 digit unique number
$userReference = 1234564122;
$authKey = 'Your Authorization Key';
$merchantID = 'Your Merchent Key';
// it should be ALL for all payment methods or specific payment method code i.e KNET
$paymentMethodCode = 'KNET';
// it will be null if store currency is same as your merchant currency.
// It will be Y if source currency and merchant currency is different
// Concat all data string
$datatocomputeHash = ( float )$amount . $authKey . $currency . $merchantID . $paymentMethodCode . ( int )$referenceID . $sourceCurrency . $timestamp . $tunnel . ( int )$userReference;
// convert the concated string in to hash and convert all string in upper character.
$hash = strtoupper( hash_hmac( "sha256", $datatocomputeHash, $secretkey ) );
'merchantCode' => $merchantID,
'currency' => $paymentMethodCurrency,
'pc' => $paymentMethodCode,
'amount' => ( float )$amount,
'doConvert' => $doConvert,
'sourceCurrency' => $sourceCurrency,
'description' => $description,
'referenceID' => ( int )$ref,
'timeStamp' => $timestamp,
'callbackURL' => 'https://www.example.com',
'userReference' => ( int )$userReference,
'billingDetails' => array(
'mobile' => '0000000000',
'address1' => 'Address 1',
'address2' => 'Address 2'
$request = json_encode( $data, true );
$curl = curl_init( 'https://ogcheckoutstage.oneglobal.com/OgPay/V1/api/GenToken/Validate' );
$curl = curl_init( $endpoint );
curl_setopt( $curl, CURLOPT_POST, true );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $request );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Content-Type:application/json' ) );
$ch = curl_exec( $curl );
$response = json_decode( $ch, true );