@@ -60,6 +60,11 @@ class Payment extends \Magento\Payment\Model\Info implements PaymentInterface
60
60
*/
61
61
protected $ methodSpecificationFactory ;
62
62
63
+ /**
64
+ * @var array
65
+ */
66
+ private $ additionalChecks ;
67
+
63
68
/**
64
69
* @param \Magento\Framework\Model\Context $context
65
70
* @param \Magento\Framework\Registry $registry
@@ -71,6 +76,7 @@ class Payment extends \Magento\Payment\Model\Info implements PaymentInterface
71
76
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
72
77
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
73
78
* @param array $data
79
+ * @param array $additionalChecks
74
80
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
75
81
*/
76
82
public function __construct (
@@ -83,9 +89,11 @@ public function __construct(
83
89
\Magento \Payment \Model \Checks \SpecificationFactory $ methodSpecificationFactory ,
84
90
\Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
85
91
\Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
86
- array $ data = []
92
+ array $ data = [],
93
+ array $ additionalChecks = []
87
94
) {
88
95
$ this ->methodSpecificationFactory = $ methodSpecificationFactory ;
96
+ $ this ->additionalChecks = $ additionalChecks ;
89
97
parent ::__construct (
90
98
$ context ,
91
99
$ registry ,
@@ -162,7 +170,8 @@ public function importData(array $data)
162
170
*/
163
171
$ quote ->collectTotals ();
164
172
165
- $ methodSpecification = $ this ->methodSpecificationFactory ->create ($ data ->getChecks ());
173
+ $ checks = array_merge ($ data ->getChecks (), $ this ->additionalChecks );
174
+ $ methodSpecification = $ this ->methodSpecificationFactory ->create ($ checks );
166
175
if (!$ method ->isAvailable ($ quote ) || !$ methodSpecification ->isApplicable ($ method , $ quote )) {
167
176
throw new \Magento \Framework \Exception \LocalizedException (
168
177
__ ('The requested Payment Method is not available. ' )
0 commit comments