> ## 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 web analytics product. It has no self-hosted edition, no session replay, no heatmaps, no A/B testing, no mobile SDKs and no data import except a site's history from a Plausible export (Settings, Import and export).
> 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.
> There is no npm package to install. 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.

# Refunds, renewals and payment types in CrispStats

> How CrispStats records one-time payments, new subscriptions, renewals and refunds per provider, deduplicates webhooks, hashes emails and exports CSV.

CrispStats stores every payment with one of four kinds: `one_time`, `subscription_new`, `subscription_renewal` or `refund`. The kind decides which figure a payment counts toward on the Revenue screen. This page lists how each provider's events map to those kinds, how duplicate webhooks are prevented, what is kept of the customer's email, and how to export your payments as CSV.

## Payment kinds

| Kind | Label in the dashboard | Counts toward |
| - | - | - |
| `one_time` | **One-time** | **Revenue**, **New revenue** |
| `subscription_new` | **New** | **Revenue**, **New revenue**, **MRR** |
| `subscription_renewal` | **Renewal** | **Revenue**, **Renewals**, **MRR** |
| `refund` | **Refund** | **Refunds**, subtracted in **After refunds** |

Amounts are integers in minor units of the payment's own currency. Refunds are stored as negative amounts, so they show with a minus sign in the payments table and in the CSV export.

A customer's first `one_time` or `subscription_new` payment is their first payment. First payments feed **Conversion rate** and **Median time to first payment**. CrispStats recognises the same customer by email hash, then user id, then visitor id. The **Time to convert** section counts every `one_time` and `subscription_new` payment in the range.

**MRR** sums each subscriber's latest `subscription_new` or `subscription_renewal` payment, if it was made in the 31 days before the end of the selected range.

## How each provider is recorded

| Provider | First payment | Renewal | Refund |
| - | - | - | - |
| [Stripe](https://docs.crispstats.com/revenue/stripe.md) | Checkout: `one_time` for mode `payment`, `subscription_new` for mode `subscription`. `invoice.paid` with billing reason `subscription_create`: `subscription_new`. Payment Intents with `crispstats_visitor_id`: `one_time`. | `invoice.paid` with a subscription billing reason other than `subscription_create`. | `charge.refunded`, the difference from the previous refunded total. |
| [Lemon Squeezy](https://docs.crispstats.com/revenue/lemon-squeezy.md) | `order_created`: always `one_time`, including the first payment of a subscription. | `subscription_payment_success`, except the initial invoice. | `order_refunded`, `subscription_payment_refunded`: the difference from the last recorded total. |
| [Polar](https://docs.crispstats.com/revenue/polar.md) | `order.paid`: `subscription_new` for `subscription_create`, `one_time` for `purchase` and any other billing reason. | `order.paid` with `subscription_cycle`, `subscription_update` or `subscription_meter_cycle`. | `order.refunded`: the difference from the last recorded total. |
| [Paddle](https://docs.crispstats.com/revenue/paddle.md) | `transaction.completed`: `subscription_new` with a `subscription_id`, otherwise `one_time`. | `transaction.completed` whose `origin` starts with `subscription_`. | Approved `refund` and `chargeback` adjustments. |
| [Dodo Payments](https://docs.crispstats.com/revenue/dodo.md) | `payment.succeeded`: `one_time` without a subscription, `subscription_new` for the first payment seen per `subscription_id`. | Later `payment.succeeded` events for the same `subscription_id`. | `refund.succeeded`. |
| [Creem](https://docs.crispstats.com/revenue/creem.md) | `checkout.completed`: `subscription_new` with a subscription in the payload, otherwise `one_time`. `subscription.paid` for the first payment carries the same transaction and is stored once. | Later `subscription.paid` events, from the subscription's `last_transaction`. | `refund.created` with status `succeeded`, for `refund_amount`. |
| [Razorpay](https://docs.crispstats.com/revenue/razorpay.md) | `order.paid`: `one_time`. `subscription.charged` with a `paid_count` of 1: `subscription_new`. | `subscription.charged` after the first charge. | `refund.processed`, except automatic refunds of payments that were never captured. |
| [RevenueCat](https://docs.crispstats.com/revenue/revenuecat.md) | `INITIAL_PURCHASE`: `subscription_new` (a free trial at price 0 is skipped). `NON_RENEWING_PURCHASE`: `one_time`. A `RENEWAL` that ends a free trial: `subscription_new`. | `RENEWAL`. | `CANCELLATION` with `cancel_reason` `CUSTOMER_SUPPORT` and a negative price. Only the latest period's refund is sent. |
| [Superwall](https://docs.crispstats.com/revenue/superwall.md) | Initial purchase: `subscription_new`. Non-renewing purchase: `one_time`. A renewal that ends a free trial: `subscription_new`. | Renewal and product change. | Refund, of its purchase. |
| [App Store](https://docs.crispstats.com/revenue/app-store.md) | Daily report rows: paid downloads and in-app purchases are `one_time`, subscription rows marked new are `subscription_new`. | Subscription rows not marked new. | Rows with negative units and price, counted only against an earlier counted sale of the same item and currency. |
| [Whop](https://docs.crispstats.com/revenue/whop.md) | A paid payment: `subscription_new` for `subscription_create`, `one_time` for `one_time` and `manual`. | `subscription_cycle` and `subscription_update`. | Each succeeded refund, and chargebacks the company lost. |
| [Shopify](https://docs.crispstats.com/revenue/shopify.md) | Every paid order is `one_time`. | Not available: Shopify does not mark renewal orders. | Each refund of an order. |
| [Shopify App Store](https://docs.crispstats.com/revenue/shopify-app-store.md) | The first subscription sale of a charge: `subscription_new`. One-time sales: `one_time`. | Later subscription sales and usage sales. | Adjustments and credits that take money back, counted only against a counted sale of the same charge. |
| [Payment API](https://docs.crispstats.com/revenue/payment-api.md) | Every `revenue` event with a positive amount is `one_time`. | Not available. | A `revenue` event with a negative amount, sent with a secret key. A negative amount from the browser is dropped. |

### Refunds reported as running totals

Stripe, Lemon Squeezy and Polar report the total refunded so far on a charge or order, not the latest refund. For Stripe, CrispStats takes the previous total from the event itself. For Lemon Squeezy and Polar, it remembers the last total it recorded for each order (for 400 days) and stores only the difference. Either way, two partial refunds become two refund rows, and a redelivered refund records nothing new.

### Attribution of renewals and refunds

Renewals and refunds often arrive without the visitor id you passed at checkout. When a subscription renewal or a refund has neither a visitor id nor a user id, CrispStats gives it the attribution of the customer's first attributed payment with the same provider and the same email hash. Only renewals and refunds carry attribution over this way, and never from another provider. A new sale (a one-time payment or the first payment of a subscription) is never matched by email: if it arrives without the visitor id or user id from its own checkout, it stays unattributed. Paddle payments have no email, so a Paddle renewal or refund is attributed only when its own `custom_data` carries the id. For Stripe subscriptions, putting `crispstats_visitor_id` in the subscription's metadata attributes renewals directly.

## Deduplication

Every payment is stored under an id taken from the provider's own ids, the same for every event that describes that charge: the Payment Intent of a one-time Stripe Checkout payment, the invoice of a subscription payment, the order, transaction or payment elsewhere, and the refund or adjustment for a refund. The database keeps at most one payment per site, provider and id, so a second event for the same charge (a Checkout Session and its Payment Intent that both carry the visitor id, the Checkout event and the first `invoice.paid` of a subscription, or any redelivery) is answered with `200` and adds nothing.

Refunds that arrive as running totals are handled separately, as described [above](#refunds-reported-as-running-totals).

The payment API has no such id: each accepted request is a new payment. See the [warning on retries](https://docs.crispstats.com/revenue/payment-api.md#responses).

## Customer email hashing and masking

When a provider includes the customer's email, the collector turns it into two values and discards the address:

* **A hash**: SHA-256 of the trimmed, lowercased address. It links a customer's renewals and refunds to their first payment and identifies their first payment. It is not shown anywhere.
* **A masked form**: the first character of the local part and of the domain, with the rest of the domain kept from its first dot. `jane.doe@example.co.uk` becomes `j***@e***.co.uk`. It is shown in the payments table and the CSV export, enough to recognise a customer, not to contact them.

The full address is never stored. Payments from Paddle, Shopify, the App Store, the Shopify App Store and the payment API are stored without an email, so those payments show **No e-mail**.

## Export payments as CSV

On the Revenue screen, select **Export CSV** in the top bar. The file holds every payment of the current view: the selected date range, the filters and the kind filter (**All**, **New**, **Renewals**, **One-time** or **Refunds**), across all pages of the table, oldest first. A range with more than 50,000 payments is cut to the latest 50,000. The button is disabled when the selected range and filters hold no payments.

The file is named `payments-<domain>-<from>-to-<to>.csv`, is UTF-8 with a byte order mark so spreadsheet apps read it correctly, and has these columns:

| Column | Content |
| - | - |
| `payment_id` | CrispStats' id for the payment. |
| `time_utc` | Payment time, ISO 8601 in UTC. |
| `amount` | Minor units divided by 100, with two decimals. Negative for refunds. |
| `currency` | ISO 4217 code. |
| `kind` | `one-time`, `new`, `renewal` or `refund`. |
| `product` | Product name, when the provider sent one. |
| `provider` | `stripe`, `polar`, `paddle`, `dodo`, `creem`, `whop`, `razorpay`, `freemius`, `lemonsqueezy`, `shopify`, `revenuecat`, `superwall`, `appstore`, `shopify_partners`, or `api` for the payment API. |
| `customer` | Masked email. |
| `visitor_id` | The visitor the payment belongs to, empty when the payment has no visitor and no attribution. |
| `visitor` | The visitor's display name in the dashboard. |
| `country` | Country code of the visit in which the customer paid, or of their latest visit before the payment. |
| `source`, `channel`, `campaign`, `landing_page` | First-touch source, channel, UTM campaign and landing page. |
| `days_to_convert` | Days from the first visit to the payment. |
| `touches` | Sessions up to and including the paying one. |

> [!NOTE]
>
> The `amount` column always divides by 100. For currencies without minor units, such as JPY, multiply it by 100 to get the amount in the currency's own units.

Text that a spreadsheet would run as a formula (starting with `=`, `+`, `-`, `@`, a tab or a carriage return) is prefixed with an apostrophe.

## Next steps

> [card] [How attribution works](https://docs.crispstats.com/revenue/overview.md)
>
> First-touch rules and the Revenue screen.

> [card] [Payment API](https://docs.crispstats.com/revenue/payment-api.md)
>
> Report one-time payments and refunds yourself.

> [card] [CSV export](https://docs.crispstats.com/share/csv-export.md)
>
> Export other reports from the dashboard.


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