|
9 | 9 | use Moyasar\Magento2\Helper\CurrencyHelper;
|
10 | 10 | use Moyasar\Magento2\Helper\MoyasarHelper;
|
11 | 11 | use Moyasar\Magento2\Model\Payment\MoyasarPayments;
|
| 12 | +use Moyasar\Magento2\Model\Payment\MoyasarPaymentsApplePay; |
| 13 | +use Moyasar\Magento2\Model\Payment\MoyasarPaymentsStcPay; |
12 | 14 |
|
13 | 15 | class PaymentConfigProvider implements ConfigProviderInterface
|
14 | 16 | {
|
@@ -56,15 +58,31 @@ public function getConfig()
|
56 | 58 | {
|
57 | 59 | $storeUrl = $this->storeManager->getStore()->getBaseUrl();
|
58 | 60 | preg_match('/^.+:\/\/([A-Za-z0-9\-\.]+)\/?.*$/', $storeUrl, $matches);
|
| 61 | + $enabled_method = []; |
| 62 | + // Credit Card |
| 63 | + if ($this->scopeConfig->getValue('payment/moyasar_payments/active')) { |
| 64 | + $enabled_method[] = 'creditcard'; |
| 65 | + } |
| 66 | + // Apple Pay |
| 67 | + if ($this->scopeConfig->getValue('payment/moyasar_payments_apple_pay/active')) { |
| 68 | + $enabled_method[] = 'applepay'; |
| 69 | + } |
| 70 | + // Stc Pay |
| 71 | + if ($this->scopeConfig->getValue('payment/moyasar_payments_stc_pay/active')) { |
| 72 | + $enabled_method[] = 'stcpay'; |
| 73 | + } |
| 74 | + |
| 75 | + $supported_networks = $this->scopeConfig->getValue('payment/moyasar_payments/schemes'); |
| 76 | + |
59 | 77 |
|
60 | 78 | $config = [
|
61 | 79 | 'api_key' => $this->moyasarHelper->publishableApiKey(),
|
62 | 80 | 'base_url' => $this->moyasarHelper->apiBaseUrl(),
|
63 | 81 | 'country' => $this->scopeConfig->getValue('general/country/default'),
|
64 | 82 | 'store_name' => $this->getStoreName(),
|
65 | 83 | 'domain_name' => $matches[1],
|
66 |
| - 'supported_networks' => explode(',', $this->scopeConfig->getValue('payment/moyasar_payments/schemes')), |
67 |
| - 'methods' => explode(',', $this->scopeConfig->getValue('payment/moyasar_payments/methods')), |
| 84 | + 'supported_networks' => explode(',', $supported_networks ? $supported_networks : []), |
| 85 | + 'methods' => $enabled_method, |
68 | 86 | 'version' => 'Moyasar Http; Magento Plugin v' . MoyasarHelper::VERSION
|
69 | 87 | ];
|
70 | 88 |
|
|
0 commit comments