Checkout.js is an embeddable checkout widget for taking payments and pre-orders on any website.
Category: Hanzo Ecosystem Related Skills: hanzo/hanzo-commerce.md, hanzo/hanzo-commerce-api.md
Checkout.js is an embeddable checkout widget for taking payments and pre-orders on any website. It renders a modal overlay with payment collection (Stripe and PayPal), shipping address, tax/shipping rate calculation, promo codes, and a thank-you screen with social sharing. Written in CoffeeScript using Riot.js 3 for UI components and Jade templates. Communicates with the Hanzo Commerce API via hanzo.js (now crowdstart.js).
shortcake)requisite (CommonJS bundler)checkout.js v2.1.21Repo: github.com/hanzoai/checkout.js (branch: master, 96 stars).
| Item | Value | |------|-------| | npm package | checkout.js | | Version | 2.1.21 | | Default branch | master | | License | BSD-3-Clause | | Language | CoffeeScript | | UI framework | Riot.js 3.0.7 | | API client | hanzo.js (aliased as crowdstart.js) | | CDN | cdn.rawgit.com/hanzoai/checkout.js/v2.1.21/checkout.min.js | | Repo | github.com/hanzoai/checkout.js |
<a class="btn" href="#checkout">Buy Now</a>
<script src="https://cdn.rawgit.com/hanzoai/checkout.js/v2.1.21/checkout.min.js"></script>
<script>
var Checkout = window.Crowdstart.Checkout
var checkout = new Checkout('your-hanzo-api-key', {
config: {
currency: 'usd',
processors: { stripe: true, paypal: false },
showPromoCode: true,
termsUrl: 'https://example.com/terms'
},
order: {
currency: 'usd',
items: []
},
user: {
email: '',
firstName: '',
lastName: ''
},
thankyou: {
header: 'Thank You!',
body: 'Check your email for the order confirmation.',
twitter: 'hanaboroai',
facebook: 'hanzoai'
},
theme: {
background: 'white',
calloutBackground: '#27AE60',
fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif",
borderRadius: 5
}
})
// Add items by product ID or slug
checkout.setItem('84cRXBYs9jX7w', 1)
checkout.setItem('doge-shirt', 2)
// Open the widget
document.querySelector('.btn').addEventListener('click', function(e) {
e.preventDefault()
checkout.open()
})
</script>
npm install checkout.js
var Checkout = require('checkout.js')
var checkout = new Checkout('your-api-key', {
config: { currency: 'usd' }
})
checkout.setItem('product-slug', 1)
checkout.open()
┌─────────────────────────────────────────────────┐
│ Browser Page │
│ │
│ ┌─────────────┐ ┌────────────────────────┐ │
│ │ Buy Button │───>│ Checkout Modal (Riot) │ │
│ │ href=#checkout │ │ │
│ └─────────────┘ │ ┌──────────────────┐ │ │
│ │ │ Screen Manager │ │ │
│ │ │ - Payment │ │ │
│ │ │ - Shipping │ │ │
│ │ │ - Thank You │ │ │
│ │ └──────────────────┘ │ │
│ └───────────┬────────────┘ │
│ │ │
│ ┌───────────▼────────────┐ │
│ │ hanzo.js API Client │ │
│ │ (Crowdstart SDK) │ │
│ └───────────┬────────────┘ │
│ │ │
└─────────────────────────────────┼────────────────┘
│
┌───────────▼────────────┐
│ Hanzo Commerce API │
│ (api.hanzo.ai) │
└────────────────────────┘
The widget follows a three-step flow defined by script: ['payment', 'shipping', 'thankyou']:
Checkout - Main entry point. Instantiate with API key + options. Methods: open(), setItem(id, qty), setUser(user), update(), on(), off(), one()Widget - Root Riot.js tag that mounts the modalScreenManager - Controls navigation between payment/shipping/thankyou screensEvents - Event bus (via crowdcontrol) for inter-component communicationconfig - Payment processors, currency, promo code toggle, terms URL, call-to-action texttaxRates - Array of {taxRate, city, state, country} objects, matched in order (first match wins)shippingRates - Array of {shippingRate, city, state, country} objects, same matching logictheme - Colors (background, light, dark, error, progress, spinner), font family, border radiusthankyou - Header, body, social sharing handles (facebook, twitter, googlePlus, pinterest, email)analytics - Pixel tracking URLstest - Custom API endpoint, PayPal sandbox toggle| Package | Purpose | |---------|---------| | hanzo.js (crowdstart.js) | Hanzo Commerce API client | | riot 3.0.7 | Reactive UI components | | crowdcontrol | Event system for Riot | | card 2.1.1 | Credit card input formatting | | style-inject | Runtime CSS injection | | bebop | Dev server with live reload |
checkout.js/
checkout.js # Built bundle (1.1MB)
checkout.min.js # Minified bundle (245KB)
checkout.css # Built stylesheet (45KB)
package.json # npm config, v2.1.21
Cakefile # Build/test tasks
bebop.coffee # Dev server config
src/
index.coffee # Main Checkout class
events.coffee # Event definitions
data/
countries.coffee # Country list for shipping
currencies.coffee # Supported currencies
states.coffee # US state list
utils/
analytics.coffee # Tracking pixel helper
country.coffee # Country lookup
currency.coffee # Currency formatting
input.coffee # Input validation
theme.coffee # Dynamic theme injection
views/
widget.coffee # Root Riot tag
modal.coffee # Modal overlay
header.coffee # Widget header
screenmanager.coffee # Screen navigation
invoice.coffee # Order summary
lineitem.coffee # Single line item
confirm.coffee # Order confirmation
promo.coffee # Promo code input
tabs.coffee # Payment method tabs
controls/ # Form input controls
screens/
screen.coffee # Base screen class
payment.coffee # Credit card / PayPal entry
shipping.coffee # Address form
thankyou.coffee # Post-purchase screen
choose.coffee # Payment method selection
paypal.coffee # PayPal-specific flow
templates/ # Jade templates for each view
css/ # Stylus source files
vendor/ # Vendored JS/CSS (select2)
examples/
basic/ # Basic HTML integration example
test/
test.coffee # Selenium WebDriver tests
widget.html # Test harness HTML
ci-config.coffee # Cross-browser CI config
| Issue | Cause | Solution | |-------|-------|----------| | Widget does not open | Button href not #checkout or open() not called | Use checkout.open() or set button href="#checkout" | | Products not loading | Invalid product ID/slug | Verify product exists in Hanzo Commerce API | | Stripe not working | Stripe processor disabled in config | Set config.processors.stripe: true | | PayPal sandbox | Test mode not enabled | Set test.paypal: true in options | | Old Node.js version | Requires Node >= 4.0.0 | Upgrade Node.js | | Build fails | Missing CoffeeScript | Run npm install to get devDependencies |
hanzo/hanzo-commerce.md - Hanzo Commerce frontendhanzo/hanzo-commerce-api.md - Hanzo Commerce API backendhanzo/hanzo-form.md - Form validation/submission library (same era)Last Updated: 2026-03-13 Category: Hanzo Ecosystem Related: checkout, payments, ecommerce, widget, stripe, paypal Prerequisites: Hanzo API key, browser environment