Skip to content

How to refund a line item in Stripe

A Stripe refund takes a charge or PaymentIntent and an amount, and no parameter names an item. To refund one line item, issue a credit note when an invoice sits behind the payment. Otherwise, compute the item's share of what the buyer paid, discount and tax included, refund that amount, and record which item it was for.
Verified against official documentationReviewed Send a correction (opens in a new tab)

Everything a Stripe refund can target fits in two parameters:

cURL
curl https://api.stripe.com/v1/refunds \
  -u "sk_test_...:" \
  -d payment_intent=pi_... \
  -d amount=1437

Stripe accepts any amount up to what's left unrefunded on the charge. Nothing on the refund says whether $14.37 was one cracked mug out of a six-item order or a goodwill credit, so the Dashboard, your webhooks, and your accounting connector all see an amount. On Flint, the same refund names the order line and a quantity, and the server works out the amount.

Which path applies to you

What you haveYour path
The payment paid a subscription, a Stripe invoice, or a Checkout Session with invoice creation onIssue a credit note
The payment came from Checkout, a Payment Link, or a PaymentIntent with no invoiceCompute the amount yourself
The item was discounted, taxed, or bought in a quantity above oneAvoid the math traps
Accounting needs to know which items a refund coveredKeep the line detail
You want refunds that name the item and do the math for youLine-item refunds on Flint

If an invoice sits behind the payment: issue a credit note

Credit notes are Stripe's line-level correction, and they attach only to finalized invoices, open or paid. Subscriptions always create invoices. Payment-mode Checkout Sessions and Payment Links create one only when invoice_creation[enabled] is true, which Stripe prices separately from Invoicing. A PaymentIntent you create yourself has none. Since API version 2025-03-31.basil, a PaymentIntent no longer carries an invoice field, so look the invoice up through invoice payments:

Shell
# An empty data list means no invoice, so no credit note
curl -G https://api.stripe.com/v1/invoice_payments \
  -u "sk_test_...:" \
  -d "payment[type]=payment_intent" \
  -d "payment[payment_intent]=pi_..."

An empty data list means there's no invoice: skip to computing the amount. Otherwise, take invoice from the result and credit the line by quantity. Stripe applies invoice discounts proportionally to each line, so a credited unit carries its discounted price. refund_amount sends the money back to the payment method:

Shell
# Credit one unit of the line and refund it to the original payment method
curl https://api.stripe.com/v1/credit_notes \
  -u "sk_test_...:" \
  -d invoice=in_... \
  -d "lines[0][type]=invoice_line_item" \
  -d "lines[0][invoice_line_item]=il_..." \
  -d "lines[0][quantity]=1" \
  -d refund_amount=1437

The rules that shape this path:

  • On a paid invoice, the credit has to go somewhere: refund_amount or linked refunds, credit_amount to the customer's balance, or out_of_band_amount, together equal to the credit note's post_payment_amount.
  • Credit notes plus refunds made through the Refunds API can't exceed the invoice amount.
  • Once you credit a line by quantity, later credit notes can credit it only by quantity. The same holds for amount.
  • You can void a credit note only while its invoice is open.

Everywhere else: compute the amount yourself

Without an invoice, a line-item refund is arithmetic you own: read what the line was paid for, split it per unit without losing cents, refund one unit's share, and record what the money was for. For Checkout, the session's line items carry the paid amounts with discounts and tax applied. Payment Links create Checkout Sessions, so the same call covers them:

JavaScript
const { data: lineItems } = await stripe.checkout.sessions.listLineItems(
  sessionId,
  { limit: 100 },
);

// Each line reports what the buyer paid for it:
// amount_subtotal, amount_discount, amount_tax, amount_total, quantity
const line = lineItems.find((li) => li.price.product === productId);

amount_total is what the buyer paid for the whole line, after its share of any discount and with its tax. Split it once and store the result:

JavaScript
// Split a line's total into per-unit amounts in integer minor units,
// so that refunds of every unit sum exactly to the total.
function perUnitAmounts(amountTotal, quantity) {
  const base = Math.floor(amountTotal / quantity);
  const extra = amountTotal - base * quantity;
  return Array.from({ length: quantity }, (_, i) =>
    i < extra ? base + 1 : base,
  );
}

// A 3-unit line that was paid 4310, discount and tax included:
perUnitAmounts(4310, 3); // [1437, 1437, 1436]

Then refund one unit's amount, with an idempotency key per unit and metadata that says what the money was for:

JavaScript
const refund = await stripe.refunds.create(
  {
    payment_intent: paymentIntentId,
    amount: 1437,
    metadata: {
      // Fixed keys your accounting integration reads back from refund
      // events. Stripe doesn't read them.
      line_item_id: line.id,
      product_id: line.price.product,
      units_refunded: "1",
    },
  },
  { idempotencyKey: `refund-${orderId}-${line.id}-unit-1` },
);

Stripe checks this refund against the charge's unrefunded balance and nothing else, so a second refund for the same unit succeeds while the charge has money left. Tracking what each line has had back is yours. For a PaymentIntent you created without Checkout, the recipe is the same with line amounts from your own order records, because Stripe never saw the items.

Four places the math goes wrong

  1. A cart discount makes the price wrong#

    The buyer used a promotion code, and refunding quantity * unit_amount gives back more than they paid for the item.

    Checkout spreads a cart-level discount across the lines it applies to. The line's amount_discount and amount_total include its share; the price's unit_amount doesn't. Refunding from the price returns the discount too.

    Confirm it

    Read amount_discount on the session line item. Anything above 0 means a discount touched the line and price arithmetic is off.

    Fix

    Base every refund on the line's amount_total, never on the price. The split helper above works from it.

  2. The refund doesn't know which item's tax it returns#

    You refunded the item's price and the buyer is still out its tax, or your tax records show the refund spread across items that never came back.

    Stripe moves exactly the amount you send and adds no tax share to it. On the tax side, the basic Stripe Tax integration for PaymentIntents records a flat-amount reversal for each refund, which Stripe spreads across every line in proportion to what's left on each, not onto the item you meant. With the custom integration, you record each reversal yourself.

    Confirm it

    amount_tax on the session line item is the tax the line carried. If your refund amount leaves it out, the buyer got a net-of-tax refund.

    Fix

    Refund the unit's share of amount_total, which includes its tax. If per-item tax records matter, use the custom Stripe Tax integration and record a partial reversal that names the line with its amount and amount_tax.

  3. Per-unit division loses cents#

    Your refunds for a line miss the line's total by a cent, or the last unit's refund fails against the charge's remaining balance.

    A line's total rarely divides evenly by its quantity once discounts and tax are in it. Rounding amount_total / quantity again on each refund drifts by a cent per refund, and after a few your records and the charge disagree.

    Confirm it

    Multiply your per-unit amount by the quantity and compare it with amount_total. Any difference is drift waiting to surface.

    Fix

    Split the total once with a largest-remainder split, store the array, and consume it as units come back. The parts always sum to the total.

  4. Nothing stops a second refund of the same item#

    One item was refunded twice, and Stripe accepted both requests.

    Stripe checks a refund against the charge's unrefunded balance, not against the item you meant it to cover. Two support agents refunding the same item hit no limit until the whole charge is used up.

    Confirm it

    Sum the refunds you attributed to a line and compare the total with that line's amount_total. Stripe has no view that answers this for you.

    Fix

    Record per-line refunded units and amounts in your own database when you create each refund, inside a transaction that locks the order, and check them before the next one.

Getting line detail into your accounting system

Accounting connectors build credit memos from what the refund carries, and a Stripe refund carries an amount and a payment reference. That's why ERP and order-management connectors show Stripe refunds as unallocated amounts against an order, and credit memos come out as one adjustment line instead of the items that came back. Two things give the connector something to read:

  • The credit note, when there's an invoice. It's the line-level record itself, so connectors that read Stripe invoicing can mirror its lines.
  • Metadata on the refund, everywhere else. Choose fixed keys once and write them when you create the refund, as in the sample above: the line item ID or SKU, units, and amounts. Stripe allows 50 keys, with names up to 40 characters and values up to 500. Stripe doesn't copy metadata between related objects, so it has to be on the refund itself; events that carry the refund include it.

Neither fixes history. A refund created without line detail stays unallocated, so set the convention before the next refund.

On Flint, the refund names the item

Flint is a payments API with orders built in, so a payment on a Flint order is refunded against that order's lines. Send the line's order_line_item_id, from GET /v1/orders/{order_id}, and a quantity:

cURL
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-1" \
  -d '{
    "refund_type": "targets",
    "order_id": "ord_01KEZF7C00JBKMARG3P06Z224B",
    "reason": "defective_product",
    "line_items": [
      {"order_line_item_id": "li_01KEZF7C004XP0V220YVMGQ354", "quantity": 1}
    ]
  }'

The line is three mugs at $14.99 that took $4.50 of the order's discount and $2.63 of tax, $43.10 in all. Flint refunds one unit's share and itemizes it in line_item_allocations. The response is abridged:

JSON
{
  "data": {
    "refund_id": "ref_01KEZF7C00H2GAMWD73WZ7K81W",
    "status": "pending",
    "reason": "defective_product",
    "amount_money": {"amount": 1437, "currency": "USD"},
    "order_id": "ord_01KEZF7C00JBKMARG3P06Z224B",
    "payment_intent_id": "pi_01KEZF7C0050JFFB0HNCWWV1G3",
    "line_item_allocations": [
      {
        "order_line_item_id": "li_01KEZF7C004XP0V220YVMGQ354",
        "quantity": 1,
        "refunded_money": {"amount": 1437, "currency": "USD"},
        "tax_refund_mode": "automatic",
        "automatic_refund": {
          "subtotal_money": {"amount": 1499, "currency": "USD"},
          "discount_money": {"amount": 150, "currency": "USD"},
          "tax_money": {"amount": 88, "currency": "USD"},
          "total_money": {"amount": 1437, "currency": "USD"}
        }
      }
    ],
    "version": 1
  },
  "request_id": "req_01KWM694EG9SNYD9JYR0SQVVP6"
}
One mug refunded on Flint
  • Subtotalautomatic_refund.subtotal_money
    $14.99
  • Discount shareautomatic_refund.discount_money
    One third of the line's $4.50
    −$1.50
  • Taxautomatic_refund.tax_money
    $0.88
  • Refundedrefunded_money
    $14.37

The work the Stripe recipe leaves to you happens on the server:

  • A quantity refund rounds its share of the line's remaining paid value half up in minor units, then rounds the tax and discount shares half up and balances the subtotal. Separate one-unit refunds here are $14.37, $14.37, and $14.36. The last unit takes exactly what's left of every component.
  • A line can't be refunded past what's left on it. More units or a larger amount than remain returns 409 LIMIT_EXCEEDED, with param naming the line's quantity or amount_money. A fully refunded line named by ID alone returns 409 ACTION_NOT_ALLOWED with reason already_applied. Retrying with the same Idempotency-Key returns the original refund instead of refunding twice.
  • The order's line keeps the running total in refunded_quantity and refunded_money, so support tools and reports read one field instead of summing refunds.
  • Tax comes back in proportion automatically. To return less, set the line's tax_refund_mode to explicit, which needs the commerce.refunds.tax_overrides.write scope; the sales tax guide covers it.
  • Leave out quantity to refund all of the line's remaining units, or send amount_money instead for a price adjustment. A restocking fee is a refund_adjustments entry on the same line. The refunds guide shows each, and a Return handles merchandise that physically comes back, with your restocking policy applied.

Invoices: credit notes that move the money

A Flint invoice is corrected the same way as on Stripe, with a credit note that names invoice lines. On a paid invoice, issue the note and refund it in one call:

Shell
# 1. Draft a credit note for one unit of the paid invoice's line
curl -X POST https://api.withflintpay.com/v1/credit-notes \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: credit-note-inv-1043-1" \
  -d '{
    "invoice_id": "inv_01KF2A4B6C8D0E2F4G6H8J0K2M",
    "reason": "returned_goods",
    "line_items": [
      {
        "invoice_line_item_id": "invli_01KF2A4B6C8D0E2F4G6H8J0K3N",
        "correction": {"type": "quantity", "quantity": 1}
      }
    ]
  }'

# 2. Issue it and refund the credit in the same call
curl -X POST https://api.withflintpay.com/v1/credit-notes/cn_01KF5D3E5F7G9H1J3K5M7N9P1Q/issue \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: issue-cn-inv-1043-1" \
  -d '{"refund": {"reason": "defective_product"}}'

Flint credits the unit's share of the line's remaining billed value, with its discount and tax, numbers the note and renders its PDF, and creates a refund that carries credit_note_id and invoice_id and sends the usual refund.* events. On an unpaid invoice, issue with "allocation": {} instead, and the credit lowers outstanding_money without moving money. An allocation can be reversed later with the original kept on the record, and one invoice line can take both quantity and amount corrections across notes. The credit notes guide covers both paths.

Stripe and Flint line-item refunds, side by side

Stripe Refunds APIStripe credit notesFlint
Payments it coversAny charge or PaymentIntentPayments with a finalized invoicePayments on an order with /v1/refunds; invoices with credit notes
Naming the itemNot possible; you send an amountlines[] with an invoice line and a quantity or amountline_items[] with order_line_item_id and a quantity or amount
Discount and tax shareYour arithmetic, from line amounts you readDiscount prorated on the invoice lineComputed and itemized in automatic_refund
Refunding past the item's shareAllowed until the charge is fully refundedCapped by the invoice amountRefused per line with 409 LIMIT_EXCEEDED
Quantity, then amount, on one lineNot applicableNot allowed; a line keeps its first credit typeAllowed on both refunds and credit notes
Undoing a credit on an unpaid invoiceNot applicableVoid the note while the invoice is openReverse the allocation; the note and its history stay
Line detail afterwardMetadata you wroteThe credit noteThe refund's line_item_allocations and the order line's refunded_quantity

Questions, answered

Can you refund a single line item in Stripe?

Not with the Refunds API. A Stripe refund takes a charge or PaymentIntent and an amount, and no parameter names an item. If an invoice sits behind the payment, a credit note can credit specific invoice lines and refund the money. Otherwise, compute the item's share of the payment, including its discount and tax, and refund that amount.

Can I use a credit note to refund a Stripe Checkout payment?

Only when the session created an invoice. Subscription-mode sessions always do. Payment-mode sessions and Payment Links create one only when invoice creation is enabled, which Stripe prices separately. A PaymentIntent you created yourself has no invoice, so a credit note has nothing to attach to.

Does Stripe calculate the tax share when I refund part of a payment?

No. The amount you send is the amount that moves, so include the item's tax in it. With the basic Stripe Tax integration for PaymentIntents, Stripe records a flat-amount tax reversal spread across all lines. To reverse tax for one item, use the custom integration and record a partial reversal for that line.

How do I record which items a Stripe refund covered?

Write it in the refund's metadata when you create it, with a fixed set of keys such as the line item ID and units, and read it back from the refund events. When the payment has an invoice, issue a credit note instead; the credit note is the line-level record.

Why doesn't my accounting integration show which items were refunded?

Because a Stripe refund has no line items to read. A connector can only allocate a refund to items when something carries the detail: a credit note on an invoice, or metadata your integration wrote on the refund.

How do I refund one item with Flint?

Send POST /v1/refunds with refund_type targets and a line_items entry naming the order's order_line_item_id and a quantity. Flint computes the amount from what the line was paid for, including its discount and tax share, returns the breakdown in line_item_allocations, and refuses a refund larger than what's left on that line.

Sources

Accessed October 31, 2026.