Connecting With Stripe
Connect your Stripe account with Churnkey to enable powerful off-boarding flows out of the box.

Linking Your Stripe Account

You can manage your Stripe connection under your account settings page found here: https://app.churnkey.co/settings/connect.
You will have the option to connect with your Stripe account in both live and test modes.

Test Mode

Churnkey offers the (optional) ability to test your integration with your Stripe test account. The Churnkey flow will look the same, but you will be using it with customers from your Stripe test account instead of the live account.
Once you have connected your Stripe testing account, you will be able to test the Churnkey flow with customers from your Stripe test account by passing a test customer id and setting the mode option to test. The rest of the implementation is identical to using Churnkey in live mode (see Installing Churnkey), including the HMAC signature and its keys.
1
// EXAMPLE TEST INTEGRATION
2
window.churnkey.init('show', {
3
customerId: 'TEST_CUSTOMER_ID', // DIFFERENT
4
authHash: 'HMAC_HASH',
5
appId: 'YOUR_APP_ID',
6
mode: 'test', // DIFFERENT
7
})
8
9
// EXAMPLE LIVE INTEGRATION
10
window.churnkey.init('show', {
11
customerId: 'LIVE_CUSTOMER_ID', // DIFFERENT
12
authHash: 'HMAC_HASH',
13
appId: 'YOUR_APP_ID',
14
mode: 'live', // DIFFERENT
15
})
Copied!

Accepting offers in test mode

When you go through the Churnkey flow in test mode, you will be able to verify that the customer accounts in Stripe are updated when selecting to pause or cancel the subscription. Importantly, accepting a discount offer will not work in test mode. This is because Churnkey applies discounts based on the coupons you select in the offer builder (see Configuring Your Offboarding Flow). Since those coupons (and the exact couponId) only exists on your Stripe live account and not the test account, it cannot be applied to test customers. Rest assured, if test cancelations are working fine, the Stripe integration is performing as it should be, and discounts will function as expected in live mode.

Stripe Actions

Churnkey is able to connect to your Stripe account and perform the following actions on your behalf
    1.
    Pause a subscription
    2.
    Apply a discount
    3.
    Cancel a subscription
We'll look at each one of these in a little bit more detail.

Pause Subscription

Churnkey uses Stripe's built-in pause feature which will update the subscription's pause_collection[behavior] to mark_uncollectible. The resumes_at field will automatically be set by ChurnKey depending on the length of the pause selected.
You can specify the maximum pause length allowed by customers while configuring your offboarding flow.
If you would like to implement a custom function for handling pause events, you can do so using the handlePause callback (see Custom Callbacks).

Apply a Discount

In the Churnkey offer builder (see Configuring Your Offboarding Flow), you can offer specific discounts to customers. These discounts are populated based on the coupons that you have created in your Stripe account.
When a customer accepts a discount, that coupon is applied directly to the Stripe customer account.
If you would like to implement a customer function for applying discounts, you can do so using the handleDiscount callback (see Custom Callbacks).

Cancel Subscription

Churnkey can handle canceling your customer's subscription for you. By default, a customer's subscription will be set to cancel at the end of the current period, but this behavior can be modified to cancel a user's subscription immediately.
Under the hood, Churnkey follows Stripe's best practices on canceling.
If you would like to implement a customer function for canceling subscriptions, you can do so using the handleCancel callback (see Custom Callbacks).
Last modified 2mo ago