# Chargebee

## How to connect Chargebee and Upzelo

Head over to the [Integrations](https://upzelo.com/app/integrations) page in the Setup menu on the bottom left of the dashboard, you will be presented with a list of Integrations that Upzelo offers.

<figure><img src="https://2477763041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fny2KheLD0svN4wwa3pPL%2Fuploads%2FaSRF5521GmR1r8HBig2u%2Fimage.png?alt=media&#x26;token=92028d23-f58a-42d7-9bae-d8487ecf555e" alt=""><figcaption></figcaption></figure>

Start by clicking the `Connect` button underneath the Chargebee card. The card will then transform into a form with fields for you to enter your Live mode and Test mode Site Names and API Keys.

<figure><img src="https://2477763041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fny2KheLD0svN4wwa3pPL%2Fuploads%2Fh0PaIZ6zRvK0bd7rDDLl%2Fimage.png?alt=media&#x26;token=7a2f708c-0491-4fcd-b0e0-d57ad1e4816c" alt=""><figcaption></figcaption></figure>

Follow the instructions on the form and confirm your keys work correctly by pressing `Check` before pressing `Save`.

After pressing `Save`, we will check that you have set up the key with the correct permissions. Once that check is complete, your data will begin to be imported into Upzelo.

## How is Chargebee used with Upzelo?

### 1. Audience Segmentation

Upzelo imports data from your Chargebee account so that it can be used to create audiences. This allows you to create Flows that can be tailored specifically to a segment of your customer base. This means that a new sign-up can receive a Flow different from a customer that you consider to be valued.

{% hint style="info" %}
Upzelo imports `Customers`, `Subscriptions`, `Coupons`, `Products` and `Prices` from Chargebee.
{% endhint %}

**Segmentation Attributes**:

* Subscription Age
* Plan
* Billing Interval
* Subscription Status

### 2.  Creating Discounts

The Actions section of Upzelo will create coupons inside of your Chargebee account which can then be used inside of Flows.

{% hint style="warning" %}
Actions created in test mode are only available for test mode flows.
{% endhint %}

### 3. Updating Customer Subscriptions

When a customer is presented with a Flow, Upzelo takes care of all of the billing updates for you. Some of the Actions that you create are billing related and we will go through those in a bit more detail below.

### 4. Creating Webhooks

Chargebee doesn't allow the automatic creation of webhooks, these need to be set up manually.

Your webhook URL can be found on the Developer dashboard on Upzelo.

Create a webhook on Chargebee using the URL provided, under Events to Send, select `All Events` and toggle `Exclude card information from webhook call`, we never require card information belonging to your customers.

## How Upzelo works with Chargebee

### 1. Subscription Pausing

Upzelo uses Chargebee's built-in pause feature. How this works, is we update the subscriptions `pauseOption` and set it to `immediately`. We also set `resumeDate` to now plus the time period specified in your Action (e.g. 2 months).

{% hint style="info" %}
We follow the best practices set out in the [Chargebee documentation](https://apidocs.chargebee.com/docs/api/subscriptions?prod_cat_ver=2#pause_a_subscription)
{% endhint %}

### 2. Applying Discounts

You can create different types of discounts in the Actions section. When a customer accepts a discount (money off, percentage, or even a "free period"), we will apply the coupon to the subscription ID that has been provided.

### 3. Cancelling Subscriptions

Upzelo handles canceling subscriptions for you. The behavior of this can be configured so that the subscription either ends immediately or at the end of the current period. This is configurable on each Flow that you offer.

## API Key Permissions

When creating an API key on Chargebee, certain permissions are required for Upzelo to function correctly.

The API key needs to be a `Full-Access Key` and be a `Write Key` for Upzelo to function correctly
