Error Codes
The provided error codes can be passed back to Magic Checkout Merchant API responses to prompt appropriate messsages displaying to the customer.
Magic Backend
Error Code 1000 - 1999
Code | Short form | Description | Customer |
---|---|---|---|
1000 | unknownError | Something went wrong with the call to Magic Backend server | |
1001 | createMagicOrderError | Failed to create Magic order | |
1002 | capturePaymentError | Failed to capture payment with Magic backend |
E-commerce platform
Error Code 2000 - 2999
Code | Short form | Description | Customer |
---|---|---|---|
2000 | unknownError | Something went wrong on the merchant platform | |
2001 | outOfStock | The item is not available in the merchant store. | |
2002 | invalidReference | The item does not exist in the merchant store | |
2003 | noShippingAvailable | Shipping is unavailable for this address | |
2004 | createUserError | Failed to create user on merchant platform | |
2005 | createOrderError | Failed to create order on merchant platform | |
2006 | orderValidationError | The order is invalid | |
2007 | createInvoiceError | Failed to create invoice | |
2008 | missingVariantError | One or more variants has not been provided. |
Payment Gateway
Error Code 3000 - 3999
Code | Short form | Description | Customer |
---|---|---|---|
3000 | unknownError | Something went wrong with the payment |
Implementation
In scenario of error occurs, a customized
Error
should be thrown with corresponding error code. Magic Checkout catches the thrown error and pays attention toerror.code
to display appropriate message to the customer.
An example of Customized Error is provided.
// customized Error class
class MagicError extends Error {
constructor(code, message) {
super(message);
this.code = code;
}
}
// example of throw an createOrderError(2005) error
try {
// create order in merchant platform
// ...
} catch (error) {
throw new MagicError(2005, 'createOrderError');
}
Updated about 2 years ago