---
title: "Discussion on \"How to Build a Refund Status API That Prevents Double Refunds\" | Hashnode"
description: "Discussion on \"How to Build a Refund Status API That Prevents Double Refunds\". A refund request times out, so your back end sends it again. Meanwhile, the first request may already have succeeded. Or the request returns successfully, your order becomes “refunded”, and a later fa"
url: "https://hashnode.com/posts/how-to-build-a-refund-status-api-that-prevents-double-refunds/6b112012137f8411d4d9b199"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to Build a Refund Status API That Prevents Double Refunds](https://jafaronpayments.hashnode.dev/how-to-build-a-refund-status-api-that-prevents-double-refunds?utm_source=hashnode&utm_medium=feed)

A refund request times out, so your back end sends it again. Meanwhile, the first request may already have succeeded. Or the request returns successfully, your order becomes “refunded”, and a later fa

3d ago · 9 min read · jafaronpayments.hashnode.dev  
Read the article

-   [#backend](https://hashnode.com/tag/backend)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#payments](https://hashnode.com/tag/payments)
-   [#api](https://hashnode.com/tag/api)

## Written by

[Jafar Sadhik](https://hashnode.com/@jaffy)

@jaffy · London, UK

  
[View profile](https://hashnode.com/@jaffy)

Payments at Atoa

Jafar Sadhik works at Atoa, the UK Pay by Bank and card payments platform. Writes about taking payments, open banking and payment APIs for UK businesses and developers.

## Responses 1

Markdown supported · ⌘↵ to post

[Paul Hartness](https://hashnode.com/@retryfix)

[2d ago](https://hashnode.com/posts/how-to-build-a-refund-status-api-that-prevents-double-refunds/6b112012137f8411d4d9b199/comment/6b126f0e59304c9f541b44c0)

The timeout case is the one that bites. I'd store the refund record with its idempotency key before calling the provider, so a retried request finds the pending row and waits for the webhook instead of sending a second refund.
