Before you begin
- A platform secret key from Connect → API keys, kept on your server.
- An active connection in the same mode. The platform key and the merchant’s connection both grant each permission an operation needs:
Bill a connected account
Pass the merchant ID as the server SDK’saccount option, or send it in the
Ionic-Account header. Every object you create belongs to that merchant, and
every customer, price, payment method, and invoice you name must belong to it in
the same mode. An object from another account returns 404.
- Every write returns
403 MERCHANT_INACTIVEwhile the merchant is not active. - Subscription writes that start or change a charge (create, resume, items,
collection method, and default payment method), collecting an invoice with
POST /v1/invoices/{id}/pay, and changing an invoice’s card also need the merchant to be ready to take payments in that mode. Until then they return403 PAYMENTS_NOT_ENABLED(403 LIVE_PAYMENTS_NOT_ENABLEDin live mode), or422 account_not_yet_activeor422 account_activation_failedwhile the merchant’s payment account is being set up. - Canceling a subscription, voiding an invoice, and issuing a credit note work even after the merchant’s payments are disabled.
- Subscriptions and invoices your platform creates record your platform and the connection that created them.
account option on products, prices, subscriptions, invoices, invoice
items, and credit notes needs @ionicfi/sdk 0.4.4 or later. On an earlier
version, pass { headers: { "Ionic-Account": "mer_..." } } instead.
Create a plan and subscribe a customer
charge_automatically needs a card saved for that customer with a SetupIntent,
which records the mandate renewals rely on. See
Save cards for connected accounts. With
send_invoice, the buyer pays each invoice on its hosted invoice page instead.
The subscription issues and collects its own invoices: you need invoices:read
to see them, and no invoice write permission.
Change or cancel a subscription
Invoice a one-off charge
This records a pending charge, creates an invoice that picks it up, and finalizes the invoice so the merchant’s customer can pay it on its hosted invoice page:charge_automatically
and the card’s payment_method_id, then collect it with ionic.invoices.pay.
Credit a paid invoice
out_of_band_amount). When you refund an
invoice’s payment, Ionic issues the matching credit note for you.
See Subscriptions for connected merchants,
Invoices for connected merchants,
and Credit notes for connected merchants
for the details of each.
Gate access with entitlement
Check entitlement on each access decision. Useentitled as the gate.
Read billing records
SendIonic-Account on each read to select the merchant.
To create and change these records, see Bill a connected account.
React to billing events
A platform webhook endpoint receives a merchant’s billing events when that merchant’s connection grants the matching read permission:
The event’s
account field names the merchant. A scheduled
cancel-at-period-end arrives as subscription.updated, so keep access until
the subscription is canceled. See Webhooks for platforms.
Test billing with clocks
Test clock operations acceptIonic-Account, so your platform can rehearse a
connected test merchant’s renewals, retries, and cancellations. The clock,
customer, and subscription must all belong to the selected merchant, and a clock
is advanced only while operating that merchant.
What’s next
Handle webhooks
Receive every connected account’s events on one endpoint and match each to its connected account.
Test billing with clocks
Advance test time through a connected test account’s renewals and retries.
- Recurring billing with Subscriptions: the subscription lifecycle.
- Invoices: drafting, finalizing, and collecting invoices.
- Credit notes: crediting a paid invoice.

