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.
Common Error Codes
1001: Failed to Render Alipay Button
- Description: The Alipay button could not be rendered on the page. This error typically occurs if there is an issue with the HTML element or script configuration. Ensure that the DOM element for the button is correctly set up and the script is properly included.
1002: No Result Returned from onClick
- Description: This error occurs when no result is returned from the
onClick
event handler. It is specifically applicable if the merchant is passing payment data or a token during theonClick
event instead of during button initialization. To avoid this error, ensure that all necessary data is passed during button initialization.
- Description: This error occurs when no result is returned from the
1003: Failed to Process Payment
- Description: The payment could not be processed through Alipay. This error may occur due to issues with the payment data, network errors, or other processing issues. Ensure all payment information is correct and try again.
1004: Failed to Process Payment with Timeout
- Description: The payment process timed out. This could happen due to network issues or server response delays.
1005: Payment Data Missing
- Description: The payment data required for processing the transaction is missing. This error typically occurs if the payment data is not passed during either the button initialization or the
onClick
event. Ensure that all necessary payment data is provided at the appropriate stage to avoid this error.
- Description: The payment data required for processing the transaction is missing. This error typically occurs if the payment data is not passed during either the button initialization or the
1006: Token Missing
- Description: The token required for the transaction is missing. This error typically occurs if the token is not passed during either the button initialization or the
onClick
event. Ensure that the token is correctly generated and included at the appropriate stage to avoid this error.
- Description: The token required for the transaction is missing. This error typically occurs if the token is not passed during either the button initialization or the
1007: Payment Data Field Missing in Result from onClick
- Description: This error occurs when a required field in the payment data is missing in the result from the
onClick
event. This error is specifically applicable if the merchant is passing payment data during theonClick
event instead of during button initialization. To avoid this error, ensure that all necessary payment data is included during button initialization.
- Description: This error occurs when a required field in the payment data is missing in the result from the
1008: Token Field Missing in Result from onClick
- Description: This error occurs when the token field is missing in the result from the
onClick
event. This error is specifically applicable if the merchant is passing the token during theonClick
event instead of during button initialization. To avoid this error, ensure that the token is correctly generated and included during button initialization.
- Description: This error occurs when the token field is missing in the result from the
1009: Payment Timeout
- Description: The payment process timed out due to prolonged inactivity or network issues.
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.