Skip to content

Why payments are never counted twice

View as Markdown

How Reveata keeps one record per payment when webhooks retry, imports overlap, the browser and your server both report a sale, or a refund arrives.

On this page

Revenue numbers are only useful if each sale appears once. Reveata is built so that a payment can arrive many times, from several places, and still be stored once.

Payments come only from providers and your server

The tracking script never creates a payment. It only adds the visitor's ids to checkouts (those your server creates, through reveata.metadata(); Stripe Payment Links, buy buttons and pricing tables). Payments themselves arrive from your provider's webhooks and history import, or from your server through the Payments API. A thank-you page that is reloaded, bookmarked or opened twice adds nothing.

One record per transaction id

Every payment is stored under its website and the provider's own transaction id: the transactionId you send to the API, a Stripe invoice or PaymentIntent id, a Polar order, a Dodo payment. That pair is unique in the database:

  • A webhook that arrives again, or a sync that reads a payment already imported, finds the stored record and changes nothing.
  • Two copies arriving at the same instant can't both be saved: the second one is refused by the database and the first one is returned.
  • The same transaction id from a different provider is refused as a conflict rather than merged.

Webhooks are processed once

Each provider delivery is recorded by its event id before it is processed, and kept for 30 days. A delivery Reveata has already handled is answered as a duplicate and not run again. One that failed half-way is retried when the provider sends it again, and one stuck for more than five minutes can be taken over.

Overlapping sources agree on one id

  • Stripe Checkout and PaymentIntents. checkout.session.completed and payment_intent.succeeded describe the same payment and map to the same PaymentIntent id. A PaymentIntent that belongs to an invoice is skipped: the invoice is the payment, so a subscription charge is never stored as both.
  • History imports. Each sync re-reads a day of overlap with the previous one, so nothing is missed at the edges, and every payment it reads again is the same record.
  • Your own Payments API calls. Sending the same transactionId again returns the stored payment unchanged. Sending it with a different amount, currency or type is refused with a 409 that shows what is stored, so a bug in your code can't quietly change revenue.

Sending the same sale both from a connected provider and from your server under different ids is the one way to count it twice. If a provider is connected, don't also send its payments through the API.

Refunds, disputes and renewals

  • A refund is its own record with a negative amount, linked to the payment it refunds. It is booked on the refund date and inherits the original payment's source, so revenue by channel stays right.
  • A lost dispute or chargeback is booked the same way.
  • A renewal is a new payment of the same subscription, with its own id. It inherits the source of the subscription's first payment and is reported as renewal revenue. The first paid invoice after a free trial counts as new revenue, not a renewal.

You decide in Settings → Payments → How revenue is counted whether renewals count and whether refunds are subtracted; the payments themselves never change.

A payment that arrives before Reveata can link it to a visit is stored without a source. When the link becomes possible (the visitor is identified, or the webhook brings the visitor id later), the same record gets its source. A job also retries unlinked payments of the last 90 days every hour. Linking only updates the existing record; it never adds one.

Check it yourself

Settings → Payments → Recent payments lists the latest payments, one row per transaction id from your provider. To compare totals, set your provider's dashboard and Reveata to the same days and currency. Small differences usually come from currency conversion (Reveata converts at each day's rate), tax (left out where the provider reports it separately), and refunds booked on a later day than the sale.

Was this helpful?