Charged twice

Why do you sometimes get charged twice online?

Demo 5 of 7Reel"Bakit minsan dalawang beses kang nasisingil online?"

Try it

This connection always loses the first reply. Pay with the key off, then turn it on and pay again.

POST /api/lab/pay

Load ₱100

₱100

Total to pay

Every try looks like a new purchase.

  1. Payment sent

    With no key

    Not yet
  2. Server charged ₱100

    The money moves here

    Not yet
  3. Reply lost on the way back

    The app can't tell if you paid

    Not yet
  4. App tries again

    With no key, so it looks new

    Not yet
  5. Server answers

    Already paid, or charged again

    Not yet

Your bank statement

₱0

taken for one ₱100 purchase

Loading your statement

What just happened

Your payment reaches the server and goes through, but the reply gets lost on the way back. Your app can't tell whether it worked, so it tries again, and the server charges you a second time.

An idempotency key fixes that. The app makes one random id per purchase and sends it with every try. The server remembers the id, so a repeat gets back the first result instead of a second charge.

Payment services like Stripe ask apps to send exactly this kind of key with every payment.

Where you've seen it

  • Pressing Pay again because the screen froze
  • A transfer that shows as failed, then turns up twice on your statement

Keep going