Cardlink-SA / cardlink-payment-gateway-magento2x

0 stars 0 forks source link

Bug: Critical Stock Management Issue #7

Open thdgeorge opened 3 weeks ago

thdgeorge commented 3 weeks ago

Description: We encountered a major issue in the Cardlink Magento 2 module regarding inventory management when a product is purchased with limited stock. If a customer selects Cardlink as the payment method, an order is not created until payment confirmation is received. This leads to a race condition where other customers can purchase the last item, resulting in stock inconsistencies and ultimately preventing the order from being created in Magento after payment has been completed.

Steps to Reproduce:

  1. Set up a product with a stock quantity of 1 in Magento.
  2. Have Customer A add the product to their cart and proceed to checkout.
  3. Customer A selects Cardlink as the payment method and does not complete the payment process (without creating an order yet in Magento).
  4. Before the payment confirmation returns from Cardlink, Customer B quickly buys the same product.
  5. When Customer A's payment confirmation returns, Magento attempts to create the order but fails due to stock unavailability.

Actual Behavior: Magento throws an exception when attempting to create the order post-payment due to the lack of available stock, despite the payment having already been completed. This results in a major issue as the customer has already paid, but the order cannot be fulfilled. Here’s the exception message:

1 exception(s):
Exception #0 (Magento\Framework\Validator\Exception): Κάποια από τα προϊόντα έχουν εξαντληθεί.

Impact: This is a critical bug since it leads to paid orders that cannot be processed and requires immediate attention to ensure payment and stock handling are synchronized.

thdgeorge commented 2 weeks ago

Any Update here ?