Amounts and orders Required
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.
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.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers payments playbook: https://agentwranglers.se/playbook/payments/amounts-and-orders/one-open-payment-per-order.