Saad Bashir
Saad Bashir

Reputation: 4519

JazzCash Gateway V2 PHP Integration

I am trying to integrate JazzCash Gateway V2, and want to make a Direct Pay transaction which is defined by the documentation as "This is a single transaction to authorize payment and transfer funds from payer's account to merchant’s account."

Following is my hash function

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;
}

I have matched my hash and it same as the one calculated by HashCalculator recommended by the documentation. https://github.com/aliabidzaidi/HashCalculator

I am using following url:

$post_url = "https://sandbox.jazzcash.com.pk/ApplicationAPI/API/Purchase/PAY";

My array looks as follows:

$data_array = array(
   "pp_IsRegisteredCustomer"=> "yes",
   "pp_ShouldTokenizeCardNumber"=> "yes",
   "pp_CustomerID"=> "25352",
   "pp_CustomerEmail"=> "[email protected]",
   "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"
);

When I run the curl, I get following output:

{"responseCode":"110","responseMessage":"Please provide a valid value for pp_ Txn Ref No.","status":null,"pp_RetreivalReferenceNo":null,"secureHash":"9DE9F8E571F29CBD1316DFB2F0388E3FBE1CA9BC26FB9C284DF900DCCBA0C301"}

What can I try next?

Upvotes: -2

Views: 615

Answers (1)

Zoya Azam
Zoya Azam

Reputation: 11

It's probably because the date format for pp_TxnDateTime and pp_TxnRefNo is change
IN your array , "pp_TxnRefNo"=> "T".date('YmdHisu') and "pp_TxnDateTime"=> date('YmdHis')

Make sure that the format is same therefore, change:

"pp_TxnRefNo"=> "T".date('YmdHisu')
into
"pp_TxnRefNo"=> "T".date('YmdHis').

I hope it will work.

Upvotes: 1

Related Questions