Skip to content

Refund a customer

Say "refund this order" and get all or part of the payment back on their card, with the books reversed and your refund Limit checked.

Give a customer back all or part of what they paid, on the card they paid with. Your books record the refund in the same step, and any refund over your refund Limit waits for your yes.

Needs Take a payment

What you get

  • 1refund to the card they paid with, all or part of the paymentOrder
  • 1the refund posted to your booksEntry
  • 1Approval from you first, for any refund over your refund LimitApproval

Your agent does

Order.refund
You, to your agent

Refund a customer.

Refund this order.

Give Harbor their money back.

# Look up the Order: Order.list
ORDER=$(curl "https://api.sb/leaseline.app/orders?where=customer%20%3D%20Harbor&limit=1" \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" | jq -r '.orders[0]["$id"] | split("/") | last')

# Order.refund
curl -X POST https://api.sb/leaseline.app/orders/$ORDER/refund \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Setup call did not happen.","amount":{"amount":49,"currency":"USD"}}'
import { $ } from 'startup-builder'

const [order] = await $.Order.list({ where: 'customer = Harbor', limit: 1 })
await $.Order.refund({ order: order.$id, reason: 'Setup call did not happen.', amount: { amount: 49, currency: 'USD' } })
ORDER=$(npx startup-builder do Order.list --json '{"where":"customer = Harbor","limit":1}' | jq -r '.orders[0]["$id"] | split("/") | last')
npx startup-builder do Order.refund --json '{"order":"'"$ORDER"'","reason":"Setup call did not happen.","amount":{"amount":49,"currency":"USD"}}'
{
  "name": "do",
  "arguments": {
    "code": "const [order] = await $.Order.list({ where: 'customer = Harbor', limit: 1 })\nreturn await $.Order.refund({ order: order.$id, reason: 'Setup call did not happen.', amount: { amount: 49, currency: 'USD' } })"
  }
}

Change it

  • Refund their last invoice instead.
  • Ask me before any refund over $250.
  • Refund the whole order.

Under the hood

Systems
Billing, Ledger
Nouns
Order, Invoice, Entry, Limit, Approval
Events
Order.refunded
Stripe objects
Refund

A one-time purchase is refunded with Order.refund; a subscription charge is an Invoice, refunded with Invoice.refund. Either posts the reversing Entries.