> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crispstats.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> CrispStats is a hosted, privacy-first analytics product. It has no self-hosted edition, no session replay, no heatmaps, no A/B testing and no data import except a site's history from a Plausible export (Settings, Import and export). Websites use the script. iOS, Android, React Native and Flutter use the mobile SDKs in the install guides. Those SDKs are source files, not a published package, and they do not read an advertising id.
> The script global is crispstats(...), site keys start with cs_pk_ and secret API keys start with cs_sk_. The script is served from https://in.crispstats.com/d.js and the REST API lives at https://crispstats.com/api/v1.
> The script tag is the main install; the npm package @crispstats/tracker does the same from code, never alongside the tag. Integrations copy the script tag, the queue stub, crispstats.d.ts and proxy code from these docs or from Settings, Tracking code in the dashboard. A first-party proxy forwards one path of the site to https://in.crispstats.com/p/ and forwards only content-type, user-agent, accept-language, referer, origin, if-none-match and x-forwarded-for, never cookies.

# Fix duplicate payments in CrispStats

> Why a payment can be counted twice in CrispStats (a provider and the API, retries without a transaction id, the browser and the server) and how to stop it and delete the extra copy.

CrispStats stores each payment once per site, provider and payment id. A webhook that arrives twice, a webhook and a history import of the same sale, or a payments API call retried with the same `transactionId` are all recorded once. When revenue still looks too high, the same sale reached CrispStats twice under two different identities. This page lists the ways that happens and how to fix each.

## Find the duplicate

Open **Revenue** and look at **Payments** for the day of the sale. A duplicate shows as two payments with the same amount within a few minutes of each other. The provider column tells you where each came from: a provider's name for a connected integration, **API** for the payments API, a `revenue` event or `crispstats.revenue()`.

To check from code, list the day's payments with `GET /api/v1/sites/{siteId}/payments` (see the [API reference](https://docs.crispstats.com/api-reference/introduction.md)) and compare `amount`, `timestamp` and `provider`.

## The causes and their fixes

> [accordion] The provider is connected and you also send the payment yourself
>
> A sale recorded by a connected provider (Stripe, Paddle and the others) and sent again through the payments API counts twice: the two copies have different providers, so neither is a repeat of the other.
>
> **Fix:** report each sale one way. Keep the provider integration and stop sending those sales to the API, then delete the API copies:
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
> curl -X DELETE "https://crispstats.com/api/v1/sites/<site id>/payments?from=2026-12-01&to=2026-12-31" \
>   -H "authorization: Bearer cs_sk_..."
> ```
>
> Deleting only ever removes payments recorded through the API. The provider's copies stay.

> [accordion] A retry of a revenue event
>
> A `revenue` event sent to the collector (`POST https://in.crispstats.com/e`) is recorded as a new payment every time it is accepted. A retry after a timeout records the sale a second time.
>
> **Fix:** send payments to the [payments API](https://docs.crispstats.com/revenue/payment-api.md) with your order or invoice id as `transactionId`. A retry with the same id answers `duplicate: true` and records nothing. Delete the extra copy by its time, as below.

> [accordion] The same payment sent with two different ids
>
> The payments API recognises a repeat only by `transactionId`. If one call sends the checkout session id and a later one the invoice id for the same sale, both are recorded.
>
> **Fix:** pick one id that never changes for a payment, such as your order id, and use it in every call, retries and backfills included. Delete the copy recorded under the other id:
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
> curl -X DELETE "https://crispstats.com/api/v1/sites/<site id>/payments?transactionId=cs_live_a1b2c3" \
>   -H "authorization: Bearer cs_sk_..."
> ```

> [accordion] The browser and the server both report the sale
>
> `crispstats.revenue()` on the thank-you page and a server call for the same order are two payments. Reloading the thank-you page adds another each time.
>
> **Fix:** remove `crispstats.revenue()` from the page and report from the server only, with a `visitorId` saved at checkout so the sale keeps its attribution. See [pass the visitor id](https://docs.crispstats.com/revenue/visitor-id-at-checkout.md).

> [accordion] Two sites track the same checkout
>
> A provider connected to two sites, or one API key used for two site ids, records the sale on both. Each site's revenue is right on its own; added together they count it twice.
>
> **Fix:** connect each provider account to the one site it sells for, and send each payment to that site's id.

## Delete the extra copy

The extra copy is easiest to remove by the filter that matches only it:

| You know | Delete with |
| - | - |
| Its `transactionId` | `?transactionId=…` removes that sale and its refunds. |
| The visitor who paid | `?visitorId=…&from=…&to=…` removes that visitor's API payments in the range. |
| Only when it happened | `?from=…&to=…` removes every API payment in the range. Narrow the range to the minutes of the duplicate first. |

A request without a filter deletes nothing. Reports, the visitor's revenue and the daily figures behind digests and alerts are updated straight away. To remove a connected provider's test payments instead, list them on **Revenue** and use **Remove test payments**.

## What is never counted twice

* A provider's webhook delivered more than once.
* A webhook and the [history import](https://docs.crispstats.com/revenue/history.md) of the same payment.
* A payments API call repeated with the same `transactionId`, including a refund repeated with the same sale and amount (or the same `refundId`).
* A refund that arrives before its sale: it waits and counts once, when the sale arrives.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.