Stripe Integration

Automatically track purchases and calculate commissions with Stripe

Overview

Refgrow integrates with Stripe to automatically track payments and calculate commissions for your affiliates.

  • Automatic tracking of one-time payments and subscriptions
  • Support for product-specific commission rates
  • Support for affiliate-specific commission overrides
  • Secure webhook implementation for real-time tracking
  • Works with both Stripe Checkout Sessions and Payment Links

Setting Up Stripe Integration

Note: You'll need a Stripe account to track payments. If you don't have one, sign up here.

Step 1: Connect Your Stripe Account

  1. Go to your project's "Integration" tab
  2. Select "Stripe Webhooks" as your tracking method
  3. Enter your Stripe Secret Key (a restricted key is recommended)
  4. Click "Connect Stripe"
Auto-configuration: Refgrow will automatically set up the required webhook endpoint in your Stripe account.

Step 2: Choose Your User Flow

Select the appropriate user conversion flow for your business:

  • Click → Signup → Purchase: Users create an account before making a purchase
  • Click → Purchase: Users can purchase directly without signing up first
  • Both: Your platform supports both flows

Passing Referral Codes to Stripe

Important: If you have a direct purchase flow (Click → Purchase), passing the referral code to Stripe is essential for correct attribution.

For Stripe Checkout Sessions

When creating a checkout session on your server, pass the referral code in the metadata:

// Example (Node.js Server-Side)
const refCode = req.cookies.refgrow_ref_code; // Get code from cookie

const session = await stripe.checkout.sessions.create({
  // ... other session parameters
  metadata: {
    referral_code: refCode || null // Pass the code here
  }
});

For Stripe Payment Links

For payment links, there are two options:

Option 1: Automatic Processing with JavaScript

  1. Add a special class to your payment links:
  2. <a href="https://buy.stripe.com/xyz..." class="refgrow-stripe-payment-link">Buy Now</a>
  3. Call the helper function after the page loads:
  4. // Call this once after the page loads
    if (window.Refgrow) {
      Refgrow.processStripePaymentLinks();
    }

Option 2: Programmatic Redirects

Redirect users with this helper function:

// Use this when you want to redirect a user to a payment link
if (window.Refgrow) {
  Refgrow.redirectToStripePaymentLink('https://buy.stripe.com/xyz...');
  // Don't use window.location.href = url; directly
}

Commission Configuration

Default Commission Settings

Configure your default commission structure in your project settings:

  • Commission Type: Percentage or Fixed Amount
  • Commission Value: The percentage or fixed amount
  • Commission Duration: Lifetime, First Purchase, or Limited Period

Product-Specific Commissions

Override commission rates for specific products:

  1. Go to your project's "Integration" tab
  2. Scroll to "Product-Specific Commissions"
  3. Click "Add Product Commission"
  4. Select a Stripe product and set its unique commission rate
Note: Product-specific rates take priority over your default commission settings.

Affiliate-Specific Overrides

Set custom commission rates for individual affiliates:

  1. Go to your "Affiliates" tab
  2. Find the affiliate you want to customize
  3. Click "Manage Override"
  4. Set a custom commission type and value
Priority: Affiliate-specific overrides take highest priority, followed by product-specific commissions, with default settings as the fallback.

How It Works

1. Referral Click

User clicks an affiliate link and the refgrow_ref_code cookie is set.

2. Stripe Payment

The referral code is passed to Stripe, and the user completes payment.

3. Webhook Processing

Refgrow receives the webhook, attributes the sale, and calculates the commission.

Supported Webhook Events

Refgrow automatically listens for these webhook events:

  • checkout.session.completed - When a purchase is completed
  • invoice.paid - When a subscription invoice is paid
  • customer.subscription.created - When a new subscription is created
  • customer.subscription.updated - When a subscription is updated

Troubleshooting

  1. Verify your Stripe API key is correctly set in your project settings
  2. Check that the webhook endpoint was created (URL should match https://refgrow.com/webhook/stripe/{your-project-id})
  3. Confirm all required events are enabled for the webhook
  4. Check your Stripe dashboard for webhook delivery logs

For "Click → Purchase" flow:

  • Ensure the referral code is being passed to Stripe via metadata or client_reference_id
  • Check that your tracking script is installed on all pages
  • Verify the cookie is being set (check browser developer tools)

For "Click → Signup → Purchase" flow:

  • Verify the customer email in Stripe matches the email used during signup
  • Check that the referral attribution was created for the user
  • Consider passing the referral code to Stripe as a more reliable method

Next Steps

Using the Tracking Script

Learn more about Refgrow's client-side tracking.

View Guide
Commissions

Understand how commission calculations work.

View Guide
Managing Affiliates

Learn how to manage your affiliate program.

View Guide