Back to Blog
AIBillingEngineeringStripePayPal

You're Running Stripe and PayPal for AI Billing. One of Them Will Double-Charge Someone.

Jane ZdravevskiNovember 29, 202611 min read

A second payment processor is supposed to be insurance.

Most teams add Stripe and PayPal side by side to cut failed-transaction rate, or because one segment won't trust a card to anything but PayPal.

Nobody adds it expecting a second place the same charge can commit.

If you've already fixed the raw-bytes signature-verification bug that hides in dual-rail billing, this is the failure behind it: your signature checks can be flawless and you can still double-charge someone, because the bug isn't in verifying the webhook — it's in what happens after both processors agree the event is real.


What Running Two Rails Actually Buys You (And What It Costs)

  • Fewer failed transactions — a card decline routes differently per processor, so a failed Stripe charge sometimes succeeds on PayPal.
  • Customers who won't trust anything but PayPal — a real segment, not a preference to argue away.
  • A second source of truth for one event — a renewal or top-up now arrives as two webhooks describing one fact, and your code must recognize that every time.

That third line is the one nobody prices in beforehand.


The Specific Failure: Same Event, Two Webhooks, One Ledger

A single-processor system often survives sloppy idempotency by accident. A second processor removes it.

  • Stripe retries a delivery if your endpoint doesn't return a fast 2xx; PayPal retries on its own schedule, with its own event ID format.
  • A renewal can touch both rails — a Stripe subscription with a PayPal top-up wallet behind it, or a mid-cycle migration between the two.
  • An idempotency key scoped to "Stripe event ID" on one path and "PayPal event ID" on another never asks whether those keys describe the same billing fact.

Two correct-looking checks, each guarding only its own processor's retries, can both pass while the same renewal is applied twice — passes every test you write for it and is still wrong.


Where Stripe And PayPal Disagree About "Already Handled"

The two processors disagree about what a duplicate even is. Stripe's idempotent-requests documentation scopes a key to one API call. PayPal's idempotency guidelines scope their own request-ID header the same way. Neither has any concept of your business event — "I paid for this once." That gap is yours to close.


The Token-Metering Problem Nobody Mentions

For an AI product billing on usage, this gets worse. A token-metering event should bill exactly once per unit consumed, the discipline behind a real per-call cost matrix.

  • A wallet top-up confirmed by both a Stripe and a PayPal webhook, under weak idempotency, gets credited twice.
  • The balance matches nothing you billed, and a ticket lands before an engineer sees the log line.
  • Nothing trips an error — both webhooks return 200, both signatures pass. The ledger is simply wrong, the same quiet drift tool descriptions can develop over time.

The Reconciliation Layer You Actually Need

A reconciliation layer doesn't trust either processor's webhook as the only record of truth. It treats both as inputs to one internal ledger it owns, and checks that ledger against both processors on a schedule — not only when something looks wrong.

It's the same spine as a kill-switch and audit-log architecture — a ledger that answers what happened, without trusting one upstream system to report it.

One idempotency key per business event, not per processor. Generate your own key the moment a customer initiates a billable action, before you know which processor confirms it. Store each processor's event ID on that key, never as the key itself.

A single ledger both webhooks write to. Each handler verifies its own signature, resolves the business-event key, and writes to one shared table with a constraint rejecting a second write for the same key.

Reconcile on a schedule, not on dispute. Pull each processor's transaction list on a fixed interval and diff it against your ledger, the pattern Stripe describes for catching missed events. A mismatch a job finds is a line in a report; one a customer finds is a refund.


A Four-Week Rollout

  • Week 1: map every billable event to a single business-event key, independent of which processor confirms it first.
  • Week 2: rebuild both webhook handlers to write through that key into one shared ledger with a constraint rejecting duplicate writes.
  • Week 3: stand up the scheduled reconciliation job against both transaction APIs, alerting on any mismatch.
  • Week 4: run both rails in parallel, alerts live, before calling the system actually dual-rail.

What To Measure

  • Reconciliation mismatches per week — should trend toward zero, never quietly stop being checked.
  • Time between a mismatch and a scheduled job catching it — hours, not a billing cycle.
  • Tickets mentioning "charged twice" — the lagging indicator the job missed something the customer didn't.

A reviewer will eventually ask who owns this ledger — a delayed deadline doesn't buy you time to stop thinking about it.


If You Want ZPro to Build This With You

  • A review of your webhook handlers against the single-ledger pattern above
  • A business-event idempotency key design that survives a processor migration
  • A scheduled reconciliation job wired into your stack, with alerting that reaches a person
  • Token-metering guardrails for usage-based AI billing
  • A second opinion before you add a third payment rail

👉 Get in touch with us

About Jane Zdravevski

Jane Zdravevski is part of the ZPro team, bringing expertise in ai, billing, engineering, stripe, paypal to help organizations solve their most complex challenges.

Work with Us

Want to tell us a feedback on this blog post, or suggest an idea, or just chat?

Join Our Team

Passionate about solving complex problems? Explore career opportunities at ZPro.