#Mike Taylor - Stripe.js error
1 messages ยท Page 1 of 1 (latest)
Hi ๐
Why are you confirming a card setup with an existing payment method ID?
We are doing this to get a setupintent so to process a card update.
What is being updated about the card?
Setup Intent's are intended to create a new card, as is the .confirmCardSetup function. Although if the existing paymentMethod.id is what is causing the error then the error message could be more helpful. I will raise that issue.
We are trying to do a customer update and getting the feeling that we are doing unnecessary calls.
We are trying to do a customer update
What is getting updated about the customer?
address details, needing to update zipcode for tax computation.
Seems to me you'd just need to do a Payment Method Update API call:
https://stripe.com/docs/api/payment_methods/update
HI there ๐ jumping in as my teammate needs to step away soon. I've read through the thread and just want to ensure I'm properly understanding what you're trying to accomplish.
Are you just trying to update the address of a Customer? Or are you trying to update a customer's address after you process a Setup Intent to add a new Payment Method for them?
(If it sounds like I'm completely missing what your goal is, would you mind restating it?)
We have been reviewing the code. The confirmCardSetup was from a way back, and we were/are using it to check for card errors. It looks like we can now? get that direct from the update and create payment methods (instead). So we will explore that. Mostly we are trying to figure out why react elements/stripe is resetting itself (we are using Quotes to compute the tax to the user on a changing zipCode - per earlier chat), so removing unecessary code in that process.
Oohh, so it sounds like you were updating the payment method details and then running it through a setup intent to trigger validation checks of the new information?
Yes. We are seeing that using confirmCardSetup allows us to present the user with a declined response in a React(ive) context. We have honed in on the challenge over the last half hour ...
... if we make any kind of state update (in this case to set a isProcessing flag), we trigger this stripe error IntegrationError: We could not retrieve data from the specified Element. presumably as the element is getting unmounted on the state update.
Is there a way to not trigger that unmount.
I'm still a bit new to React, so apologies if my terminology is a bit off, is the state change causing you to rerun the section of your code that handles the initialization of Elements?
Do you have a snippet of the code that is triggered on state change?
createPaymentMethod code
Hm, based on the behavior you're describing, I was expecting to see the Stripe and Elements initialization in the code that was being triggered on state change. However, unless I'm overlooking it, I'm not seeing that in what you provided.
The approach that comes to mind to try and get more context is for you to add more console logs throughout your code, to make it easier to see exactly what pieces are executing when.
we use const stripe = useStripe(); const elements = useElements(); below is the whole component code. We don't see the component update, we only see the stripe element update.
Hi @formal wolf ๐ I'm taking over for Toby. Give me a few minutes to get up to speed here.
It's really hard to troubleshoot more than 100 lines of code in real-time to see where the state change is occurring. I would recommend following the flow of logic from beginning to end and adding console.log(); at every step to see where things are getting out of sync.
The only other thing I can mention here is to try putting the useStripe() and useElements() calls at the very top of the component definition as shown here:
https://github.com/stripe/react-stripe-js#using-hooks