diff --git a/.gitignore b/.gitignore index 5c184e2c..d964a16c 100644 --- a/.gitignore +++ b/.gitignore @@ -82,6 +82,9 @@ obj/ .idea/gradle.xml .idea/jarRepositories.xml .idea/runConfigurations.xml +.idea/deploymentTargetDropDown.xml +.idea/kotlinc.xml +.idea/appInsightsSettings.xml # OS-specific files .DS_Store diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 566ad480..00000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt b/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt index f9255fc5..857ac1c0 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt @@ -63,7 +63,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() diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt index 0597b40b..61dc903b 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt @@ -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, @@ -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( @@ -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 { diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt index 0c9ead9c..ef02a831 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt @@ -31,6 +31,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 } @@ -41,7 +47,6 @@ 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 @@ -49,10 +54,6 @@ internal sealed class AfterpayInstalment { 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$" @@ -72,7 +73,6 @@ internal sealed class AfterpayInstalment { when (currencySymbol) { usCurrencySymbol -> this.applyPattern("¤#,##0.00 ¤¤") gbCurrencySymbol -> this.applyPattern("¤#,##0.00") - euCurrencySymbol -> this.applyPattern("#,##0.00¤") } } } @@ -94,10 +94,7 @@ internal sealed class AfterpayInstalment { } fun numberOfInstalments(currency: Currency): Int { - return when (currency.currencyCode) { - "EUR" -> 3 - else -> 4 - } + return 4 } } } diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt index cb0f0da4..0cce2e1f 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt @@ -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, @@ -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( @@ -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 { diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt index a9a5eb2a..745a491d 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt @@ -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( diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt index 11a43c31..910f56dd 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt @@ -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 { @@ -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, @@ -31,9 +25,6 @@ internal object Locales { EN_GB, EN_NZ, EN_US, - IT_IT, - FR_FR, - ES_ES, ) } diff --git a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayEnabled.kt b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayEnabled.kt index 2f6db53e..39c5d511 100644 --- a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayEnabled.kt +++ b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayEnabled.kt @@ -1,5 +1,6 @@ package com.afterpay.android +import com.afterpay.android.internal.Locales import org.junit.Assert import org.junit.Test import java.util.Locale @@ -7,6 +8,15 @@ import java.util.Locale class AfterpayEnabled { private val environment = AfterpayEnvironment.SANDBOX + private val validMerchantLocales: Array = arrayOf( + Locales.EN_AU, + Locales.EN_CA, + Locales.EN_GB, + Locales.EN_NZ, + Locales.EN_US, + Locales.FR_CA, + ) + @Test fun `Afterpay is enabled for basic config and locale is English`() { Afterpay.setConfiguration( @@ -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) + } + } } diff --git a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt index 7fc76935..f53d6dd7 100644 --- a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt +++ b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt @@ -19,6 +19,10 @@ class AfterpayInstalmentLocaleTest { private val oneHundredAndTwenty = 120.toBigDecimal() + private val itLocale = Locale.ITALY + private val frLocale = Locale.FRANCE + private val esLocale = Locale("es", "ES") + @Test fun `available instalment in en-AU locale`() { val instalments = createAllAvailableInstalments(oneHundredAndTwenty, Locales.EN_AU) @@ -28,7 +32,6 @@ class AfterpayInstalmentLocaleTest { assertEquals("£30.00", instalments.gbp.instalmentAmount) assertEquals("$30.00 NZD", instalments.nzd.instalmentAmount) assertEquals("$30.00 USD", instalments.usd.instalmentAmount) - assertEquals("40.00€", instalments.eur.instalmentAmount) } @Test @@ -40,7 +43,7 @@ class AfterpayInstalmentLocaleTest { assertEquals("£10", instalments.gbp.minimumAmount) assertEquals("$10 NZD", instalments.nzd.minimumAmount) assertEquals("$10 USD", instalments.usd.minimumAmount) - assertEquals("10€", instalments.eur.minimumAmount) + assertEquals(null, instalments.eur.minimumAmount) } @Test @@ -52,7 +55,6 @@ class AfterpayInstalmentLocaleTest { assertEquals("£30.00", instalments.gbp.instalmentAmount) assertEquals("$30.00 NZD", instalments.nzd.instalmentAmount) assertEquals("$30.00 USD", instalments.usd.instalmentAmount) - assertEquals("40.00€", instalments.eur.instalmentAmount) } @Test @@ -64,7 +66,7 @@ class AfterpayInstalmentLocaleTest { assertEquals("£10", instalments.gbp.minimumAmount) assertEquals("$10 NZD", instalments.nzd.minimumAmount) assertEquals("$10 USD", instalments.usd.minimumAmount) - assertEquals("10€", instalments.eur.minimumAmount) + assertEquals(null, instalments.eur.minimumAmount) } @Test @@ -76,7 +78,6 @@ class AfterpayInstalmentLocaleTest { assertEquals("£30,00", instalments.gbp.instalmentAmount) assertEquals("$30,00 NZD", instalments.nzd.instalmentAmount) assertEquals("$30,00 USD", instalments.usd.instalmentAmount) - assertEquals("40,00€", instalments.eur.instalmentAmount) } @Test @@ -88,7 +89,7 @@ class AfterpayInstalmentLocaleTest { assertEquals("£10", instalments.gbp.minimumAmount) assertEquals("$10 NZD", instalments.nzd.minimumAmount) assertEquals("$10 USD", instalments.usd.minimumAmount) - assertEquals("10€", instalments.eur.minimumAmount) + assertEquals(null, instalments.eur.minimumAmount) } @Test @@ -100,7 +101,6 @@ class AfterpayInstalmentLocaleTest { assertEquals("£30.00", instalments.gbp.instalmentAmount) assertEquals("$30.00 NZD", instalments.nzd.instalmentAmount) assertEquals("$30.00 USD", instalments.usd.instalmentAmount) - assertEquals("40.00€", instalments.eur.instalmentAmount) } @Test @@ -112,7 +112,7 @@ class AfterpayInstalmentLocaleTest { assertEquals("£10", instalments.gbp.minimumAmount) assertEquals("$10 NZD", instalments.nzd.minimumAmount) assertEquals("$10 USD", instalments.usd.minimumAmount) - assertEquals("10€", instalments.eur.minimumAmount) + assertEquals(null, instalments.eur.minimumAmount) } @Test @@ -124,7 +124,6 @@ class AfterpayInstalmentLocaleTest { assertEquals("£30.00", instalments.gbp.instalmentAmount) assertEquals("$30.00", instalments.nzd.instalmentAmount) assertEquals("$30.00 USD", instalments.usd.instalmentAmount) - assertEquals("40.00€", instalments.eur.instalmentAmount) } @Test @@ -136,7 +135,7 @@ class AfterpayInstalmentLocaleTest { assertEquals("£10", instalments.gbp.minimumAmount) assertEquals("$10", instalments.nzd.minimumAmount) assertEquals("$10 USD", instalments.usd.minimumAmount) - assertEquals("10€", instalments.eur.minimumAmount) + assertEquals(null, instalments.eur.minimumAmount) } @Test @@ -148,7 +147,6 @@ class AfterpayInstalmentLocaleTest { assertEquals("£30.00", instalments.gbp.instalmentAmount) assertEquals("NZ$30.00", instalments.nzd.instalmentAmount) assertEquals("$30.00", instalments.usd.instalmentAmount) - assertEquals("40.00€", instalments.eur.instalmentAmount) } @Test @@ -160,79 +158,76 @@ class AfterpayInstalmentLocaleTest { assertEquals("£10", instalments.gbp.minimumAmount) assertEquals("NZ$10", instalments.nzd.minimumAmount) assertEquals("$10", instalments.usd.minimumAmount) - assertEquals("10€", instalments.eur.minimumAmount) + assertEquals(null, instalments.eur.minimumAmount) } @Test fun `available instalment in it-IT locale`() { - val instalments = createAllAvailableInstalments(oneHundredAndTwenty, Locales.IT_IT) + val instalments = createAllAvailableInstalments(oneHundredAndTwenty, itLocale) assertEquals("$30,00 AUD", instalments.aud.instalmentAmount) assertEquals("$30,00 CAD", instalments.cad.instalmentAmount) assertEquals("£30,00", instalments.gbp.instalmentAmount) assertEquals("$30,00 NZD", instalments.nzd.instalmentAmount) assertEquals("$30,00 USD", instalments.usd.instalmentAmount) - assertEquals("40,00 €", instalments.eur.instalmentAmount) } @Test fun `unavailable instalment in it-IT locale`() { - val instalments = createAllUnavailableInstalments(oneHundredAndTwenty, Locales.IT_IT) + val instalments = createAllUnavailableInstalments(oneHundredAndTwenty, itLocale) assertEquals("$10 AUD", instalments.aud.minimumAmount) assertEquals("$10 CAD", instalments.cad.minimumAmount) assertEquals("£10", instalments.gbp.minimumAmount) assertEquals("$10 NZD", instalments.nzd.minimumAmount) assertEquals("$10 USD", instalments.usd.minimumAmount) - assertEquals("10 €", instalments.eur.minimumAmount) + assertEquals(null, instalments.eur.minimumAmount) } @Test fun `available instalment in fr-FR locale`() { - val instalments = createAllAvailableInstalments(oneHundredAndTwenty, Locales.FR_FR) + val instalments = createAllAvailableInstalments(oneHundredAndTwenty, frLocale) assertEquals("$30,00 AUD", instalments.aud.instalmentAmount) assertEquals("$30,00 CAD", instalments.cad.instalmentAmount) assertEquals("£30,00", instalments.gbp.instalmentAmount) assertEquals("$30,00 NZD", instalments.nzd.instalmentAmount) assertEquals("$30,00 USD", instalments.usd.instalmentAmount) - assertEquals("40,00 €", instalments.eur.instalmentAmount) } @Test fun `unavailable instalment in fr-FR locale`() { - val instalments = createAllUnavailableInstalments(oneHundredAndTwenty, Locales.FR_FR) + val instalments = createAllUnavailableInstalments(oneHundredAndTwenty, frLocale) assertEquals("$10 AUD", instalments.aud.minimumAmount) assertEquals("$10 CAD", instalments.cad.minimumAmount) assertEquals("£10", instalments.gbp.minimumAmount) assertEquals("$10 NZD", instalments.nzd.minimumAmount) assertEquals("$10 USD", instalments.usd.minimumAmount) - assertEquals("10 €", instalments.eur.minimumAmount) + assertEquals(null, instalments.eur.minimumAmount) } @Test fun `available instalment in es-ES locale`() { - val instalments = createAllAvailableInstalments(oneHundredAndTwenty, Locales.ES_ES) + val instalments = createAllAvailableInstalments(oneHundredAndTwenty, esLocale) assertEquals("$30,00 AUD", instalments.aud.instalmentAmount) assertEquals("$30,00 CAD", instalments.cad.instalmentAmount) assertEquals("£30,00", instalments.gbp.instalmentAmount) assertEquals("$30,00 NZD", instalments.nzd.instalmentAmount) assertEquals("$30,00 USD", instalments.usd.instalmentAmount) - assertEquals("40,00 €", instalments.eur.instalmentAmount) } @Test fun `unavailable instalment in es-ES locale`() { - val instalments = createAllUnavailableInstalments(oneHundredAndTwenty, Locales.ES_ES) + val instalments = createAllUnavailableInstalments(oneHundredAndTwenty, esLocale) assertEquals("$10 AUD", instalments.aud.minimumAmount) assertEquals("$10 CAD", instalments.cad.minimumAmount) assertEquals("£10", instalments.gbp.minimumAmount) assertEquals("$10 NZD", instalments.nzd.minimumAmount) assertEquals("$10 USD", instalments.usd.minimumAmount) - assertEquals("10 €", instalments.eur.minimumAmount) + assertEquals(null, instalments.eur.minimumAmount) } private data class AllAvailableInstallments( @@ -241,7 +236,6 @@ class AfterpayInstalmentLocaleTest { val gbp: AfterpayInstalment.Available, val nzd: AfterpayInstalment.Available, val usd: AfterpayInstalment.Available, - val eur: AfterpayInstalment.Available, ) private data class AllUnavailableInstallments( @@ -260,7 +254,6 @@ class AfterpayInstalmentLocaleTest { gbp = availableInstalment(amount, poundSterling, locale), nzd = availableInstalment(amount, newZealandDollar, locale), usd = availableInstalment(amount, unitedStatesDollar, locale), - eur = availableInstalment(amount, euro, locale), ) } diff --git a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt index 40ab0ed3..69b3e1f9 100644 --- a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt +++ b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt @@ -1,5 +1,6 @@ package com.afterpay.android +import org.junit.Assert import org.junit.Assert.assertThrows import org.junit.Test import java.util.Locale @@ -8,6 +9,13 @@ class AfterpayTest { private val environment = AfterpayEnvironment.SANDBOX + private val invalidMerchantLocales: Array = arrayOf( + Locale.ITALY, + Locale.FRANCE, + Locale("es", "ES"), + Locale.JAPAN, + ) + @Test fun `setConfiguration does not throw for valid configuration`() { Afterpay.setConfiguration( @@ -111,13 +119,17 @@ class AfterpayTest { @Test fun `setConfiguration throws for a locale not in the valid set`() { assertThrows(IllegalArgumentException::class.java) { - Afterpay.setConfiguration( - minimumAmount = "10.00", - maximumAmount = "100.00", - currencyCode = "AUD", - locale = Locale.JAPAN, - environment = environment, - ) + for (locale in invalidMerchantLocales) { + Afterpay.setConfiguration( + minimumAmount = "10.00", + maximumAmount = "1000.00", + currencyCode = "USD", + locale = locale, + environment = environment, + ) + + Assert.assertEquals(false, Afterpay.enabled) + } } } } diff --git a/build.gradle b/build.gradle index c3be7f56..98521b97 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,7 @@ buildscript { 'espresso' : '3.5.1', 'uiautomator' : '2.2.0', 'ktlint' : '0.49.1', - 'cash_app_paykit_sdk' : '2.1.0', + 'cash_app_paykit_sdk' : '2.3.0', 'mockk' : '1.13.5' ] diff --git a/docs/getting-started/cash-app-pay.md b/docs/getting-started/cash-app-pay.md index d7135f55..a23382b0 100644 --- a/docs/getting-started/cash-app-pay.md +++ b/docs/getting-started/cash-app-pay.md @@ -34,13 +34,13 @@ With our latest enhancements, you can now support taking Cash App Pay payments u You can get the the latest version of the SDK from Maven. This is the import definition using Gradle: ```gradle -implementation "app.cash.paykit:core:2.0.0" +implementation "app.cash.paykit:core:2.3.0" ``` For definitions of other build systems, see [Cash App Pay Kit on Maven Central][cash-on-maven]{:target="_blank"}. {: .info } -> Version `v2.0.0` of the SDK size is `12.3 kB`. +> Version `v2.3.0` of the SDK size is `12.3 kB`. ## Step 2: Create a Cash App Pay Kit SDK Instance @@ -208,9 +208,9 @@ The `Approved` state will contain a **Grants list** object associated with it an [cash-on-maven]: https://central.sonatype.com/artifact/app.cash.paykit/core/1.0.3/overview [configure-afterpay]: ../configuring-the-sdk -[sandbox-app]: https://cashapp-pay.stoplight.io/docs/api/technical-documentation/sandbox/sandbox-app +[sandbox-app]: https://developers.cash.app/docs/api/technical-documentation/sandbox/sandbox-app [intent-filter]: https://developer.android.com/training/app-links/deep-linking#adding-filters [example-server-props]: https://github.com/afterpay/sdk-example-server/blob/5781eadb25d7f5c5d872e754fdbb7214a8068008/src/routes/checkout.ts#L26-L27 [api-reference-props]: https://developers.afterpay.com/afterpay-online/reference/javascript-afterpayjs#redirect-method -[cash-button-docs]: https://cashapp-pay.stoplight.io/docs/api/technical-documentation/sdks/pay-kit/android-getting-started#cashpaykitbutton +[cash-button-docs]: https://developers.cash.app/docs/api/technical-documentation/sdks/pay-kit/android-getting-started#cashapppaybutton [create-checkout-endpoint-docs]: https://developers.afterpay.com/afterpay-online/reference/create-checkout-1 diff --git a/docs/installation.md b/docs/installation.md index 04ece40a..669b27eb 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -19,7 +19,7 @@ Add `afterpay-android` to your `build.gradle` dependencies. ``` gradle dependencies { - implementation 'com.afterpay:afterpay-android:4.4.0' + implementation 'com.afterpay:afterpay-android:4.5.0' } ``` diff --git a/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutFragment.kt b/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutFragment.kt index 026dc26f..ed83be33 100644 --- a/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutFragment.kt +++ b/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutFragment.kt @@ -221,7 +221,7 @@ class CheckoutFragment : Fragment() { when (validationResult) { is CashAppValidationResponse.Success -> { val responseData = CashData( - cashTag = customerResponseData.customerProfile?.cashTag ?: "unknown", + cashTag = customerResponseData.customerProfile?.cashTag?.toString() ?: "unknown", amount = ( grant.action.amount_cents?.toBigDecimal() ?.divide(centsDivisor.toBigDecimal()) diff --git a/example/src/main/res/layout/fragment_checkout.xml b/example/src/main/res/layout/fragment_checkout.xml index 0c863a76..e8fc8828 100644 --- a/example/src/main/res/layout/fragment_checkout.xml +++ b/example/src/main/res/layout/fragment_checkout.xml @@ -203,7 +203,8 @@ -