# How do I stop duplicate payment callbacks from crediting an order twice?

Source: https://www.payjn.com/help/duplicate-payment-callbacks/ · Updated 2026-11-19 · PAYJN Help center

Authenticate every callback and make credit or fulfilment idempotent, so processing it again cannot repeat the business effect. Protect that operation with an atomic database transaction and uniqueness rule. Deduplicating notification deliveries alone cannot prevent a status query and callback from crediting the same payment concurrently.

## Keep identifiers separate

A merchant reference identifies your order, a provider transaction reference identifies a payment, and a documented event identifier identifies an event. Use the approved integration documentation for exact PAYJN names, scopes and rules.

- Store stable references before presenting payment instructions.
- Authenticate every delivery, including repeats.
- Use a documented event identifier for delivery deduplication where available.
- Independently protect the ledger credit or fulfilment action.

Do not assume a payload hash identifies a payment. Different events may describe one payment, while distinct successful transactions for one order may represent two payments needing reconciliation.

## Make the credit atomic

1. Persist the verified event durably.
2. Lock the relevant business record or use equivalent concurrency control.
3. Match confirmed result, amount and currency.
4. Apply the permitted transition and uniquely protected credit together.
5. Schedule recoverable fulfilment without creating another credit.

A separate read followed by an unprotected write can let two workers both decide no credit exists. Enforce uniqueness in durable storage and handle the already-processed result deliberately. Feed verified status-query results through this same workflow.

Follow the approved acknowledgement process. A lost response after a successful commit can cause redelivery even though the business operation already happened.

## Verify recovery before launch

Agree tests with PAYJN for sequential duplicates, concurrent workers, lost acknowledgements and late callbacks after a query. Interrupt processing around the commit and verify recovery without another credit or delivery.

The [duplicate webhook guide](https://www.payjn.com/guides/payment-webhook-duplicate-events/) covers these patterns. [Contact PAYJN](https://www.payjn.com/contact/) for exact event identifiers, delivery rules and acknowledgement requirements.

## FAQ

### Does a duplicate callback mean two payments?

No. Compare verified transaction references rather than counting deliveries.

### Is an in-memory processed flag sufficient?

No. It can disappear on restart and is not reliably shared across workers; use durable controls.

### Can an older pending event undo a credit?

It should not overwrite a verified paid state. Investigate conflicts and handle genuine reversals through their documented lifecycle.
