Simulate transactions on issued cards
You can conduct end-to-end testing of your issuing integration by simulating card transactions on your Airwallex issued cards in the sandbox environment. The endpoints simulate the production behaviour of our payment networks.
Key simulation scenarios include:
- Authorization transaction including incremental auth, failed auth
- Capture transaction on an existing authorization including partial captures
- Authorization and capture in a single transaction
- Refunds and reversals
You can retrieve the simulated transactions via Get transactions for a single card API, Get single transaction API, and Get list of financial transactions API.
As a platform account, you can call the simulation APIs on behalf of a connected account using the x-on-behalf-of
header.
Prerequisites
- Obtain your access token API using your unique Client ID and API key. You must have your access token to make API calls.
- Set up your sandbox environment. See Integration checklist.
Simulate an authorization
An authorization request reserves funds on the available balance. You can simulate an authorization transaction to be approved or failed. The transaction object in the response is the same as Get single transaction API.
Successful authorization
To create a successful authorization transaction, call Create a transaction for the provided card API by providing the following request parameters:
card_id
orcard_number
: If both are provided, thencard_number
takes precedence.card_id
is the unique identifier of an Airwallex issued card. You can get thecard_id
from Get all cards API. If your account does not own the card then the transaction will fail.card_number
is a 16-digit card number, which you can retrieve from the web app or from Get sensitive card details API. If your account does not own the card then the transaction will fail.
transaction_amount
: Transaction amount to be authorized, maximum amount is $9,999.99.transaction_currency
: Currency code, only includingUSD
,AUD
,GBP
,EUR
,CAD
,JPY
,HKD
,CNY
,SGD
,NZD
, andCHF
.merchant_category_code
: A 4-digit Visa MCC.auth_code
: A 6-digit authorization code for transaction testing. If not provided, it is auto-generated.merchant_info
: Description of merchant with an exact string length of 43 characters. If not provided, defaults to ‘CARD_TX_GENERATOR TEST’.
Make sure the authorization request is compliant with the authorization controls set on your account.
Shell1curl --request POST2--url 'https://api-demo.airwallex.com/api/v1/simulation/issuing/create'3--header 'Content-Type: application/json'4--header 'Authorization: Bearer <your_bearer_token>'5--data '{6 "auth_code": "123312",7 "card_number": "4242424242424242",8 "merchant_category_code": "0742",9 "merchant_info": "Example",10 "transaction_amount": 100,11 "transaction_currency": "AUD"12}'
Failed authorization
In addition to the request fields for a successful authorization, set transaction_failure_reason
to one of the failure reasons to simulate a failed authorization. Possible failure reasons include: PIN_INVALID
, CVV_INVALID
, PIN_RETRIES_EXCEEDED
, CARDHOLDER_VERIFICATION_FAILED
, INVALID_EXPIRY_DATE
, TRANSACTION_BLOCKED
.
You can also fail an authorization based on authorization controls on the card. For example, if you set a spending limit of $100 on your account and you attempt to authorize $110, then this payment will fail.
Shell1curl --request POST2--url 'https://api-demo.airwallex.com/api/v1/simulation/issuing/create'3--header 'Content-Type: application/json'4--header 'Authorization: Bearer <your_bearer_token>'5--data '{6 "auth_code": "123312",7 "card_number": "4242424242424242",8 "merchant_category_code": "0742",9 "merchant_info": "Example",10 "transaction_failure_reason": "CARD_INVALID",11 "transaction_amount": 100,12 "transaction_currency": "AUD"13}'
Incremental authorization
In addition to the request fields for a successful authorization, provide transaction_id
, which is used to associate the given authorization request with a previous authorization. This creates an incremental authorization linked to the previous transaction.
Shell1curl --request POST2--url 'https://api-demo.airwallex.com/api/v1/simulation/issuing/create'3--header 'Content-Type: application/json'4--header 'Authorization: Bearer <your_bearer_token>'5--data '{6 "auth_code": "123312",7 "card_number": "4242424242424242",8 "merchant_category_code": "0742",9 "merchant_info": "Example",10 "transaction_amount": 100,11 "transaction_currency": "AUD",12 "transaction_id": "d8af1614-a6a1-4d45-aae7-6858fc6d9ede"13}'
Single transaction with auth and capture
In addition to the request fields for a successful authorization, specify single_phase
as true
to combine authorization and capture into a single transaction request.
Shell1curl --request POST2--url 'https://api-demo.airwallex.com/api/v1/simulation/issuing/create'3--header 'Content-Type: application/json'4--header 'Authorization: Bearer <your_bearer_token>'5--data '{6 "auth_code": "123312",7 "card_number": "4242424242424242",8 "single_phase": true,9 "merchant_category_code": "0742",10 "merchant_info": "Example",11 "transaction_amount": 100,12 "transaction_currency": "AUD"13}'
Simulate a capture
A capture transaction deducts funds specified in the request from your account balance in your multi-currency Wallet.
Successful capture
If the authorization has been approved (transaction status
: PENDING
), use Capture the transaction with the provided id API with the authorization transaction_id
from Step 2, to capture the full authorized funds. The captured amount will be deducted from your account balance in your multi-currency Wallet.
Partial capture
To capture only a partial amount of the authorized funds, specify an amount smaller than the full authorization amount in the transaction_amount
field.
Shell1curl --request POST2--url 'https://api-demo.airwallex.com/api/v1/simulation/issuing/d8af1614-a6a1-4d45-aae7-6858fc6d9ede/capture'3--header 'Content-Type: application/json'4--header 'Authorization: Bearer <your_bearer_token>'5--data '{6 "merchant_info": "Example",7 "transaction_amount": 808}'9
Simulate refunds and reversals
Simulate refunds on previously approved captured transactions and reversals on pending authorizations.
Refund a transaction
You can simulate refunds on an approved capture transaction (status
:APPROVED
), either fully captured or partially captured.
Call Refund a transaction for the provided card API by providing the following fields:
card_id
orcard_number
: If both are provided,card_number
takes precedence.transaction_amount
: The amount to refund.transaction_currency
: Currency of the refund transaction. Can only be one of USD, AUD, GBP, EUR, CAD, JPY, HKD, CNY, SGD, NZD, CHFtransaction_id
: Optional. Identifies the transaction linked with the refund request to which refund must be issued. If not provided, an unlinked refund will be created.
The transaction object in the response is the same as Get single transaction API for the REFUND
type.
Shell1curl --request POST2--url 'https://api-demo.airwallex.com/api/v1/simulation/issuing/refund'3--header 'Content-Type: application/json'4--header 'Authorization: Bearer <your_bearer_token>'5--data '{6 "card_number": "4242424242424242",7 "merchant_category_code": "0742",8 "merchant_info": "Example",9 "transaction_amount": 50,10 "transaction_currency": "AUD",11 "transaction_id": "d8af1614-a6a1-4d45-aae7-6858fc6d9ede"12}'
Reverse a transaction
You can simulate reversals on an approved authorization (status
:PENDING
).
Call Reverse a transaction with the provided id API by providing the following fields:
transaction_id
: Provide identifier of the authorization transaction to reverse as the request parameter.transaction_amount
: Optional. The amount to reverse for partial reversals. If not provided, the full amount will be reversed.
Shell1curl --request POST2--url 'https://api-demo.airwallex.com/api/v1/simulation/issuing/d8af1614-a6a1-4d45-aae7-6858fc6d9ede/reverse'3--header 'Content-Type: application/json'4--header 'Authorization: Bearer <your_bearer_token>'5--data '{6 "transaction_amount": 507}'