#Giuseppe87-webhook
1 messages · Page 1 of 1 (latest)
Hi there! Are you using Stripe Checkout to create the payment? Or you create a PaymentIntent directly?
No, in the js front end we create the session:
const session = await stripe.checkout.sessions.create({
line_items: items,
mode: 'payment',
metadata: { order_id: fetchedOrder.id },
billing_address_collection: 'required',
success_url: `${NEXT_PUBLIC_NEXT_BASE_URL}/order/success`,
cancel_url: `${NEXT_PUBLIC_NEXT_BASE_URL}/order/error`,
});
then we redirect to stripe checkout
if (session && session.url)
res.status(200).json({ data: session.url, errorMessage: undefined });```
now I need to listen to the webhook in the (drupal) backend to update and complete the order.
So you are using Checkout Session. In this case we recommend listening to the checkout.session.completed event https://stripe.com/docs/payments/checkout/fulfill-orders#fulfill