Skip to content

Commit bf93708

Browse files
Chhandak.BaruaChhandak.Barua
authored andcommitted
ACP2E-3233: Admin can still place order even without payment method
1 parent e0b7464 commit bf93708

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Payment\Plugin;
7+
8+
use Magento\Framework\App\RequestInterface;
9+
use Magento\Sales\Model\AdminOrder\Create;
10+
11+
/**
12+
* Class PaymentConfigurationProcess
13+
*
14+
* Removes inactive payment methods and group from checkout configuration.
15+
*/
16+
class AdminSetPaymentMethod
17+
{
18+
/**
19+
* @param RequestInterface $request
20+
*/
21+
public function __construct(
22+
private readonly RequestInterface $request
23+
) {
24+
}
25+
26+
/**
27+
* Checkout LayoutProcessor before process plugin.
28+
*
29+
* @param Create $subject
30+
* @param $data
31+
* @return void
32+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
33+
*/
34+
public function beforeImportPostData(Create $subject, $data)
35+
{
36+
if (!isset($data['payment_method']) && !isset($this->request->getParam('payment')['method'])) {
37+
$subject->setPaymentMethod('');
38+
}
39+
}
40+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<type name="Magento\Sales\Model\AdminOrder\Create">
10+
<plugin name="AdminSetPaymentMethod" type="Magento\Payment\Plugin\AdminSetPaymentMethod"/>
11+
</type>
12+
</config>

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,8 +1810,6 @@ public function importPostData($data)
18101810

18111811
if (isset($data['payment_method'])) {
18121812
$this->setPaymentMethod($data['payment_method']);
1813-
} else {
1814-
$this->setPaymentMethod('');
18151813
}
18161814

18171815
if (isset($data['coupon']['code'])) {

0 commit comments

Comments
 (0)