Payment Gateway integration with billdesk using php. Billdesk payment solutions help businesses, small and large, to accelerate their growth and digital transformation.
1. order.php
<!DOCTYPE html>
<html>
<head>
<title>My Order Page</title>
</head>
<body>
<h1>Place Order</h1>
<a href="orderpay.php?pay_type=pay_order&order_id=1"> Pay Now </a>
</body>
</html>
2.orderpay.php
<?php
/*****************************************/
$merchantID="YOUR-MERCHENT-ID";
$secretForChecksum="YOUR-SECRET-ID";
$securityID="YOUR-SECURITY-ID";
$paymentURL="https://pgi.billdesk.com/pgidsk/PGIMerchantPayment";
$returnURL="example.com/orderpay.php";
/*****************************************/
$pay_type="CALLBACK";
if(isset($_REQUEST['pay_type']) && $_REQUEST['pay_type']!="")
{
$pay_type=trim($_REQUEST['pay_type']);
}
$success_msg="Please wait, contacting Billdesk Payment Gateway.....";
$transaction_number=intval($_REQUEST['order_id']);
$applicant_ph=9090909090;
$applicant_name="Dipankar Biswas";
$applicant_details_blank="NR";
switch($pay_type)
{
case "pay_order":
$app_fees=100;
$txID="ODR-".date("Y")."-".str_pad($transaction_number,6,"0",STR_PAD_LEFT);
$str = "$merchantID|$txID|NA|".number_format($app_fees,2,'.','')."|NA|NA|NA|INR|NA|R|$securityID|NA|NA|F|$transaction_number|$applicant_ph|$applicant_name|$applicant_details_blank|NA|NA|NA|$returnURL";
$checksum = hash_hmac('sha256', $str, $secretForChecksum, false);
$checksum = strtoupper($checksum);
$str.="|".$checksum;
header("Location: ".$paymentURL."?msg=".$str);
break;
default:
$msg=explode("|",$_REQUEST['msg']);
if(count($msg)>10)
{
$txID_full=$msg[1];
$txID_array=explode("-",$txID_full);
$app_or_adm=trim($txID_array[0]);
$txID=intval($txID_array[3]);
$transaction_num=$msg[2];
$amount=$msg[4];
$auth_code=intval($msg[14]);
$checksum=$msg[25];
$msg_without_checksum=str_replace("|".$checksum, "", $_REQUEST['msg']);
$computed_checksum = strtoupper(hash_hmac('sha256', $msg_without_checksum, $secretForChecksum, false));
if($auth_code==300)
{
// UPDATE YOUR INFORMATION
}
else
{
$error_msg="Your payment could not be processed. Please try again.";
}
}
}
?>
Get the latest news and updates by signing up to our daily newsletter.We won't sell your email or spam you !