Skip to content

Commit c5f89ad

Browse files
Merge pull request #99 from AbdullahAldakheel/master
Fix methods value
2 parents 43e623f + 6c11c9d commit c5f89ad

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

Helper/MoyasarHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
class MoyasarHelper extends AbstractHelper
2323
{
24-
const VERSION = '5.0.5';
24+
const VERSION = '5.0.6';
2525

2626
const XML_PATH_CREDIT_CARD_IS_ACTIVE = 'payment/moyasar_payments/active';
2727
const XML_PATH_APPLE_PAY_IS_ACTIVE = 'payment/moyasar_payments_apple_pay/active';

Model/Config/PaymentConfigProvider.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Moyasar\Magento2\Helper\CurrencyHelper;
1010
use Moyasar\Magento2\Helper\MoyasarHelper;
1111
use Moyasar\Magento2\Model\Payment\MoyasarPayments;
12+
use Moyasar\Magento2\Model\Payment\MoyasarPaymentsApplePay;
13+
use Moyasar\Magento2\Model\Payment\MoyasarPaymentsStcPay;
1214

1315
class PaymentConfigProvider implements ConfigProviderInterface
1416
{
@@ -56,15 +58,31 @@ public function getConfig()
5658
{
5759
$storeUrl = $this->storeManager->getStore()->getBaseUrl();
5860
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+
5977

6078
$config = [
6179
'api_key' => $this->moyasarHelper->publishableApiKey(),
6280
'base_url' => $this->moyasarHelper->apiBaseUrl(),
6381
'country' => $this->scopeConfig->getValue('general/country/default'),
6482
'store_name' => $this->getStoreName(),
6583
'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,
6886
'version' => 'Moyasar Http; Magento Plugin v' . MoyasarHelper::VERSION
6987
];
7088

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "moyasar-fintech/magento2",
33
"description": "Magento 2 payment module that integrate with https:\\\\moyasar.com Gateway",
44
"type": "magento2-module",
5-
"version": "5.0.5",
5+
"version": "5.0.6",
66
"authors": [
77
{
88
"email": "[email protected]",

0 commit comments

Comments
 (0)