Stripe Functions

Each Stripe function owns one billing responsibility, so checkout, webhooks, access checks, pricing, and account management stay easy to reason about.

stripe-checkout

Creates a Stripe Checkout Session from an existing price or an inline one-off product. Card details stay on Stripe's hosted page; the function only returns the checkout URL.

// Creates the session and returns its URL — use billing.checkout() instead
// if you want ChromeShip to open that URL in a new tab automatically.
const { checkoutUrl } = await billing.createCheckout({
  mode: "payment",
  product: { name: "Pro" },
  amount: 19900,
});

stripe-webhook

Verifies Stripe's signature, deduplicates each event, and updates the corresponding entitlement. This is the authoritative path for purchases, renewals, cancellations, and refunds.

For local testing, turn on ngrok in Functions and register the complete public URL ending in /functions/v1/stripe-webhook in your Stripe test webhook dashboard. Keep the tunnel running throughout checkout. A successful Stripe payment cannot unlock local access if this webhook is unreachable.

Copy the endpoint signing secret to the local STRIPE_WEBHOOK_SECRET, then select these events:

  • checkout.session.completed
  • checkout.session.async_payment_succeeded
  • charge.refunded
  • customer.subscription.updated
  • customer.subscription.deleted
  • invoice.paid
  • invoice.payment_failed

In production, replace the ngrok destination with the deployed stripe-webhook URL and use its live endpoint signing secret.

stripe-entitlements

Returns access for the signed-in user. It powers billing.hasAccess() and billing.requireAccess(), while Row-Level Security prevents users from reading another account's entitlements.

stripe-portal

Creates a Stripe Customer Portal session where users manage payment methods, subscriptions, and cancellations.

stripe-catalog

Returns active Stripe products and prices for a pricing screen that stays synchronized with the Stripe dashboard.

const plans = await billing.catalog();
// [{ priceId, name, amount: 19900, currency: "eur", interval: null, ... }]

Next

See the Stripe integration for the frontend billing API. Try the Stripe + Auth Starter for a full walkthrough. Set production keys before going live.