EMI plans setup for subscriptions

Overview

This guide explains how to offer EMI plans to subscribers and prevent mid-cycle cancellations. It also covers how to handle EMI plan changes (e.g., switching from a 3-month plan to a 6-month plan).

Note: This guide applies only if you are building your own custom customer portal. Refer to this link for the complete guide on building a customer portal.


Step 1: Store important details as subscription attributes

Create the following custom attributes on every subscription. These values allow you to control renewal logic, plan changes, and cancellation restrictions.

  1. _installmentsLeft: To determine number of orders left to be processed in the current cycle before next renewal.
  2. _autoRenewal: Boolean true/ false to determine if the subscription will renew or not.
  3. _newPlan: Determines if the plan will change at the time of renewal. If its empty, then it can be considered as no change.

Step 2: Define rules for different parts of subscriber journey

1. Subscription created

Listen to our subscription/created webhook and use Update custom attributes endpoint to create the 3 keys mentioned above with following values:

  • _installmentsLeft: Delivery interval count for one cycle - completed order count.

    (Usually completed orders = 1 when created via checkout, 0 for manual admin-created subscriptions)

  • _autoRenewal: true

  • _newPlan: empty

Example: If a subscription is created with 6 months plan, then [ _installmentsLeft = 5 , _autoRenewal: true , _newPlan: empty ]

2. Plan/ frequency updated:

If a subscriber change the plan then use Update custom attributes endpoint to update the key value of _newPlan key.

  • _installmentsLeft: no change
  • _autoRenewal: no change
  • _newPlan: add new plan delivery interval count

Example: If a customer was on a 3 months plan and they changed to 6 months plan after their 2nd order then the key values before and after should be:

Old keys value: [ _installmentsLeft = 1 , _autoRenewal: true , _newPlan: empty ]

New keys value: [ _installmentsLeft = 1 , _autoRenewal: true , _newPlan: 6 ]

3. Recurring order placed:

Case 1: When installments left is more than 1 (Mid cycle)

When order is placed then listen to our order/processed webhook and update the values and key with the following logic:

  • _installmentsLeft: reduce by 1
  • _autoRenewal: no change
  • _newPlan: no change

Example: If a subscription is on the 6 months plan and 4th order is just placed then the key values before and after should be:

Old keys value: [ _installmentsLeft = 3 , _autoRenewal: true , _newPlan: empty ]

New keys value: [ _installmentsLeft = 2 , _autoRenewal: true , _newPlan: empty ]

Case 2: When installments left =1 (Renewal time)
  • _autoRenewal = true

    a.) _newPlan is empty

    • _installmentsLeft: delivery interval count
    • _autoRenewal: no change
    • _newPlan: empty

Example: If the customer is on 3 months plan and the cycle is just completed after this order with auto renewal being yes then the key values before and after should be:

Old keys value: [ _installmentsLeft = 1 , _autoRenewal: true , _newPlan: empty ]

New keys value: [ _installmentsLeft = 3 , _autoRenewal: true , _newPlan: empty ]

b.) _newPlan is not empty

Call Loop Swap line on subscription endpoint to swap the old plan with the new plan and call Update frequency to update new delivery frequency as per the _newPlan variable

  • _installmentsLeft: new plan delivery interval count
  • _autoRenewal: no change
  • _newPlan: empty

Example: If the customer was on 3 months plan and changed it to the 6 months plan then the key values before and after should be:

Old keys value: [ _installmentsLeft = 1 , _autoRenewal: true , _newPlan: 6 ]

New keys value: [ _installmentsLeft = 6 , _autoRenewal: true , _newPlan: empty ]

Case 3: _autoRenewal = false and it is the last recurring order of the plan before renewal.

Old keys value: [ _installmentsLeft = 1 , _autoRenewal: false , _newPlan: empty or some value ]

Listen to our order/processed webhook and cancel the subscription by using Cancel Subscription endpoint.