StackupDocs
Stackup

Checkout

Accept crypto payments through hosted checkout pages.

Methods

MethodDescriptionReturns
session.createCreate a new checkout sessionSession
session.getGet a session by IDSession

session.create

Type (parameters: { items: Array<{ product: string }> }) => Promise<Session>

Create a checkout session to get a URL for redirecting customers.

const session = await stackup.checkout.session.create({
  items: [{ product: "prd_01ABC123" }],
})

// Redirect user to checkout
window.location.href = session.data.url

session.get

Type (parameters: { id: string }) => Promise<Session>

Get a checkout session by its ID.

const session = await stackup.checkout.session.get({ id: "ses_01ABC123" })

Session Lifecycle

Sessions have three states:

  • open - Active and ready for payment (default)
  • completed - Payment succeeded
  • expired - Session timed out (24 hours from creation)

Payment Flow

  1. Customer visits the checkout URL
  2. Customer connects their wallet
  3. A PaymentIntent is created with the buyer's address
  4. Customer signs and sends the ERC-20 transfer
  5. Transaction is confirmed on-chain

If no customer is pre-assigned when creating the session, one is automatically created from the buyer's wallet address during payment.

Types

Session

PropertyTypeDescription
idstringUnique identifier
urlstringHosted checkout URL
status"open" | "completed" | "expired"Session state
productIDstringProduct being purchased
customerIDstring | nullOptional pre-assigned customer
expiresAtDateExpiration timestamp
timeCreatedDateCreation timestamp
timeUpdatedDateLast modification
timeDeletedDate | nullSoft delete timestamp

Errors

A list of errors that can be returned by the Checkout API.


SessionCreateErrors

The session creation request was invalid.

Status: 400 BadRequestError


SessionGetErrors

The session could not be retrieved.

Status: 400 BadRequestError, 404 NotFoundError