Skip to main content

Handling Error Codes

Handling Error Codes in Alipay Integration

When integrating Alipay, the component may return various error codes during different stages of the payment process. It is essential to handle these errors appropriately to ensure a smooth user experience and provide meaningful feedback to your customers.

The following table lists the possible error codes that can be returned by the component:

CodeMessageExplanation
400Bad requestMalformed request to the DNA Payments API.
401UnauthorizedThe request to the DNA Payments API was not authorized. Check your token.
403ForbiddenYou do not have permission to perform the requested action.
404Not foundThe requested resource was not found on the DNA Payments API.
500Internal server errorAn error occurred on the DNA Payments API server.
1000Something went wrongA general or unexpected error occurred.
1001Failed to render buttonThe component could not be rendered in the specified containerElement. Ensure the container exists in the DOM at the time of initialization.
1002Failed to process paymentAn error occurred during the communication with the DNA Payments API while creating the transaction. This could be due to invalid order parameters or a transient server issue.
1003Failed to process payment (timeout)The request to create a payment order timed out. Check your internet connection and the status of the DNA Payments service.
1004Payment data is missingThe paymentData object was not provided during initialization and was not returned by the onBeforeProcessPayment event handler.
1005Token is missingThe authentication token was not provided during initialization and was not returned by the onBeforeProcessPayment event handler.
1006Payment timeoutThe transaction timed out because the customer did not complete the payment (e.g., scan the QR code) within the allotted time.
1007Failed to execute onBeforeProcessPaymentThe onBeforeProcessPayment asynchronous event handler threw an error (e.g., a failed network request).
1008No result returned from onBeforeProcessPaymentThe event handler was called but did not return a valid result object containing the necessary paymentData and token.
1009paymentData field missing in result from onBeforeProcessPaymentThe object returned by onBeforeProcessPayment is missing the required paymentData field.
1010token field missing in result from onBeforeProcessPaymentThe object returned by onBeforeProcessPayment is missing the required token field.

Notes

User Experience: Provide clear instructions or next steps for the user when an error occurs, such as retrying the payment or contacting support.

By properly handling error codes, you can improve the reliability of your Alipay integration and ensure a better user experience.