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

CodeShort formDescriptionCustomer
1000unknownErrorSomething went wrong with the call to Magic Backend server
1001createMagicOrderErrorFailed to create Magic order
1002capturePaymentErrorFailed to capture payment with Magic backend

E-commerce platform

Error Code 2000 - 2999

CodeShort formDescriptionCustomer
2000unknownErrorSomething went wrong on the merchant platform
2001outOfStockThe item is not available in the merchant store.
2002invalidReferenceThe item does not exist in the merchant store
2003noShippingAvailableShipping is unavailable for this address
2004createUserErrorFailed to create user on merchant platform
2005createOrderErrorFailed to create order on merchant platform
2006orderValidationErrorThe order is invalid
2007createInvoiceErrorFailed to create invoice
2008missingVariantErrorOne or more variants has not been provided.

Payment Gateway

Error Code 3000 - 3999

CodeShort formDescriptionCustomer
3000unknownErrorSomething 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 to error.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');
}