Skip to content

Gift Cards (Staff)

Staff do not sell, apply or move gift cards. A buyer buys a card on the website, and the recipient adds it to their own account. Staff step in to look a card up, send an email again, refund a card that was never added, and handle disputes. The rules behind each step are in Gift Cards.

All gift card work runs through one script with a subcommand for each task. Every subcommand that changes anything shows a preview first and acts only with --apply.

cd apps/api && pnpm tsx scripts/gift-cards.ts <subcommand> [args]

Add --production to run against production. Ask Aaron before any production run that changes data.

Finding a Gift Card

Use show for any question about one card. It changes nothing.

pnpm tsx scripts/gift-cards.ts show <code-or-id>

Give it the card's id or its code, with or without dashes. The code is a secret, so the output hides it unless you add --show-code. Do not paste a code into a ticket, a Slack message or an email.

show prints:

  • The card: status, amount, bonus, the recipient, and when it was issued, added, voided and reissued.
  • The buyer and, once it is added, the owner.
  • The card's two balances, purchased value and bonus, with every transaction on each, and any edits made afterward.
  • The payments for the purchase, and the receipt and gift emails with their status.

A card that is not on an account has no balances yet. They open when the member adds the card.

Card Statuses

Status Meaning
Pending The buyer started checkout and has not paid. It cannot be added to an account.
Issued Paid. It has not been added to an account.
Added On a member's account, with its own balance.
Voided Taken out of use by a refund or a dispute. The void reason says which.

Sending an Email Again

Use resend when a buyer says the receipt never came, or when the recipient's address was wrong. The system already retries a failed email for 7 days, so check the email list in show first.

pnpm tsx scripts/gift-cards.ts resend <id> [--to=buyer] [--email=<address>] [--apply]
  • With no --to, it sends the gift email to the recipient. This works only while the card is issued; the script refuses it once the card is added.
  • --to=buyer sends the buyer's receipt. It works for an issued or added card.
  • --email=<address> corrects the recipient's address on the card before sending. It works only for the recipient's email.
  • It refuses a pending or voided card.

Run it without --apply first. The preview names the email, the address it goes to, and whether it was sent before.

Refunding a Gift Card That Was Never Added

A buyer may ask for their money back, for example after buying the wrong amount. Staff may refund a card in full while it is issued and not on an account. The refund voids the card, so nobody can add it afterward.

pnpm tsx scripts/gift-cards.ts refund <id> [--apply]

The preview shows the amount to be refunded to the original card and the bonus, which is never refunded because it was never money. Check it, then run it with --apply.

The refund goes back to the card the buyer paid with, in full. No location is involved, because a gift card purchase pays no location.

The command refuses when:

Situation What to do
The card is on an account Do not refund it. A card on an account is never refunded as money.
The card is pending or already voided Nothing to refund. A card voided by a failed refund is the exception below.
The card was reissued after a won dispute Refund by hand and tell Aaron.
The charge has an open or lost dispute Stripe will not refund it. Wait for a won dispute and run it again. A lost dispute repays the buyer.
The charge shows disputed but no dispute is recorded The dispute notice has not arrived yet. Try again later.
The charge is already refunded Check the payment in show.

When a Refund Fails

If Stripe refuses the refund or accepts it and it fails later, the card stays voided and the buyer stays owed. The card never reopens for use. Staff are emailed "A gift card refund is still owed". Run the same command again until the refund lands.

A Refund Still Settling

A refund that Stripe accepted but whose money has not settled yet reads as in transit in the nightly checks, not as owed. It does not email staff. Wait for it to settle. Run the refund again only when the checks or the staff email say the refund is still owed.

A Refund Made in Stripe

A full refund made directly in the Stripe dashboard also voids a card that is not on an account. If the card is already on an account, nothing is voided and staff are emailed "Gift card purchase refunded, card not voided". Look at the card with show and decide with Aaron, because the member now holds a balance the buyer was paid back for.

Disputes

A buyer can dispute the purchase with their bank. Stripe first sends an inquiry, which changes nothing. Only a real dispute acts, and it acts once.

Where the card is What happens at once What staff do
Issued, not on an account The card is voided. Nothing. Check the card with show if the buyer writes in.
On an account The unspent balance, value and bonus, is voided. What the card already paid for stays paid. Staff are alerted. See the alerts table below.
Reissued after a won dispute Staff are alerted. Nothing is changed. Handle by hand and tell Aaron.

A member cannot add a card while a dispute on its purchase is open or lost. They see the same generic error as for any bad code.

Alerts and Emails for a Dispute

What happened Sentry operation or email line What staff do
An inquiry Email: "Gift card, inquiry only: nothing changed" Nothing.
A card on an account is disputed gift-card-dispute-added (error). Email: "Gift card, on an account: voided with its unspent balance; what it already paid for stays paid" Nothing now. Wait for the decision.
The dispute is won Email: "Gift card, on an account, dispute won: the card stays voided until staff restore it". gift-card-dispute-won and the warning dispute-won Run restore (below).
The dispute is lost Email: "Gift card, on an account, dispute lost: each location it paid repays the value spent there and a share of the fee". Warning dispute-lost Nothing to run. See "A Lost Dispute" below.
A lost dispute is later reversed in our favour dispute-reversed Repay the locations by hand (payments refund rule 6).
A dispute on a card already reissued once gift-card-dispute-reissued (error). The email says it needs handling by hand. Handle by hand and tell Aaron.
Value returned to a voided card Warning dispute-revoid. The value is voided again at once while the dispute is open or lost. Nothing. A cancellation or a return landed on a card whose dispute is not won.
Card value was spent on something with no location gift-card-dispute-unplaced-spend Ask Aaron. The platform bears it.
A rent transfer found from an earlier attempt differs from what is now owed pay-location-adopted-mismatch Check the location's payout and ask Aaron.

The email goes to the staff address with the location shown as "no location (platform-held gift card)".

A Lost Dispute

Each location the card paid repays the full purchased value spent there and its share of the dispute fees. Nothing is recovered while the dispute is open. When the dispute is lost:

  • Hourly and rent payouts not yet sent are cut automatically, and the platform's 10% of the value spent is claimed from the location's later transfers. The location repays the same amount whether or not its payout was sent.
  • Payouts already sent become claims against the location, taken from its later transfers automatically, the same way as any lost dispute (see Payments).
  • The bonus spent was hosted free, so no location repays it.

Staff run nothing. Tell the community manager of each affected location before the recovery lands, because the location sees what it owes as for any dispute.

A Won Dispute

A won or withdrawn dispute is never restored automatically. Until staff run restore, the voided balance stays void. Locations still repay their share of Stripe's dispute fee, automatically (payments dispute rule 4).

Restoring a Card After a Won Dispute

Use restore after every dispute on a card's purchase is won or withdrawn. Stripe closes a withdrawn dispute as won. It reissues the card, and for a card on an account it gives back to each balance exactly what the dispute voided from it, including value returned to the card after the void by a cancellation or a return.

pnpm tsx scripts/gift-cards.ts restore <giftCardId> [--apply --by <staff email or name>]

The argument is the card's id, not its code. Without --apply it is a preview. With --apply, --by is required and is recorded on the ledger rows.

The preview prints:

  • gift card and dispute: the dispute's id, or "card was not on an account: nothing to give back in the ledger".
  • reissued as: ISSUED for a card voided before it was on an account, ADDED for a card that was on one.
  • value back and bonus back: one line per balance, such as "$X.XX to ".
  • result: "DRY RUN: would reissue the card as ; rerun with --apply --by ".

After --apply the result reads "reissued as ; N balance(s) restored ()". The void stays recorded.

A card is reissued at most once. The command refuses in these cases:

Situation What to do
"already reissued once" A later dispute on this card is handled by hand. Tell Aaron.
The card was not voided by a dispute, for example by a refund Nothing to restore. A refunded card is not reopened.
A dispute on the purchase is not won The message names the dispute and its status. Wait until every dispute is won or withdrawn.
A card on an account with no recorded dispute Ask Aaron.
"changed since the plan; re-run" Run the preview again, then apply.

Returning the Gift Card Part of a Refunded Payment

Refunding a booking or a rent payment in the staff tool refunds the part paid by card or account credit. It does not return the gift card part. Use return to put that part back on the card and take back the location's payout for it. It does not refund any money, and it does not require that the card-paid part was refunded first.

pnpm tsx scripts/gift-cards.ts return --booking <reservationId> [--apply --by <staff> --note "<why>"]
pnpm tsx scripts/gift-cards.ts return --invoice <in_...> [--apply --by <staff> --note "<why>"]

Give exactly one of --booking, for an hourly booking's reservation id, or --invoice, for a lockout bill's Stripe invoice id. With --apply, --by and --note are both required and both are stored.

The preview prints:

  • booking, or bill with its rent payout record and status.
  • location.
  • value back to the card and bonus back to the card, in dollars.
  • draws: how many draws are returned.
  • refunded payment: the payment's id, or "none found: check the card-paid part was refunded". This line only informs. Check that the member was refunded the card-paid part, and refund it separately in the usual way if not.
  • result: "DRY RUN: would return the gift card part and recover the location payout for it; rerun with --apply --by --note ".

The command puts the part back at the same value and bonus split it was drawn with. It recovers the location's 90% of the value in one of two ways:

  • Not yet paid out, for a held hourly payout or a bill's payout not yet transferred: the amount is taken off before payout.
  • Already paid out: the amount is claimed from the location's later transfers (payments refund rule 6).

After --apply it prints the return's id, taken off before payout and claimed from later transfers. It sends no alert.

It refuses in these cases:

Message or situation What to do
Reservation not found Check the id.
A lockout named with --booking Use --invoice with the bill's invoice id.
A bill no gift card paid Nothing to return.
The bill is unpaid Voiding the bill returns the card part. Do not use return.
Already returned, or already back on the card Nothing to do. The message names the earlier return and its time.
The card lost its dispute Settle by hand. The loss already claimed that value. Tell Aaron.
A booking's gift card payout is releasing, in review or failed Return it once the payout is settled.
On apply: returned value with no payout to recover Settle by hand and tell Aaron.
"changed since the plan; re-run" Run the preview again, then apply.

Value returned to a card whose dispute is open or lost is voided again at once, as the alerts table above says.

Rent Payouts to Locations

When a gift card pays part of a monthly bill, the location's share is sent as its own transfer once the bill is paid. These alerts concern that path.

Alert What it means What to do
gift-card-rent-draw-stranded (FAIL) The card was drawn for a bill, but the line never reached the bill. Check the bill in Stripe. If it carries the gift card line, record the line's id. If it does not, return the draw to the card. Ask Aaron, and do not run the bill again by hand, because the card could be drawn twice.
gift-card-rent-draw-stranded (WARN) The draw is on a bill that has stayed open for more than 40 days. Check the bill in Stripe. Void it, which returns the draw to the card, or mark it uncollectible, which pays the location.
A rent payout that stops retrying The transfer to the location kept failing, usually because of the location's Stripe account. Fix the cause, then ask Aaron to reopen it with stripe drain-transfer-retries --revive <dedupKey> (preview first).

A Reschedule Charge That Was Not Recorded

The nightly checks raise reschedule-charge-unrecorded (FAIL) when a reschedule that cost more charged the member's card but the system never recorded the payment. The member paid for the move. Until staff act, the booking does not move, takes no further charge, and the gift card part of the extra cost is not drawn.

  1. Find the intent named in the alert in Stripe.
  2. If it succeeded, record its id on the reschedule's payment, so the payment notice applies the move.
  3. If it did not succeed, fail the payment and return its gift card draw to the card.

Ask Aaron to run either step. Do not charge the member again.

Common Questions

The member says Check and do
"I never got my gift card" show the card. If the email failed or went to a wrong address, resend with the corrected address.
"My code doesn't work" show it. A card that is pending, on another account, voided or under dispute gets the same generic error. Tell the member what the status allows.
"Move my card to my other account" Not possible. A card goes on one account, once.
"Can you add the card for me?" No. Adding is self-serve. Send the member the card page link, or the add page address on the PDF.
"Refund my card, I have already added it" Not possible as money. Ask Aaron if there is a reason to make an exception.
"My rent was charged to my card although I have a gift card" Check that Use gift cards for my monthly rent is on, and whether the bill was already finalized when the card would have been applied. A bill already finalized is paid by the saved card in full; the gift card pays from the next bill.
"I want to use my gift card and a promo code" On the first month the two cannot be combined. The member chooses. The card pays from the second bill.
"Is my gift card about to expire?" No. Gift cards and their bonus never expire.