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

POC Feedback #4

Open
cannikin opened this issue Oct 20, 2021 · 1 comment
Open

POC Feedback #4

cannikin opened this issue Oct 20, 2021 · 1 comment

Comments

@cannikin
Copy link
Member

I'll just make a list of things here that I got confused about during setup!

Here's a couple of suggestions for the README:

  • I'd add instructions that say, after cloning, to cd app and then yarn install before running any of the follow commands
  • Mention to go sign up with Stripe and get your keys ready (can include a link to that page in the Stripe dashboard)
  • Mention to run stripe login locally after running the brew install command

I wasn't sure if I needed to setup a real Stripe Webhook on the dashboard, or if the stripe CLI tool would somehow fire those locally for me? I used the signing secret from an existing webhook when the rw-setup-plugin-stripe command asked me for it.

I noticed that when I started the server with rw-dev that apparently the stripe CLI outputs its own signing secret, different than the one that was in my .env file...should I have changed STRIPE_WEBHOOK in .env to be that value instead?

When I went to the /stripe-cart page and clicked the Checkout button, I did go over to Stripe and see the checkout page, but got this error in my console:

api | Error: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? https://github.com/stripe/stripe-node#webhook-signing
api | 
api | at /Users/rob/Sites/redwoodjs/payments/app/plugin/stripe/lib/handleStripeWebhooks.js(handleStripeWebhooks):7
api | 2   
api | 3   const handleStripeWebhooks = (event, webhooksObj, returnCb) => {
api | 4     let stripeEvent
api | 5     try {
api | 6       const sig = event.headers['stripe-signature']
api | 7       stripeEvent = stripe.webhooks.constructEvent(
api | 8         event.body,
api | 9         sig,
api | 10        process.env.STRIPE_WEBHOOK_SK
api | 11      )
api | 12  
api | 
api | 1 Object.verifyHeader
api |   /Users/rob/Sites/redwoodjs/payments/app/node_modules/stripe/lib/Webhooks.js:117
api | 
api | 2 Object.constructEvent
api |   /Users/rob/Sites/redwoodjs/payments/app/node_modules/stripe/lib/Webhooks.js:12
api | 
api | 3 handler
api |   /Users/rob/Sites/redwoodjs/payments/app/api/src/functions/stripeWebhooks/stripeWebhooks.js:25
api | 
api | 4 requestHandler
api |   /Users/rob/Sites/redwoodjs/payments/app/node_modules/@redwoodjs/api-server/dist/requestHandlers/awsLambda.js:122
api | 
api | 5 lambdaRequestHandler
api |   /Users/rob/Sites/redwoodjs/payments/app/node_modules/@redwoodjs/api-server/dist/middleware/withFunctions.js:100
api | 
api | 6 Layer.handle [as handle_request]
api |   /Users/rob/Sites/redwoodjs/payments/app/node_modules/express/lib/router/layer.js:95
api | 
api | 7 next
api |   /Users/rob/Sites/redwoodjs/payments/app/node_modules/express/lib/router/route.js:137
api | 
api | 8 next
api |   /Users/rob/Sites/redwoodjs/payments/app/node_modules/express/lib/router/route.js:131
api | 
api | 9 next
api |   /Users/rob/Sites/redwoodjs/payments/app/node_modules/express/lib/router/route.js:131
api | 

After completing checkout, I redirected back to the /stripe-cart page but saw an error in the console again:

2021-10-20 12:49:13   --> checkout.session.completed [evt_1JmkmjA8bOxMBMBO8DfdM3Ak]
api | StripeSignatureVerificationError: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? https://github.com/stripe/stripe-node#webhook-signing
api |     at Object.verifyHeader (/Users/rob/Sites/redwoodjs/payments/app/node_modules/stripe/lib/Webhooks.js:117:13)
api |     at Object.constructEvent (/Users/rob/Sites/redwoodjs/payments/app/node_modules/stripe/lib/Webhooks.js:12:20)
api |     at handleStripeWebhooks (/Users/rob/Sites/redwoodjs/payments/app/plugin/stripe/lib/handleStripeWebhooks.js:7:35)
api |     at handler (/Users/rob/Sites/redwoodjs/payments/app/api/src/functions/stripeWebhooks/stripeWebhooks.js:25:3)
api |     at requestHandler (/Users/rob/Sites/redwoodjs/payments/app/node_modules/@redwoodjs/api-server/dist/requestHandlers/awsLambda.js:122:26)
api |     at lambdaRequestHandler (/Users/rob/Sites/redwoodjs/payments/app/node_modules/@redwoodjs/api-server/dist/middleware/withFunctions.js:100:40)
api |     at Layer.handle [as handle_request] (/Users/rob/Sites/redwoodjs/payments/app/node_modules/express/lib/router/layer.js:95:5)
api |     at next (/Users/rob/Sites/redwoodjs/payments/app/node_modules/express/lib/router/route.js:137:13)
api |     at next (/Users/rob/Sites/redwoodjs/payments/app/node_modules/express/lib/router/route.js:131:14)
api |     at next (/Users/rob/Sites/redwoodjs/payments/app/node_modules/express/lib/router/route.js:131:14) 

I do see the payment in my Stripe Dashboard, so something definitely went through!

@chrisvdm
Copy link
Collaborator

Thanks @cannikin for the feedback! I will definitely look more into the webhook secret issue, to figure out a more elegant way of handling that.

Re README suggestions 👍. The Readme can defnitely be improved on

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