GrowthRailDocs

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:

customer.created
Recorded as a referral signup
invoice.paid
Recorded as a paid conversion; fires the referrer's reward

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.

Prerequisites: You need an active Stripe account and the Growth Rail SDK installed in your app. The SDK exposes getCapturedReferralCode(), which you call client-side to read the incoming referral code from the ?referralCode=... URL the referred user landed on.
1

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.

These URLs are unique to your project and environment. Always copy them straight from the dashboard — there's nothing to construct or fill in by hand.
Stripe Integration Panel in Growth Rail
Find your unique Stripe webhook URLs inside the Growth Rail Integrations tab.
2

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:

EventWhat it triggers in Growth Rail
customer.createdReferral signup recorded
invoice.paidPaid conversion recorded; referrer reward fires

Repeat this for both sandbox and production Stripe accounts using their respective Growth Rail endpoint URLs.

3

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).

Growth Rail uses this secret to verify that every incoming webhook request genuinely originates from Stripe. Without it, events are rejected.
4

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.

server/billing.ts
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:

tsx
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

Security & limitations:
  • 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.