We've moved discussions to Discord

Changes to Stripe API affecting pay integration in Jumpstart?

Ariel Fogel
Hey all,
I’m just getting Stripe setup in my app and I noticed the Stripe API was different from what was shown in the screencast. I read that it’s backwards compatible, but am not seeing charges that seem to register on Stripe's end get propagated to my admin panel. Anyone know what might be going on? Do I need to reconfig my Pay gem?
Thanks!
Ariel Fogel
Chris Oliver Hey -- I've spent a bit more time digging and have a bit more info. I followed steps to get pay up and running, I've got stripe integrated and it seems to work. I can go through the flow and a `Pay::Subscription` gets created on both my end as well as Stripe's end, but `Pay::Charge` is not being created on mine (based on trying to query in rails console). The payments are going through on Stripe's end (using test credentials). 
Do you have any insight into what might be going on?
Thanks!

Chris Oliver
Charges won't get created locally unless you have the Stripe CLI running to receive webhooks. The webhooks are required now for SCA to work properly, so you'll need them in both development and production.
Ariel Fogel   Chris Oliver I am having the same issue. Pay::Subscription gets created but not Pay::Charge. I have Webhooks running in development:

Did you find a solution yet Ariel? 

2020-10-17 23:06:23   --> customer.created [evt_1HdSDxFpD1Vi3MJwpydP0asX]
2020-10-17 23:06:23  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSDxFpD1Vi3MJwpydP0asX]
2020-10-17 23:06:23   --> payment_method.attached [evt_1HdSDxFpD1Vi3MJw1JEDA70a]
2020-10-17 23:06:23  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSDxFpD1Vi3MJw1JEDA70a]
2020-10-17 23:06:25   --> customer.updated [evt_1HdSDyFpD1Vi3MJw86mu95vt]
2020-10-17 23:06:25  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSDyFpD1Vi3MJw86mu95vt]
2020-10-17 23:06:26   --> charge.succeeded [evt_1HdSE0FpD1Vi3MJwakt1bPvQ]
2020-10-17 23:06:26   --> customer.updated [evt_1HdSE0FpD1Vi3MJwIe4SWOSw]
2020-10-17 23:06:26  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSE0FpD1Vi3MJwakt1bPvQ]
2020-10-17 23:06:26   --> invoice.finalized [evt_1HdSE0FpD1Vi3MJwUUBh733d]
2020-10-17 23:06:26   --> invoice.created [evt_1HdSE0FpD1Vi3MJwfTkp1dk0]
2020-10-17 23:06:26   --> payment_intent.succeeded [evt_1HdSE0FpD1Vi3MJwOXEUMsDb]
2020-10-17 23:06:26  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSE0FpD1Vi3MJwIe4SWOSw]
2020-10-17 23:06:26   --> customer.subscription.created [evt_1HdSE0FpD1Vi3MJwJigN4I55]
2020-10-17 23:06:26   --> invoice.payment_succeeded [evt_1HdSE0FpD1Vi3MJwcl6Frnt1]
2020-10-17 23:06:26  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSE0FpD1Vi3MJwUUBh733d]
2020-10-17 23:06:26   --> invoice.paid [evt_1HdSE0FpD1Vi3MJwQRSoVbFt]
2020-10-17 23:06:27   --> payment_intent.created [evt_1HdSE0FpD1Vi3MJwJR1xZYMo]
2020-10-17 23:06:27  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSE0FpD1Vi3MJwfTkp1dk0]
2020-10-17 23:06:27  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSE0FpD1Vi3MJwOXEUMsDb]
2020-10-17 23:06:27  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSE0FpD1Vi3MJwcl6Frnt1]
2020-10-17 23:06:27  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSE0FpD1Vi3MJwJigN4I55]
2020-10-17 23:06:27  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSE0FpD1Vi3MJwQRSoVbFt]
2020-10-17 23:06:27  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HdSE0FpD1Vi3MJwJR1xZYMo]
I am seeing this error in the log: `ActionController::RoutingError (No route matches [POST] "/pay/webhooks/stripe"):`. That's probably the reason no Pay::Charge is getting created. 

I checked rails routes and I am seeing pay related routes:

Routes for Pay::Engine:
           payment GET  /payments/:id(.:format)       pay/payments#show
   webhooks_stripe POST /webhooks/stripe(.:format)    stripe_event/webhook#event
webhooks_braintree POST /webhooks/braintree(.:format) pay/webhooks/braintree#create

If anyone has any hint, I really appreciate the help. 
Chris Oliver
Pay automounts the routes to `/pay/` here: https://github.com/excid3/pay/blob/master/lib/pay/engine.rb#L27

I can confirm they're working since I'm using JSP in production and webhooks are POSTing to /pay/webhooks/stripe

You could be missing the signing secret that the Stripe CLI is using. That must be added to the credentials for it to work. I'm not sure what HTTP status code it returns if a webhook doesn't match the signing secret, could be a 404.
Chris Oliver  

stripe listen --forward-to localhost:3000/pay/webhooks/stripe

returns a sign-in secret: 
> Ready! Your webhook signing secret is whsec_<redacted>(^C to quit)

In my development credentials file, I set the secret:

# For processing Stripe webhooks
  # https://dashboard.stripe.com/account/webhooks
  # Webhooks should be pointed to https://domain.com/webhooks/stripe
  signing_secret: whsec_<redacted>

I copied and pasted the sign-in secret so I know they are identical. But I am still getting:

Started POST "/pay/webhooks/stripe" for ::1 at 2020-10-25 23:04:17 -0400

ActionController::RoutingError (No route matches [POST] "/pay/webhooks/stripe"):

I am seeing 404s but that's from the rails app since no route is found. 

2020-10-25 23:04:13   --> customer.created [evt_1HgM0GFpD1Vi3MJw2yBhy0B0]
2020-10-25 23:04:14  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0GFpD1Vi3MJw2yBhy0B0]
2020-10-25 23:04:15   --> payment_method.attached [evt_1HgM0HFpD1Vi3MJwmAWrSq77]
2020-10-25 23:04:15   --> customer.updated [evt_1HgM0IFpD1Vi3MJwwLqiyC0R]
2020-10-25 23:04:15  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0IFpD1Vi3MJwwLqiyC0R]
2020-10-25 23:04:15  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0HFpD1Vi3MJwmAWrSq77]
2020-10-25 23:04:16   --> charge.succeeded [evt_1HgM0KFpD1Vi3MJwhusBs965]
2020-10-25 23:04:16   --> customer.updated [evt_1HgM0KFpD1Vi3MJwM0Gp4Xi6]
2020-10-25 23:04:16  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0KFpD1Vi3MJwhusBs965]
2020-10-25 23:04:16   --> invoice.created [evt_1HgM0KFpD1Vi3MJwVFIfJUG1]
2020-10-25 23:04:16   --> invoice.finalized [evt_1HgM0KFpD1Vi3MJwbxdjuo3T]
2020-10-25 23:04:16   --> invoice.paid [evt_1HgM0KFpD1Vi3MJwykIe9Iyc]
2020-10-25 23:04:16   --> invoice.payment_succeeded [evt_1HgM0KFpD1Vi3MJwgTkf4h9v]
2020-10-25 23:04:16   --> customer.subscription.created [evt_1HgM0KFpD1Vi3MJwHMoHN21W]
2020-10-25 23:04:16  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0KFpD1Vi3MJwM0Gp4Xi6]
2020-10-25 23:04:16   --> payment_intent.created [evt_1HgM0KFpD1Vi3MJwUaxAEozc]
2020-10-25 23:04:16   --> payment_intent.succeeded [evt_1HgM0KFpD1Vi3MJweWrrxM6G]
2020-10-25 23:04:17  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0KFpD1Vi3MJwVFIfJUG1]
2020-10-25 23:04:17  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0KFpD1Vi3MJwbxdjuo3T]
2020-10-25 23:04:17  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0KFpD1Vi3MJwykIe9Iyc]
2020-10-25 23:04:17  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0KFpD1Vi3MJwUaxAEozc]
2020-10-25 23:04:17  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0KFpD1Vi3MJwgTkf4h9v]
2020-10-25 23:04:17  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0KFpD1Vi3MJwHMoHN21W]
2020-10-25 23:04:17  <--  [404] POST http://localhost:3000/pay/webhooks/stripe [evt_1HgM0KFpD1Vi3MJweWrrxM6G]

I thin the Pay gem mounted fine because I am seeing this when I run rake routes:

Routes for Pay::Engine:
           payment GET  /payments/:id(.:format)       pay/payments#show
   webhooks_stripe POST /webhooks/stripe(.:format)    stripe_event/webhook#event
webhooks_braintree POST /webhooks/braintree(.:format) pay/webhooks/braintree#create

I have been stuck on this for days now. Really appreciate the help. 

Clement Camin
From what I read in your latest logs:
 - you are POSTing on `/pay/webhooks/stripe`, which leads to a non-existing route
 - the docs (in a comment in the credentials file) states 
Webhooks should be pointed to https://domain.com/webhooks/stripe
 - your rails routes (and its the same for me here) say that there is a POST route on /webhooks/stripe, but not on /pay/webhooks/stripe

So I'd say something is wrong somehow with the /pay prefix (which is weird because on the logs on the 17th, you had those routes); what about using /webhooks/stripe ?
Notifications
You’re not receiving notifications from this thread.