ZeroPointPayments

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

  1. Verify the signature over the raw body, then deduplicate by event.id in durable storage. Deliveries repeat and can arrive in any order.
  2. Overwrite your stored copy of an object only when data.object_version is 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.
  3. Decide access from your stored copy of the subscription's status, never from current_period_end and never from the event in hand alone.
  4. Answer 2xx within 10 seconds; do slow work after answering.
  5. A customer.subscription.updated whose only change is payment_hold means a charge is being confirmed: do nothing.
  6. A customer.subscription.updated may carry data.reason, beside data.object, when it reports a change your code did not make. On billing events data.reason is always an object with a code and 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 the product and customer guards a product, that another subscription of the buyer holds, with subscription_guard not off: it was canceled and the subscription renews on its current price). subscription names the one that holds the price. Before that renewal the subscription object already says so: scheduled_change.blocked_by carries 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_attention has its own reason, a string; that one is unchanged.
  7. Skip any event whose data.sample is true (samples from send_sample_event).

Subscription events

TypeFires whenDo
customer.subscription.createdA 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.updatedAny 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_attributesOverwrite your copy (rule 2) and grant or revoke by status
customer.subscription.deletedThe 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 retriesRevoke access

Invoice events

TypeFires whenDo
invoice.paidAn invoice was paid: the first payment, a renewal, a retry, a manual payment, a plan change charged now, or a zero totalSend your receipt. Re-check the subscription is active before extending access
invoice.payment_succeededWith invoice.paid, at the same object_version, when a payment paid itHandle invoice.paid or this one, not both, or both idempotently
invoice.payment_failedA 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 nextBy 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.upcoming3 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 periodSend 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.voidedAn 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}/voidNothing is owed on it. A voided renewal forgives that period
invoice.marked_uncollectibleRetries are over and the final action ran, or an unpaid invoice's period endedAlways followed by customer.subscription.deleted

Checkout, customer and card events

TypeFires whenDo
checkout.session.completedA 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_methodProvision here, once per session id
checkout.session.expiredA session ended unpaid. Never while a payment's outcome is unknownOptional cleanup
customer.created, customer.updated, customer.deletedA customer was created, changed or deleted. customer.deleted never cancels anything: a customer with a live subscription cannot be deletedKeep your copy in step
payment_method.attachedA card was saved for a customer: by POST /v1/payment_methods, by checkout in subscription mode, or on the portalOptional
payment_method.detachedA saved card was deleted. Not sent when a card merely becomes unusableIf 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:

EmailEventNotes
Renewal reminderinvoice.upcoming3 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
Receiptinvoice.paidamount_paid, status_transitions.paid_at, billing_reason
Failed paymentinvoice.payment_failedDecide 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.