Actions

Extend Trial - Action

Extends a subscription trial period for a specific duration.

Required for Trial Offer to work.

To implement the Extend Trial action, you need to implement an endpoint and define features

Prerequisites

Subscriptions - Controller

You must implement a Subscriptions controller first.

Required

Cancel - Action

Trial extension is a part of the cancel flow. You must implement the Cancel action first.

Required

SDK

If you are using the SDK, you can implement the Extend Trial action by following the code example below. You don't need to get into the details of the API endpoints, the SDK will take care of that for you.

import { Integrator } from '@churnkey/sdk'
import { Subscriptions } from '../controllers/Subscriptions'

export const ExtendTrial = Integrator.ExtendTrial.config({
    Subscriptions: Subscriptions,
    features: {
        enabled: true,
        multiple: true,
        durations: {
            period: true,
            date: true
        }
    },
    async handle(ctx, options) {
        const subscription = await this.subscriptions.retrieve({
            customerId: options.customerId,
            id: options.subscriptionId
        })

        await ctx.db.extendSubscriptionTrial(subscription, {
            duration: options.duration
        })
    }
})

Endpoints

Handle Required

POST /churnkey/actions/subscription/extend-trial

This endpoints handles the subscription trial extension. You should find the subscription by customerId and subscriptionId and extend it's trial.

Options for trial extension, provided in the request body.

Features required

Features define which behavior is supported for the Extend Trial action. Depending on the features you enabled, requests body will have different options.

For example, if you enable only period duration type, the request.body.duration will be always of period type. If you enable both type, request.body.duration can be either of type period or date.