From 1ef94518578fdae6493831e9774b86c0120cb8b1 Mon Sep 17 00:00:00 2001 From: Yannis Livasov Date: Fri, 3 May 2019 15:43:59 +0300 Subject: [PATCH] Fix list accepted coins Squashed commits --- .DS_Store | Bin 0 -> 6148 bytes Model/CoinPaymentsConfigProvider.php | 8 +++++++- .../view/payment/method-renderer/coin-method.js | 9 +++++++-- .../web/template/payment/coin_payment_form.html | 4 ++-- 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8938c2891a605566c52de61679c3bc803611e79e GIT binary patch literal 6148 zcmeHKJ5Iwu5S>X2jB+0`2dcrP*R{b z(#-SD&Rff`@a%|)?vCwNWFsPLxS^aZ%+2=AXST@93aEC*c7N!*VOIBB!njMhl|i1K zAEx}p&CgEPH%)tdIf%S{yubQ!$?5v`!p`tGJ*_y2feKIoDnJFO02Q#FZMMD&WTXOA zfC_voVE=~#H>`U;kuBZSN_*V+(s@XR?d{Xw- y*~eM0E%1Bzm!a0n5xf-xy%l3&t@wIUSL_-4HE|4dI`U2j@*-fm(5S#)DDVloAteI< literal 0 HcmV?d00001 diff --git a/Model/CoinPaymentsConfigProvider.php b/Model/CoinPaymentsConfigProvider.php index 6d910d6..fd0789e 100644 --- a/Model/CoinPaymentsConfigProvider.php +++ b/Model/CoinPaymentsConfigProvider.php @@ -71,12 +71,17 @@ public function getConfig() $currencies = ['error' => $response->error]; if ($response->error == 'ok') { $currencies = []; + $acceptedCurrencies = []; foreach ($response->result as $key => $item) { - $currencies[] = [ + $elm = [ 'value' => $key, 'body' => $item, 'name' => $item->name ]; + $currencies[] = $elm; + if (isset($item->accepted) && $item->accepted == '1') { + $acceptedCurrencies[] = $elm; + } } } @@ -84,6 +89,7 @@ public function getConfig() 'payment' => [ 'coinpayments' => [ 'available_currencies' => $currencies, + 'accepted_currencies' => $acceptedCurrencies, 'logo' => $this->_assetRepo->getUrl('Coinpayments_CoinPayments::images/logo.png'), 'direct_mode' => (int)$isDirect, 'url' => $coinpaymentsDomain, diff --git a/view/frontend/web/js/view/payment/method-renderer/coin-method.js b/view/frontend/web/js/view/payment/method-renderer/coin-method.js index d6af498..dcb27bb 100644 --- a/view/frontend/web/js/view/payment/method-renderer/coin-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/coin-method.js @@ -122,7 +122,12 @@ define( if (!window.checkoutConfig.payment.coinpayments.available_currencies.error) { return window.checkoutConfig.payment.coinpayments.available_currencies; } - + return [{error: "error"}]; + }, + getAcceptedCurrencies: function () { + if (!window.checkoutConfig.payment.coinpayments.accepted_currencies.error) { + return window.checkoutConfig.payment.coinpayments.accepted_currencies; + } return [{error: "error"}]; }, getPaymentAcceptanceMarkSrc: function () { @@ -236,4 +241,4 @@ define( } }); } -); \ No newline at end of file +); diff --git a/view/frontend/web/template/payment/coin_payment_form.html b/view/frontend/web/template/payment/coin_payment_form.html index ef46232..edb43ab 100644 --- a/view/frontend/web/template/payment/coin_payment_form.html +++ b/view/frontend/web/template/payment/coin_payment_form.html @@ -13,7 +13,7 @@ attr: {id: getCode() + '_crypto_currency', 'data-container': getCode() + '_crypto_currency'}, event: { change: getConvertedAmount}, enable: 1, - options: getCurrencies(), + options: getAcceptedCurrencies(), optionsValue: 'value', optionsText: 'name', optionsCaption: $t('Currency')"> @@ -35,4 +35,4 @@
- \ No newline at end of file +