# Stripe

## How to connect Stripe 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 Stripe card. The card will then transform into a form with fields for you to enter your Live mode and Test mode Secret/Restricted keys.

<figure><img src="https://2477763041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fny2KheLD0svN4wwa3pPL%2Fuploads%2F8tMYQVL27LU2Ijv5BA5j%2Fimage.png?alt=media&#x26;token=ec2a079d-d4dc-4aa0-87a8-ca201705567a" 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](#api-key-permissions). Once that check is complete, your data will begin to be imported into Upzelo.

## How is Stripe used with Upzelo?

### 1. Audience Segmentation

Upzelo imports data from your Stripe 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 Stripe.
{% endhint %}

**Segmentation Attributes**:

* Subscription Age
* Plan
* Billing Interval
* Subscription Metadata
* Subscription Status
* Customer Location
* Active Coupon

### 2.  Creating Discounts

The Actions section of Upzelo will create coupons inside of your Stripe 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

Upzelo automatically creates webhooks so that it is always up to date with your customer's subscriptions.

## How Upzelo works with Stripe

### 1. Subscription Pausing

Upzelo uses Stripe's built-in pause feature. How this works, is we update the subscriptions `pause_collection[behavior]` and set it to `mark_uncollectible`. We also set `pause_collection[resumes_at]` 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 [Stripe documentation](https://stripe.com/docs/billing/subscriptions/pause)
{% 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. Changing Plans

When a customer accepts an Action that is for changing Plans, we follow the best practices as set out in the Stripe documentation. Switching subscription plans is configurable in that you can choose if there should be prorations for the time used on their original plan.

### 4. Cancelling Subscriptions

Upzelo handles cancelling subscriptions for you. The behaviour 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.

### 5. Extending Trials

Upzelo can also extend trials for you, this is achieved by updating the `trial_end` parameter on the subscription.

## API Key Permissions

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

| Scope                         | Permission |
| ----------------------------- | ---------- |
| Core -> Charges               | Read       |
| Core -> Customers             | Write      |
| Core -> Events                | Read       |
| Core -> Products              | Read       |
| All Billing Resources         | Write      |
| Webhooks -> Webhook Endpoints | Write      |
