Skip to main content
The StorefrontSchemas export provides TypeScript type definitions for all request and response schemas in the Storefront API.

Overview

The Storefront API schemas are automatically generated from the PayNow OpenAPI specification and provide type safety for customer-facing operations like browsing products, managing carts, and creating checkout sessions.
import type { StorefrontSchemas } from 'paynow';

type Cart = StorefrontSchemas['CartDto'];
type Product = StorefrontSchemas['StorefrontProductDto'];
type Customer = StorefrontSchemas['CustomerDto'];

Using Storefront Schemas

Typing API Responses

Use StorefrontSchemas to type data returned from Storefront API methods:
import { createStorefrontClient } from 'paynow';
import type { StorefrontSchemas } from 'paynow';

const client = createStorefrontClient({
  storeId: 'your-store-id',
  customerToken: 'customer-token'
});

const cart = await client.cart.get();
// cart is typed as StorefrontSchemas['CartDto']

const products = await client.products.list();
// products is typed as StorefrontSchemas['StorefrontProductDto'][]

Typing Request Payloads

Type your request payloads for better type safety:
import type { StorefrontSchemas } from 'paynow';

const checkoutRequest: StorefrontSchemas['CreateCheckoutSessionDto'] = {
  lines: [
    {
      product_id: '411486491630370816',
      quantity: 1,
      subscription: false
    }
  ],
  return_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel'
};

await client.checkouts.create(checkoutRequest);

Common Storefront Schemas

CartDto

Represents a customer’s shopping cart.
store_id
string
required
The Flake ID of the store
customer_id
string
required
The Flake ID of the customer
lines
CartLineDto[]
required
The line items in the cart
total
number
required
The total price of all items in the cart in the smallest currency unit (e.g., cents)
currency
string
required
The currency code (e.g., usd, eur, gbp)

CartLineDto

Represents a line item in a cart.
line_key
string
required
The unique key for this line item
product_id
string
required
The Flake ID of the product
name
string
required
The name of the product
slug
string
required
The slug of the product
price
number
required
The price of the product in the smallest currency unit (e.g., cents)
quantity
number
required
The quantity of this product in the cart
subscription
boolean
required
Indicates whether this line item should be a subscription
trial
boolean
required
Indicates whether this line will be trialed by the customer
image_url
string | null
The URL to the product image
custom_variables
CartLineCustomVariableDto[]
required
Selected custom variables for this cart line

CreateCheckoutSessionDto

Request to create a new checkout session.
lines
CreateCheckoutSessionLineDto[]
required
The line items to include in the checkout session
coupon_id
string
Optional coupon ID to apply a discount
affiliate_code
string | null
Optional affiliate code to track referrals
return_url
string | null
Optional URL to redirect to after successful checkout
cancel_url
string | null
Optional URL to redirect to if checkout is canceled
auto_redirect
boolean | null
Whether to automatically redirect the customer (return_url must be set)

CreateCheckoutSessionLineDto

Represents a line item in a checkout session request.
product_id
string
required
The Flake ID of the product
quantity
number
The quantity of the product (defaults to 1)
subscription
boolean | null
Determines whether this line should create a subscription
trial
boolean | null
Indicates whether the product should be trialed
gift_to
CustomerPlatformAccountDto
Optional recipient information for gifting
gift_to_customer_id
string
Optional customer ID to gift to

Schema Structure

The StorefrontSchemas type is derived from the OpenAPI components:
import type { components as StorefrontComponents } from './generated/storefront';

export type StorefrontSchemas = StorefrontComponents['schemas'];
This provides access to all schema definitions in the Storefront API, including:
  • Cart operations: CartDto, CartLineDto, CreateCartCheckoutSessionDto
  • Checkout operations: CreateCheckoutSessionDto, CheckoutSessionDto
  • Customer data: CustomerDto, AuthenticateStorefrontCustomerRequestDto
  • Product data: StorefrontProductDto, StorefrontProductPricingDetailsDto
  • Custom variables: CartLineCustomVariableDto, StorefrontCustomVariableOptionDto

Type Safety Benefits

Access all available schema properties with IntelliSense/autocomplete support.
Catch type errors during development before they reach production.
Types serve as inline documentation for API request and response structures.

Storefront Client

Learn about Storefront API methods

Management Schemas

Type definitions for Management API

Build docs developers (and LLMs) love