#futurefuture

1 messages · Page 1 of 1 (latest)

dull matrixBOT
supple halo
#

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>

clear cave
#

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

supple halo
#

thanks, but the const elements = useElements()

#

on that ^ variable, there is no method for fetchUpdates()

clear cave
#

Ahhhh, okay. What version of the SDK are you on?

supple halo
#

the v3 2016 api

long bough
#

Checking on this

supple halo
#

thank you

long bough
#

What are you trying to update, exactly?

#

Are you sure you mean the elements vs the individual payment element?

#

Can you share the snippet of your code showing what you're doing?

supple halo
#

yep so im using this:

#
            <CheckoutForm
              cart={cart}
              tip={tip}
              orderDateTimes={orderDateTimes}
            />
          </Elements>
long bough
#

Ok, and then where you get the elements instance?

supple halo
#

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';

long bough
#

And, aside from the updates, this works as you expect?

#

What happens when you try to use elements.fetchUpdates()? Where does that fit in here?