Skip to content

Commit 2769f7c

Browse files
committed
Allows additional payment checks in payment method list
1 parent 50a085d commit 2769f7c

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

app/code/Magento/Payment/Model/MethodList.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,24 @@ class MethodList
3939
*/
4040
private $paymentMethodInstanceFactory;
4141

42+
/**
43+
* @var array
44+
*/
45+
private $additionalChecks;
46+
4247
/**
4348
* @param \Magento\Payment\Helper\Data $paymentHelper
44-
* @param Checks\SpecificationFactory $specificationFactory
49+
* @param Checks\SpecificationFactory $specificationFactory
50+
* @param array $additionalChecks
4551
*/
4652
public function __construct(
4753
\Magento\Payment\Helper\Data $paymentHelper,
48-
\Magento\Payment\Model\Checks\SpecificationFactory $specificationFactory
54+
\Magento\Payment\Model\Checks\SpecificationFactory $specificationFactory,
55+
array $additionalChecks = []
4956
) {
5057
$this->paymentHelper = $paymentHelper;
5158
$this->methodSpecificationFactory = $specificationFactory;
59+
$this->additionalChecks = $additionalChecks;
5260
}
5361

5462
/**
@@ -80,12 +88,15 @@ public function getAvailableMethods(\Magento\Quote\Api\Data\CartInterface $quote
8088
protected function _canUseMethod($method, \Magento\Quote\Api\Data\CartInterface $quote)
8189
{
8290
return $this->methodSpecificationFactory->create(
83-
[
84-
AbstractMethod::CHECK_USE_CHECKOUT,
85-
AbstractMethod::CHECK_USE_FOR_COUNTRY,
86-
AbstractMethod::CHECK_USE_FOR_CURRENCY,
87-
AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX,
88-
]
91+
array_merge(
92+
[
93+
AbstractMethod::CHECK_USE_CHECKOUT,
94+
AbstractMethod::CHECK_USE_FOR_COUNTRY,
95+
AbstractMethod::CHECK_USE_FOR_CURRENCY,
96+
AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX,
97+
],
98+
$this->additionalChecks
99+
)
89100
)->isApplicable(
90101
$method,
91102
$quote

0 commit comments

Comments
 (0)