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

# Stripe

> Connect Stripe to record invoices, one-time Checkout payments, refunds and subscriptions as revenue, linked to your players.

Manalens records each Stripe sale and refund from a signed webhook and links it to the player who paid. [Revenue](https://docs.manalens.dev/features/revenue.md) and [attribution](https://docs.manalens.dev/attribution/models.md) then show which channels bring paying players.

| Data | How it gets here | What it shows |
| - | - | - |
| Invoices, one-time Checkout payments, refunds and subscriptions | Signed Stripe webhooks | Revenue on Overview, user profiles, the Explorer and attribution |
| History (optional) | An import with a restricted read key | Past revenue, reconciled daily |

## Connect Stripe

You need the owner or admin role and a verified [MFA](https://docs.manalens.dev/security/mfa.md) session.

**1. Create the webhook endpoint**

In **Settings**, **Integrations**, **Stripe**, click **Create webhook endpoint**.

**2. Register it in Stripe**

In the Stripe Dashboard, add a webhook endpoint with the URL from Manalens. Select the [supported events](#supported-events).

**3. Save the signing secret**

Paste the Stripe webhook signing secret into **Webhook signing secret** and click **Save signing secret**. Revenue ingestion starts.

**4. Import history (optional)**

Enter a restricted **Read API key** with read access to invoices, refunds, subscriptions and Checkout Sessions, then import. Without Checkout Sessions access, one-time Checkout payments are skipped. Imports resume automatically and are reconciled daily.

Secrets and read keys are encrypted and never returned to the browser.

## Supported events

`invoice.paid`, `checkout.session.completed`, `checkout.session.async_payment_succeeded`, `charge.refunded` and `customer.subscription.*`.

Each webhook is verified against its signature. Other event types are ignored.

## One-time Checkout payments

A one-time Checkout Session (mode `payment`, also from a Payment Link) is recorded from `checkout.session.completed` when paid, or from `checkout.session.async_payment_succeeded` for a delayed method such as a bank debit. The record ID is the payment intent (`pi_…`), so refunds link to it.

A sale counts once. Sessions with an invoice or a subscription are counted by their invoices instead.

## Link payments to players

Use one of these:

1. A `user_id` in the Stripe `metadata`. For a Checkout Session, the session `metadata.user_id`, else its `client_reference_id`.
2. An identify trait `stripe_customer_id`:

```ts theme={null}
await analytics.identify('user_123', { stripe_customer_id: 'cus_123' });
```

See [link revenue to users](https://docs.manalens.dev/features/revenue.md#link-revenue-to-users) for the rules.

## Disconnect

In **Settings**, **Integrations**, **Stripe**, click **Disconnect read API**. This removes the read key and stops imports. The webhook and imported revenue stay. To stop new revenue, delete the webhook endpoint in the Stripe Dashboard.


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