Prerequisites
- A Macropay account with an organization
- An Organization Access Token
- A publicly accessible endpoint (or ngrok for local development)
Step 1: Create a Webhook Endpoint
From the Dashboard
- Go to your organization Settings > Webhooks
- Click Add Endpoint
- Enter your endpoint URL (e.g.,
https://your-app.com/api/webhooks/macropay) - Select the events you want to receive
- Click Create and copy the signing secret (
whsec_...)
From the API
Step 2: Configure Events
Choose which events to subscribe to based on your use case:| Event | Description |
|---|---|
order.paid | A one-time or recurring payment was completed |
order.refunded | An order was refunded |
subscription.created | A new subscription was created |
subscription.active | A subscription became active |
subscription.canceled | A subscription was canceled |
subscription.revoked | A subscription was revoked (e.g., failed payment) |
checkout.created | A checkout session was started |
checkout.updated | A checkout session status changed |
customer.created | A new customer was created |
customer.state_changed | A customer’s active subscriptions or entitlements changed |
Step 3: Implement Your Handler
Next.js (App Router)
FastAPI (Python)
Express.js
Step 4: Test with Sandbox
Using ngrok for local development
https://abc123.ngrok-free.app/api/webhooks/macropay).
Triggering a test event
- Create a checkout session pointing to one of your products
- Complete the checkout using test card
4242 4242 4242 4242 - Verify the webhook event arrives at your endpoint
Step 5: Handle Common Patterns
Idempotency
Macropay may deliver the same event more than once. Use thewebhook-id header to deduplicate:
Async processing
Return a200 response immediately, then process the event asynchronously to avoid timeouts:
What’s Next?
Webhook Events
Full reference of all webhook event types
Signature Verification
Deep dive into signature verification
Webhook Delivery
Retry behavior and delivery guarantees
Customer State
Query customer entitlements directly