Prerequisites
- A Macropay account with an organization
- A Next.js 14+ project (App Router)
- An Organization Access Token
We recommend using the Sandbox environment for this guide
so you can test without processing real payments.
Step 1: Install Dependencies
.env.local:
Step 2: Create a Product
Create a product in the Macropay dashboard or via the API:product.id — you will need it in the next step.
Step 3: Generate a Checkout Link
Create a checkout link in the dashboard under your product, or generate one via the API. You can also create dynamic checkout sessions from a route handler:Step 4: Embed Checkout on Your Page
For a seamless experience, embed the checkout directly on your page instead of redirecting:Step 5: Handle Webhooks
Set up a webhook endpoint to process payment events. The@macropay/nextjs adapter handles signature verification automatically.
Step 6: Test with Sandbox
- Open your checkout page in the browser
- Use the test card
4242 4242 4242 4242with any future expiry and any CVC - Complete the purchase
- Verify the webhook fires in your terminal
- Replace your sandbox access token with a production token
- Change
server: "sandbox"toserver: "production"(or remove it entirely) - Update your webhook endpoint URL in the dashboard
What’s Next?
Webhook Events
See all available webhook event types
Customer Portal
Let customers manage their subscriptions
AI/LLM Billing
Bill customers based on AI model usage
Embedded Checkout
Advanced embedded checkout options