JazzCash Gateway V2 PHP Integration
P粉940538947
2023-09-02 22:56:33
<p>I'm trying to integrate JazzCash Gateway V2 and want to do a direct payment transaction, which the documentation defines as "This is a single transaction that authorizes a payment and transfers funds from the payer account to the merchant account." </p >
<p>Here is my hash function</p>
<pre class="brush:php;toolbar:false;">function get_SecureHash($data_array) {
ksort($data_array);
$str = '';
foreach($data_array as $key => $value) {
if(!empty($value)) {
$str = $str . '&' . $value;
}
}
$str = $saltkey.$str;
$pp_SecureHash = hash_hmac('sha256', $str, $saltkey);
return $pp_SecureHash;
}</pre>
<p>I have matched my hash and it is the same as the hash calculated by the HashCalculator recommended by the documentation.https://github.com/aliabidzaidi/HashCalculator</p>
<p>我正在使用以下网址:</p>
<pre class="brush:php;toolbar:false;">$post_url = "https://sandbox.jazzcash.com.pk/ApplicationAPI/API/Purchase/PAY";</pre>
<p>我的数组如下所示:</p>
<pre class="brush:php;toolbar:false;">$data_array = array(
"pp_IsRegisteredCustomer"=> "yes",
"pp_ShouldTokenizeCardNumber"=> "yes",
"pp_CustomerID"=> "25352",
"pp_CustomerEmail"=> "abc@abc.com",
"pp_CustomerMobile"=> "03331234567",
"pp_Version"=> "2.0",
"pp_TxnType"=> "MPAY",
"pp_TxnRefNo"=> "T".date('YmdHisu'),
"pp_MerchantID"=> "MYMERCHANTID",
"pp_Password"=> "MYPASSWORD",
"pp_Amount"=> "20000",
"pp_TxnCurrency"=> "PKR",
"pp_TxnDateTime"=> date('YmdHis'),
"pp_TxnExpiryDateTime"=> date('YmdHis',strtotime(" 1 hours")),
"pp_BillReference"=> "billRef",
"pp_Description"=> "Description of transaction",
"pp_CustomerCardNumber"=> "512345000000008",
"pp_CustomerCardCVV"=> "100",
"pp_CustomerCardExpiry"=> "01/39",
"pp_SecureHash"=> "",
"pp_DiscountedAmount"=> "",
"pp_DiscountBank"=> "",
"pp_UsageMode"=> "API"
);</pre>
<p>当我运行curl时,我得到以下输出:</p>
<pre class="brush:php;toolbar:false;">{"responseCode":"110","responseMessage":"Please provide a valid value for pp_ Txn Ref No.","status":null,"pp_RetreivalReferenceNo":null,"secureHash":"9DE9F8E571F29CBD1316DFB2F0388E3FBE1CA9BC26FB9C284DF900DCCBA0C301"}</pre>
<p>接下来我可以尝试什么?</p>
It may be because the date format of pp_TxnDateTime and pp_TxnRefNo has changed
In your array,
"pp_TxnRefNo"=> "T".date('YmdHisu')
and"pp_TxnDateTime"=> date('YmdHis')
Make sure the format is the same, so change the following:
"pp_TxnRefNo"=> "T".date('YmdHisu')
Enter"pp_TxnRefNo"=> "T".date('YmdHis')
Hope it works.