Case Study · Confidential global B2B SaaS

Multi-Currency Payments & Subscriptions on FastAPI + Airwallex for a Global B2B SaaS

How UnlockLive shipped a production-grade Airwallex payments and subscription stack on Python and FastAPI — five currencies live in 12 weeks, 99.99% webhook delivery, PCI-DSS-aligned, and a 65% drop in failed-payment churn.

  • IndustryFintech / SaaS
  • Year2025
  • CountryCanada
  • Duration4 months
Multi-Currency Payments & Subscriptions on FastAPI + Airwallex for a Global B2B SaaS hero screenshot

At-a-glance results

  • 5+Currencies live in 12 weeks (USD, CAD, GBP, EUR, AUD)
  • 99.99%Webhook delivery success after the inbox pattern shipped
  • 65%Reduction in failed-payment subscription churn
  • SAQ APCI scope held — backend never touches card data

The challenge

A B2B SaaS expanding from North America into APAC and EMEA needed a payment infrastructure that could collect in five currencies, run subscription billing, handle retries gracefully, and survive a security review. They had outgrown a single-processor setup — FX margins were eating 1.8% of revenue, settlement was multi-day, and their existing webhook handler dropped events under load. The CFO wanted Airwallex for the FX and global rails; the CTO wanted to keep their existing FastAPI stack and not turn payments into a separate service the team couldn't operate.

The ask: ship a production Airwallex integration on FastAPI + PostgreSQL inside a single quarter, with bullet-proof webhook reliability, real subscription state machine, PCI-DSS-aligned architecture, and a clean operations story so the on-call engineer at 2am isn't paging the CTO.

Our solution

We built a focused Airwallex integration around three engineering ideas: a typed payment domain model, an outbox-pattern webhook pipeline, and a state machine for the subscription lifecycle that the rest of the app can read but only payments code can write.

On the API side, all card data is collected with Airwallex's hosted payment elements so the application backend never touches a PAN — the PCI scope stays at SAQ A. The FastAPI service exposes a small, typed payments API (Pydantic v2 models, OpenAPI documented) that the product team consumes; Airwallex API calls are wrapped in a single client with idempotency keys, exponential retries, and circuit breaking.

On the webhook side, every Airwallex event lands in a signed-and-verified endpoint that does one thing: persist the raw event into an `inbox` table inside a single transaction. A separate worker processes the inbox in order, with at-least-once delivery and idempotent handlers. This pattern alone fixed the dropped-event problem completely — even during a 4x traffic spike at launch.

The subscription state machine handles trial, active, past-due, dunning, paused, canceled, and reactivated, with explicit allowed transitions and an audit log on every state change. Failed payments now run a smart retry schedule (not the default exponential backoff) tuned to the customer's billing-day patterns, which is what produced the 65% drop in failed-payment churn.

  • Hosted Airwallex payment elements — application backend never touches a PAN (PCI SAQ A)
  • Typed FastAPI payments API with Pydantic v2 domain model and OpenAPI contract
  • Idempotent Airwallex client with idempotency keys, exponential retry, and circuit breaker
  • Inbox-pattern webhook pipeline — signed verification, persisted raw event, ordered worker drain
  • Subscription state machine: trial, active, past-due, dunning, paused, canceled, reactivated
  • Smart dunning schedule tuned to customer billing-day patterns (not naive backoff)
  • Multi-currency support: USD, CAD, GBP, EUR, AUD live at launch — others added in days
  • Datadog dashboards for webhook lag, retry rate, dunning funnel, and FX exposure
  • Real on-call playbook covering Airwallex outage, webhook backlog, and bad signature events

How we built it

  1. 01

    Discovery: payment flows, FX, compliance scope

    We mapped the existing checkout, subscription, dunning, and refund flows; documented every place that touched money or card data; and produced a one-page PCI scoping document that defined exactly which surfaces would stay in SAQ A. We also ran the FX numbers across the planned currency mix to confirm the Airwallex business case before a single line of code was written.

  2. 02

    Architecture: typed domain, outbox webhooks, idempotency

    We designed a typed payments domain (Pydantic v2 + a small repository pattern), the inbox/outbox webhook pipeline, the subscription state machine, and the idempotency contract for the Airwallex client. Every external call gets an idempotency key derived from the business event, so a retry can never create a duplicate charge.

  3. 03

    Build: incremental, behind feature flags, with replay tests

    We shipped one currency and one subscription flow at a time behind feature flags, starting with the lowest-risk new market. Every webhook handler shipped with a replay test — we'd capture real Airwallex sandbox events, then prove the handler stayed correct under reordering, duplication, and partial failure.

  4. 04

    Launch: PCI walkthrough, dashboards, on-call playbook

    Before go-live we walked the security reviewer through the PCI scope and the threat model, deployed Datadog dashboards for webhook lag, retry rate, dunning funnel, and FX exposure, and wrote a real on-call playbook that an engineer can follow at 2am without paging the lead. We stayed on retainer for 8 weeks of post-launch tuning.

Tech stack

  • Python
  • FastAPI
  • Airwallex API
  • PostgreSQL
  • Redis
  • Celery
  • Next.js
  • AWS
  • Sentry
  • Datadog
  • Payments Integration
  • Python & FastAPI
  • Backend Engineering
  • Cybersecurity
We went from a single-processor setup that dropped webhooks under load to an Airwallex integration our finance team trusts and our security reviewer signed off on the first time. The dunning rebuild paid for the project on its own.
CTO · Global B2B SaaS (name confidential)

Frequently asked questions

How do you build a reliable Airwallex webhook handler in FastAPI?

Use the inbox pattern. The HTTP endpoint does exactly two things: verify the Airwallex signature and persist the raw event into a database table inside a single transaction. A separate worker drains the table in order, with at-least-once delivery and idempotent handlers. This separation means a slow handler, a deploy, or a downstream outage can never cause you to drop or double-process a webhook.

How do you keep PCI scope at SAQ A while still using Airwallex on a custom backend?

Collect all card data with Airwallex's hosted payment elements (or their Drop-in / Hosted Payment Page). Your backend only ever sees Airwallex IDs and tokens, never a PAN, CVV, or expiry. We document this scope in a one-page PCI scoping note your security reviewer can sign off on, then we put guardrails in code so a future engineer can't accidentally take card data into the backend.

Can FastAPI handle production payment volume reliably?

Yes — FastAPI's async model is excellent for the I/O-bound nature of payment APIs. The reliability comes from the patterns around it: idempotency keys on every Airwallex call, the inbox pattern for webhooks, a circuit breaker for the Airwallex client, and a real subscription state machine. We've shipped FastAPI payment stacks running tens of thousands of charges per day with five-nines webhook delivery.

How does Airwallex compare to Stripe for a global SaaS?

Airwallex tends to win for businesses collecting in 4+ currencies because of better FX margins and faster cross-border settlement. Stripe usually wins for North America-only SaaS that values its much larger third-party ecosystem. We integrate both and have helped clients run them side by side per-region — the integration patterns we use (typed domain, inbox webhooks, state machine) are processor-agnostic.

How long does an Airwallex integration project typically take?

10-16 weeks for a production-grade integration covering checkout, subscriptions, webhooks, dunning, refunds, and reporting on a single currency and product. Each additional currency or subscription flow after that usually adds 1-2 weeks. We work in tight slices behind feature flags so you can launch the first currency before the second is complete.

Want a result like this?

Talk to the same team that built Multi-Currency Payments & Subscriptions on FastAPI + Airwallex for a Global B2B SaaS. We’ll scope your project, give you a fixed-price proposal, and show you the closest analog from our portfolio.

Book a strategy call