Skip to content

Commit

Permalink
Merge pull request #3 from melaxon/patch-3
Browse files Browse the repository at this point in the history
List only accepted currency
  • Loading branch information
grumpy-dog authored May 4, 2019
2 parents 26a9513 + 1ef9451 commit ac536f5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Binary file added .DS_Store
Binary file not shown.
8 changes: 7 additions & 1 deletion Model/CoinPaymentsConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,25 @@ 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;
}
}
}

return [
'payment' => [
'coinpayments' => [
'available_currencies' => $currencies,
'accepted_currencies' => $acceptedCurrencies,
'logo' => $this->_assetRepo->getUrl('Coinpayments_CoinPayments::images/logo.png'),
'direct_mode' => (int)$isDirect,
'url' => $coinpaymentsDomain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -236,4 +241,4 @@ define(
}
});
}
);
);
4 changes: 2 additions & 2 deletions view/frontend/web/template/payment/coin_payment_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -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')">
Expand All @@ -35,4 +35,4 @@
<div class="mage-error" data-bind="attr: {id: getCode() + '_crypto_currency_error'}"></div>
</div>
</div>
</fieldset>
</fieldset>

0 comments on commit ac536f5

Please sign in to comment.