diff --git a/apps/payments/api/.env b/apps/payments/api/.env index 61c8789aefa..c72075b46d8 100644 --- a/apps/payments/api/.env +++ b/apps/payments/api/.env @@ -38,7 +38,7 @@ FIRESTORE_CONFIG__PROJECT_ID= # Currency Config CURRENCY_CONFIG__TAX_IDS={ "EUR": "EU1234", "CHF": "CH1234" } -CURRENCY_CONFIG__CURRENCIES_TO_COUNTRIES={ "USD": ["US", "GB", "NZ", "MY", "SG", "CA", "AS", "GU", "MP", "PR", "VI"], "EUR": ["FR", "DE"] } +CURRENCY_CONFIG__CURRENCIES_TO_COUNTRIES={"USD":["AS","CA","GB","GU","MP","MY","NZ","PR","SG","US","VI"],"EUR":["AT","BG","BE","CY","DE","EE","ES","FI","FR","GR","HR","HU","IE","IT","LT","LU","LV","MT","NL","PT","RO","SE","SI","SK"],"CHF":["CH"],"CZK":["CZ"],"DKK":["DK"],"PLN":["PL"]} # StatsD Config STATS_D_CONFIG__SAMPLE_RATE= @@ -53,6 +53,6 @@ STRIPE_EVENTS_CONFIG__FIRESTORE_STRIPE_EVENT_STORE_COLLECTION_NAME=stripeEvents # Glean Config GLEAN_CONFIG__ENABLED=false GLEAN_CONFIG__APPLICATION_ID= -GLEAN_CONFIG__VERSION=0.0.0 +GLEAN_CONFIG__VERSION=0.0.0 GLEAN_CONFIG__CHANNEL='development' GLEAN_CONFIG__LOGGER_APP_NAME='fxa-payments-next' diff --git a/apps/payments/next/.env b/apps/payments/next/.env index e5da79abc1f..a7ef5d89311 100644 --- a/apps/payments/next/.env +++ b/apps/payments/next/.env @@ -90,7 +90,7 @@ FIRESTORE_CONFIG__PROJECT_ID= # Currency Config CURRENCY_CONFIG__TAX_IDS={ "EUR": "EU1234", "CHF": "CH1234" } -CURRENCY_CONFIG__CURRENCIES_TO_COUNTRIES={ "USD": ["US", "GB", "NZ", "MY", "SG", "CA", "AS", "GU", "MP", "PR", "VI"], "EUR": ["FR", "DE"] } +CURRENCY_CONFIG__CURRENCIES_TO_COUNTRIES={"USD":["AS","CA","GB","GU","MP","MY","NZ","PR","SG","US","VI"],"EUR":["AT","BG","BE","CY","DE","EE","ES","FI","FR","GR","HR","HU","IE","IT","LT","LU","LV","MT","NL","PT","RO","SE","SI","SK"],"CHF":["CH"],"CZK":["CZ"],"DKK":["DK"],"PLN":["PL"]} # Churn Intervention Config CHURN_INTERVENTION_CONFIG__COLLECTION_NAME=churnInterventions diff --git a/libs/payments/currency/src/lib/currency.config.ts b/libs/payments/currency/src/lib/currency.config.ts index d6e06b62d8c..ab0b3037001 100644 --- a/libs/payments/currency/src/lib/currency.config.ts +++ b/libs/payments/currency/src/lib/currency.config.ts @@ -24,7 +24,7 @@ export class CurrencyConfig { export const MockCurrencyConfig = { taxIds: { EUR: 'EU1234' }, - currenciesToCountries: { USD: ['US'] }, + currenciesToCountries: { USD: ['US'], EUR: ['FR', 'DE', 'NL'] }, } satisfies CurrencyConfig; export const MockCurrencyConfigProvider = { diff --git a/libs/payments/currency/src/lib/currency.constants.ts b/libs/payments/currency/src/lib/currency.constants.ts index 2dc6284363d..fba9246c25a 100644 --- a/libs/payments/currency/src/lib/currency.constants.ts +++ b/libs/payments/currency/src/lib/currency.constants.ts @@ -2,16 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* - * Mapping from ISO 4217 three-letter currency codes to list of ISO 3166-1 alpha-2 - * two-letter country codes: {"EUR": ["DE", "FR"], "USD": ["CA", "GB", "US" ]} - * Requirement for only one currency per country. Tested at runtime. Must be uppercased. - */ -export const CURRENCIES_TO_COUNTRIES = { - USD: ['US', 'GB', 'NZ', 'MY', 'SG', 'CA', 'AS', 'GU', 'MP', 'PR', 'VI'], - EUR: ['FR', 'DE'], -}; - /* * PayPal has specific restrictions on how currencies are handled. * The general documentation for the AMT field is here: https://developer.paypal.com/docs/nvp-soap-api/do-reference-transaction-nvp/#payment-details-fields diff --git a/libs/payments/currency/src/lib/currency.manager.spec.ts b/libs/payments/currency/src/lib/currency.manager.spec.ts index 42a2b231327..39a437a4967 100644 --- a/libs/payments/currency/src/lib/currency.manager.spec.ts +++ b/libs/payments/currency/src/lib/currency.manager.spec.ts @@ -12,8 +12,11 @@ import { CurrencyCodeMissingError, CountryCodeMissingError, } from './currency.error'; -import { CURRENCIES_TO_COUNTRIES } from './currency.constants'; -import { CurrencyConfig, MockCurrencyConfigProvider } from './currency.config'; +import { + CurrencyConfig, + MockCurrencyConfig, + MockCurrencyConfigProvider, +} from './currency.config'; describe('CurrencyManager', () => { let currencyManager: CurrencyManager; @@ -30,7 +33,7 @@ describe('CurrencyManager', () => { describe('assertCurrencyCompatibleWithCountry', () => { const validCountry = faker.helpers.arrayElement( - CURRENCIES_TO_COUNTRIES.USD + MockCurrencyConfig.currenciesToCountries.USD ); const validCurrency = 'USD'; diff --git a/libs/payments/currency/src/lib/currency.manager.ts b/libs/payments/currency/src/lib/currency.manager.ts index 2140850d23f..9f0b3d1550a 100644 --- a/libs/payments/currency/src/lib/currency.manager.ts +++ b/libs/payments/currency/src/lib/currency.manager.ts @@ -4,7 +4,6 @@ import { Injectable } from '@nestjs/common'; import { - CURRENCIES_TO_COUNTRIES, SUPPORTED_PAYPAL_CURRENCIES, VALID_COUNTRY_CODES, VALID_CURRENCY_CODES, @@ -42,7 +41,7 @@ export class CurrencyManager { if ( !VALID_CURRENCY_CODES.includes(currencyUpper) || !SUPPORTED_PAYPAL_CURRENCIES.includes(currencyUpper) || - !CURRENCIES_TO_COUNTRIES.hasOwnProperty(currencyUpper) + !this.config.currenciesToCountries.hasOwnProperty(currencyUpper) ) { throw new CurrencyCodeInvalidError(currencyUpper); } @@ -52,9 +51,9 @@ export class CurrencyManager { } if ( - currencyUpper in CURRENCIES_TO_COUNTRIES && - !CURRENCIES_TO_COUNTRIES[ - currencyUpper as keyof typeof CURRENCIES_TO_COUNTRIES + currencyUpper in this.config.currenciesToCountries && + !this.config.currenciesToCountries[ + currencyUpper as keyof typeof this.config.currenciesToCountries ].includes(country) ) { throw new CurrencyCountryMismatchError(currencyUpper, country);