Episodes
jakeyeaton16 said over 4 years ago on More on Stripe and Webhooks :
Hello, I followed all instructions but for some reason I still can't see the webhook's info on my** view**. Do you mind checking my code and help me understand what I did wrong? Thank you

David Kimura PRO said over 4 years ago on More on Stripe and Webhooks :
Hmmm, are you able to see the webhook requests coming in from Stripe into your logs? Also, within Stripe, they have some logs for the webhook events that are sometimes helpful to see what is happening.

jakeyeaton16 said over 4 years ago on More on Stripe and Webhooks :
So I checked my logs again and I found that I'm getting this error: **ArgumentError (Before process_action callback :verify_authenticity_token has not been defined): ** I understand that it's in my webhooks_controller.rb but I'm not sure how to fix that.

David Kimura PRO said over 4 years ago on More on Stripe and Webhooks :
Can you post the `webhooks_controller.rb`? If you are overriding the Webhook controller like I showed in the episode, it should be `skip_before_action`. ```ruby class WebhooksController < StripeEvent::WebhookController skip_before_action :verify_authenticity_token end ```

jakeyeaton16 said over 4 years ago on More on Stripe and Webhooks :
Hmm... Yes it looks like that. Here is my webhooks_controller.rb: ``` class WebhooksController < StripeEvent::WebhookController skip_before_action :verify_authenticity_token end ```

David Kimura PRO said over 4 years ago on More on Stripe and Webhooks :
Is the error happening on the WebhooksController? Maybe the routes isn't picking it up. Can you post more of the logs?

jakeyeaton16 said over 4 years ago on More on Stripe and Webhooks :
Yes, I restarted the server then refreshed my /users/edit page where the users card info should be showing and this is my entire logs: ``` => Booting Puma => Rails 5.1.4 application starting in development => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.11.2 (ruby 2.4.1-p111), codename: Love Song * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://0.0.0.0:3000 Use Ctrl-C to stop Started POST "/stripe/event" for 54.187.205.235 at 2018-02-06 14:00:31 -0700 Cannot render console from 54.187.205.235! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255 (0.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC ArgumentError (Before process_action callback :verify_authenticity_token has not been defined): app/controllers/webhooks_controller.rb:2:in `' app/controllers/webhooks_controller.rb:1:in `' Started GET "/users/edit" for 127.0.0.1 at 2018-02-06 14:00:44 -0700 Processing by Devise::RegistrationsController#edit as HTML User Load (0.9ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id ", 1], ["LIMIT", 1]] Rendering devise/registrations/edit.html.erb within layouts/application Charge Load (0.4ms) SELECT "charges".* FROM "charges" WHERE "charges"."user_id" = $1 [["user_id", 1]] Rendered devise/registrations/edit.html.erb within layouts/application (48.4ms) Rendered layouts/templates/_header.html.erb (3.0ms) Rendered layouts/templates/_footer.html.erb (0.5ms) Completed 200 OK in 421ms (Views: 364.5ms | ActiveRecord: 15.8ms | Solr: 0.0ms ```

David Kimura PRO said over 4 years ago on More on Stripe and Webhooks :
In your `application_controller.rb`, what does your `protect_from_forgery` look like? Try changing it to `:exception`. ```ruby class ApplicationController < ActionController::Base protect_from_forgery with: :exception end ```

jakeyeaton16 said over 4 years ago on More on Stripe and Webhooks :
It's already set to that value.

David Kimura PRO said over 4 years ago on More on Stripe and Webhooks :
I just checked the `stripe_event` source and it looks like they've updated it to have the check in there. Because it is being called twice, I believe it is common for it to error out. [source](https://github.com/integrallis/stripe_event/blob/master/app/controllers/stripe_event/webhook_controller.rb) Try commenting out the `routes.rb` line for the controller and add `mount StripeEvent::Engine, at: '/stripe/event'`

jakeyeaton16 said over 4 years ago on More on Stripe and Webhooks :
Like this? ``` mount StripeEvent::Engine, at: '/stripe/event' # post '/stripe/event', to: 'webhooks#event' devise_for :users resources :subscriptions, only: [:new, :create] do scope module: 'subscriptions' do collection do resource :unsubscribe, only: :destroy resource :resubscribe, only: :new end end end ```

jakeyeaton16 said over 4 years ago on More on Stripe and Webhooks :
Alright, update. It's working now. I think what was the matter was that it didn't have to load the stripe results for the first time or something! Sorta odd I know. But at least people in the future will know that a way to troubleshoot this issue is to wait it out and come back later. Also try to delete all charges then create a new charge.

David Kimura PRO said over 3 years ago on More on Stripe and Webhooks :
It looks like you're not getting the stripe token passed in from the form. In the form where the credit card is entered, the `stripeToken` should be added in via the javascript. Make sure you don't have any JS errors. You could try to comment out the form submission so that you can inspect the parameters that it adds in. If its not adding those in properly, that could be why you're getting the errors on the controller.

ovi_tsb said over 3 years ago on More on Stripe and Webhooks :
If anybody in the future is going to have the same problem. Double entry for the same customer I fixed with local: true in new subscription form: ``` ```

Login to Comment