#mkoenke

1 messages · Page 1 of 1 (latest)

kindred stumpBOT
formal hawk
#

Hello

tropic horizon
#

hello!

formal hawk
#

Hmm can you show me your code for your click handler?

tropic horizon
#

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

formal hawk
#

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?

tropic horizon
#

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

formal hawk
#

Ah ah I see

#

You update the amount server-side?

tropic horizon
#

no, through redux client side

formal hawk
#

Oh you are using the deferred intent flow

tropic horizon
#

but we do have the integration with a deferred payment intent

#

yes

formal hawk
#

I've actually seen something like this before

#

Are you sure you don't call elements.submit() multiple times here?

tropic horizon
#

i can double check, i dont think so but hold on

kindred stumpBOT
tropic horizon
#

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

formal hawk
#

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.

tropic horizon
#

I'll gather it for you, its pretty complicated, so this might take a minute to strip out what is relevant

formal hawk
#

Appreciate it.

tropic horizon
smoky jasper
#

Hello! I'm taking over and catching up...

#

That's a huge amount of code, can you share just the relevant parts?

tropic horizon
#

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

smoky jasper
tropic horizon
#

no, its updated from props being passed into where we render the elements instance

smoky jasper
#

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?

tropic horizon
#

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?

smoky jasper
#

But why would you want to listen for that?

tropic horizon
#

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

smoky jasper
#

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.

tropic horizon
#

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

smoky jasper
#

Yeah, elements.submit() should resolve with an error if they cancel out of the payment sheet.

tropic horizon
#

yes, it appears to be working now!

smoky jasper
#

Ah, awesome!

tropic horizon
#

thanks so much for your help! sorry for the confusion