#saintlike_webhooks

1 messages ยท Page 1 of 1 (latest)

fervent auroraBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1403061712189390890

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

oblique veldt
#

Hello

#

What error do you see?

#

And do you have an example Event ID that you can share?

opal sparrow
#

Hi there, I checked workbench and this is what i get when stripe webhook fails

opal sparrow
#
try {
          switch (event.type) {
            case 'payment_intent.succeeded':
                data = event.data.object
                const customer = await stripe.customers.retrieve(data.customer)

                const transporter = nodemailer.createTransport({
                  host: 'smtpout.secureserver.net',
                  port: 465,
                  secure: true,
                  auth: {
                    user: process.env.SMTP_EMAIL,
                    pass: process.env.SMTP_PASSWORD
                  }
                })

                const htmlEmailContent = `
                ...
                `

                try {
                  const info = await transporter.sendMail({
                    from: '"ShowMeYourSaas" <demo@showmeyoursaas.com>',
                    to: "demo@showmeyoursaas.com",
                    subject: "noreply",
                    text: "New product submission",
                    html: htmlEmailContent
                  })
                } catch (err) {
                  throw new Error('Failed to send email', err)
                }
              break
            default:
              throw new Error(`Unhandled event: ${event.type}`)
          }
        } catch (error) {
          return NextResponse.json(
            { message: 'Webhook handler failed', error: error },
            { status: 500 }
          )
        }
    }```
here's whats happening in the webhook
oblique veldt
#

That evt_xxx from your screenshot is what I'm looking for

opal sparrow
#

evt_3RtXClQlxuTOhr2i1GrCeeIQ
here it is

oblique veldt
#

But also your screenshot has the necessary info... basically your server is returning a 500 for some reason.

#

I might try logging that error instead of trying to return it

#

Possible it isn't formatting properly with your NextResponse.json object

opal sparrow
#

Alright, Ill try it out and get back to you in 5 minutes

#

Okay, I got the error out, its something related to sending the email

Webhook handler failed: Error: Failed to send email
at p (.next/server/app/api/stripe-webhook/route.js:16:192)

#

Ill take a look why it happens, thanks for the suggestion of logging the error ๐Ÿ˜†

oblique veldt
#

Sure thing!