Moyasar uses conventional HTTP response 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 failed because of the information provided (e.g., a required parameter was omitted, a charge failed, etc.), and codes in the 5xx range indicate an error with Moyasar’s servers (these should be rare).
Not all errors map cleanly onto HTTP response codes, however. When a request is valid but does not complete successfully (e.g., a credit card is declined by the bank), we return the normal 201 success code with a response message detailing the error.
The Moyasar API uses the following error codes:
OK – Everything worked as expected
Bad Request – The request was unacceptable, often due to missing a required parameter
Unauthorized – No valid API key was provided
Forbidden – credentials not enough to access resources
Not Found – The requested resource doesn’t exist
Method Not Allowed – Entity not activated to use live account
Too Many Requests – Too many requests hit the API too quickly.
Internal Server Error – We had a problem with our server. Try again later.
Service Unavailable – We are temporarily offline for maintenance. Please try again later.
You will receive an error response from API in case something went wrong.
Each error response will contain a message attribute describing the reason shortly. For some error types, there might be a detailed errors attribute that lists and details more information.
The following table summarizes each error type returned from API:
The request included invalid parameters.
You didn't authenticate yourself correctly, check our guide on Authentication
Too many requests hit the API too quickly.
Failure to connect to Moyasar’s API.
Your Account hasn't been activated to accept real payments,
contact our sales team for more information.
API errors cover any other type of problem (e.g. resource is not found ). API errors should be rare.
The credit card payment transaction failed due unauthorized attempt by the cardholder.