Skip to content

Stripe.Checkout reference

Source: src/Stripe/CreateCheckoutSession.ts

Create a Stripe Checkout Session over HTTP. This is how a Worker starts a purchase: create the session for a Price, then redirect the buyer to session.url. Stripe hosts the payment page and sends checkout.session.completed when it succeeds.

Account-scoped — binds the API key onto the host, not a specific resource.

CreateCheckoutSession: Starting a subscription checkout

Section titled “CreateCheckoutSession: Starting a subscription checkout”
const createCheckout = yield* Stripe.CreateCheckoutSession();
// inside a Worker route
const session = yield* createCheckout({
mode: "subscription",
line_items: [{ price: price.id, quantity: 1 }],
customer: customerId,
success_url: `${origin}/welcome`,
cancel_url: `${origin}/pricing`,
});
// redirect to session.url

Source: src/Stripe/CreateCheckoutSessionHttp.ts Kind: Layer · Provides: Stripe.CreateCheckoutSession

HTTP implementation of CreateCheckoutSession. Provide it on the Function or Worker Effect.

Source: src/Stripe/PaymentLink.ts

A Stripe Payment Link — a shareable URL that opens a hosted Checkout page. Requires at least one lineItems price. Quantity, metadata, active, and most Checkout options update in place; changing the set of prices replaces the link. Payment links cannot be deleted; destroy deactivates them (active=false).

One-time price

const product = yield* Stripe.Product("pro-plan", { name: "Pro Plan" });
const price = yield* Stripe.Price("pro-once", {
product: product.id,
currency: "usd",
unitAmount: 2000,
});
const link = yield* Stripe.PaymentLink("buy", {
lineItems: [{ price: price.id, quantity: 1 }],
});

Promotion codes and a confirmation message

const link = yield* Stripe.PaymentLink("buy", {
lineItems: [{ price: price.id, quantity: 1 }],
allowPromotionCodes: true,
afterCompletion: {
type: "hosted_confirmation",
hostedConfirmation: { customMessage: "Thanks for your order." },
},
metadata: { campaign: "launch" },
});
const link = yield* Stripe.PaymentLink("buy", {
lineItems: [{ price: price.id, quantity: 2 }],
active: false,
inactiveMessage: "This link is no longer available.",
metadata: { campaign: "paused" },
});

Source: src/Stripe/RetrievePaymentLink.ts

Retrieve a bound Stripe Payment Link over HTTP.

Section titled “RetrievePaymentLink: Reading a Payment Link”
const retrieve = yield* Stripe.RetrievePaymentLink(checkout);
const live = yield* retrieve();

Source: src/Stripe/RetrievePaymentLinkHttp.ts Kind: Layer · Provides: Stripe.RetrievePaymentLink

HTTP implementation of RetrievePaymentLink. Provide it on the Function or Worker Effect.