Skip to content

Commit

Permalink
EIT-3042 - remove assets for EU
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottAntonacAP committed Aug 4, 2023
1 parent fc2e10a commit af41ab2
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 168 deletions.
2 changes: 1 addition & 1 deletion afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object Afterpay {
get() = getRegionLanguage(locale, configuration?.consumerLocale ?: Locale.getDefault())

internal val enabled: Boolean
get() = language != null
get() = language != null && configuration?.locale != null

internal val strings: AfterpayString
get() = AfterpayString.forLocale()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import com.afterpay.android.internal.Locales.EN_CA
import com.afterpay.android.internal.Locales.EN_GB
import com.afterpay.android.internal.Locales.EN_NZ
import com.afterpay.android.internal.Locales.EN_US
import com.afterpay.android.internal.Locales.ES_ES
import com.afterpay.android.internal.Locales.FR_CA
import com.afterpay.android.internal.Locales.FR_FR
import com.afterpay.android.internal.Locales.IT_IT

private val localeLanguages = mapOf(
EN_AU to AfterpayDrawable.EN_AFTERPAY,
Expand All @@ -20,9 +17,6 @@ private val localeLanguages = mapOf(
EN_US to AfterpayDrawable.EN_AFTERPAY,
EN_CA to AfterpayDrawable.EN_AFTERPAY,
FR_CA to AfterpayDrawable.FR_CA,
FR_FR to AfterpayDrawable.FR,
IT_IT to AfterpayDrawable.IT,
ES_ES to AfterpayDrawable.ES,
)

internal enum class AfterpayDrawable(
Expand All @@ -49,24 +43,6 @@ internal enum class AfterpayDrawable(
buttonPayNowForeground = R.drawable.afterpay_button_pay_now_fg_fr_ca,
buttonPlaceOrderForeground = R.drawable.afterpay_button_place_order_fg_fr_ca,
),
FR(
buttonBuyNowForeground = R.drawable.clearpay_button_buy_now_fg_fr,
buttonCheckoutForeground = R.drawable.clearpay_button_checkout_fg_fr,
buttonPayNowForeground = R.drawable.clearpay_button_pay_now_fg_fr,
buttonPlaceOrderForeground = R.drawable.clearpay_button_place_order_fg_fr,
),
IT(
buttonBuyNowForeground = R.drawable.clearpay_button_buy_now_fg_it,
buttonCheckoutForeground = R.drawable.clearpay_button_checkout_fg_it,
buttonPayNowForeground = R.drawable.clearpay_button_pay_now_fg_it,
buttonPlaceOrderForeground = R.drawable.clearpay_button_place_order_fg_it,
),
ES(
buttonBuyNowForeground = R.drawable.clearpay_button_buy_now_fg_es,
buttonCheckoutForeground = R.drawable.clearpay_button_checkout_fg_es,
buttonPayNowForeground = R.drawable.clearpay_button_pay_now_fg_es,
buttonPlaceOrderForeground = R.drawable.clearpay_button_place_order_fg_es,
),
;

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ internal sealed class AfterpayInstalment {
}

val currencyLocale: Locale = when {
currencyLocales.isEmpty() -> {
return NotAvailable(
minimumAmount = null,
maximumAmount = "0"
)
}
currencyLocales.count() == 1 -> currencyLocales.first()
currencyLocales.contains(configuration.locale) -> configuration.locale
else -> Locales.validSet.first { Currency.getInstance(it) == configuration.currency }
Expand All @@ -40,18 +46,13 @@ internal sealed class AfterpayInstalment {

val usCurrencySymbol = Currency.getInstance(Locales.EN_US).getSymbol(Locales.EN_US)
val gbCurrencySymbol = Currency.getInstance(Locales.EN_GB).getSymbol(Locales.EN_GB)
val euCurrencySymbol = Currency.getInstance(Locales.FR_FR).getSymbol(Locales.FR_FR)

val currencyFormatter = (NumberFormat.getCurrencyInstance(clientLocale) as DecimalFormat).apply {
this.currency = configuration.currency
}

if (clientLocale == Locales.EN_US) {
currencyFormatter.apply {
when (currencySymbol) {
euCurrencySymbol -> this.applyPattern("#,##0.00¤")
}

decimalFormatSymbols = decimalFormatSymbols.apply {
this.currencySymbol = when (configuration.currency) {
Currency.getInstance(Locales.EN_AU) -> "A$"
Expand All @@ -71,7 +72,6 @@ internal sealed class AfterpayInstalment {
when (currencySymbol) {
usCurrencySymbol -> this.applyPattern("¤#,##0.00 ¤¤")
gbCurrencySymbol -> this.applyPattern("¤#,##0.00")
euCurrencySymbol -> this.applyPattern("#,##0.00¤")
}
}
}
Expand All @@ -93,10 +93,7 @@ internal sealed class AfterpayInstalment {
}

fun numberOfInstalments(currency: Currency): Int {
return when (currency.currencyCode) {
"EUR" -> 3
else -> 4
}
return 4
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import com.afterpay.android.internal.Locales.EN_CA
import com.afterpay.android.internal.Locales.EN_GB
import com.afterpay.android.internal.Locales.EN_NZ
import com.afterpay.android.internal.Locales.EN_US
import com.afterpay.android.internal.Locales.ES_ES
import com.afterpay.android.internal.Locales.FR_CA
import com.afterpay.android.internal.Locales.FR_FR
import com.afterpay.android.internal.Locales.IT_IT

private val localeLanguages = mapOf(
EN_AU to AfterpayString.EN,
Expand All @@ -18,9 +15,6 @@ private val localeLanguages = mapOf(
EN_US to AfterpayString.EN,
EN_CA to AfterpayString.EN,
FR_CA to AfterpayString.FR_CA,
FR_FR to AfterpayString.FR,
IT_IT to AfterpayString.IT,
ES_ES to AfterpayString.ES,
)

internal enum class AfterpayString(
Expand Down Expand Up @@ -109,87 +103,6 @@ internal enum class AfterpayString(
priceBreakdownLinkLearnMore = "En savoir plus",
priceBreakdownLinkMoreInfo = "Plus d'infos",
),
FR(
breakdownLimit = "disponible pour les montants entre %1\$s – %2\$s",
breakdownLimitDescription = "%1\$s disponible pour les montants entre %2\$s – %3\$s",
introOrTitle = "Ou",
introOr = "ou",
introInTitle = "En",
introIn = "en",
introPayTitle = "Payez",
introPay = "payez",
introPayInTitle = "Payez en",
introPayIn = "payez en",
introMakeTitle = "Effectuez",
introMake = "effectuez",
noConfigurationDescription = "Ou payer avec %1\$s",
noConfiguration = "ou payer avec",
loadErrorTitle = "Erreur",
loadErrorRetry = "Réessayer",
loadErrorCancel = "Annuler",
loadErrorMessage = "Échec du chargement de la page de paiement 1%\$s",
paymentButtonContentDescription = "Payez maintenant avec %1\$s",
priceBreakdownAvailable = "%1\$s %2\$s paiements %3\$sde %4\$s %5\$s",
priceBreakdownAvailableDescription = "%1\$s %2\$s paiements %3\$sde %4\$s %5\$s%6\$s",
priceBreakdownWith = "avec ",
priceBreakdownInterestFree = "sans frais ",
priceBreakdownLinkLearnMore = "En savoir plus",
priceBreakdownLinkMoreInfo = "Plus d'infos",
),
IT(
breakdownLimit = "disponibile per importi fra %1\$s – %2\$s",
breakdownLimitDescription = "%1\$s disponibile per importi fra %2\$s – %3\$s",
introOrTitle = "O",
introOr = "o",
introInTitle = "In",
introIn = "in",
introPayTitle = "Paga",
introPay = "paga",
introPayInTitle = "Paga in",
introPayIn = "paga in",
introMakeTitle = "Scegli",
introMake = "scegli",
noConfigurationDescription = "O paga con %1\$s",
noConfiguration = "o paga con",
loadErrorTitle = "Errore",
loadErrorRetry = "Riprovare",
loadErrorCancel = "Annulla",
loadErrorMessage = "Impossibile caricare il cassa di %1\$s",
paymentButtonContentDescription = "Paga ora con %1\$s",
priceBreakdownAvailable = "%1\$s %2\$s rate %3\$sda %4\$s %5\$s",
priceBreakdownAvailableDescription = "%1\$s %2\$s rate %3\$sda %4\$s %5\$s%6\$s",
priceBreakdownWith = "con ",
priceBreakdownInterestFree = "senza interessi ",
priceBreakdownLinkLearnMore = "Scopri di piú",
priceBreakdownLinkMoreInfo = "Maggiori info",
),
ES(
breakdownLimit = "disponible para importes entre %1\$s – %2\$s",
breakdownLimitDescription = "%1\$s disponible para importes entre %2\$s – %3\$s",
introOrTitle = "O",
introOr = "o",
introInTitle = "En",
introIn = "en",
introPayTitle = "Paga",
introPay = "paga",
introPayInTitle = "Paga en",
introPayIn = "paga en",
introMakeTitle = "Haga",
introMake = "haga",
noConfigurationDescription = "O pagar con %1\$s",
noConfiguration = "o pagar con",
loadErrorTitle = "Error",
loadErrorRetry = "Volver a intentar",
loadErrorCancel = "Cancelar",
loadErrorMessage = "Imposible cargar la página de pago de %1\$s",
paymentButtonContentDescription = "Pagar ahora con %1\$s",
priceBreakdownAvailable = "%1\$s %2\$s pagos %3\$sde %4\$s %5\$s",
priceBreakdownAvailableDescription = "%1\$s %2\$s pagos %3\$sde %4\$s %5\$s%6\$s",
priceBreakdownWith = "con ",
priceBreakdownInterestFree = "sin coste ",
priceBreakdownLinkLearnMore = "Saber más",
priceBreakdownLinkMoreInfo = "Más infos",
),
;

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ import com.afterpay.android.internal.Locales.EN_CA
import com.afterpay.android.internal.Locales.EN_GB
import com.afterpay.android.internal.Locales.EN_NZ
import com.afterpay.android.internal.Locales.EN_US
import com.afterpay.android.internal.Locales.ES_ES
import com.afterpay.android.internal.Locales.FR_CA
import com.afterpay.android.internal.Locales.FR_FR
import com.afterpay.android.internal.Locales.IT_IT
import java.util.Locale

private val brandLocales = mapOf(
setOf(EN_AU, EN_CA, FR_CA, EN_NZ, EN_US) to Brand.AFTERPAY,
setOf(EN_GB, IT_IT, FR_FR, ES_ES) to Brand.CLEARPAY,
setOf(EN_GB) to Brand.CLEARPAY,
)

internal enum class Brand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ private val validRegionLanguages = mapOf(
Locales.EN_NZ.country to setOf(Locales.EN_NZ),
Locales.EN_US.country to setOf(Locales.EN_US),
Locales.EN_CA.country to setOf(Locales.EN_CA, Locales.FR_CA),
Locales.FR_FR.country to setOf(Locales.FR_FR, Locales.EN_GB),
Locales.IT_IT.country to setOf(Locales.IT_IT, Locales.EN_GB),
Locales.ES_ES.country to setOf(Locales.ES_ES, Locales.EN_GB),
)

internal object Locales {
Expand All @@ -20,9 +17,6 @@ internal object Locales {
val EN_NZ: Locale = Locale("en", "NZ")
val EN_GB: Locale = Locale.UK
val EN_US: Locale = Locale.US
val IT_IT: Locale = Locale.ITALY
val FR_FR: Locale = Locale.FRANCE
val ES_ES: Locale = Locale("es", "ES")

val validSet = setOf(
EN_AU,
Expand All @@ -31,9 +25,6 @@ internal object Locales {
EN_GB,
EN_NZ,
EN_US,
IT_IT,
FR_FR,
ES_ES,
)
}

Expand Down
26 changes: 26 additions & 0 deletions afterpay/src/test/kotlin/com/afterpay/android/AfterpayEnabled.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
package com.afterpay.android

import com.afterpay.android.internal.Locales
import org.junit.Assert
import org.junit.Test
import java.util.Locale

class AfterpayEnabled {
private val environment = AfterpayEnvironment.SANDBOX

private val validMerchantLocales: Array<Locale> = arrayOf(
Locales.EN_AU,
Locales.EN_CA,
Locales.EN_GB,
Locales.EN_US,
Locales.EN_NZ,
Locales.FR_CA,
)

@Test
fun `Afterpay is enabled for basic config and locale is English`() {
Afterpay.setConfiguration(
Expand Down Expand Up @@ -34,4 +44,20 @@ class AfterpayEnabled {

Assert.assertEquals(false, Afterpay.enabled)
}

@Test
fun `Afterpay is enabled for merchant locales`() {
for(locale in validMerchantLocales) {
Afterpay.setConfiguration(
minimumAmount = "10.00",
maximumAmount = "1000.00",
currencyCode = "USD",
locale = locale,
environment = environment,
consumerLocale = Locale.US,
)

Assert.assertEquals(true, Afterpay.enabled)
}
}
}
Loading

0 comments on commit af41ab2

Please sign in to comment.