Two different things can go wrong with a payment, and they look nothing alike.
- The request failed. The API returns a
4xxor5xxwith an error body. Nothing was charged. - The payment was declined. The API returns
200with a transaction whoseresultisDECLINED. The request worked; the issuer said no.
This page is about the first. For the second, see Handle declines.
Every failure returns the same four fields.
{
"error_code": "INVALID_REQUEST_DATA",
"error_message": "The API request contains invalid data.",
"details": {
"amount": "Invalid amount",
"payment_method.pan": "Malformed PAN"
},
"source": {
"system": "TSYS",
"code": "13",
"message": "Invalid amount"
}
}| Field | What it carries |
|---|---|
error_code | The stable code to branch on. Always present |
error_message | That code in words, for a log |
details | Field name to problem, when the failure was about specific fields. A few codes use named keys instead, listed in API response codes. Otherwise null |
source | The processor's own code and text, passed through unchanged. Null when the gateway raised the error itself |
Branch on error_code, never on error_message. The message is prose and may be reworded. The code is part of the contract.
source is for your support and reconciliation, not for your control flow. It tells you what TSYS or VeriCheck said, in their vocabulary, so a support ticket can quote it.
Fifteen, and that is the whole list. The status tells you the kind of failure, and the code tells you which one.
| Status | error_code | What happened | Safe to retry |
|---|---|---|---|
400 | INVALID_REQUEST_DATA | A field is present and its value is unusable. details names the fields | No — fix the request |
400 | REQUIRED_DATA_MISSING | A required field is absent | No — supply the field |
400 | INVALID_ACTION | The operation does not apply to the transaction's current state, such as capturing a sale | No — read the transaction first |
400 | AMOUNT_LIMIT_EXCEEDED | A single amount is outside the allowed range | No |
400 | VELOCITY_LIMIT_EXCEEDED | A count or dollar cap over a period is spent. details names the limit | Not until the period resets |
401 | NOT_AUTHENTICATED | Api-Key or Client-Id is missing or wrong | No — check both headers |
403 | UNAUTHORIZED_ACTION | Authenticated, but not allowed to do this | No |
403 | PROCESSOR_NOT_CONFIGURED | The merchant is not boarded to the processor this payment routes to. details names both | No — not until the merchant is boarded |
404 | RESOURCE_NOT_FOUND | No such transaction, client, or integration | No — check the ID |
409 | DUPLICATE_ACTION | The same operation was already done, or is underway, such as canceling a transaction twice | No |
429 | TOO_MANY_REQUESTS | The processor's request limit for the merchant was exceeded, and the transaction was not attempted | Yes, with backoff |
500 | SYSTEM_ERROR | A fault inside the gateway | Yes, but read the next section first |
500 | INTEGRATION_CONFIG_ERROR | The merchant's stored integration record is wrong | No — not until it is corrected |
502 | DOWNSTREAM_ERROR | The gateway reached the processor and could not use its reply | Yes, but read the next section first |
503 | PROCESSOR_UNAVAILABLE | The processor is down or unreachable, and did not process the request | Yes, with backoff |
error_code is a plain string, so treat this list as one that can grow. Handle a code you do not recognize by falling back on the HTTP status.
A 401 does not distinguish a missing header from a wrong key. If you get one, check that both Api-Key and Client-Id are present before assuming the key is bad — a missing Client-Id produces the same answer.
Not every operation can return every code. 404 is declared on 11 of the 19 operations, 409 on 7, and 502 on only 4: creating, capturing, and canceling a transaction, and closing a batch. 429 and 503 are declared on 2 each: creating and canceling a transaction.
This is the distinction that matters when money is involved.
- A
500withSYSTEM_ERRORis a fault inside the gateway. The fault can come after the processor accepted the transaction, so the transaction may exist. - A
502means the gateway reached the processor and could not use what came back. The processor may have seen the transaction. - A
503means the processor is down or could not be reached, and never received the request. No transaction exists.
All three are safe to retry in the sense that the API will accept the request again. A 500 and a 502 need a check first. A 503 does not.
After a 500 or a 502 on a payment, reconcile before retrying. Call GET /v1/transactions filtered to the window in question and look for a transaction matching what you sent. The API has no idempotency key, so a retry that the first attempt already completed creates a second charge.
Retry 429 and 503 after a backoff, and a 502 or a 500 carrying SYSTEM_ERROR once you have reconciled. Do not retry 400, 401, 403, 404, or 409, or a 500 carrying INTEGRATION_CONFIG_ERROR — the request will fail the same way until something changes.
Use exponential backoff with jitter: wait a short interval, double it each attempt, and add a small random offset so a fleet of clients does not retry in lockstep. Three or four attempts is usually enough; past that, the failure is not transient.
A 429 is the processor's limit, not ours. The gateway sets no rate limit of its own. A 429 with TOO_MANY_REQUESTS means VeriCheck's request limit for the merchant was exceeded on a bank account payment, and the transaction was not attempted, so a retry after a backoff cannot charge twice. No Retry-After header is sent, because no processor says how long its limits last.
Successful or not, every response includes an x-request-id header holding a GUID.
x-request-id: 73039bd9-c380-4186-bffe-259125144a56Log it with every request you send. It is what lets support trace one specific call through the gateway. A support ticket without it usually turns into a request for it.
Do not put error_code, response_code, or anything from source in front of a cardholder. "Do not honor" and 51 mean nothing to them and sometimes imply something untrue about their account.
Map to a short, actionable sentence — "That card was declined. Try another card" — and keep the codes in your logs, where they are useful.