'Test Item 1',
'price' => 10000,
'quantity' => 1);
$item2 = array(
'name' => 'Test Item 2',
'price' => 30000,
'quantity' => 3);
$itemDetails = array(
$item1, $item2
);
$params = array(
'merchantCode' => $merchantCode,
'paymentAmount' => $paymentAmount,
'paymentMethod' => $paymentMethod,
'merchantOrderId' => $merchantOrderId,
'productDetails' => $productDetails,
'additionalParam' => $additionalParam,
'merchantUserInfo' => $merchantUserInfo,
'customerVaName' => $customerVaName,
'email' => $email,
'phoneNumber' => $phoneNumber,
'itemDetails' => $itemDetails,
'callbackUrl' => $callbackUrl,
'returnUrl' => $returnUrl,
'signature' => $signature,
'expiryPeriod' => $expiryPeriod
);
$params_string = json_encode($params);
$url = 'https://sandbox.duitku.com/webapi/api/merchant/v2/inquiry'; // Sandbox
// $url = 'https://passport.duitku.com/webapi/api/merchant/v2/inquiry'; // Production
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($params_string))
);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//execute post
$request = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpCode == 200)
{
$result = json_decode($request, true);
header('location: '. $result['paymentUrl']);
echo "paymentUrl :". $result['paymentUrl'] . "
";
echo "merchantCode :". $result['merchantCode'] . "
";
echo "reference :". $result['reference'] . "
";
echo "vaNumber :". $result['vaNumber'] . "
";
echo "amount :". $result['amount'] . "
";
echo "statusCode :". $result['statusCode'] . "
";
echo "statusMessage :". $result['statusMessage'] . "
";
}
else
echo $httpCode;
?>
Tidak ada komentar:
Posting Komentar