-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change RubyMoney bank to currencylayer (#10520)
* Change RubyMoney bank to currencylayer * Review changes * Adding dummy API key in env * Adding currencylayer only for production * Removed unwanted appsecret * Remove env entries
- Loading branch information
1 parent
64d379f
commit 508edad
Showing
5 changed files
with
30 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'money/bank/currencylayer_bank' | ||
|
||
Money.locale_backend = :i18n | ||
|
||
eu_bank = EuCentralBank.new | ||
Money.default_bank = eu_bank | ||
if Rails.env.production? && EnvConfig.WCA_LIVE_SITE? | ||
mclb = Money::Bank::CurrencylayerBank.new | ||
mclb.access_key = AppSecrets.CURRENCY_LAYER_API_KEY | ||
mclb.currencylayer = true | ||
mclb.ttl_in_seconds = 86_400 | ||
mclb.cache = proc do |payload| | ||
key = 'money:currencylayer_bank' | ||
if payload | ||
Rails.cache.write(key, payload) | ||
else | ||
Rails.cache.read(key) | ||
end | ||
end | ||
mclb.update_rates | ||
Money.default_bank = mclb | ||
else | ||
eu_bank = EuCentralBank.new | ||
eu_bank.update_rates | ||
Money.default_bank = eu_bank | ||
end | ||
|
||
Money.default_currency = Money::Currency.new("USD") | ||
Money.rounding_mode = BigDecimal::ROUND_HALF_UP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters