Stripe
Attribute referrals to your Stripe billing — no conversion code required.
How It Works
Connect your Stripe account to Growth Rail by registering a webhook in your Stripe dashboard. Growth Rail listens to two Stripe events:
When Stripe fires customer.created, Growth Rail reads the customer metadata you attached at creation time and records a referral signup against the referrer identified by gr_ucc. When Stripe fires invoice.paid, Growth Rail records a paid conversion, captures the invoice amount as revenue, and triggers the referrer's reward.
getCapturedReferralCode(), which you call client-side to read the incoming referral code from the ?referralCode=... URL the referred user landed on.Get your webhook endpoint URL
In the Growth Rail dashboard, open Integrations from the sidebar and select the Stripe tab. It shows your project's Sandbox and Production webhook endpoint URLs, each with a copy button.

Create a Stripe webhook
In your Stripe Dashboard, go to Developers → Webhooks and click Add endpoint. Paste the Growth Rail URL from Step 1 and enable exactly these two events:
| Event | What it triggers in Growth Rail |
|---|---|
customer.created | Referral signup recorded |
invoice.paid | Paid conversion recorded; referrer reward fires |
Repeat this for both sandbox and production Stripe accounts using their respective Growth Rail endpoint URLs.
Copy the Stripe signing secret into Growth Rail
After creating the webhook in Stripe, reveal the Signing secret (whsec_...) on the webhook detail page. Then, in the Growth Rail dashboard, open Integrations from the sidebar, select the Stripe tab, and paste it into the Signing secret field for the matching environment (sandbox or production).
Attach attribution metadata when creating Stripe customers
When your backend creates a Stripe customer for a referred user, include the Growth Rail attribution keys in the metadata object. Retrieve the referral code client-side using the Growth Rail SDK before your signup flow completes, then pass it to your server.
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
// growthRailUcc comes from the client via getCapturedReferralCode()
async function createStripeCustomer(
email: string,
user: { id: string },
growthRailUcc: string,
org?: { id: string },
) {
const customer = await stripe.customers.create({
email,
metadata: {
gr_ucc: growthRailUcc, // referrer's referral code (required)
gr_user_id: user.id, // your user id (required)
// gr_org_id: org?.id, // optional, for B2B / org-level referrals
},
});
return customer;
}On the client side, call getCapturedReferralCode() from the Growth Rail SDK and pass the result to your server when the user signs up:
import { useGrowthRail } from '@growth-rail/react';
export function SignupForm() {
const { getCapturedReferralCode } = useGrowthRail();
async function handleSubmit(email: string) {
const referralCode = getCapturedReferralCode(); // may be null
await fetch('/api/signup', {
method: 'POST',
body: JSON.stringify({ email, referralCode }),
});
}
return (/* your form */);
}Metadata Reference
- Growth Rail only needs the Stripe signing secret (
whsec_...) — never your Stripe API key. Do not paste your Stripe secret key into Growth Rail or share it with any third party. - Reward reversal on refunds or subscription cancellations is not yet supported. Rewards that were already granted will not be automatically revoked when an invoice is refunded or a subscription is cancelled. This feature is coming soon.