Checkout
Create Stripe checkout sessions for subscriptions and top-ups.
Subscriptions
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",
});The plan key must exist in the deployed catalog. Send the customer to
session.url; session.id is the Stripe checkout session ID.
Billing portal
Use client.subscriptions.portal({ identity, returnUrl }) on your server
to create a temporary Stripe URL for an existing customer to view invoices and
update billing details and payment methods. Redirect the authenticated customer
to the returned url. See the billing portal guide.
Top-ups
import { Orbyte, credits } from "orbytelabs";
const client = new Orbyte({ accessToken: process.env.ORBYTE_API_KEY });
const session = await client.topups.checkout({
identity: "customer_123",
credits: credits(5),
successUrl: "https://app.example.com/billing/success",
cancelUrl: "https://app.example.com/billing",
});Top-ups cost $1 per credit and support two decimal places, with a minimum of
0.5 credits. Purchased credits can fund any deployed feature by default, including
features added later. Add featureKeys with catalog keys to restrict access, or
use [] for no feature access. An optional expiresAt sets credit expiry as a
Unix millisecond timestamp.
Stripe Checkout lets customers save eligible cards for future top-ups. Stripe creates a paid invoice after a successful top-up unless the environment disables top-up invoices. Creating a session does not confirm payment. Credits and subscription access follow Stripe's payment confirmation. See subscriptions and grants and top-ups for their lifecycle.
