Search code examples
braintree

Braintree - Future subscription cancellation


I'm looking for a way to set an 'expiry' date for expiring subscriptions. Current business rules lets the user to still have access to the system until the end of the billing period.

Because within that period, the user may still purchase addon's and Braintree's proration helps us to charge to this pending expiring subscription. Here are some of my thoughts:

1) Set the number of billing cycle from INFINITE to 0 or -1? I didn't find much documentation on this and I wonder if I do this, at the next billing cycle, the subscription would "expire"? (I'll be running tests on it, but I thought I'll put this out here)

EDIT: The number of billing cycle must be greater than 0, but setting the value to 1 seems to set the expiry date to expire at the end of the cycle which might solve my issue. (I'm guessing Braintree assumes the current billing cycle to be counted as 1.)

2) If the user decides to continue the subscription, I could change the billing cycle back to INFINITE and the subscription continue as if nothing happened.

3) Same scenario happens, when a user upgrades to a different package. A new subscription would be created with the future date to begin after the end of the current subscription billing cycle.

4) Or do I have to bring them all in house and have my own CRON/Jobs running to handle these scenarios?

Please let me know what you think, or suggest a better solution.

ANSWER: I solved this issue by setting the number_of_billing_cycles to be equal to the current_billing_cycle as mentioned by jellenberger. This sets an expiry date to the current subscription thus allowing me to still charge to the same subscription.


Solution

  • Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

    In recurring billing there are dozens of ways to solve these kind of problems and no "right solution" for every billing flow. But the bottom line is that you can calculate expiration date in the final cycle based on billing_period_end_date and current_billing_cycle - number_of_billing_cycles == 0.

    If you would like to allow a customer to receive addons after the last billing cycle has completed, you could extend the number of billing cycles by one and either update the price to be zero, or add a discount with amount equal to the subscription price. Or, more simply, you could create a new transaction using the customer's default payment method for the prorated amount.

    To help better manage these actions, there are a number of Webhooks that pertain to subscriptions, and may aid in avoiding the need to write your own cronjob. If you need further help with your integration, feel free to reach out to Braintree Support.