202ecommerce / paypal

This repository is for developpers only. To install and upgrade the module in a production shop please install the package via PrestaShop Marketplace by following this link:
https://addons.prestashop.com/fr/paiement-carte-wallet/1748-paypal-officiel.html
Academic Free License v3.0
20 stars 31 forks source link

Fix: The quantities in stock are not verified in case of payment with PayPal #365

Open Codencode opened 1 month ago

Codencode commented 1 month ago
Questions Answers
Description? As the remaining quantity in stock is not checked when paying with PayPal or other forms that require a gateway payment, it is possible to complete the order and pay for an out-of-stock product even if this is not permitted.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #325
How to test? 1 - Create a cart with an available item. 2 - Proceed to checkout until the payment selection. 3 - Before confirming the order, modify the product quantity in the admin, making it unavailable. 4 - Confirm the order with PayPal. 5 - The system should refresh the page and redirect to the cart.
clotairer commented 1 month ago

Thank you @Codencode for your PR. We will read it and try to merge it ASAP.

Codencode commented 1 month ago

Hi @clotairer, my solution checks if the cart/product is actually available just before creating the order, and it does this in the createOrderfunction. If the cart/item is not available, the order ID is obviously not returned, and this generates an error/exception that is handled by the onErrorfunction, where I refresh the page. This way, the system redirects to the cart, showing that the product is no longer available. Perhaps it could be managed differently, but this is the solution I came up with.

Thanks.

clotairer commented 1 month ago

Hi, It looks like we already fix your issue here https://github.com/202ecommerce/paypal/pull/350

Could you confirm to us your module is up to date ?

Codencode commented 1 month ago

Hi, It looks like we already fix your issue here #350

Could you confirm to us your module is up to date ?

Yes, the module is updated to the latest version 6.4.2.

I think fix #350 solves a different case. The problem I encountered occurs when you are on a product page or in the cart and in the meantime the product has become unavailable. My change, before starting the order creation process on PayPal, performs the availability check and if unavailable blocks the order.