API

Errors

5min

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.

HTTP status code

The Moyasar API uses the following error codes:

Error Code

Meaning

200

OK – Everything worked as expected

400

Bad Request – The request was unacceptable, often due to missing a required parameter

401

Unauthorized – No valid API key was provided

403

Forbidden – credentials not enough to access resources

404

Not Found – The requested resource doesn’t exist

405

Method Not Allowed – Entity not activated to use live account

429

Too Many Requests – Too many requests hit the API too quickly.

500

Internal Server Error – We had a problem with our server. Try again later.

503

Service Unavailable – We are temporarily offline for maintenance. Please try again later.

Moyasar Errors

Invalid API Key Authentication Error

JSON


Credit Card Payment Validation Error

You will receive an error response from API in case something went wrong.

JSON


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:

Type

Meaning

invalid_request_error

The request included invalid parameters.

authentication_error

You didn't authenticate yourself correctly, check our guide on Authentication

rate_limit_error

Too many requests hit the API too quickly.

api_connection_error

Failure to connect to Moyasar’s API.

account_inactive_error

Your Account hasn't been activated to accept real payments, contact our sales team for more information.

api_error

API errors cover any other type of problem (e.g. resource is not found). API errors should be rare.

3ds_auth_error

The credit card payment transaction failed due unauthorized attempt by the cardholder.



Updated 28 Jan 2024
Did this page help you?