jakeyeaton16

Joined 2/5/2018
jakeyeaton16 said about 1 year ago:

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

kobaltz PRO said about 1 year ago:

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 about 1 year ago:

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.

kobaltz PRO said about 1 year ago:

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.

class WebhooksController < StripeEvent::WebhookController
  skip_before_action :verify_authenticity_token
end

jakeyeaton16 said about 1 year ago:

Hmm... Yes it looks like that.

Here is my webhooks_controller.rb:

class WebhooksController < StripeEvent::WebhookController
  skip_before_action :verify_authenticity_token
end

kobaltz PRO said about 1 year ago:

Is the error happening on the WebhooksController? Maybe the routes isn't picking it up. Can you post more of the logs?

jakeyeaton16 said about 1 year ago:

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 `<class:WebhooksController>'
app/controllers/webhooks_controller.rb:1:in `<top (required)>'
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

kobaltz PRO said about 1 year ago:

In your application_controller.rb, what does your protect_from_forgery look like? Try changing it to :exception.

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
end

jakeyeaton16 said about 1 year ago:

It's already set to that value.

kobaltz PRO said about 1 year ago:

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

Try commenting out the routes.rb line for the controller and add mount StripeEvent::Engine, at: '/stripe/event'

jakeyeaton16 said about 1 year ago:

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 about 1 year ago:

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.

jakeyeaton16 said about 1 year ago:

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.

kobaltz PRO said about 1 year ago:

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.

class WebhooksController < StripeEvent::WebhookController
  skip_before_action :verify_authenticity_token
end

jakeyeaton16 said about 1 year ago:

Hmm... Yes it looks like that.

Here is my webhooks_controller.rb:

class WebhooksController < StripeEvent::WebhookController
  skip_before_action :verify_authenticity_token
end

kobaltz PRO said about 1 year ago:

Is the error happening on the WebhooksController? Maybe the routes isn't picking it up. Can you post more of the logs?

jakeyeaton16 said about 1 year ago:

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 `<class:WebhooksController>'
app/controllers/webhooks_controller.rb:1:in `<top (required)>'
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

kobaltz PRO said about 1 year ago:

In your application_controller.rb, what does your protect_from_forgery look like? Try changing it to :exception.

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
end

jakeyeaton16 said about 1 year ago:

It's already set to that value.

kobaltz PRO said about 1 year ago:

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

Try commenting out the routes.rb line for the controller and add mount StripeEvent::Engine, at: '/stripe/event'

jakeyeaton16 said about 1 year ago:

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 about 1 year ago:

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.

jakeyeaton16 said about 1 year ago:

Hmm... Yes it looks like that.

Here is my webhooks_controller.rb:

class WebhooksController < StripeEvent::WebhookController
  skip_before_action :verify_authenticity_token
end

kobaltz PRO said about 1 year ago:

Is the error happening on the WebhooksController? Maybe the routes isn't picking it up. Can you post more of the logs?

jakeyeaton16 said about 1 year ago:

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 `<class:WebhooksController>'
app/controllers/webhooks_controller.rb:1:in `<top (required)>'
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

kobaltz PRO said about 1 year ago:

In your application_controller.rb, what does your protect_from_forgery look like? Try changing it to :exception.

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
end

jakeyeaton16 said about 1 year ago:

It's already set to that value.

kobaltz PRO said about 1 year ago:

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

Try commenting out the routes.rb line for the controller and add mount StripeEvent::Engine, at: '/stripe/event'

jakeyeaton16 said about 1 year ago:

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 about 1 year ago:

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.

jakeyeaton16 said about 1 year ago:

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 `<class:WebhooksController>'
app/controllers/webhooks_controller.rb:1:in `<top (required)>'
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

kobaltz PRO said about 1 year ago:

In your application_controller.rb, what does your protect_from_forgery look like? Try changing it to :exception.

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
end

jakeyeaton16 said about 1 year ago:

It's already set to that value.

kobaltz PRO said about 1 year ago:

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

Try commenting out the routes.rb line for the controller and add mount StripeEvent::Engine, at: '/stripe/event'

jakeyeaton16 said about 1 year ago:

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 about 1 year ago:

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.

jakeyeaton16 said about 1 year ago:

It's already set to that value.

kobaltz PRO said about 1 year ago:

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

Try commenting out the routes.rb line for the controller and add mount StripeEvent::Engine, at: '/stripe/event'

jakeyeaton16 said about 1 year ago:

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 about 1 year ago:

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.

jakeyeaton16 said about 1 year ago:

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 about 1 year ago:

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.

jakeyeaton16 said 12 months ago:

I have been trying to get this to work for little bit now and I'm wondering if it's because i'm using form_with. Do you know how to work around this?

This is what I have:

<%= form_with(model: listing, local: true, html: { id: 'new-listing-form' }, validate: true) do |form| %>

kobaltz PRO said 12 months ago:

It looks like form_with is not supported.

https://github.com/DavyJonesLocker/client_side_validations/issues/696

jakeyeaton16 said 12 months ago:

Hmm... shoot.

So if a person wants to use form_with they will need to use good old fashion jQuery validation?

kobaltz PRO said 12 months ago:

Yea, that's what it sounds like. Seems kind of silly to not support form_with if the other two will be deprecated in the next year or so.

jakeyeaton16 said 12 months ago:

Yeah it does haha

By the way. Do you have a video about how to create the commenting style like you have? It's much like Reddit :)

kobaltz PRO said 12 months ago:

I don't yet, I plan to add one and work on this one more. I used Summernote for a while, but I didn't like having to deal with parsing HTML in some scenarios. This seemed like a much better option since most developers are familiar with Markdown. This library is called SimpleMDE (https://simplemde.com/). I'll probably cover an episode on it soon with integrating with ActiveStorage or something similar.

jakeyeaton16 said 12 months ago:

Hmm... shoot.

So if a person wants to use form_with they will need to use good old fashion jQuery validation?

kobaltz PRO said 12 months ago:

Yea, that's what it sounds like. Seems kind of silly to not support form_with if the other two will be deprecated in the next year or so.

jakeyeaton16 said 12 months ago:

Yeah it does haha

By the way. Do you have a video about how to create the commenting style like you have? It's much like Reddit :)

kobaltz PRO said 12 months ago:

I don't yet, I plan to add one and work on this one more. I used Summernote for a while, but I didn't like having to deal with parsing HTML in some scenarios. This seemed like a much better option since most developers are familiar with Markdown. This library is called SimpleMDE (https://simplemde.com/). I'll probably cover an episode on it soon with integrating with ActiveStorage or something similar.

jakeyeaton16 said 12 months ago:

Yeah it does haha

By the way. Do you have a video about how to create the commenting style like you have? It's much like Reddit :)

kobaltz PRO said 12 months ago:

I don't yet, I plan to add one and work on this one more. I used Summernote for a while, but I didn't like having to deal with parsing HTML in some scenarios. This seemed like a much better option since most developers are familiar with Markdown. This library is called SimpleMDE (https://simplemde.com/). I'll probably cover an episode on it soon with integrating with ActiveStorage or something similar.