Agent Wranglers

PAY-15Recommended

Keep one open payment per order

Allow at most one open payment attempt per order, and reuse it when the customer comes back to checkout.

How to do it

Customers double-click, open two tabs and press back. Store the provider's payment ID on the order. When checkout opens again, fetch that payment and reuse it while it can still succeed. If the amount changed, cancel the old payment before you create a new one. A partial unique index enforces the rule in the database. Guard it against double clicks as Make each change happen exactly once says.

Examples

SQL example

CREATE UNIQUE INDEX one_open_payment_per_order
  ON payment_attempts (order_id)
  WHERE status IN ('created', 'requires_action', 'processing');

How to check

Open checkout for one order in two tabs and pay in both with a test card. One payment succeeds, and the provider shows no second charge.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/payments/amounts-and-orders/one-open-payment-per-order">Agent Wranglers payments and billing playbook</a>. In code you write, add a comment next to it with the same link.