Display usage and billing data in your app for your users
Software applications typically ship with a billing page. This allows customers to change plan, cancel subscription and view their usage.The customer endpoint returns the current state of the customer, including their active subscriptions, one-time purchases, and feature balances.
When building a pricing table, you need to know what each plan means for the current customer — is it an upgrade, a downgrade, or their current plan? Is a free trial available?Pass a customerId when listing plans and each plan will include a customerEligibility object:
The React useListPlans hook automatically includes customer context from AutumnProvider, so customerEligibility is populated on every plan without extra configuration.
Cancel a subscription using billing.update with a cancelAction. See Subscription Lifecycle for the full guide on immediate vs end-of-cycle cancellations.
import { useCustomer } from "autumn-js/react";const { updateSubscription } = useCustomer();// Cancel at end of billing cycleawait updateSubscription({ planId: "pro", cancelAction: "cancel_end_of_cycle"});
If a subscription has a pending cancellation, a scheduled downgrade, or a scheduled plan switch, you can reverse it with cancelAction: "uncancel".A subscription is pending cancellation when canceledAt is not null while the subscription is still active.
You can also use the events.list method to get the raw event data and display it in a table.Next: Deploy to productionOnce your billing page is in place, go through the production checklist to launch with real payments.