Skip to Content
TrichiDataTrichiData
Sources

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.

ResourcePermission
ChargesRead
InvoicesRead
SubscriptionsRead
CustomersRead
Checkout SessionsRead
Webhook EndpointsWrite

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 eventMeaning
checkout_completedA Checkout Session was completed
payment_succeededA payment succeeded (from invoice.paid or payment_intent.succeeded, only when the amount is greater than 0)
subscription_startedA subscription was created
subscription_canceledA subscription was canceled
refundedA 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.

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_id on the Checkout Session, Customer, Subscription or PaymentIntent
  • client_reference_id on 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

On this page