I am trying to integrate HDFC/Payu payment gateway but i am unable to add custom amount, name, email etc. to the code. My code is
// Merchant key here as provided by Payu
$key = "gtKFFx";
$salt = "eCwWELxi";
$command = "verify_payment";
$var1 = "NPMM87334121";
$hash_str = $key . '|' . $command . '|' . $var1 . '|' . $salt ;
$hash = strtolower(hash('sha512', $hash_str));
$r = array('key' => $key , 'hash' =>$hash , 'var1' => $var1, 'command' => $command);
$qs= http_build_query($r);
`$wsUrl =` "https://test.payu.in/merchant/postservice.php?form=1";
//`$wsUrl =` "https://info.payu.in/merchant/postservice?form=1";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $wsUrl);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $qs);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
$o = curl_exec($c);
if (curl_errno($c)) {
$sad = curl_error($c);
throw new Exception($sad);
}
curl_close($c);
$valueSerialized = @unserialize($o);
if($o === 'b:0;' || $valueSerialized !== false) {
print_r($valueSerialized);
}
print_r($o);
If you want to show custom amount you should send JSON string in $var1, below code is helps to you.
$var1 = '{“amount”:”10″,”txnid”:”abc3332″,”productinfo”:”jnvjrenv”,”firstname”:”test”,”email”:”test@test.com”,”phone”:”1234567890″ ,”address1″:”testaddress”,”city”:”test”,”state”:”test”,”country”:”test”,”zipcode”:”122002″,”template_id”:”14″,”validation_period”:6,”send_email_now”:”1″}';
For more clarification follow this link https://documentation.payubiz.in/email-payment/