#Yharoo

1 messages · Page 1 of 1 (latest)

frank viperBOT
tiny cove
#

Hi there!

remote socket
#

Hey!

tiny cove
#

I'm not sure I follow your question.

remote socket
#
            case 'payment_intent.created':
                const paymentIntentCreated = event.data.object;
                console.log(
                    `PaymentIntent for ${paymentIntentCreated} was successful!`
                );
                // Then define and call a method to handle the successful payment intent.
                // handlePaymentIntentSucceeded(paymentIntent);
                break;
            case 'charge.succeeded':
                const charge = event.data.object;
                let { userId, userCart, total, guest } = charge.metadata;
                if (!guest) {
                    if (typeof total !== 'number') {
                        total = JSON.parse(total);
                    }
                    if (typeof userCart === 'string') {
                        userCart = JSON.parse(userCart);
                    }

                    console.log(`Charge for ${charge} was successful!`);

                    placeOrder(userId, userCart, total);
                }
                break;
        }
        res.status(200).end();```
#

I want to catch the response in the frontend

#

but i only made a fetch request for the payment intent

tiny cove
#

That doesn't really make sense. Webhook events are asynchronous, so you can't really send the response of a webhook event to your frontend. What is your end goal exactly?

remote socket
#

Ohhhh....

#

Because I change something in my database using webhook, and I want to do something in the frontend after that happens

tiny cove
#

Can you give more details on what exactly you want to do? There might be some other options.

remote socket
#

hmmm

#

I think my issue is something to with frontend routing

#

Maybe not with stripe