#silvanete-smtp-mail
1 messages · Page 1 of 1 (latest)
Hello
It looks like those are logs of attempting to send events to your webhook endpoint, is that correct?
Yes, they are successful, but why that 404 error? My concern is trying to find out why my gmail smtp server is not being recognized. I have email notifications that are not being sent. If I change the server to Mailtrap, it works and sends the emails, but I want to send them with my authorized smtp.gmail.com account setup.
I suspect it has something to do with the Stripe checkout, but it worked in a prior project that also used Stripe checkout.
So a 404 error here means that you are reaching your Server but your Server is returning an error
Since I'm testing on localhost, I can't listen via https. Even if I include just http the listen does not work. It only works if I leave off the connection protocol altogether and just do
stripe listen --forward-to localhost
Have you looked on your server for what the 404 error is?
Also if you can share one of those event IDs I may be able to look from my end at what your server is sending back
evt_3Laiq7A1zWLq0D6G1ZqS9Yr2
Gotcha, so you can see the Response body at the bottom of your Dashboard here: https://dashboard.stripe.com/test/events/evt_3Laiq7A1zWLq0D6G1ZqS9Yr2
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Basically your Server is sending back some HTML for some reason
Instead of returning a 200
So really you need to investigate this in your Server webhook code
I don't see any server webhook code. My server is localhost. Where would I find that code?
You still have server code that you are hosting via localhost. Where is your webhook code at?
I don't understand that question. The only webhook code I ran was the stripe listen. There must be something like from deep in my node_modules. I did find this error in the DevTools:
const err = new Error('Loading initial props cancelled');
and
source mapped from webpack with this url but blank page
webpack-internal:///node_modules/next/dist/shared/lib/router/router.js
If the only thing you did was run stripe listen then that is the issue. You have to set up an endpoint to receive these webhooks: https://stripe.com/docs/webhooks
I'm sure that was done somewhere in the /pages/api/stripe files code sections. What am I looking for?
I can't really tell you where in your code you would have this. You can look at our quickstart (https://stripe.com/docs/webhooks/quickstart) for what your code might look like in general based on the language you are using on your server
There's this code in success.js
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY)
const stripe_session = await stripe.checkout.sessions.retrieve(
req.body.session_id
)
await prisma.order.create({
data: {
customer: stripe_session.customer_details,
products: stripe_session.display_items,
payment_intent: stripe_session.payment_intent,
amount: parseInt(stripe_session.amount_total),
},
})
The payments go through and get posted to my database.
I looked at your article. All that was done.
That isn't webhook code though? There is no endpoint there to receive the webhook. That is just code for when you pass data from your client to your server.
Let me check my other previous projects and I'll get back to you as soon as I can, please.
Sure thing, we'll be around. If this thread gets archived just post again in the main channel.
Thanks. I was in a bootcamp that did several Stripe related projects. Only in the first one do I see that we created an actual webhook.js endpoint in our project /pages/api/stripe route. It had a sesslion.js and a webhook.js file. In this final project there were only the session.js and the success.js file -- and I don't see any mention of the STRIPE_WEBHOOK_SECRET in it (that was in our earlier project).
Is there any possibility that our webhook could work without that? So, by looking at the events, it then looks like the checkout process was really NOT successful.
Hello! I'm taking over and catching up...
You can receive and process webhooks from Stripe without verifying the signature, but doing so is very dangerous and not recommended. Bad actors can send webhooks to your endpoints and pretend to be Stripe.
So, just logging in to Stripe and going to Developer dashboard, firing up our app on a localhost server, and running stripe listen --forward-to localhost:3000/api/stripe/webhook is not sufficient. That goes through something and then returns "Ready!" with my webhook secret. Then that is NOT the way it should be done. Would that explain why I'm getting that 404 and the error saying 'Loading initial props cancelled'? @sacred steeple showed me the events. Does that mean they were actually NOT successful? Could that be part of the cause for my smtp.gmail not working to send the notification emails? Mailtrap does, but I's like something a bit more realistic than sending emails to myself.
That command will listen for events and forward them to the code running at the URL you specified. Not sure what you mean by that being sufficient or not? The 404 is being returned by the web server running on localhost:3000 and is indicating the URL cannot be found, likely because you don't have a route handler set up for it.
Is that helpful? Is there anything else I can do to help?
Do you need to have a hosted webhook endpoint, or is it (not best practice, but ok) to just use the /api/stripe/webhook link?
not sure I understand, what do you mean?
to clarify, the /api/something/otherthing endpoint is something you define in your web server code
The app I am talking about is just in development testing on localhost. Is it absolutely necessary to actually create a hosted endpoint that checks signature?
I don't understand why the payments process with just a stripe cli listen command. When I run that, Stripe does something and comes back with "Ready! You are using Stripe API Version [2020-08-27]. Your webhook signing secret is whsec_xxxx"
what do you mean by "hosted endpoint"? one hosted on something like AWS?
if so, no.
Stripe CLI pipes the events to your local development webserver
I mean one deployed and not in localhost.
See this page: https://dashboard.stripe.com/test/webhooks
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
sorry I think we're talking past each other
if you're in test mode, just developing locally, you use the CLI and what Rubeus suggested above
if you're in live mode and deploying your web server for production, you need your webhook endpoint deployed as well
Yes, it is just the test mode. He said this: "You can receive and process webhooks from Stripe without verifying the signature, but doing so is very dangerous and not recommended." So, is it possible for webhook to process payments in the test mode without a webhook handler file?
Sorry, ok, you seem to say that YES, you can do that in test mode.
so these are 2 diff questions
So, is it possible for webhook to process payments in the test mode without a webhook handler file?
depending on the integration, some integrations require you to handle webhook events before the payment is completed. So depends on how you're integrated
and q2 is
process webhooks from Stripe without verifying the signature, but doing so is very dangerous and not recommended
if you do implement webhook handler, you could not verify signatures, we highly recommend you do