How to prevent duplicate purchases when creating multiple orders for the same item

Last updated: July 10, 2026

How to prevent duplicate purchases when creating multiple orders for the same item

Aghanim prevents duplicate payment attempts for the same order, but it does not deduplicate purchases at the item level across different orders.

Behavior by order scope

Same order

After payment is initiated, the order is protected from creating a second payment for that same order.

Different orders for the same item

If your backend creates a new order for the same item, that second order can be paid successfully. From Aghanim's side, this is a separate order, so the item may be purchased twice unless you prevent it in your own logic.

Recommended source of truth

Treat item.add as the confirmation that the item was actually purchased and should be granted to the player.

Recommended deduplication flow for one-time items

  1. Before creating a new order, check the existing order status with GET /order using the current order_id.

  2. If you find an active order (for example, status=captured or status=created with expires_at > now()), do not create a second order yet.

  3. If needed, expire the old order first with PATCH /orders/{id}/expire, then create a new one.

What happens if the player leaves checkout and returns

If a player leaves checkout without paying and later starts a new purchase flow on the same device, the earlier order may eventually end in a non-success state such as voided. However, if you create a new order before resolving the old one, the new order is still a separate payable order.

Best practice

For consumable or repeatable purchases, creating multiple orders may be acceptable. For one-time items, implement item-level deduplication on your side before creating a new order.