Adding Refindie to Your Website
Install tracking script and integrate with your payment system.Integration Steps
1. Add the tracking script
Copy and paste the script below in the<head> section of your website.
Script Parameters:
data-program-id- Your affiliate program ID (required)
2. Get referral data
The script sets a global object with referral information:refindie_metadata.program_id(string | number)refindie_metadata.ref_code(string)refindie_metadata.is_new_visit(boolean)
3. Send data during payment
Include referral data in your payment API calls to attribute commissions.Integration Options
Option 1: Stripe Connect (Recommended)
- Connect your Stripe account in Settings > Integration
- Send
window.refindie_metadatafrom your frontend to your server - Attach it as
metadataon the Stripe object that matches your payment flow (see the table below)
Supported Stripe payment flows
Affiliate promotion codes are detected automatically on Checkout Sessions and invoices, even without metadata.
Metadata format
Refindie reads two keys,program_id and ref_code:
window.refindie_metadata object as metadata works too. In the examples below, refindieMetadata is the value of window.refindie_metadata sent by your frontend.
- Checkout: one-time
- Checkout: subscription
- PaymentIntent
- Subscription API
- Invoice
- Professional payment processing
- Commission tracking via Stripe metadata
- Payment history and manual payout verification
Option 2: Referral API
Use the server-to-server endpoint when you use a custom payment provider or want to record a referral manually.- Endpoint:
POST /api/referral - Headers:
x-api-key: <YOUR_PROGRAM_API_KEY> - Body (JSON):
ref_code(string)program_id(string | number)spent_amount(number, in cents)currency(string, e.g. βUSDβ)transaction_id(string, unique)
Implementation Examples
React Component (Next.js)
API Route (app/api/checkout/route.ts)
AI Assistant Prompt
Copy this prompt into your AI assistant to implement this feature:Tips and Help
π‘ Important Tips
- Add the script to all your pages to never miss a referral
- Referral data is available as soon as the script is loaded
- Test the integration in development mode before production
- Subscriptions: The first payment is tracked via the metadata (checkout session or subscription). Renewal payments are tracked automatically using the subscription ID, no extra work needed
- Free trials: The commission is recorded on the first paid invoice, not when the trial starts
- One payment, one commission: Refindie deduplicates on the Stripe invoice ID (or PaymentIntent ID for one-time payments). Donβt also call the Referral API for a payment that already goes through Stripe Connect
β Verification
To verify that the integration works, open your browser console and typewindow.refindie_metadata. You should see the referral data.
After a test payment, open the object you created in your Stripe dashboard (Checkout Session, PaymentIntent, subscription or invoice) and check that its metadata contains program_id and ref_code.
π Troubleshooting
I see apayment_intent.succeeded event without Refindie metadata.
If you use Stripe Checkout, this is expected: Stripe does not copy the session metadata to the PaymentIntent. Check the checkout.session.completed event instead. If there is no checkout.session.completed event, you are using the PaymentIntents API directly: put the metadata on the PaymentIntent.
The commission is missing for a subscription with a free trial.
It is recorded when the first invoice is paid, at the end of the trial.
The commission is missing for a SEPA or bank transfer payment.
It is recorded once Stripe confirms the payment, which can take a few days.
Support
If you encounter any difficulties, contact us at contact@refindie.com or consult our documentation.- Email: contact@refindie.com
- Check our Program Creation guide