Create a Quick Checkout

The quick checkout endpoint offers you a simple way to create a Stripe Checkout in a single API call without having to create a Cart. This is ideal for payments that will only ever include a single Plan at purchase.

Create the checkout

Call POST /api/checkout with the parameters set in the table below. The response contains a data.url which will be the Stripe Checkout you redirect the customer to.

The checkout can be assigned a Grantee, which is the ID of an entity in your system that will gain access through the Subscription, like a user or a Salable Group ID (prefixed `grp_`) for a team. Once the customer completes checkout and the Subscription is active, every Entitlement attached to the Plan is granted to the Grantee; to check this in your code, perform an [entitlement check](/docs/check-entitlements).
ParameterDescription
planIdThe ID of the Plan being purchased.
ownerThe tenant the purchase belongs to, like a team or organisation ID. If your application is single-user, use the user ID. Cannot be an email address.
intervalday, week, month, year, or null when every Line Item on the Plan is one-off.
intervalCountThe number of intervals between billing cycles, or null when every Line Item on the Plan is one-off.
granteeOptional. The ID of the entity in your system, like a user ID or a workspace ID. Use a Salable Group ID (prefixed grp_) when the Plan has a per-seat Line Item. When not providing a Salable Group ID, a new Group containing the entity's ID is created for the owner
metadataOptional. To override default quantities, key the object by Line Item slug with a value of { quantity: N }.
successUrlOptional. Where Stripe redirects after successful payment. Falls back to the url in the Plan's Product settings if set, otherwise it will use a Salable hosted page.
cancelUrlOptional. Where the customer returns if they abandon checkout. Falls back to the url in the Plan's Product settings if set, otherwise it will use a Salable hosted page.
import { Salable } from '@salable/sdk';
const salable = new Salable(process.env.SALABLE_SECRET_KEY);
 
const { data } = await salable.api.checkout.post({
    planId: 'plan_01HXYZ...',
    owner: 'company_acme',
    grantee: 'user_alice',
    interval: 'month',
    intervalCount: 1,
    successUrl: 'https://yourapp.com/welcome',
    cancelUrl: 'https://yourapp.com/pricing'
});
 
return data.url; // https://checkout.stripe.com/c/pay/cs_live_...

If not provided in the metadata, a Line Item's quantity will default to its minimum. However, if the grantee is set to a Salable Group ID (prefixed grp_) the per-seat Line Item will instead default to the larger of the Group's member count or the minimum quantity. A Group's member count cannot exceed a Line Item's maximum quantity.

Pass metadata to override defaults per Line Item, for example, explicitly setting ten seats on a per-seat Line Item or eight hours of consultancy on a flat-rate Line Item. A Line Item with a fixed number of seats cannot take a quantity at all, so leave it out of metadata entirely.

Note: Metered Line Items cannot have a quantity and therefore cannot be overridden in metadata.

One-off Line Items are included automatically as part of Plans that also include recurring Line Items, so a monthly subscription bundled with a one-off setup fee is bought as one Plan at the interval you send. Only a Plan whose Line Items are all one-off is treated as one-off, that's when you send interval and intervalCount as null.

A Cart is created with a single Cart Item behind the scenes, these can be accessed via GET /api/carts or the Carts section in the dashboard. This means everything after payment matches the Cart flow: if a Subscription is created a subscription.created event is emitted and if a reciept is created a receipt.created event is emitted.