Provider failover can improve availability only when the system knows whether the earlier attempt may still complete. A timeout after submission is not the same as a confirmed refusal. Sending the same payment to another provider during that uncertainty can create two successful charges. Build failover around one internal business operation, with a controlled sequence of provider attempts and a clear rule for unresolved outcomes.
Separate the payment from its provider attempts
Create one internal operation representing the customer’s intended payment and a distinct record for each provider attempt. Store the provider account, request identity, amount and known status. The operation decides whether another attempt is permitted; an adapter should not independently route around an error without consulting that shared state.
Preserve idempotency within each provider according to its documented scope. Stripe’s idempotency guidance explains retry behavior for its own API. The same key sent to a different provider does not create a shared deduplication contract. Cross-provider duplicate prevention must therefore be enforced by the application’s operation model and routing policy.
Classify errors before selecting another route
Distinguish failures before dispatch, explicit terminal rejection and uncertain outcomes after submission. A local validation error may permit a corrected attempt, while an interrupted connection after the provider accepted the request requires investigation. Record enough dispatch evidence to make this distinction without placing sensitive payment credentials in logs.
For an uncertain result, retrieve the original provider object or use its supported status and reconciliation mechanisms. A confirmed cancellation may allow a new attempt, but requesting cancellation is not necessarily confirmation. Keep the operation pending when evidence remains incomplete rather than converting ambiguity into a customer-visible failure that invites another charge.
Control concurrent routing decisions
Ensure only one worker can authorize the next provider attempt for an operation at a time. Use a durable state transition and a stable attempt identifier so process restarts and queue retries do not create parallel dispatches. Record the reason for failover and the evidence that made the previous route safe to leave.
Coordinate customer-initiated retries with automatic routing. A refreshed page or a second button press should reconnect to the existing operation where it represents the same intent. If the customer deliberately starts a new purchase, distinguish it clearly. Do not infer business identity from equal amounts alone, because legitimate separate payments can have identical values.
Reconcile late outcomes and test the difficult paths
Plan for late success events even after an operation has entered an exception state. Link every attempt to the shared operation and alert on conflicting successful outcomes. Resolve any duplicate through an authorized, traceable correction workflow rather than hiding one event or silently rewriting the payment history.
Test timeouts after provider acceptance, delayed notifications, concurrent retries and a process failure during routing. Measure availability improvements alongside unresolved operations and duplicate-risk exceptions. A resilient failover design is intentionally conservative where the first outcome is unknown. Its success is a payment journey that recovers service without losing control of how many charges the customer actually authorized.
The key decisions.
- Model one payment intent with separately identified provider attempts.
- Treat post-submission uncertainty as a state to resolve before cross-provider retry.
- Serialize routing decisions and reconcile late outcomes against the shared operation.
Sources & further reading
Primary references for the concepts discussed. Check the applicable documentation when planning implementation.







