支付网关集成问题 PHP

Payment gate integration issue PHP

我正在尝试集成 HDFC/Payu 支付网关,但我无法在代码中添加自定义金额、姓名、电子邮件等。我的密码是

//此处为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);

如果你想显示自定义金额,你应该在 $var1 中发送 JSON 字符串,下面的代码对你有帮助。

 $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″}';

如需更多说明,请遵循此 link https://documentation.payubiz.in/email-payment/