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

Updates StripeCustomer.php to avoid broken SQL on guest checkout. #49

Closed jruillier closed 2 years ago

mribeiro202 commented 3 years ago

Hi jruillier, Can you give us more information?

  1. What is your PrestaShop environment?
  2. Do you have a custom PrestaShop?
  3. How can you reproduce your bug?
jruillier commented 3 years ago

Hi @mribeiro202,

  1. We're using Prestashop 1.7.6.8.
  2. We use some modules for Prestashop, but core PrestaShop files haven't been modified.
  3. To reproduce, just make a guest checkout and check the logs in admin panel.
mribeiro202 commented 3 years ago

Hello @jruillier Can you provide us with a concrete case, as we have no errors in the log. The guest has an ID that can be transformed into a customer ID, we can't reproduce the problem.

BSCrea commented 3 years ago

Hi,

I think that he was right : in classes/actions/ValidationOrderActions.php, in saveCard() (line 505), there's a verification on $stripeCustomer->id == null. The line above this check is : $stripeCustomer = $stripeCustomer->getCustomerById($this->context->customer->id, $stripeAccount->id);

So yes, $this->context->customer->id might be empty somehow.

In logs, i've got an error with this :

Exception on hook paymentOptions for module . You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \') AND (id_account = \"xxxxxxxxx\") LIMIT 1\' at line 3 SELECT * FROM `meoshop_stripe_customer` WHERE (id_customer = ) AND (id_account = \"xxxxxxxxxx\") LIMIT 1

clotairer commented 2 years ago

Seems linked to #95 fixed according to @mribeiro202 but PR still opened and code not in develop branch...

@Afayadas look after this together to prevent regression on next release.

clotairer commented 2 years ago

The pre release is ready here with refactored version of your PR. You can test it if you want. Thank you.