Skip to content

Commit

Permalink
Merge pull request #1874 from Adyen/feature/pay-by-bank-us-drop-in
Browse files Browse the repository at this point in the history
Pay by Bank US - Drop-in
  • Loading branch information
ozgur00 authored Nov 5, 2024
2 parents f603d88 + 43fc6b2 commit 20f9c34
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 2 deletions.
1 change: 1 addition & 0 deletions drop-in/api/drop-in.api
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions drop-in/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<PayByBankUSComponentState>,
)
}

checkCompileOnly { PayEasyComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
PayEasyComponentProvider(dropInOverrideParams, analyticsManager).get(
fragment = fragment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<LogoTextItem> {
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<OrderPaymentMethod>.mapToGiftCardPaymentMethodModel(): List<GiftCardPaymentMethodModel> =
map {
GiftCardPaymentMethodModel(
Expand All @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<LogoTextItem>
) : PaymentMethodListItem {
override fun getViewType(): Int = PaymentMethodListItem.PAYMENT_METHOD
}
13 changes: 13 additions & 0 deletions drop-in/src/main/res/layout/payment_methods_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@
tools:text="Test" />
</LinearLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView_brandList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:clipToPadding="false"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="4"
android:visibility="gone"
tools:visibility="visible"
tools:listitem="@layout/logo_view_holder" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/textView_amount"
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions drop-in/src/main/res/template/values/strings.xml.tt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
<!-- Untranslatable strings -->
<string name="checkout_negative_amount" translatable="false">- %s</string>
<string name="last_four_digits_format" translatable="false">•••• %s</string>
<string name="checkout_plus" translatable="false">+</string>
</resources>
1 change: 1 addition & 0 deletions drop-in/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
<!-- Untranslatable strings -->
<string name="checkout_negative_amount" translatable="false">- %s</string>
<string name="last_four_digits_format" translatable="false">•••• %s</string>
<string name="checkout_plus" translatable="false">+</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ internal object Helpers {
name = name.orEmpty(),
icon = icon.orEmpty(),
drawIconBorder = drawIconBorder,
Environment.TEST,
environment = Environment.TEST,
brandList = emptyList(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 20f9c34

Please sign in to comment.