#windy_code

1 messages ¡ Page 1 of 1 (latest)

lyric cradleBOT
#

👋 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.

dusky ore
#

Yes! payment_intent.succeeded event can be used for the successful payments

chilly karma
#

what do you mean?

dusky ore
#

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

chilly karma
#

Ahh gotcha

#

So i don't need to use ```paymentRequest.on('paymentmethod', async (ev) => {...}

#

this event subscription

dusky ore
#

Without this step, payment will not be completed

chilly karma
#

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

dusky ore
#

If the confirmCardPayment() has been called, you can listen to payment_intent.* related events for the payment outcomes

chilly karma
#
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 });
          }
        }
      });
dusky ore
#

Do you have any follow up question?

chilly karma
#

so from the above code, we don't need to send ev.complete('success');

#

??

dusky ore
#

ev.complete() is needed to close Apple Pay and Google Pay interfaces

chilly karma
#

ok so we need everything

#

thanks

dusky ore
#

Yes, all the steps in the guide are needed

chilly karma
#

ok so i don't need the webhook separately

#

thanks. you can close the ticket