#-val - Payment Requests

1 messages ยท Page 1 of 1 (latest)

trail ibex
#

That is interesting. Are you awaiting the promise returned by the .confirmCardPayment method?

warm veldt
#

Yes

#

I can post a code snippet

#
 try {
      const { paymentIntent, error: confirmError } =
 await stripe!.confirmCardPayment(...)
if(confirmError) {
//...
} else {
//...
}
}
catch (error) {
      // Error is here <---
      console.log('๐Ÿš€ ~ error', { error });
      console.log('error handlePaymentRequest', error);
    }
#

It errors on the confirmCardPayment call

#

Not sure how to handle it though

trail ibex
#

We generally only see this error when a button is clicked in rapid succession. These confirm requests show up in your Stripe developer logs so can you see them there?

warm veldt
#

I'm pending access to the developer account, so cannot check at the moment

#

This only happens, when we call our orders endpoint, and the server has something to complain

#

At this point, we display the errors to the user, i.e. item out of stock, delivery not possible etc

#

With the payment request modal being closed, the user fixes any issues, and then tries to place the order again

#

At this point is where the error happens

#

However, if the user refreshes, then the order would go through. This tells me that there's probably something wrong with our implementation, though I'm unsure how to handle this

#

If we receive errors from the server side, how do we tell stripe that the user is retrying the ordeR?

#

This is the error we receive from the confirm endpoint

You cannot provide a new payment method to a PaymentIntent when it has a status of requires_capture. You should either capture the remaining funds, or cancel this PaymentIntent and try again with a new PaymentIntent
trail ibex
#

Oh oh oh, that's different

warm veldt
#

This is the error that is shown on the request

#

however the previous error comes on the confirmCardPayment call

#

both at the same time

trail ibex
#

Okay so your integration is basically attempting to create a brand new payment method and assign it to the payment intent. In this case you just need to capture the payment. If your payment intent has a status of requires capture, you should be making a capture request.
https://stripe.com/docs/payments/capture-later

Separate authorization and capture to create a charge now, but capture funds later.

#

Are you using a manual capture methods when you create the payment intent?

warm veldt
#

I'm not sure how it's actually implemented in the server as it's handled by a different team

#

I think it is manual though

#

As the authorization happens first, and then hours later the actual capture

trail ibex
#

Okay so it sounds like your BE and FE implementation teams need to get on the same page. Are you updating the Payment Intent on the server when the OOS errors are encountered?

warm veldt
#

Yeah the payment intent is updated whenever a detail of the order changes

#

But maybe not on error

trail ibex
#

Okay so the JS error message is not super helpful but the request error is. Basically your server needs to attempt capture. You don't need to re-do the auth of the card.

warm veldt
#

Aha I think I understand. So basically if we already have a payment intent for an order, and we already attempted to confirm it we should not do so again

#

And instead just update the payment intent on the server and instruct the server to capture instead?

trail ibex
#

Yup

warm veldt
#

What if the user decides not to finish their order? i.e closes the page, etc.

#

What happens to the already created payment intent? is that something that needs to be handled separately as well?

trail ibex
#

Yes actually you can view this (on the server) by getting the List of Payment Intents filtered to status="requires_capture"

#

But if they navigate away and don't want to confirm the change, then you'd probably just want to cancel the payment intent

#

But that's up to you and how you want to design your applicaiton

warm veldt
#

Aha I see

#

Alright, I think this is a great starting point

#

Thanks a lot for your help

#

๐Ÿ‘‹