-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release 5.1.0 #1416
Release 5.1.0 #1416
Commits on Nov 10, 2023
-
Configuration menu - View commit details
-
Copy full SHA for c6e2a8a - Browse repository at this point
Copy the full SHA c6e2a8aView commit details -
Configuration menu - View commit details
-
Copy full SHA for b30a642 - Browse repository at this point
Copy the full SHA b30a642View commit details
Commits on Nov 13, 2023
-
Merge pull request #1388 from Adyen/fix/renovate_rebase
Do not rebase renovate PRs automatically
Configuration menu - View commit details
-
Copy full SHA for 4f80096 - Browse repository at this point
Copy the full SHA 4f80096View commit details -
Show card name instead of "Credit Card" on stored card payment compon…
…ent screen COAND-804
Configuration menu - View commit details
-
Copy full SHA for 2de5c55 - Browse repository at this point
Copy the full SHA 2de5c55View commit details -
Add overridePaymentMethodName method in DropInConfiguration
Add the necessary logic to override the name field of payment methods COAND-804
Configuration menu - View commit details
-
Copy full SHA for 39ecc10 - Browse repository at this point
Copy the full SHA 39ecc10View commit details -
Configuration menu - View commit details
-
Copy full SHA for 78daf08 - Browse repository at this point
Copy the full SHA 78daf08View commit details -
Modify overridePaymentMethodInformation implementation.
Add tests for overridePaymentMethodInformation function. COAND-804
Configuration menu - View commit details
-
Copy full SHA for 3e7d66a - Browse repository at this point
Copy the full SHA 3e7d66aView commit details -
Remove redundant DropInViewModelFactoryTest
Clean up code COAND-804
Configuration menu - View commit details
-
Copy full SHA for aaba2de - Browse repository at this point
Copy the full SHA aaba2deView commit details
Commits on Nov 14, 2023
-
COAND-804 diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 5ba0f46de..04bbf7767 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,21 +1,12 @@ [//]: # (This file will be used for the release notes on GitHub when publishing.) -[//]: # (Types of changes: `Added` `Changed` `Deprecated` `Removed` `Fixed` `Security`) +[//]: # (Types of changes: `Breaking changes` `New` `Added` `Changed` `Deprecated` `Removed` `Fixed`) [//]: # (Example:) [//]: # (## Added) [//]: # ( - New payment method) [//]: # (## Changed) [//]: # ( - DropIn service's package changed from `com.adyen.dropin` to `com.adyen.dropin.services`) -[//]: # ( # Deprecated) +[//]: # (## Deprecated) [//]: # ( - Configurations public constructor are deprecated, please use each Configuration's builder to make a Configuration object) -## Fixed -- `@RestrictTo` annotations no longer cause false errors with Android Studio and Lint. -- Using the layout inspector or having view attribute inspection enabled in the developer options no longer causes a crash when viewing a payment method. -- Implementing the `:action` module no longer gives a duplicate class error caused by a duplicate namespace. -- For Drop-in, dismissing the gift card payment method no longer prevents further interaction. - -## Changed -- Dependency versions: - | Name | Version | - |--------------------------------------------------------------------------------------------------------|-------------------------------| - | [AndroidX Compose BoM](https://developer.android.com/jetpack/compose/bom/bom-mapping) | **2023.09.01** | +## New +- You can now override payment method names in drop in by using `DropInConfiguration.Builder.overridePaymentMethodName(type, name)`
Configuration menu - View commit details
-
Copy full SHA for a4a090b - Browse repository at this point
Copy the full SHA a4a090bView commit details -
Configuration menu - View commit details
-
Copy full SHA for e44f359 - Browse repository at this point
Copy the full SHA e44f359View commit details -
Merge pull request #1380 from Adyen/feature/override_payment_method_n…
…ames_configuration_method Override payment method names
Configuration menu - View commit details
-
Copy full SHA for 9ebd55e - Browse repository at this point
Copy the full SHA 9ebd55eView commit details -
Configuration menu - View commit details
-
Copy full SHA for cf90737 - Browse repository at this point
Copy the full SHA cf90737View commit details -
Merge pull request #1357 from Adyen/renovate/compose_activity_version
Update dependency androidx.activity:activity-compose to v1.8.0
Configuration menu - View commit details
-
Copy full SHA for 889a25e - Browse repository at this point
Copy the full SHA 889a25eView commit details -
Configuration menu - View commit details
-
Copy full SHA for aeba138 - Browse repository at this point
Copy the full SHA aeba138View commit details -
Merge pull request #1361 from Adyen/renovate/major-json_version
Update dependency org.json:json to v20231013
Configuration menu - View commit details
-
Copy full SHA for 8b3db81 - Browse repository at this point
Copy the full SHA 8b3db81View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6188fd7 - Browse repository at this point
Copy the full SHA 6188fd7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8048b38 - Browse repository at this point
Copy the full SHA 8048b38View commit details -
Merge pull request #1359 from Adyen/renovate/material_version
Update dependency com.google.android.material:material to v1.10.0
Configuration menu - View commit details
-
Copy full SHA for 61eed42 - Browse repository at this point
Copy the full SHA 61eed42View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1cb0e30 - Browse repository at this point
Copy the full SHA 1cb0e30View commit details -
Configuration menu - View commit details
-
Copy full SHA for fec9115 - Browse repository at this point
Copy the full SHA fec9115View commit details
Commits on Nov 15, 2023
-
Merge pull request #1378 from Adyen/feature/overridable_analytics
Make it possible to override version and platform for analytics
Configuration menu - View commit details
-
Copy full SHA for f297f33 - Browse repository at this point
Copy the full SHA f297f33View commit details -
Configuration menu - View commit details
-
Copy full SHA for 57bdb02 - Browse repository at this point
Copy the full SHA 57bdb02View commit details -
Merge pull request #1358 from Adyen/renovate/gradle-8.x
Update dependency gradle to v8.4
Configuration menu - View commit details
-
Copy full SHA for f7d6dc5 - Browse repository at this point
Copy the full SHA f7d6dc5View commit details -
for consistency with the SDK and because analytics is a broader term than telemetry COAND-481
Configuration menu - View commit details
-
Copy full SHA for cd9ee7a - Browse repository at this point
Copy the full SHA cd9ee7aView commit details -
Merge pull request #1391 from Adyen/fix/telemetry_terminology
Rename telemetry to analytics
Configuration menu - View commit details
-
Copy full SHA for f07444a - Browse repository at this point
Copy the full SHA f07444aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 34f8435 - Browse repository at this point
Copy the full SHA 34f8435View commit details
Commits on Nov 16, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 7eee68d - Browse repository at this point
Copy the full SHA 7eee68dView commit details -
Merge pull request #1352 from Adyen/renovate/android_gradle_plugin_ve…
…rsion Update android_gradle_plugin_version to v8.1.2
Configuration menu - View commit details
-
Copy full SHA for ee30933 - Browse repository at this point
Copy the full SHA ee30933View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8a951a1 - Browse repository at this point
Copy the full SHA 8a951a1View commit details -
Merge pull request #1362 from Adyen/renovate/dokka_version
Update plugin org.jetbrains.dokka to v1.9.10
Configuration menu - View commit details
-
Copy full SHA for 958aafb - Browse repository at this point
Copy the full SHA 958aafbView commit details
Commits on Nov 17, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 8aadbd2 - Browse repository at this point
Copy the full SHA 8aadbd2View commit details
Commits on Nov 23, 2023
-
Merge pull request #1387 from Adyen/revert-1385-revert-1331-refactor/…
…bcmc Revert "Revert "Refactor BCMC""
Configuration menu - View commit details
-
Copy full SHA for 841aa78 - Browse repository at this point
Copy the full SHA 841aa78View commit details -
Configuration menu - View commit details
-
Copy full SHA for f722dc1 - Browse repository at this point
Copy the full SHA f722dc1View commit details -
Merge pull request #1392 from Adyen/fix/selected-card-index
Fix selected card index not being reset when a new card is detected
Configuration menu - View commit details
-
Copy full SHA for fe94d02 - Browse repository at this point
Copy the full SHA fe94d02View commit details -
Allow showing amounts as part of installment options
COAND-802 diff --git a/card/src/main/java/com/adyen/checkout/card/InstallmentConfiguration.kt b/card/src/main/java/com/adyen/checkout/card/InstallmentConfiguration.kt index 8ce139277..772177514 100644 --- a/card/src/main/java/com/adyen/checkout/card/InstallmentConfiguration.kt +++ b/card/src/main/java/com/adyen/checkout/card/InstallmentConfiguration.kt @@ -28,7 +28,8 @@ import kotlinx.parcelize.Parcelize @parcelize data class InstallmentConfiguration( val defaultOptions: InstallmentOptions.DefaultInstallmentOptions? = null, - val cardBasedOptions: List<InstallmentOptions.CardBasedInstallmentOptions> = emptyList() + val cardBasedOptions: List<InstallmentOptions.CardBasedInstallmentOptions> = emptyList(), + val showInstallmentAmount: Boolean = false ) : Parcelable { init { diff --git a/card/src/main/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapper.kt b/card/src/main/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapper.kt index 161279da9..726a6f57c 100644 --- a/card/src/main/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapper.kt +++ b/card/src/main/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapper.kt @@ -82,7 +82,11 @@ internal class CardComponentParamsMapper( isStorePaymentFieldVisible = isStorePaymentFieldVisible ?: true, socialSecurityNumberVisibility = socialSecurityNumberVisibility ?: SocialSecurityNumberVisibility.HIDE, kcpAuthVisibility = kcpAuthVisibility ?: KCPAuthVisibility.HIDE, - installmentParams = installmentsParamsMapper.mapToInstallmentParams(installmentConfiguration), + installmentParams = installmentsParamsMapper.mapToInstallmentParams( + installmentConfiguration = installmentConfiguration, + amount = amount, + shopperLocale = shopperLocale + ), addressParams = addressConfiguration?.mapToAddressParam() ?: AddressParams.None, cvcVisibility = if (isHideCvc == true) { CVCVisibility.ALWAYS_HIDE @@ -192,7 +196,11 @@ internal class CardComponentParamsMapper( // we don't fall back to the original value of installmentParams value on purpose // if sessionParams.installmentOptions is null we want installmentParams to be also null regardless of what // InstallmentConfiguration is passed to the mapper - installmentParams = installmentsParamsMapper.mapToInstallmentParams(sessionParams.installmentOptions), + installmentParams = installmentsParamsMapper.mapToInstallmentParams( + installmentConfiguration = sessionParams.installmentConfiguration, + amount = sessionParams.amount ?: amount, + shopperLocale = shopperLocale + ), amount = sessionParams.amount ?: amount, ) } diff --git a/card/src/main/java/com/adyen/checkout/card/internal/ui/model/InstallmentParams.kt b/card/src/main/java/com/adyen/checkout/card/internal/ui/model/InstallmentParams.kt index 972ad8476..f08be8860 100644 --- a/card/src/main/java/com/adyen/checkout/card/internal/ui/model/InstallmentParams.kt +++ b/card/src/main/java/com/adyen/checkout/card/internal/ui/model/InstallmentParams.kt @@ -10,6 +10,8 @@ package com.adyen.checkout.card.internal.ui.model import androidx.annotation.RestrictTo import com.adyen.checkout.card.CardBrand +import com.adyen.checkout.components.core.Amount +import java.util.Locale /** * Component params class for Installments in Card Component. This class can be used @@ -26,5 +28,8 @@ import com.adyen.checkout.card.CardBrand @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class InstallmentParams( val defaultOptions: InstallmentOptionParams.DefaultInstallmentOptions? = null, - val cardBasedOptions: List<InstallmentOptionParams.CardBasedInstallmentOptions> = emptyList() + val cardBasedOptions: List<InstallmentOptionParams.CardBasedInstallmentOptions> = emptyList(), + val amount: Amount? = null, + val shopperLocale: Locale? = null, + val showInstallmentAmount: Boolean = false ) diff --git a/card/src/main/java/com/adyen/checkout/card/internal/ui/model/InstallmentsParamsMapper.kt b/card/src/main/java/com/adyen/checkout/card/internal/ui/model/InstallmentsParamsMapper.kt index dba72902b..bf942d01b 100644 --- a/card/src/main/java/com/adyen/checkout/card/internal/ui/model/InstallmentsParamsMapper.kt +++ b/card/src/main/java/com/adyen/checkout/card/internal/ui/model/InstallmentsParamsMapper.kt @@ -11,35 +11,54 @@ package com.adyen.checkout.card.internal.ui.model import com.adyen.checkout.card.CardBrand import com.adyen.checkout.card.InstallmentConfiguration import com.adyen.checkout.card.InstallmentOptions +import com.adyen.checkout.components.core.Amount +import com.adyen.checkout.components.core.internal.ui.model.SessionInstallmentConfiguration import com.adyen.checkout.components.core.internal.ui.model.SessionInstallmentOptionsParams +import java.util.Locale internal class InstallmentsParamsMapper { internal fun mapToInstallmentParams( - sessionInstallmentOptions: Map<String, SessionInstallmentOptionsParams?>? + installmentConfiguration: SessionInstallmentConfiguration?, + amount: Amount?, + shopperLocale: Locale? ): InstallmentParams? { - sessionInstallmentOptions ?: return null + installmentConfiguration?.installmentOptions ?: return null + + val showInstallmentAmount = installmentConfiguration.showInstallmentAmount ?: false var defaultOptions: InstallmentOptionParams.DefaultInstallmentOptions? = null val cardBasedOptionsList = mutableListOf<InstallmentOptionParams.CardBasedInstallmentOptions>() - sessionInstallmentOptions.forEach { (key, value) -> + installmentConfiguration.installmentOptions?.forEach { (key, value) -> if (key == DEFAULT_INSTALLMENT_OPTION) { defaultOptions = value.mapToDefaultInstallmentOptions() } else { cardBasedOptionsList.add(value.mapToCardBasedInstallmentOptions(key)) } } - return InstallmentParams(defaultOptions, cardBasedOptionsList) + + return InstallmentParams( + defaultOptions = defaultOptions, + cardBasedOptions = cardBasedOptionsList, + amount = amount, + shopperLocale = shopperLocale, + showInstallmentAmount = showInstallmentAmount + ) } internal fun mapToInstallmentParams( - installmentConfiguration: InstallmentConfiguration? + installmentConfiguration: InstallmentConfiguration?, + amount: Amount?, + shopperLocale: Locale? ): InstallmentParams? { installmentConfiguration ?: return null return InstallmentParams( defaultOptions = installmentConfiguration.defaultOptions?.mapToDefaultInstallmentOptionsParam(), cardBasedOptions = installmentConfiguration.cardBasedOptions.map { option -> option.mapToCardBasedInstallmentOptionsParams() - } + }, + amount = amount, + shopperLocale = shopperLocale, + showInstallmentAmount = installmentConfiguration.showInstallmentAmount ) } diff --git a/card/src/main/java/com/adyen/checkout/card/internal/ui/view/InstallmentListAdapter.kt b/card/src/main/java/com/adyen/checkout/card/internal/ui/view/InstallmentListAdapter.kt index 74415926a..1b34b4f23 100644 --- a/card/src/main/java/com/adyen/checkout/card/internal/ui/view/InstallmentListAdapter.kt +++ b/card/src/main/java/com/adyen/checkout/card/internal/ui/view/InstallmentListAdapter.kt @@ -21,6 +21,8 @@ import androidx.recyclerview.widget.RecyclerView import com.adyen.checkout.card.databinding.InstallmentViewBinding import com.adyen.checkout.card.internal.ui.model.InstallmentOption import com.adyen.checkout.card.internal.util.InstallmentUtils +import com.adyen.checkout.components.core.Amount +import java.util.Locale // We need context to inflate the views and localizedContext to fetch the strings @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @@ -69,8 +71,11 @@ internal class InstallmentListAdapter( @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class InstallmentModel( @StringRes val textResId: Int, - val value: Int?, - val option: InstallmentOption + val monthValue: Int?, + val option: InstallmentOption, + val amount: Amount?, + val shopperLocale: Locale?, + val showAmount: Boolean ) internal class InstallmentFilter( diff --git a/card/src/main/java/com/adyen/checkout/card/internal/util/InstallmentUtils.kt b/card/src/main/java/com/adyen/checkout/card/internal/util/InstallmentUtils.kt index 2e0f33767..9fc6ee733 100644 --- a/card/src/main/java/com/adyen/checkout/card/internal/util/InstallmentUtils.kt +++ b/card/src/main/java/com/adyen/checkout/card/internal/util/InstallmentUtils.kt @@ -17,10 +17,14 @@ import com.adyen.checkout.card.internal.ui.model.InstallmentOption import com.adyen.checkout.card.internal.ui.model.InstallmentOptionParams import com.adyen.checkout.card.internal.ui.model.InstallmentParams import com.adyen.checkout.card.internal.ui.view.InstallmentModel +import com.adyen.checkout.components.core.Amount import com.adyen.checkout.components.core.Installments +import com.adyen.checkout.components.core.internal.util.CurrencyUtils +import java.util.Locale private const val REVOLVING_INSTALLMENT_VALUE = 1 +// TODO: Add tests internal object InstallmentUtils { /** @@ -39,41 +43,72 @@ internal object InstallmentUtils { return when { hasOptionsForCardType -> { - makeInstallmentModelList(params?.cardBasedOptions?.firstOrNull { it.cardBrand == cardBrand }) + makeInstallmentModelList( + installmentOptions = params?.cardBasedOptions?.firstOrNull { it.cardBrand == cardBrand }, + amount = params?.amount, + shopperLocale = params?.shopperLocale, + showAmount = params?.showInstallmentAmount ?: false + ) } + hasDefaultInstallmentOptions -> { - makeInstallmentModelList(params?.defaultOptions) + makeInstallmentModelList( + installmentOptions = params?.defaultOptions, + amount = params?.amount, + shopperLocale = params?.shopperLocale, + showAmount = params?.showInstallmentAmount ?: false + ) } + else -> { emptyList() } } } - private fun makeInstallmentModelList(installmentOptions: InstallmentOptionParams?): List<InstallmentModel> { + private fun makeInstallmentModelList( + installmentOptions: InstallmentOptionParams?, + amount: Amount?, + shopperLocale: Locale?, + showAmount: Boolean + ): List<InstallmentModel> { if (installmentOptions == null) return emptyList() val installmentOptionsList = mutableListOf<InstallmentModel>() val oneTimeOption = InstallmentModel( textResId = R.string.checkout_card_installments_option_one_time, - value = null, - option = InstallmentOption.ONE_TIME + monthValue = null, + option = InstallmentOption.ONE_TIME, + amount = amount, + shopperLocale = shopperLocale, + showAmount = showAmount ) installmentOptionsList.add(oneTimeOption) if (installmentOptions.includeRevolving) { val revolvingOption = InstallmentModel( textResId = R.string.checkout_card_installments_option_revolving, - value = REVOLVING_INSTALLMENT_VALUE, - option = InstallmentOption.REVOLVING + monthValue = REVOLVING_INSTALLMENT_VALUE, + option = InstallmentOption.REVOLVING, + amount = amount, + shopperLocale = shopperLocale, + showAmount = showAmount ) installmentOptionsList.add(revolvingOption) } + val regularOptionTextResId = if (showAmount && amount != null && shopperLocale != null) { + R.string.checkout_card_installments_option_regular_with_price + } else { + R.string.checkout_card_installments_option_regular + } val regularOptions = installmentOptions.values.map { InstallmentModel( - textResId = R.string.checkout_card_installments_option_regular, - value = it, - option = InstallmentOption.REGULAR + textResId = regularOptionTextResId, + monthValue = it, + option = InstallmentOption.REGULAR, + amount = amount, + shopperLocale = shopperLocale, + showAmount = showAmount ) } installmentOptionsList.addAll(regularOptions) @@ -83,13 +118,24 @@ internal object InstallmentUtils { /** * Get the text to be shown for different types of [InstallmentOption]. */ - fun getTextForInstallmentOption(context: Context, installmentModel: InstallmentModel?): String { - return when (installmentModel?.option) { - InstallmentOption.REGULAR -> context.getString(installmentModel.textResId, installmentModel.value) - InstallmentOption.REVOLVING, InstallmentOption.ONE_TIME -> context.getString(installmentModel.textResId) - else -> "" + fun getTextForInstallmentOption(context: Context, installmentModel: InstallmentModel?): String = + with(installmentModel) { + return when (this?.option) { + InstallmentOption.REGULAR -> { + val monthValue = monthValue ?: 1 + val installmentAmount = amount?.copy(value = amount.value / monthValue) + if (installmentAmount != null && shopperLocale != null) { + val formattedAmount = CurrencyUtils.formatAmount(installmentAmount, shopperLocale) + context.getString(textResId, monthValue, formattedAmount) + } else { + context.getString(textResId, monthValue) + } + } + + InstallmentOption.REVOLVING, InstallmentOption.ONE_TIME -> context.getString(textResId) + else -> "" + } } - } /** * Populate the [Installments] model object from [InstallmentModel]. @@ -97,8 +143,9 @@ internal object InstallmentUtils { fun makeInstallmentModelObject(installmentModel: InstallmentModel?): Installments? { return when (installmentModel?.option) { InstallmentOption.REGULAR, InstallmentOption.REVOLVING -> { - Installments(installmentModel.option.type, installmentModel.value) + Installments(installmentModel.option.type, installmentModel.monthValue) } + else -> null } } diff --git a/card/src/main/res/values/strings.xml b/card/src/main/res/values/strings.xml index 40af545e9..6bac9728e 100644 --- a/card/src/main/res/values/strings.xml +++ b/card/src/main/res/values/strings.xml @@ -32,6 +32,7 @@ <string name="checkout_card_installments_title">Number of installments</string> <string name="checkout_card_installments_option_regular">%s months</string> + <string name="checkout_card_installments_option_regular_with_price">%1$sx %2$s</string> <string name="checkout_card_installments_option_one_time">One time payment</string> <string name="checkout_card_installments_option_revolving">Revolving payment</string> diff --git a/card/src/test/java/com/adyen/checkout/card/internal/ui/DefaultCardDelegateTest.kt b/card/src/test/java/com/adyen/checkout/card/internal/ui/DefaultCardDelegateTest.kt index 67c472432..5ba566b94 100644 --- a/card/src/test/java/com/adyen/checkout/card/internal/ui/DefaultCardDelegateTest.kt +++ b/card/src/test/java/com/adyen/checkout/card/internal/ui/DefaultCardDelegateTest.kt @@ -566,8 +566,11 @@ internal class DefaultCardDelegateTest( delegate.outputDataFlow.test { val installmentModel = InstallmentModel( textResId = R.string.checkout_card_installments_option_revolving, - value = 1, - option = InstallmentOption.REVOLVING + monthValue = 1, + option = InstallmentOption.REVOLVING, + amount = null, + shopperLocale = null, + showAmount = false ) delegate.updateInputData { @@ -806,8 +809,11 @@ internal class DefaultCardDelegateTest( val addressUIState = AddressFormUIState.FULL_ADDRESS val installmentModel = InstallmentModel( textResId = R.string.checkout_card_installments_option_revolving, - value = 1, - option = InstallmentOption.REVOLVING + monthValue = 1, + option = InstallmentOption.REVOLVING, + amount = null, + shopperLocale = null, + showAmount = false ) val detectedCardTypes = listOf( diff --git a/card/src/test/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapperTest.kt b/card/src/test/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapperTest.kt index 55415eaf4..73da3b714 100644 --- a/card/src/test/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapperTest.kt +++ b/card/src/test/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapperTest.kt @@ -21,6 +21,7 @@ import com.adyen.checkout.components.core.PaymentMethod import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParams import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParamsLevel import com.adyen.checkout.components.core.internal.ui.model.GenericComponentParams +import com.adyen.checkout.components.core.internal.ui.model.SessionInstallmentConfiguration import com.adyen.checkout.components.core.internal.ui.model.SessionInstallmentOptionsParams import com.adyen.checkout.components.core.internal.ui.model.SessionParams import com.adyen.checkout.core.Environment @@ -59,10 +60,11 @@ internal class CardComponentParamsMapperTest { ) ) val expectedInstallmentParams = InstallmentParams( - InstallmentOptionParams.DefaultInstallmentOptions( + defaultOptions = InstallmentOptionParams.DefaultInstallmentOptions( values = listOf(2, 3), includeRevolving = true - ) + ), + shopperLocale = Locale.FRANCE ) val addressConfiguration = AddressConfiguration.FullAddress(supportedCountryCodes = listOf("CA", "GB")) @@ -270,7 +272,7 @@ internal class CardComponentParamsMapperTest { PaymentMethod(), sessionParams = SessionParams( enableStoreDetails = sessionsValue, - installmentOptions = null, + installmentConfiguration = null, amount = null, returnUrl = "", ) @@ -301,7 +303,7 @@ internal class CardComponentParamsMapperTest { PaymentMethod(), sessionParams = SessionParams( enableStoreDetails = null, - installmentOptions = null, + installmentConfiguration = null, amount = null, returnUrl = "", ) @@ -316,10 +318,21 @@ internal class CardComponentParamsMapperTest { @test fun `installmentParams should match value set in sessions`() { + val installmentOptions = mapOf( + "card" to SessionInstallmentOptionsParams( + plans = listOf("regular"), + preselectedValue = 2, + values = listOf(2) + ) + ) + val installmentConfiguration = SessionInstallmentConfiguration( + installmentOptions = installmentOptions, + showInstallmentAmount = false + ) val cardConfiguration = getCardConfigurationBuilder() .setInstallmentConfigurations( InstallmentConfiguration( - InstallmentOptions.DefaultInstallmentOptions( + defaultOptions = InstallmentOptions.DefaultInstallmentOptions( maxInstallments = 3, includeRevolving = true ) @@ -327,13 +340,6 @@ internal class CardComponentParamsMapperTest { ) .build() - val installmentOptions = mapOf( - "card" to SessionInstallmentOptionsParams( - plans = listOf("regular"), - preselectedValue = 2, - values = listOf(2) - ) - ) val mapper = InstallmentsParamsMapper() val params = CardComponentParamsMapper(mapper, null, null).mapToParamsDefault( @@ -341,14 +347,18 @@ internal class CardComponentParamsMapperTest { PaymentMethod(), sessionParams = SessionParams( enableStoreDetails = null, - installmentOptions = installmentOptions, + installmentConfiguration = installmentConfiguration, amount = null, returnUrl = "", ) ) val expected = getCardComponentParams( - installmentParams = mapper.mapToInstallmentParams(installmentOptions) + installmentParams = mapper.mapToInstallmentParams( + installmentConfiguration = installmentConfiguration, + amount = cardConfiguration.amount, + shopperLocale = cardConfiguration.shopperLocale + ) ) assertEquals(expected, params) @@ -375,7 +385,11 @@ internal class CardComponentParamsMapperTest { ) val expected = getCardComponentParams( - installmentParams = mapper.mapToInstallmentParams(installmentConfiguration) + installmentParams = mapper.mapToInstallmentParams( + installmentConfiguration = installmentConfiguration, + amount = cardConfiguration.amount, + shopperLocale = cardConfiguration.shopperLocale + ) ) assertEquals(expected, params) @@ -419,7 +433,7 @@ internal class CardComponentParamsMapperTest { PaymentMethod(), sessionParams = SessionParams( enableStoreDetails = null, - installmentOptions = null, + installmentConfiguration = null, amount = sessionsValue, returnUrl = "", ) diff --git a/card/src/test/java/com/adyen/checkout/card/internal/ui/model/InstallmentParamsMapperTest.kt b/card/src/test/java/com/adyen/checkout/card/internal/ui/model/InstallmentParamsMapperTest.kt index 478da532b..030ddda05 100644 --- a/card/src/test/java/com/adyen/checkout/card/internal/ui/model/InstallmentParamsMapperTest.kt +++ b/card/src/test/java/com/adyen/checkout/card/internal/ui/model/InstallmentParamsMapperTest.kt @@ -12,43 +12,62 @@ import com.adyen.checkout.card.CardBrand import com.adyen.checkout.card.CardType import com.adyen.checkout.card.InstallmentConfiguration import com.adyen.checkout.card.InstallmentOptions +import com.adyen.checkout.components.core.Amount +import com.adyen.checkout.components.core.internal.ui.model.SessionInstallmentConfiguration import com.adyen.checkout.components.core.internal.ui.model.SessionInstallmentOptionsParams import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test +import java.util.Locale internal class InstallmentParamsMapperTest { private val installmentsParamsMapper: InstallmentsParamsMapper = InstallmentsParamsMapper() + private val amount = Amount("EUR", 100) + private val shopperLocale = Locale.US + private val showInstallmentAmount = true @test fun `when session setup installment option is default then installment params should be the same `() { - val sessionSetupInstallmentOptionsMap = mapOf( - DEFAULT_INSTALLMENT_OPTION to SessionInstallmentOptionsParams( - plans = listOf(INSTALLMENT_PLAN), - preselectedValue = 2, - values = listOf(2) - ) + val sessionSetupInstallmentOptionsMap = SessionInstallmentConfiguration( + installmentOptions = mapOf( + DEFAULT_INSTALLMENT_OPTION to SessionInstallmentOptionsParams( + plans = listOf(INSTALLMENT_PLAN), + preselectedValue = 2, + values = listOf(2) + ) + ), + showInstallmentAmount = showInstallmentAmount ) val expectedInstallmentParams = InstallmentParams( - InstallmentOptionParams.DefaultInstallmentOptions( + defaultOptions = InstallmentOptionParams.DefaultInstallmentOptions( values = listOf(2), includeRevolving = false - ) + ), + amount = amount, + shopperLocale = shopperLocale, + showInstallmentAmount = showInstallmentAmount ) - val actualInstallmentParams = installmentsParamsMapper.mapToInstallmentParams(sessionSetupInstallmentOptionsMap) + val actualInstallmentParams = installmentsParamsMapper.mapToInstallmentParams( + installmentConfiguration = sessionSetupInstallmentOptionsMap, + amount = amount, + shopperLocale = shopperLocale + ) assertEquals(expectedInstallmentParams, actualInstallmentParams) } @test fun `when session setup installment option is card based then installment params should be the same `() { - val sessionSetupInstallmentOptionsMap = mapOf( - CardType.VISA.txVariant to SessionInstallmentOptionsParams( - plans = listOf(INSTALLMENT_PLAN), - preselectedValue = 2, - values = listOf(2) - ) + val sessionSetupInstallmentOptionsMap = SessionInstallmentConfiguration( + installmentOptions = mapOf( + CardType.VISA.txVariant to SessionInstallmentOptionsParams( + plans = listOf(INSTALLMENT_PLAN), + preselectedValue = 2, + values = listOf(2) + ) + ), + showInstallmentAmount = showInstallmentAmount ) val expectedInstallmentParams = InstallmentParams( cardBasedOptions = listOf( @@ -57,10 +76,17 @@ internal class InstallmentParamsMapperTest { includeRevolving = false, cardBrand = CardBrand(CardType.VISA) ) - ) + ), + amount = amount, + shopperLocale = shopperLocale, + showInstallmentAmount = showInstallmentAmount ) - val actualInstallmentParams = installmentsParamsMapper.mapToInstallmentParams(sessionSetupInstallmentOptionsMap) + val actualInstallmentParams = installmentsParamsMapper.mapToInstallmentParams( + installmentConfiguration = sessionSetupInstallmentOptionsMap, + amount = amount, + shopperLocale = shopperLocale + ) assertEquals(expectedInstallmentParams, actualInstallmentParams) } @@ -71,17 +97,25 @@ internal class InstallmentParamsMapperTest { defaultOptions = InstallmentOptions.DefaultInstallmentOptions( values = listOf(2), includeRevolving = false - ) + ), + showInstallmentAmount = showInstallmentAmount ) val expectedInstallmentParams = InstallmentParams( defaultOptions = InstallmentOptionParams.DefaultInstallmentOptions( values = listOf(2), includeRevolving = false - ) + ), + amount = amount, + shopperLocale = shopperLocale, + showInstallmentAmount = showInstallmentAmount ) - val actualInstallmentParams = installmentsParamsMapper.mapToInstallmentParams(installmentConfiguration) + val actualInstallmentParams = installmentsParamsMapper.mapToInstallmentParams( + installmentConfiguration = installmentConfiguration, + amount = amount, + shopperLocale = shopperLocale + ) assertEquals(expectedInstallmentParams, actualInstallmentParams) } @@ -95,7 +129,8 @@ internal class InstallmentParamsMapperTest { includeRevolving = false, cardBrand = CardBrand(CardType.VISA) ) - ) + ), + showInstallmentAmount = showInstallmentAmount ) val expectedInstallmentParams = InstallmentParams( @@ -105,10 +140,17 @@ internal class InstallmentParamsMapperTest { includeRevolving = false, cardBrand = CardBrand(CardType.VISA) ) - ) + ), + amount = amount, + shopperLocale = shopperLocale, + showInstallmentAmount = showInstallmentAmount ) - val actualInstallmentParams = installmentsParamsMapper.mapToInstallmentParams(installmentConfiguration) + val actualInstallmentParams = installmentsParamsMapper.mapToInstallmentParams( + installmentConfiguration = installmentConfiguration, + amount = amount, + shopperLocale = shopperLocale + ) assertEquals(expectedInstallmentParams, actualInstallmentParams) } diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/SessionInstallmentConfiguration.kt b/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/SessionInstallmentConfiguration.kt new file mode 100644 index 000000000..0dee0c993 --- /dev/null +++ b/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/SessionInstallmentConfiguration.kt @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023 Adyen N.V. + * + * This file is open source and available under the MIT license. See the LICENSE file for more info. + * + * Created by ararat on 15/11/2023. + */ + +package com.adyen.checkout.components.core.internal.ui.model + +import androidx.annotation.RestrictTo + +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +data class SessionInstallmentConfiguration( + val installmentOptions: Map<String, SessionInstallmentOptionsParams?>?, + val showInstallmentAmount: Boolean? +) diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/SessionParams.kt b/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/SessionParams.kt index 2ac257dc3..8370d89d3 100644 --- a/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/SessionParams.kt +++ b/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/SessionParams.kt @@ -14,7 +14,7 @@ import com.adyen.checkout.components.core.Amount @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class SessionParams( val enableStoreDetails: Boolean?, - val installmentOptions: Map<String, SessionInstallmentOptionsParams?>?, + val installmentConfiguration: SessionInstallmentConfiguration?, val amount: Amount?, val returnUrl: String?, ) diff --git a/example-app/src/main/java/com/adyen/checkout/example/data/api/model/SessionRequest.kt b/example-app/src/main/java/com/adyen/checkout/example/data/api/model/SessionRequest.kt index 683571140..ff1855f4c 100644 --- a/example-app/src/main/java/com/adyen/checkout/example/data/api/model/SessionRequest.kt +++ b/example-app/src/main/java/com/adyen/checkout/example/data/api/model/SessionRequest.kt @@ -32,5 +32,6 @@ data class SessionRequest( val allowedPaymentMethods: List<String>?, val storePaymentMethodMode: String?, val recurringProcessingModel: String?, - val installmentOptions: Map<String, SessionSetupInstallmentOptions>? + val installmentOptions: Map<String, SessionSetupInstallmentOptions>?, + val showInstallmentAmount: Boolean ) diff --git a/example-app/src/main/java/com/adyen/checkout/example/data/storage/KeyValueStorage.kt b/example-app/src/main/java/com/adyen/checkout/example/data/storage/KeyValueStorage.kt index 4c783f09a..255bd15b8 100644 --- a/example-app/src/main/java/com/adyen/checkout/example/data/storage/KeyValueStorage.kt +++ b/example-app/src/main/java/com/adyen/checkout/example/data/storage/KeyValueStorage.kt @@ -32,6 +32,7 @@ interface KeyValueStorage { fun getCardAddressMode(): CardAddressMode fun getInstantPaymentMethodType(): String fun getInstallmentOptionsMode(): CardInstallmentOptionsMode + fun isInstallmentAmountShown(): Boolean fun useSessions(): Boolean fun setUseSessions(useSessions: Boolean) fun getAnalyticsLevel(): AnalyticsLevel @@ -150,6 +151,12 @@ internal class DefaultKeyValueStorage( ) } + override fun isInstallmentAmountShown() = sharedPreferences.getBoolean( + appContext = appContext, + stringRes = R.string.card_installment_show_amount_key, + defaultStringRes = R.string.preferences_default_installment_amount_shown, + ) + override fun useSessions(): Boolean { return sharedPreferences.getBoolean( appContext = appContext, diff --git a/example-app/src/main/java/com/adyen/checkout/example/service/RequestUtils.kt b/example-app/src/main/java/com/adyen/checkout/example/service/RequestUtils.kt index 83be3db1b..53a40a0ae 100644 --- a/example-app/src/main/java/com/adyen/checkout/example/service/RequestUtils.kt +++ b/example-app/src/main/java/com/adyen/checkout/example/service/RequestUtils.kt @@ -63,6 +63,7 @@ fun getSessionRequest( isThreeds2Enabled: Boolean, isExecuteThreeD: Boolean, installmentOptions: Map<String, SessionSetupInstallmentOptions>?, + showInstallmentAmount: Boolean = false, threeDSAuthenticationOnly: Boolean = false, shopperEmail: String? = null, allowedPaymentMethods: List<String>? = null, @@ -89,7 +90,8 @@ fun getSessionRequest( allowedPaymentMethods = allowedPaymentMethods, storePaymentMethodMode = storePaymentMethodMode, recurringProcessingModel = recurringProcessingModel, - installmentOptions = installmentOptions + installmentOptions = installmentOptions, + showInstallmentAmount = showInstallmentAmount ) } diff --git a/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardTakenOverViewModel.kt b/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardTakenOverViewModel.kt index 23837213d..04ecdcb2e 100644 --- a/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardTakenOverViewModel.kt +++ b/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardTakenOverViewModel.kt @@ -114,7 +114,8 @@ internal class SessionsCardTakenOverViewModel @Inject constructor( ?: error("Return url should be set"), shopperEmail = keyValueStorage.getShopperEmail(), allowedPaymentMethods = listOf(paymentMethodType), - installmentOptions = getSettingsInstallmentOptionsMode(keyValueStorage.getInstallmentOptionsMode()) + installmentOptions = getSettingsInstallmentOptionsMode(keyValueStorage.getInstallmentOptionsMode()), + showInstallmentAmount = keyValueStorage.isInstallmentAmountShown() ) ) ?: return null diff --git a/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardViewModel.kt b/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardViewModel.kt index df7df890a..df35a851e 100644 --- a/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardViewModel.kt +++ b/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardViewModel.kt @@ -101,7 +101,8 @@ internal class SessionsCardViewModel @Inject constructor( ?: error("Return url should be set"), shopperEmail = keyValueStorage.getShopperEmail(), allowedPaymentMethods = listOf(paymentMethodType), - installmentOptions = getSettingsInstallmentOptionsMode(keyValueStorage.getInstallmentOptionsMode()) + installmentOptions = getSettingsInstallmentOptionsMode(keyValueStorage.getInstallmentOptionsMode()), + showInstallmentAmount = keyValueStorage.isInstallmentAmountShown() ) ) ?: return null diff --git a/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt b/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt index d06d56ee7..7ddf84f76 100644 --- a/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt +++ b/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt @@ -163,10 +163,11 @@ internal class CheckoutConfigurationProvider @Inject constructor( maxInstallments: Int = 3, includeRevolving: Boolean = false ) = InstallmentConfiguration( - InstallmentOptions.DefaultInstallmentOptions( + defaultOptions = InstallmentOptions.DefaultInstallmentOptions( maxInstallments = maxInstallments, includeRevolving = includeRevolving - ) + ), + showInstallmentAmount = keyValueStorage.isInstallmentAmountShown() ) private fun getCardBasedInstallmentOptions( @@ -180,6 +181,7 @@ internal class CheckoutConfigurationProvider @Inject constructor( includeRevolving = includeRevolving, cardBrand = cardBrand ) - ) + ), + showInstallmentAmount = keyValueStorage.isInstallmentAmountShown() ) } diff --git a/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainViewModel.kt b/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainViewModel.kt index 0309c9322..a0742596e 100644 --- a/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainViewModel.kt +++ b/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainViewModel.kt @@ -167,7 +167,8 @@ internal class MainViewModel @Inject constructor( redirectUrl = savedStateHandle.get<String>(MainActivity.RETURN_URL_EXTRA) ?: error("Return url should be set"), shopperEmail = keyValueStorage.getShopperEmail(), - installmentOptions = getSettingsInstallmentOptionsMode(keyValueStorage.getInstallmentOptionsMode()) + installmentOptions = getSettingsInstallmentOptionsMode(keyValueStorage.getInstallmentOptionsMode()), + showInstallmentAmount = keyValueStorage.isInstallmentAmountShown() ) ) ?: return null diff --git a/example-app/src/main/res/values/strings.xml b/example-app/src/main/res/values/strings.xml index 37ccb9d45..16fe88174 100644 --- a/example-app/src/main/res/values/strings.xml +++ b/example-app/src/main/res/values/strings.xml @@ -54,6 +54,8 @@ <string name="card_address_form_mode_key">card_address_form_mode</string> <string name="card_installment_options_mode_title">Installment options</string> <string name="card_installment_options_mode_key">card_installment_options_mode</string> + <string name="card_installment_show_amount_key">card_installment_show_amount</string> + <string name="card_installment_show_amount_title">Show installment amount</string> <string name="card_address_form_title">Address mode</string> <string name="instant_payment_method_type_key">instant_payment_method_type</string> <string name="instant_payment_method_type_title">Instant Payment Method Type</string> @@ -83,6 +85,7 @@ <string name="preferences_default_split_card_funding_sources">false</string> <string name="preferences_default_address_form_mode">NONE</string> <string name="preferences_default_installment_options_mode">NONE</string> + <string name="preferences_default_installment_amount_shown">false</string> <string name="preferences_default_instant_payment_method">wechatpaySDK</string> <string name="preferences_default_use_sessions">true</string> <string name="preferences_default_analytics_level">ALL</string> diff --git a/example-app/src/main/res/xml/preferences.xml b/example-app/src/main/res/xml/preferences.xml index f8ca721d1..88b84188d 100644 --- a/example-app/src/main/res/xml/preferences.xml +++ b/example-app/src/main/res/xml/preferences.xml @@ -88,6 +88,11 @@ android:title="@string/card_installment_options_mode_title" app:useSimpleSummaryProvider="true" /> + <SwitchPreference + android:defaultValue="@string/preferences_default_split_card_funding_sources" + android:key="@string/card_installment_show_amount_key" + android:title="@string/card_installment_show_amount_title" /> + <SwitchPreference android:defaultValue="@string/preferences_default_split_card_funding_sources" android:key="@string/split_card_funding_sources_key" diff --git a/sessions-core/src/main/java/com/adyen/checkout/sessions/core/SessionSetupConfiguration.kt b/sessions-core/src/main/java/com/adyen/checkout/sessions/core/SessionSetupConfiguration.kt index 487a0322f..ecb2a6133 100644 --- a/sessions-core/src/main/java/com/adyen/checkout/sessions/core/SessionSetupConfiguration.kt +++ b/sessions-core/src/main/java/com/adyen/checkout/sessions/core/SessionSetupConfiguration.kt @@ -18,11 +18,13 @@ import org.json.JSONObject @parcelize data class SessionSetupConfiguration( val enableStoreDetails: Boolean? = null, + val showInstallmentAmount: Boolean = false, val installmentOptions: Map<String, SessionSetupInstallmentOptions?>? = null ) : ModelObject() { companion object { private const val ENABLE_STORE_DETAILS = "enableStoreDetails" + private const val SHOW_INSTALLMENT_AMOUNT = "showInstallmentAmount" private const val INSTALLMENT_OPTIONS = "installmentOptions" @JvmField @@ -31,6 +33,7 @@ data class SessionSetupConfiguration( return try { JSONObject().apply { putOpt(ENABLE_STORE_DETAILS, modelObject.enableStoreDetails) + putOpt(SHOW_INSTALLMENT_AMOUNT, modelObject.showInstallmentAmount) putOpt( INSTALLMENT_OPTIONS, modelObject.installmentOptions?.let { JSONObject(it) } @@ -45,6 +48,7 @@ data class SessionSetupConfiguration( return try { SessionSetupConfiguration( enableStoreDetails = jsonObject.optBoolean(ENABLE_STORE_DETAILS), + showInstallmentAmount = jsonObject.optBoolean(SHOW_INSTALLMENT_AMOUNT), installmentOptions = jsonObject.optJSONObject(INSTALLMENT_OPTIONS) ?.jsonToMap(SessionSetupInstallmentOptions.SERIALIZER) ) diff --git a/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/ui/model/SessionParamsFactory.kt b/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/ui/model/SessionParamsFactory.kt index 5fcf5163c..0bd517168 100644 --- a/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/ui/model/SessionParamsFactory.kt +++ b/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/ui/model/SessionParamsFactory.kt @@ -10,6 +10,7 @@ package com.adyen.checkout.sessions.core.internal.ui.model import androidx.annotation.RestrictTo import com.adyen.checkout.components.core.Amount +import com.adyen.checkout.components.core.internal.ui.model.SessionInstallmentConfiguration import com.adyen.checkout.components.core.internal.ui.model.SessionInstallmentOptionsParams import com.adyen.checkout.components.core.internal.ui.model.SessionParams import com.adyen.checkout.sessions.core.CheckoutSession @@ -39,13 +40,16 @@ object SessionParamsFactory { ): SessionParams { return SessionParams( enableStoreDetails = sessionSetupConfiguration?.enableStoreDetails, - installmentOptions = sessionSetupConfiguration?.installmentOptions?.map { - it.key to SessionInstallmentOptionsParams( - plans = it.value?.plans, - preselectedValue = it.value?.preselectedValue, - values = it.value?.values, - ) - }?.toMap(), + installmentConfiguration = SessionInstallmentConfiguration( + installmentOptions = sessionSetupConfiguration?.installmentOptions?.map { + it.key to SessionInstallmentOptionsParams( + plans = it.value?.plans, + preselectedValue = it.value?.preselectedValue, + values = it.value?.values, + ) + }?.toMap(), + showInstallmentAmount = sessionSetupConfiguration?.showInstallmentAmount + ), amount = amount, returnUrl = returnUrl, )
Configuration menu - View commit details
-
Copy full SHA for bb4dce2 - Browse repository at this point
Copy the full SHA bb4dce2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 03242f5 - Browse repository at this point
Copy the full SHA 03242f5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 99c8da0 - Browse repository at this point
Copy the full SHA 99c8da0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5fa0a21 - Browse repository at this point
Copy the full SHA 5fa0a21View commit details -
Do optimisations and improve tests for InstallmentUtils
COAND-802 diff --git a/card/src/main/java/com/adyen/checkout/card/internal/ui/view/InstallmentListAdapter.kt b/card/src/main/java/com/adyen/checkout/card/internal/ui/view/InstallmentListAdapter.kt index 9518eb896..64ec510ab 100644 --- a/card/src/main/java/com/adyen/checkout/card/internal/ui/view/InstallmentListAdapter.kt +++ b/card/src/main/java/com/adyen/checkout/card/internal/ui/view/InstallmentListAdapter.kt @@ -16,7 +16,6 @@ import android.widget.BaseAdapter import android.widget.Filter import android.widget.Filterable import androidx.annotation.RestrictTo -import androidx.annotation.StringRes import androidx.recyclerview.widget.RecyclerView import com.adyen.checkout.card.databinding.InstallmentViewBinding import com.adyen.checkout.card.internal.ui.model.InstallmentOption @@ -70,7 +69,6 @@ internal class InstallmentListAdapter( @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class InstallmentModel( - @StringRes val textResId: Int, val numberOfInstallments: Int?, val option: InstallmentOption, val amount: Amount?, diff --git a/card/src/main/java/com/adyen/checkout/card/internal/util/InstallmentUtils.kt b/card/src/main/java/com/adyen/checkout/card/internal/util/InstallmentUtils.kt index b65d6feb4..1df2a34ac 100644 --- a/card/src/main/java/com/adyen/checkout/card/internal/util/InstallmentUtils.kt +++ b/card/src/main/java/com/adyen/checkout/card/internal/util/InstallmentUtils.kt @@ -75,7 +75,6 @@ internal object InstallmentUtils { if (installmentOptions == null) return emptyList() val installmentOptionsList = mutableListOf<InstallmentModel>() val oneTimeOption = InstallmentModel( - textResId = R.string.checkout_card_installments_option_one_time, numberOfInstallments = null, option = InstallmentOption.ONE_TIME, amount = amount, @@ -86,7 +85,6 @@ internal object InstallmentUtils { if (installmentOptions.includeRevolving) { val revolvingOption = InstallmentModel( - textResId = R.string.checkout_card_installments_option_revolving, numberOfInstallments = REVOLVING_INSTALLMENT_VALUE, option = InstallmentOption.REVOLVING, amount = amount, @@ -96,14 +94,8 @@ internal object InstallmentUtils { installmentOptionsList.add(revolvingOption) } - val regularOptionTextResId = if (showAmount && amount != null) { - R.string.checkout_card_installments_option_regular_with_price - } else { - R.string.checkout_card_installments_option_regular - } val regularOptions = installmentOptions.values.map { numberOfInstallments -> InstallmentModel( - textResId = regularOptionTextResId, numberOfInstallments = numberOfInstallments, option = InstallmentOption.REGULAR, amount = amount, @@ -121,6 +113,8 @@ internal object InstallmentUtils { fun getTextForInstallmentOption(context: Context, installmentModel: InstallmentModel?): String = with(installmentModel) { return when (this?.option) { + InstallmentOption.ONE_TIME -> context.getString(R.string.checkout_card_installments_option_one_time) + InstallmentOption.REVOLVING -> context.getString(R.string.checkout_card_installments_option_revolving) InstallmentOption.REGULAR -> { val numberOfInstallments = numberOfInstallments ?: 1 val installmentAmount = amount?.copy(value = amount.value / numberOfInstallments) @@ -128,13 +122,19 @@ internal object InstallmentUtils { if (showAmount && installmentAmount != null) { val formattedInstallmentAmount = CurrencyUtils.formatAmount(installmentAmount, shopperLocale) - context.getString(textResId, formattedNumberOfInstallments, formattedInstallmentAmount) + context.getString( + R.string.checkout_card_installments_option_regular_with_price, + formattedNumberOfInstallments, + formattedInstallmentAmount + ) } else { - context.getString(textResId, formattedNumberOfInstallments) + context.getString( + R.string.checkout_card_installments_option_regular, + formattedNumberOfInstallments + ) } } - InstallmentOption.REVOLVING, InstallmentOption.ONE_TIME -> context.getString(textResId) else -> "" } } diff --git a/card/src/test/java/com/adyen/checkout/card/internal/ui/DefaultCardDelegateTest.kt b/card/src/test/java/com/adyen/checkout/card/internal/ui/DefaultCardDelegateTest.kt index 1887b9c74..3b941ed63 100644 --- a/card/src/test/java/com/adyen/checkout/card/internal/ui/DefaultCardDelegateTest.kt +++ b/card/src/test/java/com/adyen/checkout/card/internal/ui/DefaultCardDelegateTest.kt @@ -566,7 +566,6 @@ internal class DefaultCardDelegateTest( delegate.outputDataFlow.test { val installmentModel = InstallmentModel( - textResId = R.string.checkout_card_installments_option_revolving, numberOfInstallments = 1, option = InstallmentOption.REVOLVING, amount = null, @@ -809,7 +808,6 @@ internal class DefaultCardDelegateTest( val addressUIState = AddressFormUIState.FULL_ADDRESS val installmentModel = InstallmentModel( - textResId = R.string.checkout_card_installments_option_revolving, numberOfInstallments = 1, option = InstallmentOption.REVOLVING, amount = null, diff --git a/card/src/test/java/com/adyen/checkout/card/internal/util/InstallmentUtilsTest.kt b/card/src/test/java/com/adyen/checkout/card/internal/util/InstallmentUtilsTest.kt index 31b519555..ccaa5157e 100644 --- a/card/src/test/java/com/adyen/checkout/card/internal/util/InstallmentUtilsTest.kt +++ b/card/src/test/java/com/adyen/checkout/card/internal/util/InstallmentUtilsTest.kt @@ -13,6 +13,7 @@ import com.adyen.checkout.card.CardBrand import com.adyen.checkout.card.CardType import com.adyen.checkout.card.InstallmentConfiguration import com.adyen.checkout.card.InstallmentOptions +import com.adyen.checkout.card.R import com.adyen.checkout.card.internal.ui.model.InstallmentOption import com.adyen.checkout.card.internal.ui.model.InstallmentOptionParams import com.adyen.checkout.card.internal.ui.model.InstallmentParams @@ -161,9 +162,8 @@ internal class InstallmentUtilsTest { @test fun `get text for installment option gets a string, if installment option is one time`() { - val textResourceId = Int.MAX_VALUE + val textResourceId = R.string.checkout_card_installments_option_one_time val installmentModel = InstallmentModel( - textResId = textResourceId, numberOfInstallments = null, option = InstallmentOption.ONE_TIME, amount = null, @@ -178,9 +178,8 @@ internal class InstallmentUtilsTest { @test fun `get text for installment option gets a string, if installment option is revolving`() { - val textResourceId = Int.MAX_VALUE + val textResourceId = R.string.checkout_card_installments_option_revolving val installmentModel = InstallmentModel( - textResId = textResourceId, numberOfInstallments = null, option = InstallmentOption.REVOLVING, amount = null, @@ -195,9 +194,8 @@ internal class InstallmentUtilsTest { @test fun `get text for installment option gets a string, if installment option is regular and amount is not shown`() { - val textResourceId = Int.MAX_VALUE + val textResourceId = R.string.checkout_card_installments_option_regular val installmentModel = InstallmentModel( - textResId = textResourceId, numberOfInstallments = 2, option = InstallmentOption.REGULAR, amount = Amount("USD", 100L), @@ -212,9 +210,8 @@ internal class InstallmentUtilsTest { @test fun `get text for installment option gets a string, if installment option is regular and amount is null`() { - val textResourceId = Int.MAX_VALUE + val textResourceId = R.string.checkout_card_installments_option_regular val installmentModel = InstallmentModel( - textResId = textResourceId, numberOfInstallments = 2, option = InstallmentOption.REGULAR, amount = null, @@ -229,9 +226,8 @@ internal class InstallmentUtilsTest { @test fun `get text for installment option gets a string, if installment option is regular and amount is shown`() { - val textResourceId = Int.MAX_VALUE + val textResourceId = R.string.checkout_card_installments_option_regular_with_price val installmentModel = InstallmentModel( - textResId = textResourceId, numberOfInstallments = 3, option = InstallmentOption.REGULAR, amount = Amount("USD", 10000L), @@ -359,7 +355,6 @@ internal class InstallmentUtilsTest { arguments(null), arguments( InstallmentModel( - textResId = Int.MAX_VALUE, numberOfInstallments = null, option = InstallmentOption.ONE_TIME, amount = null, @@ -373,7 +368,6 @@ internal class InstallmentUtilsTest { fun validInstallmentOptionForMakeInstallmentModelObject() = listOf( arguments( InstallmentModel( - textResId = Int.MAX_VALUE, numberOfInstallments = null, option = InstallmentOption.REGULAR, amount = null, @@ -383,7 +377,6 @@ internal class InstallmentUtilsTest { ), arguments( InstallmentModel( - textResId = Int.MAX_VALUE, numberOfInstallments = null, option = InstallmentOption.REVOLVING, amount = null,
Configuration menu - View commit details
-
Copy full SHA for 1d95c41 - Browse repository at this point
Copy the full SHA 1d95c41View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3dd68a6 - Browse repository at this point
Copy the full SHA 3dd68a6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6d44e09 - Browse repository at this point
Copy the full SHA 6d44e09View commit details -
Merge pull request #1389 from Adyen/feature/display_amounts_for_insta…
…llments_on_card_component Display amounts for installments
Configuration menu - View commit details
-
Copy full SHA for 2e367b5 - Browse repository at this point
Copy the full SHA 2e367b5View commit details -
Configuration menu - View commit details
-
Copy full SHA for d5fe9cf - Browse repository at this point
Copy the full SHA d5fe9cfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 05a80b1 - Browse repository at this point
Copy the full SHA 05a80b1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 02afea9 - Browse repository at this point
Copy the full SHA 02afea9View commit details -
Fix ktlint rules discouraged-comment-location and parameter-list-spac…
…ing except in some base classes with generics where they don't work well
Configuration menu - View commit details
-
Copy full SHA for c95e82e - Browse repository at this point
Copy the full SHA c95e82eView commit details -
Configuration menu - View commit details
-
Copy full SHA for b97df6a - Browse repository at this point
Copy the full SHA b97df6aView commit details
Commits on Nov 24, 2023
-
Add allow trailing comma rules
The IDE will automatically add any missing trailing commas when you format a file
Configuration menu - View commit details
-
Copy full SHA for c533454 - Browse repository at this point
Copy the full SHA c533454View commit details -
Merge pull request #1393 from Adyen/dependencies/ktlint_v1
Update ktlint to 1.0.1
Configuration menu - View commit details
-
Copy full SHA for 06f6d0f - Browse repository at this point
Copy the full SHA 06f6d0fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1ba2349 - Browse repository at this point
Copy the full SHA 1ba2349View commit details -
Merge pull request #1375 from Adyen/renovate/compose_bom_version
Update dependency androidx.compose:compose-bom to v2023.10.01
Configuration menu - View commit details
-
Copy full SHA for e515021 - Browse repository at this point
Copy the full SHA e515021View commit details
Commits on Dec 1, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 313d13d - Browse repository at this point
Copy the full SHA 313d13dView commit details -
Merge pull request #1407 from Adyen/renovate/detekt_version
Update detekt_version to v1.23.3
Configuration menu - View commit details
-
Copy full SHA for 4bb0d1a - Browse repository at this point
Copy the full SHA 4bb0d1aView commit details
Commits on Dec 4, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 80f5880 - Browse repository at this point
Copy the full SHA 80f5880View commit details -
Merge pull request #1406 from Adyen/renovate/recyclerview_version
Update dependency androidx.recyclerview:recyclerview to v1.3.2
Configuration menu - View commit details
-
Copy full SHA for 420c7b6 - Browse repository at this point
Copy the full SHA 420c7b6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 28e81b6 - Browse repository at this point
Copy the full SHA 28e81b6View commit details -
Merge pull request #1408 from Adyen/renovate/detekt_gradle_plugin_ver…
…sion Update plugin io.gitlab.arturbosch.detekt to v1.23.3
Configuration menu - View commit details
-
Copy full SHA for eb58637 - Browse repository at this point
Copy the full SHA eb58637View commit details -
Configuration menu - View commit details
-
Copy full SHA for c1c36c1 - Browse repository at this point
Copy the full SHA c1c36c1View commit details -
Merge pull request #1398 from Adyen/feature/pin_required_config
Add pinRequired configuration for gift card component
Configuration menu - View commit details
-
Copy full SHA for ed050eb - Browse repository at this point
Copy the full SHA ed050ebView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4694ac6 - Browse repository at this point
Copy the full SHA 4694ac6View commit details -
Merge pull request #1410 from Adyen/renovate/robolectric_version
Update dependency org.robolectric:robolectric to v4.11.1
Configuration menu - View commit details
-
Copy full SHA for 02a4619 - Browse repository at this point
Copy the full SHA 02a4619View commit details -
Configuration menu - View commit details
-
Copy full SHA for ac9bbc7 - Browse repository at this point
Copy the full SHA ac9bbc7View commit details -
Merge pull request #1411 from Adyen/renovate/okhttp-monorepo
Update okhttp monorepo to v4.12.0
Configuration menu - View commit details
-
Copy full SHA for d71dfb3 - Browse repository at this point
Copy the full SHA d71dfb3View commit details -
Configuration menu - View commit details
-
Copy full SHA for fb63e1c - Browse repository at this point
Copy the full SHA fb63e1cView commit details -
Merge pull request #1412 from Adyen/renovate/fragment_version
Update dependency androidx.fragment:fragment-ktx to v1.6.2
Configuration menu - View commit details
-
Copy full SHA for 00cf321 - Browse repository at this point
Copy the full SHA 00cf321View commit details
Commits on Dec 5, 2023
-
Reverted back the changes made in AdyenComponentView to add the compo…
…nent view only on next layout. Those changes would cause Compose to not re-draw the components when used in lazy lists. Instead, disabled the `windowEnterAnimation` for ActionComponentDialogFragment, which caused the dialog to jump before navigating to an external browser activity. COAND-825
Configuration menu - View commit details
-
Copy full SHA for 71ae855 - Browse repository at this point
Copy the full SHA 71ae855View commit details
Commits on Dec 6, 2023
-
Merge pull request #1403 from Adyen/fix/component_not_showing_in_comp…
…ose_pager Fix component not showing in Compose
Configuration menu - View commit details
-
Copy full SHA for 5d8dc98 - Browse repository at this point
Copy the full SHA 5d8dc98View commit details -
Configuration menu - View commit details
-
Copy full SHA for c057ca5 - Browse repository at this point
Copy the full SHA c057ca5View commit details -
Add getGooglePayButtonParameters to GooglePayComponent
It's basically just a wrapper around allowedPaymentMethods in case something else is required for the button later on COAND-830
Configuration menu - View commit details
-
Copy full SHA for 6523e4e - Browse repository at this point
Copy the full SHA 6523e4eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 45f18d4 - Browse repository at this point
Copy the full SHA 45f18d4View commit details -
Configuration menu - View commit details
-
Copy full SHA for aec762b - Browse repository at this point
Copy the full SHA aec762bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 74882b6 - Browse repository at this point
Copy the full SHA 74882b6View commit details -
Merge pull request #1413 from Adyen/feature/google_pay_allowed_paymen…
…t_methods Add public helpers to improve Google Pay integration
Configuration menu - View commit details
-
Copy full SHA for 0bf7868 - Browse repository at this point
Copy the full SHA 0bf7868View commit details
Commits on Dec 11, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 1a7ff19 - Browse repository at this point
Copy the full SHA 1a7ff19View commit details -
Remove unnecessary compose compiler args
The Kotlin and Compose compiler versions no longer mismatch, so this is no longer needed. COAND-826
Configuration menu - View commit details
-
Copy full SHA for 1afa81e - Browse repository at this point
Copy the full SHA 1afa81eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1ea76a0 - Browse repository at this point
Copy the full SHA 1ea76a0View commit details -
Configuration menu - View commit details
-
Copy full SHA for c096390 - Browse repository at this point
Copy the full SHA c096390View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3e1d0f4 - Browse repository at this point
Copy the full SHA 3e1d0f4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 28e4144 - Browse repository at this point
Copy the full SHA 28e4144View commit details -
Configuration menu - View commit details
-
Copy full SHA for df7f920 - Browse repository at this point
Copy the full SHA df7f920View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6d44eff - Browse repository at this point
Copy the full SHA 6d44effView commit details -
Configuration menu - View commit details
-
Copy full SHA for c91f1b6 - Browse repository at this point
Copy the full SHA c91f1b6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 51de3ac - Browse repository at this point
Copy the full SHA 51de3acView commit details -
Merge pull request #1404 from Adyen/feature/compse_example
Convert Card Component with sessions example integration to Compose
Configuration menu - View commit details
-
Copy full SHA for 43953e3 - Browse repository at this point
Copy the full SHA 43953e3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 185ecde - Browse repository at this point
Copy the full SHA 185ecdeView commit details -
Configuration menu - View commit details
-
Copy full SHA for a9d9c8b - Browse repository at this point
Copy the full SHA a9d9c8bView commit details -
Merge pull request #1415 from Adyen/release/5.1.0
Preparing release 5.1.0
Configuration menu - View commit details
-
Copy full SHA for adc16be - Browse repository at this point
Copy the full SHA adc16beView commit details