# Stripe

The ReferralHero Stripe is a powerful integration that enables a seamless connection between your ReferralHero account and your Stripe payment gateway. This support document provides a comprehensive overview of the integration's key features, outlining how you can make the most of this powerful tool for your referral marketing campaigns.

Here is what can be done with the ReferralHero Stripe integration:

* Import Stripe customers into ReferralHero
* Create customers in ReferralHero when starting an onboarding flow or completing a Stripe payment page/checkout
* Track Stripe trialing, active, and other subscription events in ReferralHero
* Track Stripe transactions
* Sync Stripe customer's conversion value and total spend to RerferralHero&#x20;
* Apply Stripe coupons to customers when a ReferralHero reward is unlocked
* Apply Stripe credit to customers when a ReferralHero reward is unlocked

## Connect Stripe Account to ReferralHero

Follow these steps to securely link your Stripe account to ReferralHero for a reliable integration.

1. In the Stripe Dashboard, navigate to Developers > API Keys section, ensure you grant the necessary permissions in your Stripe account for event tracking with RH

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FkushZoQk117O8YUN2ReN%2Fimage.png?alt=media&#x26;token=fc77eabc-4b2c-4c0e-b78d-6a1e99f4fbb9" alt=""><figcaption></figcaption></figure>

2. Go to Stripe Dashboard > Developers > API Keys and copy the Secret Key

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FSUVBAFy9UCfpDrRcKTFd%2Fimage.png?alt=media&#x26;token=dbb6fa0e-9636-4c84-9698-e6867fef673a" alt=""><figcaption></figcaption></figure>

3. If you would like to enable Test mode in the integration, turn on “Test mode” in your Stripe Dashboard and copy the Test Secret Key

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FtkiiF9gsFGirPrlrDKcc%2Fimage.png?alt=media&#x26;token=22afec1c-44ed-4320-8552-082ce69dcf47" alt=""><figcaption></figcaption></figure>

4. In ReferralHero, go to Edit Campaign > Integrations > Stripe, and click the button "Connect your Stripe account"

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FeEpF9H7ADkRlATm9xQeS%2Fimage.png?alt=media&#x26;token=efbe97c2-f3c0-4d70-8227-83148d9064b9" alt=""><figcaption></figcaption></figure>

5. Enter the Stripe Secret Key in the API KEY text box
6. Click "Connect"

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2Fj07sFnbLwC7LFtAocgNV%2Fimage.png?alt=media&#x26;token=123743fc-b840-4829-894a-0d8ec38a3ac9" alt="" width="375"><figcaption></figcaption></figure>

8. The "Transaction Tracking" event is automatically generated upon connecting your Stripe account
9. Your Stripe account is now successfully connected

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FFrJGvRPOaUrI92jTSlLY%2Fimage.png?alt=media&#x26;token=83549938-4052-4aa3-a51c-0802ced42b40" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
**NOTE:** The "Transaction Tracking" event automatically includes Stripe transactions in the "Transactions" tab under the "Reward Logs".
{% endhint %}

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2F9XrmiMsRUnbtYPzTrGZn%2Fimage.png?alt=media&#x26;token=29151c55-aebc-4040-8b18-010ac0e30c34" alt=""><figcaption></figcaption></figure>

## Test the Integration with Stripe "Test Mode"

Test mode is a testing environment that simulates creating real events without the risk of affecting live transactions or moving actual money. It allows you to verify that the integration between ReferralHero and Stripe is functioning as expected.

To enable test mode, enter your Stripe test API key in the ReferralHero integration settings. This ensures you can safely test the integration, verify referral tracking, and validate workflows without impacting live data or customer activity.

Using test mode is essential for confirming the setup of your referral program before launching it to your audience.

## Import Stripe Customers into ReferralHero

1. In your ReferralHero campaign dashboard, go to Add Subscribers > Import via Integration > Import from Stripe
2. Click "Import"

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FAq1Ubpad07w6Ffmhs70g%2Fimage.png?alt=media&#x26;token=522104bd-d1dd-4b94-abd4-3a2fb173c155" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
**NOTE:**&#x20;

1. If your "Welcome Email" automation is active, your imported list will receive this email
2. Import may take 1 to 2 hours to complete, depending on the number of customers in your Stripe account
   {% endhint %}

## Automatic Creation of Customers in ReferralHero

You can create customers in ReferralHero when they are added to Stripe using the following methods:

#### **Custom Form**

Use the ReferralHero JavaScript [RH\_MFxxxxxxxxxx.form.submit()](https://support.referralhero.com/integrate/javascript-web-api/adding-a-subscriber-manually) or [RH.pendingreferral()](https://support.referralhero.com/integrate/javascript-web-api/track-custom-referral-events#add-a-pending-referral) when implementing a custom form/checkout on your website to capture signup or customer information. Data will be automatically synced with ReferralHero when they are created in Stripe.

#### **Stripe Payment Link**

You need to create a custom Stripe thank you page on your website to use this feature.&#x20;

Follow the steps below to generate unique payment links with Stripe and add customers automatically when payment is completed.

1. Go to your website and add the following ReferralHero script to your Stripe thank you page:

<pre data-line-numbers><code>&#x3C;script>
window.RH_MFxxxxxxxxxx_Config = {
callbacks: {
ready: function() {
let checkout_id = new URLSearchParams(document.location.search).get('session_id');
if(RH_MFxxxxxxxxxx){
console.log("present");
<strong>RH_MFxxxxxxxxxx.stripe_checkout(checkout_id)
</strong>}else{
console.log("absent");
}
}
}
}
&#x3C;/script>
</code></pre>

{% hint style="success" %}
**NOTE:**&#x20;

The `RH_MFxxxxxxxxxx.stripe_checkout()` function works like  [`RH_MFxxxxxxxxxx.organicTrackReferral()`](https://support.referralhero.com/integrate/javascript-web-api/track-custom-referral-events#track-referral-conversion-or-add-subscriber). On the conversion page, it records referrals as:&#x20;

* **Confirmed** if your campaign has one conversion event
* **Unconfirmed** if your campaign has two or three conversion events
  {% endhint %}

2. Go to your Stripe dashboard > Payments > Payment Links and click "+ New"

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FBEdCjjbpLDEHxKnpk4Fl%2Fimage.png?alt=media&#x26;token=2e1327af-fce4-4548-86e5-8592cbccfae2" alt=""><figcaption></figcaption></figure>

3. Choose a product on the "Payment Page" tab

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FfQj8De1gs1f7IN6tbx02%2Fimage.png?alt=media&#x26;token=7886303a-1a60-4c31-8ddd-2f025636717c" alt=""><figcaption></figcaption></figure>

4. Go to the "After Payment" tab, check the option "Don't show confirmation page" to redirect customers to the custom thank you page on your website
5. Enter your custom thank you page URL by attaching an additional parameter session\_id as shown below to the URL text box: \
   [https://mywebsite/Stripethankyoupag&#x65;***`?session_id={CHECKOUT_SESSION_ID}`***](https://mywebsite/Stripethankyoupage?session_id={CHECKOUT_SESSION_ID})
6. Click "Create link"

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FrJEYujj2XmDTXWsy2lyf%2Fimage.png?alt=media&#x26;token=16cc3fe3-f1f1-4038-a213-365b272998cb" alt=""><figcaption></figcaption></figure>

7. Copy the payment link created and send it to your customer

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FdF49emRt3gumYcRvz1CY%2Fimage.png?alt=media&#x26;token=6dcaa549-7769-4312-be0d-9856451a1ca4" alt=""><figcaption></figcaption></figure>

8. The customer will be created in ReferralHero when they complete the payment

{% hint style="success" %}
**NOTE:**

* **Organic Subscriber Creation**: The RH\_MFxxxxxxxxxx.stripe\_checkout() creates an organic subscriber by default when triggered.
* **Pending Referral Confirmation**: If the subscriber already exists as a pending referral, the referral is confirmed automatically.
* **Referred Visitor Conversion**: If a referral cookie exists, the referred visitor is converted into an unconfirmed/confirmed referral.
  {% endhint %}

## Definitions to Track Referral Events

There are three types of Stripe events that can be tracked in the integration based on specific Stripe activities:

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FBgsbYYj5Csw48HUhy8pZ%2Fimage.png?alt=media&#x26;token=31216ce0-eef7-44b2-9f3d-cb65546cb3ed" alt="" width="375"><figcaption></figcaption></figure>

1. Stripe Status Change: Monitor changes in customer statuses (such as trialing or active) to trigger referral actions in ReferralHero
2. Payment Succeeds in Stripe: Record referral events when specific payment transactions occur in Stripe
3. Customer Created: Add new Stripe customers automatically to ReferralHero

{% hint style="success" %}
**NOTE:** The **Transaction Occurs** event is automatically created when the Stripe account is connected. It logs the transaction data in the “Transactions” tab, sets the Conversion Value and updates the Lifetime Spend with the Stripe Total\_Spend in the subscriber profile. You must track this event if you plan to use affiliate reward structures.
{% endhint %}

**Example 'Stripe Status Change' event**

This example illustrates an event that sets the referral status from 'pending' to 'unconfirmed' when a Stripe subscription state moves into trialing.

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FhdMzMtvX90jPkkS2oieQ%2Fimage.png?alt=media&#x26;token=3e5ccb75-118e-435b-9fd6-e22e49c46563" alt="" width="375"><figcaption></figcaption></figure>

**Example 'Payment Succeeds' event**

This example illustrates an event that sets the referral status from 'unconfirmed' to 'confirmed' when a customer's Stripe payment amount is greater than $50.

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FhtBKgHiiaa16EnL4ZlOq%2Fimage.png?alt=media&#x26;token=2fb03c78-9df3-4a3f-91d4-8f94c395e69c" alt="" width="375"><figcaption></figcaption></figure>

**Example 'Transaction Tracking' event**

This example illustrates the event that sends the Stripe transaction data, which is logged in the “Transactions” tab. It also sets the Conversion Value and updates the Lifetime Spend with the Stripe Total\_Spend in the subscriber profile.

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FN2qE73J8TmnL42GrbqSk%2Fimage.png?alt=media&#x26;token=16307b8f-eb85-461d-b10b-391eb36328e9" alt="" width="375"><figcaption></figcaption></figure>

## Apply Stripe Coupons

Enhance your referral campaigns by offering discounts through Stripe coupons, seamlessly integrated with ReferralHero. Stripe customers' accounts will automatically apply a discount code when they unlock a reward in ReferralHero.

1. Set up a reward in your ReferralHero campaign
2. Go to your Stripe integration in ReferralHero and click the button "Add reward coupon"

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FgIuWX2FPSpc9UVqFq9G2%2Fimage.png?alt=media&#x26;token=ad7a5ef2-252e-4f7e-abec-180ca6a8c558" alt=""><figcaption></figcaption></figure>

3. Select the coupon you would like to apply to the Stripe customer from the dropdown
4. Select the reward that the customer needs to unlock to earn the discount

**Example ‘Reward Coupon’ event**

This example illustrates that when the Stripe customer successfully refers one referral and unlocks the reward "Reward for Advocate",

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FBHT2hQvbTRCcrnzvVmee%2Fimage.png?alt=media&#x26;token=79a15213-3115-41ff-a252-89afd160b209" alt=""><figcaption></figcaption></figure>

the 'Reward Coupon' event set up for the reward will automatically apply the discount code "50OFFOneTime" to the customer's account in Stripe.

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2F5iFyHozfZP4TO2Shctyr%2Fimage.png?alt=media&#x26;token=9618dbfa-127f-47d4-91f7-9b31e8a9f3a4" alt="" width="375"><figcaption></figcaption></figure>

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FceRcMlH8VHHiYsV7DwbC%2Fimage.png?alt=media&#x26;token=cbab0aea-cac9-4f39-8d44-ca21c5d77a7c" alt=""><figcaption></figcaption></figure>

## Apply Stripe Credit

Enhance your referral program by applying Stripe credit directly to customers' accounts when they unlock a reward in ReferralHero. This feature allows you to offer incentives without requiring a separate discount code or manual intervention.

1. Navigate to the Reward Overview section and enable the "Apply Stripe credit" option

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2Fl5knOX29jgiF4XBBz08q%2Fimage.png?alt=media&#x26;token=c6c61515-7806-4eac-a28b-37c7ef023226" alt=""><figcaption></figcaption></figure>

2. Set the reward value in the Reward Value section

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FBb3H1mr0LRHpwzXL8cla%2Fimage.png?alt=media&#x26;token=2a519e7e-d030-4f23-9d05-6897ad926a6a" alt=""><figcaption></figcaption></figure>

3. Once a subscriber unlocks the reward, the corresponding credit amount will be automatically applied to their Stripe account

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FwTWJ7Muox0oxSBtfm6nM%2Fimage.png?alt=media&#x26;token=66c23b03-8f5a-4857-9056-18b68ad0e58e" alt=""><figcaption></figcaption></figure>

## Track Stripe Transactions

ReferralHero supports ongoing transaction tracking, empowering you to reward affiliates for transactions that occur over time. This feature allows you to provide commissions beyond the initial transaction.&#x20;

{% hint style="success" %}
**NOTE:** For existing Stripe customers, the first-ever payment amount becomes the Conversion Value, and the Stripe Total\_Spend is reflected as the Lifetime Spend in the ReferralHero subscriber profile.
{% endhint %}

**Scenario Overview**

Stripe integration events:

1. “Transaction Tracking”
2. "Stripe Status Change" event triggered when a subscriber moves into "Active", setting the referral to confirmed.

Reward settings:

1. Reward the advocate for each transaction completed by a “Confirmed” referral
2. Reward the advocate 10% of each transaction by the “Confirmed” referral
3. Reward should recur for 10 transactions

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FNrbmzcloOcfg87w0gEDA%2Fimage.png?alt=media&#x26;token=d5808460-8135-4747-97e3-228474fba2e6" alt=""><figcaption></figcaption></figure>

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FuQpJ9SJubASgss5LdK9D%2Fimage.png?alt=media&#x26;token=72da2e27-89fe-44b9-a4ed-7cd03b8e62a0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://363135598-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LsuqexOLPOWiUrWg_Ko%2Fuploads%2FMsT5vn9Out9WQMuP2Nwl%2Fimage.png?alt=media&#x26;token=a3809a77-88c0-4369-a945-e22eeb654d6c" alt=""><figcaption></figcaption></figure>

**Expected Behavior of Events:**

1. A Pending referral is simultaneously created in ReferralHero when a Trialing customer is created in Stripe
2. The Trialing customer purchases a $200 plan and transitions into Active status in Stripe
3. "Stripe Status Change" event triggers, changing the referral status from Pending to Confirmed
4. "Transaction Tracking" event is triggered, logging data in the Transactions tab, and updating the subscriber profile
5. A reward of $20 is unlocked by the advocate&#x20;
6. The referral makes another payment in Stripe
7. “Transaction Tracking” event is triggered again, logging data in the Transactions tab, and updating the subscriber profile
8. Rewards are unlocked by advocate for 10 transactions
