Airwallex logo

Airwallex runs discovery and checkout

On your own storefront, Airwallex hosts the catalog, runs search, cart, and checkout inside the chat, and takes the payment.

Copy for LLMView as Markdown

To let a conversation on your site sell, with Airwallex running search, cart, checkout, and payment, complete the steps in this document.

Choose this path when a conversation already happens on your site, run by your own agent or by the chatbot provider you already use. Your chat app gains a set of commerce tools. Airwallex runs search, cart, and checkout behind them, and takes the payment.

What Airwallex renders is an iframe inside your chat window. Product cards, the cart, and the card form live in it. Your chat app never handles card data and never builds checkout screens. The look of the conversation stays yours.

Before you begin

  • Agentic commerce enabled on your account. See Enable Airwallex Agentic Commerce Suite.
  • A chat app on your site, or the Assistant SDK in its place.
  • A URL where Airwallex can call your create checkout API, and a Webhook endpoint that can receive PaymentIntent events. See Payment webhooks.

Who does what

StageYouYour chat appAirwallex
DiscoveryKeep your catalog current.Calls the Airwallex catalog tools with a Bearer token you issued.Searches your catalog and renders product cards in the chat window.
CheckoutReturn availability, fulfillment options, and totals from your create checkout API.Nothing. The iframe carries it.Calls your API and renders the cart.
PaymentNothing.Nothing. The card form is Airwallex's.Collects the card, creates the PaymentIntent, and confirms it.
FulfillmentFulfill on the Webhook.Nothing.Sends the Webhook with the shopper's choices.

How the purchase runs

The steps below follow the sequence diagram. The MCP app in that diagram is the MCP WebUI: the iframe inside your chat window. Your chat app mounts it, and Airwallex renders what is inside it. The MCP server is the backend that powers the WebUI. Your chat app calls the MCP server with the Bearer token.

  1. The shopper asks your chat app for something you sell.
  2. Your chat app authenticates the shopper. On your own domain it calls your session token endpoint. If the assistant is hosted off your domain, it uses the OAuth server you expose.
  3. Your chat app receives a Bearer token and holds it for the conversation.
  4. Your chat app calls the Airwallex catalog tools with that token.
  5. Airwallex renders product cards in the iframe.
  6. The shopper picks a product in the iframe.
  7. The iframe asks Airwallex to create a checkout.
  8. Airwallex calls your create checkout API.
  9. You return availability, fulfillment options, and totals.
  10. Airwallex renders the cart in the iframe.
  11. The shopper enters a card in the form inside the iframe.
  12. Airwallex turns the card into a single-use agentic token. The card number never reaches your chat app or your systems.
  13. The iframe calls complete checkout, with that token.
  14. Airwallex creates the PaymentIntent and confirms it with the token.
  15. Airwallex sends you the PaymentIntent Webhook. It carries the payment result and the shopper's fulfillment choice. You fulfill the order. See Sample payload.

Sequence inside the chat window: the shopper asks, the chat app authenticates, Airwallex renders product cards and the cart, then confirms the PaymentIntent and sends the Webhook

Supply your catalog

Send Airwallex a product feed and keep it current. Enable Airwallex Agentic Commerce Suite covers the formats, the required fields, and how ingestion works.

Nothing else on this path works until the catalog is loaded. The commerce tools your chat app calls read from it. Until there is a catalog, there is nothing to search, nothing to put in a basket, and nothing to price.

You are done when your Account Manager confirms the feed is ingested and your products are searchable.

Build your create checkout API

This is the one endpoint you build for this path: POST /create_checkout. It is where your commerce logic runs. You host it on your own systems and give Airwallex the URL. Airwallex records it in your merchant configuration as your create checkout endpoint. Whenever a shopper is ready to buy, Airwallex sends the basket to this endpoint and waits for your answer before showing the shopper anything.

Your answer settles three things, and each of them is final:

  • You decide what is actually available. Airwallex sells only the quantities you confirm.
  • You decide how the order can reach the shopper, by listing the fulfillment methods you offer and the priced options under each one.
  • You decide what the order costs. The totals you return are the totals the shopper is charged.

Create checkout is not an order. The response only indicates that the shopper started checkout. Fulfill when the PaymentIntent Webhook arrives. See Sample payload.

Airwallex sends the basket to your create checkout API with a timestamp and signature. You verify the signature, check stock, price fulfillment, and return totals

Verify the signature

Check the signature before you act on the request. A mismatch means the request did not come from Airwallex. The signature does not identify the shopper.

text
1POST /your/create-checkout HTTP/1.1
2Content-Type: application/json
3x-timestamp: 1731600000000
4x-signature: {{SIGNATURE}}

x-timestamp is epoch milliseconds, as a decimal string. x-signature is the hex HMAC-SHA256 of timestamp + the raw JSON body, keyed with the signing secret your Account Manager gives you after onboarding. Authorization: Bearer is present only on the Airwallex-hosted chat path.

JavaScript
1import { createHmac, timingSafeEqual } from 'node:crypto';
2
3function signaturesMatch(secretKey, timestamp, rawBody, signature) {
4 const expected = createHmac('sha256', secretKey).update(timestamp + rawBody).digest('hex');
5 const a = Buffer.from(expected);
6 const b = Buffer.from(signature);
7 return a.length === b.length && timingSafeEqual(a, b);
8}

Reject a timestamp more than five minutes from your clock. Airwallex rotates keys with an overlap, so you are never without a valid secret. Ask your Account Manager to arrange a rotation.

Airwallex signs the raw body with HMAC-SHA256. Your endpoint recomputes that signature and checks that the timestamp is fresh

Example request

JSON
1{
2 "line_items": [
3 { "id": "line_item_001", "item_id": "dress_tropical_s", "requested_quantity": 1 },
4 { "id": "line_item_002", "item_id": "dress_floral_s", "requested_quantity": 1 }
5 ],
6 "currency": "USD",
7 "customer": {
8 "id": "cus_hkpdxxxxxxxx",
9 "email": "[email protected]",
10 "first_name": "Jane",
11 "last_name": "Merchant",
12 "phone_number": "+1 415 555 0100"
13 },
14 "shipping_address": {
15 "street": "123 Market Street",
16 "city": "San Francisco",
17 "state": "CA",
18 "postcode": "94103",
19 "country_code": "US"
20 }
21}

A call with no customer and no shipping_address is still a valid basket. Return pickup options, which do not depend on an address. On ACP you can also return DIGITAL. Price shipping on the later call that carries an address. Do not return DIGITAL or LOCAL_DELIVERY when the agent speaks UCP.

Example response

Return the same checkout id on retries for the same basket. Do not create an order or decrement stock here.

JSON
1{
2 "id": "mch_co_01EXAMPLE",
3 "line_items": [
4 { "id": "line_item_001", "item_id": "dress_tropical_s", "requested_quantity": 1, "available_quantity": 1 },
5 { "id": "line_item_002", "item_id": "dress_floral_s", "requested_quantity": 1, "available_quantity": 1 }
6 ],
7 "fulfillment": {
8 "methods": [
9 {
10 "id": "ship",
11 "type": "SHIPPING",
12 "line_item_ids": ["line_item_001", "line_item_002"],
13 "destinations": [
14 {
15 "id": "dest_home",
16 "address": {
17 "street": "123 Market Street",
18 "city": "San Francisco",
19 "state": "CA",
20 "postcode": "94103",
21 "country_code": "US"
22 }
23 }
24 ],
25 "options": [
26 { "id": "std", "title": "Standard shipping (4-5 days)", "carrier": "USPS", "cost": 500 },
27 { "id": "exp", "title": "Express shipping (1-2 days)", "carrier": "FedEx", "cost": 1500 }
28 ]
29 },
30 {
31 "id": "pickup",
32 "type": "PICKUP",
33 "line_item_ids": ["line_item_001", "line_item_002"],
34 "destinations": [
35 { "id": "loc_downtown", "name": "Downtown Store" },
36 { "id": "loc_uptown", "name": "Uptown Store" }
37 ],
38 "options": [
39 { "id": "pu_instore", "title": "In-store pickup", "cost": 0 },
40 { "id": "pu_curbside", "title": "Curbside pickup", "cost": 0 }
41 ]
42 }
43 ]
44 },
45 "totals": [
46 { "type": "subtotal", "amount": 11798, "display_text": "Subtotal" },
47 { "type": "tax", "amount": 950, "display_text": "Tax" },
48 { "type": "total", "amount": 12748, "display_text": "Total" }
49 ],
50 "permalink_url": "https://merchant.example/checkout/mch_co_01EXAMPLE"
51}

Signaling availability

Echo each line item with available_quantity next to requested_quantity. An equal quantity is available. A lower quantity is partially available. 0, or a line you omit, is unavailable. Drop that line from the method's line_item_ids as well.

Fulfillment and totals

Return at most one method of each type. Shipping and pickup together is fine. Two shipping methods is not. Every method must list every line item you returned. Ids for methods, destinations, and options must be unique across the whole response, stable across retries, and meaningful in a log.

cost and each totals[].amount are integers in minor units. 500 is 5.00 in a two-decimal currency. Never send a fulfillment total. Airwallex adds that row from the option the shopper selects. Your total excludes fulfillment.

CodeWhat triggered it
multiple_fulfillment_methods_per_typeMore than one method with the same type.
fulfillment_does_not_cover_cartA method's line_item_ids did not cover every line item you returned.
duplicate_fulfillment_idTwo method, destination, or option ids collided.
unsupported_fulfillment_method_typeA type outside SHIPPING, PICKUP, DIGITAL, and LOCAL_DELIVERY.

Request and response fields are in the Merchant-hosted endpoints reference.

Handle the PaymentIntent Webhook

Airwallex creates and confirms the PaymentIntent for this flow. You do not need to create or confirm it yourself. Your integration must handle the Webhook that follows.

Use the Webhook to trigger fulfillment. The Create a checkout response only indicates that the shopper started checkout. The Webhook confirms that the payment was completed. It also includes the fulfillment option selected by the shopper, identified by the IDs you returned in the Create a checkout request. Use these IDs to associate the selected delivery method and option with the order.

Make your Webhook handler idempotent, because Airwallex may deliver the same Webhook more than once. Without idempotency, you could fulfill an order twice. Verify the Webhook as you would any Airwallex Webhook. See Check webhook signatures.

The agent receives a single-use token, completes checkout, and Airwallex checks the merchant, amount, session, and window before sending the PaymentIntent Webhook

The PaymentIntent Webhook carries merchant_order_id, the checkout id you returned, and agentic_payment_data with the fulfillment choice, which you join to your order

All IDs in the Webhook are IDs your integration generated. Match the type value case-insensitively: for example, you can send SHIPPING or PICKUP, and the Webhook returns shipping or pickup.

Ids you mint for methods, options, and destinations come back on the Webhook as the fulfillment id and the selected option and destination

Create checkout fields map onto the PaymentIntent Webhook: method id, type, line items, destination, and option

Sample payload

Fulfill on payment_intent.succeeded. The envelope matches the PaymentIntent payload example. data.object is the PaymentIntent. merchant_order_id is the checkout id you returned. agentic_payment_data carries the fulfillment choice.

JSON
1{
2 "id": "evt_100_2019102201549020043_8321220011893766",
3 "name": "payment_intent.succeeded",
4 "accountId": "78814faa-1b30-4598-a9c8-f0583db8d09d",
5 "data": {
6 "object": {
7 "request_id": "d6a92e2a-02e5-c37b-c977-13796ec7443a",
8 "id": "int_aaaat9w2hgh8mzi1111",
9 "merchant_order_id": "mch_co_01EXAMPLE",
10 "amount": 16.66,
11 "currency": "USD",
12 "captured_amount": 16.66,
13 "payment_method_options": {
14 "card": {
15 "risk_control": {
16 "three_domain_secure_action": "FORCE_3DS",
17 "three_ds_action": "FORCE_3DS"
18 },
19 "three_ds_action": "FORCE_3DS"
20 }
21 },
22 "status": "SUCCEEDED",
23 "created_at": "2023-01-13T07:32:05+0000",
24 "updated_at": "2023-01-13T07:32:05+0000",
25 "agentic_payment_data": {
26 "fulfillment": [
27 {
28 "id": "pickup",
29 "type": "pickup",
30 "line_item_ids": ["line_item_001", "line_item_002"],
31 "selected_destination_id": "loc_downtown",
32 "selected_option_id": "pu_instore"
33 }
34 ]
35 }
36 }
37 }
38}

Read agentic_payment_data as in-store pickup at loc_downtown, covering line_item_001 and line_item_002. Those are the line item ids from the example response. merchant_order_id is the checkout session id you returned. The fulfillment array length is 1 in this release. Do not assume the length stays 1.

  1. Verify the Webhook signature.
  2. Look up the checkout by merchant_order_id. That value is the checkout session id you returned from create checkout.
  3. Read the fulfillment selection and attach it to the order.
  4. Fulfill the order.
  5. Return 2xx quickly, and do the work asynchronously.
  6. Reconcile payments you might have missed. Poll the list PaymentIntents APIAPI by merchant_order_id, the checkout session id you returned.

The Webhook carries the same PaymentIntent object as the API. Agentic fields are in Confirm a PaymentIntentAPI. Standard PaymentIntent events are in Payment webhooks.

You are done when a test payment produces a Webhook you can resolve to an order, with the right fulfillment method and option attached.

Expose an authentication method

Before your chat app can call any commerce tool, it has to prove which shopper it is acting for. You decide how that proof is produced. Airwallex accepts either method below. Which one suits you depends on where the conversation runs.

What you exposeUse it whenWhat your chat app presents
POST /chat/generate_session_token on your own originThe conversation runs on your own domain, inside your own session.A short-lived session Bearer token that Airwallex validates.
An OAuth authorization server and a JWKS URLYour chat provider hosts the assistant off your domain.A Bearer token you issued, validated against the JWKS you publish.

If you choose the session token, build the endpoint on your own origin. It returns a short-lived token that the chat app carries for the rest of the conversation. Omit Authorization for a guest.

text
1POST /chat/generate_session_token HTTP/1.1
2Host: your-backend.example.com
JSON
1{
2 "access_token": "eyJhbGciOi…",
3 "expires_in": 3600
4}

For a guest, call Obtain an access tokenAPI with the scoped API key from onboarding, and return that token as access_token. That key needs only Read access to the Payment Acceptance > Customs Declarations scope, and no wider access. Create it as a scoped key rather than an Admin key. See Manage API keys.

A shopper who is already signed in sends your website session on the same endpoint. Validate it, then call Generate a client secret for a CustomerAPI and return that client secret as access_token.

text
1POST /chat/generate_session_token HTTP/1.1
2Host: your-backend.example.com
3Authorization: Bearer {{MERCHANT_WEBSITE_TOKEN}}
JSON
1{
2 "access_token": "eyJhbGciOi…",
3 "expires_in": 900
4}

That shopper arrives at create checkout as customer.id. An absent customer.id is a guest checkout. The request can also carry a CAPTCHA payload. Confirm the field name with your Account Manager before you rely on it.

Request and response fields are in the Merchant-hosted endpoints reference.

What your chat app does

The rest of the integration happens on your chat provider's side, or with your own agent team.

What your chat app doesDetail
Authenticate with youCall the method you exposed and hold the Bearer token for the life of the conversation.
Connect to the Airwallex MCP serverThe MCP server is the backend. It carries the catalog, checkout, and payment tools. The MCP app is the WebUI in the chat window, and this server powers it. On your own storefront the chat app calls https://mcp.airwallex.com/agentic_commerce_sdk/acp or https://mcp.airwallex.com/agentic_commerce_sdk/ucp, with the Bearer token from POST /chat/generate_session_token.
Mount the Airwallex iframe in the chat windowProduct cards, the cart, and the card form are rendered by Airwallex. Your provider sizes and mounts the frame. They do not rebuild what is inside it.
Carry the result back into the conversationThe checkout result returns to the chat app so the assistant can confirm the order in its own voice.

None of this touches card data, and none of it reimplements checkout. If your provider says they need to build a cart or a payment form for this integration, they have misread it.

Authentication on this path

ShopperCredential
GuestSession token your backend mints.
Signed in to your siteCustomer client secret, obtained through the website-auth bridge.

Before you go live

  1. Your catalog is ingested and current.
  2. Your create checkout API is registered, verifies signatures, is idempotent, and responds quickly.
  3. Your Webhook handler is idempotent and resolves every id back to an order.
  4. A reconciliation job polls PaymentIntent status for any checkout session where no Webhook arrived in your expected window.
  5. Your authentication method is live and rate-limited. If it is the session token endpoint, it is also protected with CAPTCHA.
  6. A signed-in shopper reaches your create checkout API with customer.id populated.
  7. Your chat provider has completed their side and driven a test purchase end to end.

Next steps

Was this page helpful?