magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.55k stars 9.32k forks source link

Cart Items are deleted after fail checkout magento2.2.1 #19838

Closed devmag1 closed 5 years ago

devmag1 commented 5 years ago

Preconditions (*)

  1. Magento v2.2.1
  2. Products should be added in the cart
  3. Payment Gateway that accepts online transaction

Steps to reproduce (*)

  1. Add products to cart
  2. Go to the checkout page
  3. Fill out all the information
  4. let's say I select PayUMoney payment gateway
  5. Next, I click PLACE ORDER button (on click of this button the order gets placed as pending in the Magento 2 backend)
  6. A popup opens asking me to enter credit card details
  7. If I close the popup the cart/checkout is empty and there are no products that I had selected

Expected result (*)

  1. On PLACE ORDER button click, the order should not get placed in the Magento Backend.
  2. On Succesful payment only, the order should get placed in the Magento backend
  3. If I cancel/fail the order, then cart items should not get cleared and I should be able to checkout again with another payment option.

Actual result (*)

  1. The order is placed on the backend as pending in Magento 2 backend irrespective of successful or failed payment.
  2. If I cancel/fail the payment, the cart items should not get cleared and I should be able to reorder again through another or same payment gateway.
magento-engcom-team commented 5 years ago

Hi @devmag1. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop). For more details, please, review the Magento Contributor Assistant documentation.

@devmag1 do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

magento-engcom-team commented 5 years ago

Hi @engcom-backlog-andrii. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

ghost commented 5 years ago

Hi @devmag1 Thanks for the report, i'm not able to reproduce following steps your described.

devmag1 commented 5 years ago

@engcom-backlog-andrii

Summary of the issue(*)

When I try to place an order with all the required information filled in and choose the mode of payment as PayUmoney payment Gateway then post click of Place order button, it redirects me to Payumoney popup. If I cancel the transaction on reaching this stage then in Magento Admin Panel it shows in ordered list with the order payment status as"pending payment"which should not be the case. Instead it should show cancelled status without affecting the inventory.

Information environment (*)

  1. magento version 2.2.1
  2. payment getway module : PayUmoney
  3. checkout module : magestore onestep checkout

Steps to reproduce (*)

  1. Add products to cart
  2. Go to the checkout page
  3. Fill out all the information
  4. let's say I select PayUMoney payment gateway
  5. Next, I click PLACE ORDER button (on click of this button the order gets placed as pending in the Magento 2 backend)
  6. A popup opens asking me to enter credit card details
  7. If I close the popup the cart/checkout is empty and there are no products that I had selected

Expected results (*)

  1. On PLACE ORDER button click, the order should not get placed in the Magento Backend.
  2. On Succesful payment only, the order should get placed in the Magento backend
  3. If I cancel/fail the order, then cart items should not get cleared and I should be able to checkout again with another payment option.

Actual results (*)

  1. The order is placed on the backend as pending in Magento 2 backend irrespective of successful or failed payment.
  2. If I cancel/fail the payment, the cart items should not get cleared and I should be able to reorder again through another or same payment gateway.
chittik27 commented 4 years ago

Please override Failure.php and change change Public Function as below in magento 2.3.5,

` public function execute() {

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $_checkoutSession = $objectManager->create('\Magento\Checkout\Model\Session');
    $_quoteFactory = $objectManager->create('\Magento\Quote\Model\QuoteFactory');

    $order = $_checkoutSession->getLastRealOrder();
    $quote = $_quoteFactory->create()->loadByIdWithoutStore($order->getQuoteId());
    if ($quote->getId()) {
        $quote->setIsActive(1)->setReservedOrderId(null)->save();
        $_checkoutSession->replaceQuote($quote);
        $resultRedirect = $this->resultRedirectFactory->create();
        $resultRedirect->setPath('checkout/cart');
        //$this->messageManager->addWarningMessage('Payment Failed.');
        return $resultRedirect;
    }
}`