支付门集成问题PHP

时间:2018-04-02 12:33:44

标签: php payment-gateway payment payu

我正在尝试集成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);

1 个答案:

答案 0 :(得分:0)

如果你想显示自定义金额,你应该在$ 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″}';

如需更多说明,请点击此链接https://documentation.payubiz.in/email-payment/