# Setup Stripe Payment Button

The Buy Button, powered by Stripe Payment Links, lets you accept payments or sell subscriptions directly from your website without building a separate store. Create a button by selecting or creating a Payment Link, customising the products, and designing the checkout experience. The button supports over 20 payment methods, including cards, Apple Pay, and Google Pay, and adapts to your customer’s preferred language. Once configured, generate the embed code and paste it into your website to start accepting payments seamlessly.

{% embed url="https://drive.google.com/file/d/1nEmt_DI_MGB3HHZKJWfDjM6OOaWNgzOU/view?usp=sharing" %}



In this guide, you will learn how to set up your buy button to track referrals. Once a successful payment is made through a referral link, Referral Rocket will track the referral.

#### Step 1: Add the Referral Rocket Global Script to Your Website

To track referrals, add the ReferralRocket global script to your website. This script will automatically capture any referral links on your site.

**Here’s how to add it:**

1. You can find the global script under "Installation" on the Campaign Detail page in your Referral Rocket account.
   1. This includes your unique Referral Rocket campaign ID

```
// Some code
    <script
        type="text/javascript"
        campaign-id="your-campaign-Id"
        defer
        src="https://app.referralrocket.io/widget/widgetIndex.js">
    </script>
```



Copy the script and paste it into the landing page or the custom code section of your website, inside the \<head> or \<body> tags.

**How to Add Custom Code with Popular Website Builders**

* [Webflow](https://university.webflow.com/lesson/custom-code-in-the-head-and-body-tags?topics=site-settings#custom-code-in-site-settings): Go to Project Settings > Custom Code > Paste the script.
* [Framer](https://www.framer.com/academy/lessons/custom-code): Open the project settings > Code tab > Paste the script.
* [WordPress](https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/): Use the header/footer plugin or paste it directly in the theme’s header file.

#### Step 2: Update Your buy button Page

After adding the global script, the next step is to configure your buy button page. This script will track referral data and associate it with your Stripe payment information, allowing Stripe to properly track referral details.

**Add this script to your payment page:**

```
<script>
        const updateStripeBtns = () => {
            const referralCode = window.Rocket.getCampaign().getReferralCode();
            if (referralCode && referralCode.trim() !== '') {
                const buyButtons = document.querySelectorAll("stripe-buy-button");
                if (buyButtons.length > 0) {
                    buyButtons.forEach(BuyBtn => {
                        BuyBtn.setAttribute("client-reference-id", referralCode);
                    });
                }
            }
        };


        setTimeout(updateStripeBtns, 1000);
        setTimeout(updateStripeBtns, 2000);
    </script>

```



This script ensures that the referral code is included when the customer clicks the buy button, allowing Stripe to track the referral.

#### Step 3: Test the Integration

After adding the necessary scripts, you can test to ensure everything is working correctly with your Stripe integration. Follow these steps to perform a test:

1. Create a Test Affiliate Participant:
   1. Go to the Referral Rocket hosted campaign widget, or embed it on your site.
   2. You can use any email address to sign up as a participant.
2. Get the Referral Link:
   1. After submitting, Referral Rocket will generate a unique affiliate link for the participant.
   2. Open this link in a new tab. It will land you on your landing page.
3. Test the buy button:
   1. Click the buy button to proceed to the Stripe Checkout page.
   2. Use Stripe's Test Mode to avoid any charges while testing.
4. Complete the Payment:
   1. Complete the test payment to verify that the referral information is being tracked correctly.
   2. Head over to Referral Rocket and ensure that the referred participant is properly recorded in the system.
   3. You can also check the reward section to confirm that rewards are being tracked and assigned.
