#futurefuture
1 messages · Page 1 of 1 (latest)
thanks, was trying to get back into the old thread but its closed
the method @clear cave gave me, fetchUpdates...it makes sense, but how to I access this when using the react elements from the hook: <Elements options={options} stripe={stripePromise}>
<CheckoutForm
cart={cart}
tip={tip}
orderDateTimes={orderDateTimes}
/>
</Elements>
Hi there! 👋 welcome back. You would need to call fetchUpdates() at some point after the update has occurred. So wherever you update the Payment Intent, you should immediately call fetchUpdates() once you get a response back from the Payment Intent update API call
thanks, but the const elements = useElements()
on that ^ variable, there is no method for fetchUpdates()
Ahhhh, okay. What version of the SDK are you on?
the v3 2016 api
Checking on this
thank you
What are you trying to update, exactly?
Are you sure you mean the elements vs the individual payment element?
https://stripe.com/docs/js/elements_object/fetch_updates This should be usable on the elements instance
Can you share the snippet of your code showing what you're doing?
yep so im using this:
<CheckoutForm
cart={cart}
tip={tip}
orderDateTimes={orderDateTimes}
/>
</Elements>
Ok, and then where you get the elements instance?
const elements = useElements();
im not manually mounting the elements instance, im using a react hook
this elements const is used in the following manner:
// update cart with order date times, tip
e.preventDefault();
if (!stripe || !elements || !user || !user.cart) {
// Stripe.js has not yet loaded.
// Make sure to disable form submission until Stripe.js has loaded.
return;
}
const userUuid = user.uuid;
const { uuid } = user.cart;
updateCartMutation(
{
uuid,
user_uuid: userUuid,
// tip: Math.round(tip),
order_date_times: orderDateTimes,
},
{
onSuccess: async () => {
const { error } = await stripe.confirmPayment({
elements,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: `http://www.runner.test/confirmation-new/${cart.payment_intent_id}`,
},
});
// This point will only be reached if there is an immediate error when
// confirming the payment. Otherwise, your customer will be redirected to
// your `return_url`. For some payment methods like iDEAL, your customer will
// be redirected to an intermediate site first to authorize the payment, then
// redirected to the `return_url`.
if (
error.type === 'card_error' ||
error.type === 'validation_error'
) {
setMessage(error.message);
} else {
setMessage('An unexpected error occurred.');
}
setIsLoading(false);
},
onError: (error) => {
console.log(error);
},
},
);
setIsLoading(true);
}```
and then the Elements component is being pulled from this:
import { Elements } from '@stripe/react-stripe-js';