Security//4 min

A Payment Arrived Twice: Stop Your App from Acting Twice

Payment services sometimes send the same notice again. Give your app a reliable receipt check so one customer action produces one intended result.

before you start

A repeated payment notice can be normal. The important protection is making sure your app recognizes it before acting again.

What it means when the same notice arrives again

in plain words

A payment or account service may repeat a notice even though the customer acted only once.

Imagine that a customer pays once, but your app creates two orders, adds two account credits, or sends two welcome emails. The customer sees a confusing result, while you may need to correct account and payment records by hand. This guide shows how to make one outside notice produce one intended result, even if that notice arrives more than once. A notice automatically sent from one service to another app is something developers call a webhook.

A repeated notice is not automatically an attack or a service mistake. The payment service may send the notice, wait for your app's answer, and receive nothing because the connection briefly failed or your app was restarting. It then tries again so an important payment update is not lost. Developers call this a retry. The retry is useful; the danger appears when your app assumes every arrival represents a new customer action.

  • ▸A payment confirmation may arrive again after a delayed answer.
  • ▸A subscription update may be repeated while your app is restarting.
  • ▸Your app should expect repeats instead of relying on perfect delivery.

common risk

A customer buys one month of access. The same payment notice arrives twice, and the app mistakenly grants two months or creates two orders.

what to do now

Write down every result each outside notice can cause, including orders, credits, emails, refunds, account status changes, and paid access.

ask your AI

Review the parts of my app that receive webhooks. List every payment, order, credit, email, refund, or account-access action that could happen twice when the same valid webhook arrives again. Do not change real customer or payment records. Give me an inspection plan and safe tests for a separate test copy of the app.

How your app can recognize a repeat

in plain words

Treat the sender's unique receipt number as proof that a particular notice has already been handled.

Most senders include a unique receipt number with every notice. Developers usually call this an event ID. Your app should save the sender's name, this event ID, the arrival time, and whether the work is still being processed or has finished. These organized saved records are commonly kept in a database. Before creating an order or changing an account, the app tries to save the receipt. If the same sender and number are already present, it does not repeat the business action.

This plain idea has a technical name: idempotency. It means that receiving the same request again does not create another intended result. The check must also work when two copies arrive almost simultaneously. A simple check followed by a later save can fail because both copies may see an empty record. Instead, the database needs a rule that rejects a second matching sender-and-number record. Developers call this a unique constraint. The app should treat that rejection as a recognized repeat, not as permission to act again.

  • ▸Use the sender's event ID, not the customer's email, payment amount, or arrival time.
  • ▸Save the receipt before any action that would be difficult to reverse.
  • ▸If a completed receipt already exists, perform no new business action and return a normal success answer.

common risk

Two copies arrive almost together. Both initially appear new, and without a unique saved-record rule, each copy adds a customer credit.

what to do now

Ask your AI builder or developer to add one unique saved-record rule covering the sender's name and event ID, then safely handle the rejected duplicate.

ask your AI

In a separate test copy, inspect how my app stores each webhook sender and event ID. Add or propose a database unique constraint covering both values. When a duplicate save is rejected, return the sender's expected success response without creating another order, payment record, credit, email, refund, or access change. Do not read or modify real customer data.

How to reject copied or outdated notices

in plain words

Recognizing a receipt number is useful only after the app confirms that the notice truly came from the expected service.

A person should not be able to invent a payment notice and choose their own receipt number. The sending service normally attaches mathematical proof created with a signing access code held by the service and your protected app environment. Your app checks that proof against the notice's original, unchanged content before trusting any payment status or customer details. The technical name for this check is signature verification. The signing access code must stay in the part of your app that visitors cannot download.

A genuine old notice can also be copied and sent again later. Many services include a protected record of when the notice was created; developers call this a signed timestamp. Your app can reject notices older than the service's recommended time window while still allowing normal short delays. The technical name for limiting reuse of an old valid message is replay protection. It complements idempotency rather than replacing it: an ordinary recent retry can pass the time check, so the saved event ID is still necessary.

  • ▸Verify the original notice content before using any values inside it.
  • ▸Follow the sender's official instructions for signature verification and acceptable time windows.
  • ▸Never place a signing access code in files that a visitor's browser can download.

common risk

Someone resends a genuine but outdated account notice after the customer has changed plans, causing an old status to be applied again.

what to do now

Confirm that proof and time checks happen before the app creates an order, changes access, sends email, or records a payment result.

ask your AI

In a separate test copy, inspect my webhook flow without displaying any real signing access code. Confirm that signature verification uses the original unchanged notice before any action, that signed timestamps use the sender's recommended age window when supported, and that the signing access code is kept where browser visitors cannot download it. Include safe tests for an altered notice, an outdated notice, and a valid recent notice.

What should happen if work stops halfway

in plain words

Careful progress records prevent a crash from turning the sender's next attempt into duplicate work.

The app can stop halfway through a valid notice. It might save the receipt and create an order, then fail before sending an email or answering the sender. Give every saved receipt a clear state such as received, processing, completed, or failed. Decide exactly which work belongs to each state. When another copy arrives, the app should inspect that state and continue only unfinished safe work; it should never repeat an order, payment record, credit, refund, or access change blindly.

Do not tell the sender that everything succeeded before the receipt and essential account change are safely saved. Also avoid making the sender wait for slower work such as email delivery. Save the verified receipt and essential change together when your app's storage supports it. Slower follow-up work should have its own saved identifier so it cannot run twice. Record the event ID, state, and error for review, but never record payment keys, signing access codes, full card details, or unnecessary customer information.

  • ▸Define which steps may safely continue after a failure.
  • ▸Give staff a way to find receipts that remain in processing or failed states.
  • ▸Use fictional customers and test payments for failure tests.

common risk

The app creates an order, stops before answering, and receives a retry. Without a clear saved state, it creates the order again.

what to do now

Create a separate test that stops the process after the essential change but before follow-up work, then confirm that another delivery does not repeat the essential change.

ask your AI

Create a safe test plan for my separate test copy. Send the same valid webhook twice, then simulate a failure after its event ID and essential account change are saved but before the follow-up email finishes. Show the expected received, processing, completed, or failed state at each step. Confirm that no second order, payment record, credit, refund, email, or access change is created. Use only fictional customers and test payments.

What to check after every app update

in plain words

Repeat protection can disappear during a redesign, so test it whenever payment or account-notice processing changes.

After an update, send one approved test notice twice and confirm that it creates exactly one intended result. Then send a different approved notice once and confirm that it is not blocked by mistake. Test invalid proof and an outdated notice as well. Keep the results with your update notes. This evidence does not prove permanent safety, but it makes accidental removal of the receipt rule, sender check, or time check easier to catch before real customers are affected.

VibeCodeWall complements these tests by examining the public app for exposure problems; it cannot see private source code or prove that duplicate-notice logic works. Free public checks assess what is publicly reachable. A newly reported security weakness can change an app's risk even when the app itself has not changed; the technical name is a vulnerability. If Pro monitoring is activated, it uses the technologies and versions actually listed in the app's inventory to watch for relevant new public vulnerabilities. Missing or outdated inventory limits that coverage.

  • ▸Repeat the tests after changing the payment service, saved-record structure, or notice-processing instructions.
  • ▸Update the monitoring inventory when an app technology or version changes.
  • ▸Keep duplicate-delivery testing separate from checks of the public app.

common risk

A redesign replaces the old payment-notice process and quietly removes the database rule that rejected duplicate event IDs.

what to do now

Add the repeated-notice, different-notice, altered-notice, and outdated-notice tests to the checklist for every relevant update.

ask your AI

Write a repeatable update checklist for a separate test copy of my app. It must send one valid test webhook twice, a different valid webhook once, one webhook with altered content, and one outdated webhook. Check signature verification, replay protection, the unique event-ID rule, saved progress states, one intended business result, and records that exclude payment keys, signing access codes, full card details, and unnecessary customer information. Do not access or modify real customer or payment data.

Quick checklist

  1. 01List the outside services that send notices to your app.
  2. 02Find the unique receipt number included with each notice.
  3. 03Confirm who sent a notice before trusting its contents.
  4. 04Save every accepted receipt number before performing the requested action.
  5. 05Reject a second saved record with the same service and receipt number.
  6. 06Test the same harmless sample notice twice in a separate test copy.
  7. 07Confirm that the test creates only one order, credit, email, or access change.
  8. 08Keep payment keys and service access codes where visitors cannot download them.

FAQ

What is a webhook?

It is an automatic notice sent from one service to another app when something happens, such as a completed payment or subscription change.

Are duplicate webhooks always an attack?

No. They commonly result from normal retries after a delayed or missing answer. Your app should safely accept valid retries without repeating the business action.

Can I use the customer's email or payment amount to find duplicates?

No. One customer may make several valid purchases for the same amount. Use the unique event ID supplied by the sending service.

Do idempotency and replay protection do the same job?

No. Idempotency prevents repeated processing of the same event ID. Replay protection rejects valid notices reused after an acceptable time window. A safe design normally needs both.

Can VibeCodeWall confirm that this payment logic works?

No. It checks the publicly reachable app and does not see private source code. Test duplicate processing in a separate test copy with your AI builder or developer.