Subscriptions
Sell recurring plans through Stripe Checkout and view customer subscriptions.
Define a plan in your catalog, connect Stripe, then start checkout from your server:
import { Orbyte } from "orbytelabs";
const client = new Orbyte({ accessToken: process.env.ORBYTE_API_KEY });
const session = await client.subscriptions.checkout({
identity: "customer_123",
planKey: "pro",
successUrl: "https://app.example.com/billing/success",
cancelUrl: "https://app.example.com/billing",
});
// Redirect the customer to session.url.The server resolves the plan from the active catalog and creates or reuses the customer. Each request creates a new checkout session; inspect the dashboard before repeating an uncertain request.
When credits arrive
Verified Stripe events synchronize the subscription and grant its configured credits for each paid recurring invoice. This includes $0 plans, fully discounted invoices, and free trials. A zero-credit plan issues no grant. A checkout URL or success redirect alone does not grant credits.
Subscription grants use the plan terms recorded for the invoice. By default,
they can fund any deployed feature, including features added after issuance.
Add featureKeys to a plan to limit its grants to specific features.
They are usable only while the subscription is active or trialing and within its
access period. Reaching that deadline or a cancellation taking effect ends access even if credits
remain. Purchased and manual grants remain independent.
Plans default to monthly billing. period supports DAILY, WEEKLY, MONTHLY,
and YEARLY intervals. Optional trialDays and rollover configure trial and
unused-credit behavior. Rollover accepts expiresAfterDays and either maxCredits
or maxPercentage; it does not extend access after a subscription ends.
Refunds and disputes
A successful refund or lost dispute reduces the credits issued for the affected invoice in proportion to the amount reversed. Credit uses the amount actually paid after discounts and rounds the reduction up to the smallest credit unit. For example, if a $20 invoice grants 100 credits and the customer spends 30, a $10 refund leaves 20 spendable credits. If the reduction exceeds the unspent credits, the spendable balance reaches zero. Recorded usage stays in the ledger and the customer incurs no credit debt.
An open dispute freezes the affected grant. A won dispute releases any credits still available under the original expiry and rollover rules. Stripe subscription status and the access period continue to govern access.
The credit history records reversals and restorations. The dashboard's funding report includes them in net subscription credits for the period when they are recorded. Zero-dollar invoices still grant the plan's credits and have no payment to reconcile. Automatic adjustments cover the invoice's default Stripe payment when it covers the full paid amount. Split payments and payments recorded outside Stripe fall outside this policy.
View customer subscriptions
In Credit, open a customer or the environment's Subscriptions page to see each plan, its status, billing period, and any scheduled cancellation.
const subscriptions = await client.subscriptions.list({
identity: "customer_123",
});The SDK returns all of the customer's managed subscriptions in the selected environment, newest first. A customer without subscriptions returns an empty array. The API key or OAuth caller needs the subscriptions read permission. HTTP clients can page through the same data with List customer subscriptions.
An active subscription can still have a scheduledCancellation. Its at field
is present when the effective date is known. A value of null means no
cancellation is scheduled. If Stripe timing data is unavailable, the response
may omit the billing period or cancellation state. All timestamps are in Unix
milliseconds.
Open the billing portal
Let signed-in customers view invoices and update their billing details and payment methods in Stripe. Resolve the customer's Orbyte identity from your authenticated account on the server and use a return URL from your app.
const { url } = await client.subscriptions.portal({
identity: account.orbyteCustomerIdentity,
returnUrl: "https://app.example.com/settings/billing",
});
// Redirect this customer to url.Orbyte configures the portal when a new environment connects to Stripe. Opening
the portal requires a configured portal, an existing customer billing profile
in the selected environment, and the subscriptions write permission. A customer
who has completed Stripe checkout already has a billing profile. An unknown
identity returns 404. A missing portal configuration or billing profile
returns 409.
Create a new session when the customer clicks your billing button. The URL is temporary and grants access to that customer's billing details and invoices.
For HTTP integrations, see Open a customer's billing portal.
Manage your organization's Orbyte billing
Open Settings → Billing to view your organization's credit purchases. Select Open Stripe billing to see Stripe invoices and update billing details or payment methods. By default, Stripe creates a paid invoice when a new organization top-up succeeds. Top-ups paid without an invoice appear in Billing activity.
Stripe Checkout lets you save an eligible card for future top-ups. Manage the default payment method for invoices in Open Stripe billing.
