66namespace Magento \Payment \Model ;
77
88use Magento \Payment \Api \Data \PaymentMethodInterface ;
9+ use Magento \Payment \Api \Data \PaymentMethodInterfaceFactory ;
10+ use Magento \Payment \Api \PaymentMethodListInterface ;
11+ use Magento \Payment \Helper \Data ;
12+ use UnexpectedValueException ;
913
10- /**
11- * Payment method list class.
12- */
13- class PaymentMethodList implements \Magento \Payment \Api \PaymentMethodListInterface
14+ class PaymentMethodList implements PaymentMethodListInterface
1415{
1516 /**
16- * @var \Magento\Payment\Api\Data\ PaymentMethodInterfaceFactory
17+ * @var PaymentMethodInterfaceFactory
1718 */
1819 private $ methodFactory ;
1920
2021 /**
21- * @var \Magento\Payment\Helper\ Data
22+ * @var Data
2223 */
2324 private $ helper ;
2425
2526 /**
26- * @param \Magento\Payment\Api\Data\ PaymentMethodInterfaceFactory $methodFactory
27- * @param \Magento\Payment\Helper\ Data $helper
27+ * @param PaymentMethodInterfaceFactory $methodFactory
28+ * @param Data $helper
2829 */
2930 public function __construct (
30- \ Magento \ Payment \ Api \ Data \ PaymentMethodInterfaceFactory $ methodFactory ,
31- \ Magento \ Payment \ Helper \ Data $ helper
31+ PaymentMethodInterfaceFactory $ methodFactory ,
32+ Data $ helper
3233 ) {
3334 $ this ->methodFactory = $ methodFactory ;
3435 $ this ->helper = $ helper ;
3536 }
3637
3738 /**
38- * {@inheritdoc}
39+ * @inheritDoc
3940 */
4041 public function getList ($ storeId )
4142 {
4243 $ methodsCodes = array_keys ($ this ->helper ->getPaymentMethods ());
43-
4444 $ methodsInstances = array_map (
4545 function ($ code ) {
46- return $ this ->helper ->getMethodInstance ($ code );
46+ try {
47+ return $ this ->helper ->getMethodInstance ($ code );
48+ } catch (UnexpectedValueException $ e ) {
49+ return null ;
50+ }
4751 },
4852 $ methodsCodes
4953 );
5054
51- $ methodsInstances = array_filter ($ methodsInstances , function (MethodInterface $ method ) {
52- return !($ method instanceof \Magento \Payment \Model \Method \Substitution);
55+ $ methodsInstances = array_filter ($ methodsInstances , function ($ method ) {
56+ return $ method && !($ method instanceof \Magento \Payment \Model \Method \Substitution);
5357 });
5458
55- @ uasort (
59+ uasort (
5660 $ methodsInstances ,
5761 function (MethodInterface $ a , MethodInterface $ b ) use ($ storeId ) {
5862 return (int )$ a ->getConfigData ('sort_order ' , $ storeId ) - (int )$ b ->getConfigData ('sort_order ' , $ storeId );
@@ -76,7 +80,7 @@ function (MethodInterface $methodInstance) use ($storeId) {
7680 }
7781
7882 /**
79- * {@inheritdoc}
83+ * @inheritDoc
8084 */
8185 public function getActiveList ($ storeId )
8286 {
0 commit comments