# Stored value tools

[All tool areas](/docs/tools.md). Each tool acts within your access.

## Stored value

### redeem_stored_value

Take a gift certificate or a credit as payment on a confirmed booking with a balance due, at the desk or on the phone: its code (a gift certificate's is 12 characters, a credit's 10) and an optional `amount` in minor units (left out: as much as is owed, up to what's left on it). Only money-like value: a purchased gift certificate, or a credit given instead of a refund. A promotional gift certificate or a goodwill or service recovery credit comes off before tax, so it's refused here: the guest uses it when booking online. Another entity's, another currency's, voided, expired, or used up is refused in words, as is a booking with nothing owed, one still waiting on its online payment, a canceled one, and a gift certificate purchase. Needs orders:amounts as well as bookings:write. The guest is emailed a receipt when the booking has an address. Undo puts it back on the gift certificate or credit within 15 minutes, until something else is paid or refunded on the booking. Returns a preview to confirm; applying it is refused if what's owed or what's left on it has changed since.

Changes · Members of an organization · Needs bookings:write, orders:amounts

#### Input

- `orderId` — string; required. The order's id, from list_bookings or list_orders
- `code` — string; required. The gift certificate's code (12 characters, ABCD-EFGH-JKLM) or the credit's (10 characters), as the guest gives it: any case, dashes and spaces ignored minLength: 1; maxLength: 40
- `amount` — integer; optional. Minor units in the order's currency. Left out: as much as the balance due, up to what's left on it exclusiveMinimum: 0
- `invoiceId` — string; optional. The invoice it pays (ivc_…). Required when the booking has more than one invoice with something owed; with one, it goes to that one. The amount is capped by both the invoice's balance and the booking's

#### Output

- `payment` — object; required. 
  - `payment.id` — string; required. The payment, pay_…
  - `payment.orderId` — string; required. 
  - `payment.tender` — string; required.  Allowed: "gift\_certificate", "credit"
  - `payment.source` — string; required.  Allowed: "gift\_certificate", "credit"
  - `payment.code` — string; required. The gift certificate's or credit's code, masked: ••••JKLM
  - `payment.amount` — integer; required. Minor units (cents) in the location's currency
  - `payment.currency` — string; required. 
  - `payment.balanceAfter` — integer; required. What's left on the gift certificate or credit after it
  - `payment.createdAt` — string; required.  format: "date-time"
- `order` — object; required. The booking as list_bookings shows it, after the payment: balanceDue and paymentStatus
  - `order.id` — string; required. 
  - `order.code` — string; required. The booking code guests quote
  - `order.status` — string; required.  Allowed: "pending", "confirmed", "canceled"
  - `order.cancelReason` — string or null; required.  Allowed: "seats\_unavailable", "guest\_request", "session\_canceled", "duplicate", "other"
  - `order.cancelNote` — string or null; required. Staff's own words. Null without orders:amounts
  - `order.createdAt` — string; required.  format: "date-time"
  - `order.confirmedAt` — string or null; required.  format: "date-time"
  - `order.canceledAt` — string or null; required.  format: "date-time"
  - `order.customer` — object; required. 
    - `order.customer.id` — string; required. 
    - `order.customer.name` — string; required. The first name only, without customers:contact
    - `order.customer.email` — string or null; required. Null without customers:contact
    - `order.customer.phone` — string or null; required. Null without customers:contact, or when there's none
    - `order.customer.contactHidden` — boolean; required. True when email and phone are hidden from you (you lack customers:contact here). False with a null email or phone means the guest gave none
  - `order.product` — object; required. 
    - `order.product.id` — string; required. 
    - `order.product.name` — string; required. 
  - `order.location` — object; required. 
    - `order.location.id` — string; required. 
    - `order.location.name` — string; required. 
    - `order.location.timeZone` — string; required. 
  - `order.session` — object; required. 
    - `order.session.id` — string; required. 
    - `order.session.startsAt` — string; required.  format: "date-time"
    - `order.session.when` — string; required. In the location's time zone
  - `order.partySize` — integer; required.  minimum: -9007199254740991; maximum: 9007199254740991
  - `order.currency` — string; required. 
  - `order.total` — integer or null; required. Null without orders:amounts
  - `order.paid` — integer or null; required. Null without orders:amounts
  - `order.refunded` — integer or null; required. Refunded or on its way back. Null without orders:amounts
  - `order.kept` — integer or null; required. Fees sold as non-refundable (the service charge) and their tax, kept on staff refunds, as far as the money is still held: 0 once everything paid has come back, refunded or as a credit in its place (a session the operator moved or called off), and none on an order canceled before it was booked. Null without orders:amounts
  - `order.refundable` — integer or null; required. What staff can still refund: paid, less refunds, less a credit given in place of a refund (a session moved or called off), less what's kept. Null without orders:amounts
  - `order.refunds` — array; required. 
    - `order.refunds[]` — object; optional. 
      - `order.refunds[].id` — string; required. 
      - `order.refunds[].amount` — integer or null; required. Null without orders:amounts
      - `order.refunds[].status` — string; required. pending (on its way), succeeded, failed, or reversed: given as a credit or gift certificate that was voided unused since, so it was taken back and isn't counted as refunded Allowed: "pending", "succeeded", "failed", "reversed"
      - `order.refunds[].reason` — string or null; required.  Allowed: "seats\_unavailable", "guest\_request", "session\_canceled", "service\_issue", "duplicate", "goodwill", "other"
      - `order.refunds[].note` — string or null; required. Staff's own words. Null without orders:amounts
      - `order.refunds[].failureReason` — string or null; required. 
      - `order.refunds[].createdAt` — string; required.  format: "date-time"
      - `order.refunds[].tender` — string; optional. What the refunded payment was made with: card (back to the guest's card), gift_certificate or credit (back to it), or an offline tender (card_terminal, cash, debit, e_transfer, cheque), which staff gave back that way at the desk; a voucher's part is given back as a credit (creditId), and a guest's own refund under the booking's refundDestination as a credit (creditId) or gift certificate (giftCertificateId) instead of back to the card or the desk Allowed: "card", "gift\_certificate", "credit", "card\_terminal", "cash", "debit", "e\_transfer", "cheque", "voucher"
      - `order.refunds[].creditId` — string or null; optional. The credit this refund became instead of going back where it was paid: a third party's voucher can't be handed back, so its part is a credit (voucher_refunded); a guest's own cancellation or change under refundDestination credit gives one (guest_change). The same credit the booking's credits list shows. Null for every other refund. Always present
      - `order.refunds[].giftCertificateId` — string or null; optional. The gift certificate (kind refund) this refund became instead of going back where it was paid: a guest's own cancellation or change under refundDestination gift_certificate. Null for every other refund. Always present
      - `order.refunds[].issuer` — string or null; optional. Who issued the voucher the refunded payment was (such as Costco); null for any other tender, and without orders:amounts. Always present
  - `order.bookingId` — string or null; optional. Null until it's booked. Always present
  - `order.booker` — string; optional. Who made it: a guest at checkout, or staff. Always present Allowed: "customer", "staff"
  - `order.balanceDue` — integer or null; optional. What's still owing. Above 0 on a staff booking with payment to come, or seats added since: confirmed isn't paid. Null without orders:amounts. Always present
  - `order.overPaid` — integer or null; optional. What's been paid beyond the total: seats removed, which refunds nothing by itself. Null without orders:amounts. Always present
  - `order.paymentStatus` — string or null; optional. unpaid, partly_paid, paid, over_paid, refunded (all but any kept fee has gone back), or nothing_due, from what's actually been paid. A partial refund stays paid. Null without orders:amounts. Always present Allowed: "unpaid", "partly\_paid", "paid", "over\_paid", "refunded", "nothing\_due"
  - `order.staffNote` — string or null; optional. Staff's own note, never shown to the guest. Null without orders:amounts, or when there's none. Always present
