Partial refunds supported and recorded
Why it matters
All-or-nothing refunds create a real business problem: a customer receives a damaged item among a multi-item order and is entitled to a partial refund. If the refund handler always calls stripe.refunds.create() with no amount parameter, the only option is a full refund — over-refunding destroys margin. The iso-25010:2011 functional correctness gap here is the absence of an amount field on the refund interface, and the GDPR Art. 17 dimension is the inability to correctly reflect the agreed financial correction in the stored record. The validation preventing total refunds from exceeding order total is equally important — without it, a bug or a race condition can issue more money than was collected.
Severity rationale
Medium because all-or-nothing refunds force over-refunding in partial-damage scenarios and prevent accurate financial reconciliation across multi-item orders.
Remediation
Accept an amount parameter in your refund handler at app/api/orders/[id]/refund/route.ts, validate it against the refundable balance, and pass it explicitly to the payment provider.
const alreadyRefunded = order.refunds.reduce((sum, r) => sum + r.amount, 0)
const maxRefundable = order.total - alreadyRefunded
if (amount > maxRefundable) {
return Response.json(
{ error: `Refund amount exceeds refundable balance of ${maxRefundable}` },
{ status: 400 }
)
}
const providerRefund = await stripe.refunds.create({
payment_intent: order.paymentIntentId,
amount, // explicit partial amount in cents
})
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Order Management Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · functional-correctness — Functional Correctness
- gdpr · Art. 17 — Right to erasure / refund processing obligation
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ecommerce-order-management·automated