/spree-commerce:spree-checkoutfrom spree-commerce
Implements Spree's checkout state machine (cart → address → delivery → payment → confirm → complete), Payment/Shipment sub-state machines, return flow (ReturnAuthorization → CustomerReturn → Reimbursement → Refund), guest checkout, and V3 checkout API. Use when building or debugging checkout flows or wiring custom steps.
Ships in spree-commerce. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Fetch live docs:
Spree::Order source on GitHub for the state_machine block — transitions and callbacks change.spree-starter.cart → address → delivery → payment → confirm → complete
↓
skip if store-credit-covered
Each transition validates prerequisites:
| State | Prerequisites |
|---|---|
cart | One or more line items |
address | Bill + ship address present |
delivery | Shipping method selected for every shipment |
payment | At least one payment method valid for the total |
confirm | Optional review step (configurable) |
complete | All sub-states valid; transitions trigger fulfillment + emails |
Order#payment_state is a separate field summarizing all Payment rows:
| Value | Meaning |
|---|---|
balance_due | Outstanding amount remains |
paid | Fully paid |
credit_owed | Refund pending |
failed | All payments failed |
void | Voided |
Order#shipment_state summarizes all Shipment rows:
| Value | Meaning |
|---|---|
pending | Awaiting payment / stock |
ready | Ready to ship |
partial | Some shipped |
shipped | All shipped |
backorder | Inventory shortfall |
canceled | Canceled |
Shipment#state: pending → ready → shipped (+ canceled)Payment#state: checkout → processing → pending → completed (+ failed, void, invalid)ReturnAuthorization (authorized | canceled)
→ CustomerReturn
→ Reimbursement (pending | reimbursed | errored)
→ Refund (against original Payment)
StoreCredit reimbursements skip the Refund step and credit the user's balance.
If order.outstanding_balance.zero? after store-credit/gift-card application, the state machine skips payment and goes straight to confirm. Useful for free-trial / 100%-off scenarios.
Spree supports guest checkout by default — orders carry an email and order_token even without a User. The token allows a guest to revisit their order. Convert guests to users post-checkout via Spree::Order#associate_user!.
Add a custom step by inserting into the state machine via decorator:
# app/models/spree/order_decorator.rb
module MyApp::OrderDecorator
def self.prepended(base)
base.state_machine.before_transition to: :delivery, do: :verify_gift_message
end
def verify_gift_message
# …
end
Spree::Order.prepend(self)
end
Custom steps are powerful but upgrade-fragile — Spree's state machine evolves. Prefer events or service objects when you only need to react.
Headless checkout typically:
POST /api/v3/store/cart — create cart (returns ord_… ID + cart token)POST /api/v3/store/cart/line_items — add itemsPUT /api/v3/store/checkout — set addresses, shipping method, payment methodPOST /api/v3/store/checkout/payment_sessions — create a PaymentSession (Stripe/Adyen/PayPal)POST /api/v3/store/checkout/complete — finalize(Verify exact paths in the v3 API reference — endpoint shapes are still settling.)
The v5.4 PaymentSession abstracts the payment-provider handshake. The storefront creates a PaymentSession, the user authorizes via the gateway's hosted UI (Stripe Elements, Adyen Drop-in, PayPal Checkout), and the session is captured into a Payment on completion. Provider-specific.
order.state # one of cart/address/delivery/payment/confirm/complete
order.payment_state # balance_due/paid/...
order.shipment_state # pending/ready/...
order.can_transition?(:complete) # check before triggering
order.next! # advance to the next state if valid
order.complete! # force to complete if valid (typically last step)
order.cancel! # cancel + revert inventory
Never call update_attribute(:state, …) directly — bypasses callbacks and corrupts inventory/payments.
class CheckoutSubscriber < Spree::Subscriber
subscribes_to 'order.completed'
on 'order.completed', :send_welcome_email
def send_welcome_email(event)
return if event.order.user.nil?
# …
end
end
Events fire after the database commit — safe to enqueue background jobs.
/complete — prevent double-charging on retry.order.errors.full_messages
order.valid?(state) # validate for a specific state
order.checkout_steps # configured step list
ra = Spree::ReturnAuthorization.create!(order: order, return_items: items)
ra.authorize!
cr = Spree::CustomerReturn.create!(return_items: ra.return_items, stock_location: location)
cr.fully_received?
reimbursement = Spree::Reimbursement.create!(customer_return: cr, order: order)
reimbursement.perform! # creates Refunds or StoreCredits
state directly → corrupts inventory and payment totals.Spree::OrderUpdater.completed manually → use the gateway's capture flow; manual completion skips reconciliation.confirm as required — it's configurable (checkout_steps order).Order#state. Re-fetch after every mutating call.state_machine — survives minor upgrades poorly; prefer event subscribers when possible.Always re-verify state names and transition guards against the live Spree::Order source for the version you target.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
spree, ecommerce-checkout, state-machine, payment-flow, order-management
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin spree-commerce22 skills in this plugin
/spree-admin-customizationCustomize the Spree v5 Admin Dashboard — Tailwind 4 + Hotwire/Turbo/Stimulus stack, the `Spree.admin.navigation` declarative API (v5.2+) for menu items, partial injection slots (`store_nav_partials`, `store_products_nav_partials`, `store_orders_nav_partials`, `settings_nav_partials`), the Admin SDK components + form builder, custom dashboard reports, the Page Builder for storefront editing, and theme management. Use when adding admin pages, injecting UI into existing screens, or building admin extensions./spree-api-v3Build with Spree's v3 APIs (v5.4+) — Store API at `/api/v3/store/*` (publishable key + per-user JWT, customer-facing) and Admin API at `/api/v3/admin/*` (per-user API keys + OAuth2 Doorkeeper, admin/operations). Covers the flat-JSON Stripe-like envelope, `?expand=` / `?include=` parameters, prefixed IDs (`prod_…`, `ord_…`), OpenAPI 3.0 spec, rate limiting, idempotency, and migration from v2 JSON:API. Use when building API clients, SDKs, or extending API endpoints in a Spree v5.4+ deployment./spree-catalogBuild and customize Spree's catalog — Products with Variants and OptionTypes/OptionValues, Taxonomies and Taxons (nested set), Properties, Images via ActiveStorage, multi-currency Prices, the v5.3+ PriceList feature for customer/segment overrides, MeiliSearch faceted search (v5.4+), product archiving/activation, CSV import/export, and SEO. Use when modeling products, customizing the catalog UI, indexing search, or importing inventory./spree-data-modelNavigate Spree's canonical data model — the Catalog (Product/Variant/OptionType/Taxon/Property/Metafield), Pricing (Price/PriceList), Order graph (Order/LineItem/Adjustment/Shipment/Payment/PaymentSession/Refund/Reimbursement), Inventory (StockLocation/StockItem/StockMovement), Shipping (ShippingMethod/Zone), Promotions, Identity (User/Role/Address/StoreCredit/GiftCard), Taxes, and the v5.4+ Markets + Store multi-region model. Use when designing a feature that touches Spree models, writing decorators, or building admin/storefront UIs./spree-deploymentDeploy Spree to production — PostgreSQL + Redis + Sidekiq stack, Docker multi-arch images on GHCR, the `spree-starter` Dockerfile + Compose, Heroku/Render/Fly.io/AWS targets, env-var conventions, RAILS_MASTER_KEY, asset precompilation (Tailwind 4 + Propshaft), Action Cable, MeiliSearch indexing, S3 / ActiveStorage for media, log/observability setup, zero-downtime deploys, and migration strategy. Use when going from local dev to production, scaling Spree, or troubleshooting deploys./spree-dev-patternsCross-cutting Spree development patterns — the customization preference hierarchy (Events > Webhooks > Dependencies > Decorators), `Spree::Dependencies` service-object swapping, the `_decorator.rb` + `prepend` + `self.prepended` idiom, idempotent subscribers and webhook receivers, multi-store scoping discipline, prefixed IDs, calculator polymorphism (shipping/promotion/tax share the base), service-object composition with `dry-monads` or simple results, why to avoid `class_eval` reopening and Deface, and Spree-on-Rails idioms (Hotwire/Turbo Stimulus, ActiveStorage, Action Cable, Sidekiq). Use when designing the architecture of a Spree extension or solving cross-cutting concerns.Other plugins' skills for the same job