/spree-commerce:spree-paymentsfrom spree-commerce
Integrates payment gateways with Spree, covering PaymentMethod model, v5.4+ PaymentSession checkout flow, Stripe (Apple/Google Pay, Connect), Adyen, PayPal, StoreCredit/GiftCard, refunds, payment state machine, and custom gateway authoring. Use when wiring payment integrations, handling webhooks, or debugging payment-state issues.
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::Payment source for state transitions and column names.| Model | Purpose |
|---|---|
PaymentMethod | Admin-configured way to pay (Stripe, Adyen, PayPal, StoreCredit, etc.). Per-store, per-currency. |
Payment | A specific payment attempt on an Order. Has a state, a source (CreditCard/StoreCredit/...), and an amount. |
PaymentSession (v5.4+) | Provider-agnostic envelope around a payment authorization. Wraps Stripe Payment Intents, Adyen sessions, PayPal orders. |
checkout → processing → pending → completed
↓
failed | void | invalid
checkout — initialized, waiting for captureprocessing — sent to gatewaypending — gateway accepted, awaiting async confirmation (3DS, ACH)completed — capturedfailed — declinedvoid — voided pre-captureinvalid — gateway returned an unparseable responseMost Payment rows have a polymorphic source:
Spree::CreditCard — tokenized card dataSpree::StoreCredit — user's store credit balanceSpree::GiftCard — gift card balanceSpree::PayPalCheckout::Order, etc.)POST /api/v3/store/checkout/payment_sessions with payment_method_id.PaymentSession, hits the gateway's session API (Stripe Payment Intent, Adyen /sessions, PayPal /v2/orders).POST /api/v3/store/checkout/complete.Payment and advances the order.Provider differences are hidden behind the PaymentSession envelope — the storefront code is gateway-agnostic above the UI layer.
payment_intent.succeeded, payment_intent.payment_failed, etc. routed to /webhooks/stripeRefund a captured Payment:
refund = Spree::Refund.create!(
payment: payment,
amount: payment.amount,
reason: Spree::RefundReason.first
)
refund.perform!
perform! hits the gateway's refund endpoint and updates the Payment#state if fully refunded.
Both work as native payment sources. The checkout state machine skips the payment step if store credit fully covers the order.
# Gemfile
gem 'spree_stripe'
# Then
bundle install
bin/rails g spree_stripe:install
bin/rails db:migrate
In admin → Settings → Payment Methods → Stripe → connect via OAuth (Stripe Express / Standard). Set webhook endpoint in Stripe dashboard to https://yourdomain/webhooks/stripe. Verify the env vars (STRIPE_API_KEY, STRIPE_PUBLISHABLE_KEY, STRIPE_WEBHOOK_SECRET) — check the README for the current naming.
// In a Server Action of the Next.js storefront
const session = await spree.checkout.createPaymentSession({
paymentMethodId: 'pm_stripe',
});
// session.clientSecret used by Stripe Elements
// session.dropInPayload used by Adyen Drop-in
(Verify against @spree/sdk docs.)
# app/models/my_app/payment_method/custom_gateway.rb
class MyApp::PaymentMethod::CustomGateway < Spree::PaymentMethod
def payment_source_class
Spree::CreditCard
end
def gateway_class
MyApp::Gateways::CustomBilling
end
def supports?(source)
source.is_a?(Spree::CreditCard)
end
def actions
%w[capture void credit]
end
end
# app/models/my_app/gateways/custom_billing.rb
class MyApp::Gateways::CustomBilling
def initialize(options = {})
@api_key = options[:api_key]
end
def authorize(amount_cents, source, options = {})
# Hit the gateway's authorize endpoint
# Return ActiveMerchant::Billing::Response.new(...)
end
def capture(amount_cents, authorization_token, options = {})
# …
end
def void(authorization_token, options = {})
# …
end
def credit(amount_cents, authorization_token, options = {})
# refund
end
end
Register the payment method type in an initializer:
Rails.application.config.spree.payment_methods << MyApp::PaymentMethod::CustomGateway
Spree gateway gems mount their own webhook routes (e.g., /webhooks/stripe). When customizing:
# Subscribe to Spree's own events after webhook processing
class PaymentSubscriber < Spree::Subscriber
subscribes_to 'payment.paid'
on 'payment.paid', :sync_to_accounting
end
Payment#state == 'pending' after authorize means the gateway is waiting for the customer to complete a challenge. The storefront polls or listens for the gateway's webhook, then either payment.complete! or payment.failure!.
Spree natively supports multiple Payment rows per order. The order updater allocates outstanding balance across them in order of creation. The order state machine completes only when sum(payments.completed) == order.total.
config/spree.rb — use Rails credentials or env vars.Payment#state = 'completed' — bypasses the gateway flow; reconciliation breaks.pk_test_ and sk_test_ must match; mixing modes silently fails.Always re-fetch the gateway gem's README before writing integration code — gateway APIs and Spree wrapper versions drift independently.
What SKILL.md sets; muted values are Claude Code's defaults
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.Other plugins' skills for the same job