Skip to main content

Upsell unlimited billing logic change Part 1

Currently, when the user purchases Upsell unlimited their original subscription gets modified. The new logic will be to create a separate linked subscription.

Specs:

Scenario: When user buys upsell subscription (upsell unlimited, bundle or something else) the second linked subscription should be created

Given a user

When they purchase any Upsell (Upsell Unlimited, bundles, something else) after check out

Then a new subscription for the Upsell should be created for them

And it should be tied to the original subscription

Eng notes: add-on subscriptions table - talk to Ivan \ Many to many with subscriptions

Scenario: Several upsell subscriptions can be added to original one

Given a user

Then they can purchase several upsells that will tie to their original subscription

Scenario: One upsell subscription can be added to several original ones

Given a user

Then they can purchase an upsell that requires the user to have two or more subscriptions

Scenario: Additional subscription may be prorated by days (similar to Shopify)

Given a user

When they purchase an upsell

Then the amount of Upsell may be prorated by formula: Amount = price of upsell x/365, where x = number of days left till the end of the original subscription for yearly users, and Amount = price of upsell x/30 for monthly users

Scenario: After the billing cycle there will be two or more charges for renewal of upsells

Given an upselled user

When their subscription needs to be renewed

Then there will be 2 or more charges depending on number of upsell they have (for their two subscriptions - original and upsell). Charges happen independently

Scenario: If one of the original subscription cancels, then the upsells tied to it needs to be canceled automatically

Given an upselled user

When they cancel their original subscription

Then the upsell subscriptions tied to the original one should cancel too

Scenario: Upsell subscriptions can be canceled separately

Given an upselled user

When they cancel upsell subscriptions

Then only the upsell subscription should cancel

And original subscription will not cancel

Scenario: User purchased subscription1 for app1 at date1 and subscription2 for app2 at date2, then we offered upsell for app3 and the user purchased subscription3 at date 3. What would be the next billing cycle date of subscription3? Will it be the same with the next billing cycle date of subscription1 or subscription2?

Given a user with 2 or more existing subscriptions

When they purchase upsell that ties to 2 or more existing subscriptions

Then the charge for upsell on next billing cycle will be performed on the latest subscription

Eng proposal:

  1. Add_on_subscriptions table:
  • id
  • primary_subscription_id (should be indexed)
  • secondary_subscription_id
  • active (redundant column)
  • created_at
  • updated_at
  1. Create secondary_subscription.rb:
  • Add create_secondary_subscription
  • Add cancel_secondary_subscriptions
  1. Fix logic of create_transaction method of pro_subscription.rb

Ex:

alt_text

  • Add an add_on_subscription_controller
  • Route:
    • POST /pro_subscriptions/add-on, data = { primary_subscription_ids: [] }

Scenario: When primary subscription gets paused, the secondary subscriptions get paused too

Given an upselled user

When they pause their original subscription

Then the upsell subscriptions tied to the original one should pause too

Scenario:

Given an upselled user

And they have multiple primary subscriptions

When they change one of the primary subscriptions

Then the add on subscription should cancel

Scenario:

Given an upselled user

And they have one primary subscription

When they change the billing cycle of the original subscription

Then the upselled subscription’s billing cycle should also change