Billing
Invoices
Every successful charge generates an invoice: one-off checkouts, subscription renewals, and ad-hoc billing runs all flow through the same record. Pull the PDF, listen for state changes, render line items in your own UI.
When invoices are generated
- Checkout completion: a one-time
POST /checkoutspayment creates a single-line invoice when the buyer pays. - Subscription renewal: every cycle, Merida creates the renewal invoice just before charging. Failed charges leave the invoice in a retry state.
- Plan change proration: a mid-cycle plan change mints an adjustment invoice covering the difference.
- Manual: merchants can compose invoices by hand from the dashboard, typically for services billed outside the catalog.
Every case fires invoice.created so your backend stays in sync without
polling.
Webhook events
invoice.createdwebhookA new invoice exists. The payload includes the invoice ID, account ID, total, currency, and the originating subscription or payment link.
invoice.updatedwebhookAn existing invoice was credited, refunded, or otherwise adjusted. Re-fetch the invoice to get the new state.
Fetch the printable invoice
Each invoice has a printable HTML view served behind a Bearer-authenticated endpoint. Print to PDF in the browser, or pipe through a headless renderer if you need server-side PDF output. The markup is print-stylesheet ready.
curl https://meridapay.com/api/invoices/<invoice-id>/pdf \
-H "Authorization: Bearer $MERIDA_API_KEY" \
-o invoice.html
AuthorizationstringrequiredBearer mrd_test_… or Bearer mrd_live_… from
your org. The endpoint is org- and mode-scoped: a key from a different
org (or wrong mode) returns 404 not found for any invoice ID.
Returns text/html; charset=utf-8. 404 when the
invoice doesn't exist or doesn't belong to the caller's org.
Customer-side access
Customers see their own invoices via the self-service portal. The portal lists every invoice for the account behind a token, no Merida login or API key required.
Tax and adjustments
Tax lines, discounts, and credits all roll up into the invoice total before the charge fires. The webhook payload reports the final amount. The printable view itemises the breakdown for the customer.
Next up
API reference →