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
Step 1: Connect Your Stripe Account
- Go to your project's "Integration" tab
- Select "Stripe Webhooks" as your tracking method
- Enter your Stripe Secret Key (a restricted key is recommended)
- Click "Connect Stripe"
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
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
- Add a special class to your payment links:
- Call the helper function after the page loads:
<a href="https://buy.stripe.com/xyz..." class="refgrow-stripe-payment-link">Buy Now</a>
// 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:
- Go to your project's "Integration" tab
- Scroll to "Product-Specific Commissions"
- Click "Add Product Commission"
- Select a Stripe product and set its unique commission rate
Affiliate-Specific Overrides
Set custom commission rates for individual affiliates:
- Go to your "Affiliates" tab
- Find the affiliate you want to customize
- Click "Manage Override"
- Set a custom commission type and value
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 completedinvoice.paid
- When a subscription invoice is paidcustomer.subscription.created
- When a new subscription is createdcustomer.subscription.updated - When a subscription is updated
Troubleshooting
- Verify your Stripe API key is correctly set in your project settings
- Check that the webhook endpoint was created (URL should match
https://refgrow.com/webhook/stripe/{your-project-id}
) - Confirm all required events are enabled for the webhook
- 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