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.54k stars 9.32k forks source link

Voiding a payment moves the order into processing status #36565

Closed asim-blueprintprep closed 1 year ago

asim-blueprintprep commented 1 year ago

Preconditions and environment

If an order in pending is voided, it forces a status move to processing - voiding should leave the order in it's current state. For stripe, processing is after payment is taken, which means some customers are gaining access to things that they haven't paid for.

Steps to reproduce

  1. Place an order that hasn't taken payment yet(stripe declined card )
  2. in admin open the order
  3. the order is in pending
  4. void the order
  5. the order is now in processing

Expected result

The order is left in it's state/status

Actual result

The order is moved to processing

Additional information

Screenshot 2022-12-05 at 16 25 20 Screenshot 2022-12-05 at 16 25 47

The hard coded move to processing comes from:

vendor/magento/module-sales/Model/Order/Payment.php

protected function _void($isOnline, $amount = null, $gatewayCallback = 'void')

$this->setOrderStateProcessing($message);

/**
     * Sets order state to 'processing' with appropriate message
     *
     * @param \Magento\Framework\Phrase|string $message
     */
    protected function setOrderStateProcessing($message)
    {
        $this->getOrder()->setState(Order::STATE_PROCESSING)
            ->setStatus($this->getOrder()->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING))
            ->addStatusHistoryComment($message);
    }

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @asim-blueprintprep. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

asim-blueprintprep commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @asim-blueprintprep. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @asim-blueprintprep, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

asim-blueprintprep commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @asim-blueprintprep. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @asim-blueprintprep, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

m2-assistant[bot] commented 1 year ago

Hi @engcom-November. 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:

asim-blueprintprep commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @asim-blueprintprep. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @asim-blueprintprep, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

engcom-November commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-November. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-November, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

engcom-November commented 1 year ago

Hi @asim-blueprintprep , Thank you for reporting and collaboration. Verified the issue on Magento 2.4-develop instance but cannot able to reproduce the issue with provided steps. We do not have "Void" option for payments made using check / money order. Hence cancelled the order from magento admin for a Pending Order and the status is updated as "Cancelled". Please refer the screenshot below. image image Kindly recheck the issue on Magento 2.4-develop instance and elaborate steps to reproduce if you are still facing any issues. Thank you.

asim-blueprintprep commented 1 year ago

Hi, The issue is NOT with cancelling. The issue is with voiding. I am aware cancelling changes the state correctly. Please remove the screenshots from an unrelated test.

EDIT: it also is irrelevant of payment method, as the void function is core magento code - which hard codes the state to processing.

asim-blueprintprep commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @asim-blueprintprep. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @asim-blueprintprep, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

asim-blueprintprep commented 1 year ago

How can I test if this won't create one?

@engcom-November voiding is for online transactions - how can I enable one in a magento 2.4 develop instance, without providing you our test credentials tied to our stripe account etc?

asim-blueprintprep commented 1 year ago

@engcom-November A work around for a local environment, so you can see the core magento bug: edit: vendor/magento/module-payment/Model/Method/AbstractMethod.php and comment out:

/*if (!$this->canVoid()) {
            throw new \Magento\Framework\Exception\LocalizedException(__('The void action is not available.'));
        }*/

and

vendor/magento/module-sales/Block/Adminhtml/Order/View.php and comment out:

//if ($this->_isAllowedAction('Magento_Sales::invoice') && $order->canVoidPayment()) {
            $message = __('Are you sure you want to void the payment?');
            $this->addButton(
                'void_payment',
                [
                    'label' => __('Void'),
                    'onclick' => "confirmSetLocation('{$message}', '{$this->getVoidPaymentUrl()}')"
                ]
            );
        //}

This will allow you to simulate online payment - and the void button will appear.

I have done this with bank transfer and money order:

Screenshot 2022-12-06 at 14 28 19 Screenshot 2022-12-06 at 14 28 23

As noted previously, there is a function which hard codes it to move the order to processing

/**
     * Sets order state to 'processing' with appropriate message
     *
     * @param \Magento\Framework\Phrase|string $message
     */
    protected function setOrderStateProcessing($message)
    {
        $this->getOrder()->setState(Order::STATE_PROCESSING)
            ->setStatus($this->getOrder()->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING))
            ->addStatusHistoryComment($message);
    }
engcom-November commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-November. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-November, here is your Magento Instance: https://35080aa70b4c318fa0a6077e54e40361.instances.magento-community.engineering Admin access: https://35080aa70b4c318fa0a6077e54e40361.instances.magento-community.engineering/admin_c0cd Login: aca0a8e2 Password: 649768e37969

engcom-November commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-November. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-November, here is your Magento Instance: https://35080aa70b4c318fa0a6077e54e40361.instances.magento-community.engineering Admin access: https://35080aa70b4c318fa0a6077e54e40361.instances.magento-community.engineering/admin_c8c5 Login: edf4351d Password: 3ab1ca5aac54

engcom-November commented 1 year ago

Hi @asim-blueprintprep , Verified the issue again on Magento 2.4-develop instance and is working fine if a processing order is voided. As per Magento officials docs , we can VOID an order only if the order status is "Processing" and not captured. As per Magento docs, Only sales orders that are not invoiced, have a status of Processing, and a payment setting of authorize, can be voided. Scenarios tested: Scenario 1: Made payment using Payflow PRO. Order status is Processing. Void button displayed - Voided the payment - Order status is Processing. Scenario 2: Created invoice for a Processing Order with "not capture option" - VOID button is displayed. Voided the payment. Order status is processing. image

image Can you please provide supporting documents / proofs showing Pending orders can be voided. Kindly recheck the behavior on Magento 2.4-develop instance and provide steps for valid use case scenario. Thank you.

asim-blueprintprep commented 1 year ago

@engcom-November

Yes, stripe creates orders in pending regardless if if theyve been paid or not. As per a copy of my email chain with stripe:

Hi Alex,

We have received feedback from customers who prefer the old checkout flow from versions 2.x of the module. In versions 2.x, orders were not placed in Pending status when a payment failed. In versions 3.x we made this change due to limitations we had at the time with the new PaymentElement

See below screenshots: Screenshot 2022-12-08 at 13 04 14 Screenshot 2022-12-08 at 13 04 18 Screenshot 2022-12-08 at 13 04 21

As you can clearly see in the above, an order is created in pending, and void button is visible. I believe it is not an admin clicking it, but a webhook that comes back to void it.

This then moves the order into processing.

This is an issue either with the logic of if voiding is allowed, or with voiding moving it into processing.

Thanks,

asim-blueprintprep commented 1 year ago

As a follow up, here is official stripe documentation: https://stripe.com/docs/plugins/adobe-commerce/troubleshooting?locale=en-GB#order-stuck-in-pending-status

Order stuck in pending status When creating an order, the initial status is Pending, which indicates that the authorization of the payment by the customer’s bank is still pending.

Again, I CANNOT show you on a develop-instance as I cannot give you our stripe credentials.

The screenshots and documentation clearly demonstrate an ability to void a pending order.

asim-blueprintprep commented 1 year ago

Extra follow up screenshots: Screenshot 2022-12-08 at 13 14 31 Screenshot 2022-12-08 at 13 14 36

engcom-November commented 1 year ago

Hi @asim-blueprintprep , Thank you for the response. Stripe payment is a 3rd party package / extension and code of this extension is not part of https://github.com/magento/magento2 git repository. This issue is not reproducible with Magento built in default payment methods. Void button will not be displayed for Pending Orders. Community cannot able to provide fix for it in this repository. All questions, issue reports and fix for them should be addressed to the corresponding extension owners(support) on the Magento Market place page Thank you.

engcom-November commented 1 year ago

Hi @asim-blueprintprep , We are closing this issue as there has been no latest update on the same. Kindly reopen / create new issue if you are still facing any issues. Thank you.