#awells-paymentrequest-followup

1 messages ยท Page 1 of 1 (latest)

kind pumice
#

Hi, can you post a summary here and perhaps an update on what you've found whilst debugging?

cobalt meteor
#

the call for stripe.confirmCardPayment is taking ~35s

#

summary:

kind pumice
#

Is this in live mode or test mode?

cobalt meteor
#

live mode

#

we're having trouble with the apple modal: because something is timing out, we see "payment not completed"

#

at which point the modal pops down, and then we proceed as normal and the payment actually goes through

kind pumice
#

hmm that's odd, do you have the PaymentIntent ID?

cobalt meteor
#

pi_3JnJeWDFZA9p024R0fk2r4KE

kind pumice
#

Thanks, looking into this

#

Are you able to open up a network tab of some sorts and see what exact request is taking so long?

#

Basically I'm trying to establish is this is a problem on Apple's end or Stripe's

#

Looking at the latency of your requests, confirming a PaymentIntent is around ~2 seconds, which is normal. So something else is going on here

cobalt meteor
#

the timing above seems to suggest it takes 35 seconds

#

but the network request only takes 2.69s

kind pumice
#

Yeah something else is causing it to hang, the actual API request to Stripe is working normally

#

Ah I think I see what's going on

cobalt meteor
#

i've posted a screenshot of the code above: can you see anything wrong?

kind pumice
#

You need to report to the browser that the confirmation succeeded with ev.complete('success');

cobalt meteor
#

how long does the web hook take?

kind pumice
#

So in your case if initialConfirmError is null you'd want to call ev.complete('success')

cobalt meteor
#

at the moment we're actually waiting for our backend to receive the webhook and update some state

#

and then calling ev.complete('success')

kind pumice
#

Waiting for a webhook is not recommended and quite brittle, webhooks do get lost and/or delayed

cobalt meteor
#

webhooks do get lost

#

? are there any guarantees around this?

#

we're using it for fulfilment

kind pumice
#

So a payment could have completed but you would have no way of informing your user. Instead you should use the result of the Stripe.js call to confirm to the customer if the payment succeeded (and call ev.complete('success')). You'd use webhooks for your business logic on the backend

kind pumice
cobalt meteor
#

sorry yes that makes sense! but i'm assuming you re-try several times?

kind pumice
# cobalt meteor we're using it for fulfilment

You should use webhooks as fulfilment and business logic, but don't use them to signal to your customer that the payment succeeded. You can safely use the response from stripe.confirmCardPayment for that.

cobalt meteor
#

gotcha, thanks!

cobalt meteor
#

is there a way to test this in the test env?

kind pumice
#

The whole Payment Request flow should be the same in test as it is in live when it comes to load times

cobalt meteor
#

so we can test apple pay ?

#

in test

#

thanks for your help ๐Ÿ™‚

kind pumice
#

You sure can, you need to have a real card set up in your Apple Wallet, but when using your test keys Stripe won't make a real payment

cobalt meteor
#

do i need to regsiter the domain on test?

#

also, we've made the changes suggested but still have the same problem

kind pumice
#

Are you using connect?

cobalt meteor
#

yep

kind pumice
cobalt meteor
#

so, register the domain on a test account, using the live key?

#

thanks

#

we implemented the changes and the timing is like so:

#

you can see 33s to call confirm card payment

#
console.log('stripe.confirmCardPayment start:', new Date())
        // Confirm the PaymentIntent with Stripe's API without handling potential next actions (yet).
        const {
          paymentIntent: confirmPaymentIntent,
          error: initialConfirmError,
        } = await stripe.confirmCardPayment(
          paymentIntent.client_secret,
          { payment_method: event.paymentMethod.id },
          { handleActions: false },
        )
        console.log('stripe.confirmCardPayment end:', new Date())
        if (initialConfirmError != null) {
          event.complete('fail')
        } else {
          // Report to the browser that the confirmation was successful, prompting
          // it to close the browser payment method collection interface.
          event.complete('success')
shadow zinc
#

hello again

#

reading up on your console logs

#

ah perfect so you've narrowed it down to confirmCardPayment() being the one taking so long

and I know the solution

#

hmm actually, you're already doing handleActions: false , IMO that should not be taking >30s so that seems pretty off

and that is the main issue here, confirmCardPayment() takes so long that by the time your code calls event.complete('success'), the Apple Pay sheet has decided to time out and show that error

now I wanna dig into why that confirm took so long
lets start here, can you share the PaymentIntent ID for a repro, the PI ID that you confirmed

cobalt meteor
#

pi_3JnJeWDFZA9p024R0fk2r4KE

cobalt meteor
#

@shadow zinc is there anything else you need ๐Ÿ™‚ ?

shadow zinc
#

just started looking (might be a bit, Discord is busy and also pulled into things internally)

#

ok so seeing that request completed in roughly 2.45 seconds on Stripe's side. so yeah a bit confused on how the Promise resolved on your webpage in >20s

cobalt meteor
#

from the above code, does anything stand out?

#

it's worth noting it only does this for Apple pay, not google pay

shadow zinc
#

nope code is fine and the request was under 3 s so I'm thinking about why the promise resolved much later for you
is anything else going on in that page?
The code you shared reads fine top down but not sure if something else is throwing that off

cobalt meteor
#

nothing much else

shadow zinc
#

lemme bounce ideas with a colleague in case I missed something simple

#

can you do another repro, share the browser logs again and the PaymentIntent ID as well
The one you shared earlier was helpful but the timestamps logged out were different from the PaymentIntent you repro'ed so wanna rule that out and narrow down

cobalt meteor
#

sure

shadow zinc
#

I just tried to repo and on my end, confirmCardPayment() with Apple Pay resolves in 1 or 2 seconds across my two repros

can you share the logs in text? easier to copy/paste

and also the PaymentIntent ID, thanks!

cobalt meteor
#
[Log] request with Monzo API to create payment intent end โ€“ Fri Oct 22 2021 18:09:19 GMT+0100 (BST)  (97cfe03671c4392eaedf70876fc3fd51047801ec.abda44760b3ce06a3097.js, line 1)
[Log] stripe.confirmCardPayment start: โ€“ Fri Oct 22 2021 18:09:19 GMT+0100 (BST)  (97cfe03671c4392eaedf70876fc3fd51047801ec.abda44760b3ce06a3097.js, line 1)
[Log] stripe.confirmCardPayment end: โ€“ Fri Oct 22 2021 18:09:55 GMT+0100 (BST)  (97cfe03671c4392eaedf70876fc3fd51047801ec.abda44760b3ce06a3097.js, line 1)
[Log] polling Monzo API for state change start โ€“ Fri Oct 22 2021 18:09:55 GMT+0100 (BST)  (97cfe03671c4392eaedf70876fc3fd51047801ec.abda44760b3ce06a3097.js, line 1)
[Log] polling Monzo API for state change end โ€“ Fri Oct 22 2021 18:09:58 GMT+0100 (BST)  (97cfe03671c4392eaedf70876fc3fd51047801ec.abda44760b3ce06a3097.js, line 1)
#

payment intent ID is pi_3JnRF5DFZA9p024R1Z11CK5Z

shadow zinc
#

thanks
and one more thing, can you tell me what your browser's Network tab as, for the Stripe API request to /v1/payment_intents/:id/confirm?

when does that network request start/complete

cobalt meteor
#

in the screenshot above, it was api.stripe.com

#

took 2.78s

#

but that's the network request coming from when we call stripe.confirmCardPayment

#

the unexplained bit is why when we called stripe.confirmCardPayment, the requset isn't made for ~30s after we call it

shadow zinc
cobalt meteor
#

does that make sense?^

#

or do you need start/end time of the network request?

shadow zinc
#

no that works

#

I had missed the network tab you shared

#

thanks for sharing that proactively!!

#

digging in

cobalt meteor
#

gotta jump off, but if we can keep this thread open so we don't lose progress that'd be great!

#

thanks for your help!

crystal tundra
#

@cobalt meteor wait for a sec

cobalt meteor
#

๐Ÿ‘

crystal tundra
#

We can't really keep the thread open for a long time. I think you'll want to chat directly with our support team if you have to run. Especially on a Friday (we're not on Discord on week ends)

cobalt meteor
#

i'll hang around on here then ๐Ÿ‘

#

if you're still looking into it ๐Ÿ™‚

crystal tundra
#

but you just said you had to jump off ๐Ÿ˜…

shadow zinc
#

@cobalt meteor ok another thing

1/ I'm trying to narrow things down a bit, can you share the timestamps+browser logs for when your paymentmethod event is called (from PRButton)

2/ pls also add timestamps for when you're about to call ev.complete() in either success/fail state

3/ can you share the full function you've implemented in the paymentmethod event from PRButton

cobalt meteor
#

@shadow zinc please see above for the timestamps and logs ๐Ÿ™

crystal tundra
#

@cobalt meteor you didn't share the timestamps we asked for right?

#

hmunoz asked for extra information

#

But I really think you'll need to talk to our support team instead, we didn't hear back from you since then and we haven't found anything conclusive

cobalt meteor
shadow zinc
#

@cobalt meteor thanks that is helpful
can you please also get me logs + timestamps in that function for

1/ when paymentmethod event is triggered
2/ when you're about to call doMutation` to create the PaymentIntent
3/ when 2/ above resolves
4/ before the first and second confirmCardPayment()
5/ after the first and second confirmCardPayment()
6/ also log out the PaymentIntent ID or client_secret in code

I'm basically looking for a clear picture into what line of code is hit at what time , so the more logs the better

and your updated code with those logs would be helpful too to really get a great picture

a/ can you try this all in test mode using testmode publishable and testmode secret keys? want to see if test mode is different from live mode here

b/ retry in live mode with all the extra logs from 1/ -> 5/

and please share PaymentIntent IDs for both repro's in live and test mode
and please write in with all that info to Support at https://support.stripe.com/contact and let them know you spoke to Heath in Discord and I recommended you write in with those details

cobalt meteor
#

can you try this all in test mode using testmode publishable and testmode secret keys?
-> is this possible in test mode for a Stripe Connect integration? do i need to register the domain with the test connected account using testmode secret key, or live key?

shadow zinc
#

yes it is
the account has to be live mode and the domain registered in live mode

but after that, you can use test mode API keys to create test mode PaymentIntents and test mode Apple Pay card PaymentMethods

cobalt meteor
#

against a live connected account?

shadow zinc
#

so to explain

#

do i need to register the domain with the test connected account using testmode secret key, or live key?
domain stays registered in live mode on a live mode Connect account

cobalt meteor
#

so

  1. register domain on live connected account
  2. create an intent on the connected account as usual, but instead use the test key
shadow zinc
#

so question

#

were you already testing on Connect? or no

#

I don't recall

cobalt meteor
#

yes

shadow zinc
#

yeah so that means you already have the right domain registration etc

cobalt meteor
#

we've got a standard connect integration

#

but i was doing it on real payments

shadow zinc
#

so all you need to do is use test mode API keys to create PaymentIntents and also test mode keys in your React code

#

everything else just works

cobalt meteor
#

great, thanks

#

i'll try that

#

what's the reason for testing in test, shouldn't live mode be the same?

crystal tundra
#

@cobalt meteor unfortunately we won't be able to dig deeper at this point as we're all out for the day ๐Ÿ˜ฆ