Live checkout
Two-column subscription checkout with plan radio cards, 1-500 seat stepper, monthly/yearly billing toggle, checkbox add-ons, coupon codes, country tax and postal validation, card inputs, rolling summary amounts, and receipt morph.
import { CheckoutLive } from '@uthereal/ui/checkout-live'Checkout live playground
Checkout
Overview
CheckoutLive provides a complete two-column SaaS subscription checkout whose sticky order summary recomputes on every edit. On the left column, buyers pick an express wallet or choose a plan, switch between monthly and yearly billing (showing the configured savings badge), step seats from 1 to 500, toggle flat-priced add-ons, select their billing country, and fill address and card fields with live Luhn, expiry, CVC, and country-specific postal validation.
On the right column, the sticky summary rolls every line item, subtotal, coupon discount, country tax, and total in tabular numerals. When payment succeeds, the form steps aside and the summary glides to the center of the container, folding the coupon away and unfolding into a receipt with order metadata, a Receipt PDF download button, and Start over.
Use CheckoutLive for paid signups and self-serve plan upgrades where seats, add-ons, and country taxes affect the charge on the same screen. For a compact single-product confirmation card before a hosted redirect, use Checkout summary. For adjusting seats on an active subscription, use Seat manager.
Usage
'use client'
import { CheckoutLive } from '@uthereal/ui/checkout-live'
export function UpgradeCheckout() {
return (
<CheckoutLive
defaultPlan="team"
defaultSeats={12}
defaultBilling="yearly"
validateCoupon={async (code) => {
const res = await fetch(`/api/coupons/${encodeURIComponent(code)}`)
return res.json()
}}
onPay={async (order) => {
const res = await fetch('/api/subscribe', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify(order),
})
if (!res.ok) {
throw new Error('Your card was declined. Try another card.')
}
}}
/>
)
}Omit validateCoupon and onPay to run the built-in local simulation (nothing leaves the browser: LAUNCH20 and TEAM10 apply sample percent discounts, Use test card fills a passing Visa 4242, and 4000 0000 0000 0002 simulates a card decline). In production, replace client card inputs with your payment processor's hosted fields and treat client totals as a preview.
Examples
European Enterprise workspace in EUR
Supply custom EU plans, add-ons, and European VAT countries (DE, FR, NL, CH) with currency="EUR", locale="de-DE", and defaultAddons={['sso', 'audit']} to preview localized formatting, 25% annual savings, and live VAT updates when switching countries.
Enterprise checkout
Pricing, validation, and receipt flow
Price computation
| Line | Formula |
|---|---|
| Factor | 1 for monthly billing; 12 × (1 - yearlyDiscount) for yearly billing. |
| Seats | round(plan.seat × seats × factor) (prices are monthly cents). |
| Add-ons | Each checked add-on adds round(addon.monthly × factor). |
| Discount | round(subtotal × coupon.percent / 100) when a coupon is applied. |
| Tax | round((subtotal - discount) × country.rate). Shows "Not charged" when rate is 0. |
Inline field validation
| Field | Rule |
|---|---|
Standard email pattern (name@company.com). | |
| Address | Name ≥ 2 chars, street ≥ 3 chars, non-empty city, and postal matched against country.postal. |
| Card | Auto-formatted 4-4-4-4 (Amex 4-6-5), brand detection (Visa, Mastercard, Amex), Luhn check. |
| Expiry | MM/YY auto-slash formatting, valid month (01–12), and not expired. |
| CVC | 4 digits for Amex, 3 digits for all other cards. |
Submitting with invalid fields reveals every error inline and moves focus directly to the first invalid input.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
title | stringDefault: "Checkout" | Page heading above the two columns. Pass an empty string (or null in React) to hide it. |
plans | CheckoutPlan[]Default: [{"id":"starter","name":"Starter","seat":1200,"blurb":"Core docs and boards"},{"id":"team","name":"Team","seat":2400,"blurb":"Automations and guests"},{"id":"business","name":"Business","seat":4200,"blurb":"Audit, SLAs, and admin"}] | Plans offered as radio cards with an id, name, monthly seat price in cents, and a short blurb. Defaults to Starter, Team, and Business. |
addons | CheckoutAddon[]Default: [{"id":"support","name":"Priority support","detail":"Four hour response","monthly":4900},{"id":"sso","name":"SSO and SCIM","detail":"Okta, Entra ID, Google","monthly":9900},{"id":"audit","name":"Extended audit log","detail":"Two year retention","monthly":2900}] | Optional add-ons with a flat monthly price in cents, offered as checkboxes. Defaults to Priority support, SSO and SCIM, and Extended audit log. |
countries | CheckoutCountry[]Default: [{"code":"DE","name":"Germany","rate":0.19,"taxLabel":"VAT 19%","postal":"^\\d{5}$","postalHint":"Use five digits"},{"code":"US","name":"United States","rate":0,"taxLabel":"Sales tax","postal":"^\\d{5}(-\\d{4})?$","postalHint":"Use a five digit ZIP code"},{"code":"GB","name":"United Kingdom","rate":0.2,"taxLabel":"VAT 20%","postal":"^[A-Z]{1,2}\\d[A-Z\\d]? ?\\d[A-Z]{2}$","postalHint":"Use a UK postcode like SW1A 1AA"},{"code":"CH","name":"Switzerland","rate":0.081,"taxLabel":"VAT 8.1%","postal":"^\\d{4}$","postalHint":"Use four digits"},{"code":"CA","name":"Canada","rate":0.13,"taxLabel":"HST 13%","postal":"^[A-Z]\\d[A-Z] ?\\d[A-Z]\\d$","postalHint":"Use a postal code like M5V 2T6"},{"code":"AU","name":"Australia","rate":0.1,"taxLabel":"GST 10%","postal":"^\\d{4}$","postalHint":"Use four digits"}] | Billing countries with a tax rate, tax label, postal code pattern, and a hint shown when the postal code does not match. Defaults to a six-country sample. |
defaultPlan | stringDefault: "team" | Plan selected on mount. Must match one of plans. |
defaultSeats | integerDefault: 8 | Seats on mount, from 1 to 500. |
defaultBilling | monthly | yearlyDefault: "yearly" | Billing period on mount. |
defaultAddons | string[]Default: ["support"] | Add-on ids selected on mount. Must match ids in addons. |
yearlyDiscount | numberDefault: 0.2 | Discount for yearly billing, from 0 to 1. Shown on the billing toggle. |
currency | stringDefault: "USD" | ISO 4217 code used to format every amount, e.g. "USD". |
seatsLabel | stringDefault: "Seats" | Label for the seat stepper. |
expressLabel | stringDefault: "Express checkout" | Screen-reader heading over the express wallet row. |
cardLabel | stringDefault: "Card" | Heading of the card section. |
billingLabel | stringDefault: "Billing details" | Heading of the address section. |
addonsLabel | stringDefault: "Add-ons" | Heading of the add-on section. |
planLabel | stringDefault: "Plan" | Heading of the plan section. |
summaryLabel | stringDefault: "Order summary" | Heading of the sticky summary card. |
paidLabel | stringDefault: "Payment successful" | Summary heading after a successful charge. |
payLabel | stringDefault: "Pay" | Pay button text; the total rolls beside it. |
processingLabel | stringDefault: "Processing" | Pay button text while a charge is in flight. |
payAction | string— | Registered host action requested when the user activates the pay button. |
applyCouponAction | string— | Registered host action requested when the user applies a coupon code. |
downloadReceiptAction | string— | Registered host action requested when the user activates Receipt PDF on the receipt. |
startOverAction | string— | Registered host action requested when the user activates Start over on the receipt. |
useTestCardLabel | stringDefault: "Use test card" | Text of the affordance that fills the sample card. |
secureNote | stringDefault: "Simulated payment. No card is charged." | Reassuring note under the pay button. |
couponLabel | stringDefault: "Add coupon" | Text of the control that opens the coupon field. |
couponPlaceholder | stringDefault: "Code" | Placeholder of the coupon code field. |
applyCouponLabel | stringDefault: "Apply" | Text of the button that checks the coupon code. |
locale | string— | BCP 47 locale for currency, dates, and the receipt; inherited from the page when omitted. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve interaction behavior. |
theme | CheckoutLiveThemeDefault: {} | Color mode, accent, and typed semantic token overrides. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | CheckoutLiveMotionOptionsDefault: {} | Amount roll, line height, highlight travel, and receipt glide timing overrides in milliseconds. |
dir | ltr | rtl— | Reading direction; inherited from the page when omitted. |
CheckoutPlanaccepts{ id, name, seat, blurb }, whereseatis monthly price per seat in cents. Plan IDs must be unique and includedefaultPlan.CheckoutAddonaccepts{ id, name, detail, monthly }, wheremonthlyis flat monthly price in cents. Add-on IDs must be unique and include every ID indefaultAddons.CheckoutCountryaccepts{ code, name, rate, taxLabel, postal, postalHint }, wherepostalis an anchored regular expression string compiled bycountryPattern.
React integration
| Prop | Purpose |
|---|---|
title | Overrides the heading above the two columns; pass "" or null to omit it. |
validateCoupon(code) | Validates a coupon code (sync or async) returning { ok: true, code, percent } or { ok: false, message }. |
onPay(order) | Charges the CheckoutOrder (all amounts in cents). Throw an Error to display its message above the pay button. |
onAction(action, itemId?) | Called for payAction, applyCouponAction (with the coupon code), downloadReceiptAction, and startOverAction. |
portalContainer | Portal target forwarded to the country selector menu. |
preset | Application defaults overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme, forwarded to the root section and portalled country menu. |
ref, className, style | Applied to the root <section> element. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root element. |
Keyboard & accessibility
| Key | Action |
|---|---|
Tab | Moves through express wallets, billing toggle, plan cards, stepper, add-ons, fields, and pay. |
ArrowLeft / ArrowRight | Moves between plan radio cards (also ArrowUp / ArrowDown) with roving tabIndex. |
Enter | Submits the checkout form or applies the coupon code from the coupon field. |
Escape | Closes the open coupon form and clears coupon errors. |
- Billing periods and plans expose
role="radiogroup"withrole="radio"andaria-checked; add-ons use native checkboxes. - Every field error connects via
aria-invalidandaria-describedbywithrole="alert"; failed submission focuses the first invalid input. - Every rolling
Amountpairsaria-hidden="true"digits with a visually hidden full formatted value so screen readers never read isolated digits. - After payment succeeds, focus moves cleanly to the receipt heading (
tabIndex={-1}), and a pre-mounted politerole="status"live region announces coupon changes, validation failures, payment outcomes, PDF saves, and resets. - Container queries switch from two columns to a single column with a collapsible summary header below
760px, and stack plan cards, express wallets, and two-column field grids below520px. Logical CSS properties mirror cleanly in RTL (dir="rtl"), and@media (forced-colors: active)preserves rings, checks, buttons, and errors.
Motion & theming
Every summary and button figure rolls through RollingNumber, the active billing pill and plan selection ring travel across options on shared layoutId morph springs, and add-on/discount/error lines open on a bounce-free height spring. On success, the form exits aside while the summary glides to center on a layout="position" spring and draws the receipt check stroke.
Under prefers-reduced-motion: reduce, layout travel, springs, blur swaps, and press scales turn off while crossfades shorten to 120ms opacity transitions and spinners slow to 1.6s. Setting motion="none" makes every transition immediate (0ms) and stops spinner animation.
theme accepts mode, accent, and typed tokens across these groups:
| Token group | CSS custom properties |
|---|---|
core | --ui-surface, --ui-surface-raised, --ui-text, --ui-text-secondary, --ui-muted, --ui-border, --ui-highlight, --ui-accent, --ui-accent-foreground, --ui-danger, --ui-focus-ring, --ui-radius, --ui-border-width, --ui-shadow, --ui-disabled-opacity, --ui-font, --ui-font-size, --ui-font-weight |
extended | --ui-surface-sunken, --ui-border-strong, --ui-border-subtle, --ui-track, --ui-info, --ui-success, --ui-warning, --ui-tone-foreground, --ui-overlay, --ui-tint-strength |
shape | --ui-radius-sm, --ui-popup-radius, --ui-surface-radius |
accentTones | --ui-accent-strong, --ui-accent-subtle |
control | --ui-control-height, --ui-control-padding-x, --ui-control-gap, --ui-icon-size |
selectionControl | --ui-control-on, --ui-control-glyph, --ui-track, --ui-control-track-hover, --ui-control-thumb, --ui-control-thumb-on, --ui-control-fill, --ui-shadow-thumb |
elevation | --ui-shadow-resting, --ui-shadow-raised |
type | --ui-font-mono, --ui-font-display |
An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, CheckoutLive is a leaf block. Express plan and add-on prices in monthly cents, keep defaultPlan and defaultAddons aligned with configured IDs, and wire payAction, applyCouponAction, downloadReceiptAction, and startOverAction to registered host actions. See Building with agents.
{
"type": "CheckoutLive",
"props": {
"title": "Checkout",
"defaultPlan": "team",
"defaultSeats": 10,
"defaultBilling": "yearly",
"yearlyDiscount": 0.2,
"currency": "USD",
"payAction": "submit_subscription_checkout",
"applyCouponAction": "apply_checkout_coupon"
},
"children": []
}