#castop
1 messages ยท Page 1 of 1 (latest)
๐ Can you share more details? What have you tried so far? How are you testing this?
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);```
Are you seeing the value for paymentIntent in your console log? Is the handler code above currently on a local/test server?
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
I'm not following. Could you share a PaymentIntent ID or an Event ID if you have it handy?
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
You should be able to.
If you're just getting started, I recommend following this quickstart guide: https://stripe.com/docs/webhooks/quickstart?lang=node
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 ?
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?
How are you triggering the payment_intent.succeeded event?
through my payment element i created on the frontend
Got it. And you see payment_intent.succeeded events in your Dashboard?
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
How did you get the endpoint secret you're using?
im using the sigining secret on the dashboard
Can you share an event ID or payment intent ID from your Dashboard?
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!
sure thing!
wait sorry I only got the req.body ๐ฆ but when I log paymentIntent still prints nothing
"pi_3NfUhBGrdQJDjDbi1iZ0K975" thats the ID
i see no event is being created
not sure why signature and endpoint secret look ok
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
what should my signature look like?
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