Card payment APIs record an amount. On Stripe, a refund takes an amount and a payment; on Square, the Refunds API takes an amount too. The items, options, discounts, tax, and delivery choice behind that amount live in a database you build and keep in sync. That is why so many of the lookups above end with a workaround.
Flint's API is built around the order, so each of those workarounds is an object you call instead:
Refund one item from a discounted order
A buyer paid for two $24.00 mugs with a 10% order discount and 8.25% sales tax, then sends one back. Name the line item and the quantity; Flint works out the amount:
curl -X POST https://api.withflintpay.com/v1/refunds \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: refund-ord-1042-mug" \
-d '{
"order_id": "ord_01KEZF7C00JBKMARG3P06Z224B",
"refund_type": "targets",
"reason": "requested_by_customer",
"line_items": [
{"order_line_item_id": "li_01KEZF7C00Q4V3M8T2W6R9Y1N5", "quantity": 1}
]
}'
{
"data": {
"refund_id": "ref_01KEZF7C00H2GAMWD73WZ7K81W",
"order_id": "ord_01KEZF7C00JBKMARG3P06Z224B",
"amount_money": {"amount": 2338, "currency": "USD"},
"status": "succeeded",
"line_item_allocations": [
{
"order_line_item_id": "li_01KEZF7C00Q4V3M8T2W6R9Y1N5",
"quantity": 1,
"refunded_money": {"amount": 2338, "currency": "USD"},
"automatic_refund": {
"subtotal_money": {"amount": 2400, "currency": "USD"},
"discount_money": {"amount": 240, "currency": "USD"},
"tax_money": {"amount": 178, "currency": "USD"},
"total_money": {"amount": 2338, "currency": "USD"}
},
"tax_refund_mode": "automatic"
}
]
}
}
The refund returns the mug's price less its share of the discount, plus the tax charged on what the buyer paid for it:
One of two $24.00 mugs, refunded
Subtotalautomatic_refund.subtotal_money
$24.00
Discountautomatic_refund.discount_money
10% order discount
−$2.40
Taxautomatic_refund.tax_money
8.25% of $21.60
$1.78
Refundedautomatic_refund.total_money
$23.38
The split is stored on the refund in line_item_allocations, so you never rebuild it from an amount. The refunds guide covers partial quantities, charges and tax, and restocking fees.
Flint docs and free tools
Building on Flint? Start at the docs, the API reference, or the error catalog.
Pricing a store or writing its return policy? Flint's free tools include a Shopify headless cost calculator and a return policy generator.