Skip to main content
If your payment provider is not Stripe, Polar, Paddle, Dodo Payments, Creem, Whop, Razorpay, Lemon Squeezy, Shopify, RevenueCat, Superwall, the App Store or the Shopify App Store, or you run your own billing, report each payment to CrispStats yourself. Send a revenue event from your server with a secret API key and the visitor id you saved at checkout. The payment is recorded and attributed exactly like a webhook payment, with provider api. Amounts are integers in minor units (4900 is 49.00) with an ISO 4217 currency code. The same instructions are in Settings, Integrations, under Payment API, View instructions.

Report a payment from your server

You need:
  • A secret API key (cs_sk_…) with the events scope. Create one in Settings, API keys. See API keys. Never ship it to a browser.
  • The site’s public key (cs_pk_…).
  • The visitor id from crispstats.id(), saved with the order when the visitor checked out.
Send the event when the payment succeeds, for example in your provider’s webhook handler:
The authorization header must start with Bearer cs_sk_. Without it the request is handled as a browser event: it gets an empty 202 without any checks and is then dropped, because it does not come from a browser. A 202 response with an empty body means the payment was accepted. It appears under Payments on the Revenue screen within a few seconds. The example uses the global fetch, so it runs on Node.js 18 and later, Cloudflare Workers, Vercel Edge, Deno and Bun.

Request body

string
required
The site’s public key, cs_pk_….
string
required
revenue.
string
required
The page URL the payment relates to, or "".
number
required
The amount as an integer in minor units. 4900 is 49.00. A number with decimals fails with 400. A negative amount is recorded as a refund (only with a secret key, as here), and 0 records no payment.
string
The three-letter ISO 4217 currency code, such as USD. It must be exactly three characters, or the request fails with 400. When it is missing, or its three characters are not all letters, the site’s currency is used.
string
The visitor id from crispstats.id(), 32 lowercase hex characters. It ties the payment to that visitor’s visits. A value of another shape is ignored, and one over 64 characters fails with 400. Without a visitor id or a user id (i) the payment is recorded but not tied to a visit.
string
Your own user id, as passed to crispstats.identify(), up to 200 characters. Attribution then uses that user’s sessions. trackServer sends its userId option here.
string
An event name, up to 120 characters. Shown as the payment’s product when p.product is not set. trackServer sends its name option here.
object
Flat properties with keys up to 60 characters: strings (up to 500 characters), numbers, booleans or null. Set product to name the product in the payments table. trackServer sends its props option here.
The whole body may be at most 16 KB. The payment’s time is the time the collector receives it, so you cannot backdate payments. A ts field in the body is not used for the time.

Responses

Each accepted request is recorded as a separate payment. A retry after a timeout can record the same payment twice. Retry only on 429, 503 or a network error, and keep your own record of which payments you have reported.

How the payment is recorded

The payment is stored with provider api and kind one_time, or refund for a negative amount. The API does not record subscription_new or subscription_renewal: use a provider integration for those. See payment types. When the request carries vid and that visitor is still on your site, the payment is attached to their open session and appears in the realtime feed. Either way, first-touch attribution then runs as described in how revenue attribution works.

Report a payment from the browser

The script can also report a payment from the page the buyer lands on after paying:
The payment is tied to the current visit with no visitor id to pass, and is recorded with provider api like a server-side payment. It needs no API key, but it has trade-offs. Prefer the server for anything you rely on:
  • It can be blocked. Ad blockers that block the script block the payment too.
  • Anyone can send it. The public key is in your page, so a visitor can call crispstats.revenue() with any amount.
  • Every call counts. Reloading or revisiting the thank-you page records the payment again.
  • It cannot record a refund. Refunds are accepted only from a secret key (the server-side event above) or a verified payment webhook. A negative amount sent from the browser with the public key is dropped like any other invalid browser input.
  • It is skipped when the browser is not tracked, for example on an excluded path or with localStorage.crispstats_ignore set.
  • Errors are silent. The collector answers 202 to browser events even when the payload is invalid.
To call crispstats.revenue() before the script has loaded, add the queue stub for identify and revenue from custom events.

Next steps

Pass the visitor id

Get the id at checkout and store it with the order.

Server-side events

The same endpoint for custom events and identify.

API keys

Create a key with the events scope.
Last modified on November 24, 2026