Built for startups,
scaled for unicorns
Successfully submitted!
Error! Please try again

Chargebee manages your subscription billing β and subscription credits are one of the most natural referral rewards for SaaS businesses. When a referrer's friend becomes a paying subscriber, automatically crediting the referrer's Chargebee account creates a seamless experience: the credit appears on their next invoice, reducing their bill without any manual intervention.
This guide covers connecting GrowSurf referral conversions to Chargebee's promotional credits system. You'll learn how to apply credits to subscriber accounts, handle credit stacking, configure credit expiration, and track credit usage for financial reporting.
Configure Chargebee API credentials for your webhook handler.
https://{site}.chargebee.com)Plan how referral credits will work within your Chargebee billing setup.
Create a webhook handler that receives GrowSurf reward events and applies credits in Chargebee.
PARTICIPANT_REACHED_REWARD or CAMPAIGN_REFERRAL_CONVERTEDUse Chargebee's Promotional Credits API to add referral credits to subscriber accounts.
POST /api/v2/promotional_credits/add to add creditsImplement business rules for managing multiple referral credits on a single account.
Monitor credit issuance and usage for financial reporting.
// Apply referral credits to Chargebee subscriptions
const chargebee = require('chargebee');
chargebee.configure({
site: process.env.CHARGEBEE_SITE,
api_key: process.env.CHARGEBEE_API_KEY
});
async function applyReferralCredit(referrerEmail, creditAmount, referralId) {
// Find the customer in Chargebee
const result = await chargebee.customer.list({
'email[is]': referrerEmail,
limit: 1
}).request();
if (result.list.length === 0) {
throw new Error(`Customer not found: ${referrerEmail}`);
}
const customer = result.list[0].customer;
// Check existing credits (optional: enforce cap)
const existingCredits = await chargebee.promotional_credit.list({
'customer_id[is]': customer.id
}).request();
const totalCredits = existingCredits.list.reduce(
(sum, pc) => sum + pc.promotional_credit.amount, 0
);
const MAX_CREDIT = 10000; // $100 cap in cents
if (totalCredits + creditAmount > MAX_CREDIT) {
creditAmount = MAX_CREDIT - totalCredits;
if (creditAmount <= 0) {
console.log(`Credit cap reached for ${referrerEmail}`);
return null;
}
}
// Add promotional credit
const credit = await chargebee.promotional_credit.add({
customer_id: customer.id,
amount: creditAmount,
description: `Referral reward (ID: ${referralId})`,
credit_type: 'general'
}).request();
return credit.promotional_credit;
}
app.post('/webhooks/growsurf/chargebee-credit', async (req, res) => {
const { event, participant, referrer } = req.body;
if (event !== 'CAMPAIGN_REFERRAL_CONVERTED' || !referrer) {
return res.json({ skipped: true });
}
try {
const credit = await applyReferralCredit(
referrer.email,
1000, // $10.00 in cents
participant.id
);
if (credit) {
console.log(`Applied $${credit.amount / 100} credit to ${referrer.email}`);
}
res.json({ success: true });
} catch (error) {
console.error('Chargebee credit error:', error);
res.status(500).json({ error: error.message });
}
});If you want credits to apply to the current billing period (not just the next invoice), use Chargebee's Credit Notes API instead of Promotional Credits. Credit notes adjust the current or outstanding invoice immediately, while promotional credits apply to future invoices.
Chargebee promotional credits don't expire automatically. If your program requires credit expiration, create a scheduled job that checks for credits older than your expiration period and removes them using the promotional_credit.deduct API. Notify customers before expiring their credits.
Keep GrowSurf participant metadata updated with their current Chargebee credit balance. This lets you display credit information in GrowSurf's referral widget and emails, giving participants real-time visibility into their earned rewards.
Yes. Once added, Chargebee promotional credits are automatically applied to the customer's next invoice, reducing the amount charged. If the credit exceeds the invoice amount, the remaining balance carries forward to subsequent invoices. No additional code is needed for credit application.
Yes. In your webhook handler, apply a credit to the referrer's account (reward for referring) and also apply a credit to the referred subscriber's account (welcome discount). Use GrowSurf's conversion event to trigger credits for both parties simultaneously.
Promotional credits remain on the Chargebee customer account even after cancellation. If they re-subscribe, the credits will apply to their new subscription. You can choose to deduct unused credits upon cancellation by calling the promotional_credit.deduct API in response to Chargebee's subscription_cancelled webhook.
Trusted by marketing and product teams at fast-growing B2C, fintech, and SaaS companies
