Checkout
Accept crypto payments through hosted checkout pages.
Methods
| Method | Description | Returns |
|---|---|---|
| session.create | Create a new checkout session | Session |
| session.get | Get a session by ID | Session |
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.urlsession.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
- Customer visits the checkout URL
- Customer connects their wallet
- A PaymentIntent is created with the buyer's address
- Customer signs and sends the ERC-20 transfer
- 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
| Property | Type | Description |
|---|---|---|
| id | string | Unique identifier |
| url | string | Hosted checkout URL |
| status | "open" | "completed" | "expired" | Session state |
| productID | string | Product being purchased |
| customerID | string | null | Optional pre-assigned customer |
| expiresAt | Date | Expiration timestamp |
| timeCreated | Date | Creation timestamp |
| timeUpdated | Date | Last modification |
| timeDeleted | Date | null | Soft 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