#castop

1 messages ยท Page 1 of 1 (latest)

inner flameBOT
spiral crown
#

๐Ÿ‘‹ Can you share more details? What have you tried so far? How are you testing this?

topaz sorrel
#

so I see that on my webhook on the stripe dashboard the payment_intent.succeeded are going through with green checkmarks, but I'm not sure if I can see if its calling my API.
so far ive got:

app.post(
  "/webhook",
  express.raw({ type: "application/json" }),
  (req, res) => {
    let event;
    const signature = req.headers["stripe-signature"];

    try {
      event = stripe.webhooks.constructEvent(
        req.body,
        signature,
        endpointSecret
      );
    } catch (err) {
      return res.json({ error: err });
    }
    console.log(event);
    switch (event.type) {
      case "payment_intent.succeeded":
        const paymentIntent = event.data.object;
        console.log(paymentIntent);```
spiral crown
#

Are you seeing the value for paymentIntent in your console log? Is the handler code above currently on a local/test server?

topaz sorrel
#

yeah but my local server is already set up with NGINX so its using the server name and im not seeing the paymentIntent or event

spiral crown
#

I'm not following. Could you share a PaymentIntent ID or an Event ID if you have it handy?

topaz sorrel
#

like from my webhook on the stripe dashboard?

#

im not entirely sure if im suppose to be able to print anything when I log event but nothing prints when I log paymentIntent

spiral crown
#

You should be able to.

#

I think you might be following this already based on your first message

#

Did you get the endpoint secret from the Dashboard or API after creating an endpoint, or did you get this from the Stripe CLI after using stripe listen ?

topaz sorrel
#

okay im logging the req.body and I see that I am receveing the payment_intent.created payload but i dont get any of the payment_intent.succeeded payload

#

any way to debug?

spiral crown
#

How are you triggering the payment_intent.succeeded event?

topaz sorrel
#

through my payment element i created on the frontend

spiral crown
#

Got it. And you see payment_intent.succeeded events in your Dashboard?

topaz sorrel
#

yeah I also see the payment_intent.created too but im not receving the succeeded on my backend API

#

I do see the payment_intent.created events

spiral crown
#

How did you get the endpoint secret you're using?

topaz sorrel
#

im using the sigining secret on the dashboard

spiral crown
#

Can you share an event ID or payment intent ID from your Dashboard?

topaz sorrel
#

wait I got it

#

i had to let event = req.body initially but idk why that prevented me from just getting success events and got the created events

#

not sure but it works now

#

thanks!

spiral crown
#

sure thing!

topaz sorrel
#

"pi_3NfUhBGrdQJDjDbi1iZ0K975" thats the ID

#

i see no event is being created

#

not sure why signature and endpoint secret look ok

spiral crown
#

I think something is happening with how you're constructing the event

#

If you're looking at the webhooks section of the Dashboard, click on one of the events and look at the response. You'll see StripeSignatureVerificationError and a message

topaz sorrel
#

what should my signature look like?

spiral crown
#

When you're constructing events, you should be using the raw request body for this. I recommend omitting the secret first to verify whether event construction is in fact the problem. Since you're following this guide, toggle the "Secure your webhook" option to see what this looks like without the secret: https://stripe.com/docs/webhooks/quickstart?lang=node

topaz sorrel
#

omg finally got it

#

i was looking online I think the app,use(express.json()) messes it up