Skip to content
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

Pay by Bank US #1899

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
[//]: # (## Deprecated)
[//]: # ( - Configurations public constructor are deprecated, please use each Configuration's builder to make a Configuration object)

## New
- Payment method:
- Pay by Bank US. Payment method type: **paybybank_AIS_DD**.

## Fixed
- For the Address Lookup functionality, when the postal/zip code field is focused and the user presses back, then it no longer crashes.
25 changes: 25 additions & 0 deletions components-core/api/components-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ public final class com/adyen/checkout/components/core/PaymentMethodTypes {
public static final field OPEN_BANKING Ljava/lang/String;
public static final field OXXO Ljava/lang/String;
public static final field PAY_BY_BANK Ljava/lang/String;
public static final field PAY_BY_BANK_US Ljava/lang/String;
public static final field PAY_NOW Ljava/lang/String;
public static final field PIX Ljava/lang/String;
public static final field PROMPT_PAY Ljava/lang/String;
Expand Down Expand Up @@ -2686,6 +2687,30 @@ public final class com/adyen/checkout/components/core/paymentmethod/PayByBankPay
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public final class com/adyen/checkout/components/core/paymentmethod/PayByBankUSPaymentMethod : com/adyen/checkout/components/core/paymentmethod/PaymentMethodDetails {
public static final field CREATOR Landroid/os/Parcelable$Creator;
public static final field Companion Lcom/adyen/checkout/components/core/paymentmethod/PayByBankUSPaymentMethod$Companion;
public static final field SERIALIZER Lcom/adyen/checkout/core/internal/data/model/ModelObject$Serializer;
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
public fun describeContents ()I
public fun getCheckoutAttemptId ()Ljava/lang/String;
public fun getType ()Ljava/lang/String;
public fun setCheckoutAttemptId (Ljava/lang/String;)V
public fun setType (Ljava/lang/String;)V
public fun writeToParcel (Landroid/os/Parcel;I)V
}

public final class com/adyen/checkout/components/core/paymentmethod/PayByBankUSPaymentMethod$Companion {
}

public final class com/adyen/checkout/components/core/paymentmethod/PayByBankUSPaymentMethod$Creator : android/os/Parcelable$Creator {
public fun <init> ()V
public final fun createFromParcel (Landroid/os/Parcel;)Lcom/adyen/checkout/components/core/paymentmethod/PayByBankUSPaymentMethod;
public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object;
public final fun newArray (I)[Lcom/adyen/checkout/components/core/paymentmethod/PayByBankUSPaymentMethod;
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public final class com/adyen/checkout/components/core/paymentmethod/PayEasyPaymentMethod : com/adyen/checkout/components/core/paymentmethod/EContextPaymentMethod {
public static final field CREATOR Landroid/os/Parcelable$Creator;
public static final field Companion Lcom/adyen/checkout/components/core/paymentmethod/PayEasyPaymentMethod$Companion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ object PaymentMethodTypes {
const val ONLINE_BANKING_SK = "onlineBanking_SK"
const val OPEN_BANKING = "openbanking_UK"
const val PAY_BY_BANK = "paybybank"
const val PAY_BY_BANK_US = "paybybank_AIS_DD"
const val SCHEME = "scheme"
const val SEPA = "sepadirectdebit"
const val TWINT = "twint"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by ozgur on 21/10/2024.
*/

package com.adyen.checkout.components.core.paymentmethod

import com.adyen.checkout.core.exception.ModelSerializationException
import com.adyen.checkout.core.internal.data.model.getStringOrNull
import kotlinx.parcelize.Parcelize
import org.json.JSONException
import org.json.JSONObject

@Parcelize
class PayByBankUSPaymentMethod(
override var type: String?,
override var checkoutAttemptId: String?,
) : PaymentMethodDetails() {

companion object {

@JvmField
val SERIALIZER: Serializer<PayByBankUSPaymentMethod> = object : Serializer<PayByBankUSPaymentMethod> {
override fun serialize(modelObject: PayByBankUSPaymentMethod): JSONObject {
return try {
JSONObject().apply {
putOpt(TYPE, modelObject.type)
putOpt(CHECKOUT_ATTEMPT_ID, modelObject.checkoutAttemptId)
}
} catch (e: JSONException) {
throw ModelSerializationException(PayByBankUSPaymentMethod::class.java, e)
}
}

override fun deserialize(jsonObject: JSONObject): PayByBankUSPaymentMethod {
return PayByBankUSPaymentMethod(
type = jsonObject.getStringOrNull(TYPE),
checkoutAttemptId = jsonObject.getStringOrNull(CHECKOUT_ATTEMPT_ID),
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ abstract class PaymentMethodDetails : ModelObject() {
OnlineBankingSKPaymentMethod.PAYMENT_METHOD_TYPE -> OnlineBankingSKPaymentMethod.SERIALIZER
OpenBankingPaymentMethod.PAYMENT_METHOD_TYPE -> OpenBankingPaymentMethod.SERIALIZER
PayByBankPaymentMethod.PAYMENT_METHOD_TYPE -> PayByBankPaymentMethod.SERIALIZER
PaymentMethodTypes.PAY_BY_BANK_US -> PayByBankUSPaymentMethod.SERIALIZER
PayEasyPaymentMethod.PAYMENT_METHOD_TYPE -> PayEasyPaymentMethod.SERIALIZER
PaymentMethodTypes.GOOGLE_PAY,
PaymentMethodTypes.GOOGLE_PAY_LEGACY -> GooglePayPaymentMethod.SERIALIZER
Expand Down
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.map {
LogoItem(
it.path,
dropInParams.environment,
)
},
listOf(TextItem(R.string.checkout_plus)),
).flatten()
}

private fun List<OrderPaymentMethod>.mapToGiftCardPaymentMethodModel(): List<GiftCardPaymentMethodModel> =
map {
GiftCardPaymentMethodModel(
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
1 change: 1 addition & 0 deletions paybybank-us/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Loading