#adamgp

1 messages · Page 1 of 1 (latest)

nova gorgeBOT
signal flare
#

Hi! hmm. If you're explicitly using the PaymentRequestButton, you don't need a PaymentIntent or a client secret at any point until the final .on("paymentmethod") event that happens when the user finishes their actions in the wallet window , so I don't 100% follow.

slate oxide
#

Hi Karl, I see what you're saying, and now - trying to identify why we're doing what we're doing...

signal flare
#

normally the way you'd integrate with the PaymentRequestButton is when you get that final event, you can confirm a PaymentIntent. That can mean either you have a client secret already available, ideally from first render(the traditional way to use PaymentIntents is you create one when the page is loaded, and the guide at https://stripe.com/docs/stripe-js/elements/payment-request-button?client=html#html-js-complete-payment sort of implicitly assume that), or you could ajax your backend at that point and get one and then call confirmCardPayment with it, that works fine too.

slate oxide
#

Ok, sorry just give me a few minutes to digest what you're saying

#

Hi again, ok so reading the link above, step 4 a Payment Intent is created (at which point this is created is not specified, but crucially) before the .on("paymentmethod") section is reached (step 5)

#

To prevent creating hundreds of thousands of unused Payment Intents when the cart page is viewed with the Digital Wallet payment button in the small chance that a visitor proceed to pay (by digital wallet) we create the payment intent when it is clicked

signal flare
slate oxide
#

Is it not possible for me to call our backend upon paymentrequest button being clicked. But allow me to control when the UI of the digital wallet appears with paymentrequest.show()

#

As we're experiencing a race conditiona I believe between the PI being created (only when needed) and shippingaddress events being fired

signal flare
#

yeah I didn't really understand that, since the shippingaddresschange doesn't really have anything to do with or require a PaymentIntent.

#

Is it not possible for me to call our backend upon paymentrequest button being clicked.
to be clear that is not what I'm suggesting.

slate oxide
#

I think you're right, im using the payment intent client_secret to obtain the relevant link to our shopping basket in the backend for recalculating address costs - I think talking it out has releaved that actually, I can use a better reference for calculating shipping rates - against the correct shopping cart/basket.

signal flare
#

yeah I assumed it was that, that your backend requires the PaymentIntent/order on its side to exist when you send whatever request you send from the shippingaddresschange handler to calculate rates for the updateWith function.

#

in which case I suppose you just have to try to rearchitect this so either the backend can do that without that context/backend order, or so that you create the PaymentIntent earlier in the flow(which yes might lead to dummy extra PaymentIntents like you say but that's unfortunately just how a lot of Stripe integrations work and it's not a massive problem)

slate oxide
#

Ok - I will do just that, but continue to avoid creating unnecesary payment intents. Thanks for invaluable and prompt help, as per usual!