2 posts / 0 new
Last post
robertwilliams14407
Error 401, acceess denied

$serviceURL = 'https://api.payeezy.com/v1/transactions';
$apiKey = "**************************";
(I obfuscatd this, but the info comes from https://developer.payeezy.com/user/me/apps, the specific api is labeled "gorilla")
$apiSecret = "*************************************************";
(I obfuscatd this, but the info comes from https://developer.payeezy.com/user/me/apps, the specific api is labeled "gorilla")
$token = "**************************";
(I obfuscated it, but this token comes from https://developer.payeezy.com/user/me/merchants/live

$nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong))));
$timestamp = strval(time()*1000); //time stamp in milli seconds

#############################################

$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 -->
$hmac_enc = base64_encode($hmac);

$curl = curl_init($serviceURL);

$headers = array(
'Content-Type: application/json',
'apikey:'.strval($apiKey),
'token:'.strval($token),
'Authorization:'.$hmac_enc,
'nonce:'.$nonce,
'timestamp:'.$timestamp,
);

curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);

curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);

// Set so curl_exec returns the result instead of outputting it.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

// Get the response and close the channel.
$response = curl_exec($curl);
$json_response = $response;

This worked for the sandbox, but after changing the service url and api info for the live system, it is not working. I'm getting this error message:
Error: call to URL failed with status 401, response {"correlation_id":"232.5010998596173","Error":{"messages":[{"code":"401","description":"Access denied"}]}}, curl_error , curl_errno 0


christopherlord730
Re: Error 401, acceess denied

Please email payeezyboarding@firstdata.com and provide the production merchant ID, apiKey, apiSecret and merchant token for testing. If the merchant shows as 'pending' under the live section and the merchant has an existing account you'll need to have the Payeezy Boarding team handle adding the existing merchant ID to generate a valid merchant token for authentication. The process takes 24-48 business hours.