From 217b61bdd81236a437ea0f2de0bb843c80163b99 Mon Sep 17 00:00:00 2001 From: ozgur <6615094+ozgur00@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:41:40 +0200 Subject: [PATCH 01/15] Create paybybank-us module COAND-974 --- paybybank-us/.gitignore | 1 + paybybank-us/api/paybybank-us.api | 8 ++++ paybybank-us/build.gradle | 47 +++++++++++++++++++++++ paybybank-us/consumer-rules.pro | 0 paybybank-us/proguard-rules.pro | 21 ++++++++++ paybybank-us/src/main/AndroidManifest.xml | 10 +++++ settings.gradle | 1 + 7 files changed, 88 insertions(+) create mode 100644 paybybank-us/.gitignore create mode 100644 paybybank-us/api/paybybank-us.api create mode 100644 paybybank-us/build.gradle create mode 100644 paybybank-us/consumer-rules.pro create mode 100644 paybybank-us/proguard-rules.pro create mode 100644 paybybank-us/src/main/AndroidManifest.xml diff --git a/paybybank-us/.gitignore b/paybybank-us/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/paybybank-us/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/paybybank-us/api/paybybank-us.api b/paybybank-us/api/paybybank-us.api new file mode 100644 index 0000000000..67eed6465a --- /dev/null +++ b/paybybank-us/api/paybybank-us.api @@ -0,0 +1,8 @@ +public final class com/adyen/checkout/paybybankus/BuildConfig { + public static final field BUILD_TYPE Ljava/lang/String; + public static final field CHECKOUT_VERSION Ljava/lang/String; + public static final field DEBUG Z + public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String; + public fun ()V +} + diff --git a/paybybank-us/build.gradle b/paybybank-us/build.gradle new file mode 100644 index 0000000000..69ec3c7a70 --- /dev/null +++ b/paybybank-us/build.gradle @@ -0,0 +1,47 @@ +plugins { + alias libs.plugins.android.library + alias libs.plugins.kotlin.android + alias libs.plugins.kotlin.parcelize +} + +// Maven artifact +ext.mavenArtifactId = "paybybank-us" +ext.mavenArtifactName = "Adyen Pay by Bank US component" +ext.mavenArtifactDescription = "Adyen Checkout Pay by Bank US component client for Adyen's Checkout API." + +apply from: "${rootDir}/config/gradle/sharedTasks.gradle" + +android { + namespace 'com.adyen.checkout.paybybankus' + compileSdk libs.versions.compile.sdk.get().toInteger() + + defaultConfig { + minSdk libs.versions.min.sdk.get().toInteger() + targetSdk libs.versions.target.sdk.get().toInteger() + + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + consumerProguardFiles "consumer-rules.pro" + } + + buildFeatures { + viewBinding true + } +} + +dependencies { + // Checkout + api project(':action-core') + api project(':components-core') + api project(':sessions-core') + + // Dependencies + implementation libs.material + + //Tests + testImplementation testFixtures(project(':test-core')) + testImplementation testFixtures(project(':components-core')) + testImplementation testFixtures(project(':ui-core')) + testImplementation libs.bundles.junit + testImplementation libs.bundles.mockito + testImplementation libs.bundles.kotlin.coroutines.test +} diff --git a/paybybank-us/consumer-rules.pro b/paybybank-us/consumer-rules.pro new file mode 100644 index 0000000000..e69de29bb2 diff --git a/paybybank-us/proguard-rules.pro b/paybybank-us/proguard-rules.pro new file mode 100644 index 0000000000..481bb43481 --- /dev/null +++ b/paybybank-us/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/paybybank-us/src/main/AndroidManifest.xml b/paybybank-us/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..1ebae297b7 --- /dev/null +++ b/paybybank-us/src/main/AndroidManifest.xml @@ -0,0 +1,10 @@ + + + + diff --git a/settings.gradle b/settings.gradle index 2956b9a7a4..402a603586 100644 --- a/settings.gradle +++ b/settings.gradle @@ -58,6 +58,7 @@ include ':3ds2', ':online-banking-sk', ':openbanking', ':paybybank', + ':paybybank-us', ':payeasy', ':qr-code', ':redirect', From 74f8f7e33bdb8deacbbf779acfe3d88ad152b315 Mon Sep 17 00:00:00 2001 From: ozgur <6615094+ozgur00@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:02:07 +0200 Subject: [PATCH 02/15] Create paybybank-us component files COAND-974 --- paybybank-us/api/paybybank-us.api | 39 +++++++++++++++++++ .../paybybankus/PayByBankUSComponent.kt | 13 +++++++ .../paybybankus/PayByBankUSComponentState.kt | 13 +++++++ .../paybybankus/PayByBankUSConfiguration.kt | 13 +++++++ .../internal/DefaultPayByBankUSDelegate.kt | 13 +++++++ .../internal/PayByBankUSDelegate.kt | 13 +++++++ .../internal/PayByBankUSViewProvider.kt | 13 +++++++ .../provider/PayByBankUSComponentProvider.kt | 13 +++++++ .../internal/ui/model/PayByBankUSInputData.kt | 13 +++++++ .../ui/model/PayByBankUSOutputData.kt | 13 +++++++ .../internal/ui/view/PayByBankUSView.kt | 13 +++++++ 11 files changed, 169 insertions(+) create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponentState.kt create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSConfiguration.kt create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvider.kt create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider.kt create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSInputData.kt create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView.kt diff --git a/paybybank-us/api/paybybank-us.api b/paybybank-us/api/paybybank-us.api index 67eed6465a..b04c5d7eab 100644 --- a/paybybank-us/api/paybybank-us.api +++ b/paybybank-us/api/paybybank-us.api @@ -6,3 +6,42 @@ public final class com/adyen/checkout/paybybankus/BuildConfig { public fun ()V } +public final class com/adyen/checkout/paybybankus/PayByBankUSComponent { + public fun ()V +} + +public final class com/adyen/checkout/paybybankus/PayByBankUSComponentState { + public fun ()V +} + +public final class com/adyen/checkout/paybybankus/PayByBankUSConfiguration { + public fun ()V +} + +public final class com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate { + public fun ()V +} + +public abstract interface class com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate { +} + +public final class com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvider { + public fun ()V +} + +public final class com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider { + public fun ()V +} + +public final class com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSInputData { + public fun ()V +} + +public final class com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData { + public fun ()V +} + +public final class com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView { + public fun ()V +} + diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt new file mode 100644 index 0000000000..6a4518cfbb --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt @@ -0,0 +1,13 @@ +/* + * 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.paybybankus + +class PayByBankUSComponent { + // TODO implement +} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponentState.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponentState.kt new file mode 100644 index 0000000000..78cf31085f --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponentState.kt @@ -0,0 +1,13 @@ +/* + * 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.paybybankus + +class PayByBankUSComponentState { + // TODO implement +} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSConfiguration.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSConfiguration.kt new file mode 100644 index 0000000000..fcf6782e2a --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSConfiguration.kt @@ -0,0 +1,13 @@ +/* + * 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.paybybankus + +class PayByBankUSConfiguration { + // TODO implement +} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt new file mode 100644 index 0000000000..2e8042bc31 --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt @@ -0,0 +1,13 @@ +/* + * 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.paybybankus.internal + +class DefaultPayByBankUSDelegate { + // TODO implement +} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt new file mode 100644 index 0000000000..07c671a860 --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt @@ -0,0 +1,13 @@ +/* + * 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.paybybankus.internal + +interface PayByBankUSDelegate { + // TODO implement +} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvider.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvider.kt new file mode 100644 index 0000000000..ee5985ea84 --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvider.kt @@ -0,0 +1,13 @@ +/* + * 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.paybybankus.internal + +class PayByBankUSViewProvider { + // TODO implement +} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider.kt new file mode 100644 index 0000000000..baddb855e7 --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider.kt @@ -0,0 +1,13 @@ +/* + * 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.paybybankus.internal.provider + +class PayByBankUSComponentProvider { + // TODO implement +} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSInputData.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSInputData.kt new file mode 100644 index 0000000000..2b06c0ec71 --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSInputData.kt @@ -0,0 +1,13 @@ +/* + * 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.paybybankus.internal.ui.model + +class PayByBankUSInputData { + // TODO implement +} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt new file mode 100644 index 0000000000..87399d1534 --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt @@ -0,0 +1,13 @@ +/* + * 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.paybybankus.internal.ui.model + +class PayByBankUSOutputData { + // TODO implement +} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView.kt new file mode 100644 index 0000000000..7111f948a4 --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView.kt @@ -0,0 +1,13 @@ +/* + * 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.paybybankus.internal.ui.view + +class PayByBankUSView { + // TODO implement +} From bc8840e614a35606a0c093be34bd65bfeee4b843 Mon Sep 17 00:00:00 2001 From: ozgur <6615094+ozgur00@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:25:43 +0200 Subject: [PATCH 03/15] Implement PayByBankUSConfiguration COAND-974 --- components-core/api/components-core.api | 1 + .../components/core/PaymentMethodTypes.kt | 1 + paybybank-us/api/paybybank-us.api | 29 ++++- .../paybybankus/PayByBankUSConfiguration.kt | 104 +++++++++++++++++- 4 files changed, 132 insertions(+), 3 deletions(-) diff --git a/components-core/api/components-core.api b/components-core/api/components-core.api index 6665b06e63..b076b2388e 100644 --- a/components-core/api/components-core.api +++ b/components-core/api/components-core.api @@ -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; diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/PaymentMethodTypes.kt b/components-core/src/main/java/com/adyen/checkout/components/core/PaymentMethodTypes.kt index 2daa2a4101..7e9dc9d75c 100644 --- a/components-core/src/main/java/com/adyen/checkout/components/core/PaymentMethodTypes.kt +++ b/components-core/src/main/java/com/adyen/checkout/components/core/PaymentMethodTypes.kt @@ -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" diff --git a/paybybank-us/api/paybybank-us.api b/paybybank-us/api/paybybank-us.api index b04c5d7eab..71e69477d7 100644 --- a/paybybank-us/api/paybybank-us.api +++ b/paybybank-us/api/paybybank-us.api @@ -14,8 +14,35 @@ public final class com/adyen/checkout/paybybankus/PayByBankUSComponentState { public fun ()V } -public final class com/adyen/checkout/paybybankus/PayByBankUSConfiguration { +public final class com/adyen/checkout/paybybankus/PayByBankUSConfiguration : com/adyen/checkout/components/core/internal/Configuration { + public static final field CREATOR Landroid/os/Parcelable$Creator; + public synthetic fun (Ljava/util/Locale;Lcom/adyen/checkout/core/Environment;Ljava/lang/String;Lcom/adyen/checkout/components/core/AnalyticsConfiguration;Lcom/adyen/checkout/components/core/Amount;Lcom/adyen/checkout/action/core/GenericActionConfiguration;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun describeContents ()I + public fun getAmount ()Lcom/adyen/checkout/components/core/Amount; + public fun getAnalyticsConfiguration ()Lcom/adyen/checkout/components/core/AnalyticsConfiguration; + public fun getClientKey ()Ljava/lang/String; + public fun getEnvironment ()Lcom/adyen/checkout/core/Environment; + public fun getShopperLocale ()Ljava/util/Locale; + public fun writeToParcel (Landroid/os/Parcel;I)V +} + +public final class com/adyen/checkout/paybybankus/PayByBankUSConfiguration$Builder : com/adyen/checkout/action/core/internal/ActionHandlingPaymentMethodConfigurationBuilder { + public fun (Lcom/adyen/checkout/core/Environment;Ljava/lang/String;)V + public fun (Ljava/util/Locale;Lcom/adyen/checkout/core/Environment;Ljava/lang/String;)V + public synthetic fun buildInternal ()Lcom/adyen/checkout/components/core/internal/Configuration; +} + +public final class com/adyen/checkout/paybybankus/PayByBankUSConfiguration$Creator : android/os/Parcelable$Creator { public fun ()V + public final fun createFromParcel (Landroid/os/Parcel;)Lcom/adyen/checkout/paybybankus/PayByBankUSConfiguration; + public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object; + public final fun newArray (I)[Lcom/adyen/checkout/paybybankus/PayByBankUSConfiguration; + public synthetic fun newArray (I)[Ljava/lang/Object; +} + +public final class com/adyen/checkout/paybybankus/PayByBankUSConfigurationKt { + public static final fun payByBankUS (Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lkotlin/jvm/functions/Function1;)Lcom/adyen/checkout/components/core/CheckoutConfiguration; + public static synthetic fun payByBankUS$default (Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/adyen/checkout/components/core/CheckoutConfiguration; } public final class com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate { diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSConfiguration.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSConfiguration.kt index fcf6782e2a..a5830a2f08 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSConfiguration.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSConfiguration.kt @@ -8,6 +8,106 @@ package com.adyen.checkout.paybybankus -class PayByBankUSConfiguration { - // TODO implement +import com.adyen.checkout.action.core.GenericActionConfiguration +import com.adyen.checkout.action.core.internal.ActionHandlingPaymentMethodConfigurationBuilder +import com.adyen.checkout.components.core.Amount +import com.adyen.checkout.components.core.AnalyticsConfiguration +import com.adyen.checkout.components.core.CheckoutConfiguration +import com.adyen.checkout.components.core.PaymentMethodTypes +import com.adyen.checkout.components.core.internal.Configuration +import com.adyen.checkout.components.core.internal.util.CheckoutConfigurationMarker +import com.adyen.checkout.core.Environment +import kotlinx.parcelize.Parcelize +import java.util.Locale + +/** + * Configuration class for the [PayByBankUSComponent]. + */ +@Parcelize +class PayByBankUSConfiguration private constructor( + override val shopperLocale: Locale?, + override val environment: Environment, + override val clientKey: String, + override val analyticsConfiguration: AnalyticsConfiguration?, + override val amount: Amount?, + internal val genericActionConfiguration: GenericActionConfiguration, +) : Configuration { + + class Builder : ActionHandlingPaymentMethodConfigurationBuilder { + + /** + * Initialize a configuration builder with the required fields. + * + * The shopper locale will match the value passed to the API with the sessions flow, or the primary user locale + * on the device otherwise. Check out the + * [Sessions API documentation](https://docs.adyen.com/api-explorer/Checkout/latest/post/sessions) on how to set + * this value. + * + * @param environment The [Environment] to be used for internal network calls from the SDK to Adyen. + * @param clientKey Your Client Key used for internal network calls from the SDK to Adyen. + */ + constructor(environment: Environment, clientKey: String) : super( + environment, + clientKey, + ) + + /** + * Initialize a configuration builder with the required fields and a shopper locale. + * + * @param shopperLocale The [Locale] of the shopper. + * @param environment The [Environment] to be used for internal network calls from the SDK to Adyen. + * @param clientKey Your Client Key used for internal network calls from the SDK to Adyen. + */ + constructor( + shopperLocale: Locale, + environment: Environment, + clientKey: String + ) : super(shopperLocale, environment, clientKey) + + override fun buildInternal(): PayByBankUSConfiguration { + return PayByBankUSConfiguration( + shopperLocale = shopperLocale, + environment = environment, + clientKey = clientKey, + analyticsConfiguration = analyticsConfiguration, + amount = amount, + genericActionConfiguration = genericActionConfigurationBuilder.build(), + ) + } + } +} + +fun CheckoutConfiguration.payByBankUS( + configuration: @CheckoutConfigurationMarker PayByBankUSConfiguration.Builder.() -> Unit = {} +): CheckoutConfiguration { + val config = PayByBankUSConfiguration.Builder(environment, clientKey) + .apply { + shopperLocale?.let { setShopperLocale(it) } + amount?.let { setAmount(it) } + analyticsConfiguration?.let { setAnalyticsConfiguration(it) } + } + .apply(configuration) + .build() + addConfiguration(PaymentMethodTypes.PAY_BY_BANK_US, config) + return this +} + +internal fun CheckoutConfiguration.getPayByBankUSConfiguration(): PayByBankUSConfiguration? { + return getConfiguration(PaymentMethodTypes.PAY_BY_BANK_US) +} + +internal fun PayByBankUSConfiguration.toCheckoutConfiguration(): CheckoutConfiguration { + return CheckoutConfiguration( + shopperLocale = shopperLocale, + environment = environment, + clientKey = clientKey, + amount = amount, + analyticsConfiguration = analyticsConfiguration, + ) { + addConfiguration(PaymentMethodTypes.PAY_BY_BANK_US, this@toCheckoutConfiguration) + + genericActionConfiguration.getAllConfigurations().forEach { + addActionConfiguration(it) + } + } } From 81bdc8f2b219a1ed12bdeaa6a225c7228ad21519 Mon Sep 17 00:00:00 2001 From: ozgur <6615094+ozgur00@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:30:40 +0200 Subject: [PATCH 04/15] Add PayByBankUSConfigurationTest COAND-974 --- .../PayByBankUSConfigurationTest.kt | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 paybybank-us/src/test/java/com/adyen/checkout/paybybankus/PayByBankUSConfigurationTest.kt diff --git a/paybybank-us/src/test/java/com/adyen/checkout/paybybankus/PayByBankUSConfigurationTest.kt b/paybybank-us/src/test/java/com/adyen/checkout/paybybankus/PayByBankUSConfigurationTest.kt new file mode 100644 index 0000000000..b9bd8e6453 --- /dev/null +++ b/paybybank-us/src/test/java/com/adyen/checkout/paybybankus/PayByBankUSConfigurationTest.kt @@ -0,0 +1,90 @@ +/* + * 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 24/10/2024. + */ + +package com.adyen.checkout.paybybankus + +import com.adyen.checkout.components.core.Amount +import com.adyen.checkout.components.core.AnalyticsConfiguration +import com.adyen.checkout.components.core.AnalyticsLevel +import com.adyen.checkout.components.core.CheckoutConfiguration +import com.adyen.checkout.core.Environment +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test +import java.util.Locale + +class PayByBankUSConfigurationTest { + + @Test + fun `when creating the configuration through CheckoutConfiguration, then it should be the same as when the builder is used`() { + val checkoutConfiguration = CheckoutConfiguration( + shopperLocale = Locale.US, + environment = Environment.TEST, + clientKey = TEST_CLIENT_KEY, + amount = Amount("EUR", 123L), + analyticsConfiguration = AnalyticsConfiguration(AnalyticsLevel.ALL), + ) { + payByBankUS() + } + + val actual = checkoutConfiguration.getPayByBankUSConfiguration() + + val expected = PayByBankUSConfiguration.Builder( + shopperLocale = Locale.US, + environment = Environment.TEST, + clientKey = TEST_CLIENT_KEY, + ) + .setAmount(Amount("EUR", 123L)) + .setAnalyticsConfiguration(AnalyticsConfiguration(AnalyticsLevel.ALL)) + .build() + + assertEquals(expected.shopperLocale, actual?.shopperLocale) + assertEquals(expected.environment, actual?.environment) + assertEquals(expected.clientKey, actual?.clientKey) + assertEquals(expected.amount, actual?.amount) + assertEquals(expected.analyticsConfiguration, actual?.analyticsConfiguration) + } + + @Test + fun `when the configuration is mapped to CheckoutConfiguration, then CheckoutConfiguration is created correctly`() { + val config = PayByBankUSConfiguration.Builder( + shopperLocale = Locale.US, + environment = Environment.TEST, + clientKey = TEST_CLIENT_KEY, + ) + .setAmount(Amount("EUR", 123L)) + .setAnalyticsConfiguration(AnalyticsConfiguration(AnalyticsLevel.ALL)) + .build() + + val actual = config.toCheckoutConfiguration() + + val expected = CheckoutConfiguration( + shopperLocale = Locale.US, + environment = Environment.TEST, + clientKey = TEST_CLIENT_KEY, + amount = Amount("EUR", 123L), + analyticsConfiguration = AnalyticsConfiguration(AnalyticsLevel.ALL), + ) + + assertEquals(expected.shopperLocale, actual.shopperLocale) + assertEquals(expected.environment, actual.environment) + assertEquals(expected.clientKey, actual.clientKey) + assertEquals(expected.amount, actual.amount) + assertEquals(expected.analyticsConfiguration, actual.analyticsConfiguration) + + val actualPayConfig = actual.getPayByBankUSConfiguration() + assertEquals(config.shopperLocale, actualPayConfig?.shopperLocale) + assertEquals(config.environment, actualPayConfig?.environment) + assertEquals(config.clientKey, actualPayConfig?.clientKey) + assertEquals(config.amount, actualPayConfig?.amount) + assertEquals(config.analyticsConfiguration, actualPayConfig?.analyticsConfiguration) + } + + companion object { + private const val TEST_CLIENT_KEY = "test_qwertyuiopasdfghjklzxcvbnmqwerty" + } +} From b9fbe0978370b4586de496a4d7565944263d86f6 Mon Sep 17 00:00:00 2001 From: ozgur <6615094+ozgur00@users.noreply.github.com> Date: Fri, 25 Oct 2024 10:40:34 +0200 Subject: [PATCH 05/15] Implement paybybank-us component, delegate and component state classes COAND-974 --- components-core/api/components-core.api | 24 ++++++ .../paymentmethod/PayByBankUSPaymentMethod.kt | 46 +++++++++++ .../paymentmethod/PaymentMethodDetails.kt | 1 + paybybank-us/api/paybybank-us.api | 47 ++++++----- .../paybybankus/PayByBankUSComponent.kt | 67 ++++++++++++++- .../paybybankus/PayByBankUSComponentState.kt | 15 +++- .../internal/DefaultPayByBankUSDelegate.kt | 82 ++++++++++++++++++- .../internal/PayByBankUSDelegate.kt | 18 +++- .../internal/ui/model/PayByBankUSInputData.kt | 13 --- .../ui/model/PayByBankUSOutputData.kt | 13 --- 10 files changed, 272 insertions(+), 54 deletions(-) create mode 100644 components-core/src/main/java/com/adyen/checkout/components/core/paymentmethod/PayByBankUSPaymentMethod.kt delete mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSInputData.kt delete mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt diff --git a/components-core/api/components-core.api b/components-core/api/components-core.api index b076b2388e..eab7506ae8 100644 --- a/components-core/api/components-core.api +++ b/components-core/api/components-core.api @@ -2687,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 (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 ()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; diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/paymentmethod/PayByBankUSPaymentMethod.kt b/components-core/src/main/java/com/adyen/checkout/components/core/paymentmethod/PayByBankUSPaymentMethod.kt new file mode 100644 index 0000000000..ee363814c7 --- /dev/null +++ b/components-core/src/main/java/com/adyen/checkout/components/core/paymentmethod/PayByBankUSPaymentMethod.kt @@ -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 = object : Serializer { + 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), + ) + } + } + } +} diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/paymentmethod/PaymentMethodDetails.kt b/components-core/src/main/java/com/adyen/checkout/components/core/paymentmethod/PaymentMethodDetails.kt index 4fd527ee0b..378f809ad0 100644 --- a/components-core/src/main/java/com/adyen/checkout/components/core/paymentmethod/PaymentMethodDetails.kt +++ b/components-core/src/main/java/com/adyen/checkout/components/core/paymentmethod/PaymentMethodDetails.kt @@ -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 diff --git a/paybybank-us/api/paybybank-us.api b/paybybank-us/api/paybybank-us.api index 71e69477d7..e42b0db140 100644 --- a/paybybank-us/api/paybybank-us.api +++ b/paybybank-us/api/paybybank-us.api @@ -6,12 +6,36 @@ public final class com/adyen/checkout/paybybankus/BuildConfig { public fun ()V } -public final class com/adyen/checkout/paybybankus/PayByBankUSComponent { - public fun ()V +public final class com/adyen/checkout/paybybankus/PayByBankUSComponent : androidx/lifecycle/ViewModel, com/adyen/checkout/action/core/internal/ActionHandlingComponent, com/adyen/checkout/components/core/internal/PaymentComponent, com/adyen/checkout/ui/core/internal/ui/ViewableComponent { + public static final field Companion Lcom/adyen/checkout/paybybankus/PayByBankUSComponent$Companion; + public static final field PAYMENT_METHOD_TYPES Ljava/util/List; + public static final field PROVIDER Lcom/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider; + public fun canHandleAction (Lcom/adyen/checkout/components/core/action/Action;)Z + public fun getDelegate ()Lcom/adyen/checkout/components/core/internal/ui/ComponentDelegate; + public fun getViewFlow ()Lkotlinx/coroutines/flow/Flow; + public fun handleAction (Lcom/adyen/checkout/components/core/action/Action;Landroid/app/Activity;)V + public fun handleIntent (Landroid/content/Intent;)V + public fun setInteractionBlocked (Z)V + public fun setOnRedirectListener (Lkotlin/jvm/functions/Function0;)V } -public final class com/adyen/checkout/paybybankus/PayByBankUSComponentState { - public fun ()V +public final class com/adyen/checkout/paybybankus/PayByBankUSComponent$Companion { +} + +public final class com/adyen/checkout/paybybankus/PayByBankUSComponentState : com/adyen/checkout/components/core/PaymentComponentState { + public fun (Lcom/adyen/checkout/components/core/PaymentComponentData;ZZ)V + public final fun component1 ()Lcom/adyen/checkout/components/core/PaymentComponentData; + public final fun component2 ()Z + public final fun component3 ()Z + public final fun copy (Lcom/adyen/checkout/components/core/PaymentComponentData;ZZ)Lcom/adyen/checkout/paybybankus/PayByBankUSComponentState; + public static synthetic fun copy$default (Lcom/adyen/checkout/paybybankus/PayByBankUSComponentState;Lcom/adyen/checkout/components/core/PaymentComponentData;ZZILjava/lang/Object;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponentState; + public fun equals (Ljava/lang/Object;)Z + public fun getData ()Lcom/adyen/checkout/components/core/PaymentComponentData; + public fun hashCode ()I + public fun isInputValid ()Z + public fun isReady ()Z + public fun isValid ()Z + public fun toString ()Ljava/lang/String; } public final class com/adyen/checkout/paybybankus/PayByBankUSConfiguration : com/adyen/checkout/components/core/internal/Configuration { @@ -45,13 +69,6 @@ public final class com/adyen/checkout/paybybankus/PayByBankUSConfigurationKt { public static synthetic fun payByBankUS$default (Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/adyen/checkout/components/core/CheckoutConfiguration; } -public final class com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate { - public fun ()V -} - -public abstract interface class com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate { -} - public final class com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvider { public fun ()V } @@ -60,14 +77,6 @@ public final class com/adyen/checkout/paybybankus/internal/provider/PayByBankUSC public fun ()V } -public final class com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSInputData { - public fun ()V -} - -public final class com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData { - public fun ()V -} - public final class com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView { public fun ()V } diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt index 6a4518cfbb..d847d39773 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt @@ -8,6 +8,69 @@ package com.adyen.checkout.paybybankus -class PayByBankUSComponent { - // TODO implement +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.ViewModel +import com.adyen.checkout.action.core.internal.ActionHandlingComponent +import com.adyen.checkout.action.core.internal.DefaultActionHandlingComponent +import com.adyen.checkout.action.core.internal.ui.GenericActionDelegate +import com.adyen.checkout.components.core.PaymentMethodTypes +import com.adyen.checkout.components.core.internal.ComponentEventHandler +import com.adyen.checkout.components.core.internal.PaymentComponent +import com.adyen.checkout.components.core.internal.PaymentComponentEvent +import com.adyen.checkout.components.core.internal.ui.ComponentDelegate +import com.adyen.checkout.paybybankus.internal.PayByBankUSDelegate +import com.adyen.checkout.paybybankus.internal.provider.PayByBankUSComponentProvider +import com.adyen.checkout.ui.core.internal.ui.ComponentViewType +import com.adyen.checkout.ui.core.internal.ui.ViewableComponent +import kotlinx.coroutines.flow.Flow + +/** + * A [PaymentComponent] that supports the [PaymentMethodTypes.PAY_BY_BANK_US] payment method. + */ +// TODO remove the suppress annotation after complete implementation +@Suppress("UnusedPrivateProperty", "UnusedParameter") +class PayByBankUSComponent internal constructor( + private val payByBankUSDelegate: PayByBankUSDelegate, + private val genericActionDelegate: GenericActionDelegate, + private val actionHandlingComponent: DefaultActionHandlingComponent, + internal val componentEventHandler: ComponentEventHandler, +) : ViewModel(), + PaymentComponent, + ViewableComponent, + ActionHandlingComponent by actionHandlingComponent { + + override val delegate: ComponentDelegate + get() = TODO("Not yet implemented") + + override val viewFlow: Flow + get() = TODO("Not yet implemented") + + internal fun observe( + lifecycleOwner: LifecycleOwner, + callback: (PaymentComponentEvent) -> Unit + ) { + TODO("Not yet implemented") + } + + internal fun removeObserver() { + TODO("Not yet implemented") + } + + override fun setInteractionBlocked(isInteractionBlocked: Boolean) { + TODO("Not yet implemented") + } + + override fun onCleared() { + super.onCleared() + TODO("Not yet implemented") + } + + companion object { + + @JvmField + val PROVIDER = PayByBankUSComponentProvider() + + @JvmField + val PAYMENT_METHOD_TYPES = listOf(PaymentMethodTypes.PAY_BY_BANK_US) + } } diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponentState.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponentState.kt index 78cf31085f..45c1550bf3 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponentState.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponentState.kt @@ -8,6 +8,15 @@ package com.adyen.checkout.paybybankus -class PayByBankUSComponentState { - // TODO implement -} +import com.adyen.checkout.components.core.PaymentComponentData +import com.adyen.checkout.components.core.PaymentComponentState +import com.adyen.checkout.components.core.paymentmethod.PayByBankUSPaymentMethod + +/** + * Represents the state of [PayByBankUSComponent]. + */ +data class PayByBankUSComponentState( + override val data: PaymentComponentData, + override val isInputValid: Boolean, + override val isReady: Boolean +) : PaymentComponentState diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt index 2e8042bc31..fd5fa6d4ee 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt @@ -8,6 +8,84 @@ package com.adyen.checkout.paybybankus.internal -class DefaultPayByBankUSDelegate { - // TODO implement +import androidx.lifecycle.LifecycleOwner +import com.adyen.checkout.components.core.Order +import com.adyen.checkout.components.core.PaymentMethod +import com.adyen.checkout.components.core.internal.PaymentComponentEvent +import com.adyen.checkout.components.core.internal.PaymentObserverRepository +import com.adyen.checkout.components.core.internal.analytics.AnalyticsManager +import com.adyen.checkout.components.core.internal.ui.model.ButtonComponentParams +import com.adyen.checkout.paybybankus.PayByBankUSComponentState +import com.adyen.checkout.ui.core.internal.ui.ComponentViewType +import com.adyen.checkout.ui.core.internal.ui.PaymentComponentUIEvent +import com.adyen.checkout.ui.core.internal.ui.PaymentComponentUIState +import com.adyen.checkout.ui.core.internal.ui.SubmitHandler +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.Flow + +// TODO remove the suppress annotation after complete implementation +@Suppress("UnusedPrivateProperty", "UnusedParameter") +internal class DefaultPayByBankUSDelegate( + private val observerRepository: PaymentObserverRepository, + private val paymentMethod: PaymentMethod, + private val order: Order?, + override val componentParams: ButtonComponentParams, + private val analyticsManager: AnalyticsManager, + private val submitHandler: SubmitHandler, +) : PayByBankUSDelegate { + + override val componentStateFlow: Flow + get() = TODO("Not yet implemented") + + override val viewFlow: Flow + get() = TODO("Not yet implemented") + + override val submitFlow: Flow + get() = TODO("Not yet implemented") + + override val uiStateFlow: Flow + get() = TODO("Not yet implemented") + + override val uiEventFlow: Flow + get() = TODO("Not yet implemented") + + override fun initialize(coroutineScope: CoroutineScope) { + TODO("Not yet implemented") + } + + override fun observe( + lifecycleOwner: LifecycleOwner, + coroutineScope: CoroutineScope, + callback: (PaymentComponentEvent) -> Unit + ) { + TODO("Not yet implemented") + } + + override fun removeObserver() { + TODO("Not yet implemented") + } + + override fun getPaymentMethodType(): String { + TODO("Not yet implemented") + } + + override fun onSubmit() { + TODO("Not yet implemented") + } + + override fun isConfirmationRequired(): Boolean { + TODO("Not yet implemented") + } + + override fun shouldShowSubmitButton(): Boolean { + TODO("Not yet implemented") + } + + override fun setInteractionBlocked(isInteractionBlocked: Boolean) { + TODO("Not yet implemented") + } + + override fun onCleared() { + TODO("Not yet implemented") + } } diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt index 07c671a860..91120c31ee 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt @@ -8,6 +8,20 @@ package com.adyen.checkout.paybybankus.internal -interface PayByBankUSDelegate { - // TODO implement +import com.adyen.checkout.components.core.internal.ui.PaymentComponentDelegate +import com.adyen.checkout.paybybankus.PayByBankUSComponentState +import com.adyen.checkout.ui.core.internal.ui.ButtonDelegate +import com.adyen.checkout.ui.core.internal.ui.UIStateDelegate +import com.adyen.checkout.ui.core.internal.ui.ViewProvidingDelegate +import kotlinx.coroutines.flow.Flow + +internal interface PayByBankUSDelegate : + PaymentComponentDelegate, + ViewProvidingDelegate, + ButtonDelegate, + UIStateDelegate { + + val componentStateFlow: Flow + + fun setInteractionBlocked(isInteractionBlocked: Boolean) } diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSInputData.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSInputData.kt deleted file mode 100644 index 2b06c0ec71..0000000000 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSInputData.kt +++ /dev/null @@ -1,13 +0,0 @@ -/* - * 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.paybybankus.internal.ui.model - -class PayByBankUSInputData { - // TODO implement -} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt deleted file mode 100644 index 87399d1534..0000000000 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt +++ /dev/null @@ -1,13 +0,0 @@ -/* - * 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.paybybankus.internal.ui.model - -class PayByBankUSOutputData { - // TODO implement -} From 24bd06e0915ab95ec42839ef02453ca819b4951e Mon Sep 17 00:00:00 2001 From: ozgur <6615094+ozgur00@users.noreply.github.com> Date: Fri, 1 Nov 2024 09:15:00 +0100 Subject: [PATCH 06/15] Implement PayByBankUSComponentProvider COAND-974 --- paybybank-us/api/paybybank-us.api | 32 ++- .../provider/PayByBankUSComponentProvider.kt | 268 +++++++++++++++++- 2 files changed, 296 insertions(+), 4 deletions(-) diff --git a/paybybank-us/api/paybybank-us.api b/paybybank-us/api/paybybank-us.api index e42b0db140..3ac16f012c 100644 --- a/paybybank-us/api/paybybank-us.api +++ b/paybybank-us/api/paybybank-us.api @@ -73,8 +73,36 @@ public final class com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvid public fun ()V } -public final class com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider { - public fun ()V +public final class com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider : com/adyen/checkout/components/core/internal/provider/PaymentComponentProvider, com/adyen/checkout/sessions/core/internal/provider/SessionPaymentComponentProvider { + public synthetic fun get (Landroidx/activity/ComponentActivity;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/activity/ComponentActivity;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/activity/ComponentActivity;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/internal/Configuration;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/activity/ComponentActivity;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/paybybankus/PayByBankUSConfiguration;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/activity/ComponentActivity;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/activity/ComponentActivity;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/activity/ComponentActivity;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/internal/Configuration;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/activity/ComponentActivity;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/paybybankus/PayByBankUSConfiguration;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/activity/ComponentActivity;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/activity/ComponentActivity;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/fragment/app/Fragment;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/fragment/app/Fragment;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/fragment/app/Fragment;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/internal/Configuration;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/fragment/app/Fragment;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/paybybankus/PayByBankUSConfiguration;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/fragment/app/Fragment;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/fragment/app/Fragment;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/fragment/app/Fragment;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/internal/Configuration;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/fragment/app/Fragment;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/paybybankus/PayByBankUSConfiguration;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/fragment/app/Fragment;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/fragment/app/Fragment;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/savedstate/SavedStateRegistryOwner;Landroidx/lifecycle/ViewModelStoreOwner;Landroidx/lifecycle/LifecycleOwner;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Landroid/app/Application;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/savedstate/SavedStateRegistryOwner;Landroidx/lifecycle/ViewModelStoreOwner;Landroidx/lifecycle/LifecycleOwner;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Landroid/app/Application;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/savedstate/SavedStateRegistryOwner;Landroidx/lifecycle/ViewModelStoreOwner;Landroidx/lifecycle/LifecycleOwner;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/internal/Configuration;Landroid/app/Application;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/savedstate/SavedStateRegistryOwner;Landroidx/lifecycle/ViewModelStoreOwner;Landroidx/lifecycle/LifecycleOwner;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/paybybankus/PayByBankUSConfiguration;Landroid/app/Application;Lcom/adyen/checkout/components/core/ComponentCallback;Lcom/adyen/checkout/components/core/OrderRequest;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/savedstate/SavedStateRegistryOwner;Landroidx/lifecycle/ViewModelStoreOwner;Landroidx/lifecycle/LifecycleOwner;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Landroid/app/Application;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/savedstate/SavedStateRegistryOwner;Landroidx/lifecycle/ViewModelStoreOwner;Landroidx/lifecycle/LifecycleOwner;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/CheckoutConfiguration;Landroid/app/Application;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public synthetic fun get (Landroidx/savedstate/SavedStateRegistryOwner;Landroidx/lifecycle/ViewModelStoreOwner;Landroidx/lifecycle/LifecycleOwner;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/components/core/internal/Configuration;Landroid/app/Application;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/components/core/internal/PaymentComponent; + public fun get (Landroidx/savedstate/SavedStateRegistryOwner;Landroidx/lifecycle/ViewModelStoreOwner;Landroidx/lifecycle/LifecycleOwner;Lcom/adyen/checkout/sessions/core/CheckoutSession;Lcom/adyen/checkout/components/core/PaymentMethod;Lcom/adyen/checkout/paybybankus/PayByBankUSConfiguration;Landroid/app/Application;Lcom/adyen/checkout/sessions/core/SessionComponentCallback;Ljava/lang/String;)Lcom/adyen/checkout/paybybankus/PayByBankUSComponent; + public fun isPaymentMethodSupported (Lcom/adyen/checkout/components/core/PaymentMethod;)Z } public final class com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView { diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider.kt index baddb855e7..a9dc0c261f 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider.kt @@ -8,6 +8,270 @@ package com.adyen.checkout.paybybankus.internal.provider -class PayByBankUSComponentProvider { - // TODO implement +import android.app.Application +import androidx.annotation.RestrictTo +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.ViewModelStoreOwner +import androidx.savedstate.SavedStateRegistryOwner +import com.adyen.checkout.action.core.internal.DefaultActionHandlingComponent +import com.adyen.checkout.action.core.internal.provider.GenericActionComponentProvider +import com.adyen.checkout.components.core.CheckoutConfiguration +import com.adyen.checkout.components.core.ComponentCallback +import com.adyen.checkout.components.core.Order +import com.adyen.checkout.components.core.PaymentMethod +import com.adyen.checkout.components.core.internal.DefaultComponentEventHandler +import com.adyen.checkout.components.core.internal.PaymentObserverRepository +import com.adyen.checkout.components.core.internal.analytics.AnalyticsManager +import com.adyen.checkout.components.core.internal.analytics.AnalyticsManagerFactory +import com.adyen.checkout.components.core.internal.analytics.AnalyticsSource +import com.adyen.checkout.components.core.internal.provider.PaymentComponentProvider +import com.adyen.checkout.components.core.internal.ui.model.ButtonComponentParamsMapper +import com.adyen.checkout.components.core.internal.ui.model.CommonComponentParamsMapper +import com.adyen.checkout.components.core.internal.ui.model.DropInOverrideParams +import com.adyen.checkout.components.core.internal.util.get +import com.adyen.checkout.components.core.internal.util.viewModelFactory +import com.adyen.checkout.core.exception.ComponentException +import com.adyen.checkout.core.internal.data.api.HttpClientFactory +import com.adyen.checkout.core.internal.util.LocaleProvider +import com.adyen.checkout.paybybankus.PayByBankUSComponent +import com.adyen.checkout.paybybankus.PayByBankUSComponentState +import com.adyen.checkout.paybybankus.PayByBankUSConfiguration +import com.adyen.checkout.paybybankus.getPayByBankUSConfiguration +import com.adyen.checkout.paybybankus.internal.DefaultPayByBankUSDelegate +import com.adyen.checkout.paybybankus.toCheckoutConfiguration +import com.adyen.checkout.sessions.core.CheckoutSession +import com.adyen.checkout.sessions.core.SessionComponentCallback +import com.adyen.checkout.sessions.core.internal.SessionComponentEventHandler +import com.adyen.checkout.sessions.core.internal.SessionInteractor +import com.adyen.checkout.sessions.core.internal.SessionSavedStateHandleContainer +import com.adyen.checkout.sessions.core.internal.data.api.SessionRepository +import com.adyen.checkout.sessions.core.internal.data.api.SessionService +import com.adyen.checkout.sessions.core.internal.provider.SessionPaymentComponentProvider +import com.adyen.checkout.sessions.core.internal.ui.model.SessionParamsFactory +import com.adyen.checkout.ui.core.internal.ui.SubmitHandler + +class PayByBankUSComponentProvider +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +constructor( + private val dropInOverrideParams: DropInOverrideParams? = null, + private val analyticsManager: AnalyticsManager? = null, + private val localeProvider: LocaleProvider = LocaleProvider(), +) : + PaymentComponentProvider< + PayByBankUSComponent, + PayByBankUSConfiguration, + PayByBankUSComponentState, + ComponentCallback, + >, + SessionPaymentComponentProvider< + PayByBankUSComponent, + PayByBankUSConfiguration, + PayByBankUSComponentState, + SessionComponentCallback, + > { + + override fun get( + savedStateRegistryOwner: SavedStateRegistryOwner, + viewModelStoreOwner: ViewModelStoreOwner, + lifecycleOwner: LifecycleOwner, + paymentMethod: PaymentMethod, + checkoutConfiguration: CheckoutConfiguration, + application: Application, + componentCallback: ComponentCallback, + order: Order?, + key: String? + ): PayByBankUSComponent { + assertSupported(paymentMethod) + + val genericFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle -> + val componentParams = + ButtonComponentParamsMapper(CommonComponentParamsMapper()).mapToParams( + checkoutConfiguration = checkoutConfiguration, + deviceLocale = localeProvider.getLocale(application), + dropInOverrideParams = dropInOverrideParams, + componentSessionParams = null, + componentConfiguration = checkoutConfiguration.getPayByBankUSConfiguration(), + ) + + val analyticsManager = analyticsManager ?: AnalyticsManagerFactory().provide( + componentParams = componentParams, + application = application, + source = AnalyticsSource.PaymentComponent(paymentMethod.type.orEmpty()), + sessionId = null, + ) + + val payByBankUSDelegate = DefaultPayByBankUSDelegate( + observerRepository = PaymentObserverRepository(), + paymentMethod = paymentMethod, + order = order, + componentParams = componentParams, + analyticsManager = analyticsManager, + submitHandler = SubmitHandler(savedStateHandle), + ) + + val genericActionDelegate = + GenericActionComponentProvider(analyticsManager, dropInOverrideParams).getDelegate( + checkoutConfiguration = checkoutConfiguration, + savedStateHandle = savedStateHandle, + application = application, + ) + + PayByBankUSComponent( + payByBankUSDelegate = payByBankUSDelegate, + genericActionDelegate = genericActionDelegate, + actionHandlingComponent = DefaultActionHandlingComponent( + genericActionDelegate, + payByBankUSDelegate, + ), + componentEventHandler = DefaultComponentEventHandler(), + ) + } + + return ViewModelProvider(viewModelStoreOwner, genericFactory)[key, PayByBankUSComponent::class.java] + .also { component -> + component.observe(lifecycleOwner) { + component.componentEventHandler.onPaymentComponentEvent(it, componentCallback) + } + } + } + + override fun get( + savedStateRegistryOwner: SavedStateRegistryOwner, + viewModelStoreOwner: ViewModelStoreOwner, + lifecycleOwner: LifecycleOwner, + paymentMethod: PaymentMethod, + configuration: PayByBankUSConfiguration, + application: Application, + componentCallback: ComponentCallback, + order: Order?, + key: String? + ): PayByBankUSComponent { + return get( + savedStateRegistryOwner = savedStateRegistryOwner, + viewModelStoreOwner = viewModelStoreOwner, + lifecycleOwner = lifecycleOwner, + paymentMethod = paymentMethod, + checkoutConfiguration = configuration.toCheckoutConfiguration(), + application = application, + componentCallback = componentCallback, + order = order, + key = key, + ) + } + + @Suppress("LongMethod") + override fun get( + savedStateRegistryOwner: SavedStateRegistryOwner, + viewModelStoreOwner: ViewModelStoreOwner, + lifecycleOwner: LifecycleOwner, + checkoutSession: CheckoutSession, + paymentMethod: PaymentMethod, + checkoutConfiguration: CheckoutConfiguration, + application: Application, + componentCallback: SessionComponentCallback, + key: String? + ): PayByBankUSComponent { + assertSupported(paymentMethod) + + val genericFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle -> + val componentParams = ButtonComponentParamsMapper(CommonComponentParamsMapper()).mapToParams( + checkoutConfiguration = checkoutConfiguration, + deviceLocale = localeProvider.getLocale(application), + dropInOverrideParams = dropInOverrideParams, + componentSessionParams = SessionParamsFactory.create(checkoutSession), + componentConfiguration = checkoutConfiguration.getPayByBankUSConfiguration(), + ) + + val httpClient = HttpClientFactory.getHttpClient(componentParams.environment) + + val analyticsManager = analyticsManager ?: AnalyticsManagerFactory().provide( + componentParams = componentParams, + application = application, + source = AnalyticsSource.PaymentComponent(paymentMethod.type.orEmpty()), + sessionId = checkoutSession.sessionSetupResponse.id, + ) + + val payByBankDelegate = DefaultPayByBankUSDelegate( + observerRepository = PaymentObserverRepository(), + paymentMethod = paymentMethod, + order = checkoutSession.order, + componentParams = componentParams, + analyticsManager = analyticsManager, + submitHandler = SubmitHandler(savedStateHandle), + ) + + val genericActionDelegate = + GenericActionComponentProvider(analyticsManager, dropInOverrideParams).getDelegate( + checkoutConfiguration = checkoutConfiguration, + savedStateHandle = savedStateHandle, + application = application, + ) + + val sessionSavedStateHandleContainer = SessionSavedStateHandleContainer( + savedStateHandle = savedStateHandle, + checkoutSession = checkoutSession, + ) + val sessionInteractor = SessionInteractor( + sessionRepository = SessionRepository( + sessionService = SessionService(httpClient), + clientKey = componentParams.clientKey, + ), + sessionModel = sessionSavedStateHandleContainer.getSessionModel(), + isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false, + ) + val sessionComponentEventHandler = SessionComponentEventHandler( + sessionInteractor = sessionInteractor, + sessionSavedStateHandleContainer = sessionSavedStateHandleContainer, + ) + + PayByBankUSComponent( + payByBankUSDelegate = payByBankDelegate, + genericActionDelegate = genericActionDelegate, + actionHandlingComponent = DefaultActionHandlingComponent(genericActionDelegate, payByBankDelegate), + componentEventHandler = sessionComponentEventHandler, + ) + } + + return ViewModelProvider(viewModelStoreOwner, genericFactory)[key, PayByBankUSComponent::class.java] + .also { component -> + component.observe(lifecycleOwner) { + component.componentEventHandler.onPaymentComponentEvent(it, componentCallback) + } + } + } + + override fun get( + savedStateRegistryOwner: SavedStateRegistryOwner, + viewModelStoreOwner: ViewModelStoreOwner, + lifecycleOwner: LifecycleOwner, + checkoutSession: CheckoutSession, + paymentMethod: PaymentMethod, + configuration: PayByBankUSConfiguration, + application: Application, + componentCallback: SessionComponentCallback, + key: String? + ): PayByBankUSComponent { + return get( + savedStateRegistryOwner = savedStateRegistryOwner, + viewModelStoreOwner = viewModelStoreOwner, + lifecycleOwner = lifecycleOwner, + checkoutSession = checkoutSession, + paymentMethod = paymentMethod, + checkoutConfiguration = configuration.toCheckoutConfiguration(), + application = application, + componentCallback = componentCallback, + key = key, + ) + } + + private fun assertSupported(paymentMethod: PaymentMethod) { + if (!isPaymentMethodSupported(paymentMethod)) { + throw ComponentException("Unsupported payment method ${paymentMethod.type}") + } + } + + override fun isPaymentMethodSupported(paymentMethod: PaymentMethod): Boolean { + return PayByBankUSComponent.PAYMENT_METHOD_TYPES.contains(paymentMethod.type) + } } From 814d0b10441d04d526ae3e3a977945b776119e7e Mon Sep 17 00:00:00 2001 From: ozgur <6615094+ozgur00@users.noreply.github.com> Date: Fri, 1 Nov 2024 09:43:55 +0100 Subject: [PATCH 07/15] Implement PayByBankUSComponent COAND-974 --- .../paybybankus/PayByBankUSComponent.kt | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt index d847d39773..f5bde79afd 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/PayByBankUSComponent.kt @@ -10,6 +10,7 @@ package com.adyen.checkout.paybybankus import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope import com.adyen.checkout.action.core.internal.ActionHandlingComponent import com.adyen.checkout.action.core.internal.DefaultActionHandlingComponent import com.adyen.checkout.action.core.internal.ui.GenericActionDelegate @@ -17,11 +18,15 @@ import com.adyen.checkout.components.core.PaymentMethodTypes import com.adyen.checkout.components.core.internal.ComponentEventHandler import com.adyen.checkout.components.core.internal.PaymentComponent import com.adyen.checkout.components.core.internal.PaymentComponentEvent +import com.adyen.checkout.components.core.internal.toActionCallback import com.adyen.checkout.components.core.internal.ui.ComponentDelegate +import com.adyen.checkout.core.AdyenLogLevel +import com.adyen.checkout.core.internal.util.adyenLog import com.adyen.checkout.paybybankus.internal.PayByBankUSDelegate import com.adyen.checkout.paybybankus.internal.provider.PayByBankUSComponentProvider import com.adyen.checkout.ui.core.internal.ui.ComponentViewType import com.adyen.checkout.ui.core.internal.ui.ViewableComponent +import com.adyen.checkout.ui.core.internal.util.mergeViewFlows import kotlinx.coroutines.flow.Flow /** @@ -39,30 +44,43 @@ class PayByBankUSComponent internal constructor( ViewableComponent, ActionHandlingComponent by actionHandlingComponent { - override val delegate: ComponentDelegate - get() = TODO("Not yet implemented") + override val delegate: ComponentDelegate get() = actionHandlingComponent.activeDelegate - override val viewFlow: Flow - get() = TODO("Not yet implemented") + override val viewFlow: Flow = mergeViewFlows( + viewModelScope, + payByBankUSDelegate.viewFlow, + genericActionDelegate.viewFlow, + ) + + init { + payByBankUSDelegate.initialize(viewModelScope) + genericActionDelegate.initialize(viewModelScope) + componentEventHandler.initialize(viewModelScope) + } internal fun observe( lifecycleOwner: LifecycleOwner, callback: (PaymentComponentEvent) -> Unit ) { - TODO("Not yet implemented") + payByBankUSDelegate.observe(lifecycleOwner, viewModelScope, callback) + genericActionDelegate.observe(lifecycleOwner, viewModelScope, callback.toActionCallback()) } internal fun removeObserver() { - TODO("Not yet implemented") + payByBankUSDelegate.removeObserver() + genericActionDelegate.removeObserver() } override fun setInteractionBlocked(isInteractionBlocked: Boolean) { - TODO("Not yet implemented") + (delegate as? PayByBankUSDelegate)?.setInteractionBlocked(isInteractionBlocked) + ?: adyenLog(AdyenLogLevel.ERROR) { "Payment component is not interactable, ignoring." } } override fun onCleared() { super.onCleared() - TODO("Not yet implemented") + payByBankUSDelegate.onCleared() + genericActionDelegate.onCleared() + componentEventHandler.onCleared() } companion object { From 86e7af5a5cfe6d1019048639bad440fa3442b8bd Mon Sep 17 00:00:00 2001 From: ozgur <6615094+ozgur00@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:36:34 +0100 Subject: [PATCH 08/15] Implement DefaultPayByBankUSDelegate COAND-974 --- .../internal/DefaultPayByBankUSDelegate.kt | 91 +++++++++++++------ 1 file changed, 64 insertions(+), 27 deletions(-) diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt index fd5fa6d4ee..d51824db30 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt @@ -10,21 +10,28 @@ package com.adyen.checkout.paybybankus.internal import androidx.lifecycle.LifecycleOwner import com.adyen.checkout.components.core.Order +import com.adyen.checkout.components.core.PaymentComponentData import com.adyen.checkout.components.core.PaymentMethod +import com.adyen.checkout.components.core.PaymentMethodTypes import com.adyen.checkout.components.core.internal.PaymentComponentEvent import com.adyen.checkout.components.core.internal.PaymentObserverRepository import com.adyen.checkout.components.core.internal.analytics.AnalyticsManager +import com.adyen.checkout.components.core.internal.analytics.GenericEvents import com.adyen.checkout.components.core.internal.ui.model.ButtonComponentParams +import com.adyen.checkout.components.core.paymentmethod.PayByBankUSPaymentMethod +import com.adyen.checkout.core.AdyenLogLevel +import com.adyen.checkout.core.internal.util.adyenLog import com.adyen.checkout.paybybankus.PayByBankUSComponentState +import com.adyen.checkout.ui.core.internal.ui.ButtonComponentViewType import com.adyen.checkout.ui.core.internal.ui.ComponentViewType import com.adyen.checkout.ui.core.internal.ui.PaymentComponentUIEvent import com.adyen.checkout.ui.core.internal.ui.PaymentComponentUIState import com.adyen.checkout.ui.core.internal.ui.SubmitHandler import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableStateFlow -// TODO remove the suppress annotation after complete implementation -@Suppress("UnusedPrivateProperty", "UnusedParameter") +@Suppress("TooManyFunctions") internal class DefaultPayByBankUSDelegate( private val observerRepository: PaymentObserverRepository, private val paymentMethod: PaymentMethod, @@ -34,23 +41,28 @@ internal class DefaultPayByBankUSDelegate( private val submitHandler: SubmitHandler, ) : PayByBankUSDelegate { - override val componentStateFlow: Flow - get() = TODO("Not yet implemented") + private val _componentStateFlow = MutableStateFlow(createComponentState()) + override val componentStateFlow: Flow = _componentStateFlow - override val viewFlow: Flow - get() = TODO("Not yet implemented") + // TODO push pay by bank us view after implementing view provider and view + private val _viewFlow: MutableStateFlow = MutableStateFlow(null) + override val viewFlow: Flow = _viewFlow - override val submitFlow: Flow - get() = TODO("Not yet implemented") + override val submitFlow: Flow = submitHandler.submitFlow + override val uiStateFlow: Flow = submitHandler.uiStateFlow + override val uiEventFlow: Flow = submitHandler.uiEventFlow - override val uiStateFlow: Flow - get() = TODO("Not yet implemented") + override fun initialize(coroutineScope: CoroutineScope) { + submitHandler.initialize(coroutineScope, componentStateFlow) + initializeAnalytics(coroutineScope) + } - override val uiEventFlow: Flow - get() = TODO("Not yet implemented") + private fun initializeAnalytics(coroutineScope: CoroutineScope) { + adyenLog(AdyenLogLevel.VERBOSE) { "initializeAnalytics" } + analyticsManager.initialize(this, coroutineScope) - override fun initialize(coroutineScope: CoroutineScope) { - TODO("Not yet implemented") + val event = GenericEvents.rendered(paymentMethod.type.orEmpty()) + analyticsManager.trackEvent(event) } override fun observe( @@ -58,34 +70,59 @@ internal class DefaultPayByBankUSDelegate( coroutineScope: CoroutineScope, callback: (PaymentComponentEvent) -> Unit ) { - TODO("Not yet implemented") + observerRepository.addObservers( + stateFlow = componentStateFlow, + exceptionFlow = null, + submitFlow = submitFlow, + lifecycleOwner = lifecycleOwner, + coroutineScope = coroutineScope, + callback = callback, + ) } override fun removeObserver() { - TODO("Not yet implemented") + observerRepository.removeObservers() } - override fun getPaymentMethodType(): String { - TODO("Not yet implemented") + override fun getPaymentMethodType(): String = paymentMethod.type ?: PaymentMethodTypes.UNKNOWN + + private fun createComponentState(): PayByBankUSComponentState { + val payByBankUsPaymentMethod = PayByBankUSPaymentMethod( + type = getPaymentMethodType(), + checkoutAttemptId = analyticsManager.getCheckoutAttemptId(), + ) + + val paymentComponentData = PaymentComponentData( + paymentMethod = payByBankUsPaymentMethod, + order = order, + amount = componentParams.amount, + ) + + return PayByBankUSComponentState( + data = paymentComponentData, + isInputValid = true, + isReady = true, + ) } override fun onSubmit() { - TODO("Not yet implemented") - } + val event = GenericEvents.submit(paymentMethod.type.orEmpty()) + analyticsManager.trackEvent(event) - override fun isConfirmationRequired(): Boolean { - TODO("Not yet implemented") + val state = _componentStateFlow.value + submitHandler.onSubmit(state = state) } - override fun shouldShowSubmitButton(): Boolean { - TODO("Not yet implemented") - } + override fun isConfirmationRequired(): Boolean = _viewFlow.value is ButtonComponentViewType + + override fun shouldShowSubmitButton(): Boolean = isConfirmationRequired() && componentParams.isSubmitButtonVisible override fun setInteractionBlocked(isInteractionBlocked: Boolean) { - TODO("Not yet implemented") + submitHandler.setInteractionBlocked(isInteractionBlocked) } override fun onCleared() { - TODO("Not yet implemented") + removeObserver() + analyticsManager.clear(this) } } From a4c6583afa7a33e5fee8bc06a71c0ebcc2e3c6e4 Mon Sep 17 00:00:00 2001 From: ozgur <6615094+ozgur00@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:39:52 +0100 Subject: [PATCH 09/15] Implement ui for PayByBankUSComponent COAND-974 --- paybybank-us/api/paybybank-us.api | 15 +-- .../internal/DefaultPayByBankUSDelegate.kt | 28 ++++- .../internal/PayByBankUSDelegate.kt | 5 + .../internal/PayByBankUSViewProvider.kt | 22 +++- .../internal/ui/model/PayByBankUSBrandLogo.kt | 16 +++ .../ui/model/PayByBankUSOutputData.kt | 18 ++++ .../internal/ui/view/PayByBankUSView.kt | 87 ++++++++++++++- .../main/res/layout/pay_by_bank_us_view.xml | 53 ++++++++++ .../main/res/template/values/strings.xml.tt | 17 +++ .../src/main/res/values-ar/strings.xml | 15 +++ .../src/main/res/values-bg-rBG/strings.xml | 15 +++ .../src/main/res/values-ca-rES/strings.xml | 15 +++ .../src/main/res/values-cs-rCZ/strings.xml | 15 +++ .../src/main/res/values-da-rDK/strings.xml | 15 +++ .../src/main/res/values-de-rDE/strings.xml | 15 +++ .../src/main/res/values-el-rGR/strings.xml | 15 +++ .../src/main/res/values-es-rES/strings.xml | 15 +++ .../src/main/res/values-et-rEE/strings.xml | 15 +++ .../src/main/res/values-fi-rFI/strings.xml | 15 +++ .../src/main/res/values-fr-rFR/strings.xml | 15 +++ .../src/main/res/values-hr-rHR/strings.xml | 15 +++ .../src/main/res/values-hu-rHU/strings.xml | 15 +++ .../src/main/res/values-is-rIS/strings.xml | 15 +++ .../src/main/res/values-it-rIT/strings.xml | 15 +++ .../src/main/res/values-ja-rJP/strings.xml | 15 +++ .../src/main/res/values-ko-rKR/strings.xml | 15 +++ .../src/main/res/values-lt-rLT/strings.xml | 15 +++ .../src/main/res/values-lv-rLV/strings.xml | 15 +++ .../src/main/res/values-nb-rNO/strings.xml | 15 +++ .../src/main/res/values-nl-rNL/strings.xml | 15 +++ .../src/main/res/values-pl-rPL/strings.xml | 15 +++ .../src/main/res/values-pt-rBR/strings.xml | 15 +++ .../src/main/res/values-pt-rPT/strings.xml | 15 +++ .../src/main/res/values-ro-rRO/strings.xml | 15 +++ .../src/main/res/values-ru-rRU/strings.xml | 15 +++ .../src/main/res/values-sk-rSK/strings.xml | 15 +++ .../src/main/res/values-sl-rSI/strings.xml | 15 +++ .../src/main/res/values-sv-rSE/strings.xml | 15 +++ .../src/main/res/values-zh-rCN/strings.xml | 15 +++ .../src/main/res/values-zh-rTW/strings.xml | 15 +++ paybybank-us/src/main/res/values/strings.xml | 17 +++ paybybank-us/src/main/res/values/styles.xml | 54 ++++++++++ .../ui/core/internal/ui/model/LogoTextItem.kt | 41 +++++++ .../core/internal/ui/view/LogoTextAdapter.kt | 100 ++++++++++++++++++ .../src/main/res/layout/logo_view_holder.xml | 20 ++++ .../src/main/res/layout/text_view_holder.xml | 17 +++ ui-core/src/main/res/values/dimens.xml | 3 + ui-core/src/main/res/values/styles.xml | 12 +++ 48 files changed, 978 insertions(+), 12 deletions(-) create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSBrandLogo.kt create mode 100644 paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt create mode 100644 paybybank-us/src/main/res/layout/pay_by_bank_us_view.xml create mode 100644 paybybank-us/src/main/res/template/values/strings.xml.tt create mode 100644 paybybank-us/src/main/res/values-ar/strings.xml create mode 100644 paybybank-us/src/main/res/values-bg-rBG/strings.xml create mode 100644 paybybank-us/src/main/res/values-ca-rES/strings.xml create mode 100644 paybybank-us/src/main/res/values-cs-rCZ/strings.xml create mode 100644 paybybank-us/src/main/res/values-da-rDK/strings.xml create mode 100644 paybybank-us/src/main/res/values-de-rDE/strings.xml create mode 100644 paybybank-us/src/main/res/values-el-rGR/strings.xml create mode 100644 paybybank-us/src/main/res/values-es-rES/strings.xml create mode 100644 paybybank-us/src/main/res/values-et-rEE/strings.xml create mode 100644 paybybank-us/src/main/res/values-fi-rFI/strings.xml create mode 100644 paybybank-us/src/main/res/values-fr-rFR/strings.xml create mode 100644 paybybank-us/src/main/res/values-hr-rHR/strings.xml create mode 100644 paybybank-us/src/main/res/values-hu-rHU/strings.xml create mode 100644 paybybank-us/src/main/res/values-is-rIS/strings.xml create mode 100644 paybybank-us/src/main/res/values-it-rIT/strings.xml create mode 100644 paybybank-us/src/main/res/values-ja-rJP/strings.xml create mode 100644 paybybank-us/src/main/res/values-ko-rKR/strings.xml create mode 100644 paybybank-us/src/main/res/values-lt-rLT/strings.xml create mode 100644 paybybank-us/src/main/res/values-lv-rLV/strings.xml create mode 100644 paybybank-us/src/main/res/values-nb-rNO/strings.xml create mode 100644 paybybank-us/src/main/res/values-nl-rNL/strings.xml create mode 100644 paybybank-us/src/main/res/values-pl-rPL/strings.xml create mode 100644 paybybank-us/src/main/res/values-pt-rBR/strings.xml create mode 100644 paybybank-us/src/main/res/values-pt-rPT/strings.xml create mode 100644 paybybank-us/src/main/res/values-ro-rRO/strings.xml create mode 100644 paybybank-us/src/main/res/values-ru-rRU/strings.xml create mode 100644 paybybank-us/src/main/res/values-sk-rSK/strings.xml create mode 100644 paybybank-us/src/main/res/values-sl-rSI/strings.xml create mode 100644 paybybank-us/src/main/res/values-sv-rSE/strings.xml create mode 100644 paybybank-us/src/main/res/values-zh-rCN/strings.xml create mode 100644 paybybank-us/src/main/res/values-zh-rTW/strings.xml create mode 100644 paybybank-us/src/main/res/values/strings.xml create mode 100644 paybybank-us/src/main/res/values/styles.xml create mode 100644 ui-core/src/main/java/com/adyen/checkout/ui/core/internal/ui/model/LogoTextItem.kt create mode 100644 ui-core/src/main/java/com/adyen/checkout/ui/core/internal/ui/view/LogoTextAdapter.kt create mode 100644 ui-core/src/main/res/layout/logo_view_holder.xml create mode 100644 ui-core/src/main/res/layout/text_view_holder.xml diff --git a/paybybank-us/api/paybybank-us.api b/paybybank-us/api/paybybank-us.api index 3ac16f012c..33a016c516 100644 --- a/paybybank-us/api/paybybank-us.api +++ b/paybybank-us/api/paybybank-us.api @@ -69,8 +69,15 @@ public final class com/adyen/checkout/paybybankus/PayByBankUSConfigurationKt { public static synthetic fun payByBankUS$default (Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/adyen/checkout/components/core/CheckoutConfiguration; } -public final class com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvider { - public fun ()V +public final class com/adyen/checkout/paybybankus/databinding/PayByBankUsViewBinding : androidx/viewbinding/ViewBinding { + public final field imageViewLogo Landroid/widget/ImageView; + public final field recyclerViewBrandList Landroidx/recyclerview/widget/RecyclerView; + public final field textViewDisclaimerBody Landroid/widget/TextView; + public final field textViewDisclaimerHeader Landroid/widget/TextView; + public final field textViewTitle Landroid/widget/TextView; + public static fun bind (Landroid/view/View;)Lcom/adyen/checkout/paybybankus/databinding/PayByBankUsViewBinding; + public fun getRoot ()Landroid/view/View; + public static fun inflate (Landroid/view/LayoutInflater;Landroid/view/ViewGroup;)Lcom/adyen/checkout/paybybankus/databinding/PayByBankUsViewBinding; } public final class com/adyen/checkout/paybybankus/internal/provider/PayByBankUSComponentProvider : com/adyen/checkout/components/core/internal/provider/PaymentComponentProvider, com/adyen/checkout/sessions/core/internal/provider/SessionPaymentComponentProvider { @@ -105,7 +112,3 @@ public final class com/adyen/checkout/paybybankus/internal/provider/PayByBankUSC public fun isPaymentMethodSupported (Lcom/adyen/checkout/components/core/PaymentMethod;)Z } -public final class com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView { - public fun ()V -} - diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt index d51824db30..8e22138ca2 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/DefaultPayByBankUSDelegate.kt @@ -22,11 +22,17 @@ import com.adyen.checkout.components.core.paymentmethod.PayByBankUSPaymentMethod import com.adyen.checkout.core.AdyenLogLevel import com.adyen.checkout.core.internal.util.adyenLog import com.adyen.checkout.paybybankus.PayByBankUSComponentState +import com.adyen.checkout.paybybankus.R +import com.adyen.checkout.paybybankus.internal.ui.model.PayByBankUSBrandLogo +import com.adyen.checkout.paybybankus.internal.ui.model.PayByBankUSOutputData import com.adyen.checkout.ui.core.internal.ui.ButtonComponentViewType import com.adyen.checkout.ui.core.internal.ui.ComponentViewType import com.adyen.checkout.ui.core.internal.ui.PaymentComponentUIEvent import com.adyen.checkout.ui.core.internal.ui.PaymentComponentUIState import com.adyen.checkout.ui.core.internal.ui.SubmitHandler +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.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -41,11 +47,15 @@ internal class DefaultPayByBankUSDelegate( private val submitHandler: SubmitHandler, ) : PayByBankUSDelegate { + private val _outputDataFlow = MutableStateFlow(createOutputData()) + override val outputDataFlow: Flow = _outputDataFlow + + override val outputData: PayByBankUSOutputData = _outputDataFlow.value + private val _componentStateFlow = MutableStateFlow(createComponentState()) override val componentStateFlow: Flow = _componentStateFlow - // TODO push pay by bank us view after implementing view provider and view - private val _viewFlow: MutableStateFlow = MutableStateFlow(null) + private val _viewFlow: MutableStateFlow = MutableStateFlow(PayByBankUSComponentViewType) override val viewFlow: Flow = _viewFlow override val submitFlow: Flow = submitHandler.submitFlow @@ -86,6 +96,10 @@ internal class DefaultPayByBankUSDelegate( override fun getPaymentMethodType(): String = paymentMethod.type ?: PaymentMethodTypes.UNKNOWN + private fun createOutputData() = PayByBankUSOutputData( + brandList = getBrandList() + ) + private fun createComponentState(): PayByBankUSComponentState { val payByBankUsPaymentMethod = PayByBankUSPaymentMethod( type = getPaymentMethodType(), @@ -125,4 +139,14 @@ internal class DefaultPayByBankUSDelegate( removeObserver() analyticsManager.clear(this) } + + private fun getBrandList(): List { + return listOf( + LogoItem(PayByBankUSBrandLogo.US_1.path, componentParams.environment), + LogoItem(PayByBankUSBrandLogo.US_2.path, componentParams.environment), + LogoItem(PayByBankUSBrandLogo.US_3.path, componentParams.environment), + LogoItem(PayByBankUSBrandLogo.US_4.path, componentParams.environment), + TextItem(R.string.checkout_pay_by_bank_us_more), + ) + } } diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt index 91120c31ee..b6cc70c191 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSDelegate.kt @@ -10,6 +10,7 @@ package com.adyen.checkout.paybybankus.internal import com.adyen.checkout.components.core.internal.ui.PaymentComponentDelegate import com.adyen.checkout.paybybankus.PayByBankUSComponentState +import com.adyen.checkout.paybybankus.internal.ui.model.PayByBankUSOutputData import com.adyen.checkout.ui.core.internal.ui.ButtonDelegate import com.adyen.checkout.ui.core.internal.ui.UIStateDelegate import com.adyen.checkout.ui.core.internal.ui.ViewProvidingDelegate @@ -21,6 +22,10 @@ internal interface PayByBankUSDelegate : ButtonDelegate, UIStateDelegate { + val outputData: PayByBankUSOutputData + + val outputDataFlow: Flow + val componentStateFlow: Flow fun setInteractionBlocked(isInteractionBlocked: Boolean) diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvider.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvider.kt index ee5985ea84..031f7e0402 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvider.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/PayByBankUSViewProvider.kt @@ -8,6 +8,24 @@ package com.adyen.checkout.paybybankus.internal -class PayByBankUSViewProvider { - // TODO implement +import android.content.Context +import com.adyen.checkout.paybybankus.R +import com.adyen.checkout.paybybankus.internal.ui.view.PayByBankUSView +import com.adyen.checkout.ui.core.internal.ui.ButtonComponentViewType +import com.adyen.checkout.ui.core.internal.ui.ComponentView +import com.adyen.checkout.ui.core.internal.ui.ComponentViewType +import com.adyen.checkout.ui.core.internal.ui.ViewProvider + +internal object PayByBankUSViewProvider : ViewProvider { + override fun getView(viewType: ComponentViewType, context: Context): ComponentView { + return when (viewType) { + PayByBankUSComponentViewType -> PayByBankUSView(context) + else -> throw IllegalArgumentException("Unsupported view type") + } + } +} + +internal object PayByBankUSComponentViewType : ButtonComponentViewType { + override val viewProvider: ViewProvider = PayByBankUSViewProvider + override val buttonTextResId: Int = R.string.checkout_pay_by_bank_us_submit } 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 new file mode 100644 index 0000000000..f8033c8797 --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSBrandLogo.kt @@ -0,0 +1,16 @@ +/* + * 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 1/11/2024. + */ + +package com.adyen.checkout.paybybankus.internal.ui.model + +internal enum class PayByBankUSBrandLogo(val path: String) { + US_1("US-1"), + US_2("US-2"), + US_3("US-3"), + US_4("US-4"), +} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt new file mode 100644 index 0000000000..0cc3d03834 --- /dev/null +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/model/PayByBankUSOutputData.kt @@ -0,0 +1,18 @@ +/* + * 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 5/11/2024. + */ + +package com.adyen.checkout.paybybankus.internal.ui.model + +import com.adyen.checkout.components.core.internal.ui.model.OutputData +import com.adyen.checkout.ui.core.internal.ui.model.LogoTextItem + +internal data class PayByBankUSOutputData( + val brandList: List +) : OutputData { + override val isValid: Boolean = true +} diff --git a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView.kt b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView.kt index 7111f948a4..23c6df693b 100644 --- a/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView.kt +++ b/paybybank-us/src/main/java/com/adyen/checkout/paybybankus/internal/ui/view/PayByBankUSView.kt @@ -8,6 +8,89 @@ package com.adyen.checkout.paybybankus.internal.ui.view -class PayByBankUSView { - // TODO implement +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import android.widget.LinearLayout +import com.adyen.checkout.components.core.internal.ui.ComponentDelegate +import com.adyen.checkout.paybybankus.R +import com.adyen.checkout.paybybankus.databinding.PayByBankUsViewBinding +import com.adyen.checkout.paybybankus.internal.PayByBankUSDelegate +import com.adyen.checkout.ui.core.internal.ui.ComponentView +import com.adyen.checkout.ui.core.internal.ui.loadLogo +import com.adyen.checkout.ui.core.internal.ui.model.LogoTextItem +import com.adyen.checkout.ui.core.internal.ui.view.LogoTextAdapter +import com.adyen.checkout.ui.core.internal.util.setLocalizedTextFromStyle +import kotlinx.coroutines.CoroutineScope +import com.adyen.checkout.ui.core.R as UiCoreR + +internal class PayByBankUSView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : LinearLayout(context, attrs, defStyleAttr), ComponentView { + + private val binding: PayByBankUsViewBinding = PayByBankUsViewBinding.inflate(LayoutInflater.from(context), this) + + private lateinit var localizedContext: Context + + private lateinit var delegate: PayByBankUSDelegate + + private var logoTextAdapter: LogoTextAdapter? = null + + init { + orientation = VERTICAL + val padding = resources.getDimension(UiCoreR.dimen.standard_margin).toInt() + setPadding(0, padding, 0, 0) + } + + override fun initView(delegate: ComponentDelegate, coroutineScope: CoroutineScope, localizedContext: Context) { + require(delegate is PayByBankUSDelegate) { "Unsupported delegate type" } + this.delegate = delegate + + this.localizedContext = localizedContext + initLocalizedStrings(localizedContext) + + initPayByBankUSLogo() + initBrandList(delegate.outputData.brandList) + } + + private fun initLocalizedStrings(localizedContext: Context) { + binding.textViewTitle.setLocalizedTextFromStyle( + R.style.AdyenCheckout_PayByBankUS_Title, + localizedContext, + ) + + binding.textViewDisclaimerHeader.setLocalizedTextFromStyle( + R.style.AdyenCheckout_PayByBankUS_DisclaimerHeader, + localizedContext, + ) + + binding.textViewDisclaimerBody.setLocalizedTextFromStyle( + R.style.AdyenCheckout_PayByBankUS_DisclaimerBody, + localizedContext, + ) + } + + private fun initPayByBankUSLogo() { + binding.imageViewLogo.loadLogo( + delegate.componentParams.environment, + delegate.getPaymentMethodType(), + ) + } + + private fun initBrandList(brands: List) { + if (logoTextAdapter == null) { + logoTextAdapter = LogoTextAdapter(localizedContext) + binding.recyclerViewBrandList.adapter = logoTextAdapter + } + logoTextAdapter?.submitList(brands) + } + + override fun highlightValidationErrors() { + // no validation + } + + override fun getView(): View = this } diff --git a/paybybank-us/src/main/res/layout/pay_by_bank_us_view.xml b/paybybank-us/src/main/res/layout/pay_by_bank_us_view.xml new file mode 100644 index 0000000000..3247729172 --- /dev/null +++ b/paybybank-us/src/main/res/layout/pay_by_bank_us_view.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + diff --git a/paybybank-us/src/main/res/template/values/strings.xml.tt b/paybybank-us/src/main/res/template/values/strings.xml.tt new file mode 100644 index 0000000000..0b3991f8de --- /dev/null +++ b/paybybank-us/src/main/res/template/values/strings.xml.tt @@ -0,0 +1,17 @@ + + + + + %%payByBankAISDD.disclaimer.header%% + %%payByBankAISDD.disclaimer.body%% + %%payByBankAISDD.submit%% + %%payByBankAISDD.more%% + + Pay by Bank + diff --git a/paybybank-us/src/main/res/values-ar/strings.xml b/paybybank-us/src/main/res/values-ar/strings.xml new file mode 100644 index 0000000000..a404c47720 --- /dev/null +++ b/paybybank-us/src/main/res/values-ar/strings.xml @@ -0,0 +1,15 @@ + + + + + استخدم خدمة Pay by Bank للدفع الفوري من خلال أي حساب مصرفي. + من خلال ربط حسابك البنكي، أنت بذلك تمنحنا تفويضًا بخصم مدفوعات المبالغ المستحقة من حسابك البنكي، وذلك مقابل استخدام خدماتنا و/أو شراء منتجاتنا. ويستمر العمل بهذا التفويض إلى أن يتم إلغاؤه. + المضي قُدمًا والدفع عن طريق البنك + + المزيد + diff --git a/paybybank-us/src/main/res/values-bg-rBG/strings.xml b/paybybank-us/src/main/res/values-bg-rBG/strings.xml new file mode 100644 index 0000000000..3504f42d12 --- /dev/null +++ b/paybybank-us/src/main/res/values-bg-rBG/strings.xml @@ -0,0 +1,15 @@ + + + + + Използвайте Pay by Bank, за да платите незабавно от всяка банкова сметка. + Като свържете банковата си сметка, Вие разрешавате дебитиране на сметката Ви за всяка сума, дължима за употреба на нашите услуги и/или закупуване на нашите продукти, докато това разрешение не бъде оттеглено. + Продължете към Pay by Bank + + още + diff --git a/paybybank-us/src/main/res/values-ca-rES/strings.xml b/paybybank-us/src/main/res/values-ca-rES/strings.xml new file mode 100644 index 0000000000..a9b0c1f6c5 --- /dev/null +++ b/paybybank-us/src/main/res/values-ca-rES/strings.xml @@ -0,0 +1,15 @@ + + + + + Utilitzeu el pagament per banc per pagar a l\'instant des de qualsevol compte bancari. + En connectar el vostre compte bancari, esteu autoritzant càrrecs a aquest compte per qualsevol import degut per l\'ús dels nostres serveis o la compra dels nostres productes, fins que es revoqui aquesta autorització. + Continua a pagament per banc + + més + diff --git a/paybybank-us/src/main/res/values-cs-rCZ/strings.xml b/paybybank-us/src/main/res/values-cs-rCZ/strings.xml new file mode 100644 index 0000000000..c16af8ee53 --- /dev/null +++ b/paybybank-us/src/main/res/values-cs-rCZ/strings.xml @@ -0,0 +1,15 @@ + + + + + Použijte Pay by Bank k okamžité platbě z jakéhokoli bankovního účtu. + Připojením svého bankovního účtu vyjadřujete souhlas s tím, aby z účtu byly strženy všechny dlužné částky za využívání našich služeb a nákup našich produktů, a to až do odvolání tohoto souhlasu. + Pokračovat v platbě přes banku + + více + diff --git a/paybybank-us/src/main/res/values-da-rDK/strings.xml b/paybybank-us/src/main/res/values-da-rDK/strings.xml new file mode 100644 index 0000000000..61fad6141f --- /dev/null +++ b/paybybank-us/src/main/res/values-da-rDK/strings.xml @@ -0,0 +1,15 @@ + + + + + Brug Pay by Bank til at betale med det samme fra enhver bankkonto. + Ved at tilknytte din bankkonto tillader du debiteringer på din konto for ethvert skyldigt beløb for brug af vores tjenester og/eller køb af vores produkter, indtil denne tilladelse tilbagekaldes. + Fortsæt via Pay by Bank + + mere + diff --git a/paybybank-us/src/main/res/values-de-rDE/strings.xml b/paybybank-us/src/main/res/values-de-rDE/strings.xml new file mode 100644 index 0000000000..3d19dbfcb9 --- /dev/null +++ b/paybybank-us/src/main/res/values-de-rDE/strings.xml @@ -0,0 +1,15 @@ + + + + + Verwenden Sie Pay by Bank, um sofort von jedem Bankkonto zu bezahlen. + Durch die Verbindung Ihres Bankkontos autorisieren Sie bis auf Widerruf Abbuchungen von Ihrem Konto für alle Beträge, die für die Nutzung unserer Dienste und/oder den Kauf unserer Produkte geschuldet werden. + Weiter zu Pay by Bank + + mehr + diff --git a/paybybank-us/src/main/res/values-el-rGR/strings.xml b/paybybank-us/src/main/res/values-el-rGR/strings.xml new file mode 100644 index 0000000000..5c3634d2d0 --- /dev/null +++ b/paybybank-us/src/main/res/values-el-rGR/strings.xml @@ -0,0 +1,15 @@ + + + + + Χρησιμοποιήστε το Pay by Bank για άμεση πληρωμή από οποιονδήποτε τραπεζικό λογαριασμό. + Συνδέοντας τον τραπεζικό λογαριασμό σας, εξουσιοδοτείτε χρεώσεις στον λογαριασμό σας για οποιοδήποτε ποσό οφείλεται για τη χρήση των υπηρεσιών μας ή/και την αγορά των προϊόντων μας, έως ότου ανακληθεί αυτή η εξουσιοδότηση. + Συνεχίστε να πληρώνετε μέσω τράπεζας + + περισσότερα + diff --git a/paybybank-us/src/main/res/values-es-rES/strings.xml b/paybybank-us/src/main/res/values-es-rES/strings.xml new file mode 100644 index 0000000000..ca82557432 --- /dev/null +++ b/paybybank-us/src/main/res/values-es-rES/strings.xml @@ -0,0 +1,15 @@ + + + + + Utilice la opción de pago bancario para pagar al instante desde cualquier cuenta bancaria. + Al conectar su cuenta bancaria, autoriza los cargos en su cuenta de cualquier importe que deba pagar por el uso de nuestros servicios o la compra de nuestros productos hasta que se revoque esta autorización. + Continúe para pagar a través del banco + + más + diff --git a/paybybank-us/src/main/res/values-et-rEE/strings.xml b/paybybank-us/src/main/res/values-et-rEE/strings.xml new file mode 100644 index 0000000000..1d94c1d136 --- /dev/null +++ b/paybybank-us/src/main/res/values-et-rEE/strings.xml @@ -0,0 +1,15 @@ + + + + + Kasutage pangamakset, et maksta koheselt mis tahes pangakontoga. + Pangakonto sidumisega annate loa debiteerida oma kontolt meie teenuste kasutamise ja/või meie toodete ostmise eest mis tahes võlgnetavad summad kuni selle loa tühistamiseni. + Jätkake pangaga maksmist + + veel + diff --git a/paybybank-us/src/main/res/values-fi-rFI/strings.xml b/paybybank-us/src/main/res/values-fi-rFI/strings.xml new file mode 100644 index 0000000000..11c10f1c11 --- /dev/null +++ b/paybybank-us/src/main/res/values-fi-rFI/strings.xml @@ -0,0 +1,15 @@ + + + + + Pankkimaksutoiminnolla voit maksaa heti miltä tahansa pankkitililtä. + Kun yhdistät pankkitilisi, annat luvan veloittaa tililtäsi kaikki palveluidemme käytöstä ja/tai tuotteidemme ostamisesta aiheutuvat kulut. Tämä valtuutus on voimassa siihen saakka, kunnes peruutat sen. + Jatka pankkimaksuun + + lisää + diff --git a/paybybank-us/src/main/res/values-fr-rFR/strings.xml b/paybybank-us/src/main/res/values-fr-rFR/strings.xml new file mode 100644 index 0000000000..9cb1f080e6 --- /dev/null +++ b/paybybank-us/src/main/res/values-fr-rFR/strings.xml @@ -0,0 +1,15 @@ + + + + + Utilisez Pay by Bank pour payer instantanément depuis n\'importe quel compte bancaire. + En connectant votre compte bancaire, vous autorisez le débit de tous les montants dus pour l\'utilisation de nos services et l\'achat de nos produits, jusqu\'à révocation de votre autorisation. + Continuer vers Pay by Bank + + de détails + diff --git a/paybybank-us/src/main/res/values-hr-rHR/strings.xml b/paybybank-us/src/main/res/values-hr-rHR/strings.xml new file mode 100644 index 0000000000..af29fcce99 --- /dev/null +++ b/paybybank-us/src/main/res/values-hr-rHR/strings.xml @@ -0,0 +1,15 @@ + + + + + Koristite Pay by Bank za trenutačno plaćanje s bilo kojeg bankovnog računa. + Povezivanjem svog bankovnog računa autorizirate zaduženja na svoj račun za bilo koji iznos koji se duguje za upotrebu naših usluga i/ili kupnju naših proizvoda, sve dok se autorizacija ne opozove. + Nastavite s plaćanjem putem banke + + više + diff --git a/paybybank-us/src/main/res/values-hu-rHU/strings.xml b/paybybank-us/src/main/res/values-hu-rHU/strings.xml new file mode 100644 index 0000000000..c0649d520f --- /dev/null +++ b/paybybank-us/src/main/res/values-hu-rHU/strings.xml @@ -0,0 +1,15 @@ + + + + + Ha bankszámláról szeretne azonnal fizetni, használja a Fizetés bankkal lehetőséget. + Bankszámlája csatlakoztatásával engedélyezi, hogy a szolgáltatásaink használatáért és/vagy termékeink megvásárlásáért levonandó összeget a számlájára terheljük egészen addig, amíg ezt az engedélyt vissza nem vonja. + Tovább a Fizetés bankkal lehetőségre + + továbbiak + diff --git a/paybybank-us/src/main/res/values-is-rIS/strings.xml b/paybybank-us/src/main/res/values-is-rIS/strings.xml new file mode 100644 index 0000000000..82b4d8786d --- /dev/null +++ b/paybybank-us/src/main/res/values-is-rIS/strings.xml @@ -0,0 +1,15 @@ + + + + + Notaðu Pay by Bank til að greiða strax af hvaða bankareikningi sem er. + Með því að tengja bankareikninginn þinn heimilar þú skuldfærslu af reikningnum þínum fyrir hvaða upphæð sem þú skuldar vegna notkunar á þjónustu okkar og/eða kaupum á vörum okkar, þar til þessi heimild er afturkölluð. + Fara í Pay by Bank + + meira + diff --git a/paybybank-us/src/main/res/values-it-rIT/strings.xml b/paybybank-us/src/main/res/values-it-rIT/strings.xml new file mode 100644 index 0000000000..c1577da253 --- /dev/null +++ b/paybybank-us/src/main/res/values-it-rIT/strings.xml @@ -0,0 +1,15 @@ + + + + + Utilizza Pay by Bank per pagare istantaneamente da qualsiasi conto bancario. + Collegando il tuo conto bancario, autorizzi l\'addebito su di esso di qualsiasi importo dovuto per l\'utilizzo dei nostri servizi e/o l\'acquisto dei nostri prodotti, fino alla revoca di tale autorizzazione. + Continua su Pay by Bank + + altro + diff --git a/paybybank-us/src/main/res/values-ja-rJP/strings.xml b/paybybank-us/src/main/res/values-ja-rJP/strings.xml new file mode 100644 index 0000000000..7e44d16d54 --- /dev/null +++ b/paybybank-us/src/main/res/values-ja-rJP/strings.xml @@ -0,0 +1,15 @@ + + + + + Pay by Bankを使用すると、どの銀行口座からでも即座に支払いができます。 + 銀行口座を接続することで、お客様は、この承認が取り消されるまで、当社のサービスの利用および/または当社製品の購入のために支払うべき金額をお客様の口座から引き落とすことを承認したことになります。 + Pay by Bankに進む + + 詳細を確認 + diff --git a/paybybank-us/src/main/res/values-ko-rKR/strings.xml b/paybybank-us/src/main/res/values-ko-rKR/strings.xml new file mode 100644 index 0000000000..05875300ae --- /dev/null +++ b/paybybank-us/src/main/res/values-ko-rKR/strings.xml @@ -0,0 +1,15 @@ + + + + + Pay by Bank를 사용하면 어떤 은행 계좌에서든 즉시 결제할 수 있습니다. + 은행 계좌를 연결함으로써, 이 승인이 취소될 때까지 당사의 서비스 이용 및/또는 제품 구매에 대해 지불해야 할 모든 금액이 귀하의 계좌에서 인출되는 것을 승인하게 됩니다. + Pay by Bank로 계속 진행 + + 더 보기 + diff --git a/paybybank-us/src/main/res/values-lt-rLT/strings.xml b/paybybank-us/src/main/res/values-lt-rLT/strings.xml new file mode 100644 index 0000000000..d44a95f9d5 --- /dev/null +++ b/paybybank-us/src/main/res/values-lt-rLT/strings.xml @@ -0,0 +1,15 @@ + + + + + Naudokitės „Pay by Bank“ ir akimirksniu atsiskaitykite iš bet kurios banko sąskaitos. + Prijungdami savo banko sąskaitą sutinkate, kad iš jos būtų nurašomos visos mokėtinos sumos už naudojimąsi mūsų paslaugomis ir (arba) už mūsų produktų pirkimą, kol šis leidimas bus atšauktas. + Toliau eiti į „Pay by Bank“ + + daugiau + diff --git a/paybybank-us/src/main/res/values-lv-rLV/strings.xml b/paybybank-us/src/main/res/values-lv-rLV/strings.xml new file mode 100644 index 0000000000..6faa2fe7a9 --- /dev/null +++ b/paybybank-us/src/main/res/values-lv-rLV/strings.xml @@ -0,0 +1,15 @@ + + + + + Izmantojiet Pay by Bank pakalpojumu, lai nekavējoties norēķinātos no jebkura bankas konta. + Pievienojot bankas kontu, jūs atļaujat debetēt no sava konta jebkuru summu, kas maksājama par mūsu pakalpojumu izmantošanu un/vai mūsu produktu iegādi, līdz brīdim, kad šī atļauja tiek atsaukta. + Turpināt maksāt ar bankas starpniecību + + vairāk + diff --git a/paybybank-us/src/main/res/values-nb-rNO/strings.xml b/paybybank-us/src/main/res/values-nb-rNO/strings.xml new file mode 100644 index 0000000000..32991c89cc --- /dev/null +++ b/paybybank-us/src/main/res/values-nb-rNO/strings.xml @@ -0,0 +1,15 @@ + + + + + Bruk Pay by Bank for å betale umiddelbart fra en hvilken som helst bankkonto. + Ved å koble til bankkontoen din autoriserer du debiteringer av kontoen for ethvert beløp du skylder for din bruk av våre tjenester og/eller kjøp av våre produkter, inntil denne autorisasjonen blir trukket tilbake. + Fortsett for å bruke Pay by Bank + + mer + diff --git a/paybybank-us/src/main/res/values-nl-rNL/strings.xml b/paybybank-us/src/main/res/values-nl-rNL/strings.xml new file mode 100644 index 0000000000..59e280657e --- /dev/null +++ b/paybybank-us/src/main/res/values-nl-rNL/strings.xml @@ -0,0 +1,15 @@ + + + + + Gebruik Pay by Bank om direct vanaf elke bankrekening te betalen. + Door uw bankrekening te koppelen, machtigt u afschrijvingen van uw rekening voor elk bedrag dat u verschuldigd bent voor het gebruik van onze diensten en/of de aankoop van onze producten, totdat deze machtiging wordt ingetrokken. + Doorgaan met betalen via de bank + + meer + diff --git a/paybybank-us/src/main/res/values-pl-rPL/strings.xml b/paybybank-us/src/main/res/values-pl-rPL/strings.xml new file mode 100644 index 0000000000..18d130599d --- /dev/null +++ b/paybybank-us/src/main/res/values-pl-rPL/strings.xml @@ -0,0 +1,15 @@ + + + + + Użyj Pay by Bank, aby zapłacić natychmiast z dowolnego konta bankowego. + Podłączając swoje konto bankowe, zezwalasz na obciążanie swojego konta wszelkimi kwotami należnymi za korzystanie z naszych usług i/lub zakup naszych produktów, do czasu odwołania tego upoważnienia. + Kontynuuj płatność przez bank + + więcej + diff --git a/paybybank-us/src/main/res/values-pt-rBR/strings.xml b/paybybank-us/src/main/res/values-pt-rBR/strings.xml new file mode 100644 index 0000000000..6f43ca47a3 --- /dev/null +++ b/paybybank-us/src/main/res/values-pt-rBR/strings.xml @@ -0,0 +1,15 @@ + + + + + Use o Pay by Bank para pagar instantaneamente de qualquer conta bancária. + Ao conectar sua conta bancária, você autoriza débitos dessa conta de qualquer valor devido pelo uso de nossos serviços e/ou compra de nossos produtos até que esta autorização seja revogada. + Continuar para o Pay by Bank + + mais + diff --git a/paybybank-us/src/main/res/values-pt-rPT/strings.xml b/paybybank-us/src/main/res/values-pt-rPT/strings.xml new file mode 100644 index 0000000000..1922fb23c6 --- /dev/null +++ b/paybybank-us/src/main/res/values-pt-rPT/strings.xml @@ -0,0 +1,15 @@ + + + + + Utilize Pagamento por banco para pagar instantaneamente com qualquer conta bancária. + Ao conectar a sua conta bancária, você autoriza débitos na sua conta de qualquer valor devido pela utilização dos nossos serviços e/ou compra dos nossos produtos, até que esta autorização seja revogada. + Continuar para pagamento por banco + + mais + diff --git a/paybybank-us/src/main/res/values-ro-rRO/strings.xml b/paybybank-us/src/main/res/values-ro-rRO/strings.xml new file mode 100644 index 0000000000..1b961ab863 --- /dev/null +++ b/paybybank-us/src/main/res/values-ro-rRO/strings.xml @@ -0,0 +1,15 @@ + + + + + Utilizați Plată prin bancă pentru a plăti instantaneu din orice cont bancar. + Prin conectarea contului dvs. bancar, autorizați debitarea din contul dvs. a oricărei sume datorate cu privire la utilizarea serviciilor noastre și/sau achiziționarea produselor noastre, până la revocarea acestei autorizații. + Continuați către plata prin bancă + + mai multe + diff --git a/paybybank-us/src/main/res/values-ru-rRU/strings.xml b/paybybank-us/src/main/res/values-ru-rRU/strings.xml new file mode 100644 index 0000000000..14a4645260 --- /dev/null +++ b/paybybank-us/src/main/res/values-ru-rRU/strings.xml @@ -0,0 +1,15 @@ + + + + + Для моментальной оплаты с любого банковского счета воспользуйтесь приложением Pay by Bank. + Привязывая банковский счет, вы тем самым даете разрешение на списание с него средств за пользование нашими услугами и/или покупку нашей продукции. Данное разрешение продействует до тех пор, пока оно не будет отозвано. + Продолжить оплату через банк + + иное + diff --git a/paybybank-us/src/main/res/values-sk-rSK/strings.xml b/paybybank-us/src/main/res/values-sk-rSK/strings.xml new file mode 100644 index 0000000000..43c2c01d9c --- /dev/null +++ b/paybybank-us/src/main/res/values-sk-rSK/strings.xml @@ -0,0 +1,15 @@ + + + + + Používajte Pay by Bank na okamžitú platbu z akéhokoľvek bankového účtu. + Pripojením svojho bankového účtu dávate súhlas na odpísanie akejkoľvek dlžnej sumy z vášho účtu za používanie našich služieb a/alebo nákup našich produktov, a to až do odvolania tohto súhlasu. + Pokračovať v platbe bankou + + ďalšie + diff --git a/paybybank-us/src/main/res/values-sl-rSI/strings.xml b/paybybank-us/src/main/res/values-sl-rSI/strings.xml new file mode 100644 index 0000000000..55d025202e --- /dev/null +++ b/paybybank-us/src/main/res/values-sl-rSI/strings.xml @@ -0,0 +1,15 @@ + + + + + Uporabite Pay by Bank za takojšnje plačilo s katerega koli bančnega računa. + S povezavo svojega bančnega računa dovoljujete bremenitev računa za vse zneske, ki jih dolgujete za uporabo naših storitev in/ali nakup naših izdelkov, dokler tega dovoljenja ne prekličete. + Nadaljuj na storitev Pay by Bank + + več + diff --git a/paybybank-us/src/main/res/values-sv-rSE/strings.xml b/paybybank-us/src/main/res/values-sv-rSE/strings.xml new file mode 100644 index 0000000000..4ddc034f87 --- /dev/null +++ b/paybybank-us/src/main/res/values-sv-rSE/strings.xml @@ -0,0 +1,15 @@ + + + + + Använd Pay by Bank och betala direkt från vilket bankkonto som helst. + Genom att ansluta ditt bankkonto godkänner du att ditt konto debiteras eventuella belopp som du är skyldig för användning av våra tjänster och/eller köp av våra produkter, tills detta godkännande återkallas. + Fortsätt att betala via bank + + mer + diff --git a/paybybank-us/src/main/res/values-zh-rCN/strings.xml b/paybybank-us/src/main/res/values-zh-rCN/strings.xml new file mode 100644 index 0000000000..785ec04c8b --- /dev/null +++ b/paybybank-us/src/main/res/values-zh-rCN/strings.xml @@ -0,0 +1,15 @@ + + + + + 使用 Pay by Bank 从任何银行账户即时付款。 + 关联您的银行账户,即表示您授权从您的账户中扣除因使用我们的服务和/或购买我们的产品而需支付的任何金额,直至该授权被撤销。 + 继续使用 Pay by Bank + + 更多 + diff --git a/paybybank-us/src/main/res/values-zh-rTW/strings.xml b/paybybank-us/src/main/res/values-zh-rTW/strings.xml new file mode 100644 index 0000000000..b18ef9ebee --- /dev/null +++ b/paybybank-us/src/main/res/values-zh-rTW/strings.xml @@ -0,0 +1,15 @@ + + + + + 運用銀行支付方式透過任何銀行帳戶立即付款。 + 連結您的銀行帳戶即表示您授權我們可以在您享有我們的服務和/或購買我們的產品時,向您的帳戶扣款對應的費用,直到授權被撤銷為止。 + 繼續透過銀行付款 + + 更多 + diff --git a/paybybank-us/src/main/res/values/strings.xml b/paybybank-us/src/main/res/values/strings.xml new file mode 100644 index 0000000000..0c9b005318 --- /dev/null +++ b/paybybank-us/src/main/res/values/strings.xml @@ -0,0 +1,17 @@ + + + + + Use Pay by Bank to pay instantly from any bank account. + By connecting your bank account you are authorizing debits to your account for any amount owed for use of our services and/or purchase of our products, until this authorization is revoked. + Continue to Pay by Bank + + more + + Pay by Bank + diff --git a/paybybank-us/src/main/res/values/styles.xml b/paybybank-us/src/main/res/values/styles.xml new file mode 100644 index 0000000000..d246193776 --- /dev/null +++ b/paybybank-us/src/main/res/values/styles.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + diff --git a/ui-core/src/main/java/com/adyen/checkout/ui/core/internal/ui/model/LogoTextItem.kt b/ui-core/src/main/java/com/adyen/checkout/ui/core/internal/ui/model/LogoTextItem.kt new file mode 100644 index 0000000000..9e23eb69b3 --- /dev/null +++ b/ui-core/src/main/java/com/adyen/checkout/ui/core/internal/ui/model/LogoTextItem.kt @@ -0,0 +1,41 @@ +/* + * 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 29/10/2024. + */ + +package com.adyen.checkout.ui.core.internal.ui.model + +import androidx.annotation.RestrictTo +import androidx.annotation.StringRes +import com.adyen.checkout.core.Environment + +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +sealed interface LogoTextItem { + fun getViewType(): LogoTextItemViewType + + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) + data class LogoItem( + val logoPath: String, + // We need the environment to load the logo + val environment: Environment, + ) : LogoTextItem { + override fun getViewType() = LogoTextItemViewType.Logo + } + + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) + data class TextItem( + @StringRes + val textResId: Int, + ) : LogoTextItem { + override fun getViewType() = LogoTextItemViewType.Text + } + + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) + enum class LogoTextItemViewType(val type: Int) { + Logo(0), + Text(1) + } +} diff --git a/ui-core/src/main/java/com/adyen/checkout/ui/core/internal/ui/view/LogoTextAdapter.kt b/ui-core/src/main/java/com/adyen/checkout/ui/core/internal/ui/view/LogoTextAdapter.kt new file mode 100644 index 0000000000..26d6a161b4 --- /dev/null +++ b/ui-core/src/main/java/com/adyen/checkout/ui/core/internal/ui/view/LogoTextAdapter.kt @@ -0,0 +1,100 @@ +/* + * 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 29/10/2024. + */ + +package com.adyen.checkout.ui.core.internal.ui.view + +import android.content.Context +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.annotation.RestrictTo +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView +import com.adyen.checkout.core.exception.CheckoutException +import com.adyen.checkout.ui.core.databinding.LogoViewHolderBinding +import com.adyen.checkout.ui.core.databinding.TextViewHolderBinding +import com.adyen.checkout.ui.core.internal.ui.loadLogo +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 + +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +class LogoTextAdapter(private val localizedContext: Context) : + ListAdapter(LogoTextItemDiffCallback) { + + override fun getItemViewType(position: Int): Int { + return currentList[position].getViewType().type + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { + val inflater = LayoutInflater.from(parent.context) + return when (viewType) { + LogoTextItem.LogoTextItemViewType.Logo.type -> { + LogoViewHolder( + LogoViewHolderBinding.inflate(inflater, parent, false), + ) + } + + LogoTextItem.LogoTextItemViewType.Text.type -> { + TextViewHolder( + TextViewHolderBinding.inflate(inflater, parent, false), + localizedContext, + ) + } + + else -> throw CheckoutException("Unexpected viewType on onCreateViewHolder - $viewType") + } + } + + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { + val item = currentList[position] + when (holder) { + is LogoViewHolder -> holder.bind(item as LogoItem) + is TextViewHolder -> holder.bind(item as TextItem) + } + } + + internal class LogoViewHolder( + private val binding: LogoViewHolderBinding + ) : RecyclerView.ViewHolder(binding.root) { + fun bind(item: LogoItem) { + binding.imageViewBrandLogo.loadLogo( + environment = item.environment, + txVariant = item.logoPath, + ) + } + } + + internal class TextViewHolder( + private val binding: TextViewHolderBinding, + private val localizedContext: Context + ) : RecyclerView.ViewHolder(binding.root) { + fun bind(item: TextItem) { + binding.textView.text = localizedContext.getString(item.textResId) + } + } + + internal object LogoTextItemDiffCallback : DiffUtil.ItemCallback() { + + override fun areItemsTheSame(oldItem: LogoTextItem, newItem: LogoTextItem): Boolean { + return when (oldItem) { + is LogoItem -> { + oldItem.logoPath == (newItem as? LogoItem)?.logoPath + } + + is TextItem -> { + oldItem.textResId == (newItem as? TextItem)?.textResId + } + } + } + + override fun areContentsTheSame(oldItem: LogoTextItem, newItem: LogoTextItem): Boolean { + return oldItem == newItem + } + } +} diff --git a/ui-core/src/main/res/layout/logo_view_holder.xml b/ui-core/src/main/res/layout/logo_view_holder.xml new file mode 100644 index 0000000000..c59a3e6176 --- /dev/null +++ b/ui-core/src/main/res/layout/logo_view_holder.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/ui-core/src/main/res/layout/text_view_holder.xml b/ui-core/src/main/res/layout/text_view_holder.xml new file mode 100644 index 0000000000..7edfe7a7c0 --- /dev/null +++ b/ui-core/src/main/res/layout/text_view_holder.xml @@ -0,0 +1,17 @@ + + + + diff --git a/ui-core/src/main/res/values/dimens.xml b/ui-core/src/main/res/values/dimens.xml index fcfa517936..12445116be 100644 --- a/ui-core/src/main/res/values/dimens.xml +++ b/ui-core/src/main/res/values/dimens.xml @@ -22,6 +22,9 @@ 80dp 52dp + 24dp + 16dp + 82dp 55dp diff --git a/ui-core/src/main/res/values/styles.xml b/ui-core/src/main/res/values/styles.xml index 9596fdc49a..fe3053e36e 100644 --- a/ui-core/src/main/res/values/styles.xml +++ b/ui-core/src/main/res/values/styles.xml @@ -43,6 +43,11 @@ 14sp + + + +