7 posts / 0 new
Last post
Missing or invalid API Key

I am getting the 401 error "Missing or invalid API Key" on LIVE, even though I have checked that I am using the LIVE API Key and Secret, and merchant token from my live merchant account. I am also using the live URL: https://api.payeezy.com/v1/transactions
I am using Payeezy.js and sending tokenized request to Payeezy with PHP after creating token with JavaScript. My code worked fine in sandbox and all I did was switch out the key, secret, merchant and ta token values for the live ones and it stopped working.

Here is my code:


$('#payment-info-form').off('submit').on('submit', function(event) {
$(this).find('button').prop('disabled', true).html(' Processing Payment');
var apiKey = document.getElementById('apikey').value;
var js_security_key = document.getElementById('js_security_key').value;
var ta_token = document.getElementById('ta_token').value;
return false;
var responseHandler = function(status, response) {
var form = $('#payment-info-form');
if (status !== 201) {
if (status !== 400) {
var error = response['Error']['messages'];
var errormsg = error[0]['description'];
var errorcode = error[0]['code'];
console.log('Error Code: ' + errorcode + ' Error Message: ' + errormsg);
} else {

This is the token that should be getting sent to the PHP script:

"merchant_ref": "GLOBAL ELECTRONIC SERV",
"transaction_type": "purchase",
"method": "token",
"amount": 200,
"currency_code": "USD",
"token": {
"token_type": "FDToken",
"token_data": token


$checkdata = json_decode($_POST["data"]);
if (is_numeric($checkdata->amount)) {
$serviceURL = 'https://api-cert.payeezy.com/v1/transactions';
$reqbody = $_POST["data"];

list($usec, $sec) = explode(" ", microtime());
$timestamp = round(((float)$usec + (float)$sec) * 1000);
$timestamp = $timestamp - 5000;
$nonce = rand();

$summarize = "";
$summarize .= $apikey;
$summarize .= $nonce;
$summarize .= $timestamp;
$summarize .= $token;
$summarize .= $reqbody;

$hmac = hash_hmac('SHA256', $summarize, $apisecret);

$hmac_enc = base64_encode($hmac);

$curl = curl_init($serviceURL);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $reqbody);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_VERBOSE, true);

$headers = array(
'Content-type: application/json',
'Authorization: ' . $hmac_enc,
'apikey: ' . $apikey,
'token: ' . $token,
'timestamp: ' . $timestamp,
'nonce: ' . $nonce

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ($status != 201) {
die("Error: call to URL $serviceURL failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));


$response = json_decode($json_response, true);

echo json_encode($response);
} else {
echo 'Amount must be an integer';

Re: Missing or invalid API Key


Please check that your API key enabled for Live. You can check this by viewing the API properties and making sure that the "Live" checkbox is checked.

Is it that the tokenization request is succeeding and the PHP payment transaction is failing? Or are both of them failing?


Payeezy team


Re: Missing or invalid API Key

The API Key is enabled for Live, I have checked several times.

The tokenization request is failing. It never creates the token to send to the PHP.

Re: Missing or invalid API Key

Also, in the PHP code you pasted, you are using the sandbox API URL. Please change it to https://api.payeezy.com/v1/transactions


Payeezy team

Re: Missing or invalid API Key

I have changed my URL in the PHP to https://api.payeezy.com/v1/transactions
The tokenization request is still failing.

Re: Missing or invalid API Key

I am still having the same error of "missing or invalid API key". I have made sure that the API key, API secret and merchant token I'm using are all from live API and live merchant. I have changed the URL to live URL (https://api.payeezy.com/v1/transactions). I am still not getting a successful token response (tokenization request is still failing with the same error). What do I do next?

Re: Missing or invalid API Key

I have found the solution. I needed to update the URL in the payeezy_v3.2.js file as well in order to send request to correct URL for the token creation. No errors now. Thank you so much for your help.