Airwallex logo
Airwallex logo
Home
Developer Tools
Developer Tools
Back to home
OverviewAPI
SDKs
Sandbox environment
Sandbox environment overviewConnected accounts
Deposits
Linked Accounts
Payments
Simulate shopper action
Simulate payment disputes
Payouts
Issuing
Risk

Simulate shopper action

You can conduct end-to-end testing of your local payment methods integration by simulating shopper actions after being redirected to the payment page in the sandbox environment. To learn about local payment methods offered by Airwallex Online Payments, see payment methods.

Key simulation scenarios include:

  • Simulate a successful or failed payment on a payment intent.
  • Simulate verification of a payment method on a payment consent.

The redirect URL is obtained from the response of a PaymentIntent or PaymentConsent. A successful simulation of a shopper action on the given URL will return HTTP status 200 OK and an empty body.

As a platform account, you can call the simulation APIs on behalf of a connected account using the x-on-behalf-of header.

Pay or reject a payment

Call Simulate shopper action API with the following action URL parameter and request body field.

  • action: In the URL path, specify pay or reject to simulate a successful or failed payment respectively.
  • url: Specify the next_action.url obtained from the response of Confirm a PaymentIntent API in the sandbox environment. The shopper action will be simulated after redirection to this URL.

Create a simulation for successful payment

Shell
1curl --request POST
2--url 'https://api-demo.airwallex.com/api/v1/simulation/pa/shopper_actions/pay'
3--header 'Content-Type: application/json'
4--header 'Authorization: Bearer <your_bearer_token>'
5--data '{
6 "url": "https://api-demo.airwallex.com/pa/sandbox/sg/mck_hkdmt2qn2gk5b13d15o"
7}'

Create a simulation for failed payment

Shell
1curl --request POST
2--url 'https://api-demo.airwallex.com/api/v1/simulation/pa/shopper_actions/reject'
3--header 'Content-Type: application/json'
4--header 'Authorization: Bearer <your_bearer_token>'
5--data '{
6 "url": "https://api-demo.airwallex.com/pa/sandbox/sg/mck_hkdmt2qn2gk5b13d15o"
7}'

Call Simulate shopper action API with the following fields.

  • action: In the URL path, specify verify to simulate PaymentConsent verification with the payment method details.
  • url: In the request body, specify the next_action.url obtained from the response of Verify a PaymentConsent API in the demo environment. The verification will be simulated after redirection to this URL.
Shell
1curl --request POST
2--url 'https://api-demo.airwallex.com/api/v1/simulation/pa/shopper_actions/verify'
3--header 'Content-Type: application/json'
4--header 'Authorization: Bearer <your_bearer_token>'
5--data '{
6 "url": "https://api-demo.airwallex.com/pa/sandbox/sg/mck_hkdmt2qn2gk5b13d15o"
7}'

Troubleshooting

You might encounter the following errors when simulating payment APIs.

Error scenarioError code Error responseRecommended actions
Invalid action in action parametervalidation_error

{
"code": "validation_error",
"message": "Invalid action. Supported values are: pay,reject,verify."
}

Check input and pass valid values for action parameter.
Invalid URL in url parametervalidation_error

{
"code": "validation_error",
"message": "Invalid URL: ${url}"
}

Check input and pass valid values for url parameter.
Unsupported action for the url parameter

For example, a PaymentConsent URL passed as a URL for a payment that only supports pay and reject. Or, if the URL is not generated with the payment_intent/confirm API, hence not recognized by our system.
operation_not_supported

{
"code": "operation_not_supported",
"message": "Requested action ${action} is not supported."
}

Check the url and action values and make sure the url can support the action.
General failures in the system.internal_error

{
"code": "internal_error",
"message": "An internal error was encountered."
}

Contact Airwallex support.
Was this page helpful?
On this page
Was this page helpful?