const created = await (await fetch('https://api.airwallex.com/api/v1/pa/payment_intents/create', {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
request_id: 'booking-2026-08-04-001', // your external_action_reference (idempotency)
amount: 42000, // minor units, matches proposed_action.payment
currency: 'EUR',
merchant_order_id: 'booking-2026-08-04-001', // findable after a lost response
return_url: 'https://your-app.example/airwallex/return', // required when 3D Secure may trigger
metadata: { external_action_reference: 'booking-2026-08-04-001' },
}),
})).json();
const confirmed = await (await fetch(
`https://api.airwallex.com/api/v1/pa/payment_intents/${created.id}/confirm`,
{
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
request_id: 'booking-2026-08-04-001.confirm',
payment_method: {
type: 'card',
card: { number: '...', expiry_month: '...', expiry_year: '...', cvc: '...' },
},
}),
},
)).json();
// confirmed.id is your provider_transaction_reference