Guides
Errors
How the API reports errors, and the codes you can branch on.
A success body has statusCode, message (Success), and the result in data. On an error, data holds { code, message }. Branch on data.code.
409 REFERENCE_IN_USE
{
"statusCode": 409,
"message": "This reference was already used with a different amount.",
"error": "HttpException",
"version": "v2",
"data": {
"code": "REFERENCE_IN_USE",
"message": "This reference was already used with a different amount."
}
}HTTP status codes
| Code | Meaning |
|---|---|
| 200, 201 | It worked. Read data. |
| 400 | The body failed validation, the environment header disagrees with the key, or metadata is over 4 KB. |
| 401 | The key is missing, malformed, unknown or revoked. |
| 403 | The merchant is suspended, or a live key was used before live access was approved. |
| 404 | No payment or link with that id. |
| 409 | The reference, amount or account state conflicts with an existing record. |
| 429 | Too many requests for this key. Slow down and retry. |
| 5xx | Something went wrong on our side. Retry a payment with the same reference and amount. |
Error codes
| code | What to do |
|---|---|
INVALID_API_KEY | Send Authorization: Bearer and a key shaped sk_test_ or sk_live_ plus 40 letters or digits. |
PG_ENVIRONMENT_MISMATCH | Drop X-CSwitch-Pg-Environment, or make it match the key prefix. |
LIVE_ACCESS_REQUIRED | Live access is not approved. Keep using an sk_test_ key until it is. |
MERCHANT_SUSPENDED | The account is suspended. Contact support. |
INVALID_AMOUNT | Send a whole number of kobo inside the allowed range. The default minimum is 10000. |
METADATA_TOO_LARGE | Keep metadata at 4 KB or less. |
REFERENCE_IN_USE | That reference already belongs to a payment with a different amount. |
PAYMENT_NOT_FOUND | Check the reference and that the key's mode matches the payment. |
PAYMENT_FAILED | This payment could not be set up, so it cannot be simulated. |
SETUP_INCOMPLETE | Finish signup until the settlement account exists. |
METHOD_UNAVAILABLE | No payment method is enabled for this account. |
LINK_NOT_FOUND | Check the payment link id. |