Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After deleting billing information (delete stripe customer) user should remain on plan until end of billing cycle #9

Open
sferoze opened this issue Mar 5, 2017 · 2 comments

Comments

@sferoze
Copy link

sferoze commented Mar 5, 2017

I was working on implementing this today and ran into one issue.

If a customer wants to delete their billing information, the only way to do it with Stripe is to delete the customer from Stripe.

So the user will no longer has a stripe customer #.

Thus it always sets the user back to the free plan when it syncs since the customer is no longer in Stripe.

But if a customer deletes their billing information (thus deleting stripe customer), and the customer still has time left on the current billing cycle....syncing will make the customer forfeit the remaining time they paid for.

Syncing would be fine as long as the next time the customer subscribes to pro (thus creating a new stripe customer) the system should determine if they have time left on the current billing cycle. If so the system should set a trial_start_date at the date the current billing cycle end.

The hack below avoids syncing with Stripe until the current billing cycle end date has arrived. But there is a problem with it.

Accounts.onLogin (info) ->
  userId = info.user._id

  syncAndSet = ->
    AppPlans.sync userId: userId
    plan = AppPlans.get(userId: userId)
    if !plan
      AppPlans.set 'lite', userId: userId

  if !!AppPlans.endDate('pro', userId: userId)
    if moment().isAfter(AppPlans.endDate('pro', userId: userId))
      syncAndSet()
  else
    syncAndSet()

This issue arises when the customer tries to resubscribe to the plan and they also have time left on the current billing cycle ... since they are no longer a stripe customer (since they deleted their billing info) ... it charges them immediately instead of charging them on the next billing cycle.

So what needs to happen is when they subscribe again, and if they are no longer a stripe customer, the package should set the first billing date to be when AppPlans.endDate is

@sferoze
Copy link
Author

sferoze commented Apr 2, 2017

@aldeed I have updated the post above to clarify the issue.

@aldeed
Copy link
Collaborator

aldeed commented Apr 10, 2017

@sferoze OK, so you have to delete the customer, which also cancels all subscriptions, and by default no proration refund is given.

One solution would be to issue a refund for the rest of the month as soon as you delete the customer. Then going back to the paid plan would start over with a different billing period, but they wouldn't be overcharged.

Otherwise, yeah I think it would make sense to use the endDate as the first billing date if we are creating a new customer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants