Vatly
JavaScript SDK

Checkouts

Checkouts create hosted payment pages for your customers.

Checkouts create hosted payment pages for your customers. When a checkout completes successfully, an Order is created.

For all fields and options, see the Checkouts API reference. The OpenAPI spec is also available for tooling.

The Checkout resource

NameTypeDescription
idstringUnique identifier for the checkout (checkout_…).
resourcestringAlways checkout.
statusstringcreated, paid, canceled, failed, or expired.
customerIdstring | nullThe customer this checkout is for, if known.
orderIdstring | nullOrder ID, available after successful payment.
redirectUrlSuccessstringWhere the customer returns on success.
redirectUrlCanceledstringWhere the customer returns on cancel.
metadataobject | nullYour custom key/value metadata.
expiresAtstring | nullExpiration timestamp (ISO 8601).
createdAtstringCreation timestamp (ISO 8601).
testmodebooleanWhether this is a test checkout.
links.checkoutUrlLinkThe hosted page to send the customer to.

Create a checkout

POST /v1/checkouts

Required attributes

NameTypeDescription
productsarrayProduct items to sell. Each item is { id, quantity }, where id is a subscription_plan_… or one_off_product_… id.
redirectUrlSuccessstringSuccess redirect URL.
redirectUrlCanceledstringCancel redirect URL.

Optional attributes

NameTypeDescription
customerIdstringAttach the checkout to an existing customer.
metadataobjectCustom metadata echoed back on the checkout and resulting order.
const checkout = await vatly.checkouts.create({
  redirectUrlSuccess: "https://yourapp.com/success",
  redirectUrlCanceled: "https://yourapp.com/canceled",
  products: [{ id: "subscription_plan_abc123", quantity: 1 }],
  customerId: "customer_abc123",
  metadata: { signupId: "su_42" },
});

// Send the customer here:
redirect(checkout.links.checkoutUrl.href);

Retrieve a checkout

GET /v1/checkouts/{checkoutId}

const checkout = await vatly.checkouts.get("checkout_abc123");

List checkouts

GET /v1/checkouts

const page = await vatly.checkouts.list({ limit: 25 });

for await (const checkout of vatly.checkouts.listAll()) {
  // ...
}
Copyright © 2026