# Chargebee

{% hint style="info" %}
**Note:** The Chargebee integration is only available to users on the LoyaltySurf Business plan or higher.
{% endhint %}

Even if the Chargebee customer's email address changes, LoyaltySurf will track those changes to ultimately ensure the Chargebee coupon, credit, or trial extension gets applied to the right Chargebee customer.

### How to Set Up

{% hint style="info" %}
You must first select a default currency for your LoyaltySurf campaign in order to use Chargebee.\
\
Your default currency determines whether Chargebee coupons, credits, or trial extensions can be applied to your Chargebee subscriptions. For example, if your default currency is USD, then the coupon, credit, or trial extension you set up can only be redeemed for Chargebee subscriptions using USD.
{% endhint %}

**Step 1**: In *Campaign Editor > 4. Options > Integrations*, open the Chargebee integration card and enter your [Chargebee site](https://www.chargebee.com/docs/1.0/sites-intro.html), [Chargebee API key](https://www.chargebee.com/docs/2.0/api_keys.html), and [Chargebee product catalog version](https://www.chargebee.com/docs/2.0/product-catalog.html) for both live and test mode.

<figure><img src="https://3285719719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTwFF4MDnpq2eL5eyOdtK%2Fuploads%2FevOgXgI0BhFDyZN8PUls%2FCampaign%20Editor%20-%20Options%20(Campaign%20oiz246)%20-%20Google%20Chrome%202023-02-28%20at%202.35.40%20PM.png?alt=media&#x26;token=070a5048-2e24-4c97-ae7d-643de9776493" alt=""><figcaption></figcaption></figure>

**Step 2:** Once connected, press the 'Connect A Reward' button and select your reward.

<figure><img src="https://3285719719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTwFF4MDnpq2eL5eyOdtK%2Fuploads%2FZL6CvgXR4R2SyFeJ8rgc%2FLoyaltySurf-%20Dashboard%20-%20Google%20Chrome%202023-03-06%20at%207.09.57%20PM.png?alt=media&#x26;token=70b63aa5-8d7b-43aa-97fe-477ee0143707" alt=""><figcaption></figcaption></figure>

**Step 3:** Click on either coupon, credit, or trial extensio&#x6E;*.* If 'Coupon' is selected, enter the details of the coupon, including the name, type, and discount. You can also click *Show advanced coupon* settings to view more customization settings.

{% hint style="info" %}
**Advanced feature tip: Issue different reward amounts by using dynamic rewards**

Dynamic rewards let you offer different reward values based on specific attributes of the referred friend (such as the pricing plan they signed up for) or referrer (such as their partner status).

For example, you can award $50 in credits to winners when their referral signs up for your base plan or $100 in credits when they sign up for a higher-costing plan.

[Learn more →](https://support.loyaltysurf.io/article/437-how-to-set-up-dynamic-rewards)
{% endhint %}

<figure><img src="https://3285719719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTwFF4MDnpq2eL5eyOdtK%2Fuploads%2FklPBV0vz9QV2ohXMprCI%2FLoyaltySurf-%20Dashboard%20-%20Google%20Chrome%202023-03-06%20at%207.28.47%20PM.png?alt=media&#x26;token=d3ed2dd9-f3d6-4b4b-a042-9e7b549f111c" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Note:** By default, coupons are recommended. However, if you want rewards to be stackable (e.g., $10 off for every loyalty action), you will want to use credits.
{% endhint %}

If 'Credit' is selected, enter the credit description and amount to apply to the Chargebee customer's account every time this reward is unlocked.

<figure><img src="https://3285719719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTwFF4MDnpq2eL5eyOdtK%2Fuploads%2FICPdptDGhn2yEVzaAZaY%2FCampaign%20Editor%20-%20Options%20(Campaign%20oiz246)%20-%20Google%20Chrome%202023-02-28%20at%204.32.32%20PM.png?alt=media&#x26;token=b105db1a-b4ac-4e40-80c2-a0fe70a37c08" alt=""><figcaption></figcaption></figure>

To extend the trial period, select 'Trial Extension', and specify the number of days.

{% hint style="info" %}
Chargebee trial extensions only work for subscriptions labeled <mark style="color:red;">`IN TRIAL`</mark>`.`
{% endhint %}

<figure><img src="https://3285719719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTwFF4MDnpq2eL5eyOdtK%2Fuploads%2FyK2MKUZPg0162ZEeHEu2%2FCampaign%20Editor%20-%20Options%20(Campaign%20oiz246)%20-%20Google%20Chrome%202023-03-01%20at%207.28.52%20PM.png?alt=media&#x26;token=05493525-fddd-473d-8d01-0d4eb909c551" alt=""><figcaption></figcaption></figure>

**Step 4:** When you're done, click the Save button.<br>

**Step 5 (optional):** To ensure the legitimacy of your campaign and prevent any fraudulent activities, it is advisable to establish Chargebee webhooks. By setting up webhooks, LoyaltySurf can monitor any modifications customers make to their email addresses on Chargebee using the customer's unique Chargebee ID.

<figure><img src="https://3285719719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTwFF4MDnpq2eL5eyOdtK%2Fuploads%2FIPyDzeJfmkvZyJDdrw73%2FLoyaltySurf-%20Dashboard%20-%20Google%20Chrome%202023-03-06%20at%207.56.12%20PM.png?alt=media&#x26;token=6dac8a68-868e-459b-bce0-003898d8b132" alt=""><figcaption></figcaption></figure>

**Step 6:** Once you have enabled webhooks, create a new Chargebee webhook and return to the LoyaltySurf Chargebee integration and input the username and password for your Chargebee webhook. For guidance on setting up your webhook, click on this [link](https://www.chargebee.com/docs/2.0/webhook_settings.html).

<figure><img src="https://3285719719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTwFF4MDnpq2eL5eyOdtK%2Fuploads%2FfSe9EEtKplqu5yMUjnML%2FLoyaltySurf-%20Dashboard%20-%20Google%20Chrome%202023-03-08%20at%202.21.46%20PM.png?alt=media&#x26;token=200bff2e-d5d9-420e-870b-aa5d55c4a0b7" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
**Important Note:** Only the following event should be selected for your Chargebee webhook:

* Customer Changed

Remember to toggle on "Exclude card information from webhook call".
{% endhint %}

<figure><img src="https://3285719719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTwFF4MDnpq2eL5eyOdtK%2Fuploads%2FJ19lV9fX4THylhbw6U4s%2FScreen%20Shot%202023-03-08%20at%203.39.00%20PM.png?alt=media&#x26;token=dbf73fab-78d4-456d-b599-5981800e1930" alt=""><figcaption></figcaption></figure>

### Test Mode

Our Chargebee integration comes with a test mode that allows you to test coupons, credits, and trial extensions. When you toggle *Test Mode* on, LoyaltySurf will only apply coupons, credits, or trial extensions to Chargebee subscriptions that exist within your Chargebee account when test mode is toggled on.&#x20;

To enable test mode, toggle the *Test Mode* switch at the bottom-right, then connect a reward(s).

<figure><img src="https://3285719719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTwFF4MDnpq2eL5eyOdtK%2Fuploads%2FZNa1Hxy3it4hGTnecUzE%2FLoyaltySurf-%20Dashboard%20-%20Google%20Chrome%202023-03-06%20at%208.17.40%20PM.png?alt=media&#x26;token=538807bd-582c-446c-960f-2425cb4c2e75" alt=""><figcaption></figcaption></figure>

Please note that the rewards you connect to while *Test Mode* is enabled are completely separate from those you connect to in live mode.

<figure><img src="https://3285719719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTwFF4MDnpq2eL5eyOdtK%2Fuploads%2FOrQwkWByEgZEeOUrMNUC%2FLoyaltySurf-%20Dashboard%20-%20Google%20Chrome%202023-03-06%20at%208.20.15%20PM.png?alt=media&#x26;token=3730d2ac-b773-4e81-9d3e-d38ff55d7980" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
**Important note:** When you go live with your campaign, please make sure to switch back to live mode. Otherwise, rewards will not be issued in live mode while test mode is enabled.
{% endhint %}

### Troubleshooting Tips

If there is an issue with applying Chargebee coupons, credits, or trial extensions, LoyaltySurf will send out a notification email to the campaign owner. The issue will also be stated in the participant's detail page when you view their reward or when you view the participant's activity logs.

Here are some common reasons why there may be failures:

* The customer with the associated LoyaltySurf participant email address does not exist in Chargebee (please make sure to check live or test mode depending on if you have toggled on Test Mode in the LoyaltySurf Chargebee integration)
* If dynamic reward rules are enabled for the Chargebee reward, there may have been no matching rule found.
* If you were expecting a reward to be applied in live mode, double-check that you do not have test mode enabled.
* If your Chargebee customer changes their email address right before the Chargebee reward gets applied, they may not receive it. This is because LoyaltySurf relies on Chargebee sending out a webhook event which notifies LoyaltySurf of the Chargebee customer's new email address, but if there is not at least a few minutes before the reward event, LoyaltySurf will not know about the Chargebee customer's email change.

If there was a failure, you will need to manually issue the Chargebee reward from your [Chargebee dashboard](https://app.chargebee.com/).

#### Other notes:

* If you have manual reward approval enabled for your campaign: Chargebee coupons, credits, and trial extensions will only be issued to the winner(s) after you approve the reward.
* If the loyalty action was triggered recently (or if the reward was approved recently), please allow for a few minutes of server processing before viewing the participant's reward from your LoyaltySurf admin dashboard. During this time, the data displayed for the participant's reward may not be accurate.
