If you use your Stripe account for other things other than the stuff you are linking to Koudoku then Stripe still hits the Koudoku webhooks with events from the other stuff. The result is that the stripe_id that hits the Koudoku registered webhooks throws a 500 error to Stripe.
Now that would be fine, and maybe even a good thing, HOWEVER Stripe will keep retrying to hit the webhook until it gets a 200 response. Eventually Stripe will threaten to even kill your webhook.
The Solution
Instead of letting it throw errors like NoMethodError: undefined methodpayment_succeeded' for nil:NilClass, just log a warning if the subscription doesn't exist for thestripe_id` that was posted.
Good stuff. I agree, this should be in the gem. I recently ran into this as well after manually migrating from a Wordpress Plugin to a custom rails site that uses Koudoku. Kudos for this.
The Problem
If you use your Stripe account for other things other than the stuff you are linking to Koudoku then Stripe still hits the Koudoku webhooks with events from the other stuff. The result is that the
stripe_id
that hits the Koudoku registered webhooks throws a 500 error to Stripe.Now that would be fine, and maybe even a good thing, HOWEVER Stripe will keep retrying to hit the webhook until it gets a 200 response. Eventually Stripe will threaten to even kill your webhook.
The Solution
Instead of letting it throw errors like
NoMethodError: undefined method
payment_succeeded' for nil:NilClass, just log a warning if the subscription doesn't exist for the
stripe_id` that was posted.Also...
Using dynamic
find_by's like
find_by_blehis deprecated in Rails 4 and you should use
find_by(stripe_id: strip_id)` instead, so I updated these lines. See http://edgeguides.rubyonrails.org/4_0_release_notes.html#active-record-deprecations for reference.Great gem BTW! Very useful!!