# Thank-you page payments

> Link payments to visitors from the checkout id on your thank-you page, or with reveata('payment'), without ever counting a payment twice.

Most payments are linked to the visit that brought the customer through checkout metadata or a decorated payment link (see [connect a payment provider](https://reveata.com/docs/connect-a-payment-provider)). Some checkouts can't carry those ids: a payment link sent by email, a QR code, a link in a social bio or a checkout opened from another app. For those, Reveata can use the page the customer comes back to after paying.

## How it works

Every pageview already sends the page address. When the address of a thank-you page holds a checkout id from your provider, Reveata records a **claim**: this visitor just came back from that checkout.

- With the provider connected in **Settings → Payments**, Reveata asks the provider about the checkout right away. That proves it exists and was paid, and the payment is recorded at once, before the webhook arrives.
- The payment is linked to the visitor (the API reports it with `matchedBy: "checkout_return"`).
- If the payment isn't paid yet (bank transfers and other delayed methods), the claim waits. When the provider's webhook brings the payment, it finds the claim and is linked then.

A claim never creates a payment. Payments only come from your provider's webhooks, imports, the provider API or the [payments API](https://reveata.com/docs/payments-api), and each one is stored once by its provider id. Opening the thank-you page again, refreshing it or sharing its link adds nothing.

Checkout metadata and decorated links always win: a claim only links a payment that has no visitor from those. The first visitor to claim a checkout keeps it; later claims of the same id are ignored. Checkout ids are never stored with your analytics events. Only campaign parameters are kept from page addresses.

Turn it off in **Settings → Payments → Link payments from thank-you pages**. It is on by default.

## Set up your provider

Add the parameter to the success or redirect URL of your checkout or payment link. Use your own thank-you page.

| Provider | Success / redirect URL | What Reveata checks |
|---|---|---|
| Stripe Checkout and Payment Links | `https://your-site.com/thanks?session_id={CHECKOUT_SESSION_ID}` | The Checkout Session, its PaymentIntent or invoice, and its subscription |
| Polar | `https://your-site.com/thanks?checkout_id={CHECKOUT_ID}` | Linked when the order arrives (orders carry their checkout id) |
| Dodo Payments | Any return URL. Dodo adds `?payment_id=pay_…&status=…` | The payment |

Stripe replaces `{CHECKOUT_SESSION_ID}` itself. In Stripe, set it under **Payment Links → After payment → Don't show confirmation page → Redirect** or as `success_url` when you create a Checkout Session.

Only ids in the provider's real format are read. `session_id=cs_…` counts as a Stripe session, but `session_id=42` from another tool on your site does not.

### Your own parameter

If you send payments with the [payments API](https://reveata.com/docs/payments-api), set **Settings → Payments → Your own thank-you page parameter**, for example `order`. A visit to `/thanks?order=1042` then claims the payment whose transaction id is `1042`, from any provider or the API.

## From JavaScript: `reveata('payment')`

When the thank-you page knows who paid but the address holds no id (Podia, Kajabi, Ghost, Gumroad, a custom checkout), call:

```js
reveata('payment', { email: 'ada@example.com' });

// or with your own transaction id
reveata('payment', { transactionId: 'order_1042' });
```

- **email**: the next payment with that email, from a day before the call to a day after it, is linked to this visitor (`matchedBy: "payment_call"` in the API). This follows **Match payments using browser identify calls**: with it off, email claims are ignored, because anyone can send them.
- **transactionId**: the payment with that transaction id (or provider reference) is linked.

With the npm package: `import { payment } from '@reveata/tracker'`. With Next.js: `trackPayment({ email })` from `@reveata/next`.

### Payments without an integration (unverified)

For a checkout Reveata isn't connected to, you can also send the amount:

```js
reveata('payment', { email: 'ada@example.com', amount: 49, currency: 'EUR' });
```

This records a payment only if you turn on **Settings → Payments → Accept unverified browser payments**. It is off by default. Such payments are marked **Unverified** in the payments list, because anyone can send them from a browser. They count as revenue, but they never produce [subscription goals](https://reveata.com/docs/subscription-goals). If a verified payment with the same email (within a day) or the same transaction id arrives later, it replaces the unverified one, so the sale is counted once. If the verified payment is already there, the call adds nothing. Reloading the thank-you page doesn't add a second payment.

## Limits

- Claims are kept for 7 days. A checkout claim links payments made up to 2 days before or after it.
- In cookieless mode the claim uses the visitor's daily id. It works when the thank-you page is opened on the same day and device as the visit.
- Polar's checkout API is not asked. A Polar claim is linked when the order webhook or import arrives.
- The thank-you page must have the tracking script, and the visitor must allow it.
