Guides
Billing events reference
Every billing event type, when it fires, what data.object holds, and what your handler should do with it, including invoice.upcoming three days before a renewal. ZeroPoint sends no email to your customers; your app sends its own from these events.
Billing events use the same signed envelope as payment events: id (evt_...), type, created, livemode, merchant_id, api_version and data (object, object_version, and previous_attributes on updates). data.object is the Stripe-shaped object as committed by the change that fired the event: integer cents, Unix seconds. How to subscribe, verify the ZeroPoint-Signature header and catch up after an outage: Billing webhooks.
Billing events are opt-in. An endpoint with an empty event_types receives payment events only; list the types below, or ["*"].
ZeroPoint sends no email to your customers: no receipts, reminders or failed-payment notices. Your app sends its own from these events, in its own name.
Handler rules
- Verify the signature over the raw body, then deduplicate by
event.idin durable storage. Deliveries repeat and can arrive in any order. - Overwrite your stored copy of an object only when
data.object_versionis greater than or equal to the one you hold. Never use it to skip a handler: one change can send two events at the same version. - Decide access from your stored copy of the subscription's
status, never fromcurrent_period_endand never from the event in hand alone. - Answer 2xx within 10 seconds; do slow work after answering.
- A
customer.subscription.updatedwhose only change ispayment_holdmeans a charge is being confirmed: do nothing. - A
customer.subscription.updatedmay carrydata.reason, besidedata.object, when it reports a change your code did not make. On billing eventsdata.reasonis always an object with acodeand the ids it names:{"code": "scheduled_change_not_restored", "change": "sch_...", "price": "price_...", "subscription": "sub_..."}(a failed upgrade did not bring back the downgrade it replaced, because another subscription of the buyer holds that price) or{"code": "scheduled_change_refused_subscription_exists", ...}(a scheduled change fell due onto a price, or under theproductandcustomerguards a product, that another subscription of the buyer holds, withsubscription_guardnotoff: it was canceled and the subscription renews on its current price).subscriptionnames the one that holds the price. Before that renewal the subscription object already says so:scheduled_change.blocked_bycarries the same code while the change would be refused as things stand (it can change with no event on that subscription: see Upgrades, downgrades and cancel). Note:payment.needs_attentionhas its ownreason, a string; that one is unchanged. - Skip any event whose
data.sampleis true (samples fromsend_sample_event).
Subscription events
| Type | Fires when | Do |
|---|---|---|
customer.subscription.created | A subscription was created: by POST /v1/subscriptions (status incomplete until the first payment captures) or by checkout (already active) | Store it and its status, and grant by status (rule 3). A checkout sends it already active, and no customer.subscription.updated follows at purchase: subscribe to this type |
customer.subscription.updated | Any public field changed: status, the period, the price, cancel_at_period_end, scheduled_change, pending_update, default_payment_method, payment_hold, latest_invoice, discount, metadata. One event per change, with previous_attributes | Overwrite your copy (rule 2) and grant or revoke by status |
customer.subscription.deleted | The subscription ended (status: canceled, ended_at set): cancel now, the end of a period after cancel_at_period_end, or the final action after failed retries | Revoke access |
Invoice events
| Type | Fires when | Do |
|---|---|---|
invoice.paid | An invoice was paid: the first payment, a renewal, a retry, a manual payment, a plan change charged now, or a zero total | Send your receipt. Re-check the subscription is active before extending access |
invoice.payment_succeeded | With invoice.paid, at the same object_version, when a payment paid it | Handle invoice.paid or this one, not both, or both idempotently |
invoice.payment_failed | A charge on the invoice was proven declined. Never for an unknown outcome or the processor's duplicate screen. billing_reason says which charge: subscription_cycle (a renewal or its retry), subscription_update (a plan change: the plan is unchanged and invoice.voided follows), subscription_create (a first payment: the subscription is incomplete). attempt_count, next_payment_attempt (null when no retry follows, always null for the last two) and last_payment_error (code, decline_code, requires_new_payment_method) say what next | By billing_reason: a renewal, ask for a new card; a plan change, say it did not go through; a first payment, ask for another card and pay latest_invoice. See Failed renewals and retries |
invoice.upcoming | 3 days before a renewal by default (the merchant's upcoming_days, 0 to 30; 0 turns it off), for an active subscription that is not ending at period end. Once per period. A subscription created inside the window gets none for its first period | Send your renewal reminder, with a link to your account page (which opens the portal). data.object has no id and no object_version: deduplicate by event.id. A plan change after it does not resend it, so say "about" or read POST /v1/invoices/create_preview |
invoice.voided | An open invoice was voided: an expiring incomplete subscription, a cancel now, a plan change that did not go through, or POST /v1/invoices/{invoice_id}/void | Nothing is owed on it. A voided renewal forgives that period |
invoice.marked_uncollectible | Retries are over and the final action ran, or an unpaid invoice's period ended | Always followed by customer.subscription.deleted |
Checkout, customer and card events
| Type | Fires when | Do |
|---|---|---|
checkout.session.completed | A session was paid (or a zero total confirmed). In subscription mode it names an active subscription, a paid invoice, the customer and the saved payment_method | Provision here, once per session id |
checkout.session.expired | A session ended unpaid. Never while a payment's outcome is unknown | Optional cleanup |
customer.created, customer.updated, customer.deleted | A customer was created, changed or deleted. customer.deleted never cancels anything: a customer with a live subscription cannot be deleted | Keep your copy in step |
payment_method.attached | A card was saved for a customer: by POST /v1/payment_methods, by checkout in subscription mode, or on the portal | Optional |
payment_method.detached | A saved card was deleted. Not sent when a card merely becomes unusable | If it was the subscription's default card, ask for a new one |
Every billing payment also sends the payment events (payment.succeeded, payment.failed and the rest) for its pay_... row. A billing handler can ignore them.
One renewal, in order
A paid renewal sends invoice.upcoming (3 days before), then customer.subscription.updated when the renewal invoice is created (latest_invoice names it; the period has not moved yet), then at the capture invoice.paid, invoice.payment_succeeded and customer.subscription.updated (the new period). A declined renewal sends invoice.payment_failed and customer.subscription.updated (status: past_due); each failed retry another invoice.payment_failed. The last declined retry sends its invoice.payment_failed (next_payment_attempt: null) in the same change as invoice.marked_uncollectible and customer.subscription.deleted (final action cancel), so send your last-chance notice on the failure before it. A retry skipped by a per-card ceiling sends no event; a skipped last slot still sends the final three.
Customer emails
ZeroPoint sends no email to your customers. Send each one yourself, in your own name, from its event:
| Event | Notes | |
|---|---|---|
| Renewal reminder | invoice.upcoming | 3 days before the renewal by default (upcoming_days). The renewal is charged at period_start (also next_payment_attempt); period_end is the end of the period it buys. Show the date in the merchant's billing timezone (GET /v1/billing_settings). Skip it if your copy of the subscription is no longer active or is set to cancel at period end |
| Receipt | invoice.paid | amount_paid, status_transitions.paid_at, billing_reason |
| Failed payment | invoice.payment_failed | Decide the wording by billing_reason (see Invoice events): a declined renewal, a declined first payment, or a plan change that did not go through |
Never put a billing portal link in an email. A portal link works once and stops working 5 minutes after it is created, and whoever holds an unused one can open that customer's portal. Link to a route of your own instead, for example https://example.com/billing/manage: it signs the user in your usual way, creates a portal session with POST /v1/billing_portal/sessions and redirects to its url at once. The zeropoint.node.subscriptions snippet has both parts (sendBillingEmails and createManageRoute in emails.mjs).
See it in the sandbox
send_sample_event (or POST /v1/webhooks/{webhook_id}/test with event_type) sends one sample of a type to an endpoint that subscribes to it. Real events come from the flows: Sell a subscription in five calls and Test your billing with test clocks and failure injection. GET /v1/events (MCP list_events) lists them with types filters.