#windy_code
1 messages ¡ Page 1 of 1 (latest)
đ 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/1231765197815939092
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Yes! payment_intent.succeeded event can be used for the successful payments
what do you mean?
After the payment is made successfully via Payment Request Button, payment_intent.succeeded event will be sent to your Webhook endpoint, which your system can also use it to determine whether a payment is succeeded
This is to answer your question:
is there any webhook you provide after the payment success
Ahh gotcha
So i don't need to use ```paymentRequest.on('paymentmethod', async (ev) => {...}
this event subscription
This function is still needed. On paymentmethod event is used to confirm card details to complete the payment, i.e. submit payment method details to make a payment: https://docs.stripe.com/stripe-js/elements/payment-request-button?client=react#react-complete-payment
Without this step, payment will not be completed
oh ok. so it must be there on the ui side. but what if user immediately closes the app before subscribing that paymentmethod event?
then the payment fails?
anyways not a big deal, thanks. i think i will need to have both the event subscription and the webhook
If the confirmCardPayment() has been called, you can listen to payment_intent.* related events for the payment outcomes
paymentRequest.on('paymentmethod', async (ev) => {
// Confirm the PaymentIntent without handling potential next actions (yet).
const { paymentIntent, error: confirmError } =
await stripe.confirmCardPayment(
initialPaymentIntent?.client_secret as string,
{ payment_method: ev.paymentMethod.id },
{ handleActions: false }
);
if (confirmError) {
// Report to the browser that the payment failed, prompting it to
// re-show the payment interface, or show an error message and close
// the payment interface.
ev.complete('fail');
} else {
// Report to the browser that the confirmation was successful, prompting
// it to close the browser payment method collection interface.
ev.complete('success');
// Check if the PaymentIntent requires any actions and, if so, let Stripe.js
// handle the flow. If using an API version older than "2019-02-11"
// instead check for: `paymentIntent.status === "requires_source_action"`.
if (paymentIntent.status === 'requires_action') {
// Let Stripe.js handle the rest of the payment flow.
const { error } = await stripe.confirmCardPayment(
initialPaymentIntent?.client_secret as string
);
if (error) {
// The payment failed -- ask your customer for a new payment method.
} else {
// The payment has succeeded -- show a success message to your customer.
confirm({ membershipPlan, email });
}
} else {
// The payment has succeeded -- show a success message to your customer.
confirm({ membershipPlan, email });
}
}
});
Do you have any follow up question?
ev.complete() is needed to close Apple Pay and Google Pay interfaces
Yes, all the steps in the guide are needed