andrewculver / koudoku

Robust subscription support for Rails with Stripe.
MIT License
1.16k stars 187 forks source link

Receiving payment_succeeded event on subscription cancelation #171

Open knagode opened 8 years ago

knagode commented 8 years ago

When I cancel subscription I receive customer.subscription.deletedevent from Stripe which is OK.

After that I immediately receive invoice.payment_succeeded which even triggers error in code:

NoMethodError (undefined method `payment_succeeded' for nil:NilClass):
2016-09-13T16:30:27.066412+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/koudoku-1.2.4/config/initializers/stripe_event.rb:13:in `block (2 levels) in <top (required)>'

Why am I even getting payment succeeded event on cancelation?

yas4891 commented 8 years ago

@knagode Thanks for reporting this. It looks like Stripe creates a final invoice to settle the remaining balance. That's what's causing this error.