-
Notifications
You must be signed in to change notification settings - Fork 104
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
How do you manage responses? #131
Comments
I was wondering about that too. For me it seems that it is not possible to control the response code. def event
StripeEvent.instrument(verified_event)
head :ok
rescue Stripe::SignatureVerificationError => e
log_error(e)
head :bad_request
end Isn't it a common use case to return error codes if something goes wrong? In my case I convert a user to a premium user for incoming 'checkout.session.completed' events. If that failes I would like to return a 422 or something similar. UpdateI think a problem is that an event can have many subscribers. Each may set a different response code. I tried to solve that by using an exception. I implemented it testwise (#132) but I think it breaks the processing of the event by other subscribers. So it is probably not a good solution. Just wanted to reference it here. |
I'm the first to admit I'm a hack coder so maybe I don't grok how different subscribers would break this. I'm testing out a slight change to your patch #132 but made a slight change to your webhook controller for ProcessError:
And I'm calling it by raising the error similar to yours but passing through the return code I want sent: So far it's working in my tests and I can customize the header by just sending a valid response code number. |
I'm also struggling to find a clean way to extend this controller, i realized these webhooks were failing to get tagged properly as i'm not appending needed params for lograge https://github.com/roidrage/lograge # app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
def append_info_to_payload(payload)
super
payload[:service] = :stripe
# ...truncated
end
end pretty reasonable. anyone happy with their implementation of something similar? |
I didn't see this in the documentation, but how does this library respond with 400s?
The text was updated successfully, but these errors were encountered: