← View All Guides
Stripe logo
Integration Guide

How to Create Referral Discount Coupons with Stripe + GrowSurf

Generate unique Stripe discount codes for referral participants automatically.

Unique discount coupons are a classic referral incentive β€” and when you combine GrowSurf's referral tracking with Stripe's coupon and promotion code system, you can automatically generate and distribute personalized discount codes to both referrers and their friends. This dual-sided incentive is proven to increase referral conversion rates.

In this guide, you'll learn how to programmatically create Stripe promotion codes tied to GrowSurf referral campaigns. We'll cover generating unique codes for each referrer, applying friend-side discounts at checkout, and tracking which coupons drive the most conversions. Whether you're offering "Give $10, Get $10" or percentage-based discounts, this integration handles it all.

Integration Steps

Step 1: Design Your Double-Sided Coupon Strategy

Plan your referral coupon structure. The most effective programs offer rewards to both the referrer and the referred friend (double-sided rewards).

  • Define the friend's discount (e.g., 15% off first purchase)
  • Define the referrer's reward (e.g., $10 credit after friend's purchase)
  • Decide on single-use vs. multi-use codes
  • Set expiration periods for coupons (30-90 days recommended)

Step 2: Create a Base Coupon in Stripe

Create a base coupon in Stripe that your promotion codes will be generated from. The base coupon defines the discount amount and restrictions.

  • Go to Stripe Dashboard > Products > Coupons
  • Create a coupon with your desired discount (e.g., 15% off)
  • Set max_redemptions if you want to limit total usage
  • Configure product restrictions if the discount only applies to specific plans

Step 3: Generate Unique Promotion Codes via API

When a new participant joins your GrowSurf campaign, automatically generate a unique Stripe promotion code linked to the base coupon.

  • Listen for GrowSurf's PARTICIPANT_CREATED webhook event
  • Call stripe.promotionCodes.create() with a unique code string
  • Use the participant's referral code as part of the promotion code for easy tracking
  • Store the promotion code ID mapped to the GrowSurf participant

Step 4: Distribute Codes Through GrowSurf's Sharing

Configure GrowSurf to display the unique Stripe promo code alongside the referral link so participants can share it via social media, email, or word of mouth.

  • Use GrowSurf's API to update the participant's metadata with their promo code
  • Customize GrowSurf's referral widget to display the promo code
  • Add the code to GrowSurf's email templates using merge tags

Step 5: Apply Codes at Checkout

Integrate the promotion code acceptance into your Stripe Checkout or payment flow. When a referred friend uses the code, Stripe applies the discount and you can track the conversion.

  • Add a promo code field to your Stripe Checkout Session
  • Enable allow_promotion_codes: true in your Checkout Session creation
  • Alternatively, auto-apply the code using URL parameters from the referral link

Step 6: Track Coupon Performance and Attribution

Monitor which referral coupons are being redeemed and attribute conversions back to the correct referrer in GrowSurf.

  • Listen for Stripe's customer.discount.created webhook event
  • Look up the promotion code to find the associated referrer
  • Call GrowSurf's API to mark the referral as converted
  • Track redemption rates in your analytics dashboard

Code Snippets

// Generate unique promo code when participant joins
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);

app.post('/api/growsurf-participant-created', async (req, res) => {
  const { participant } = req.body;

  // Create a unique promotion code from the base coupon
  const promoCode = await stripe.promotionCodes.create({
    coupon: 'referral-friend-15pct', // Your base coupon ID
    code: `REF-${participant.referralCode.toUpperCase()}`,
    max_redemptions: 1, // Single use per friend
    metadata: {
      growsurf_participant_id: participant.id,
      referrer_email: participant.email
    }
  });

  // Update GrowSurf participant with the promo code
  await fetch(
    `https://api.growsurf.com/v2/campaign/${CAMPAIGN_ID}/participant/${participant.id}`,
    {
      method: 'PUT',
      headers: {
        'Authorization': `Bearer ${GROWSURF_API_KEY}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        metadata: { stripePromoCode: promoCode.code }
      })
    }
  );

  res.json({ promoCode: promoCode.code });
});

// Stripe Checkout with promo code support
app.post('/api/create-checkout', async (req, res) => {
  const session = await stripe.checkout.sessions.create({
    mode: 'subscription',
    allow_promotion_codes: true, // Enables promo code field
    line_items: [{ price: 'price_xxx', quantity: 1 }],
    success_url: 'https://yourapp.com/success',
    cancel_url: 'https://yourapp.com/cancel'
  });
  res.json({ url: session.url });
});

Tips

Make Promo Codes Memorable

Instead of random strings, use the referrer's name or username as part of the promo code (e.g., "FRIEND-JOHN20"). Memorable codes get shared more often via word of mouth and are easier to type at checkout.

Auto-Apply Codes from Referral Links

Pass the promo code as a URL parameter in the referral link (e.g., ?promo=REF-ABC123) and automatically populate it in your checkout flow. This removes friction and increases conversion rates significantly.

Set Smart Expiration Windows

Give promo codes a 30-60 day expiration window. Too short and referred friends won't have time to convert; too long and the urgency to act disappears. You can set this via expires_at in the Stripe Promotion Codes API.

FAQ

What's the difference between Stripe Coupons and Promotion Codes?

Coupons define the discount (e.g., 15% off). Promotion Codes are customer-facing codes linked to a coupon that users enter at checkout. You create one base coupon, then generate many unique promotion codes from it β€” one per referrer.

Can I limit each promo code to one use per customer?

Yes. Set max_redemptions: 1 when creating the promotion code. You can also set restrictions.first_time_order: true to ensure it's only used by new customers, preventing existing customers from using referral codes.

How do I handle promo codes for a free trial extension instead of a discount?

Instead of a percentage or amount coupon, create a coupon with duration: 'once' and apply it alongside a trial period extension. Alternatively, use GrowSurf's webhook to call stripe.subscriptions.update() with an extended trial_end timestamp.

Set up your refer a friend program with customer referral and affiliate program software that lowers your acquisition costs, increases customer loyalty, and saves you gobs of time.

Trusted by marketing and product teams at fast-growing B2C, fintech, and SaaS companies