Checkout with Back
A checkout sends a charge for the cart total and waits for the reply. While it waits, the user can press Back, add an item and check out again. The reply for the first cart can still arrive, and it marks the new, bigger cart paid for the old amount.
PaymentPending: { on: { Back: { target: targets.root.Cart }, PaymentSucceeded: { target: targets.root.Paid, data: ({ event }) => ({ amount: event.amount }) }, },},See how effect-machine finds and fixes it.