Error Handling
The Teljoy Platform Payment API uses standard HTTP status codes to indicate the success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the provided information (e.g., a required parameter was missing), and codes in the 5xx range indicate a server-side error.
When an error occurs, the API will return a JSON object containing more information about the error. This object will have the following structure:
{
"type": "string",
"title": "string",
"status": "integer",
"detail": "string",
"instance": "string",
"errors": {
"field1": ["Error message 1"],
"field2": ["Error message 2"]
}
}
| Field | Type | Description |
|---|---|---|
| type | string | A URI reference that identifies the problem type |
| title | string | A short, human-readable summary of the problem |
| status | integer | The HTTP status code generated by the origin server for this occurrence |
| detail | string | A human-readable explanation specific to this occurrence of the problem |
| instance | string | A URI reference that identifies the specific occurrence of the problem |
| errors | object | An object containing field-specific error messages (only for 4xx errors) |
Common Error Codes
Here are some common error codes you might encounter while using the Payment API:
| Code | Description |
|---|---|
| 400 | Bad Request - The request was invalid or cannot be served. The exact error should be explained in the error payload. |
| 401 | Unauthorized - The request requires authentication. The API key is missing or invalid. |
| 403 | Forbidden - The client does not have access rights to the content. |
| 404 | Not Found - The requested resource could not be found. |
| 500 | Internal Server Error - The server failed to fulfill a valid request. |
When handling errors, it's important to check the error payload for more information and to handle different error codes appropriately in your application.