-
Hi everyone, I'm following the docs and trying to configure custom Stripe webhook listeners as described here I add the And then I create a However, on
I tried adding As suggested in #486, I also tried this lambda approach: Pay::Webhooks.delegator.subscribe "stripe.charge.succeeded", ->(event) { FulfillCheckout.new.call(event) } – but no luck either, same uninitialized constant error. I've also seen people defining the Also tried matching the name of the class to the name of the file ( It looks like Rails is just not loading my Using ruby 3.2.2 on rails 7.1.2 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Your issue is likely due to the file name you've chosen as Zeitwerk, the autoloader that Rails uses, is expecting your From the Rails docs:
If you rename the |
Beta Was this translation helpful? Give feedback.
-
Update: looks like it works if I manually require each file in require Rails.root.join('app/webhooks/fulfill_checkout.rb')
Pay::Webhooks.delegator.subscribe "stripe.checkout.session.completed", FulfillCheckout.new
Pay::Webhooks.delegator.subscribe "stripe.checkout.session.async_payment_succeeded", FulfillCheckout.new Not sure this is the best solution, though, since Zeitwerk should be doing this work. |
Beta Was this translation helpful? Give feedback.
-
I found out what I was doing wrong: the # config/initializers/pay.rb
ActiveSupport.on_load(:pay) do
Pay::Webhooks.delegator.subscribe "stripe.checkout.session.completed", FulfillCheckout.new
end Doing this, there's no need to manually require any files. Turns out this was not mentioned in the Looks like this change was introduced in version |
Beta Was this translation helpful? Give feedback.
I found out what I was doing wrong: the
Pay::Webhooks.delegator.subscribe
lines need to go inside anActiveSupport.on_load(:pay)
block, like this:Doing this, there's no need to manually require any files.
Turns out this was not mentioned in the
pay
docs for Stripe Checkout (docs/stripe/8_stripe_checkout.md
) – but it was mentioned in the regular webhooks docs (docs/7_webhooks.md
)Looks like this change was introduced in version
6.4.0
and the Stripe docs were not updated. I'm submitting a PR to fix the Stripe Checkout docs.