Stripe
Send payment and subscription events from Stripe to TrichiData and link them to your users.
The Stripe integration receives Stripe events through a webhook and turns them into TrichiData events, so revenue appears next to the rest of your funnel without any server code.
Restricted API key
Create a restricted key in Stripe with these permissions. Then open Sources in your project (Configuration → Sources), click Connect on Stripe and paste the key.
| Resource | Permission |
|---|---|
| Charges | Read |
| Invoices | Read |
| Subscriptions | Read |
| Customers | Read |
| Checkout Sessions | Read |
| Webhook Endpoints | Write |
Webhook Endpoints: Write lets TrichiData register its own webhook endpoint. No other write access is needed.
Restricted (rk_...) and secret (sk_...) keys are accepted. The key is stored encrypted and never shown again.
Events produced
| TrichiData event | Meaning |
|---|---|
checkout_completed | A Checkout Session was completed |
payment_succeeded | A payment succeeded (from invoice.paid or payment_intent.succeeded, only when the amount is greater than 0) |
subscription_started | A subscription was created |
subscription_canceled | A subscription was canceled |
refunded | A charge was refunded |
These events carry the source stripe. Stripe amounts are in minor units (cents); revenue reports divide them by 100 and group by currency. In reports, payment_succeeded counts as a payment alongside the SDK's order_completed.
Link payments to users
TrichiData joins Stripe events to your users by the same user id you pass to identify() — your auth user id (for example Supabase auth.users.id). Put it in one of:
metadata.user_idon the Checkout Session, Customer, Subscription or PaymentIntentclient_reference_idon the Checkout Session
Checkout Session example (Node):
const session = await stripe.checkout.sessions.create({
mode: 'subscription',
line_items: [{ price: 'price_123', quantity: 1 }],
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/pricing',
client_reference_id: user.id, // same value as identify({ userId })
metadata: { user_id: user.id },
subscription_data: { metadata: { user_id: user.id } },
});On the client, identify the same user after login:
await client.identify({ userId: user.id });If the ids differ, Stripe revenue cannot be attributed to the visitor's source or campaign.
Do not put emails, names or other personal data in metadata. Use the opaque user id only.
See also
- Supabase — sign-up events from Supabase Auth
- Install with your AI assistant
- Browser SDK —
identify()andreset()