RailsApps / rails-stripe-membership-saas

An example Rails 4.2 app with Stripe and the Payola gem for a membership or subscription site.
http://railsapps.github.io/rails-stripe-membership-saas
1.14k stars 232 forks source link

Let stripe event handle deletion of user #79

Closed mmorrison closed 11 years ago

mmorrison commented 11 years ago

Applied fix for issue where stripe event was throwing a 500 because the user was already deleted. So this allows stripe event to handle deletion of user.

DanielKehoe commented 11 years ago

Could you give me more description of the failure case? I don't know if it has been reported previously and it would be helpful to know the conditions required to duplicate the failure. You say, when the user is already deleted, do you mean, using the Stripe admin interface? And then attempting to delete through the rails-stripe-membership-saas application admin interface?

mmorrison commented 11 years ago

Sure thing! Basically when an user is deleted there is before_destroy method that cancels the stripe subscription. Then when the stripe event 'customer. subscription.deleted' is received that event blows up because the user is already deleted. Which causes the email to not be sent.

It is the same issue bug here https://github.com/RailsApps/rails-stripe-membership-saas/issues/42

mmorrison commented 11 years ago

After playing around with more I decided to close this PR and try another solution. Thanks for all your work on this project!

DanielKehoe commented 11 years ago

Sorry, but could you explain? Is there still an issue? Did the pull request not handle it? Is there another way to address the issue?

mmorrison commented 11 years ago

Yeah sorry this is still an issue. I do not believe the pull request was the right way to handle it. I think it might be better to have a method that cancels the subscription for the user first then have the stripe event ''customer. subscription.deleted' callback actually delete the user and send out the confirmation email. I hope I was able to clarify the issue. Hopefully I will get time to play around with this solution and submit a new PR. Thanks again.