Skip to main content

Overview

Spree provides two stored value mechanisms that customers can use at checkout:
  • Store Credits - Value assigned directly to a customer’s account by admins (refunds, loyalty rewards, compensation)
  • Gift Cards - Value with a redeemable code that can be shared and redeemed by anyone

Store Credits

Store Credits are monetary values assigned directly to a customer’s account. They are commonly used for:
  • Refunds (instead of returning money to original payment method)
  • Loyalty rewards
  • Customer compensation
  • Promotional credits

Store Credit Model

Store Credit Attributes

Why a Credit Exists

Store credits carry no category and no type. Two fields cover it instead: Store credits do not expire; only gift cards carry an expiry, on their own record. Which credit is spent first is decided by Spree::StoreCredit.oldest_first.
Spree::StoreCreditCategory and Spree::StoreCreditType still exist as deprecated shells for compatibility. Nothing writes them.

Store Credit Events

Every action on a store credit is recorded as an event for audit purposes:

Assigning Store Credits

Store credits are managed in the Admin Panel:
  1. Navigate to Customers in the Admin Panel
  2. Select a customer
  3. Go to the Store Credits tab
  4. Click Add Store Credit
  5. Enter the amount, currency, and optional memo
  6. Click Create
Store credits can also be created via the Admin API, as a nested resource under the customer:

Listing Store Credits Across Customers

Credits are written per customer, but read across them. The Admin API exposes a read-only list so an integration can answer what the store owes without walking every customer:
Filters mirror the questions a merchant asks: customer_id, customer_email_cont, currency, created_by_id, memo_cont, a created_at range, and two scopes — outstanding (money still owed versus money spent) and from_gift_card (whether a gift card redemption created it). Each credit’s ledger is its own endpoint:
Creating, updating and deleting a credit remain nested under the customer that holds it — a credit without an owner has nobody to pay.

Store Credit Events

The store credit system publishes lifecycle events:

Gift Cards

Gift Cards are stored value codes created by admins that can be shared and redeemed by customers. When redeemed, they create a Store Credit on the customer’s account.

Gift Card Model

Gift Card Attributes

Gift Card Statuses

Redemption does not need the caller to choose: Spree::GiftCards::Redeem looks at what is left on the card and marks it partially or fully redeemed accordingly. A card can be partially redeemed more than once, and each spend publishes its own event. Money an order took from a card goes back to the card when that order is cancelled, or when its gift card payment is voided or refunded. The card’s amount_used drops by that amount. A redeemed or partially redeemed card becomes active again once nothing is drawn against it, and partially_redeemed while something still is. The store credit made from the card is credited too, but it never adds to the customer’s own store credit balance, so the money is returned once. Cancelling is refused once a card has been spent against, so cancellation can never take back value a customer has already used. Deleting a card is refused the same way. A card applied to an open cart or draft order cannot be deleted from the model directly, because the store credit made from it would keep paying for that order with no card behind it. Delete a card with Spree::GiftCards::Destroy (Spree.gift_card_destroy_workflow), which the Admin API delete uses. It takes the card off those carts and draft orders first (through Spree.gift_card_remove_workflow, which voids the store credit payment), so a card left on an abandoned cart can still be deleted. It refuses only while a checkout is completing with the card.
Gift cards can also be expired if expires_at date has passed and the card hasn’t been fully redeemed.

Gift Card Lifecycle

Creating Gift Cards

Single Gift Card

  1. Navigate to Gift Cards in the Admin Panel
  2. Click Create Gift Card
  3. Enter the amount and optional expiration date
  4. Click Create
  5. Share the generated code with the recipient
Gift cards can also be created via the Admin API. The code is generated automatically if you don’t supply one:

Batch Gift Card Generation

For promotions or bulk distribution, you can create multiple gift cards at once using Gift Card Batches:
  1. Navigate to Gift Cards in the Admin Panel
  2. Click Create Batch
  3. Enter:
    • Prefix - Code prefix for easy identification (e.g., HOLIDAY)
    • Count - Number of cards to generate
    • Amount - Value per card
    • Expiration - Optional expiration date
  4. Click Create
Batches can also be created via the Admin API:
Large batches are processed in the background to avoid timeout issues.

Redeeming Gift Cards

Gift cards can be redeemed by both registered customers and guest visitors at checkout. This is a key difference from Store Credits, which require a customer account.
Unlike Store Credits which are tied to a customer account, Gift Cards can be applied directly to an order during checkout - no account required. This makes them ideal for gifting to anyone.
When a gift card is applied to an order:
  • The gift card value is used to pay for the order
  • The gift card is marked as redeemed (or partially redeemed)
  • No Store Credit is created for guest checkouts
Gift cards are applied via a dedicated POST /api/v3/store/carts/:cart_id/gift_cards endpoint (separate from the discount_codes endpoint used for promotion codes); the discount-codes endpoint does not handle gift cards. See the cart & checkout SDK guide for the full cart flow these calls belong to.

Selling Gift Cards

A product with gift_card: true sells gift cards: each variant is a denomination, and its price is the card’s face value. The flag is the single switch for everything that does not apply to prepaid money. The product skips inventory tracking, tax (with every tax provider), promotions, manual discounts and price lists, moves to the store’s digital delivery profile, and cannot belong to a seller. A purchase containing one cannot be paid with a gift card or store credit. A shopper names who a card is for when adding it to the cart. The recipient is optional; without it the code goes to the order’s email. Two adds of the same denomination for different recipients make two lines.
Cards are issued by Spree::GiftCards::IssueFromOrder once the order is paid in full: at order.placed when checkout already took the payment, otherwise at order.paid. An order with a pending offline payment has no spendable code until that payment settles. It creates one card per unit, records the line item on each card, and is safe to run again. The store preference gift_card_default_validity_days sets when bought cards expire; empty means never. Each card publishes gift_card.issued, which spree_emails uses to email the code to the recipient (at send_at when one was chosen). The buyer’s order shows the cards masked under each line’s gift_cards. Canceling the order with a refund, or refunding a return that holds a gift card line, cancels the cards nobody has spent from. A line that issued cards cannot be removed from the order. A card already partly or fully spent is left alone.

Gift Card Events

The gift card system publishes lifecycle events:

Using at Checkout

Store Credits and Gift Cards work differently at checkout:
  • Store Credits - Require a customer account; applied from the customer’s balance
  • Gift Cards - Can be used by anyone (guests included); applied directly to the order via code
Both are applied before the customer chooses how to pay, and neither appears among the cart’s payment methods. An order uses one or the other, never both. A gift card covers as much of the total as its balance allows and keeps up as the total changes. See the cart & checkout SDK guide for the calls.

Checkout Flow

Store Credit Priority

When a registered customer holds several store credits, the oldest is spent first (Spree::StoreCredit.oldest_first). Store credits do not expire — only gift cards carry an expiry, on their own record.