2 posts / 0 new
Last post
ernestoten3222
PHP send token purchase error

Trying to send a token payment with the following payload:

{
"transaction_type": "authorize",
"method": "token",
"amount": "10",
"currency_code": "USD",
"token": {
"token_type": "transarmor",
"token_data": {
"type": "Visa",
"value": "1705031592561111",
"cardholder_name": "John Doe",
"exp_date": "0125"
}
}
}

Headers sent:

Array
(
[0] => Content-Ttype: application/json
[1] => apikey:[redacted, is API key]
[2] => token:[redacted, is Mechant Token]
[3] => Authorization:[HMAC, generated with API secred, nonce, timestamp, ]
[4] => nonce:3675846461
[5] => timestamp:1428426746000
)

Response I'm getting:

{"corrID":"228.1428426748315","error":{"code":"500","description":null}}

This is against the sandbox URL:

https://api-cert.payeezy.com/v1/transactions


nileshdafeniles...
Re: PHP send token purchase error

Can you please verify if you generated the HMAC correctly? Following is the code to generate HMAC correctly.

<?php
   $apiKey = "<your api key>";
   $apiSecret = "<your consumer secret>";
   $nonce = "<Crypographically strong random number>";
   $timestamp = "<Epoch timestamp in milli seconds>";
   $token = "<Merchant Token>";
   $payload = "<For POST - Request body / For GET - empty string>";
   $data = $apiKey + $nonce + $timestamp + $token + $payload;
   $hashAlgorithm = "sha256";

   <!-- Make sure the HMAC hash is in hex --> 
   $hmac = hash_hmac ( $hashAlgorithm , $data , $apiSecret, false );

   <!-- Authorization : base64 of hmac hash -->
   $authorization = base64_encode($hmac); 
   ehco $authorization;
?>