Overview
TheBillingOSClient class provides direct access to all BillingOS API methods. Use it when you need more control than hooks and components provide.
Most apps should use the hooks and components instead. The client is for advanced use cases like custom data fetching, server-side rendering, or non-React integrations.
Access the client
From within a BillingOSProvider:Constructor options
Methods
Customers
| Method | Description |
|---|---|
createCustomer(input) | Create a new customer |
getCustomer(id) | Get a customer by ID |
listCustomers(params?) | List customers (paginated) |
updateCustomer(id, input) | Update customer details |
deleteCustomer(id) | Delete a customer |
Subscriptions
| Method | Description |
|---|---|
createSubscription(input) | Create a subscription |
getSubscription(id) | Get a subscription |
listSubscriptions(params?) | List subscriptions (paginated) |
updateSubscription(id, input) | Update a subscription |
cancelSubscription(id, immediately?) | Cancel a subscription |
reactivateSubscription(id) | Reactivate a cancelled subscription |
previewSubscription(id, input) | Preview subscription update proration |
getAvailablePlans(subscriptionId) | Get upgrade/downgrade options |
previewPlanChange(subId, input) | Preview plan change cost |
changePlan(subId, input) | Execute a plan change |
Entitlements and features
| Method | Description |
|---|---|
checkEntitlement(input) | Check if a customer has access to a feature |
listEntitlements(customerId?) | List all entitlements |
Usage tracking
| Method | Description |
|---|---|
trackUsage(event) | Track a usage event |
getUsageMetrics(customerId?, featureKey?) | Get usage metrics |
Invoices
| Method | Description |
|---|---|
getInvoice(id) | Get an invoice |
listInvoices(params?) | List invoices (paginated) |
Payment methods
| Method | Description |
|---|---|
listPaymentMethods(customerId) | List payment methods |
removePaymentMethod(id) | Remove a payment method |
setDefaultPaymentMethod(id) | Set the default payment method |
Checkout
| Method | Description |
|---|---|
createCheckout(input) | Create a checkout session |
confirmCheckout(clientSecret, paymentMethodId) | Confirm a payment |
Checkout modal (iframe)
Access viaclient.checkout.*:
| Method | Description |
|---|---|
checkout.createSession(input) | Create a checkout session for the modal |
checkout.getSession(sessionId) | Get session details |
checkout.confirmPayment(secret, pmId) | Confirm payment |
Portal (iframe)
Access viaclient.portal.*:
| Method | Description |
|---|---|
portal.createSession(input?) | Create a portal session |
portal.getSessionStatus(sessionId) | Check session validity |
portal.getPortalData(sessionId) | Get aggregated portal data |
Pricing
| Method | Description |
|---|---|
getProducts(planIds?) | Fetch products for pricing table |
Upgrade nudge
| Method | Description |
|---|---|
checkUsage() | Check if an upgrade nudge should be shown |