createComponent()
createComponent() is called by merchant applications to create and display payment or card binding component UIs.
Notes:
- This method must be called after
init(). - This method is mutually exclusive with
confirmPayment(). - In the Payment Element scenario, paymentSessionData must be obtained from the server's createPaymentSession (One-time Payments) API response.
- In the Vaulting Element scenario, vaultingSessionData must be obtained from the server's createVaultingSession API response.
Method signature
Payment Element scenario
Future<void> createComponent(
String paymentSessionData,
void Function(AMSStatusResult) onResult,
)Vaulting Element scenario
Future<void> createComponent(
String vaultSessionData,
void Function(AMSStatusResult) onResult,
)Parameters
Parameter | Data type | Is required? | Description |
paymentSessionData | String | Yes | Payment session data. Pass the complete paymentSessionData value obtained from the createPaymentSession (One-time Payments) API response into this parameter. Notes:
|
vaultSessionData | String | Yes | Vaulting session data. Pass the complete vaultingSessionData value obtained from the createVaultingSession API response into this parameter. Notes:
|
onResult | Function | Yes | Initialization result callback function. Used to return the result of successful or failed initialization. Refer to |
onResult
The result callback from the createComponent() method receives an AMSStatusResult object indicating whether the initialization was successful.
Parameter | Data type | Is required? | Description |
result | Yes | Status results containing initialization status and error details. |
Return value
This method returns no value, and the initialization result is returned asynchronously through the onResult callback.
Error codes
Error messages are returned via AMSStatusResult in the onResult callback. When getStatus() returns FAIL , you can obtain error details through getError().
Payment Element scenario
code | status | Suggested prompt to the buyer (message) | Description | Further action |
|
| The order status is abnormal. Please check the payment status and contact the merchant. | The payment session has expired. | The order has timed out and been closed. Use a new paymentRequestId to initiate the payment again. |
| N/A | An error occurred. The transaction cannot be initiated. | SDK input parameters are abnormal. | Integration code exception. Troubleshoot yourself required. If the problem persists, contact Antom Technical Support. |
| N/A | An error occurred. The transaction cannot be initiated. | Abnormal timing when creating SDK instances or | Integration code exception. Troubleshoot yourself required. If the problem persists, contact Antom Technical Support. |
| N/A | An error occurred. The transaction cannot be initiated. | The checkout page static resource loading had timed out. | Buyer network exception or Antom service exception detected. Retry the |
Vaulting Element scenario
code | status | Suggested prompt for buyers (message) | Description | Recommended action |
| N/A | Request exception, transaction cannot be initiated. | The SDK input parameters are invalid. | Check your integration code. If the issue persists, contact Antom Technical Support. |
|
| Request exception, transaction cannot be initiated. | The API was called at an invalid time or in an invalid state. | Check your integration code. If the issue persists, contact Antom Technical Support. |
| N/A | Request exception, transaction cannot be initiated. | The checkout static resources failed to load within the timeout period. | The issue may be caused by the user's network or an Antom service exception. Retry the operation. |