|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © 2016 Magento. All rights reserved. |
|
4
|
|
|
* See COPYING.txt for license details. |
|
5
|
|
|
*/ |
|
6
|
|
|
namespace Getloy\GetloyMagentoGateway\Model\Ui; |
|
7
|
|
|
|
|
8
|
|
|
use Magento\Checkout\Model\ConfigProviderInterface; |
|
9
|
|
|
use Magento\Framework\View\Asset\Repository as AssetRepository; |
|
10
|
|
|
use Magento\Checkout\Model\Session; |
|
11
|
|
|
use Magento\Quote\Model\Quote; |
|
12
|
|
|
use Magento\Store\Model\StoreManagerInterface; |
|
13
|
|
|
use Magento\Directory\Model\CurrencyFactory; |
|
|
|
|
|
|
14
|
|
|
use Magento\Directory\Model\Currency; |
|
15
|
|
|
use Magento\Framework\App\Config\ScopeConfigInterface; |
|
16
|
|
|
use Getloy\GetloyMagentoGateway\Gateway\Config\Config; |
|
17
|
|
|
|
|
18
|
|
|
class ConfigProvider implements ConfigProviderInterface |
|
19
|
|
|
{ |
|
20
|
|
|
const CODE = 'getloy_magento_gateway'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var ScopeConfigInterface |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $scopeConfig; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var Config |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $config; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var Session |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $checkoutSession; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var StoreManagerInterface |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $storeManager; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var AssetRepository |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $assetRepo; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var Currency |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $currency; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var Quote |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $quote; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param ScopeConfigInterface $scopeConfig |
|
59
|
|
|
* @param Session $checkoutSession |
|
60
|
|
|
* @param StoreManagerInterface $storeManager |
|
61
|
|
|
* @param CurrencyFactory $currencyFactory |
|
62
|
|
|
* @param AssetRepository $assetRepo |
|
63
|
|
|
*/ |
|
64
|
|
|
public function __construct( |
|
65
|
|
|
ScopeConfigInterface $scopeConfig, |
|
66
|
|
|
Session $checkoutSession, |
|
67
|
|
|
StoreManagerInterface $storeManager, |
|
68
|
|
|
CurrencyFactory $currencyFactory, |
|
69
|
|
|
AssetRepository $assetRepo |
|
70
|
|
|
) { |
|
71
|
|
|
$this->scopeConfig = $scopeConfig; |
|
72
|
|
|
$this->checkoutSession = $checkoutSession; |
|
73
|
|
|
$this->storeManager = $storeManager; |
|
74
|
|
|
$this->config = new Config($scopeConfig, self::CODE); |
|
75
|
|
|
$this->currency = $currencyFactory->create(); |
|
76
|
|
|
$this->quote = $this->checkoutSession->getQuote(); |
|
77
|
|
|
$this->assetRepo = $assetRepo; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Retrieve assoc array of checkout configuration |
|
82
|
|
|
* |
|
83
|
|
|
* @return array |
|
84
|
|
|
*/ |
|
85
|
|
|
public function getConfig() |
|
86
|
|
|
{ |
|
87
|
|
|
// $storeId = $this->session->getStoreId(); |
|
88
|
|
|
return [ |
|
89
|
|
|
'payment' => [ |
|
90
|
|
|
self::CODE => [ |
|
91
|
|
|
'active' => $this->isActive(), |
|
92
|
|
|
'sandbox' => $this->config->isSandbox(), |
|
93
|
|
|
'title' => $this->config->getMethodTitles()[ |
|
94
|
|
|
$this->config::PAYMENT_METHOD_PAYWAY_KH |
|
95
|
|
|
][ |
|
96
|
|
|
$this->config::PAYMENT_METHOD_VARIANT_DEFAULT |
|
97
|
|
|
], |
|
98
|
|
|
'payment_method_logos' => $this->paymentMethodLogos(), |
|
99
|
|
|
] |
|
100
|
|
|
] |
|
101
|
|
|
]; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function paymentMethodLogos() |
|
105
|
|
|
{ |
|
106
|
|
|
return [ |
|
107
|
|
|
[ |
|
108
|
|
|
'title' => 'Visa', |
|
109
|
|
|
'logo' => $this->assetRepo->getUrl( |
|
110
|
|
|
'Getloy_GetloyMagentoGateway::images/visa.svg' |
|
111
|
|
|
), |
|
112
|
|
|
], |
|
113
|
|
|
[ |
|
114
|
|
|
'title' => 'MasterCard', |
|
115
|
|
|
'logo' => $this->assetRepo->getUrl( |
|
116
|
|
|
'Getloy_GetloyMagentoGateway::images/mastercard.svg' |
|
117
|
|
|
), |
|
118
|
|
|
], |
|
119
|
|
|
[ |
|
120
|
|
|
'title' => 'UnionPay', |
|
121
|
|
|
'logo' => $this->assetRepo->getUrl( |
|
122
|
|
|
'Getloy_GetloyMagentoGateway::images/unionpay.svg' |
|
123
|
|
|
), |
|
124
|
|
|
], |
|
125
|
|
|
[ |
|
126
|
|
|
'title' => 'ABA Pay', |
|
127
|
|
|
'logo' => $this->assetRepo->getUrl( |
|
128
|
|
|
'Getloy_GetloyMagentoGateway::images/aba-pay.svg' |
|
129
|
|
|
), |
|
130
|
|
|
], |
|
131
|
|
|
]; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function isActive() |
|
135
|
|
|
{ |
|
136
|
|
|
if (!$this->config->isActive()) { |
|
137
|
|
|
return false; |
|
138
|
|
|
} |
|
139
|
|
|
return (bool) in_array( |
|
140
|
|
|
$this->quote->getQuoteCurrencyCode(), |
|
141
|
|
|
$this->config->getAcceptedCurrencies() |
|
142
|
|
|
); |
|
143
|
|
|
} |
|
144
|
|
|
} |
|
145
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths