Checkout
Create a checkout for exactly one plan or one-time credit pack.
const checkout = await usagey.checkout.create(
{
customerId: "cus_123",
creditPackId: "pack_credits_10k",
successUrl: "https://app.example.com/billing/success",
cancelUrl: "https://app.example.com/billing/cancel",
},
{ idempotencyKey: "credit-order-456" },
);
console.log(checkout.checkoutUrl);
Replace creditPackId with planId to create a subscription checkout. The customer, checkout target, provider connection, and API key must belong to the same Usagey environment.
The response includes the provider, Usagey transaction ID, provider external ID, checkout URL, and whether the operation was replayed.