【发布时间】:2018-06-18 09:37:39
【问题描述】:
我正在开发 PayUMoney 支付网关。我已经成功集成了它。现在,在通过 PayUMoney 进行审核之前,他们突然告诉我,我必须在我的门户上集成交易状态 API。他们为我提供了 API。我也整合了它。以下是他们提供给我的代码。
$key = "gtKFFx";
$salt = "eCwWELxi";
$command = "verify_payment";
$var1 = "NPMM87334121";
//hash formaula
$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);
上面的代码给了我如下回复:
Array
(
[status] => 1
[msg] => 1 out of 1 Transactions Fetched Successfully
[transaction_details] => Array
(
[NPMM87334121] => Array
(
[mihpayid] => 403993715517090502
[request_id] =>
[bank_ref_num] =>
[amt] => 100813.00
[transaction_amount] => 100813.00
[txnid] => TRANS-2011-01-05-11-05-00
[additional_charges] => 0.00
[productinfo] => Test
[firstname] => Test User
[bankcode] => CC
[udf1] =>
[udf3] =>
[udf4] =>
[udf5] =>
[field2] =>
[field9] => FSS0001-Authentication Not Available
[error_code] => E500
[payment_source] => payu
[card_type] => VISA
[error_Message] => Bank failed to authenticate the customer
[net_amount_debit] => 0.00
[disc] => 0.00
[mode] => CC
[PG_TYPE] => HDFCPG
[card_no] => 411111XXXXXX1111
[name_on_card] => Demo
[udf2] =>
[addedon] => 2018-01-05 11:21:36
[status] => failure
[unmappedstatus] => failed
[Merchant_UTR] =>
[Settled_At] =>
)
)
)
在此之后,我编写了以下行以访问上述响应。
$checkout_data = $o['transaction_details'][$var1];
但是在这一行之后它给了我以下错误。
Message: Illegal string offset 'transaction_details'
Message: Illegal string offset 'NPMM87334121'
我不明白我在哪里做错了。 payu 给出的响应在数组中,所以如果我将它作为数组访问,仍然为什么它会给我错误。
【问题讨论】:
-
检查我的答案!在 print_r($o); 之后你可以在 json_decode 之后在 foreach 中做 ..
-
尝试一次,如果您遇到任何问题,请告诉我。
-
所以你现在在用别人的钱工作,请告诉我你为什么要关闭安全性? (
CURLOPT_SSL_VERIFYHOST, 0...) -
@DanFromGermany 代码仅由 PayU 团队提供。 OP 未更新 CURLOPT_SSL_VERIFYHOST
-
@DanFromGermany 请检查一次:- documentation.payubiz.in/check-status-apis
标签: php payment-gateway payumoney