diff --git a/drop-in/api/drop-in.api b/drop-in/api/drop-in.api index 1901c4dd73..f303b01736 100644 --- a/drop-in/api/drop-in.api +++ b/drop-in/api/drop-in.api @@ -133,6 +133,7 @@ public final class com/adyen/checkout/dropin/DropInConfiguration$Builder : com/a public final fun addOnlineBankingPLConfiguration (Lcom/adyen/checkout/onlinebankingpl/OnlineBankingPLConfiguration;)Lcom/adyen/checkout/dropin/DropInConfiguration$Builder; public final fun addOnlineBankingSKConfiguration (Lcom/adyen/checkout/onlinebankingsk/OnlineBankingSKConfiguration;)Lcom/adyen/checkout/dropin/DropInConfiguration$Builder; public final fun addOpenBankingConfiguration (Lcom/adyen/checkout/openbanking/OpenBankingConfiguration;)Lcom/adyen/checkout/dropin/DropInConfiguration$Builder; + public final fun addPayByBankUSConfiguration (Lcom/adyen/checkout/paybybankus/PayByBankUSConfiguration;)Lcom/adyen/checkout/dropin/DropInConfiguration$Builder; public final fun addPayEasyConfiguration (Lcom/adyen/checkout/payeasy/PayEasyConfiguration;)Lcom/adyen/checkout/dropin/DropInConfiguration$Builder; public final fun addSepaConfiguration (Lcom/adyen/checkout/sepa/SepaConfiguration;)Lcom/adyen/checkout/dropin/DropInConfiguration$Builder; public final fun addSevenElevenConfiguration (Lcom/adyen/checkout/seveneleven/SevenElevenConfiguration;)Lcom/adyen/checkout/dropin/DropInConfiguration$Builder; diff --git a/drop-in/build.gradle b/drop-in/build.gradle index 02829d7f4e..54881d2191 100644 --- a/drop-in/build.gradle +++ b/drop-in/build.gradle @@ -72,6 +72,7 @@ dependencies { api project(':openbanking') api project(':payeasy') api project(':paybybank') + api project(':paybybank-us') api project(':sepa') api project(':seven-eleven') api project(':sessions-core') diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt index ad03713868..0109bb412d 100644 --- a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt +++ b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt @@ -45,6 +45,7 @@ import com.adyen.checkout.onlinebankingjp.OnlineBankingJPConfiguration import com.adyen.checkout.onlinebankingpl.OnlineBankingPLConfiguration import com.adyen.checkout.onlinebankingsk.OnlineBankingSKConfiguration import com.adyen.checkout.openbanking.OpenBankingConfiguration +import com.adyen.checkout.paybybankus.PayByBankUSConfiguration import com.adyen.checkout.payeasy.PayEasyConfiguration import com.adyen.checkout.sepa.SepaConfiguration import com.adyen.checkout.seveneleven.SevenElevenConfiguration @@ -459,6 +460,14 @@ class DropInConfiguration private constructor( return this } + /** + * Add configuration for Pay by Bank US payment method. + */ + fun addPayByBankUSConfiguration(payByBankUSConfiguration: PayByBankUSConfiguration): Builder { + availablePaymentConfigs[PaymentMethodTypes.PAY_BY_BANK_US] = payByBankUSConfiguration + return this + } + /** * Provide a custom name to be shown in Drop-in for payment methods with a type matching [paymentMethodType]. * For [paymentMethodType] you can pass [PaymentMethodTypes] or any other custom value. diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentProvider.kt index fdff02accb..04dc5b9c3b 100644 --- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentProvider.kt +++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentProvider.kt @@ -91,6 +91,9 @@ import com.adyen.checkout.openbanking.internal.provider.OpenBankingComponentProv import com.adyen.checkout.paybybank.PayByBankComponent import com.adyen.checkout.paybybank.PayByBankComponentState import com.adyen.checkout.paybybank.internal.provider.PayByBankComponentProvider +import com.adyen.checkout.paybybankus.PayByBankUSComponent +import com.adyen.checkout.paybybankus.PayByBankUSComponentState +import com.adyen.checkout.paybybankus.internal.provider.PayByBankUSComponentProvider import com.adyen.checkout.payeasy.PayEasyComponent import com.adyen.checkout.payeasy.PayEasyComponentState import com.adyen.checkout.payeasy.internal.provider.PayEasyComponentProvider @@ -408,6 +411,15 @@ internal fun getComponentFor( ) } + checkCompileOnly { PayByBankUSComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> { + PayByBankUSComponentProvider(dropInOverrideParams, analyticsManager).get( + fragment = fragment, + paymentMethod = paymentMethod, + checkoutConfiguration = checkoutConfiguration, + callback = componentCallback as ComponentCallback, + ) + } + checkCompileOnly { PayEasyComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> { PayEasyComponentProvider(dropInOverrideParams, analyticsManager).get( fragment = fragment, diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodAdapter.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodAdapter.kt index 3c3c0eb86b..b35dd4ea94 100644 --- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodAdapter.kt +++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodAdapter.kt @@ -35,6 +35,7 @@ import com.adyen.checkout.dropin.internal.ui.model.StoredCardModel import com.adyen.checkout.dropin.internal.ui.model.StoredPaymentMethodModel import com.adyen.checkout.ui.core.internal.ui.loadLogo import com.adyen.checkout.ui.core.internal.ui.view.AdyenSwipeToRevealLayout +import com.adyen.checkout.ui.core.internal.ui.view.LogoTextAdapter internal class PaymentMethodAdapter @JvmOverloads constructor( private val onPaymentMethodSelectedCallback: OnPaymentMethodSelectedCallback? = null, @@ -213,6 +214,11 @@ internal class PaymentMethodAdapter @JvmOverloads constructor( } textViewAmount.isVisible = false + + recyclerViewBrandList.isVisible = model.brandList.isNotEmpty() + val adapter = LogoTextAdapter(binding.root.context) + recyclerViewBrandList.adapter = adapter + adapter.submitList(model.brandList) } } diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModel.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModel.kt index d5f6b7f255..7b7b36446d 100644 --- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModel.kt +++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModel.kt @@ -37,6 +37,10 @@ import com.adyen.checkout.dropin.internal.ui.model.PaymentMethodNote import com.adyen.checkout.dropin.internal.ui.model.StoredPaymentMethodModel import com.adyen.checkout.dropin.internal.util.isStoredPaymentSupported import com.adyen.checkout.dropin.internal.util.mapStoredModel +import com.adyen.checkout.paybybankus.internal.ui.model.PayByBankUSBrandLogo +import com.adyen.checkout.ui.core.internal.ui.model.LogoTextItem +import com.adyen.checkout.ui.core.internal.ui.model.LogoTextItem.LogoItem +import com.adyen.checkout.ui.core.internal.ui.model.LogoTextItem.TextItem import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -240,9 +244,26 @@ internal class PaymentMethodsListViewModel( icon = icon.orEmpty(), drawIconBorder = drawIconBorder, environment = dropInParams.environment, + brandList = if (type == PaymentMethodTypes.PAY_BY_BANK_US) { + makeBrandList() + } else { + emptyList() + }, ) } + private fun makeBrandList(): List { + return listOf( + PayByBankUSBrandLogo.entries.take(PAY_BY_BANK_BRAND_LOGO_SIZE).map { + LogoItem( + it.path, + dropInParams.environment, + ) + }, + listOf(TextItem(R.string.checkout_plus)), + ).flatten() + } + private fun List.mapToGiftCardPaymentMethodModel(): List = map { GiftCardPaymentMethodModel( @@ -258,6 +279,7 @@ internal class PaymentMethodsListViewModel( companion object { private const val CARD_LOGO_TYPE = "card" private const val GOOGLE_PAY_LOGO_TYPE = PaymentMethodTypes.GOOGLE_PAY + private const val PAY_BY_BANK_BRAND_LOGO_SIZE = 3 } } diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/PaymentMethodModel.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/PaymentMethodModel.kt index 2207dc2047..cceaf7ff7e 100644 --- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/PaymentMethodModel.kt +++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/PaymentMethodModel.kt @@ -9,6 +9,7 @@ package com.adyen.checkout.dropin.internal.ui.model import com.adyen.checkout.core.Environment +import com.adyen.checkout.ui.core.internal.ui.model.LogoTextItem internal data class PaymentMethodModel( val index: Int, @@ -18,6 +19,7 @@ internal data class PaymentMethodModel( val drawIconBorder: Boolean, // We need the environment to load the logo val environment: Environment, + val brandList: List ) : PaymentMethodListItem { override fun getViewType(): Int = PaymentMethodListItem.PAYMENT_METHOD } diff --git a/drop-in/src/main/res/layout/payment_methods_list_item.xml b/drop-in/src/main/res/layout/payment_methods_list_item.xml index 81c5d85986..f185971978 100644 --- a/drop-in/src/main/res/layout/payment_methods_list_item.xml +++ b/drop-in/src/main/res/layout/payment_methods_list_item.xml @@ -61,6 +61,19 @@ tools:text="Test" /> + + - %s •••• %s + + diff --git a/drop-in/src/main/res/values/strings.xml b/drop-in/src/main/res/values/strings.xml index bac8a6f5a1..02070fd2f3 100644 --- a/drop-in/src/main/res/values/strings.xml +++ b/drop-in/src/main/res/values/strings.xml @@ -39,4 +39,5 @@ - %s •••• %s + + diff --git a/drop-in/src/test/java/com/adyen/checkout/dropin/internal/Helpers.kt b/drop-in/src/test/java/com/adyen/checkout/dropin/internal/Helpers.kt index 17865b61c3..c344a37685 100644 --- a/drop-in/src/test/java/com/adyen/checkout/dropin/internal/Helpers.kt +++ b/drop-in/src/test/java/com/adyen/checkout/dropin/internal/Helpers.kt @@ -48,7 +48,8 @@ internal object Helpers { name = name.orEmpty(), icon = icon.orEmpty(), drawIconBorder = drawIconBorder, - Environment.TEST, + environment = Environment.TEST, + brandList = emptyList(), ) } diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSBrandLogo.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSBrandLogo.kt index f8033c8797..f33561a171 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSBrandLogo.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSBrandLogo.kt @@ -8,7 +8,10 @@ package com.adyen.checkout.paybybankus.internal.ui.model -internal enum class PayByBankUSBrandLogo(val path: String) { +import androidx.annotation.RestrictTo + +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +enum class PayByBankUSBrandLogo(val path: String) { US_1("US-1"), US_2("US-2"), US_3("US-3"),