Skip to main content
Macropay is your merchant of record: when a customer checks out, Macropay is the legal seller. That means we calculate and remit sales tax and VAT worldwide, keep card data inside a PCI DSS Level 1 compliant vault, and own the chargeback process — so your Python service only ever touches a checkout URL and a webhook. This guide wires up a working integration end to end: install the SDK, mint a checkout, verify a signed webhook in FastAPI, and read back orders. Budget about five minutes.

What you’ll need

Run everything against the sandbox first. It mirrors production behavior — webhooks, signatures, the lot — without moving real money.

1. Install and authenticate

Pick your package manager:
Export your sandbox token and webhook secret so they stay out of source control:

2. Initialize the client

Point the client at sandbox while you build. The curl tab below reuses the same environment variable for the raw-HTTP examples throughout this guide.

3. Create a checkout session

Create a product once in the dashboard — a one-time license, a monthly plan, whatever you’re selling — then generate a hosted checkout per customer. Macropay’s hosted page handles card entry, 3-D Secure, tax collection, and localization for you.
The success_url is only a redirect — never the place to provision access. Tax may still be settling and the payment can fail asynchronously. Treat the webhook in the next step as your single source of truth.

4. Verify and handle webhooks

Macropay signs every webhook using the Standard Webhooks spec, so you can verify authenticity before trusting a payload. Install the verifier:
Here’s a complete FastAPI endpoint that checks the signature, then fans out on event type:
Register the endpoint in the dashboard under Settings → Webhooks and copy its signing secret into MACROPAY_WEBHOOK_SECRET. For local development, tunnel the route with ngrok and point the dashboard at the public URL.
The full catalog of events you can subscribe to lives in the webhook events reference.

5. Read back orders, subscriptions, and customers

With money flowing, query your data directly from the SDK. Amounts are integers in the smallest currency unit (cents), so divide by 100 to display.

6. Test the full loop in sandbox

1

Open the checkout

Run the script from step 3 and open the returned checkout.url in a browser.
2

Pay with a test card

Use 4242 4242 4242 4242 with any future expiry and any CVC, then complete the purchase.
3

Confirm the webhook

Watch your FastAPI logs — an order.paid event should arrive and pass signature verification.

Go to production

When the sandbox loop works, switch over: That’s the whole footprint. Because Macropay is the merchant of record, there’s no separate tax engine to integrate, no PCI questionnaire to fill out, and no dispute workflow to build — those stay on our side of the line.

Where to go next

Bill for AI usage

Meter tokens, activity, or agent outcomes and bill on real consumption

Webhook event reference

Every event type you can subscribe to

Python SDK reference

Full method and model documentation

Self-serve customer portal

Let customers manage plans, invoices, and payment methods