#mkoenke
1 messages · Page 1 of 1 (latest)
Hello
hello!
Hmm can you show me your code for your click handler?
for which click? We do not have a click handler on the payment element to open apple pay or google pay... we are listening for when the payment element changes, and complete is true from the event in order to determine when to call elements.submit() so that we can then create a payment method.... but when the payment method is not created, because the user closes the interface instead of confirming, there is an invalid_request_error in the stripe response when we attempt to create the payment method. Is there a way to know from the payment element that the user closed the apple pay interface? We call elements.submit() to be able to show the interface, but I don't think we should be attempting to create a payment method unless the user clicks on Pay in that interface, but I don't know where to get that information from the payment element
sorry if that is confusing, and maybe its a related issue
Okay let's back up a second.
You are saying this error happens specifically when the wallet modal is opened but then closed and then you try to create a PaymentMethod via like a normal card input?
yes
so we get the invalid request error, the modal is closed, and then if we try to update the amount, we get the integration error
no, through redux client side
Oh you are using the deferred intent flow
I've actually seen something like this before
Are you sure you don't call elements.submit() multiple times here?
i can double check, i dont think so but hold on
we are only calling it once, when the user clicks on Apple Pay or Google Pay - since we are listening to the events on the payment element, and know that complete: true , thats when we call submit... im logging in the console and only see it called once
Okay can you share you relevant code here? We are likely going to need to reproduce on our end to see exatly what is going on and determine if this is a bug or not.
I'll gather it for you, its pretty complicated, so this might take a minute to strip out what is relevant
Appreciate it.
Hello! I'm taking over and catching up...
That's a huge amount of code, can you share just the relevant parts?
yeah I know, I cut out a ton of it... those are the three components we are using to render the payment element with a ton of code already taken out... I tried to distill it more with this one and filtered it down to two components
sorry, thank you so much for your help
Are you using this approach to update the amount? https://stripe.com/docs/js/elements_object/update#elements_update-options-amount
no, its updated from props being passed into where we render the elements instance
Ah, that might be the issue. If you're not updating the Elements instance correctly that can lead to this problem.
Also note that I'm not a React developer, so I don't know about the React-specific pieces of this.
Are you creating the underlying Setup or Payment Intent first and using the client secret to initialize Elements, or are you creating the Intent later? It seems like you're doing it later?
we are doing a deferred payment intent... creating it later
Is there some kind of indicator that we can watch for that would tell us the customer has closed the Apply Pay UI instead of approving the payment?
I don't think so... possibly the change event: https://stripe.com/docs/js/element/events/on_change?type=paymentElement
But why would you want to listen for that?
yeah thats what we are listening for currently, we call elements.submit() to open the modal, and then create the payment method, but we probably shouldnt be attempting to create the payment method unless the user is approving the payment, i would think.... and when they do not approve the payment, we get the invalid request error. The change event has the complete value that remains true, even if the modal is closed without the user approving the purchase
in fact, all of the values on the change event remain the same regardless of the action the user takes
Would it be possible for you to provide a video showing this happening? I'm not sure I fully understand the steps that are leading to the error.
sure, can you give me a few minutes? I think I may have figured something out - if the user closes the modal, the response from elemets.submit() has an error... and if we dont attempt to create the payment method when there is an error in that response, it seems to resolve the invalid request error as well as the integration error... and the amounts are updating in the model correctly....
im going to double check that this is the case
Yeah, elements.submit() should resolve with an error if they cancel out of the payment sheet.
yes, it appears to be working now!
Ah, awesome!
thanks so much for your help! sorry for the confusion