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

Support for webhook route with dynamic segment #136

Open
jkburges opened this issue Jul 16, 2020 · 2 comments
Open

Support for webhook route with dynamic segment #136

jkburges opened this issue Jul 16, 2020 · 2 comments

Comments

@jkburges
Copy link

jkburges commented Jul 16, 2020

I'm trying to solve the problem of knowing from which stripe account events are coming. It doesn't seem like there's consistently an account field in the event from stripe (I think this may only be a stripe connect thing, which I don't have).

e.g. with a route definition having a dynamic segment such as:

mount StripeEvent::Engine, at: "/stripe/event/(:account_country)"

I can configure my US stripe account to hit "/stripe/event/us" and likewise my AU account to hit "/stripe/event/au".

The dynamic segment value is then available at https://github.com/integrallis/stripe_event/blob/master/app/controllers/stripe_event/webhook_controller.rb#L8 as params[:account_country].

After that point however, the information is lost and doesn't make it through to the event handlers.

One way to pass it on would be to change https://github.com/integrallis/stripe_event/blob/master/app/controllers/stripe_event/webhook_controller.rb#L8 to:

StripeEvent.instrument(verified_event, params)

and so on downstream, so that the event handler ends up having an interface such as:

class Handler
  def call(event, params)
  end
end

but I'm not sure if that can be done without breaking compatibility with the old interface.

Another alternative would be to piggyback on the event object itself, e.g at https://github.com/integrallis/stripe_event/blob/master/app/controllers/stripe_event/webhook_controller.rb#L8"

StripeEvent.instrument(verified_event.merge(params: params))

but that seems a bit of a hack.

Does anyone have some advice?

@daniely
Copy link

daniely commented Feb 10, 2021

I have a need for seeing the params along with the event as well. Any update on this?

@jkburges
Copy link
Author

@daniely FWIW I didn't get anywhere with this.

I might be able to submit a PR at some point but would need advice from the gem owners on the best way to proceed.

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

No branches or pull requests

2 participants