202-ecommerce / stripe_official

After years of hard work with Stripe connector for PrestaShop, 202 ecommerce stop the development of Stripe module on January 9th 2023. Thanks for all contributors that help us!
20 stars 20 forks source link

Loading module slow #145

Closed gmauro99 closed 2 years ago

gmauro99 commented 2 years ago

Hello,

The loading of module in ajax checkout slows the page of several seconds. I've found that the problem in function of class \Stripe\Account::retrieve(). Commenting, infact, from hookPaymentOptions the checkApiConnection (that uses retrieve) and also the var stripeAccount the loading of scripts are much faster (about 20ms against 1200ms).

I would to know if it depends from stripe's server latency or not and if its possible to increases the speed.

Thank you

clotairer commented 2 years ago

This method call Stripe API to retrieve users that have saved Credit Card.

If there is a network slow call you can verify by call this command line :

curl  -o /dev/null -s -w 'Total: %{time_total}s\n'  https://api.stripe.com/v1/customers \
  -u sk_test_VePHdqKTYQjKNInc7u56JBrQ: \
  -X "POST"

In my computer "Total: 0.412044s"... that quite long but lower than 1200ms.

No downtime on Stripe https://status.stripe.com/

testing-nerd commented 2 years ago

Having the same issue, the stripe module slows down the cart summary page too much. I'm using PS 1.6.

clotairer commented 2 years ago

Hi @testing3-apps

Do you have enabled options "Saving cards" on your PrestaShop backoffice ? If yes, could you try to disable it and compare the load time of the page ?

I try to understand if the issue come from the module or Stripe call. If you have Saving card enabled, the module call Stripe to get information about customer and it could explain that something is wrong with Stripe call.

testing-nerd commented 2 years ago

Yes, I have this option enabled, I'll disable it and provide the result soon.

testing-nerd commented 2 years ago

I tested it, and the results are the same, enabling or disabling the option does not affect the loading time. Enabled

clotairer commented 2 years ago

It looks like there is no condition (never added) on hookPayment about "save card" feature on Prestashop 1.6 hookPayment ...

Could you please try to return $display just before this line and check the time (and if all right) ? https://github.com/202-ecommerce/stripe_official/blob/5631793cf2e3645440ccd2494a0ca431f0615225/stripe_official.php#L1814

Please note, for PrestaShop 1.7, we have this condition : https://github.com/202-ecommerce/stripe_official/blob/5631793cf2e3645440ccd2494a0ca431f0615225/stripe_official.php#L1902

testing-nerd commented 2 years ago

Yes, it reduced the loading time! Screenshot 2022-05-11 131132

clotairer commented 2 years ago

It looks like each call on Stripe "cost" between 400ms and 600ms (perhaps 750ms on your server). I've sent a message to Stripe to know if there have register some trouble with some networks.

We will fix the condition (like in PS 1.7) in the next release.

gmauro99 commented 2 years ago

It looks like each call on Stripe "cost" between 400ms and 600ms (perhaps 750ms on your server). I've sent a message to Stripe to know if there have register some trouble with some networks.

We will fix the condition (like in PS 1.7) in the next release.

These response times have been high for over a year, I believe that is their average response times. Obviously the difference between 400 and 750 I think depends on the time of the request and the distance between the servers.

clotairer commented 2 years ago

OK thank you @gmauro99

So in a first time, we will add the condition for PS 1.6 to load unnecessary requests in case of save cards feature disabled. But, if the time average is around 500ms, the module couldn't have an impact on Stripe less than 500ms.