Skip to main content
Wire a Next.js App Router app to Macropay end to end: create something to sell, send buyers to checkout, and react to paid orders — all in about five minutes. Because Macropay acts as your Merchant of Record, you never touch the parts that usually slow a launch down: we are the seller on the customer’s statement, we calculate and remit sales tax and VAT worldwide, and card data stays inside our PCI DSS Level 1 compliant vault. You write app logic; we own the tax and compliance liability.
Build against the Sandbox environment first. It mirrors production exactly but moves no real money, so you can replay checkouts and webhooks freely.

What you’ll need

Install the SDK

Add the SDK, the React checkout component, and the webhook verifier:
Drop your credentials into .env.local:
1

Create a product

In Macropay, everything you sell is a product — one-time or recurring share the same API and data model, only the pricing differs. Spin one up in the dashboard or straight from code. Here’s a monthly subscription priced at $24:
Need usage-based, seat-based, free, or pay-what-you-want pricing instead? Swap the prices array — the rest of this guide is identical. See pricing models for the full set.
Keep the product.id; the next step needs it.
2

Send buyers to checkout

A route handler is the cleanest way to mint a checkout on demand. It takes a product ID, opens a hosted checkout session, and redirects the buyer:
Point your pricing page at the route and pass the product ID through:
The hosted page handles currency localization, theming, and tax collection automatically — VAT and sales tax appear at the right rate for the buyer’s country with no extra work on your side.
3

Embed checkout inline (optional)

To keep buyers on your own page, render the checkout component instead of redirecting:
For theming, prefilled fields, and other options, see the embedded checkout reference.
4

Listen for webhooks

Webhooks are how your app learns a payment succeeded so it can grant access. Every Macropay webhook is signed using the Standard Webhooks spec — verify the signature with the standardwebhooks library before trusting the payload:
Register the endpoint in the dashboard under SettingsWebhooks, then read the body as raw text (as above) — parsing JSON first will break signature verification. For local development, tunnel your dev server with ngrok: ngrok http 3000.
The full catalog of event types lives in the webhook events reference.
5

Test in the sandbox

  1. Open your checkout page in the browser.
  2. Pay with the test card 4242 4242 4242 4242, any future expiry, any CVC.
  3. Confirm you land on your successUrl.
  4. Watch the order.paid event arrive in your terminal.

Going to production

Three changes flip you from test to live:
Once live, every order automatically carries the correct tax, settles into your Macropay balance, and pays out via ACH or SEPA at no fee. Disputes and chargebacks are handled for you as part of the Merchant of Record service.

Where to go next

All webhook events

Every event type your app can react to

Customer portal

A self-serve page for managing subscriptions

Meter AI & agent usage

Bill by tokens, activity, or outcome — and track agent ROI

Embedded checkout

Theming, prefills, and advanced options