#daniel_best-practices
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/1331771840632328277
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- daniel_best-practices, 5 days ago, 8 messages
Another thing i did think of is setting a random guid in the meta data under a parameter called “version”… however would guess Stripe does something like this by default… maybe missing what parameter that is hidden somewhere?
hiya 👋 have you looked into the elements.fetchUpdates() method yet? that's the recommended method for updating elements when a PaymentIntent has been updated
https://docs.stripe.com/js/elements_object/fetch_updates
Hiya, okay just had a read of this… so if i call this method when confirming payment it can then tell me if the payment intent has been updated? And then re-direct the customer client side to the latest payment page with cart details/price
normally you would do something along these lines:
- customer clicks a button or does something in your UI that triggers an update to your payment intent on your backend
- your frontend waits for the response from the backend then calls the
fetchUpdates()method to update the payment element
so you want to do fetchUpdates before confirming the payment intent
Would this work when someone is already in the Apple Pay UI popover? Or is it too late at that stage.
Same goes for 3DSecure modal
yeah, once you're at the apple pay stage you're already confirming
can you give me an example of what updates you're doing? do you have an example you can share?
yeah, i can go into much more detail with screen grabs, i'll run through what we are currently doing step by step
so step 1 would be the customer just goes normally to our payment page which states the price in a few places together with a summary of the cart (in this case Travel Insurance)
so this is using the payment element together with the express checkout element as we wanted the proper Google Pay/Apple Pay buttons to appear
so this works great at this stage, just gets complex when the following happens...
Step 2 - the customer decides to click on Save Quote which then gives the ability to e-mail across a retrieval link which can be done on a totally different device
so in this example, the customer retrieves the quote on another device and then changes the selections in the cart and the price which would look something like
so then we have got Device A on £15.23 and Device B on £30.59 (however it's all under the same order ID)
as mentioned earlier the current work-around i'm doing is as soon as Device B loads with a updated cart/price i'm cancelling the payment intent and creating a new one
also i'm setting the cancellation reason as "abandoned" so that i can do this final check right before confirming payment
function setPaymentDetails(intent) {
if (intent.cancellation_reason === "abandoned") {
window.location.href = "../decline/payment/?cancelled";
} else {
switch (intent.status) {
case "succeeded":
window.location.href = "../decline/live/";
break;
default:
window.location.href = "../decline/payment/";
break;
}
}
}
const {
paymentIntent
} = await stripe.retrievePaymentIntent(document.querySelector('#stripe-data-values').getAttribute('data-STRIPE_PAYMENT_CLIENT_SECRET'));
setPaymentDetails(paymentIntent);
and looking for the intent.status as IF = succeeded... i can easily re-direct the customer if the order has already been completed on another device to a screen with a message to state that "it's already been setup"
👋 What you described seem possible. But are you looking for a way to update the PaymentIntent, instead of cancelling and recreating it?
👋 yeah ideally would like to ONLY update rather than cancelling/recreating as best practice is to keep just the 1 payment_intent for the Order ID
just wondering if fetchUpdates is the winner for me?
or my meta_data idea
if fetchUpdates works it sounds cleaner to me. Could you try it?