Error Format
All error responses follow this structure:Common Status Codes
-
4xx Client Errors: These indicate issues in the request sent to the server.
- 400 Bad Request: The request was invalid or missing required fields.
- 401 Unauthorized: Missing or invalid API key.
- 403 Forbidden: You don’t have permission to access this resource.
- 404 Not Found: The requested resource doesn’t exist or was entered incorrectly.
- 405 Method Not Allowed: The HTTP method used is not supported for this endpoint.
- 422 Unprocessable Entity: The request was well-formed but contained semantic errors.
- 427 Too Many Requests: You’ve exceeded the rate limit for API requests.
-
5xx Server Errors: These signify an issue on Modem Pay’s end.
- 500 Internal Server Error: General server error; retry the request or contact support if it persists.
Handling Errors
Check themessage
field in the response to understand the cause of the error. If the status code is 400 or higher, review your request parameters and API key to ensure they meet Modem Pay’s requirements.
Error Retries
Modem Pay offers automatic retry handling for certain types of errors. By default, Modem Pay retries up to three times if a request fails due to transient issues, such as network errors or temporary server overloads. This is configurable via themaxRetries
option, which you can set during initialization:
When Retries Occur
Retries are triggered for errors that are likely temporary, typically with 5xx server errors. Each retry is delayed slightly to give the server time to recover, helping ensure more reliable payment handling.Adjusting or Disabling Retries
To reduce or increase the retry count, simply adjust themaxRetries
value. Setting it to 0
disables retries entirely:
To disable error retry logs, add
RETRY_LOGGING=false
to your .env
file. This will suppress the retry attempt logs while still performing the retries.