Skip to content

Commit 3ed3be2

Browse files
committed
ACP2E-1120: extend new statuses that can apply for new placed order with free payment
1 parent c6e86a4 commit 3ed3be2

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

app/code/Magento/Payment/Model/Method/Free.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,12 @@ public function getConfigPaymentAction()
139139
{
140140
$newStateStatuses = $this->config->getStateStatuses('new');
141141
$configNewOrderStatus = $this->getConfigData('order_status');
142+
$paymentAction = parent::getConfigPaymentAction();
143+
142144
return
143-
$configNewOrderStatus == 'pending' ||
144-
array_key_exists($configNewOrderStatus, $newStateStatuses) ?
145-
null : parent::getConfigPaymentAction();
145+
array_key_exists($configNewOrderStatus, $newStateStatuses) &&
146+
$configNewOrderStatus != 'processing' &&
147+
empty($paymentAction)
148+
? null : $paymentAction;
146149
}
147150
}

app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ public function testGetConfigPaymentAction($orderStatus, $paymentAction, $result
105105
->willReturn($stateStatuses);
106106
$this->scopeConfig
107107
->method('getValue')
108-
->willReturnOnConsecutiveCalls($orderStatus, $paymentAction);
108+
->withConsecutive(['payment/free/order_status'], ['payment/free/'.$paymentAction])
109+
->willReturnOnConsecutiveCalls($orderStatus, $result);
109110
$this->assertEquals($result, $this->methodFree->getConfigPaymentAction());
110111
}
111112

@@ -164,10 +165,12 @@ public function getIsAvailableProvider(): array
164165
public function getConfigPaymentActionProvider(): array
165166
{
166167
return [
167-
['pending', 'action', null, ['pending' => 'Pending']],
168-
['new', 'action', null, ['pending' => 'Pending', 'new' => 'New']],
168+
['pending', 'payment_action', null, ['pending' => 'Pending']],
169+
['new', 'payment_action', null, ['pending' => 'Pending', 'new' => 'New']],
169170
['new', 'payment_action', 'payment_action', ['pending' => 'Pending']],
170-
['processing', 'payment_action', 'payment_action', ['pending' => 'Pending']]
171+
['processing', 'payment_action', 'payment_action', ['pending' => 'Pending']],
172+
['processing', 'payment_action', null, ['pending' => 'Pending', 'processing' => 'Processing']],
173+
['processing', 'payment_action', 'payment_action', ['pending' => 'Pending', 'processing' => 'Processing']]
171174
];
172175
}
173176
}

0 commit comments

Comments
 (0)