From a73f8c024324b11c0e3a87375eb51a016fa261e8 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 1 Feb 2024 07:47:46 +0000
Subject: [PATCH 001/255] Update hilt_version to v2.50
---
dependencies.gradle | 2 +-
gradle/verification-metadata.xml | 69 ++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/dependencies.gradle b/dependencies.gradle
index 8e986e6324..12ac72ca15 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -23,7 +23,7 @@ ext {
kotlin_version = '1.9.21'
detekt_gradle_plugin_version = "1.23.4"
dokka_version = "1.9.10"
- hilt_version = "2.49"
+ hilt_version = "2.50"
compose_compiler_version = '1.5.7'
// Code quality
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index ad73ab43e2..6beabd7ce6 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -5492,6 +5492,14 @@
+
+
+
+
+
+
+
+
@@ -5532,6 +5540,14 @@
+
+
+
+
+
+
+
+
@@ -5572,6 +5588,14 @@
+
+
+
+
+
+
+
+
@@ -5644,6 +5668,14 @@
+
+
+
+
+
+
+
+
@@ -5684,6 +5716,14 @@
+
+
+
+
+
+
+
+
@@ -5724,6 +5764,14 @@
+
+
+
+
+
+
+
+
@@ -5764,6 +5812,14 @@
+
+
+
+
+
+
+
+
@@ -5804,6 +5860,14 @@
+
+
+
+
+
+
+
+
@@ -5829,6 +5893,11 @@
+
+
+
+
+
From 8f30716fab4f878353c90f9f6f39aba85b7baff3 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 1 Feb 2024 09:37:13 +0000
Subject: [PATCH 002/255] Update actions/setup-java action to v4
---
.github/workflows/assemble.yml | 2 +-
.github/workflows/check_release.yml | 2 +-
.github/workflows/code_analysis.yml | 4 ++--
.github/workflows/publish_docs.yml | 2 +-
.github/workflows/publish_release.yml | 2 +-
.github/workflows/run_tests.yml | 4 ++--
.github/workflows/sonar_cloud.yml | 2 +-
.github/workflows/update_verification_metadata.yml | 2 +-
8 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/.github/workflows/assemble.yml b/.github/workflows/assemble.yml
index ddf64463e6..2795869d2c 100644
--- a/.github/workflows/assemble.yml
+++ b/.github/workflows/assemble.yml
@@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- name: Set up JDK
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
diff --git a/.github/workflows/check_release.yml b/.github/workflows/check_release.yml
index fa4bcfcea2..fedb53cce3 100644
--- a/.github/workflows/check_release.yml
+++ b/.github/workflows/check_release.yml
@@ -20,7 +20,7 @@ jobs:
# Setup Java 17
# https://github.com/marketplace/actions/setup-java-jdk
- name: Set up JDK
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
diff --git a/.github/workflows/code_analysis.yml b/.github/workflows/code_analysis.yml
index a9f947c96f..552daf7cd8 100644
--- a/.github/workflows/code_analysis.yml
+++ b/.github/workflows/code_analysis.yml
@@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- name: Set up JDK
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
@@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v4
- name: Set up JDK
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/publish_docs.yml
index a9785155b0..0aaf928ebf 100644
--- a/.github/workflows/publish_docs.yml
+++ b/.github/workflows/publish_docs.yml
@@ -19,7 +19,7 @@ jobs:
# Setup Java 17
# https://github.com/marketplace/actions/setup-java-jdk
- name: Set up JDK
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml
index 7fe8eaeb22..0ee9a8f674 100644
--- a/.github/workflows/publish_release.yml
+++ b/.github/workflows/publish_release.yml
@@ -17,7 +17,7 @@ jobs:
ref: main
- name: Set up JDK
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml
index 5220997b56..28e21ff83d 100644
--- a/.github/workflows/run_tests.yml
+++ b/.github/workflows/run_tests.yml
@@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- name: Set up JDK
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
@@ -37,7 +37,7 @@ jobs:
- uses: actions/checkout@v4
- name: Set up JDK
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
diff --git a/.github/workflows/sonar_cloud.yml b/.github/workflows/sonar_cloud.yml
index e6f9d7acd6..4a4bf2d4ec 100644
--- a/.github/workflows/sonar_cloud.yml
+++ b/.github/workflows/sonar_cloud.yml
@@ -14,7 +14,7 @@ jobs:
fetch-depth: '0'
- name: Set up JDK
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
diff --git a/.github/workflows/update_verification_metadata.yml b/.github/workflows/update_verification_metadata.yml
index ece0fc2ff0..a14782b84d 100644
--- a/.github/workflows/update_verification_metadata.yml
+++ b/.github/workflows/update_verification_metadata.yml
@@ -14,7 +14,7 @@ jobs:
ref: ${{ github.head_ref }}
- name: Set up JDK
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
From e96b1dfca552e1b4b5efe7e8fdd4368fd46e7c81 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 1 Feb 2024 10:45:52 +0000
Subject: [PATCH 003/255] Update dependency
com.google.android.material:material to v1.11.0
---
dependencies.gradle | 2 +-
gradle/verification-metadata.xml | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/dependencies.gradle b/dependencies.gradle
index 12ac72ca15..4c3a465d85 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -39,7 +39,7 @@ ext {
coroutines_version = "1.6.4"
fragment_version = "1.6.2"
lifecycle_version = "2.5.1"
- material_version = "1.10.0"
+ material_version = "1.11.0"
recyclerview_version = "1.3.2"
constraintlayout_version = '2.1.4'
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index 6beabd7ce6..5d043871bf 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -5303,6 +5303,14 @@
+
+
+
+
+
+
+
+
From 4a146154c3f41e7d25a626d9b77cddef4b601d39 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 1 Feb 2024 11:24:54 +0000
Subject: [PATCH 004/255] Update dependency androidx.activity:activity-compose
to v1.8.2
---
dependencies.gradle | 2 +-
gradle/verification-metadata.xml | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/dependencies.gradle b/dependencies.gradle
index 4c3a465d85..a60df1546c 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -44,7 +44,7 @@ ext {
constraintlayout_version = '2.1.4'
// Compose Dependencies
- compose_activity_version = '1.8.1'
+ compose_activity_version = '1.8.2'
compose_bom_version = '2023.10.01'
compose_hilt_version = '1.1.0'
compose_viewmodel_version = '2.6.2'
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index 5d043871bf..63e35b3fca 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -89,6 +89,14 @@
+
+
+
+
+
+
+
+
@@ -121,6 +129,14 @@
+
+
+
+
+
+
+
+
@@ -187,6 +203,14 @@
+
+
+
+
+
+
+
+
From 6e4cf96f66f5e4c2ae53fcd0fc97ece778e02951 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 1 Feb 2024 12:07:42 +0000
Subject: [PATCH 005/255] Update dependency androidx.annotation:annotation to
v1.7.1
---
dependencies.gradle | 2 +-
gradle/verification-metadata.xml | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/dependencies.gradle b/dependencies.gradle
index a60df1546c..7ee39aafcc 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -33,7 +33,7 @@ ext {
sonarqube_version = '4.4.1.3373'
// Android Dependencies
- annotation_version = "1.7.0"
+ annotation_version = "1.7.1"
appcompat_version = "1.6.1"
browser_version = "1.7.0"
coroutines_version = "1.6.4"
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index 63e35b3fca..ad346bc074 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -267,6 +267,14 @@
+
+
+
+
+
+
+
+
@@ -312,6 +320,14 @@
+
+
+
+
+
+
+
+
From 7bfd121cc5b3f72e4d54e517f71af47e26a5a5f7 Mon Sep 17 00:00:00 2001
From: Ararat Mnatsakanyan
Date: Thu, 21 Dec 2023 10:19:45 +0100
Subject: [PATCH 006/255] Add Multibanco as a supported voucher payment method
COAND-372
---
.../adyen/checkout/components/core/PaymentMethodTypes.kt | 4 ++--
.../qrcode/internal/ui/model/QRCodePaymentMethodConfig.kt | 2 +-
.../voucher/internal/provider/VoucherComponentProvider.kt | 3 ++-
.../checkout/voucher/internal/ui/VoucherViewProvider.kt | 6 ++++--
.../voucher/internal/ui/model/VoucherPaymentMethodConfig.kt | 5 +++++
5 files changed, 14 insertions(+), 6 deletions(-)
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 db25896506..ed9101b9b7 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
@@ -56,6 +56,7 @@ object PaymentMethodTypes {
const val PIX = "pix"
const val PROMPT_PAY = "promptpay"
const val WECHAT_PAY_SDK = "wechatpaySDK"
+ const val MULTIBANCO = "multibanco"
// Voucher payment methods that are not yet supported
const val DOKU = "doku"
@@ -79,7 +80,6 @@ object PaymentMethodTypes {
const val ECONTEXT_ONLINE = "econtext_online"
const val ECONTEXT_SEVEN_ELEVEN = "econtext_seven_eleven"
const val ECONTEXT_STORES = "econtext_stores"
- const val MULTIBANCO = "multibanco"
const val OXXO = "oxxo"
// Payment methods that might be interpreted as redirect, but are actually not supported
@@ -137,6 +137,7 @@ object PaymentMethodTypes {
PIX,
PROMPT_PAY,
WECHAT_PAY_SDK,
+ MULTIBANCO,
)
// Payment methods that are explicitly unsupported
@@ -164,7 +165,6 @@ object PaymentMethodTypes {
ECONTEXT_ONLINE,
ECONTEXT_SEVEN_ELEVEN,
ECONTEXT_STORES,
- MULTIBANCO,
OXXO,
WECHAT_PAY_MINI_PROGRAM,
WECHAT_PAY_QR,
diff --git a/qr-code/src/main/java/com/adyen/checkout/qrcode/internal/ui/model/QRCodePaymentMethodConfig.kt b/qr-code/src/main/java/com/adyen/checkout/qrcode/internal/ui/model/QRCodePaymentMethodConfig.kt
index cff159f0b7..822dd544dd 100644
--- a/qr-code/src/main/java/com/adyen/checkout/qrcode/internal/ui/model/QRCodePaymentMethodConfig.kt
+++ b/qr-code/src/main/java/com/adyen/checkout/qrcode/internal/ui/model/QRCodePaymentMethodConfig.kt
@@ -54,7 +54,7 @@ internal enum class QRCodePaymentMethodConfig(
companion object {
fun getByPaymentMethodType(paymentMethodType: String): QRCodePaymentMethodConfig {
- return values().firstOrNull { it.paymentMethodType == paymentMethodType } ?: DEFAULT
+ return entries.firstOrNull { it.paymentMethodType == paymentMethodType } ?: DEFAULT
}
}
}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/provider/VoucherComponentProvider.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/provider/VoucherComponentProvider.kt
index 13f3dc0e02..04a03240bc 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/provider/VoucherComponentProvider.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/provider/VoucherComponentProvider.kt
@@ -97,7 +97,8 @@ constructor(
PaymentMethodTypes.BOLETOBANCARIO_HSBC,
PaymentMethodTypes.BOLETOBANCARIO_ITAU,
PaymentMethodTypes.BOLETOBANCARIO_SANTANDER,
- PaymentMethodTypes.BOLETO_PRIMEIRO_PAY
+ PaymentMethodTypes.BOLETO_PRIMEIRO_PAY,
+ PaymentMethodTypes.MULTIBANCO
)
}
}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
index 116009c189..d4f16c32a1 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
@@ -12,6 +12,8 @@ import android.content.Context
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
+import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.FULL_VOUCHER
+import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.SIMPLE_VOUCHER
import com.adyen.checkout.voucher.internal.ui.view.FullVoucherView
import com.adyen.checkout.voucher.internal.ui.view.VoucherView
@@ -22,8 +24,8 @@ internal object VoucherViewProvider : ViewProvider {
context: Context,
): ComponentView {
return when (viewType) {
- VoucherComponentViewType.SIMPLE_VOUCHER -> VoucherView(context)
- VoucherComponentViewType.FULL_VOUCHER -> FullVoucherView(context)
+ SIMPLE_VOUCHER -> VoucherView(context)
+ FULL_VOUCHER -> FullVoucherView(context)
else -> throw IllegalArgumentException("Unsupported view type")
}
}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
index 4cce19ad75..819a6ad990 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
@@ -20,6 +20,9 @@ internal enum class VoucherPaymentMethodConfig(
),
BOLETO(
viewType = VoucherComponentViewType.FULL_VOUCHER,
+ ),
+ MULTIBANCO(
+ viewType = VoucherComponentViewType.FULL_VOUCHER,
);
companion object {
@@ -36,6 +39,8 @@ internal enum class VoucherPaymentMethodConfig(
PaymentMethodTypes.BOLETOBANCARIO_SANTANDER,
PaymentMethodTypes.BOLETO_PRIMEIRO_PAY -> BOLETO
+ PaymentMethodTypes.MULTIBANCO -> MULTIBANCO
+
else -> null
}
}
From b6eed65a4d204d80f15a16d7f2cffa4cbdde403c Mon Sep 17 00:00:00 2001
From: Ararat Mnatsakanyan
Date: Thu, 21 Dec 2023 15:27:39 +0100
Subject: [PATCH 007/255] Separate Boleto voucher from full screen voucher to
keep the implementation backward compatible. Add a comment that the Boleto
style is deprecated.
COAND-372
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt
index e6dcf605e..98ef5ffb0 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt
@@ -74,21 +74,23 @@ internal class DefaultVoucherDelegate(
return
}
- val viewType = VoucherPaymentMethodConfig.getByPaymentMethodType(action.paymentMethodType)?.viewType
-
- if (viewType == null) {
+ val config = VoucherPaymentMethodConfig.getByPaymentMethodType(action.paymentMethodType)
+ if (config == null) {
exceptionChannel.trySend(
ComponentException("Payment method ${action.paymentMethodType} not supported for this action")
)
return
}
- _viewFlow.tryEmit(viewType)
+ _viewFlow.tryEmit(config.viewType)
- createOutputData(action)
+ createOutputData(action, config)
}
- private fun createOutputData(action: VoucherAction) {
+ private fun createOutputData(
+ action: VoucherAction,
+ config: VoucherPaymentMethodConfig
+ ) {
val outputData = VoucherOutputData(
isValid = true,
paymentMethodType = action.paymentMethodType,
@@ -97,6 +99,7 @@ internal class DefaultVoucherDelegate(
expiresAt = action.expiresAt,
reference = action.reference,
totalAmount = action.totalAmount,
+ introductionTextResource = config.introductionTextResource
)
_outputDataFlow.tryEmit(outputData)
}
@@ -107,7 +110,8 @@ internal class DefaultVoucherDelegate(
downloadUrl = null,
expiresAt = null,
reference = null,
- totalAmount = null
+ totalAmount = null,
+ introductionTextResource = null,
)
override fun downloadVoucher(context: Context) {
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
index d4f16c32a..c81aa4c3a 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
@@ -12,8 +12,10 @@ import android.content.Context
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
+import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.BOLETO_VOUCHER
import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.FULL_VOUCHER
import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.SIMPLE_VOUCHER
+import com.adyen.checkout.voucher.internal.ui.view.BoletoVoucherView
import com.adyen.checkout.voucher.internal.ui.view.FullVoucherView
import com.adyen.checkout.voucher.internal.ui.view.VoucherView
@@ -25,6 +27,7 @@ internal object VoucherViewProvider : ViewProvider {
): ComponentView {
return when (viewType) {
SIMPLE_VOUCHER -> VoucherView(context)
+ BOLETO_VOUCHER -> BoletoVoucherView(context)
FULL_VOUCHER -> FullVoucherView(context)
else -> throw IllegalArgumentException("Unsupported view type")
}
@@ -32,8 +35,7 @@ internal object VoucherViewProvider : ViewProvider {
}
internal enum class VoucherComponentViewType : ComponentViewType {
- SIMPLE_VOUCHER,
- FULL_VOUCHER;
+ SIMPLE_VOUCHER, BOLETO_VOUCHER, FULL_VOUCHER;
override val viewProvider: ViewProvider = VoucherViewProvider
}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt
index d69877680..9d0c5be6d 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt
@@ -20,4 +20,5 @@ data class VoucherOutputData(
val expiresAt: String?,
val reference: String?,
val totalAmount: Amount?,
+ val introductionTextResource: Int?,
) : OutputData
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
index 819a6ad99..e367b9f3f 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
@@ -8,21 +8,29 @@
package com.adyen.checkout.voucher.internal.ui.model
+import androidx.annotation.StringRes
import com.adyen.checkout.components.core.PaymentMethodTypes
+import com.adyen.checkout.voucher.R
import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType
internal enum class VoucherPaymentMethodConfig(
val viewType: VoucherComponentViewType,
+ // TODO: If we do not want to introduce braking changes, then this should become style, instead of text resource. Which I do not like.
+ @StringRes val introductionTextResource: Int?,
) {
BACS(
viewType = VoucherComponentViewType.SIMPLE_VOUCHER,
+ introductionTextResource = R.string.checkout_voucher_introduction_bacs,
),
BOLETO(
- viewType = VoucherComponentViewType.FULL_VOUCHER,
+ viewType = VoucherComponentViewType.BOLETO_VOUCHER,
+ introductionTextResource = null,
),
MULTIBANCO(
viewType = VoucherComponentViewType.FULL_VOUCHER,
+ // TODO: To be changed to checkout_voucher_introduction
+ introductionTextResource = R.string.checkout_voucher_introduction_boleto,
);
companion object {
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt
new file mode 100644
index 000000000..ccfeae266
--- /dev/null
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2023 Adyen N.V.
+ *
+ * This file is open source and available under the MIT license. See the LICENSE file for more info.
+ *
+ * Created by ararat on 21/12/2023.
+ */
+
+package com.adyen.checkout.voucher.internal.ui.view
+
+import android.content.Context
+import android.util.AttributeSet
+import com.adyen.checkout.components.core.internal.ui.ComponentDelegate
+import com.adyen.checkout.ui.core.internal.util.setLocalizedTextFromStyle
+import com.adyen.checkout.voucher.R
+import kotlinx.coroutines.CoroutineScope
+
+// TODO: After removing BoletoVoucherView, make sure to make FullVoucherView non open, binding to private and remove Bolet styles.
+class BoletoVoucherView @JvmOverloads constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0
+) : FullVoucherView(context, attrs, defStyleAttr) {
+ override fun initView(delegate: ComponentDelegate, coroutineScope: CoroutineScope, localizedContext: Context) {
+ super.initView(delegate, coroutineScope, localizedContext)
+
+ binding.textViewIntroduction.setLocalizedTextFromStyle(
+ R.style.AdyenCheckout_Voucher_Description_Boleto,
+ localizedContext
+ )
+ }
+}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
index b31152c87..d4d7da176 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
@@ -12,6 +12,7 @@ import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
+import androidx.annotation.StringRes
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import com.adyen.checkout.components.core.Amount
@@ -35,7 +36,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@Suppress("TooManyFunctions")
-class FullVoucherView @JvmOverloads constructor(
+open class FullVoucherView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
@@ -47,7 +48,7 @@ class FullVoucherView @JvmOverloads constructor(
),
ComponentView {
- private val binding: FullVoucherViewBinding = FullVoucherViewBinding.inflate(LayoutInflater.from(context), this)
+ protected val binding: FullVoucherViewBinding = FullVoucherViewBinding.inflate(LayoutInflater.from(context), this)
private lateinit var localizedContext: Context
@@ -55,7 +56,7 @@ class FullVoucherView @JvmOverloads constructor(
init {
val padding = resources.getDimension(R.dimen.standard_margin).toInt()
- setPadding(padding, padding, padding, padding)
+ this.setPadding(padding, padding, padding, padding)
}
override fun initView(delegate: ComponentDelegate, coroutineScope: CoroutineScope, localizedContext: Context) {
@@ -73,10 +74,6 @@ class FullVoucherView @JvmOverloads constructor(
}
private fun initLocalizedStrings(localizedContext: Context) {
- binding.textViewIntroduction.setLocalizedTextFromStyle(
- R.style.AdyenCheckout_Voucher_Description_Boleto,
- localizedContext
- )
binding.textViewPaymentReference.setLocalizedTextFromStyle(
R.style.AdyenCheckout_Voucher_PaymentReference,
localizedContext
@@ -105,6 +102,7 @@ class FullVoucherView @JvmOverloads constructor(
Logger.d(TAG, "outputDataChanged")
loadLogo(outputData.paymentMethodType)
+ updateIntroductionText(outputData.introductionTextResource)
updateAmount(outputData.totalAmount)
updateCodeReference(outputData.reference)
updateExpirationDate(outputData.expiresAt)
@@ -120,6 +118,11 @@ class FullVoucherView @JvmOverloads constructor(
}
}
+ private fun updateIntroductionText(@StringRes introductionTextResource: Int?) {
+ if (introductionTextResource == null) return
+ binding.textViewIntroduction.text = localizedContext.getString(introductionTextResource)
+ }
+
private fun updateAmount(amount: Amount?) {
if (amount != null && !amount.isEmpty) {
val formattedAmount = CurrencyUtils.formatAmount(
diff --git a/voucher/src/main/res/layout/full_voucher_view.xml b/voucher/src/main/res/layout/full_voucher_view.xml
index b5bc08f05..186c74f6b 100644
--- a/voucher/src/main/res/layout/full_voucher_view.xml
+++ b/voucher/src/main/res/layout/full_voucher_view.xml
@@ -35,7 +35,7 @@
center_horizontal
+
+
+
---
.../internal/ui/DefaultVoucherDelegate.kt | 18 +++++++----
.../internal/ui/VoucherViewProvider.kt | 6 ++--
.../internal/ui/model/VoucherOutputData.kt | 1 +
.../ui/model/VoucherPaymentMethodConfig.kt | 10 +++++-
.../internal/ui/view/BoletoVoucherView.kt | 32 +++++++++++++++++++
.../internal/ui/view/FullVoucherView.kt | 17 ++++++----
.../src/main/res/layout/full_voucher_view.xml | 2 +-
voucher/src/main/res/values/styles.xml | 10 ++++++
8 files changed, 78 insertions(+), 18 deletions(-)
create mode 100644 voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt
index e6dcf605ea..98ef5ffb07 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt
@@ -74,21 +74,23 @@ internal class DefaultVoucherDelegate(
return
}
- val viewType = VoucherPaymentMethodConfig.getByPaymentMethodType(action.paymentMethodType)?.viewType
-
- if (viewType == null) {
+ val config = VoucherPaymentMethodConfig.getByPaymentMethodType(action.paymentMethodType)
+ if (config == null) {
exceptionChannel.trySend(
ComponentException("Payment method ${action.paymentMethodType} not supported for this action")
)
return
}
- _viewFlow.tryEmit(viewType)
+ _viewFlow.tryEmit(config.viewType)
- createOutputData(action)
+ createOutputData(action, config)
}
- private fun createOutputData(action: VoucherAction) {
+ private fun createOutputData(
+ action: VoucherAction,
+ config: VoucherPaymentMethodConfig
+ ) {
val outputData = VoucherOutputData(
isValid = true,
paymentMethodType = action.paymentMethodType,
@@ -97,6 +99,7 @@ internal class DefaultVoucherDelegate(
expiresAt = action.expiresAt,
reference = action.reference,
totalAmount = action.totalAmount,
+ introductionTextResource = config.introductionTextResource
)
_outputDataFlow.tryEmit(outputData)
}
@@ -107,7 +110,8 @@ internal class DefaultVoucherDelegate(
downloadUrl = null,
expiresAt = null,
reference = null,
- totalAmount = null
+ totalAmount = null,
+ introductionTextResource = null,
)
override fun downloadVoucher(context: Context) {
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
index d4f16c32a1..c81aa4c3a3 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
@@ -12,8 +12,10 @@ import android.content.Context
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
+import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.BOLETO_VOUCHER
import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.FULL_VOUCHER
import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.SIMPLE_VOUCHER
+import com.adyen.checkout.voucher.internal.ui.view.BoletoVoucherView
import com.adyen.checkout.voucher.internal.ui.view.FullVoucherView
import com.adyen.checkout.voucher.internal.ui.view.VoucherView
@@ -25,6 +27,7 @@ internal object VoucherViewProvider : ViewProvider {
): ComponentView {
return when (viewType) {
SIMPLE_VOUCHER -> VoucherView(context)
+ BOLETO_VOUCHER -> BoletoVoucherView(context)
FULL_VOUCHER -> FullVoucherView(context)
else -> throw IllegalArgumentException("Unsupported view type")
}
@@ -32,8 +35,7 @@ internal object VoucherViewProvider : ViewProvider {
}
internal enum class VoucherComponentViewType : ComponentViewType {
- SIMPLE_VOUCHER,
- FULL_VOUCHER;
+ SIMPLE_VOUCHER, BOLETO_VOUCHER, FULL_VOUCHER;
override val viewProvider: ViewProvider = VoucherViewProvider
}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt
index d69877680f..9d0c5be6de 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt
@@ -20,4 +20,5 @@ data class VoucherOutputData(
val expiresAt: String?,
val reference: String?,
val totalAmount: Amount?,
+ val introductionTextResource: Int?,
) : OutputData
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
index 819a6ad990..e367b9f3fb 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
@@ -8,21 +8,29 @@
package com.adyen.checkout.voucher.internal.ui.model
+import androidx.annotation.StringRes
import com.adyen.checkout.components.core.PaymentMethodTypes
+import com.adyen.checkout.voucher.R
import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType
internal enum class VoucherPaymentMethodConfig(
val viewType: VoucherComponentViewType,
+ // TODO: If we do not want to introduce braking changes, then this should become style, instead of text resource. Which I do not like.
+ @StringRes val introductionTextResource: Int?,
) {
BACS(
viewType = VoucherComponentViewType.SIMPLE_VOUCHER,
+ introductionTextResource = R.string.checkout_voucher_introduction_bacs,
),
BOLETO(
- viewType = VoucherComponentViewType.FULL_VOUCHER,
+ viewType = VoucherComponentViewType.BOLETO_VOUCHER,
+ introductionTextResource = null,
),
MULTIBANCO(
viewType = VoucherComponentViewType.FULL_VOUCHER,
+ // TODO: To be changed to checkout_voucher_introduction
+ introductionTextResource = R.string.checkout_voucher_introduction_boleto,
);
companion object {
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt
new file mode 100644
index 0000000000..ccfeae2668
--- /dev/null
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2023 Adyen N.V.
+ *
+ * This file is open source and available under the MIT license. See the LICENSE file for more info.
+ *
+ * Created by ararat on 21/12/2023.
+ */
+
+package com.adyen.checkout.voucher.internal.ui.view
+
+import android.content.Context
+import android.util.AttributeSet
+import com.adyen.checkout.components.core.internal.ui.ComponentDelegate
+import com.adyen.checkout.ui.core.internal.util.setLocalizedTextFromStyle
+import com.adyen.checkout.voucher.R
+import kotlinx.coroutines.CoroutineScope
+
+// TODO: After removing BoletoVoucherView, make sure to make FullVoucherView non open, binding to private and remove Bolet styles.
+class BoletoVoucherView @JvmOverloads constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0
+) : FullVoucherView(context, attrs, defStyleAttr) {
+ override fun initView(delegate: ComponentDelegate, coroutineScope: CoroutineScope, localizedContext: Context) {
+ super.initView(delegate, coroutineScope, localizedContext)
+
+ binding.textViewIntroduction.setLocalizedTextFromStyle(
+ R.style.AdyenCheckout_Voucher_Description_Boleto,
+ localizedContext
+ )
+ }
+}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
index b31152c874..d4d7da1769 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
@@ -12,6 +12,7 @@ import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
+import androidx.annotation.StringRes
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import com.adyen.checkout.components.core.Amount
@@ -35,7 +36,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@Suppress("TooManyFunctions")
-class FullVoucherView @JvmOverloads constructor(
+open class FullVoucherView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
@@ -47,7 +48,7 @@ class FullVoucherView @JvmOverloads constructor(
),
ComponentView {
- private val binding: FullVoucherViewBinding = FullVoucherViewBinding.inflate(LayoutInflater.from(context), this)
+ protected val binding: FullVoucherViewBinding = FullVoucherViewBinding.inflate(LayoutInflater.from(context), this)
private lateinit var localizedContext: Context
@@ -55,7 +56,7 @@ class FullVoucherView @JvmOverloads constructor(
init {
val padding = resources.getDimension(R.dimen.standard_margin).toInt()
- setPadding(padding, padding, padding, padding)
+ this.setPadding(padding, padding, padding, padding)
}
override fun initView(delegate: ComponentDelegate, coroutineScope: CoroutineScope, localizedContext: Context) {
@@ -73,10 +74,6 @@ class FullVoucherView @JvmOverloads constructor(
}
private fun initLocalizedStrings(localizedContext: Context) {
- binding.textViewIntroduction.setLocalizedTextFromStyle(
- R.style.AdyenCheckout_Voucher_Description_Boleto,
- localizedContext
- )
binding.textViewPaymentReference.setLocalizedTextFromStyle(
R.style.AdyenCheckout_Voucher_PaymentReference,
localizedContext
@@ -105,6 +102,7 @@ class FullVoucherView @JvmOverloads constructor(
Logger.d(TAG, "outputDataChanged")
loadLogo(outputData.paymentMethodType)
+ updateIntroductionText(outputData.introductionTextResource)
updateAmount(outputData.totalAmount)
updateCodeReference(outputData.reference)
updateExpirationDate(outputData.expiresAt)
@@ -120,6 +118,11 @@ class FullVoucherView @JvmOverloads constructor(
}
}
+ private fun updateIntroductionText(@StringRes introductionTextResource: Int?) {
+ if (introductionTextResource == null) return
+ binding.textViewIntroduction.text = localizedContext.getString(introductionTextResource)
+ }
+
private fun updateAmount(amount: Amount?) {
if (amount != null && !amount.isEmpty) {
val formattedAmount = CurrencyUtils.formatAmount(
diff --git a/voucher/src/main/res/layout/full_voucher_view.xml b/voucher/src/main/res/layout/full_voucher_view.xml
index b5bc08f05a..186c74f6b9 100644
--- a/voucher/src/main/res/layout/full_voucher_view.xml
+++ b/voucher/src/main/res/layout/full_voucher_view.xml
@@ -35,7 +35,7 @@
center_horizontal
+
+
+
From d51bf9eb4d572f6c74758f548d3ceac95bb3167e Mon Sep 17 00:00:00 2001
From: Ararat Mnatsakanyan
Date: Thu, 21 Dec 2023 15:56:32 +0100
Subject: [PATCH 008/255] Update voucher introduction string key to make it
more generic
COAND-372
---
.../voucher/internal/ui/model/VoucherPaymentMethodConfig.kt | 2 +-
voucher/src/main/res/template/values/strings.xml.tt | 2 +-
voucher/src/main/res/values-ar/strings.xml | 2 +-
voucher/src/main/res/values-cs-rCZ/strings.xml | 2 +-
voucher/src/main/res/values-da-rDK/strings.xml | 2 +-
voucher/src/main/res/values-de-rDE/strings.xml | 2 +-
voucher/src/main/res/values-el-rGR/strings.xml | 2 +-
voucher/src/main/res/values-es-rES/strings.xml | 2 +-
voucher/src/main/res/values-fi-rFI/strings.xml | 2 +-
voucher/src/main/res/values-fr-rFR/strings.xml | 2 +-
voucher/src/main/res/values-hr-rHR/strings.xml | 2 +-
voucher/src/main/res/values-hu-rHU/strings.xml | 2 +-
voucher/src/main/res/values-it-rIT/strings.xml | 2 +-
voucher/src/main/res/values-ja-rJP/strings.xml | 2 +-
voucher/src/main/res/values-ko-rKR/strings.xml | 2 +-
voucher/src/main/res/values-nb-rNO/strings.xml | 2 +-
voucher/src/main/res/values-nl-rNL/strings.xml | 2 +-
voucher/src/main/res/values-pl-rPL/strings.xml | 2 +-
voucher/src/main/res/values-pt-rBR/strings.xml | 2 +-
voucher/src/main/res/values-pt-rPT/strings.xml | 2 +-
voucher/src/main/res/values-ro-rRO/strings.xml | 2 +-
voucher/src/main/res/values-ru-rRU/strings.xml | 2 +-
voucher/src/main/res/values-sk-rSK/strings.xml | 2 +-
voucher/src/main/res/values-sl-rSI/strings.xml | 2 +-
voucher/src/main/res/values-sv-rSE/strings.xml | 2 +-
voucher/src/main/res/values-zh-rCN/strings.xml | 2 +-
voucher/src/main/res/values-zh-rTW/strings.xml | 2 +-
voucher/src/main/res/values/strings.xml | 2 +-
voucher/src/main/res/values/styles.xml | 2 +-
29 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
index e367b9f3fb..f6060445ce 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
@@ -30,7 +30,7 @@ internal enum class VoucherPaymentMethodConfig(
MULTIBANCO(
viewType = VoucherComponentViewType.FULL_VOUCHER,
// TODO: To be changed to checkout_voucher_introduction
- introductionTextResource = R.string.checkout_voucher_introduction_boleto,
+ introductionTextResource = R.string.checkout_voucher_introduction,
);
companion object {
diff --git a/voucher/src/main/res/template/values/strings.xml.tt b/voucher/src/main/res/template/values/strings.xml.tt
index 7e5bdd9343..66aafba54c 100644
--- a/voucher/src/main/res/template/values/strings.xml.tt
+++ b/voucher/src/main/res/template/values/strings.xml.tt
@@ -9,7 +9,7 @@
%%bacs.result.introduction%%
- %%voucher.introduction%%
+ %%voucher.introduction%%
%%voucher.paymentReferenceLabel%%
%%voucher.expirationDate%%
%%pix.instructions.copyButton%%
diff --git a/voucher/src/main/res/values-ar/strings.xml b/voucher/src/main/res/values-ar/strings.xml
index fd96db990f..1cae394d72 100644
--- a/voucher/src/main/res/values-ar/strings.xml
+++ b/voucher/src/main/res/values-ar/strings.xml
@@ -9,7 +9,7 @@
تنزيل تعليمات الخصم المباشر (تعليمات / تفويض DDI)
- شكرًا لك على شرائك، يرجى استخدام القسيمة التالية لإتمام عملية الدفع.
+ شكرًا لك على شرائك، يرجى استخدام القسيمة التالية لإتمام عملية الدفع.
مرجع الدفع
تاريخ الانتهاء
نسخ الرمز
diff --git a/voucher/src/main/res/values-cs-rCZ/strings.xml b/voucher/src/main/res/values-cs-rCZ/strings.xml
index 2a1683587d..91afcf8f49 100644
--- a/voucher/src/main/res/values-cs-rCZ/strings.xml
+++ b/voucher/src/main/res/values-cs-rCZ/strings.xml
@@ -9,7 +9,7 @@
Stáhněte si pokyny k přímému inkasu (DDI / podpisové právo)
- Děkujeme za nákup. K dokončení platby použijte prosím následující kupón.
+ Děkujeme za nákup. K dokončení platby použijte prosím následující kupón.
Číslo platby
Datum konce platnosti
Kopírovat kód
diff --git a/voucher/src/main/res/values-da-rDK/strings.xml b/voucher/src/main/res/values-da-rDK/strings.xml
index ae5532daef..f3745a6eab 100644
--- a/voucher/src/main/res/values-da-rDK/strings.xml
+++ b/voucher/src/main/res/values-da-rDK/strings.xml
@@ -9,7 +9,7 @@
Download vejledningen til direkte debitering (fuldmagt til direkte debitering)
- Tak for dit køb. Brug følgende kupon til at gennemføre din betaling.
+ Tak for dit køb. Brug følgende kupon til at gennemføre din betaling.
Betalingsreference
Udløbsdato
Kopiér koden
diff --git a/voucher/src/main/res/values-de-rDE/strings.xml b/voucher/src/main/res/values-de-rDE/strings.xml
index b61ae763ff..0fd1beb2c3 100644
--- a/voucher/src/main/res/values-de-rDE/strings.xml
+++ b/voucher/src/main/res/values-de-rDE/strings.xml
@@ -9,7 +9,7 @@
Laden Sie Ihre Lastschriftanweisung (DDI/Einzugsermächtigung) herunter
- Vielen Dank für Ihren Kauf. Bitte schließen Sie Ihre Zahlung unter Verwendung des folgenden Gutscheins ab.
+ Vielen Dank für Ihren Kauf. Bitte schließen Sie Ihre Zahlung unter Verwendung des folgenden Gutscheins ab.
Zahlungsreferenz
Gültig bis
Code kopieren
diff --git a/voucher/src/main/res/values-el-rGR/strings.xml b/voucher/src/main/res/values-el-rGR/strings.xml
index 100c2d154a..0190d3e792 100644
--- a/voucher/src/main/res/values-el-rGR/strings.xml
+++ b/voucher/src/main/res/values-el-rGR/strings.xml
@@ -9,7 +9,7 @@
Κατεβάστε την Εντολή Άμεσης Χρέωσης (DDI/Εντολή)
- Σας ευχαριστούμε για την αγορά. Χρησιμοποιήστε το παρακάτω κουπόνι για να ολοκληρώσετε την πληρωμή.
+ Σας ευχαριστούμε για την αγορά. Χρησιμοποιήστε το παρακάτω κουπόνι για να ολοκληρώσετε την πληρωμή.
Αναφορά πληρωμής
Ημερομηνία λήξης
Αντιγραφή κωδικού
diff --git a/voucher/src/main/res/values-es-rES/strings.xml b/voucher/src/main/res/values-es-rES/strings.xml
index e626a82277..6a0dc74e4a 100644
--- a/voucher/src/main/res/values-es-rES/strings.xml
+++ b/voucher/src/main/res/values-es-rES/strings.xml
@@ -9,7 +9,7 @@
Descargue su instrucción de débito directo (IDD/mandato)
- Gracias por su compra. Use el siguiente cupón para completar su pago.
+ Gracias por su compra. Use el siguiente cupón para completar su pago.
Referencia de pago
Fecha de caducidad
Copiar código
diff --git a/voucher/src/main/res/values-fi-rFI/strings.xml b/voucher/src/main/res/values-fi-rFI/strings.xml
index 2b323b4176..935909f475 100644
--- a/voucher/src/main/res/values-fi-rFI/strings.xml
+++ b/voucher/src/main/res/values-fi-rFI/strings.xml
@@ -9,7 +9,7 @@
Lataa suoraveloitusohjeet (DDI / Mandate)
- Kiitos hankinnastasi, käytä seuraavaa kuponkia viedäksesi maksusi päätökseen.
+ Kiitos hankinnastasi, käytä seuraavaa kuponkia viedäksesi maksusi päätökseen.
Maksun viite
Vanhenemispäivämäärä
Kopioi koodi
diff --git a/voucher/src/main/res/values-fr-rFR/strings.xml b/voucher/src/main/res/values-fr-rFR/strings.xml
index 66f08b0925..6178175d7b 100644
--- a/voucher/src/main/res/values-fr-rFR/strings.xml
+++ b/voucher/src/main/res/values-fr-rFR/strings.xml
@@ -9,7 +9,7 @@
Téléchargez votre mandat de prélèvement (DDI)
- Merci pour votre achat, veuillez utiliser le coupon suivant pour finaliser votre paiement.
+ Merci pour votre achat, veuillez utiliser le coupon suivant pour finaliser votre paiement.
Référence du paiement
Date d\'expiration
Copier le code
diff --git a/voucher/src/main/res/values-hr-rHR/strings.xml b/voucher/src/main/res/values-hr-rHR/strings.xml
index ea14dd50c9..a207650235 100644
--- a/voucher/src/main/res/values-hr-rHR/strings.xml
+++ b/voucher/src/main/res/values-hr-rHR/strings.xml
@@ -9,7 +9,7 @@
Preuzmite upute za izravno terećenje (DDI / mandat)
- Zahvaljujemo na kupnji, upotrijebite sljedeći kupon za dovršetak plaćanja.
+ Zahvaljujemo na kupnji, upotrijebite sljedeći kupon za dovršetak plaćanja.
Referenca za plaćanje
Datum isteka
Kopiraj kôd
diff --git a/voucher/src/main/res/values-hu-rHU/strings.xml b/voucher/src/main/res/values-hu-rHU/strings.xml
index 36f483f75e..042d586e66 100644
--- a/voucher/src/main/res/values-hu-rHU/strings.xml
+++ b/voucher/src/main/res/values-hu-rHU/strings.xml
@@ -9,7 +9,7 @@
Beszedési megbízási utasítás (meghatalmazás) letöltése
- Köszönjük a vásárlást! Kérjük, a fizetéshez használja a következő kupont.
+ Köszönjük a vásárlást! Kérjük, a fizetéshez használja a következő kupont.
Fizetési referencia
Lejárati dátum
Kód másolása
diff --git a/voucher/src/main/res/values-it-rIT/strings.xml b/voucher/src/main/res/values-it-rIT/strings.xml
index e7ecba8cb4..a79f3e730c 100644
--- a/voucher/src/main/res/values-it-rIT/strings.xml
+++ b/voucher/src/main/res/values-it-rIT/strings.xml
@@ -9,7 +9,7 @@
Scarica le Istruzioni per l\'addebito diretto (DDI / Mandato)
- Grazie per il tuo acquisto, utilizza il seguente coupon per completare il pagamento.
+ Grazie per il tuo acquisto, utilizza il seguente coupon per completare il pagamento.
Riferimento del pagamento
Data di scadenza
Copia codice
diff --git a/voucher/src/main/res/values-ja-rJP/strings.xml b/voucher/src/main/res/values-ja-rJP/strings.xml
index e663229f03..e0f0a42bfc 100644
--- a/voucher/src/main/res/values-ja-rJP/strings.xml
+++ b/voucher/src/main/res/values-ja-rJP/strings.xml
@@ -9,7 +9,7 @@
自動引き落としの説明 (DDI/委任状) をダウンロードする
- お買い上げありがとうございます。以下のクーポンを使用して、お支払いを完了してください。
+ お買い上げありがとうございます。以下のクーポンを使用して、お支払いを完了してください。
支払いの参照
有効期限
コードをコピー
diff --git a/voucher/src/main/res/values-ko-rKR/strings.xml b/voucher/src/main/res/values-ko-rKR/strings.xml
index e6ccd42b0c..6059b2abc6 100644
--- a/voucher/src/main/res/values-ko-rKR/strings.xml
+++ b/voucher/src/main/res/values-ko-rKR/strings.xml
@@ -9,7 +9,7 @@
자동 이체 안내(DDI/필수) 다운로드
- 구매해 주셔서 감사합니다. 다음 쿠폰을 사용하여 결제를 완료하십시오.
+ 구매해 주셔서 감사합니다. 다음 쿠폰을 사용하여 결제를 완료하십시오.
결제 참조번호
만료일
코드 복사하기
diff --git a/voucher/src/main/res/values-nb-rNO/strings.xml b/voucher/src/main/res/values-nb-rNO/strings.xml
index a416da41c9..a308220a5d 100644
--- a/voucher/src/main/res/values-nb-rNO/strings.xml
+++ b/voucher/src/main/res/values-nb-rNO/strings.xml
@@ -9,7 +9,7 @@
Last ned instruksjoner for direktebelastning (DDI/ mandat)
- Takk for ditt kjøp. Vennligst bruk den følgende kupongen til å fullføre betalingen.
+ Takk for ditt kjøp. Vennligst bruk den følgende kupongen til å fullføre betalingen.
Betalingsreferanse
Utløpsdato
Kopier kode
diff --git a/voucher/src/main/res/values-nl-rNL/strings.xml b/voucher/src/main/res/values-nl-rNL/strings.xml
index a3bb49e508..aea687d4d8 100644
--- a/voucher/src/main/res/values-nl-rNL/strings.xml
+++ b/voucher/src/main/res/values-nl-rNL/strings.xml
@@ -9,7 +9,7 @@
Download uw machtiging automatische incasso
- Bedankt voor uw aankoop. Gebruik deze coupon om uw betaling te voltooien.
+ Bedankt voor uw aankoop. Gebruik deze coupon om uw betaling te voltooien.
Betalingsreferentie
Vervaldatum
Code kopiëren
diff --git a/voucher/src/main/res/values-pl-rPL/strings.xml b/voucher/src/main/res/values-pl-rPL/strings.xml
index ca46547eb7..c1f00ea491 100644
--- a/voucher/src/main/res/values-pl-rPL/strings.xml
+++ b/voucher/src/main/res/values-pl-rPL/strings.xml
@@ -9,7 +9,7 @@
Pobierz dyspozycję polecenia zapłaty (DDI/upoważnienie)
- Dziękujemy za zakup, dokończ płatność przy użyciu tego kuponu.
+ Dziękujemy za zakup, dokończ płatność przy użyciu tego kuponu.
Nr referencyjny płatności
Data ważności
Skopiuj kod
diff --git a/voucher/src/main/res/values-pt-rBR/strings.xml b/voucher/src/main/res/values-pt-rBR/strings.xml
index 5492175b15..f0ecf64703 100644
--- a/voucher/src/main/res/values-pt-rBR/strings.xml
+++ b/voucher/src/main/res/values-pt-rBR/strings.xml
@@ -9,7 +9,7 @@
Baixar instrução de débito direto (DDI)
- Obrigado pela sua compra, use o cupom a seguir para concluir o seu pagamento.
+ Obrigado pela sua compra, use o cupom a seguir para concluir o seu pagamento.
Referência de pagamento
Data de validade
Copiar código
diff --git a/voucher/src/main/res/values-pt-rPT/strings.xml b/voucher/src/main/res/values-pt-rPT/strings.xml
index 2aa1cdad24..5b363d8aab 100644
--- a/voucher/src/main/res/values-pt-rPT/strings.xml
+++ b/voucher/src/main/res/values-pt-rPT/strings.xml
@@ -9,7 +9,7 @@
Descarregue a sua Instrução de Débito Direto (DDI / Mandato)
- Obrigado pela sua compra, utilize o seguinte cupão para completar o seu pagamento.
+ Obrigado pela sua compra, utilize o seguinte cupão para completar o seu pagamento.
Referência de pagamento
Data de validade
Copiar código
diff --git a/voucher/src/main/res/values-ro-rRO/strings.xml b/voucher/src/main/res/values-ro-rRO/strings.xml
index ce0d6da110..105eb9567e 100644
--- a/voucher/src/main/res/values-ro-rRO/strings.xml
+++ b/voucher/src/main/res/values-ro-rRO/strings.xml
@@ -9,7 +9,7 @@
Descărcați instrucțiunile de debitare directă (DDI/mandat)
- Vă mulțumim pentru cumpărături, vă rugăm să utilizați următorul cupon pentru a vă finaliza plata.
+ Vă mulțumim pentru cumpărături, vă rugăm să utilizați următorul cupon pentru a vă finaliza plata.
Referința plății
Data de expirare
Copiați codul
diff --git a/voucher/src/main/res/values-ru-rRU/strings.xml b/voucher/src/main/res/values-ru-rRU/strings.xml
index 09e168abcc..ada3a554c6 100644
--- a/voucher/src/main/res/values-ru-rRU/strings.xml
+++ b/voucher/src/main/res/values-ru-rRU/strings.xml
@@ -9,7 +9,7 @@
Загрузить распоряжение прямого дебетования (DDI / поручение)
- Благодарим за покупку. Для завершения оплаты используйте следующий купон.
+ Благодарим за покупку. Для завершения оплаты используйте следующий купон.
Код оплаты
Срок действия
Скопировать код
diff --git a/voucher/src/main/res/values-sk-rSK/strings.xml b/voucher/src/main/res/values-sk-rSK/strings.xml
index b904c77969..da1b44b348 100644
--- a/voucher/src/main/res/values-sk-rSK/strings.xml
+++ b/voucher/src/main/res/values-sk-rSK/strings.xml
@@ -9,7 +9,7 @@
Stiahnite si pokyny k inkasu (DDI/Mandát)
- Ďakujeme vám za nákup; na dokončenie platby použite nasledujúci kupón.
+ Ďakujeme vám za nákup; na dokončenie platby použite nasledujúci kupón.
Platobná referencia
Dátum vypršania platnosti
Skopírovať kód
diff --git a/voucher/src/main/res/values-sl-rSI/strings.xml b/voucher/src/main/res/values-sl-rSI/strings.xml
index 0d4b45416b..0c37131f36 100644
--- a/voucher/src/main/res/values-sl-rSI/strings.xml
+++ b/voucher/src/main/res/values-sl-rSI/strings.xml
@@ -9,7 +9,7 @@
Prenesite navodila za neposredno bremenitev (DDI/mandat)
- Zahvaljujemo se vam za nakup. Za dokončanje plačila uporabite naslednji kupon.
+ Zahvaljujemo se vam za nakup. Za dokončanje plačila uporabite naslednji kupon.
Referenčna številka plačila
Datum poteka veljavnosti
Kopiraj kodo
diff --git a/voucher/src/main/res/values-sv-rSE/strings.xml b/voucher/src/main/res/values-sv-rSE/strings.xml
index 5e09b49e2a..6e6ea30a80 100644
--- a/voucher/src/main/res/values-sv-rSE/strings.xml
+++ b/voucher/src/main/res/values-sv-rSE/strings.xml
@@ -9,7 +9,7 @@
Ladda ner din instruktion för autogiro/direktdebitering (DDI / Mandate)
- Tack för ditt köp, vänligen använd följande kupong för att slutföra din betalning.
+ Tack för ditt köp, vänligen använd följande kupong för att slutföra din betalning.
Betalreferens
Utgångsdatum
Kopiera kod
diff --git a/voucher/src/main/res/values-zh-rCN/strings.xml b/voucher/src/main/res/values-zh-rCN/strings.xml
index f9064b9f5b..d54e383b90 100644
--- a/voucher/src/main/res/values-zh-rCN/strings.xml
+++ b/voucher/src/main/res/values-zh-rCN/strings.xml
@@ -9,7 +9,7 @@
下载您的直接借记指示(DDI/委托)
- 感谢您的购买,请使用以下优惠券完成支付。
+ 感谢您的购买,请使用以下优惠券完成支付。
交易号
有效期
复制代码
diff --git a/voucher/src/main/res/values-zh-rTW/strings.xml b/voucher/src/main/res/values-zh-rTW/strings.xml
index 9f176d3d0e..e46f1bc3f1 100644
--- a/voucher/src/main/res/values-zh-rTW/strings.xml
+++ b/voucher/src/main/res/values-zh-rTW/strings.xml
@@ -9,7 +9,7 @@
下載您的直接扣款指示(DDI/授權)
- 多謝惠顧,請使用以下優惠券完成付款。
+ 多謝惠顧,請使用以下優惠券完成付款。
付款參照號碼
到期日期
複製代碼
diff --git a/voucher/src/main/res/values/strings.xml b/voucher/src/main/res/values/strings.xml
index 840f53f17a..752b16ab0a 100644
--- a/voucher/src/main/res/values/strings.xml
+++ b/voucher/src/main/res/values/strings.xml
@@ -9,7 +9,7 @@
Download your Direct Debit Instruction (DDI / Mandate)
- Thank you for your purchase, please use the following coupon to complete your payment.
+ Thank you for your purchase, please use the following coupon to complete your payment.
Payment Reference
Expiration Date
Copy code
diff --git a/voucher/src/main/res/values/styles.xml b/voucher/src/main/res/values/styles.xml
index c55f194655..11905caa6e 100644
--- a/voucher/src/main/res/values/styles.xml
+++ b/voucher/src/main/res/values/styles.xml
@@ -27,7 +27,7 @@
- @dimen/standard_double_margin
- @dimen/standard_double_margin
- @dimen/standard_one_half_margin
- - @string/checkout_voucher_introduction_boleto
+ - @string/checkout_voucher_introduction
- center_horizontal
From 97f4facb692218f3acccd2b11990e8639764ddb9 Mon Sep 17 00:00:00 2001
From: Ararat Mnatsakanyan
Date: Fri, 22 Dec 2023 10:38:05 +0100
Subject: [PATCH 009/255] Separate Bacs voucher from simple voucher to keep the
implementation backward compatible. Add a comment that the Bacs style is
deprecated.
COAND-372
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
index c81aa4c3a..9a817a789 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/VoucherViewProvider.kt
@@ -12,9 +12,11 @@ import android.content.Context
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
+import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.BACS_VOUCHER
import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.BOLETO_VOUCHER
import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.FULL_VOUCHER
import com.adyen.checkout.voucher.internal.ui.VoucherComponentViewType.SIMPLE_VOUCHER
+import com.adyen.checkout.voucher.internal.ui.view.BacsVoucherView
import com.adyen.checkout.voucher.internal.ui.view.BoletoVoucherView
import com.adyen.checkout.voucher.internal.ui.view.FullVoucherView
import com.adyen.checkout.voucher.internal.ui.view.VoucherView
@@ -26,6 +28,7 @@ internal object VoucherViewProvider : ViewProvider {
context: Context,
): ComponentView {
return when (viewType) {
+ BACS_VOUCHER -> BacsVoucherView(context)
SIMPLE_VOUCHER -> VoucherView(context)
BOLETO_VOUCHER -> BoletoVoucherView(context)
FULL_VOUCHER -> FullVoucherView(context)
@@ -35,7 +38,7 @@ internal object VoucherViewProvider : ViewProvider {
}
internal enum class VoucherComponentViewType : ComponentViewType {
- SIMPLE_VOUCHER, BOLETO_VOUCHER, FULL_VOUCHER;
+ BACS_VOUCHER, SIMPLE_VOUCHER, BOLETO_VOUCHER, FULL_VOUCHER;
override val viewProvider: ViewProvider = VoucherViewProvider
}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
index f6060445c..5d77a326b 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherPaymentMethodConfig.kt
@@ -20,8 +20,8 @@ internal enum class VoucherPaymentMethodConfig(
) {
BACS(
- viewType = VoucherComponentViewType.SIMPLE_VOUCHER,
- introductionTextResource = R.string.checkout_voucher_introduction_bacs,
+ viewType = VoucherComponentViewType.BACS_VOUCHER,
+ introductionTextResource = null,
),
BOLETO(
viewType = VoucherComponentViewType.BOLETO_VOUCHER,
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BacsVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BacsVoucherView.kt
new file mode 100644
index 000000000..0b70e6dae
--- /dev/null
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BacsVoucherView.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2023 Adyen N.V.
+ *
+ * This file is open source and available under the MIT license. See the LICENSE file for more info.
+ *
+ * Created by ararat on 21/12/2023.
+ */
+
+package com.adyen.checkout.voucher.internal.ui.view
+
+import android.content.Context
+import android.util.AttributeSet
+import com.adyen.checkout.components.core.internal.ui.ComponentDelegate
+import com.adyen.checkout.ui.core.internal.util.setLocalizedTextFromStyle
+import com.adyen.checkout.voucher.R
+import kotlinx.coroutines.CoroutineScope
+
+// TODO: After removing BacsVoucherView, make sure to make SimpleVoucherView non open, binding to private and remove Bacs styles.
+internal class BacsVoucherView @JvmOverloads constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0
+) : VoucherView(context, attrs, defStyleAttr) {
+ override fun initView(delegate: ComponentDelegate, coroutineScope: CoroutineScope, localizedContext: Context) {
+ super.initView(delegate, coroutineScope, localizedContext)
+
+ binding.textViewDescription.setLocalizedTextFromStyle(
+ R.style.AdyenCheckout_Voucher_Description_Bacs,
+ localizedContext
+ )
+ }
+}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt
index ccfeae266..24582769a 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt
@@ -16,7 +16,7 @@ import com.adyen.checkout.voucher.R
import kotlinx.coroutines.CoroutineScope
// TODO: After removing BoletoVoucherView, make sure to make FullVoucherView non open, binding to private and remove Bolet styles.
-class BoletoVoucherView @JvmOverloads constructor(
+internal class BoletoVoucherView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
index d4d7da176..2525669b8 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
@@ -36,7 +36,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@Suppress("TooManyFunctions")
-open class FullVoucherView @JvmOverloads constructor(
+internal open class FullVoucherView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/VoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/VoucherView.kt
index de86c6de4..36d421028 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/VoucherView.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/VoucherView.kt
@@ -13,6 +13,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
+import androidx.annotation.StringRes
import com.adyen.checkout.components.core.internal.ui.ComponentDelegate
import com.adyen.checkout.core.internal.util.LogUtil
import com.adyen.checkout.core.internal.util.Logger
@@ -28,7 +29,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
-internal class VoucherView @JvmOverloads constructor(
+internal open class VoucherView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
@@ -40,7 +41,7 @@ internal class VoucherView @JvmOverloads constructor(
),
ComponentView {
- private val binding: VoucherViewBinding = VoucherViewBinding.inflate(LayoutInflater.from(context), this)
+ protected val binding: VoucherViewBinding = VoucherViewBinding.inflate(LayoutInflater.from(context), this)
private lateinit var localizedContext: Context
@@ -49,7 +50,7 @@ internal class VoucherView @JvmOverloads constructor(
init {
orientation = VERTICAL
val padding = resources.getDimension(R.dimen.standard_margin).toInt()
- setPadding(padding, padding, padding, padding)
+ this.setPadding(padding, padding, padding, padding)
}
override fun initView(delegate: ComponentDelegate, coroutineScope: CoroutineScope, localizedContext: Context) {
@@ -66,10 +67,6 @@ internal class VoucherView @JvmOverloads constructor(
}
private fun initLocalizedStrings(localizedContext: Context) {
- binding.textViewDescription.setLocalizedTextFromStyle(
- R.style.AdyenCheckout_Voucher_Description_Bacs,
- localizedContext
- )
binding.textViewDownload.setLocalizedTextFromStyle(
R.style.AdyenCheckout_Voucher_DownloadTextAppearance,
localizedContext
@@ -85,6 +82,7 @@ internal class VoucherView @JvmOverloads constructor(
private fun outputDataChanged(outputData: VoucherOutputData) {
Logger.d(TAG, "outputDataChanged")
loadLogo(outputData.paymentMethodType)
+ updateIntroductionText(outputData.introductionTextResource)
}
private fun loadLogo(paymentMethodType: String?) {
@@ -97,6 +95,11 @@ internal class VoucherView @JvmOverloads constructor(
}
}
+ private fun updateIntroductionText(@StringRes introductionTextResource: Int?) {
+ if (introductionTextResource == null) return
+ binding.textViewDescription.text = localizedContext.getString(introductionTextResource)
+ }
+
override fun highlightValidationErrors() {
// No validation required
}
diff --git a/voucher/src/main/res/layout/voucher_view.xml b/voucher/src/main/res/layout/voucher_view.xml
index 09bbf0daf..688b3ed21 100644
--- a/voucher/src/main/res/layout/voucher_view.xml
+++ b/voucher/src/main/res/layout/voucher_view.xml
@@ -22,7 +22,7 @@
diff --git a/voucher/src/main/res/values/styles.xml b/voucher/src/main/res/values/styles.xml
index 11905caa6..2cc001f87 100644
--- a/voucher/src/main/res/values/styles.xml
+++ b/voucher/src/main/res/values/styles.xml
@@ -10,8 +10,8 @@
-
-
+
+
+
+
+
-
-
+
+
+
+
+
+
From 105bcda6c37102bc3ec2a1e5ccf15ab1182e9d0b Mon Sep 17 00:00:00 2001
From: Ararat Mnatsakanyan
Date: Wed, 27 Dec 2023 14:56:04 +0100
Subject: [PATCH 013/255] Use Flexbox to align voucher buttons on the screen
and wrap them when text size is too big
COAND-372
diff --git a/dependencies.gradle b/dependencies.gradle
index 368b82eff..545b97065 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -41,6 +41,7 @@ ext {
material_version = "1.10.0"
recyclerview_version = "1.3.2"
constraintlayout_version = '2.1.4'
+ flexbox_version = "3.0.0"
// Compose Dependencies
compose_activity_version = '1.8.1'
@@ -108,6 +109,7 @@ ext {
],
viewmodel: "androidx.lifecycle:lifecycle-viewmodel-compose:$compose_viewmodel_version"
],
+ flexbox : "com.google.android.flexbox:flexbox:$flexbox_version",
googlePay : [
composeButton : "com.google.pay.button:compose-pay-button:$google_pay_compose_button_version",
playServicesWallet: "com.google.android.gms:play-services-wallet:$play_services_wallet_version",
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index ad73ab43e..2d9fbca15 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -5231,6 +5231,14 @@
+
+
+
+
+
+
+
+
diff --git a/voucher/build.gradle b/voucher/build.gradle
index 6e689999a..679698d43 100644
--- a/voucher/build.gradle
+++ b/voucher/build.gradle
@@ -48,6 +48,7 @@ dependencies {
// Dependencies
implementation libraries.androidx.browser
+ implementation libraries.flexbox
//Tests
testImplementation project(':test-core')
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
index feda72c45..bb91a6c39 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
@@ -150,7 +150,7 @@ internal open class FullVoucherView @JvmOverloads constructor(
if (informationFields.isNullOrEmpty()) return
if (informationFieldsAdapter == null) {
informationFieldsAdapter = VoucherInformationFieldsAdapter()
- binding.listViewInformationFields.adapter = informationFieldsAdapter
+ binding.recyclerViewInformationFields.adapter = informationFieldsAdapter
}
informationFieldsAdapter?.submitList(informationFields)
}
diff --git a/voucher/src/main/res/layout/full_voucher_view.xml b/voucher/src/main/res/layout/full_voucher_view.xml
index ec76d8354..2fac830a2 100644
--- a/voucher/src/main/res/layout/full_voucher_view.xml
+++ b/voucher/src/main/res/layout/full_voucher_view.xml
@@ -91,35 +91,40 @@
app:layout_constraintTop_toBottomOf="@id/paymentReferenceSeparator"
tools:text="12345.1234.12345.12345.12345678901 123456789012345" />
-
+ app:layout_constraintTop_toBottomOf="@id/textView_reference_code">
-
+
+
+
+
+
+ app:layout_constraintTop_toBottomOf="@id/flexboxLayout_buttons" />
+
+
+
+
+
+
+
+
diff --git a/voucher/build.gradle b/voucher/build.gradle
index 6e689999ae..679698d431 100644
--- a/voucher/build.gradle
+++ b/voucher/build.gradle
@@ -48,6 +48,7 @@ dependencies {
// Dependencies
implementation libraries.androidx.browser
+ implementation libraries.flexbox
//Tests
testImplementation project(':test-core')
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
index feda72c456..bb91a6c39e 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
@@ -150,7 +150,7 @@ internal open class FullVoucherView @JvmOverloads constructor(
if (informationFields.isNullOrEmpty()) return
if (informationFieldsAdapter == null) {
informationFieldsAdapter = VoucherInformationFieldsAdapter()
- binding.listViewInformationFields.adapter = informationFieldsAdapter
+ binding.recyclerViewInformationFields.adapter = informationFieldsAdapter
}
informationFieldsAdapter?.submitList(informationFields)
}
diff --git a/voucher/src/main/res/layout/full_voucher_view.xml b/voucher/src/main/res/layout/full_voucher_view.xml
index ec76d8354e..2fac830a29 100644
--- a/voucher/src/main/res/layout/full_voucher_view.xml
+++ b/voucher/src/main/res/layout/full_voucher_view.xml
@@ -91,35 +91,40 @@
app:layout_constraintTop_toBottomOf="@id/paymentReferenceSeparator"
tools:text="12345.1234.12345.12345.12345678901 123456789012345" />
-
+ app:layout_constraintTop_toBottomOf="@id/textView_reference_code">
-
+
+
+
+
+
+ app:layout_constraintTop_toBottomOf="@id/flexboxLayout_buttons" />
Date: Thu, 28 Dec 2023 09:57:03 +0100
Subject: [PATCH 014/255] Make BoletoVoucherView a duplicate of old
FullVoucherView with Boleto specific layout to not introduce breaking
changes.
COAND-372
---
.../internal/ui/DefaultVoucherDelegate.kt | 2 +
.../internal/ui/model/VoucherOutputData.kt | 2 +
.../internal/ui/view/BoletoVoucherView.kt | 153 +++++++++++++++++-
.../internal/ui/view/FullVoucherView.kt | 4 +-
.../main/res/layout/boleto_voucher_view.xml | 141 ++++++++++++++++
voucher/src/main/res/values/styles.xml | 17 +-
6 files changed, 307 insertions(+), 12 deletions(-)
create mode 100644 voucher/src/main/res/layout/boleto_voucher_view.xml
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt
index 578b134648..6f1ac05667 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegate.kt
@@ -98,6 +98,7 @@ internal class DefaultVoucherDelegate(
paymentMethodType = action.paymentMethodType,
// TODO: remove action.url when it's fixed from backend side
downloadUrl = action.downloadUrl ?: action.url,
+ expiresAt = action.expiresAt,
reference = action.reference,
totalAmount = action.totalAmount,
introductionTextResource = config.introductionTextResource,
@@ -110,6 +111,7 @@ internal class DefaultVoucherDelegate(
isValid = false,
paymentMethodType = null,
downloadUrl = null,
+ expiresAt = null,
reference = null,
totalAmount = null,
introductionTextResource = null,
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt
index b0758468fc..8dee9f510c 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/model/VoucherOutputData.kt
@@ -17,6 +17,8 @@ data class VoucherOutputData(
override val isValid: Boolean,
val paymentMethodType: String?,
val downloadUrl: String?,
+ // TODO: Should be removed with BoletoVoucherView
+ val expiresAt: String?,
val reference: String?,
val totalAmount: Amount?,
val introductionTextResource: Int?,
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt
index 24582769a0..1385482785 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/BoletoVoucherView.kt
@@ -3,30 +3,175 @@
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
- * Created by ararat on 21/12/2023.
+ * Created by ararat on 28/12/2023.
*/
package com.adyen.checkout.voucher.internal.ui.view
import android.content.Context
import android.util.AttributeSet
+import android.view.LayoutInflater
+import android.view.View
+import androidx.constraintlayout.widget.ConstraintLayout
+import androidx.core.view.isVisible
+import com.adyen.checkout.components.core.Amount
import com.adyen.checkout.components.core.internal.ui.ComponentDelegate
+import com.adyen.checkout.components.core.internal.util.CurrencyUtils
+import com.adyen.checkout.components.core.internal.util.DateUtils
+import com.adyen.checkout.components.core.internal.util.copyTextToClipboard
+import com.adyen.checkout.components.core.internal.util.isEmpty
+import com.adyen.checkout.core.internal.util.LogUtil
+import com.adyen.checkout.core.internal.util.Logger
+import com.adyen.checkout.ui.core.internal.ui.ComponentView
+import com.adyen.checkout.ui.core.internal.ui.LogoSize
+import com.adyen.checkout.ui.core.internal.ui.loadLogo
import com.adyen.checkout.ui.core.internal.util.setLocalizedTextFromStyle
import com.adyen.checkout.voucher.R
+import com.adyen.checkout.voucher.databinding.BoletoVoucherViewBinding
+import com.adyen.checkout.voucher.internal.ui.VoucherDelegate
+import com.adyen.checkout.voucher.internal.ui.model.VoucherOutputData
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.flow.launchIn
+import kotlinx.coroutines.flow.onEach
-// TODO: After removing BoletoVoucherView, make sure to make FullVoucherView non open, binding to private and remove Bolet styles.
+@Suppress("TooManyFunctions")
internal class BoletoVoucherView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
-) : FullVoucherView(context, attrs, defStyleAttr) {
+) :
+ ConstraintLayout(
+ context,
+ attrs,
+ defStyleAttr
+ ),
+ ComponentView {
+
+ private val binding: BoletoVoucherViewBinding = BoletoVoucherViewBinding.inflate(LayoutInflater.from(context), this)
+
+ private lateinit var localizedContext: Context
+
+ private lateinit var delegate: VoucherDelegate
+
+ init {
+ val padding = resources.getDimension(R.dimen.standard_margin).toInt()
+ setPadding(padding, padding, padding, padding)
+ }
+
override fun initView(delegate: ComponentDelegate, coroutineScope: CoroutineScope, localizedContext: Context) {
- super.initView(delegate, coroutineScope, localizedContext)
+ require(delegate is VoucherDelegate) { "Unsupported delegate type" }
+
+ this.delegate = delegate
+
+ this.localizedContext = localizedContext
+ initLocalizedStrings(localizedContext)
+
+ observeDelegate(delegate, coroutineScope)
+
+ binding.buttonCopyCode.setOnClickListener { copyCode(delegate.outputData.reference) }
+ binding.buttonDownloadPdf.setOnClickListener { delegate.downloadVoucher(context) }
+ }
+ private fun initLocalizedStrings(localizedContext: Context) {
binding.textViewIntroduction.setLocalizedTextFromStyle(
R.style.AdyenCheckout_Voucher_Description_Boleto,
localizedContext
)
+ binding.textViewPaymentReference.setLocalizedTextFromStyle(
+ R.style.AdyenCheckout_Voucher_PaymentReference,
+ localizedContext
+ )
+ binding.buttonCopyCode.setLocalizedTextFromStyle(
+ R.style.AdyenCheckout_Voucher_ButtonCopyCode,
+ localizedContext
+ )
+ binding.buttonDownloadPdf.setLocalizedTextFromStyle(
+ R.style.AdyenCheckout_Voucher_ButtonDownloadPdf,
+ localizedContext
+ )
+ binding.textViewExpirationLabel.setLocalizedTextFromStyle(
+ R.style.AdyenCheckout_Voucher_ExpirationDateLabel,
+ localizedContext
+ )
+ }
+
+ private fun observeDelegate(delegate: VoucherDelegate, coroutineScope: CoroutineScope) {
+ delegate.outputDataFlow
+ .onEach { outputDataChanged(it) }
+ .launchIn(coroutineScope)
+ }
+
+ private fun outputDataChanged(outputData: VoucherOutputData) {
+ Logger.d(TAG, "outputDataChanged")
+
+ loadLogo(outputData.paymentMethodType)
+ updateAmount(outputData.totalAmount)
+ updateCodeReference(outputData.reference)
+ updateExpirationDate(outputData.expiresAt)
+ }
+
+ private fun loadLogo(paymentMethodType: String?) {
+ if (!paymentMethodType.isNullOrEmpty()) {
+ binding.imageViewLogo.loadLogo(
+ environment = delegate.componentParams.environment,
+ txVariant = paymentMethodType,
+ size = LogoSize.MEDIUM,
+ )
+ }
+ }
+
+ private fun updateAmount(amount: Amount?) {
+ if (amount != null && !amount.isEmpty) {
+ val formattedAmount = CurrencyUtils.formatAmount(
+ amount,
+ delegate.componentParams.shopperLocale
+ )
+ binding.textViewAmount.isVisible = true
+ binding.textViewAmount.text = formattedAmount
+ } else {
+ binding.textViewAmount.isVisible = false
+ }
+ }
+
+ private fun updateCodeReference(codeReference: String?) {
+ binding.textViewReferenceCode.text = codeReference
+
+ val isVisible = !codeReference.isNullOrEmpty()
+ binding.textViewReferenceCode.isVisible = isVisible
+ binding.buttonCopyCode.isVisible = isVisible
+ }
+
+ private fun updateExpirationDate(expiresAt: String?) {
+ binding.textViewExpirationDate.text = expiresAt?.let {
+ DateUtils.formatStringDate(
+ expiresAt,
+ delegate.componentParams.shopperLocale
+ )
+ }
+
+ val isVisible = !expiresAt.isNullOrEmpty()
+ binding.textViewExpirationLabel.isVisible = isVisible
+ binding.textViewExpirationDate.isVisible = isVisible
+ binding.expiryDateSeparator.isVisible = isVisible
+ }
+
+ private fun copyCode(codeReference: String?) {
+ codeReference ?: return
+ context.copyTextToClipboard(
+ COPY_LABEL,
+ codeReference,
+ localizedContext.getString(R.string.checkout_voucher_copied_toast)
+ )
+ }
+
+ override fun highlightValidationErrors() {
+ // No validation required
+ }
+
+ override fun getView(): View = this
+
+ companion object {
+ private val TAG = LogUtil.getTag()
+ private const val COPY_LABEL = "Voucher code reference"
}
}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
index bb91a6c39e..b9e169450b 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
@@ -36,7 +36,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@Suppress("TooManyFunctions")
-internal open class FullVoucherView @JvmOverloads constructor(
+internal class FullVoucherView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
@@ -48,7 +48,7 @@ internal open class FullVoucherView @JvmOverloads constructor(
),
ComponentView {
- protected val binding: FullVoucherViewBinding = FullVoucherViewBinding.inflate(LayoutInflater.from(context), this)
+ private val binding: FullVoucherViewBinding = FullVoucherViewBinding.inflate(LayoutInflater.from(context), this)
private lateinit var localizedContext: Context
private lateinit var delegate: VoucherDelegate
diff --git a/voucher/src/main/res/layout/boleto_voucher_view.xml b/voucher/src/main/res/layout/boleto_voucher_view.xml
new file mode 100644
index 0000000000..35d11d78ab
--- /dev/null
+++ b/voucher/src/main/res/layout/boleto_voucher_view.xml
@@ -0,0 +1,141 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/voucher/src/main/res/values/styles.xml b/voucher/src/main/res/values/styles.xml
index 40b4387e77..1ce757d6cc 100644
--- a/voucher/src/main/res/values/styles.xml
+++ b/voucher/src/main/res/values/styles.xml
@@ -10,8 +10,7 @@
-
+
@@ -23,8 +22,7 @@
- center_horizontal
-
+
+
+
-
+
+
+
-
+
@@ -22,7 +23,8 @@
- center_horizontal
-
+
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/voucher/src/test/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegateTest.kt b/voucher/src/test/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegateTest.kt
index ce659b8fb5..ce9bcaf67b 100644
--- a/voucher/src/test/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegateTest.kt
+++ b/voucher/src/test/java/com/adyen/checkout/voucher/internal/ui/DefaultVoucherDelegateTest.kt
@@ -129,7 +129,6 @@ internal class DefaultVoucherDelegateTest(
with(expectMostRecentItem()) {
assertEquals(PaymentMethodTypes.BACS, paymentMethodType)
assertEquals(VoucherStoreAction.DownloadPdf("download_url"), storeAction)
- assertEquals("now", expiresAt)
assertEquals("ref", reference)
assertEquals(Amount("EUR", 1000), totalAmount)
}
@@ -154,7 +153,6 @@ internal class DefaultVoucherDelegateTest(
with(expectMostRecentItem()) {
assertEquals(PaymentMethodTypes.MULTIBANCO, paymentMethodType)
assertEquals(VoucherStoreAction.SaveAsImage, storeAction)
- assertEquals("now", expiresAt)
assertEquals("ref", reference)
assertEquals(Amount("EUR", 1000), totalAmount)
}
@@ -224,7 +222,7 @@ internal class DefaultVoucherDelegateTest(
@Test
fun `when saveVoucherAsImage is called, then correct ui event should be emitted`() = runTest {
- whenever(imageSaver.saveImageFromView(any(), any(), any(), anyOrNull(), anyOrNull())).thenReturn(
+ whenever(imageSaver.saveImageFromView(any(), any(), any(), anyOrNull(), anyOrNull(), anyOrNull())).thenReturn(
Result.success(Unit),
)
@@ -241,7 +239,16 @@ internal class DefaultVoucherDelegateTest(
@Test
fun `when saveVoucherAsImage is called with permission exception, then permission denied ui event should be emitted`() =
runTest {
- whenever(imageSaver.saveImageFromView(any(), any(), any(), anyOrNull(), anyOrNull())).thenReturn(
+ whenever(
+ imageSaver.saveImageFromView(
+ any(),
+ any(),
+ any(),
+ anyOrNull(),
+ anyOrNull(),
+ anyOrNull(),
+ ),
+ ).thenReturn(
Result.failure(PermissionRequestException("Error message for permission request exception")),
)
@@ -258,7 +265,7 @@ internal class DefaultVoucherDelegateTest(
@Test
fun `when saveVoucherAsImage is called with error, then failure ui event should be emitted`() = runTest {
val throwable = ComponentException("Error message")
- whenever(imageSaver.saveImageFromView(any(), any(), any(), anyOrNull(), anyOrNull())).thenReturn(
+ whenever(imageSaver.saveImageFromView(any(), any(), any(), anyOrNull(), anyOrNull(), anyOrNull())).thenReturn(
Result.failure(throwable),
)
@@ -310,14 +317,14 @@ internal class DefaultVoucherDelegateTest(
@JvmStatic
fun viewTypeSource() = listOf(
// PaymentMethodType, VoucherComponentViewType
- arguments(PaymentMethodTypes.BACS, VoucherComponentViewType.BACS_VOUCHER),
- arguments(PaymentMethodTypes.BOLETOBANCARIO, VoucherComponentViewType.BOLETO_VOUCHER),
- arguments(PaymentMethodTypes.BOLETOBANCARIO_BANCODOBRASIL, VoucherComponentViewType.BOLETO_VOUCHER),
- arguments(PaymentMethodTypes.BOLETOBANCARIO_BRADESCO, VoucherComponentViewType.BOLETO_VOUCHER),
- arguments(PaymentMethodTypes.BOLETOBANCARIO_HSBC, VoucherComponentViewType.BOLETO_VOUCHER),
- arguments(PaymentMethodTypes.BOLETOBANCARIO_ITAU, VoucherComponentViewType.BOLETO_VOUCHER),
- arguments(PaymentMethodTypes.BOLETOBANCARIO_SANTANDER, VoucherComponentViewType.BOLETO_VOUCHER),
- arguments(PaymentMethodTypes.BOLETO_PRIMEIRO_PAY, VoucherComponentViewType.BOLETO_VOUCHER),
+ arguments(PaymentMethodTypes.BACS, VoucherComponentViewType.SIMPLE_VOUCHER),
+ arguments(PaymentMethodTypes.BOLETOBANCARIO, VoucherComponentViewType.FULL_VOUCHER),
+ arguments(PaymentMethodTypes.BOLETOBANCARIO_BANCODOBRASIL, VoucherComponentViewType.FULL_VOUCHER),
+ arguments(PaymentMethodTypes.BOLETOBANCARIO_BRADESCO, VoucherComponentViewType.FULL_VOUCHER),
+ arguments(PaymentMethodTypes.BOLETOBANCARIO_HSBC, VoucherComponentViewType.FULL_VOUCHER),
+ arguments(PaymentMethodTypes.BOLETOBANCARIO_ITAU, VoucherComponentViewType.FULL_VOUCHER),
+ arguments(PaymentMethodTypes.BOLETOBANCARIO_SANTANDER, VoucherComponentViewType.FULL_VOUCHER),
+ arguments(PaymentMethodTypes.BOLETO_PRIMEIRO_PAY, VoucherComponentViewType.FULL_VOUCHER),
arguments(PaymentMethodTypes.MULTIBANCO, VoucherComponentViewType.FULL_VOUCHER),
)
}
From 4dd521abbf023be82ecfc89708b1d8ba55d5cc62 Mon Sep 17 00:00:00 2001
From: Ararat Mnatsakanyan
Date: Fri, 26 Jan 2024 15:22:16 +0100
Subject: [PATCH 037/255] Address CR comments
COAND-372
---
RELEASE_NOTES.md | 3 +-
.../internal/ui/view/FullVoucherView.kt | 54 +++++++++++--------
.../view/VoucherInformationFieldsAdapter.kt | 16 +++---
.../src/main/res/layout/full_voucher_view.xml | 19 +++++--
voucher/src/main/res/values/styles.xml | 32 +++++------
5 files changed, 76 insertions(+), 48 deletions(-)
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index fdebe43746..ef5b375c4e 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -21,7 +21,8 @@
- The `AdyenCheckout.Voucher.Description.Boleto` style will not work anymore. Use `AdyenCheckout.Voucher.Full.Description` instead.
- The `AdyenCheckout.Voucher.ExpirationDateLabel` style will not work anymore. Use `AdyenCheckout.Voucher.InformationFieldLabel` instead.
- The `AdyenCheckout.Voucher.ExpirationDate` style will not work anymore. Use `AdyenCheckout.Voucher.InformationFieldValue` instead.
- - The `AdyenCheckout.Voucher.ButtonCopyCode` and `AdyenCheckout.Voucher.ButtonDownloadPdf` styles will not work anymore. Use `AdyenCheckout.Voucher.ActionButton` instead.
+ - The `AdyenCheckout.Voucher.ButtonCopyCode` style will not work anymore. Use `AdyenCheckout.Voucher.Button.CopyCode` instead.
+ - The `AdyenCheckout.Voucher.ButtonDownloadPdf` styles will not work anymore. Use `AdyenCheckout.Voucher.Button.DownloadPdf` instead.
## Changed
- In drop-in all actions will start in expanded mode
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
index 73237df1bd..219f7ce261 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/FullVoucherView.kt
@@ -80,13 +80,27 @@ internal class FullVoucherView @JvmOverloads constructor(
this.coroutineScope = coroutineScope
binding.buttonCopyCode.setOnClickListener { copyCode(delegate.outputData.reference) }
+ binding.buttonDownloadPdf.setOnClickListener { onDownloadPdfClicked() }
+ binding.buttonSaveImage.setOnClickListener { onSaveAsImageClicked() }
}
- private fun initLocalizedStrings(localizedContext: Context) {
- binding.textViewPaymentReference.setLocalizedTextFromStyle(
+ private fun initLocalizedStrings(localizedContext: Context) = with(binding) {
+ textViewPaymentReference.setLocalizedTextFromStyle(
R.style.AdyenCheckout_Voucher_PaymentReference,
localizedContext,
)
+ buttonCopyCode.setLocalizedTextFromStyle(
+ R.style.AdyenCheckout_Voucher_Button_CopyCode,
+ localizedContext,
+ )
+ buttonDownloadPdf.setLocalizedTextFromStyle(
+ R.style.AdyenCheckout_Voucher_Button_DownloadPdf,
+ localizedContext,
+ )
+ buttonSaveImage.setLocalizedTextFromStyle(
+ R.style.AdyenCheckout_Voucher_Button_SaveImage,
+ localizedContext,
+ )
}
private fun observeDelegate(delegate: VoucherDelegate, coroutineScope: CoroutineScope) {
@@ -106,7 +120,7 @@ internal class FullVoucherView @JvmOverloads constructor(
updateIntroductionText(outputData.introductionTextResource)
updateAmount(outputData.totalAmount)
updateCodeReference(outputData.reference)
- updateStoreActionButton(outputData.storeAction)
+ updateStoreAction(outputData.storeAction)
updateInformationFields(outputData.informationFields)
}
@@ -146,27 +160,15 @@ internal class FullVoucherView @JvmOverloads constructor(
buttonCopyCode.isVisible = isVisible
}
- private fun updateStoreActionButton(storeAction: VoucherStoreAction?) = with(binding) {
- buttonStore.isVisible = storeAction != null
-
- if (storeAction == null) return
- when (storeAction) {
- is VoucherStoreAction.DownloadPdf -> {
- buttonStore.text = localizedContext.getString(R.string.checkout_voucher_download_pdf)
- buttonStore.setOnClickListener { onDownloadPdfClicked() }
- }
-
- VoucherStoreAction.SaveAsImage -> {
- buttonStore.text = localizedContext.getString(R.string.checkout_voucher_save_image)
- buttonStore.setOnClickListener { onSaveAsImageClicked() }
- }
- }
+ private fun updateStoreAction(storeAction: VoucherStoreAction?) = with(binding) {
+ buttonDownloadPdf.isVisible = storeAction is VoucherStoreAction.DownloadPdf
+ buttonSaveImage.isVisible = storeAction is VoucherStoreAction.SaveAsImage
}
private fun updateInformationFields(informationFields: List?) {
if (informationFields.isNullOrEmpty()) return
if (informationFieldsAdapter == null) {
- informationFieldsAdapter = VoucherInformationFieldsAdapter()
+ informationFieldsAdapter = VoucherInformationFieldsAdapter(context, localizedContext)
binding.recyclerViewInformationFields.adapter = informationFieldsAdapter
}
informationFieldsAdapter?.submitList(informationFields)
@@ -177,13 +179,23 @@ internal class FullVoucherView @JvmOverloads constructor(
}
private fun onSaveAsImageClicked() {
- binding.layoutButtons.isVisible = false
+ hideButtons()
doOnNextLayout {
delegate.saveVoucherAsImage(context, this)
- binding.layoutButtons.isVisible = true
+ showButtons()
}
}
+ private fun hideButtons() = with(binding) {
+ buttonCopyCode.isVisible = false
+ updateStoreAction(null)
+ }
+
+ private fun showButtons() = with(binding) {
+ buttonCopyCode.isVisible = true
+ updateStoreAction(delegate.outputData.storeAction)
+ }
+
private fun copyCode(codeReference: String?) {
codeReference ?: return
context.copyTextToClipboard(
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/VoucherInformationFieldsAdapter.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/VoucherInformationFieldsAdapter.kt
index 6201c0dd6a..a8d54feafc 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/VoucherInformationFieldsAdapter.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/ui/view/VoucherInformationFieldsAdapter.kt
@@ -8,6 +8,7 @@
package com.adyen.checkout.voucher.internal.ui.view
+import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
@@ -17,12 +18,14 @@ import com.adyen.checkout.voucher.databinding.FullVoucherInformationFieldBinding
import com.adyen.checkout.voucher.internal.ui.model.VoucherInformationField
import com.adyen.checkout.voucher.internal.ui.view.VoucherInformationFieldsAdapter.InformationFieldViewHolder
-internal class VoucherInformationFieldsAdapter :
- ListAdapter(InformationFieldsDiffCallback) {
+internal class VoucherInformationFieldsAdapter(
+ private val context: Context,
+ private val localizedContext: Context
+) : ListAdapter(InformationFieldsDiffCallback) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): InformationFieldViewHolder {
- val binding = FullVoucherInformationFieldBinding.inflate(LayoutInflater.from(parent.context), parent, false)
- return InformationFieldViewHolder(binding)
+ val binding = FullVoucherInformationFieldBinding.inflate(LayoutInflater.from(context), parent, false)
+ return InformationFieldViewHolder(binding, localizedContext)
}
override fun onBindViewHolder(holder: InformationFieldViewHolder, position: Int) {
@@ -31,10 +34,11 @@ internal class VoucherInformationFieldsAdapter :
}
internal class InformationFieldViewHolder(
- private val binding: FullVoucherInformationFieldBinding
+ private val binding: FullVoucherInformationFieldBinding,
+ private val localizedContext: Context
) : ViewHolder(binding.root) {
fun bindItem(model: VoucherInformationField) {
- binding.textViewInformationLabel.text = binding.root.context.getString(model.labelResId)
+ binding.textViewInformationLabel.text = localizedContext.getString(model.labelResId)
binding.textViewInformationValue.text = model.value
}
}
diff --git a/voucher/src/main/res/layout/full_voucher_view.xml b/voucher/src/main/res/layout/full_voucher_view.xml
index ff5da949b2..1d9156a977 100644
--- a/voucher/src/main/res/layout/full_voucher_view.xml
+++ b/voucher/src/main/res/layout/full_voucher_view.xml
@@ -105,7 +105,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/standard_half_margin"
android:layout_marginEnd="@dimen/standard_half_margin"
- app:constraint_referenced_ids="button_copyCode,button_store"
+ app:constraint_referenced_ids="button_copyCode,button_downloadPdf,button_saveImage"
app:flow_horizontalGap="@dimen/standard_half_margin"
app:flow_horizontalStyle="spread_inside"
app:flow_wrapMode="chain"
@@ -115,20 +115,29 @@
+ tools:text="@string/checkout_voucher_copy_code" />
+
+
@string/checkout_voucher_download_pdf
-
-
@@ -75,6 +70,23 @@
- center_horizontal
+
+
+
+
+
+
+
+
@@ -97,14 +109,4 @@
-
-
-
-
-
-
-
-
From 190be3afc7abfbfc98f407bed8757689017153d7 Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Thu, 7 Dec 2023 14:18:26 +0100
Subject: [PATCH 038/255] Create CheckoutConfiguration object
COAND-811
---
.../components/core/CheckoutConfiguration.kt | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt b/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
new file mode 100644
index 0000000000..e6dc760711
--- /dev/null
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2023 Adyen N.V.
+ *
+ * This file is open source and available under the MIT license. See the LICENSE file for more info.
+ *
+ * Created by oscars on 5/12/2023.
+ */
+
+package com.adyen.checkout.components.core
+
+import androidx.annotation.RestrictTo
+import com.adyen.checkout.components.core.internal.Configuration
+import com.adyen.checkout.core.Environment
+import java.util.Locale
+import kotlin.reflect.KClass
+
+class CheckoutConfiguration(
+ val shopperLocale: Locale,
+ val environment: Environment,
+ val clientKey: String,
+ val amount: Amount? = null,
+ val analyticsConfiguration: AnalyticsConfiguration? = null,
+ config: CheckoutConfiguration.() -> Unit = {},
+) {
+
+ init {
+ this.apply(config)
+ }
+
+ private val availablePaymentConfigs = mutableMapOf, Configuration>()
+
+ fun addConfiguration(configuration: Configuration) {
+ availablePaymentConfigs[configuration::class] = configuration
+ }
+
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ fun getConfiguration(configKlass: KClass): T? {
+ @Suppress("UNCHECKED_CAST")
+ return availablePaymentConfigs[configKlass] as? T
+ }
+}
From 36480ca425a2bedbadc5cd1a5815428794eee5ff Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Thu, 7 Dec 2023 15:19:48 +0100
Subject: [PATCH 039/255] Add config methods for every component
COAND-811
---
.../adyen3ds2/Adyen3DS2Configuration.kt | 23 ++-
.../ach/ACHDirectDebitConfiguration.kt | 20 ++
.../checkout/await/AwaitConfiguration.kt | 23 ++-
.../bacs/BacsDirectDebitConfiguration.kt | 19 ++
.../adyen/checkout/bcmc/BcmcConfiguration.kt | 21 +-
.../adyen/checkout/blik/BlikConfiguration.kt | 19 ++
.../checkout/boleto/BoletoConfiguration.kt | 25 ++-
.../adyen/checkout/card/CardConfiguration.kt | 25 ++-
.../cashapppay/CashAppPayConfiguration.kt | 23 ++-
.../ConvenienceStoresJPConfiguration.kt | 21 +-
.../checkout/dotpay/DotpayConfiguration.kt | 21 +-
.../checkout/dropin/DropInConfiguration.kt | 19 +-
.../entercash/EntercashConfiguration.kt | 19 ++
.../adyen/checkout/eps/EPSConfiguration.kt | 22 +-
.../CheckoutConfigurationProvider.kt | 194 +++++++++---------
.../giftcard/GiftCardConfiguration.kt | 19 ++
.../googlepay/GooglePayConfiguration.kt | 23 ++-
.../checkout/ideal/IdealConfiguration.kt | 21 +-
.../instant/InstantPaymentConfiguration.kt | 19 ++
.../checkout/mbway/MBWayConfiguration.kt | 24 ++-
.../checkout/molpay/MolpayConfiguration.kt | 21 +-
.../OnlineBankingCZConfiguration.kt | 21 +-
.../OnlineBankingJPConfiguration.kt | 19 ++
.../OnlineBankingPLConfiguration.kt | 21 +-
.../OnlineBankingSKConfiguration.kt | 21 +-
.../openbanking/OpenBankingConfiguration.kt | 21 +-
.../paybybank/PayByBankConfiguration.kt | 21 +-
.../checkout/payeasy/PayEasyConfiguration.kt | 19 ++
.../checkout/qrcode/QRCodeConfiguration.kt | 24 ++-
.../redirect/RedirectConfiguration.kt | 19 ++
.../adyen/checkout/sepa/SepaConfiguration.kt | 21 +-
.../seveneleven/SevenElevenConfiguration.kt | 21 +-
.../adyen/checkout/upi/UPIConfiguration.kt | 24 ++-
.../checkout/voucher/VoucherConfiguration.kt | 23 ++-
.../wechatpay/WeChatPayActionConfiguration.kt | 21 +-
35 files changed, 777 insertions(+), 140 deletions(-)
diff --git a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt
index 1315698c9d..6962db68eb 100644
--- a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt
+++ b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt
@@ -11,6 +11,7 @@ import android.content.Context
import android.content.IntentFilter
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.internal.BaseConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.core.Environment
@@ -53,7 +54,7 @@ class Adyen3DS2Configuration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -66,7 +67,7 @@ class Adyen3DS2Configuration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
/**
@@ -106,3 +107,21 @@ class Adyen3DS2Configuration private constructor(
}
}
}
+
+fun CheckoutConfiguration.adyen3DS2Configuration(
+ configuration: Adyen3DS2Configuration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = Adyen3DS2Configuration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getAdyen3DS2Configuration(): Adyen3DS2Configuration? {
+ return getConfiguration(Adyen3DS2Configuration::class)
+}
diff --git a/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt b/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt
index 550ab4f8ac..4045bd3ce6 100644
--- a/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt
+++ b/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt
@@ -13,6 +13,7 @@ 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.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -127,3 +128,22 @@ class ACHDirectDebitConfiguration private constructor(
}
}
}
+
+@Suppress("FunctionName")
+fun CheckoutConfiguration.ACHDirectDebitConfiguration(
+ configuration: ACHDirectDebitConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = ACHDirectDebitConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getACHDirectDebitConfiguration(): ACHDirectDebitConfiguration? {
+ return getConfiguration(ACHDirectDebitConfiguration::class)
+}
diff --git a/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt b/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt
index 8922b1d87f..80bdd4cdf1 100644
--- a/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt
+++ b/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt
@@ -10,6 +10,7 @@ package com.adyen.checkout.await
import android.content.Context
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.internal.BaseConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.core.Environment
@@ -43,7 +44,7 @@ class AwaitConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -56,7 +57,7 @@ class AwaitConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
override fun buildInternal(): AwaitConfiguration {
@@ -70,3 +71,21 @@ class AwaitConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.awaitConfiguration(
+ configuration: AwaitConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = AwaitConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getAwaitConfiguration(): AwaitConfiguration? {
+ return getConfiguration(AwaitConfiguration::class)
+}
diff --git a/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt b/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt
index d74f20df88..a7904d30d4 100644
--- a/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt
+++ b/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt
@@ -13,6 +13,7 @@ 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.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -95,3 +96,21 @@ class BacsDirectDebitConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.bacsDirectDebitConfiguration(
+ configuration: BacsDirectDebitConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = BacsDirectDebitConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getBacsDirectDebitConfiguration(): BacsDirectDebitConfiguration? {
+ return getConfiguration(BacsDirectDebitConfiguration::class)
+}
diff --git a/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt b/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt
index 6c0a5e1c9c..95048e97df 100644
--- a/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt
+++ b/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt
@@ -12,6 +12,7 @@ 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.PaymentComponentData
import com.adyen.checkout.components.core.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
@@ -60,7 +61,7 @@ class BcmcConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -150,3 +151,21 @@ class BcmcConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.bcmcConfiguration(
+ configuration: BcmcConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = BcmcConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getBcmcConfiguration(): BcmcConfiguration? {
+ return getConfiguration(BcmcConfiguration::class)
+}
diff --git a/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt b/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt
index e3c42ddbb2..0925d0e775 100644
--- a/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt
+++ b/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt
@@ -12,6 +12,7 @@ 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.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -94,3 +95,21 @@ class BlikConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.blikConfiguration(
+ configuration: BlikConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = BlikConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getBlikConfiguration(): BlikConfiguration? {
+ return getConfiguration(BlikConfiguration::class)
+}
diff --git a/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt b/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt
index 2152b819a6..5a31296614 100644
--- a/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt
+++ b/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt
@@ -13,6 +13,7 @@ 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.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -55,7 +56,7 @@ class BoletoConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -68,7 +69,7 @@ class BoletoConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
/**
@@ -102,7 +103,25 @@ class BoletoConfiguration private constructor(
amount = amount,
isSubmitButtonVisible = isSubmitButtonVisible,
genericActionConfiguration = genericActionConfigurationBuilder.build(),
- isEmailVisible = isEmailVisible
+ isEmailVisible = isEmailVisible,
)
}
}
+
+fun CheckoutConfiguration.boletoConfiguration(
+ configuration: BoletoConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = BoletoConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getBoletoConfiguration(): BoletoConfiguration? {
+ return getConfiguration(BoletoConfiguration::class)
+}
diff --git a/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt b/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt
index c715f79bac..e97e366417 100644
--- a/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt
+++ b/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt
@@ -12,6 +12,7 @@ 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.PaymentComponentData
import com.adyen.checkout.components.core.PaymentMethod
import com.adyen.checkout.components.core.internal.ButtonConfiguration
@@ -75,7 +76,7 @@ class CardConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -279,7 +280,7 @@ class CardConfiguration private constructor(
kcpAuthVisibility = kcpAuthVisibility,
installmentConfiguration = installmentConfiguration,
addressConfiguration = addressConfiguration,
- genericActionConfiguration = genericActionConfigurationBuilder.build()
+ genericActionConfiguration = genericActionConfigurationBuilder.build(),
)
}
}
@@ -288,7 +289,25 @@ class CardConfiguration private constructor(
val DEFAULT_SUPPORTED_CARDS_LIST: List = listOf(
CardBrand(cardType = CardType.VISA),
CardBrand(cardType = CardType.AMERICAN_EXPRESS),
- CardBrand(cardType = CardType.MASTERCARD)
+ CardBrand(cardType = CardType.MASTERCARD),
)
}
}
+
+fun CheckoutConfiguration.cardConfiguration(
+ configuration: CardConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = CardConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getCardConfiguration(): CardConfiguration? {
+ return getConfiguration(CardConfiguration::class)
+}
diff --git a/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt b/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt
index 45e04a229b..ce6eff48a2 100644
--- a/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt
+++ b/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt
@@ -13,6 +13,7 @@ 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.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -60,7 +61,7 @@ private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -73,7 +74,7 @@ private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
/**
@@ -158,3 +159,21 @@ private constructor(
)
}
}
+
+fun CheckoutConfiguration.cashAppPayConfiguration(
+ configuration: CashAppPayConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = CashAppPayConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getCashAppPayConfiguration(): CashAppPayConfiguration? {
+ return getConfiguration(CashAppPayConfiguration::class)
+}
diff --git a/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt b/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt
index beecdbd543..dbaf6c0570 100644
--- a/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt
+++ b/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt
@@ -12,6 +12,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.econtext.internal.EContextConfiguration
import kotlinx.parcelize.Parcelize
@@ -47,7 +48,7 @@ class ConvenienceStoresJPConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -76,3 +77,21 @@ class ConvenienceStoresJPConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.convenienceStoresJPConfiguration(
+ configuration: ConvenienceStoresJPConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = ConvenienceStoresJPConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getConvenienceStoresJPConfiguration(): ConvenienceStoresJPConfiguration? {
+ return getConfiguration(ConvenienceStoresJPConfiguration::class)
+}
diff --git a/dotpay/src/main/java/com/adyen/checkout/dotpay/DotpayConfiguration.kt b/dotpay/src/main/java/com/adyen/checkout/dotpay/DotpayConfiguration.kt
index d3ec92724a..d945b67f9d 100644
--- a/dotpay/src/main/java/com/adyen/checkout/dotpay/DotpayConfiguration.kt
+++ b/dotpay/src/main/java/com/adyen/checkout/dotpay/DotpayConfiguration.kt
@@ -11,6 +11,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -49,7 +50,7 @@ class DotpayConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -80,3 +81,21 @@ class DotpayConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.dotpayConfiguration(
+ configuration: DotpayConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = DotpayConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getDotpayConfiguration(): DotpayConfiguration? {
+ return getConfiguration(DotpayConfiguration::class)
+}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
index 677c9c85b3..255a787a21 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
@@ -21,6 +21,7 @@ import com.adyen.checkout.card.CardConfiguration
import com.adyen.checkout.cashapppay.CashAppPayConfiguration
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.conveniencestoresjp.ConvenienceStoresJPConfiguration
@@ -104,7 +105,7 @@ class DropInConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
/**
@@ -117,7 +118,7 @@ class DropInConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -420,3 +421,17 @@ class DropInConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.dropInConfiguration(
+ configuration: Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = Builder(shopperLocale, environment, clientKey)
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getDropInConfiguration(): DropInConfiguration? {
+ return getConfiguration(DropInConfiguration::class)
+}
diff --git a/entercash/src/main/java/com/adyen/checkout/entercash/EntercashConfiguration.kt b/entercash/src/main/java/com/adyen/checkout/entercash/EntercashConfiguration.kt
index 1d76d2f743..44e25adb90 100644
--- a/entercash/src/main/java/com/adyen/checkout/entercash/EntercashConfiguration.kt
+++ b/entercash/src/main/java/com/adyen/checkout/entercash/EntercashConfiguration.kt
@@ -11,6 +11,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -80,3 +81,21 @@ class EntercashConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.entercashConfiguration(
+ configuration: EntercashConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = EntercashConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getEntercashConfiguration(): EntercashConfiguration? {
+ return getConfiguration(EntercashConfiguration::class)
+}
diff --git a/eps/src/main/java/com/adyen/checkout/eps/EPSConfiguration.kt b/eps/src/main/java/com/adyen/checkout/eps/EPSConfiguration.kt
index ef16d489d2..7d94d4348b 100644
--- a/eps/src/main/java/com/adyen/checkout/eps/EPSConfiguration.kt
+++ b/eps/src/main/java/com/adyen/checkout/eps/EPSConfiguration.kt
@@ -11,6 +11,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -49,7 +50,7 @@ class EPSConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -91,3 +92,22 @@ class EPSConfiguration private constructor(
}
}
}
+
+@Suppress("FunctionName")
+fun CheckoutConfiguration.EPSConfiguration(
+ configuration: EPSConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = EPSConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getEPSConfiguration(): EPSConfiguration? {
+ return getConfiguration(EPSConfiguration::class)
+}
diff --git a/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt b/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt
index db8117843b..914fb99c46 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt
@@ -1,30 +1,45 @@
package com.adyen.checkout.example.ui.configuration
import android.content.Context
-import com.adyen.checkout.adyen3ds2.Adyen3DS2Configuration
+import com.adyen.checkout.adyen3ds2.adyen3DS2Configuration
import com.adyen.checkout.bacs.BacsDirectDebitConfiguration
-import com.adyen.checkout.bcmc.BcmcConfiguration
+import com.adyen.checkout.bacs.bacsDirectDebitConfiguration
+import com.adyen.checkout.bacs.getBacsDirectDebitConfiguration
+import com.adyen.checkout.bcmc.bcmcConfiguration
import com.adyen.checkout.blik.BlikConfiguration
+import com.adyen.checkout.blik.blikConfiguration
+import com.adyen.checkout.blik.getBlikConfiguration
import com.adyen.checkout.card.AddressConfiguration
import com.adyen.checkout.card.CardBrand
import com.adyen.checkout.card.CardConfiguration
import com.adyen.checkout.card.CardType
import com.adyen.checkout.card.InstallmentConfiguration
import com.adyen.checkout.card.InstallmentOptions
+import com.adyen.checkout.card.cardConfiguration
+import com.adyen.checkout.card.getCardConfiguration
import com.adyen.checkout.cashapppay.CashAppPayComponent
-import com.adyen.checkout.cashapppay.CashAppPayConfiguration
+import com.adyen.checkout.cashapppay.cashAppPayConfiguration
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.core.Environment
import com.adyen.checkout.dropin.DropInConfiguration
+import com.adyen.checkout.dropin.dropInConfiguration
+import com.adyen.checkout.dropin.getDropInConfiguration
import com.adyen.checkout.example.BuildConfig
import com.adyen.checkout.example.data.storage.CardAddressMode
import com.adyen.checkout.example.data.storage.CardInstallmentOptionsMode
import com.adyen.checkout.example.data.storage.KeyValueStorage
import com.adyen.checkout.giftcard.GiftCardConfiguration
+import com.adyen.checkout.giftcard.getGiftCardConfiguration
+import com.adyen.checkout.giftcard.giftCardConfiguration
import com.adyen.checkout.googlepay.GooglePayConfiguration
+import com.adyen.checkout.googlepay.getGooglePayConfiguration
+import com.adyen.checkout.googlepay.googlePayConfiguration
import com.adyen.checkout.instant.InstantPaymentConfiguration
-import com.adyen.checkout.redirect.RedirectConfiguration
+import com.adyen.checkout.instant.getInstantPaymentConfiguration
+import com.adyen.checkout.instant.instantPaymentConfiguration
+import com.adyen.checkout.redirect.redirectConfiguration
import dagger.hilt.android.qualifiers.ApplicationContext
import java.util.Locale
import javax.inject.Inject
@@ -49,65 +64,72 @@ internal class CheckoutConfigurationProvider @Inject constructor(
private val environment = Environment.TEST
- fun getDropInConfiguration(): DropInConfiguration = DropInConfiguration.Builder(
- shopperLocale,
- environment,
- clientKey,
- )
- .addCardConfiguration(getCardConfiguration())
- .addCashAppPayConfiguration(getCashAppPayConfiguration())
- .addBlikConfiguration(getBlikConfiguration())
- .addBacsDirectDebitConfiguration(getBacsConfiguration())
- .addBcmcConfiguration(getBcmcConfiguration())
- .addGooglePayConfiguration(getGooglePayConfiguration())
- .add3ds2ActionConfiguration(get3DS2Configuration())
- .addRedirectActionConfiguration(getRedirectConfiguration())
- .addGiftCardConfiguration(getGiftCardConfiguration())
- .setEnableRemovingStoredPaymentMethods(true)
- .setAmount(amount)
- .setAnalyticsConfiguration(getAnalyticsConfiguration())
- .build()
-
- fun getCardConfiguration(): CardConfiguration =
- CardConfiguration.Builder(shopperLocale, environment, clientKey)
- .setShopperReference(keyValueStorage.getShopperReference())
- .setAddressConfiguration(getAddressConfiguration())
- .setInstallmentConfigurations(getInstallmentConfiguration())
- .setAmount(amount)
- .setAnalyticsConfiguration(getAnalyticsConfiguration())
- .build()
-
- private fun getCashAppPayConfiguration(): CashAppPayConfiguration =
- CashAppPayConfiguration.Builder(shopperLocale, environment, clientKey)
- .setReturnUrl(CashAppPayComponent.getReturnUrl(context))
- .setAmount(amount)
- .setAnalyticsConfiguration(getAnalyticsConfiguration())
- .build()
-
- fun getBlikConfiguration(): BlikConfiguration =
- BlikConfiguration.Builder(shopperLocale, environment, clientKey)
- .setAmount(amount)
- .setAnalyticsConfiguration(getAnalyticsConfiguration())
- .build()
-
- fun getBacsConfiguration(): BacsDirectDebitConfiguration =
- BacsDirectDebitConfiguration.Builder(shopperLocale, environment, clientKey)
- .setAmount(amount)
- .setAnalyticsConfiguration(getAnalyticsConfiguration())
- .build()
-
- fun getInstantConfiguration(): InstantPaymentConfiguration =
- InstantPaymentConfiguration.Builder(shopperLocale, environment, clientKey)
- .setAmount(amount)
- .setAnalyticsConfiguration(getAnalyticsConfiguration())
- .build()
-
- fun getGiftCardConfiguration(): GiftCardConfiguration =
- GiftCardConfiguration.Builder(shopperLocale, environment, clientKey)
- .setAmount(amount)
- .setAnalyticsConfiguration(getAnalyticsConfiguration())
- .setPinRequired(true)
- .build()
+ private val checkoutConfig = CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = getAnalyticsConfiguration(),
+ ) {
+ // Drop-in
+ dropInConfiguration {
+ setEnableRemovingStoredPaymentMethods(true)
+ }
+
+ // Payment methods
+ bacsDirectDebitConfiguration()
+
+ bcmcConfiguration {
+ setShopperReference(keyValueStorage.getShopperReference())
+ setShowStorePaymentField(true)
+ }
+
+ blikConfiguration()
+
+ cardConfiguration {
+ setShopperReference(keyValueStorage.getShopperReference())
+ setAddressConfiguration(getAddressConfiguration())
+ setInstallmentConfigurations(getInstallmentConfiguration())
+ }
+
+ cashAppPayConfiguration {
+ setReturnUrl(CashAppPayComponent.getReturnUrl(context))
+ }
+
+ giftCardConfiguration {
+ setPinRequired(true)
+ }
+
+ googlePayConfiguration {
+ setCountryCode(keyValueStorage.getCountry())
+ }
+
+ instantPaymentConfiguration()
+
+ // Actions
+ adyen3DS2Configuration()
+
+ redirectConfiguration()
+ }
+
+ private fun getAnalyticsConfiguration(): AnalyticsConfiguration {
+ val analyticsLevel = keyValueStorage.getAnalyticsLevel()
+ return AnalyticsConfiguration(level = analyticsLevel)
+ }
+
+ fun getDropInConfiguration(): DropInConfiguration = checkoutConfig.getDropInConfiguration()!!
+
+ fun getBacsConfiguration(): BacsDirectDebitConfiguration = checkoutConfig.getBacsDirectDebitConfiguration()!!
+
+ fun getBlikConfiguration(): BlikConfiguration = checkoutConfig.getBlikConfiguration()!!
+
+ fun getCardConfiguration(): CardConfiguration = checkoutConfig.getCardConfiguration()!!
+
+ fun getGiftCardConfiguration(): GiftCardConfiguration = checkoutConfig.getGiftCardConfiguration()!!
+
+ fun getGooglePayConfiguration(): GooglePayConfiguration = checkoutConfig.getGooglePayConfiguration()!!
+
+ fun getInstantConfiguration(): InstantPaymentConfiguration = checkoutConfig.getInstantPaymentConfiguration()!!
private fun getAddressConfiguration(): AddressConfiguration = when (keyValueStorage.getCardAddressMode()) {
CardAddressMode.NONE -> AddressConfiguration.None
@@ -116,43 +138,11 @@ internal class CheckoutConfigurationProvider @Inject constructor(
defaultCountryCode = null,
supportedCountryCodes = listOf("NL", "GB", "US", "CA", "BR"),
addressFieldPolicy = AddressConfiguration.CardAddressFieldPolicy.OptionalForCardTypes(
- brands = listOf("jcb")
- )
+ brands = listOf("jcb"),
+ ),
)
}
- private fun getBcmcConfiguration(): BcmcConfiguration =
- BcmcConfiguration.Builder(shopperLocale, environment, clientKey)
- .setShopperReference(keyValueStorage.getShopperReference())
- .setShowStorePaymentField(true)
- .setAmount(amount)
- .setAnalyticsConfiguration(getAnalyticsConfiguration())
- .build()
-
- fun getGooglePayConfiguration(): GooglePayConfiguration =
- GooglePayConfiguration.Builder(shopperLocale, environment, clientKey)
- .setCountryCode(keyValueStorage.getCountry())
- .setAmount(amount)
- .setAnalyticsConfiguration(getAnalyticsConfiguration())
- .build()
-
- private fun get3DS2Configuration(): Adyen3DS2Configuration =
- Adyen3DS2Configuration.Builder(shopperLocale, environment, clientKey)
- .setAmount(amount)
- .setAnalyticsConfiguration(getAnalyticsConfiguration())
- .build()
-
- private fun getRedirectConfiguration(): RedirectConfiguration =
- RedirectConfiguration.Builder(shopperLocale, environment, clientKey)
- .setAmount(amount)
- .setAnalyticsConfiguration(getAnalyticsConfiguration())
- .build()
-
- private fun getAnalyticsConfiguration(): AnalyticsConfiguration {
- val analyticsLevel = keyValueStorage.getAnalyticsLevel()
- return AnalyticsConfiguration(level = analyticsLevel)
- }
-
private fun getInstallmentConfiguration(): InstallmentConfiguration =
when (keyValueStorage.getInstallmentOptionsMode()) {
CardInstallmentOptionsMode.NONE -> InstallmentConfiguration()
@@ -167,9 +157,9 @@ internal class CheckoutConfigurationProvider @Inject constructor(
) = InstallmentConfiguration(
defaultOptions = InstallmentOptions.DefaultInstallmentOptions(
maxInstallments = maxInstallments,
- includeRevolving = includeRevolving
+ includeRevolving = includeRevolving,
),
- showInstallmentAmount = keyValueStorage.isInstallmentAmountShown()
+ showInstallmentAmount = keyValueStorage.isInstallmentAmountShown(),
)
private fun getCardBasedInstallmentOptions(
@@ -181,9 +171,9 @@ internal class CheckoutConfigurationProvider @Inject constructor(
InstallmentOptions.CardBasedInstallmentOptions(
maxInstallments = maxInstallments,
includeRevolving = includeRevolving,
- cardBrand = cardBrand
- )
+ cardBrand = cardBrand,
+ ),
),
- showInstallmentAmount = keyValueStorage.isInstallmentAmountShown()
+ showInstallmentAmount = keyValueStorage.isInstallmentAmountShown(),
)
}
diff --git a/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt b/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt
index f8dceb1f37..55d0425bf2 100644
--- a/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt
+++ b/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt
@@ -12,6 +12,7 @@ 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.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -110,3 +111,21 @@ class GiftCardConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.giftCardConfiguration(
+ configuration: GiftCardConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = GiftCardConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getGiftCardConfiguration(): GiftCardConfiguration? {
+ return getConfiguration(GiftCardConfiguration::class)
+}
diff --git a/googlepay/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.kt b/googlepay/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.kt
index 7bd14475f9..c8772b3548 100644
--- a/googlepay/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.kt
+++ b/googlepay/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.kt
@@ -14,6 +14,7 @@ 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.PaymentMethod
import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.core.Environment
@@ -85,7 +86,7 @@ class GooglePayConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -127,7 +128,7 @@ class GooglePayConfiguration private constructor(
if (!isGooglePayEnvironmentValid(googlePayEnvironment)) {
throw CheckoutException(
"Invalid value for Google Environment. Use either WalletConstants.ENVIRONMENT_TEST or" +
- " WalletConstants.ENVIRONMENT_PRODUCTION"
+ " WalletConstants.ENVIRONMENT_PRODUCTION",
)
}
this.googlePayEnvironment = googlePayEnvironment
@@ -383,3 +384,21 @@ class GooglePayConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.googlePayConfiguration(
+ configuration: GooglePayConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = GooglePayConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getGooglePayConfiguration(): GooglePayConfiguration? {
+ return getConfiguration(GooglePayConfiguration::class)
+}
diff --git a/ideal/src/main/java/com/adyen/checkout/ideal/IdealConfiguration.kt b/ideal/src/main/java/com/adyen/checkout/ideal/IdealConfiguration.kt
index c1c4255242..412a061335 100644
--- a/ideal/src/main/java/com/adyen/checkout/ideal/IdealConfiguration.kt
+++ b/ideal/src/main/java/com/adyen/checkout/ideal/IdealConfiguration.kt
@@ -11,6 +11,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -49,7 +50,7 @@ class IdealConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -80,3 +81,21 @@ class IdealConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.idealConfiguration(
+ configuration: IdealConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = IdealConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getIdealConfiguration(): IdealConfiguration? {
+ return getConfiguration(IdealConfiguration::class)
+}
diff --git a/instant/src/main/java/com/adyen/checkout/instant/InstantPaymentConfiguration.kt b/instant/src/main/java/com/adyen/checkout/instant/InstantPaymentConfiguration.kt
index fda228e79d..ec32797baa 100644
--- a/instant/src/main/java/com/adyen/checkout/instant/InstantPaymentConfiguration.kt
+++ b/instant/src/main/java/com/adyen/checkout/instant/InstantPaymentConfiguration.kt
@@ -13,6 +13,7 @@ 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.internal.Configuration
import com.adyen.checkout.core.Environment
import kotlinx.parcelize.Parcelize
@@ -74,3 +75,21 @@ class InstantPaymentConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.instantPaymentConfiguration(
+ configuration: InstantPaymentConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = InstantPaymentConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getInstantPaymentConfiguration(): InstantPaymentConfiguration? {
+ return getConfiguration(InstantPaymentConfiguration::class)
+}
diff --git a/mbway/src/main/java/com/adyen/checkout/mbway/MBWayConfiguration.kt b/mbway/src/main/java/com/adyen/checkout/mbway/MBWayConfiguration.kt
index 44a9eb4743..5e982381f0 100644
--- a/mbway/src/main/java/com/adyen/checkout/mbway/MBWayConfiguration.kt
+++ b/mbway/src/main/java/com/adyen/checkout/mbway/MBWayConfiguration.kt
@@ -12,6 +12,7 @@ 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.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -53,7 +54,7 @@ class MBWayConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -66,7 +67,7 @@ class MBWayConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
/**
@@ -94,3 +95,22 @@ class MBWayConfiguration private constructor(
}
}
}
+
+@Suppress("FunctionName")
+fun CheckoutConfiguration.MBWayConfiguration(
+ configuration: MBWayConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = MBWayConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getMBWayConfiguration(): MBWayConfiguration? {
+ return getConfiguration(MBWayConfiguration::class)
+}
diff --git a/molpay/src/main/java/com/adyen/checkout/molpay/MolpayConfiguration.kt b/molpay/src/main/java/com/adyen/checkout/molpay/MolpayConfiguration.kt
index f619b836ac..7a855acb24 100644
--- a/molpay/src/main/java/com/adyen/checkout/molpay/MolpayConfiguration.kt
+++ b/molpay/src/main/java/com/adyen/checkout/molpay/MolpayConfiguration.kt
@@ -11,6 +11,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -49,7 +50,7 @@ class MolpayConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -80,3 +81,21 @@ class MolpayConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.molpayConfiguration(
+ configuration: MolpayConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = MolpayConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getMolpayConfiguration(): MolpayConfiguration? {
+ return getConfiguration(MolpayConfiguration::class)
+}
diff --git a/online-banking-cz/src/main/java/com/adyen/checkout/onlinebankingcz/OnlineBankingCZConfiguration.kt b/online-banking-cz/src/main/java/com/adyen/checkout/onlinebankingcz/OnlineBankingCZConfiguration.kt
index 505bcc827a..029282055e 100644
--- a/online-banking-cz/src/main/java/com/adyen/checkout/onlinebankingcz/OnlineBankingCZConfiguration.kt
+++ b/online-banking-cz/src/main/java/com/adyen/checkout/onlinebankingcz/OnlineBankingCZConfiguration.kt
@@ -12,6 +12,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.onlinebankingcore.internal.OnlineBankingConfiguration
import kotlinx.parcelize.Parcelize
@@ -47,7 +48,7 @@ class OnlineBankingCZConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -76,3 +77,21 @@ class OnlineBankingCZConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.onlineBankingCZConfiguration(
+ configuration: OnlineBankingCZConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = OnlineBankingCZConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getOnlineBankingCZConfiguration(): OnlineBankingCZConfiguration? {
+ return getConfiguration(OnlineBankingCZConfiguration::class)
+}
diff --git a/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt b/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt
index b66f701e0d..be87e43279 100644
--- a/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt
+++ b/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt
@@ -12,6 +12,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.econtext.internal.EContextConfiguration
import kotlinx.parcelize.Parcelize
@@ -76,3 +77,21 @@ class OnlineBankingJPConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.onlineBankingJPConfiguration(
+ configuration: OnlineBankingJPConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = OnlineBankingJPConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getOnlineBankingJPConfiguration(): OnlineBankingJPConfiguration? {
+ return getConfiguration(OnlineBankingJPConfiguration::class)
+}
diff --git a/online-banking-pl/src/main/java/com/adyen/checkout/onlinebankingpl/OnlineBankingPLConfiguration.kt b/online-banking-pl/src/main/java/com/adyen/checkout/onlinebankingpl/OnlineBankingPLConfiguration.kt
index 0098beee93..e0a6a05229 100644
--- a/online-banking-pl/src/main/java/com/adyen/checkout/onlinebankingpl/OnlineBankingPLConfiguration.kt
+++ b/online-banking-pl/src/main/java/com/adyen/checkout/onlinebankingpl/OnlineBankingPLConfiguration.kt
@@ -12,6 +12,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -50,7 +51,7 @@ class OnlineBankingPLConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -81,3 +82,21 @@ class OnlineBankingPLConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.onlineBankingPLConfiguration(
+ configuration: OnlineBankingPLConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = OnlineBankingPLConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getOnlineBankingPLConfiguration(): OnlineBankingPLConfiguration? {
+ return getConfiguration(OnlineBankingPLConfiguration::class)
+}
diff --git a/online-banking-sk/src/main/java/com/adyen/checkout/onlinebankingsk/OnlineBankingSKConfiguration.kt b/online-banking-sk/src/main/java/com/adyen/checkout/onlinebankingsk/OnlineBankingSKConfiguration.kt
index 909f622c41..14e774d463 100644
--- a/online-banking-sk/src/main/java/com/adyen/checkout/onlinebankingsk/OnlineBankingSKConfiguration.kt
+++ b/online-banking-sk/src/main/java/com/adyen/checkout/onlinebankingsk/OnlineBankingSKConfiguration.kt
@@ -12,6 +12,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.onlinebankingcore.internal.OnlineBankingConfiguration
import kotlinx.parcelize.Parcelize
@@ -47,7 +48,7 @@ class OnlineBankingSKConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -76,3 +77,21 @@ class OnlineBankingSKConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.onlineBankingSKConfiguration(
+ configuration: OnlineBankingSKConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = OnlineBankingSKConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getOnlineBankingSKConfiguration(): OnlineBankingSKConfiguration? {
+ return getConfiguration(OnlineBankingSKConfiguration::class)
+}
diff --git a/openbanking/src/main/java/com/adyen/checkout/openbanking/OpenBankingConfiguration.kt b/openbanking/src/main/java/com/adyen/checkout/openbanking/OpenBankingConfiguration.kt
index 8aa1f2338b..bb292be87e 100644
--- a/openbanking/src/main/java/com/adyen/checkout/openbanking/OpenBankingConfiguration.kt
+++ b/openbanking/src/main/java/com/adyen/checkout/openbanking/OpenBankingConfiguration.kt
@@ -11,6 +11,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -49,7 +50,7 @@ class OpenBankingConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -80,3 +81,21 @@ class OpenBankingConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.openBankingConfiguration(
+ configuration: OpenBankingConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = OpenBankingConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getOpenBankingConfiguration(): OpenBankingConfiguration? {
+ return getConfiguration(OpenBankingConfiguration::class)
+}
diff --git a/paybybank/src/main/java/com/adyen/checkout/paybybank/PayByBankConfiguration.kt b/paybybank/src/main/java/com/adyen/checkout/paybybank/PayByBankConfiguration.kt
index 45605fe515..2eb6af6235 100644
--- a/paybybank/src/main/java/com/adyen/checkout/paybybank/PayByBankConfiguration.kt
+++ b/paybybank/src/main/java/com/adyen/checkout/paybybank/PayByBankConfiguration.kt
@@ -13,6 +13,7 @@ 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.internal.Configuration
import com.adyen.checkout.core.Environment
import kotlinx.parcelize.Parcelize
@@ -45,7 +46,7 @@ class PayByBankConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -73,3 +74,21 @@ class PayByBankConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.payByBankConfiguration(
+ configuration: PayByBankConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = PayByBankConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getPayByBankConfiguration(): PayByBankConfiguration? {
+ return getConfiguration(PayByBankConfiguration::class)
+}
diff --git a/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt b/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt
index 6be74bf957..81ffa09b90 100644
--- a/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt
+++ b/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt
@@ -12,6 +12,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.econtext.internal.EContextConfiguration
import kotlinx.parcelize.Parcelize
@@ -76,3 +77,21 @@ class PayEasyConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.payEasyConfiguration(
+ configuration: PayEasyConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = PayEasyConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getPayEasyConfiguration(): PayEasyConfiguration? {
+ return getConfiguration(PayEasyConfiguration::class)
+}
diff --git a/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt b/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt
index 7648eb2ba1..2326712479 100644
--- a/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt
+++ b/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt
@@ -10,6 +10,7 @@ package com.adyen.checkout.qrcode
import android.content.Context
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.internal.BaseConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.core.Environment
@@ -43,7 +44,7 @@ class QRCodeConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -56,7 +57,7 @@ class QRCodeConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
override fun buildInternal(): QRCodeConfiguration {
@@ -70,3 +71,22 @@ class QRCodeConfiguration private constructor(
}
}
}
+
+@Suppress("FunctionName")
+fun CheckoutConfiguration.QRCodeConfiguration(
+ configuration: QRCodeConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = QRCodeConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getQRCodeConfiguration(): QRCodeConfiguration? {
+ return getConfiguration(QRCodeConfiguration::class)
+}
diff --git a/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt b/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt
index 342e85017c..94cbaa2b0d 100644
--- a/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt
+++ b/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt
@@ -10,6 +10,7 @@ package com.adyen.checkout.redirect
import android.content.Context
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.internal.BaseConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.core.Environment
@@ -70,3 +71,21 @@ class RedirectConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.redirectConfiguration(
+ configuration: RedirectConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = RedirectConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getRedirectConfiguration(): RedirectConfiguration? {
+ return getConfiguration(RedirectConfiguration::class)
+}
diff --git a/sepa/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.kt b/sepa/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.kt
index 7970b63ab7..92c79ea61e 100644
--- a/sepa/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.kt
+++ b/sepa/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.kt
@@ -12,6 +12,7 @@ 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.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -53,7 +54,7 @@ class SepaConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -94,3 +95,21 @@ class SepaConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.sepaConfiguration(
+ configuration: SepaConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = SepaConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getSepaConfiguration(): SepaConfiguration? {
+ return getConfiguration(SepaConfiguration::class)
+}
diff --git a/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt b/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt
index 1eead288db..af3b8ee8a6 100644
--- a/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt
+++ b/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt
@@ -12,6 +12,7 @@ import android.content.Context
import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.econtext.internal.EContextConfiguration
import kotlinx.parcelize.Parcelize
@@ -47,7 +48,7 @@ class SevenElevenConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -76,3 +77,21 @@ class SevenElevenConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.sevenElevenConfiguration(
+ configuration: SevenElevenConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = SevenElevenConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getSevenElevenConfiguration(): SevenElevenConfiguration? {
+ return getConfiguration(SevenElevenConfiguration::class)
+}
diff --git a/upi/src/main/java/com/adyen/checkout/upi/UPIConfiguration.kt b/upi/src/main/java/com/adyen/checkout/upi/UPIConfiguration.kt
index 90cd643d9b..7854dc62d9 100644
--- a/upi/src/main/java/com/adyen/checkout/upi/UPIConfiguration.kt
+++ b/upi/src/main/java/com/adyen/checkout/upi/UPIConfiguration.kt
@@ -13,6 +13,7 @@ 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.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -54,7 +55,7 @@ class UPIConfiguration(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -67,7 +68,7 @@ class UPIConfiguration(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
/**
@@ -93,3 +94,22 @@ class UPIConfiguration(
)
}
}
+
+@Suppress("FunctionName")
+fun CheckoutConfiguration.UPIConfiguration(
+ configuration: UPIConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = UPIConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getUPIConfiguration(): UPIConfiguration? {
+ return getConfiguration(UPIConfiguration::class)
+}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt b/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt
index 6488c45999..29461cee46 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt
@@ -11,6 +11,7 @@ package com.adyen.checkout.voucher
import android.content.Context
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.internal.BaseConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.core.Environment
@@ -44,7 +45,7 @@ class VoucherConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -57,7 +58,7 @@ class VoucherConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
override fun buildInternal(): VoucherConfiguration {
@@ -71,3 +72,21 @@ class VoucherConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.voucherConfiguration(
+ configuration: VoucherConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = VoucherConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getVoucherConfiguration(): VoucherConfiguration? {
+ return getConfiguration(VoucherConfiguration::class)
+}
diff --git a/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt b/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt
index 60fcfc3681..cb238ae269 100644
--- a/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt
+++ b/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt
@@ -10,6 +10,7 @@ package com.adyen.checkout.wechatpay
import android.content.Context
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.internal.BaseConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.core.Environment
@@ -43,7 +44,7 @@ class WeChatPayActionConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -70,3 +71,21 @@ class WeChatPayActionConfiguration private constructor(
}
}
}
+
+fun CheckoutConfiguration.weChatPayActionConfiguration(
+ configuration: WeChatPayActionConfiguration.Builder.() -> Unit = {}
+): CheckoutConfiguration {
+ val config = WeChatPayActionConfiguration.Builder(shopperLocale, environment, clientKey)
+ .apply {
+ amount?.let { setAmount(it) }
+ analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
+ }
+ .apply(configuration)
+ .build()
+ addConfiguration(config)
+ return this
+}
+
+fun CheckoutConfiguration.getWeChatPayActionConfiguration(): WeChatPayActionConfiguration? {
+ return getConfiguration(WeChatPayActionConfiguration::class)
+}
From 682d6b4811c65211c262d406f4c9d049f1a04db1 Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Fri, 8 Dec 2023 13:54:19 +0100
Subject: [PATCH 040/255] Make drop-in accept CheckoutConfiguration
COAND-811
---
.../action/core/GenericActionConfiguration.kt | 7 +-
.../components/core/CheckoutConfiguration.kt | 70 +++++++++++--
.../java/com/adyen/checkout/dropin/DropIn.kt | 47 +++++++--
.../checkout/dropin/DropInConfiguration.kt | 20 ++++
.../checkout/dropin/DropInResultContract.kt | 2 +-
.../dropin/SessionDropInResultContract.kt | 7 +-
.../dropin/internal/ui/DropInActivity.kt | 18 ++--
.../ui/DropInSavedStateHandleContainer.kt | 20 ++--
.../dropin/internal/ui/DropInViewModel.kt | 31 +++---
.../internal/ui/DropInViewModelFactory.kt | 19 ++--
.../ui/model/DropInResultContractParams.kt | 4 +-
.../SessionDropInResultContractParams.kt | 4 +-
.../CheckoutConfigurationProvider.kt | 97 +++++++++----------
.../checkout/example/ui/main/MainActivity.kt | 6 +-
.../example/ui/main/MainNavigation.kt | 8 +-
.../checkout/example/ui/main/MainViewModel.kt | 22 ++---
16 files changed, 249 insertions(+), 133 deletions(-)
diff --git a/action-core/src/main/java/com/adyen/checkout/action/core/GenericActionConfiguration.kt b/action-core/src/main/java/com/adyen/checkout/action/core/GenericActionConfiguration.kt
index 069a8a87c8..b9d1832f62 100644
--- a/action-core/src/main/java/com/adyen/checkout/action/core/GenericActionConfiguration.kt
+++ b/action-core/src/main/java/com/adyen/checkout/action/core/GenericActionConfiguration.kt
@@ -53,6 +53,9 @@ class GenericActionConfiguration private constructor(
return null
}
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ fun getAllConfigurations(): List = availableActionConfigs.values.toList()
+
/**
* Builder for creating a [GenericActionConfiguration] where you can set specific Configurations for each action
* component.
@@ -75,7 +78,7 @@ class GenericActionConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -88,7 +91,7 @@ class GenericActionConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
/**
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt b/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
index e6dc760711..a9b49a43d7 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
@@ -8,34 +8,84 @@
package com.adyen.checkout.components.core
+import android.annotation.SuppressLint
+import android.os.Parcel
+import android.os.Parcelable
+import android.os.Parcelable.CONTENTS_FILE_DESCRIPTOR
import androidx.annotation.RestrictTo
import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.core.Environment
+import kotlinx.parcelize.IgnoredOnParcel
import java.util.Locale
import kotlin.reflect.KClass
class CheckoutConfiguration(
- val shopperLocale: Locale,
- val environment: Environment,
- val clientKey: String,
- val amount: Amount? = null,
- val analyticsConfiguration: AnalyticsConfiguration? = null,
- config: CheckoutConfiguration.() -> Unit = {},
-) {
+ override val shopperLocale: Locale,
+ override val environment: Environment,
+ override val clientKey: String,
+ override val amount: Amount? = null,
+ override val analyticsConfiguration: AnalyticsConfiguration? = null,
+ @IgnoredOnParcel
+ private val config: CheckoutConfiguration.() -> Unit = {},
+) : Configuration {
+
+ private val availableConfigurations = mutableMapOf, Configuration>()
init {
this.apply(config)
}
- private val availablePaymentConfigs = mutableMapOf, Configuration>()
+ @SuppressLint("ParcelClassLoader")
+ @Suppress("UNCHECKED_CAST")
+ private constructor(parcel: Parcel) : this(
+ shopperLocale = parcel.readSerializable() as Locale,
+ environment = parcel.readParcelable(Environment::class.java.classLoader)!!,
+ clientKey = parcel.readString()!!,
+ amount = parcel.readParcelable(Amount::class.java.classLoader),
+ analyticsConfiguration = parcel.readParcelable(Amount::class.java.classLoader),
+ ) {
+ val size = parcel.readInt()
+
+ for (i in 0 until size) {
+ val clazz = parcel.readSerializable() as Class
+ val config = parcel.readParcelable(clazz.classLoader)!!
+ availableConfigurations[config::class] = config
+ }
+ }
fun addConfiguration(configuration: Configuration) {
- availablePaymentConfigs[configuration::class] = configuration
+ availableConfigurations[configuration::class] = configuration
}
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun getConfiguration(configKlass: KClass): T? {
@Suppress("UNCHECKED_CAST")
- return availablePaymentConfigs[configKlass] as? T
+ return availableConfigurations[configKlass] as? T
+ }
+
+ override fun writeToParcel(dest: Parcel, flags: Int) {
+ dest.writeSerializable(shopperLocale)
+ dest.writeParcelable(environment, flags)
+ dest.writeString(clientKey)
+ dest.writeParcelable(amount, flags)
+ dest.writeParcelable(analyticsConfiguration, flags)
+ dest.writeInt(availableConfigurations.size)
+ availableConfigurations.forEach {
+ dest.writeSerializable(it.key.java)
+ dest.writeParcelable(it.value, flags)
+ }
+ }
+
+ override fun describeContents(): Int = CONTENTS_FILE_DESCRIPTOR
+
+ companion object CREATOR : Parcelable.Creator {
+
+ override fun createFromParcel(source: Parcel): CheckoutConfiguration {
+ return CheckoutConfiguration(source)
+ }
+
+ override fun newArray(size: Int): Array {
+ return arrayOfNulls(size)
+ }
}
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/DropIn.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/DropIn.kt
index a09b4b4aae..73731f0bba 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/DropIn.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/DropIn.kt
@@ -11,6 +11,7 @@ package com.adyen.checkout.dropin
import android.content.Context
import androidx.activity.result.ActivityResultCaller
import androidx.activity.result.ActivityResultLauncher
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethodsApiResponse
import com.adyen.checkout.core.internal.util.BuildUtils
import com.adyen.checkout.core.internal.util.LogUtil
@@ -91,14 +92,31 @@ object DropIn {
checkoutSession: CheckoutSession,
dropInConfiguration: DropInConfiguration,
serviceClass: Class = SessionDropInService::class.java,
+ ) {
+ startPayment(
+ context = context,
+ dropInLauncher = dropInLauncher,
+ checkoutSession = checkoutSession,
+ checkoutConfiguration = dropInConfiguration.toCheckoutConfiguration(),
+ serviceClass = serviceClass,
+ )
+ }
+
+ @JvmStatic
+ fun startPayment(
+ context: Context,
+ dropInLauncher: ActivityResultLauncher,
+ checkoutSession: CheckoutSession,
+ checkoutConfiguration: CheckoutConfiguration,
+ serviceClass: Class = SessionDropInService::class.java,
) {
Logger.d(TAG, "startPayment with sessions")
val sessionDropInResultContractParams = SessionDropInResultContractParams(
- dropInConfiguration,
+ checkoutConfiguration,
checkoutSession,
serviceClass,
)
- startPayment(context, dropInLauncher, dropInConfiguration, sessionDropInResultContractParams)
+ startPayment(context, dropInLauncher, checkoutConfiguration, sessionDropInResultContractParams)
}
/**
@@ -149,24 +167,41 @@ object DropIn {
paymentMethodsApiResponse: PaymentMethodsApiResponse,
dropInConfiguration: DropInConfiguration,
serviceClass: Class,
+ ) {
+ startPayment(
+ context = context,
+ dropInLauncher = dropInLauncher,
+ paymentMethodsApiResponse = paymentMethodsApiResponse,
+ checkoutConfiguration = dropInConfiguration.toCheckoutConfiguration(),
+ serviceClass = serviceClass,
+ )
+ }
+
+ @JvmStatic
+ fun startPayment(
+ context: Context,
+ dropInLauncher: ActivityResultLauncher,
+ paymentMethodsApiResponse: PaymentMethodsApiResponse,
+ checkoutConfiguration: CheckoutConfiguration,
+ serviceClass: Class,
) {
Logger.d(TAG, "startPayment with payment methods")
val dropInResultContractParams = DropInResultContractParams(
- dropInConfiguration,
+ checkoutConfiguration,
paymentMethodsApiResponse,
serviceClass,
)
- startPayment(context, dropInLauncher, dropInConfiguration, dropInResultContractParams)
+ startPayment(context, dropInLauncher, checkoutConfiguration, dropInResultContractParams)
}
private fun startPayment(
context: Context,
dropInLauncher: ActivityResultLauncher,
- dropInConfiguration: DropInConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
params: T,
) {
updateDefaultLogLevel(context)
- DropInPrefs.setShopperLocale(context, dropInConfiguration.shopperLocale)
+ DropInPrefs.setShopperLocale(context, checkoutConfiguration.shopperLocale)
dropInLauncher.launch(params)
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
index 255a787a21..4b2f5a01de 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
@@ -80,6 +80,26 @@ class DropInConfiguration private constructor(
return null
}
+ internal fun toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addConfiguration(this@DropInConfiguration)
+
+ availablePaymentConfigs.values.forEach { paymentConfig ->
+ addConfiguration(paymentConfig)
+ }
+
+ genericActionConfiguration.getAllConfigurations().forEach { actionConfig ->
+ addConfiguration(actionConfig)
+ }
+ }
+ }
+
/**
* Builder for creating a [DropInConfiguration] where you can set specific Configurations for a Payment Method
*/
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInResultContract.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInResultContract.kt
index 297f7bed8e..6163f1655c 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInResultContract.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInResultContract.kt
@@ -20,7 +20,7 @@ class DropInResultContract : ActivityResultContract {
SessionDropInResult.Finished(requireNotNull(data.getParcelableExtra(DropIn.SESSION_RESULT_KEY)))
}
+
resultCode == Activity.RESULT_OK && data.hasExtra(DropIn.RESULT_KEY) -> {
val result = data.getStringExtra(DropIn.RESULT_KEY)
SessionDropInResult.Finished(
@@ -55,9 +57,10 @@ class SessionDropInResultContract :
sessionData = null,
resultCode = result,
order = null,
- )
+ ),
)
}
+
else -> null
}
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt
index b4ac5e4857..bee8a035a6 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt
@@ -25,6 +25,7 @@ import androidx.lifecycle.repeatOnLifecycle
import com.adyen.checkout.card.BinLookupData
import com.adyen.checkout.components.core.ActionComponentData
import com.adyen.checkout.components.core.BalanceResult
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.OrderRequest
import com.adyen.checkout.components.core.OrderResponse
import com.adyen.checkout.components.core.PaymentComponentState
@@ -38,7 +39,6 @@ import com.adyen.checkout.core.internal.util.Logger
import com.adyen.checkout.dropin.BalanceDropInServiceResult
import com.adyen.checkout.dropin.BaseDropInServiceResult
import com.adyen.checkout.dropin.DropIn
-import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.dropin.DropInServiceResult
import com.adyen.checkout.dropin.DropInServiceResultError
import com.adyen.checkout.dropin.OrderDropInServiceResult
@@ -224,7 +224,7 @@ internal class DropInActivity :
Logger.e(
TAG,
"Error binding to ${dropInViewModel.serviceComponentName.className}. " +
- "The system couldn't find the service or your client doesn't have permission to bind to it"
+ "The system couldn't find the service or your client doesn't have permission to bind to it",
)
}
}
@@ -403,7 +403,7 @@ internal class DropInActivity :
is DropInServiceResult.Update -> handlePaymentMethodsUpdate(dropInServiceResult)
is DropInServiceResult.Error -> handleErrorDropInServiceResult(dropInServiceResult)
is DropInServiceResult.ToPaymentMethodsList -> dropInViewModel.onToPaymentMethodsList(
- dropInServiceResult.paymentMethodsApiResponse
+ dropInServiceResult.paymentMethodsApiResponse,
)
}
}
@@ -480,7 +480,7 @@ internal class DropInActivity :
private fun handlePaymentMethodsUpdate(dropInServiceResult: DropInServiceResult.Update) {
dropInViewModel.handlePaymentMethodsUpdate(
dropInServiceResult.paymentMethodsApiResponse,
- dropInServiceResult.order
+ dropInServiceResult.order,
)
}
@@ -624,7 +624,7 @@ internal class DropInActivity :
dialogTitle = null,
errorMessage = getString(result.errorMessage),
reason = result.reason,
- terminate = result.terminateDropIn
+ terminate = result.terminateDropIn,
)
is GiftCardBalanceResult.FullPayment -> handleGiftCardFullPayment(result)
@@ -714,14 +714,14 @@ internal class DropInActivity :
fun createIntent(
context: Context,
- dropInConfiguration: DropInConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
paymentMethodsApiResponse: PaymentMethodsApiResponse,
service: ComponentName,
): Intent {
val intent = Intent(context, DropInActivity::class.java)
DropInBundleHandler.putIntentExtras(
intent = intent,
- dropInConfiguration = dropInConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
paymentMethodsApiResponse = paymentMethodsApiResponse,
service = service,
)
@@ -730,14 +730,14 @@ internal class DropInActivity :
fun createIntent(
context: Context,
- dropInConfiguration: DropInConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
checkoutSession: CheckoutSession,
service: ComponentName,
): Intent {
val intent = Intent(context, DropInActivity::class.java)
DropInBundleHandler.putIntentExtras(
intent = intent,
- dropInConfiguration = dropInConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
checkoutSession = checkoutSession,
service = service,
)
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInSavedStateHandleContainer.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInSavedStateHandleContainer.kt
index 6dea75420e..822e165cf5 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInSavedStateHandleContainer.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInSavedStateHandleContainer.kt
@@ -13,12 +13,12 @@ import android.content.Intent
import android.os.Bundle
import androidx.lifecycle.SavedStateHandle
import com.adyen.checkout.components.core.Amount
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethodsApiResponse
import com.adyen.checkout.components.core.internal.SavedStateHandleContainer
import com.adyen.checkout.components.core.internal.SavedStateHandleProperty
import com.adyen.checkout.core.internal.util.LogUtil
import com.adyen.checkout.core.internal.util.Logger
-import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.dropin.internal.ui.model.OrderModel
import com.adyen.checkout.giftcard.GiftCardComponentState
import com.adyen.checkout.sessions.core.CheckoutSession
@@ -29,7 +29,7 @@ internal class DropInSavedStateHandleContainer(
override val savedStateHandle: SavedStateHandle,
) : SavedStateHandleContainer {
- var dropInConfiguration: DropInConfiguration? by SavedStateHandleProperty(DROP_IN_CONFIGURATION_KEY)
+ var checkoutConfiguration: CheckoutConfiguration? by SavedStateHandleProperty(CHECKOUT_CONFIGURATION_KEY)
var serviceComponentName: ComponentName? by SavedStateHandleProperty(DROP_IN_SERVICE_KEY)
var amount: Amount? by SavedStateHandleProperty(AMOUNT)
var sessionDetails: SessionDetails? by SavedStateHandleProperty(SESSION_KEY)
@@ -46,27 +46,27 @@ internal object DropInBundleHandler {
fun putIntentExtras(
intent: Intent,
- dropInConfiguration: DropInConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
paymentMethodsApiResponse: PaymentMethodsApiResponse,
service: ComponentName,
) {
intent.apply {
putExtra(PAYMENT_METHODS_RESPONSE_KEY, paymentMethodsApiResponse)
- putExtra(DROP_IN_CONFIGURATION_KEY, dropInConfiguration)
+ putExtra(CHECKOUT_CONFIGURATION_KEY, checkoutConfiguration)
putExtra(DROP_IN_SERVICE_KEY, service)
- putExtra(AMOUNT, dropInConfiguration.amount)
+ putExtra(AMOUNT, checkoutConfiguration.amount)
}
}
fun putIntentExtras(
intent: Intent,
- dropInConfiguration: DropInConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
checkoutSession: CheckoutSession,
service: ComponentName,
) {
putIntentExtras(
intent,
- dropInConfiguration,
+ checkoutConfiguration,
checkoutSession.sessionSetupResponse.paymentMethodsApiResponse ?: PaymentMethodsApiResponse(),
service,
)
@@ -82,10 +82,12 @@ internal object DropInBundleHandler {
Logger.e(TAG, "Failed to initialize - bundle is null")
false
}
- !bundle.containsKey(DROP_IN_SERVICE_KEY) || !bundle.containsKey(DROP_IN_CONFIGURATION_KEY) -> {
+
+ !bundle.containsKey(DROP_IN_SERVICE_KEY) || !bundle.containsKey(CHECKOUT_CONFIGURATION_KEY) -> {
Logger.e(TAG, "Failed to initialize - bundle does not have the required keys")
false
}
+
else -> true
}
}
@@ -94,7 +96,7 @@ internal object DropInBundleHandler {
private const val PAYMENT_METHODS_RESPONSE_KEY = "PAYMENT_METHODS_RESPONSE_KEY"
private const val SESSION_KEY = "SESSION_KEY"
private const val IS_SESSIONS_FLOW_TAKEN_OVER_KEY = "IS_SESSIONS_FLOW_TAKEN_OVER_KEY"
-private const val DROP_IN_CONFIGURATION_KEY = "DROP_IN_CONFIGURATION_KEY"
+private const val CHECKOUT_CONFIGURATION_KEY = "CHECKOUT_CONFIGURATION_KEY"
private const val DROP_IN_SERVICE_KEY = "DROP_IN_SERVICE_KEY"
private const val IS_WAITING_FOR_RESULT_KEY = "IS_WAITING_FOR_RESULT_KEY"
private const val CACHED_GIFT_CARD = "CACHED_GIFT_CARD"
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt
index 78324ac66c..e33e61c53b 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt
@@ -13,6 +13,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.adyen.checkout.components.core.Amount
import com.adyen.checkout.components.core.BalanceResult
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.OrderRequest
import com.adyen.checkout.components.core.OrderResponse
import com.adyen.checkout.components.core.PaymentComponentData
@@ -24,13 +25,13 @@ import com.adyen.checkout.components.core.StoredPaymentMethod
import com.adyen.checkout.components.core.internal.data.api.AnalyticsRepository
import com.adyen.checkout.components.core.internal.data.api.OrderStatusRepository
import com.adyen.checkout.components.core.internal.util.bufferedChannel
-import com.adyen.checkout.components.core.internal.util.isEmpty
import com.adyen.checkout.components.core.paymentmethod.GiftCardPaymentMethod
import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.internal.util.LogUtil
import com.adyen.checkout.core.internal.util.Logger
import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.dropin.R
+import com.adyen.checkout.dropin.getDropInConfiguration
import com.adyen.checkout.dropin.internal.provider.checkCompileOnly
import com.adyen.checkout.dropin.internal.ui.model.DropInActivityEvent
import com.adyen.checkout.dropin.internal.ui.model.DropInDestination
@@ -58,7 +59,9 @@ internal class DropInViewModel(
private val eventChannel: Channel = bufferedChannel()
internal val eventsFlow = eventChannel.receiveAsFlow()
- val dropInConfiguration: DropInConfiguration = requireNotNull(bundleHandler.dropInConfiguration)
+ val checkoutConfiguration: CheckoutConfiguration = requireNotNull(bundleHandler.checkoutConfiguration)
+
+ val dropInConfiguration: DropInConfiguration = requireNotNull(checkoutConfiguration.getDropInConfiguration())
val serviceComponentName: ComponentName = requireNotNull(bundleHandler.serviceComponentName)
@@ -171,7 +174,7 @@ internal class DropInViewModel(
sessionModel = sessionModel,
clientKey = dropInConfiguration.clientKey,
environment = dropInConfiguration.environment,
- isFlowTakenOver = isSessionsFlowTakenOver
+ isFlowTakenOver = isSessionsFlowTakenOver,
)
sendEvent(event)
}
@@ -227,13 +230,13 @@ internal class DropInViewModel(
Logger.d(
TAG,
"handleBalanceResult - balance: ${balanceResult.balance} - " +
- "transactionLimit: ${balanceResult.transactionLimit}"
+ "transactionLimit: ${balanceResult.transactionLimit}",
)
val giftCardBalanceResult = GiftCardBalanceUtils.checkBalance(
balance = balanceResult.balance,
transactionLimit = balanceResult.transactionLimit,
- amountToBePaid = amount
+ amountToBePaid = amount,
)
val cachedGiftCardComponentState =
cachedGiftCardComponentState ?: throw CheckoutException("Failed to retrieved cached gift card object")
@@ -243,7 +246,7 @@ internal class DropInViewModel(
GiftCardBalanceResult.Error(
R.string.checkout_giftcard_error_zero_balance,
"Gift Card has zero balance",
- false
+ false,
)
}
@@ -252,7 +255,7 @@ internal class DropInViewModel(
GiftCardBalanceResult.Error(
R.string.checkout_giftcard_error_currency,
"Gift Card currency mismatch",
- false
+ false,
)
}
@@ -260,7 +263,7 @@ internal class DropInViewModel(
Logger.e(
TAG,
"handleBalanceResult - You must set an amount in DropInConfiguration.Builder to enable gift " +
- "card payments"
+ "card payments",
)
GiftCardBalanceResult.Error(R.string.payment_failed, "Drop-in amount is not set", true)
}
@@ -268,7 +271,7 @@ internal class DropInViewModel(
is GiftCardBalanceStatus.FullPayment -> {
cachedPartialPaymentAmount = giftCardBalanceResult.amountPaid
GiftCardBalanceResult.FullPayment(
- createGiftCardPaymentConfirmationData(giftCardBalanceResult, cachedGiftCardComponentState)
+ createGiftCardPaymentConfirmationData(giftCardBalanceResult, cachedGiftCardComponentState),
)
}
@@ -292,7 +295,7 @@ internal class DropInViewModel(
remainingBalance = giftCardBalanceStatus.remainingBalance,
shopperLocale = dropInConfiguration.shopperLocale,
brand = giftCardComponentState.data.paymentMethod?.brand.orEmpty(),
- lastFourDigits = giftCardComponentState.lastFourDigits.orEmpty()
+ lastFourDigits = giftCardComponentState.lastFourDigits.orEmpty(),
)
}
@@ -347,7 +350,7 @@ internal class DropInViewModel(
private fun createOrder(order: OrderModel): OrderRequest {
return OrderRequest(
pspReference = order.pspReference,
- orderData = order.orderData
+ orderData = order.orderData,
)
}
@@ -385,13 +388,13 @@ internal class DropInViewModel(
orderData = orderResponse.orderData,
pspReference = orderResponse.pspReference,
remainingAmount = statusResponse.remainingAmount,
- paymentMethods = statusResponse.paymentMethods
+ paymentMethods = statusResponse.paymentMethods,
)
},
onFailure = { e ->
Logger.e(TAG, "Unable to fetch order details", e)
null
- }
+ },
)
}
@@ -421,7 +424,7 @@ internal class DropInViewModel(
private fun sendCancelOrderEvent(order: OrderModel, isDropInCancelledByUser: Boolean) {
val orderRequest = OrderRequest(
pspReference = order.pspReference,
- orderData = order.orderData
+ orderData = order.orderData,
)
sendEvent(DropInActivityEvent.CancelOrder(orderRequest, isDropInCancelledByUser))
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModelFactory.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModelFactory.kt
index 0faff2ce20..616837cdb1 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModelFactory.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModelFactory.kt
@@ -13,6 +13,7 @@ import androidx.lifecycle.AbstractSavedStateViewModelFactory
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import com.adyen.checkout.components.core.Amount
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.internal.data.api.AnalyticsMapper
import com.adyen.checkout.components.core.internal.data.api.AnalyticsRepositoryData
import com.adyen.checkout.components.core.internal.data.api.AnalyticsService
@@ -23,7 +24,7 @@ import com.adyen.checkout.components.core.internal.data.model.AnalyticsSource
import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParams
import com.adyen.checkout.components.core.internal.util.screenWidthPixels
import com.adyen.checkout.core.internal.data.api.HttpClientFactory
-import com.adyen.checkout.dropin.DropInConfiguration
+import com.adyen.checkout.dropin.getDropInConfiguration
import com.adyen.checkout.dropin.internal.ui.model.DropInPaymentMethodInformation
import com.adyen.checkout.dropin.internal.ui.model.overrideInformation
@@ -37,29 +38,31 @@ internal class DropInViewModelFactory(
override fun create(key: String, modelClass: Class, handle: SavedStateHandle): T {
val bundleHandler = DropInSavedStateHandleContainer(handle)
- val dropInConfiguration: DropInConfiguration = requireNotNull(bundleHandler.dropInConfiguration)
- bundleHandler.overridePaymentMethodInformation(dropInConfiguration.overriddenPaymentMethodInformation)
+ val checkoutConfiguration: CheckoutConfiguration = requireNotNull(bundleHandler.checkoutConfiguration)
+ val overriddenPaymentMethodInformation =
+ checkoutConfiguration.getDropInConfiguration()?.overriddenPaymentMethodInformation.orEmpty()
+ bundleHandler.overridePaymentMethodInformation(overriddenPaymentMethodInformation)
val amount: Amount? = bundleHandler.amount
val paymentMethods = bundleHandler.paymentMethodsApiResponse?.paymentMethods?.mapNotNull { it.type }.orEmpty()
val session = bundleHandler.sessionDetails
- val httpClient = HttpClientFactory.getHttpClient(dropInConfiguration.environment)
+ val httpClient = HttpClientFactory.getHttpClient(checkoutConfiguration.environment)
val orderStatusRepository = OrderStatusRepository(OrderStatusService(httpClient))
val analyticsRepository = DefaultAnalyticsRepository(
analyticsRepositoryData = AnalyticsRepositoryData(
- level = AnalyticsParams(dropInConfiguration.analyticsConfiguration).level,
+ level = AnalyticsParams(checkoutConfiguration.analyticsConfiguration).level,
packageName = packageName,
- locale = dropInConfiguration.shopperLocale,
+ locale = checkoutConfiguration.shopperLocale,
source = AnalyticsSource.DropIn(),
- clientKey = dropInConfiguration.clientKey,
+ clientKey = checkoutConfiguration.clientKey,
amount = amount,
screenWidth = screenWidth,
paymentMethods = paymentMethods,
sessionId = session?.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(dropInConfiguration.environment)
+ HttpClientFactory.getAnalyticsHttpClient(checkoutConfiguration.environment),
),
analyticsMapper = AnalyticsMapper(),
)
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/DropInResultContractParams.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/DropInResultContractParams.kt
index 791469e7f0..24a8cdd761 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/DropInResultContractParams.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/DropInResultContractParams.kt
@@ -9,13 +9,13 @@
package com.adyen.checkout.dropin.internal.ui.model
import androidx.annotation.RestrictTo
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethodsApiResponse
-import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.dropin.DropInService
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
data class DropInResultContractParams(
- val dropInConfiguration: DropInConfiguration,
+ val checkoutConfiguration: CheckoutConfiguration,
val paymentMethodsApiResponse: PaymentMethodsApiResponse,
val serviceClass: Class,
)
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/SessionDropInResultContractParams.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/SessionDropInResultContractParams.kt
index 711a924895..50ea084e4e 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/SessionDropInResultContractParams.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/model/SessionDropInResultContractParams.kt
@@ -9,13 +9,13 @@
package com.adyen.checkout.dropin.internal.ui.model
import androidx.annotation.RestrictTo
-import com.adyen.checkout.dropin.DropInConfiguration
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.dropin.SessionDropInService
import com.adyen.checkout.sessions.core.CheckoutSession
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
data class SessionDropInResultContractParams(
- val dropInConfiguration: DropInConfiguration,
+ val checkoutConfiguration: CheckoutConfiguration,
val checkoutSession: CheckoutSession,
val serviceClass: Class,
)
diff --git a/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt b/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt
index 914fb99c46..2ba812a4aa 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/ui/configuration/CheckoutConfigurationProvider.kt
@@ -23,9 +23,7 @@ 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.core.Environment
-import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.dropin.dropInConfiguration
-import com.adyen.checkout.dropin.getDropInConfiguration
import com.adyen.checkout.example.BuildConfig
import com.adyen.checkout.example.data.storage.CardAddressMode
import com.adyen.checkout.example.data.storage.CardInstallmentOptionsMode
@@ -64,61 +62,60 @@ internal class CheckoutConfigurationProvider @Inject constructor(
private val environment = Environment.TEST
- private val checkoutConfig = CheckoutConfiguration(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey,
- amount = amount,
- analyticsConfiguration = getAnalyticsConfiguration(),
- ) {
- // Drop-in
- dropInConfiguration {
- setEnableRemovingStoredPaymentMethods(true)
+ val checkoutConfig: CheckoutConfiguration
+ get() = CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = getAnalyticsConfiguration(),
+ ) {
+ // Drop-in
+ dropInConfiguration {
+ setEnableRemovingStoredPaymentMethods(true)
+ }
+
+ // Payment methods
+ bacsDirectDebitConfiguration()
+
+ bcmcConfiguration {
+ setShopperReference(keyValueStorage.getShopperReference())
+ setShowStorePaymentField(true)
+ }
+
+ blikConfiguration()
+
+ cardConfiguration {
+ setShopperReference(keyValueStorage.getShopperReference())
+ setAddressConfiguration(getAddressConfiguration())
+ setInstallmentConfigurations(getInstallmentConfiguration())
+ }
+
+ cashAppPayConfiguration {
+ setReturnUrl(CashAppPayComponent.getReturnUrl(context))
+ }
+
+ giftCardConfiguration {
+ setPinRequired(true)
+ }
+
+ googlePayConfiguration {
+ setCountryCode(keyValueStorage.getCountry())
+ }
+
+ instantPaymentConfiguration()
+
+ // Actions
+ adyen3DS2Configuration()
+
+ redirectConfiguration()
}
- // Payment methods
- bacsDirectDebitConfiguration()
-
- bcmcConfiguration {
- setShopperReference(keyValueStorage.getShopperReference())
- setShowStorePaymentField(true)
- }
-
- blikConfiguration()
-
- cardConfiguration {
- setShopperReference(keyValueStorage.getShopperReference())
- setAddressConfiguration(getAddressConfiguration())
- setInstallmentConfigurations(getInstallmentConfiguration())
- }
-
- cashAppPayConfiguration {
- setReturnUrl(CashAppPayComponent.getReturnUrl(context))
- }
-
- giftCardConfiguration {
- setPinRequired(true)
- }
-
- googlePayConfiguration {
- setCountryCode(keyValueStorage.getCountry())
- }
-
- instantPaymentConfiguration()
-
- // Actions
- adyen3DS2Configuration()
-
- redirectConfiguration()
- }
-
private fun getAnalyticsConfiguration(): AnalyticsConfiguration {
val analyticsLevel = keyValueStorage.getAnalyticsLevel()
return AnalyticsConfiguration(level = analyticsLevel)
}
- fun getDropInConfiguration(): DropInConfiguration = checkoutConfig.getDropInConfiguration()!!
-
fun getBacsConfiguration(): BacsDirectDebitConfiguration = checkoutConfig.getBacsDirectDebitConfiguration()!!
fun getBlikConfiguration(): BlikConfiguration = checkoutConfig.getBlikConfiguration()!!
diff --git a/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainActivity.kt b/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainActivity.kt
index 8d50b61db1..07a9a40bfe 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainActivity.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainActivity.kt
@@ -145,7 +145,7 @@ class MainActivity : AppCompatActivity() {
this,
dropInLauncher,
navigation.paymentMethodsApiResponse,
- navigation.dropInConfiguration,
+ navigation.checkoutConfiguration,
ExampleAdvancedDropInService::class.java,
)
}
@@ -155,7 +155,7 @@ class MainActivity : AppCompatActivity() {
this,
sessionDropInLauncher,
navigation.checkoutSession,
- navigation.dropInConfiguration,
+ navigation.checkoutConfiguration,
)
}
@@ -164,7 +164,7 @@ class MainActivity : AppCompatActivity() {
this,
sessionDropInLauncher,
navigation.checkoutSession,
- navigation.dropInConfiguration,
+ navigation.checkoutConfiguration,
ExampleSessionsDropInService::class.java,
)
}
diff --git a/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainNavigation.kt b/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainNavigation.kt
index e72a8d6ee9..8c3e085919 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainNavigation.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainNavigation.kt
@@ -8,8 +8,8 @@
package com.adyen.checkout.example.ui.main
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethodsApiResponse
-import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.sessions.core.CheckoutSession
internal sealed class MainNavigation {
@@ -36,16 +36,16 @@ internal sealed class MainNavigation {
data class DropIn(
val paymentMethodsApiResponse: PaymentMethodsApiResponse,
- val dropInConfiguration: DropInConfiguration
+ val checkoutConfiguration: CheckoutConfiguration
) : MainNavigation()
data class DropInWithSession(
val checkoutSession: CheckoutSession,
- val dropInConfiguration: DropInConfiguration
+ val checkoutConfiguration: CheckoutConfiguration
) : MainNavigation()
data class DropInWithCustomSession(
val checkoutSession: CheckoutSession,
- val dropInConfiguration: DropInConfiguration
+ val checkoutConfiguration: CheckoutConfiguration
) : MainNavigation()
}
diff --git a/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainViewModel.kt b/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainViewModel.kt
index 980ebc28cf..56a101bbd8 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainViewModel.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/ui/main/MainViewModel.kt
@@ -12,7 +12,7 @@ import android.util.Log
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
-import com.adyen.checkout.dropin.DropInConfiguration
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.dropin.DropInResult
import com.adyen.checkout.dropin.SessionDropInResult
import com.adyen.checkout.example.data.storage.KeyValueStorage
@@ -125,8 +125,8 @@ internal class MainViewModel @Inject constructor(
showLoading(false)
if (paymentMethods != null) {
- val dropInConfiguration = checkoutConfigurationProvider.getDropInConfiguration()
- _eventFlow.tryEmit(MainEvent.NavigateTo(MainNavigation.DropIn(paymentMethods, dropInConfiguration)))
+ val checkoutConfiguration = checkoutConfigurationProvider.checkoutConfig
+ _eventFlow.tryEmit(MainEvent.NavigateTo(MainNavigation.DropIn(paymentMethods, checkoutConfiguration)))
} else {
onError("Something went wrong while fetching payment methods")
}
@@ -137,17 +137,17 @@ internal class MainViewModel @Inject constructor(
viewModelScope.launch {
showLoading(true)
- val dropInConfiguration = checkoutConfigurationProvider.getDropInConfiguration()
+ val checkoutConfiguration = checkoutConfigurationProvider.checkoutConfig
- val session = getSession(dropInConfiguration)
+ val session = getSession(checkoutConfiguration)
showLoading(false)
if (session != null) {
val navigation = if (takeOverSession) {
- MainNavigation.DropInWithCustomSession(session, dropInConfiguration)
+ MainNavigation.DropInWithCustomSession(session, checkoutConfiguration)
} else {
- MainNavigation.DropInWithSession(session, dropInConfiguration)
+ MainNavigation.DropInWithSession(session, checkoutConfiguration)
}
_eventFlow.tryEmit(MainEvent.NavigateTo(navigation))
} else {
@@ -167,7 +167,7 @@ internal class MainViewModel @Inject constructor(
),
)
- private suspend fun getSession(dropInConfiguration: DropInConfiguration): CheckoutSession? {
+ private suspend fun getSession(checkoutConfiguration: CheckoutConfiguration): CheckoutSession? {
val sessionModel = paymentsRepository.createSession(
getSessionRequest(
merchantAccount = keyValueStorage.getMerchantAccount(),
@@ -186,14 +186,14 @@ internal class MainViewModel @Inject constructor(
),
) ?: return null
- return getCheckoutSession(sessionModel, dropInConfiguration)
+ return getCheckoutSession(sessionModel, checkoutConfiguration)
}
private suspend fun getCheckoutSession(
sessionModel: SessionModel,
- dropInConfiguration: DropInConfiguration
+ checkoutConfiguration: CheckoutConfiguration
): CheckoutSession? {
- return when (val result = CheckoutSessionProvider.createSession(sessionModel, dropInConfiguration)) {
+ return when (val result = CheckoutSessionProvider.createSession(sessionModel, checkoutConfiguration)) {
is CheckoutSessionResult.Success -> result.checkoutSession
is CheckoutSessionResult.Error -> {
onError("Something went wrong while starting session")
From 6c80daf3a8fa3b20ba4364abd16e0a00177621e5 Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Fri, 8 Dec 2023 14:21:08 +0100
Subject: [PATCH 041/255] Split up ComponentParsingProvider
COAND-811
---
.../components/core/CheckoutConfiguration.kt | 3 +-
.../provider/ComponentParsingProvider.kt | 415 +-----------------
.../provider/ConfigurationParsingProvider.kt | 363 +++++++++++++++
.../internal/provider/FragmentProvider.kt | 62 +++
.../PaymentMethodAvailabilityProvider.kt | 81 ++++
.../dropin/internal/ui/DropInActivity.kt | 2 +-
.../dropin/internal/ui/DropInViewModel.kt | 2 +-
.../dropin/internal/util/CheckCompileOnly.kt | 15 +
8 files changed, 529 insertions(+), 414 deletions(-)
create mode 100644 drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt
create mode 100644 drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/FragmentProvider.kt
create mode 100644 drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt
create mode 100644 drop-in/src/main/java/com/adyen/checkout/dropin/internal/util/CheckCompileOnly.kt
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt b/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
index a9b49a43d7..f3c53e30f1 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
@@ -35,6 +35,7 @@ class CheckoutConfiguration(
this.apply(config)
}
+ // We need custom parcelization for this class to parcelize availableConfigurations.
@SuppressLint("ParcelClassLoader")
@Suppress("UNCHECKED_CAST")
private constructor(parcel: Parcel) : this(
@@ -46,7 +47,7 @@ class CheckoutConfiguration(
) {
val size = parcel.readInt()
- for (i in 0 until size) {
+ repeat(size) {
val clazz = parcel.readSerializable() as Class
val config = parcel.readParcelable(clazz.classLoader)!!
availableConfigurations[config::class] = config
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
index 841f078ad4..5ff742e55c 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
@@ -6,12 +6,8 @@
* Created by caiof on 24/4/2019.
*/
-@file:Suppress("TooManyFunctions")
-
package com.adyen.checkout.dropin.internal.provider
-import android.app.Application
-import android.content.Context
import androidx.fragment.app.Fragment
import com.adyen.checkout.ach.ACHDirectDebitComponent
import com.adyen.checkout.ach.ACHDirectDebitComponentState
@@ -42,17 +38,10 @@ import com.adyen.checkout.cashapppay.CashAppPayComponentState
import com.adyen.checkout.cashapppay.CashAppPayConfiguration
import com.adyen.checkout.cashapppay.internal.provider.CashAppPayComponentProvider
import com.adyen.checkout.components.core.Amount
-import com.adyen.checkout.components.core.ComponentAvailableCallback
import com.adyen.checkout.components.core.ComponentCallback
import com.adyen.checkout.components.core.PaymentMethod
-import com.adyen.checkout.components.core.PaymentMethodTypes
import com.adyen.checkout.components.core.StoredPaymentMethod
-import com.adyen.checkout.components.core.internal.AlwaysAvailablePaymentMethod
-import com.adyen.checkout.components.core.internal.BaseConfigurationBuilder
-import com.adyen.checkout.components.core.internal.Configuration
-import com.adyen.checkout.components.core.internal.NotAvailablePaymentMethod
import com.adyen.checkout.components.core.internal.PaymentComponent
-import com.adyen.checkout.components.core.internal.PaymentMethodAvailabilityCheck
import com.adyen.checkout.components.core.internal.data.api.AnalyticsRepository
import com.adyen.checkout.components.core.internal.provider.PaymentComponentProvider
import com.adyen.checkout.conveniencestoresjp.ConvenienceStoresJPComponent
@@ -60,22 +49,14 @@ import com.adyen.checkout.conveniencestoresjp.ConvenienceStoresJPComponentState
import com.adyen.checkout.conveniencestoresjp.ConvenienceStoresJPConfiguration
import com.adyen.checkout.conveniencestoresjp.internal.provider.ConvenienceStoresJPComponentProvider
import com.adyen.checkout.core.exception.CheckoutException
-import com.adyen.checkout.core.internal.util.LogUtil
-import com.adyen.checkout.core.internal.util.Logger
-import com.adyen.checkout.core.internal.util.runCompileOnly
import com.adyen.checkout.dotpay.DotpayComponent
import com.adyen.checkout.dotpay.DotpayComponentState
import com.adyen.checkout.dotpay.DotpayConfiguration
import com.adyen.checkout.dotpay.internal.provider.DotpayComponentProvider
import com.adyen.checkout.dropin.DropInConfiguration
-import com.adyen.checkout.dropin.internal.ui.BacsDirectDebitDialogFragment
-import com.adyen.checkout.dropin.internal.ui.CardComponentDialogFragment
-import com.adyen.checkout.dropin.internal.ui.DropInBottomSheetDialogFragment
-import com.adyen.checkout.dropin.internal.ui.GenericComponentDialogFragment
-import com.adyen.checkout.dropin.internal.ui.GiftCardComponentDialogFragment
-import com.adyen.checkout.dropin.internal.ui.GooglePayComponentDialogFragment
import com.adyen.checkout.dropin.internal.ui.model.DropInComponentParams
import com.adyen.checkout.dropin.internal.ui.model.DropInComponentParamsMapper
+import com.adyen.checkout.dropin.internal.util.checkCompileOnly
import com.adyen.checkout.entercash.EntercashComponent
import com.adyen.checkout.entercash.EntercashComponentState
import com.adyen.checkout.entercash.EntercashConfiguration
@@ -150,351 +131,6 @@ import com.adyen.checkout.upi.UPIComponent
import com.adyen.checkout.upi.UPIComponentState
import com.adyen.checkout.upi.UPIConfiguration
import com.adyen.checkout.upi.internal.provider.UPIComponentProvider
-import com.adyen.checkout.wechatpay.WeChatPayProvider
-
-private val TAG = LogUtil.getTag()
-
-internal inline fun getConfigurationForPaymentMethod(
- paymentMethod: PaymentMethod,
- dropInConfiguration: DropInConfiguration,
- context: Context,
-): T {
- val paymentMethodType = paymentMethod.type ?: throw CheckoutException("Payment method type is null")
- return dropInConfiguration.getConfigurationForPaymentMethod(paymentMethodType) ?: getDefaultConfigForPaymentMethod(
- paymentMethod,
- dropInConfiguration,
- context,
- )
-}
-
-internal inline fun getConfigurationForPaymentMethod(
- storedPaymentMethod: StoredPaymentMethod,
- dropInConfiguration: DropInConfiguration,
-): T {
- val storedPaymentMethodType = storedPaymentMethod.type ?: throw CheckoutException("Payment method type is null")
- return dropInConfiguration.getConfigurationForPaymentMethod(storedPaymentMethodType)
- ?: getDefaultConfigForPaymentMethod(
- storedPaymentMethod = storedPaymentMethod,
- dropInConfiguration = dropInConfiguration
- )
-}
-
-internal fun getDefaultConfigForPaymentMethod(
- storedPaymentMethod: StoredPaymentMethod,
- dropInConfiguration: DropInConfiguration
-): T {
- val shopperLocale = dropInConfiguration.shopperLocale
- val environment = dropInConfiguration.environment
- val clientKey = dropInConfiguration.clientKey
- val builder: BaseConfigurationBuilder<*, *> = when {
- checkCompileOnly { ACHDirectDebitComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
- ACHDirectDebitConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { BlikComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
- BlikConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
- CardConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { CashAppPayComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
- CashAppPayConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- else -> throw CheckoutException(
- errorMessage = "Unable to find component configuration for storedPaymentMethod - $storedPaymentMethod"
- )
- }
- @Suppress("UNCHECKED_CAST")
- return builder.build() as T
-}
-
-@Suppress("LongMethod", "CyclomaticComplexMethod")
-internal fun getDefaultConfigForPaymentMethod(
- paymentMethod: PaymentMethod,
- dropInConfiguration: DropInConfiguration,
- context: Context,
-): T {
- val shopperLocale = dropInConfiguration.shopperLocale
- val environment = dropInConfiguration.environment
- val clientKey = dropInConfiguration.clientKey
-
- // get default builder for Configuration type
- val builder: BaseConfigurationBuilder<*, *> = when {
- checkCompileOnly { ACHDirectDebitComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- ACHDirectDebitConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { BacsDirectDebitComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- BacsDirectDebitConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { BcmcComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- BcmcConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { BlikComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- BlikConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { BoletoComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- BoletoConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- CardConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { CashAppPayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- CashAppPayConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
- .setReturnUrl(CashAppPayComponent.getReturnUrl(context))
-
- checkCompileOnly { ConvenienceStoresJPComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- ConvenienceStoresJPConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { DotpayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- DotpayConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { EntercashComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- EntercashConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { EPSComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- EPSConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { GiftCardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- GiftCardConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { GooglePayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- GooglePayConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { IdealComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- IdealConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { InstantPaymentComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- InstantPaymentConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { MBWayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- MBWayConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { MolpayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- MolpayConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { OnlineBankingCZComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- OnlineBankingCZConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { OnlineBankingJPComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- OnlineBankingJPConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { OnlineBankingPLComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- OnlineBankingPLConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { OnlineBankingSKComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- OnlineBankingSKConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { OpenBankingComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- OpenBankingConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { PayByBankComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- PayByBankConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { PayEasyComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- PayEasyConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { SepaComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- SepaConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { SevenElevenComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- SevenElevenConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey
- )
-
- checkCompileOnly { UPIComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
- UPIConfiguration.Builder(
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey,
- )
-
- else -> throw CheckoutException("Unable to find component configuration for paymentMethod - $paymentMethod")
- }
-
- @Suppress("UNCHECKED_CAST")
- return builder.build() as T
-}
-
-private inline fun getConfigurationForPaymentMethodOrNull(
- paymentMethod: PaymentMethod,
- dropInConfiguration: DropInConfiguration,
- context: Context,
-): T? {
- @Suppress("SwallowedException")
- return try {
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
- } catch (e: CheckoutException) {
- null
- }
-}
-
-@Suppress("LongParameterList")
-internal fun checkPaymentMethodAvailability(
- application: Application,
- paymentMethod: PaymentMethod,
- dropInConfiguration: DropInConfiguration,
- amount: Amount?,
- sessionDetails: SessionDetails?,
- callback: ComponentAvailableCallback,
-) {
- try {
- Logger.v(TAG, "Checking availability for type - ${paymentMethod.type}")
-
- val type = paymentMethod.type ?: throw CheckoutException("PaymentMethod type is null")
-
- val availabilityCheck = getPaymentMethodAvailabilityCheck(dropInConfiguration, type, amount, sessionDetails)
- val configuration =
- getConfigurationForPaymentMethodOrNull(paymentMethod, dropInConfiguration, application)
-
- availabilityCheck.isAvailable(application, paymentMethod, configuration, callback)
- } catch (e: CheckoutException) {
- Logger.e(TAG, "Unable to initiate ${paymentMethod.type}", e)
- callback.onAvailabilityResult(false, paymentMethod)
- }
-}
-
-/**
- * Provides the [PaymentMethodAvailabilityCheck] class for the specified [paymentMethodType], if available.
- */
-internal fun getPaymentMethodAvailabilityCheck(
- dropInConfiguration: DropInConfiguration,
- paymentMethodType: String,
- amount: Amount?,
- sessionDetails: SessionDetails?,
-): PaymentMethodAvailabilityCheck {
- val dropInParams = dropInConfiguration.mapToParams(amount)
- val sessionParams = sessionDetails?.mapToParams(amount)
-
- @Suppress("UNCHECKED_CAST")
- val availabilityCheck = when (paymentMethodType) {
- PaymentMethodTypes.GOOGLE_PAY,
- PaymentMethodTypes.GOOGLE_PAY_LEGACY -> runCompileOnly {
- GooglePayComponentProvider(dropInParams, sessionParams)
- }
-
- PaymentMethodTypes.WECHAT_PAY_SDK -> runCompileOnly { WeChatPayProvider() }
- else -> AlwaysAvailablePaymentMethod()
- } as? PaymentMethodAvailabilityCheck
-
- return availabilityCheck ?: NotAvailablePaymentMethod()
-}
/**
* Provides a [PaymentComponent] from a [PaymentComponentProvider] using the [StoredPaymentMethod] reference.
@@ -537,7 +173,7 @@ internal fun getComponentFor(
storedPaymentMethod = storedPaymentMethod,
configuration = cardConfig,
callback = componentCallback as ComponentCallback,
- key = storedPaymentMethod.id
+ key = storedPaymentMethod.id,
)
}
@@ -549,7 +185,7 @@ internal fun getComponentFor(
storedPaymentMethod = storedPaymentMethod,
configuration = cashAppPayConfig,
callback = componentCallback as ComponentCallback,
- key = storedPaymentMethod.id
+ key = storedPaymentMethod.id,
)
}
@@ -561,7 +197,7 @@ internal fun getComponentFor(
storedPaymentMethod = storedPaymentMethod,
configuration = blikConfig,
callback = componentCallback as ComponentCallback,
- key = storedPaymentMethod.id
+ key = storedPaymentMethod.id,
)
}
@@ -903,46 +539,3 @@ internal fun getComponentFor(
internal fun DropInConfiguration.mapToParams(amount: Amount?): DropInComponentParams {
return DropInComponentParamsMapper().mapToParams(this, amount)
}
-
-internal fun getFragmentForStoredPaymentMethod(
- storedPaymentMethod: StoredPaymentMethod,
- fromPreselected: Boolean
-): DropInBottomSheetDialogFragment {
- return when {
- checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
- CardComponentDialogFragment.newInstance(storedPaymentMethod, fromPreselected)
- }
-
- else -> {
- GenericComponentDialogFragment.newInstance(storedPaymentMethod, fromPreselected)
- }
- }
-}
-
-internal fun getFragmentForPaymentMethod(paymentMethod: PaymentMethod): DropInBottomSheetDialogFragment {
- return when {
- checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
- CardComponentDialogFragment.newInstance(paymentMethod)
- }
-
- checkCompileOnly { BacsDirectDebitComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
- BacsDirectDebitDialogFragment.newInstance(paymentMethod)
- }
-
- checkCompileOnly { GiftCardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
- GiftCardComponentDialogFragment.newInstance(paymentMethod)
- }
-
- checkCompileOnly { GooglePayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
- GooglePayComponentDialogFragment.newInstance(paymentMethod)
- }
-
- else -> {
- GenericComponentDialogFragment.newInstance(paymentMethod)
- }
- }
-}
-
-internal inline fun checkCompileOnly(block: () -> Boolean): Boolean {
- return runCompileOnly(block) ?: false
-}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt
new file mode 100644
index 0000000000..6b7fa80230
--- /dev/null
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt
@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 2023 Adyen N.V.
+ *
+ * This file is open source and available under the MIT license. See the LICENSE file for more info.
+ *
+ * Created by oscars on 8/12/2023.
+ */
+
+package com.adyen.checkout.dropin.internal.provider
+
+import android.content.Context
+import com.adyen.checkout.ach.ACHDirectDebitComponent
+import com.adyen.checkout.ach.ACHDirectDebitConfiguration
+import com.adyen.checkout.bacs.BacsDirectDebitComponent
+import com.adyen.checkout.bacs.BacsDirectDebitConfiguration
+import com.adyen.checkout.bcmc.BcmcComponent
+import com.adyen.checkout.bcmc.BcmcConfiguration
+import com.adyen.checkout.blik.BlikComponent
+import com.adyen.checkout.blik.BlikConfiguration
+import com.adyen.checkout.boleto.BoletoComponent
+import com.adyen.checkout.boleto.BoletoConfiguration
+import com.adyen.checkout.card.CardComponent
+import com.adyen.checkout.card.CardConfiguration
+import com.adyen.checkout.cashapppay.CashAppPayComponent
+import com.adyen.checkout.cashapppay.CashAppPayConfiguration
+import com.adyen.checkout.components.core.PaymentMethod
+import com.adyen.checkout.components.core.StoredPaymentMethod
+import com.adyen.checkout.components.core.internal.BaseConfigurationBuilder
+import com.adyen.checkout.components.core.internal.Configuration
+import com.adyen.checkout.conveniencestoresjp.ConvenienceStoresJPComponent
+import com.adyen.checkout.conveniencestoresjp.ConvenienceStoresJPConfiguration
+import com.adyen.checkout.core.exception.CheckoutException
+import com.adyen.checkout.dotpay.DotpayComponent
+import com.adyen.checkout.dotpay.DotpayConfiguration
+import com.adyen.checkout.dropin.DropInConfiguration
+import com.adyen.checkout.dropin.internal.util.checkCompileOnly
+import com.adyen.checkout.entercash.EntercashComponent
+import com.adyen.checkout.entercash.EntercashConfiguration
+import com.adyen.checkout.eps.EPSComponent
+import com.adyen.checkout.eps.EPSConfiguration
+import com.adyen.checkout.giftcard.GiftCardComponent
+import com.adyen.checkout.giftcard.GiftCardConfiguration
+import com.adyen.checkout.googlepay.GooglePayComponent
+import com.adyen.checkout.googlepay.GooglePayConfiguration
+import com.adyen.checkout.ideal.IdealComponent
+import com.adyen.checkout.ideal.IdealConfiguration
+import com.adyen.checkout.instant.InstantPaymentComponent
+import com.adyen.checkout.instant.InstantPaymentConfiguration
+import com.adyen.checkout.mbway.MBWayComponent
+import com.adyen.checkout.mbway.MBWayConfiguration
+import com.adyen.checkout.molpay.MolpayComponent
+import com.adyen.checkout.molpay.MolpayConfiguration
+import com.adyen.checkout.onlinebankingcz.OnlineBankingCZComponent
+import com.adyen.checkout.onlinebankingcz.OnlineBankingCZConfiguration
+import com.adyen.checkout.onlinebankingjp.OnlineBankingJPComponent
+import com.adyen.checkout.onlinebankingjp.OnlineBankingJPConfiguration
+import com.adyen.checkout.onlinebankingpl.OnlineBankingPLComponent
+import com.adyen.checkout.onlinebankingpl.OnlineBankingPLConfiguration
+import com.adyen.checkout.onlinebankingsk.OnlineBankingSKComponent
+import com.adyen.checkout.onlinebankingsk.OnlineBankingSKConfiguration
+import com.adyen.checkout.openbanking.OpenBankingComponent
+import com.adyen.checkout.openbanking.OpenBankingConfiguration
+import com.adyen.checkout.paybybank.PayByBankComponent
+import com.adyen.checkout.paybybank.PayByBankConfiguration
+import com.adyen.checkout.payeasy.PayEasyComponent
+import com.adyen.checkout.payeasy.PayEasyConfiguration
+import com.adyen.checkout.sepa.SepaComponent
+import com.adyen.checkout.sepa.SepaConfiguration
+import com.adyen.checkout.seveneleven.SevenElevenComponent
+import com.adyen.checkout.seveneleven.SevenElevenConfiguration
+import com.adyen.checkout.upi.UPIComponent
+import com.adyen.checkout.upi.UPIConfiguration
+
+internal inline fun getConfigurationForPaymentMethod(
+ paymentMethod: PaymentMethod,
+ dropInConfiguration: DropInConfiguration,
+ context: Context,
+): T {
+ val paymentMethodType = paymentMethod.type ?: throw CheckoutException("Payment method type is null")
+ return dropInConfiguration.getConfigurationForPaymentMethod(paymentMethodType) ?: getDefaultConfigForPaymentMethod(
+ paymentMethod,
+ dropInConfiguration,
+ context,
+ )
+}
+
+@Suppress("LongMethod", "CyclomaticComplexMethod")
+internal fun getDefaultConfigForPaymentMethod(
+ paymentMethod: PaymentMethod,
+ dropInConfiguration: DropInConfiguration,
+ context: Context,
+): T {
+ val shopperLocale = dropInConfiguration.shopperLocale
+ val environment = dropInConfiguration.environment
+ val clientKey = dropInConfiguration.clientKey
+
+ // get default builder for Configuration type
+ val builder: BaseConfigurationBuilder<*, *> = when {
+ checkCompileOnly { ACHDirectDebitComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ ACHDirectDebitConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { BacsDirectDebitComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ BacsDirectDebitConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { BcmcComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ BcmcConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { BlikComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ BlikConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { BoletoComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ BoletoConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ CardConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { CashAppPayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ CashAppPayConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+ .setReturnUrl(CashAppPayComponent.getReturnUrl(context))
+
+ checkCompileOnly { ConvenienceStoresJPComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ ConvenienceStoresJPConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { DotpayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ DotpayConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { EntercashComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ EntercashConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { EPSComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ EPSConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { GiftCardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ GiftCardConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { GooglePayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ GooglePayConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { IdealComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ IdealConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { InstantPaymentComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ InstantPaymentConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { MBWayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ MBWayConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { MolpayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ MolpayConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { OnlineBankingCZComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ OnlineBankingCZConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { OnlineBankingJPComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ OnlineBankingJPConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { OnlineBankingPLComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ OnlineBankingPLConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { OnlineBankingSKComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ OnlineBankingSKConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { OpenBankingComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ OpenBankingConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { PayByBankComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ PayByBankConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { PayEasyComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ PayEasyConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { SepaComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ SepaConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { SevenElevenComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ SevenElevenConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { UPIComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
+ UPIConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ )
+
+ else -> throw CheckoutException("Unable to find component configuration for paymentMethod - $paymentMethod")
+ }
+
+ @Suppress("UNCHECKED_CAST")
+ return builder.build() as T
+}
+
+internal inline fun getConfigurationForPaymentMethod(
+ storedPaymentMethod: StoredPaymentMethod,
+ dropInConfiguration: DropInConfiguration,
+): T {
+ val storedPaymentMethodType = storedPaymentMethod.type ?: throw CheckoutException("Payment method type is null")
+ return dropInConfiguration.getConfigurationForPaymentMethod(storedPaymentMethodType)
+ ?: getDefaultConfigForPaymentMethod(
+ storedPaymentMethod = storedPaymentMethod,
+ dropInConfiguration = dropInConfiguration
+ )
+}
+
+internal fun getDefaultConfigForPaymentMethod(
+ storedPaymentMethod: StoredPaymentMethod,
+ dropInConfiguration: DropInConfiguration
+): T {
+ val shopperLocale = dropInConfiguration.shopperLocale
+ val environment = dropInConfiguration.environment
+ val clientKey = dropInConfiguration.clientKey
+ val builder: BaseConfigurationBuilder<*, *> = when {
+ checkCompileOnly { ACHDirectDebitComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
+ ACHDirectDebitConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { BlikComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
+ BlikConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
+ CardConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ checkCompileOnly { CashAppPayComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
+ CashAppPayConfiguration.Builder(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey
+ )
+
+ else -> throw CheckoutException(
+ errorMessage = "Unable to find component configuration for storedPaymentMethod - $storedPaymentMethod"
+ )
+ }
+ @Suppress("UNCHECKED_CAST")
+ return builder.build() as T
+}
+
+internal inline fun getConfigurationForPaymentMethodOrNull(
+ paymentMethod: PaymentMethod,
+ dropInConfiguration: DropInConfiguration,
+ context: Context,
+): T? {
+ @Suppress("SwallowedException")
+ return try {
+ getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ } catch (e: CheckoutException) {
+ null
+ }
+}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/FragmentProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/FragmentProvider.kt
new file mode 100644
index 0000000000..954e795ee4
--- /dev/null
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/FragmentProvider.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2023 Adyen N.V.
+ *
+ * This file is open source and available under the MIT license. See the LICENSE file for more info.
+ *
+ * Created by oscars on 8/12/2023.
+ */
+
+package com.adyen.checkout.dropin.internal.provider
+
+import com.adyen.checkout.bacs.BacsDirectDebitComponent
+import com.adyen.checkout.card.CardComponent
+import com.adyen.checkout.components.core.PaymentMethod
+import com.adyen.checkout.components.core.StoredPaymentMethod
+import com.adyen.checkout.dropin.internal.ui.BacsDirectDebitDialogFragment
+import com.adyen.checkout.dropin.internal.ui.CardComponentDialogFragment
+import com.adyen.checkout.dropin.internal.ui.DropInBottomSheetDialogFragment
+import com.adyen.checkout.dropin.internal.ui.GenericComponentDialogFragment
+import com.adyen.checkout.dropin.internal.ui.GiftCardComponentDialogFragment
+import com.adyen.checkout.dropin.internal.ui.GooglePayComponentDialogFragment
+import com.adyen.checkout.dropin.internal.util.checkCompileOnly
+import com.adyen.checkout.giftcard.GiftCardComponent
+import com.adyen.checkout.googlepay.GooglePayComponent
+
+internal fun getFragmentForStoredPaymentMethod(
+ storedPaymentMethod: StoredPaymentMethod,
+ fromPreselected: Boolean
+): DropInBottomSheetDialogFragment {
+ return when {
+ checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
+ CardComponentDialogFragment.newInstance(storedPaymentMethod, fromPreselected)
+ }
+
+ else -> {
+ GenericComponentDialogFragment.newInstance(storedPaymentMethod, fromPreselected)
+ }
+ }
+}
+
+internal fun getFragmentForPaymentMethod(paymentMethod: PaymentMethod): DropInBottomSheetDialogFragment {
+ return when {
+ checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
+ CardComponentDialogFragment.newInstance(paymentMethod)
+ }
+
+ checkCompileOnly { BacsDirectDebitComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
+ BacsDirectDebitDialogFragment.newInstance(paymentMethod)
+ }
+
+ checkCompileOnly { GiftCardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
+ GiftCardComponentDialogFragment.newInstance(paymentMethod)
+ }
+
+ checkCompileOnly { GooglePayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
+ GooglePayComponentDialogFragment.newInstance(paymentMethod)
+ }
+
+ else -> {
+ GenericComponentDialogFragment.newInstance(paymentMethod)
+ }
+ }
+}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt
new file mode 100644
index 0000000000..e613cc6ec1
--- /dev/null
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2023 Adyen N.V.
+ *
+ * This file is open source and available under the MIT license. See the LICENSE file for more info.
+ *
+ * Created by oscars on 8/12/2023.
+ */
+
+package com.adyen.checkout.dropin.internal.provider
+
+import android.app.Application
+import com.adyen.checkout.components.core.Amount
+import com.adyen.checkout.components.core.ComponentAvailableCallback
+import com.adyen.checkout.components.core.PaymentMethod
+import com.adyen.checkout.components.core.PaymentMethodTypes
+import com.adyen.checkout.components.core.internal.AlwaysAvailablePaymentMethod
+import com.adyen.checkout.components.core.internal.Configuration
+import com.adyen.checkout.components.core.internal.NotAvailablePaymentMethod
+import com.adyen.checkout.components.core.internal.PaymentMethodAvailabilityCheck
+import com.adyen.checkout.core.exception.CheckoutException
+import com.adyen.checkout.core.internal.util.LogUtil
+import com.adyen.checkout.core.internal.util.Logger
+import com.adyen.checkout.core.internal.util.runCompileOnly
+import com.adyen.checkout.dropin.DropInConfiguration
+import com.adyen.checkout.googlepay.internal.provider.GooglePayComponentProvider
+import com.adyen.checkout.sessions.core.internal.data.model.SessionDetails
+import com.adyen.checkout.sessions.core.internal.data.model.mapToParams
+import com.adyen.checkout.wechatpay.WeChatPayProvider
+
+private val TAG = LogUtil.getTag()
+
+@Suppress("LongParameterList")
+internal fun checkPaymentMethodAvailability(
+ application: Application,
+ paymentMethod: PaymentMethod,
+ dropInConfiguration: DropInConfiguration,
+ amount: Amount?,
+ sessionDetails: SessionDetails?,
+ callback: ComponentAvailableCallback,
+) {
+ try {
+ Logger.v(TAG, "Checking availability for type - ${paymentMethod.type}")
+
+ val type = paymentMethod.type ?: throw CheckoutException("PaymentMethod type is null")
+
+ val availabilityCheck = getPaymentMethodAvailabilityCheck(dropInConfiguration, type, amount, sessionDetails)
+ val configuration =
+ getConfigurationForPaymentMethodOrNull(paymentMethod, dropInConfiguration, application)
+
+ availabilityCheck.isAvailable(application, paymentMethod, configuration, callback)
+ } catch (e: CheckoutException) {
+ Logger.e(TAG, "Unable to initiate ${paymentMethod.type}", e)
+ callback.onAvailabilityResult(false, paymentMethod)
+ }
+}
+
+/**
+ * Provides the [PaymentMethodAvailabilityCheck] class for the specified [paymentMethodType], if available.
+ */
+internal fun getPaymentMethodAvailabilityCheck(
+ dropInConfiguration: DropInConfiguration,
+ paymentMethodType: String,
+ amount: Amount?,
+ sessionDetails: SessionDetails?,
+): PaymentMethodAvailabilityCheck {
+ val dropInParams = dropInConfiguration.mapToParams(amount)
+ val sessionParams = sessionDetails?.mapToParams(amount)
+
+ @Suppress("UNCHECKED_CAST")
+ val availabilityCheck = when (paymentMethodType) {
+ PaymentMethodTypes.GOOGLE_PAY,
+ PaymentMethodTypes.GOOGLE_PAY_LEGACY -> runCompileOnly {
+ GooglePayComponentProvider(dropInParams, sessionParams)
+ }
+
+ PaymentMethodTypes.WECHAT_PAY_SDK -> runCompileOnly { WeChatPayProvider() }
+ else -> AlwaysAvailablePaymentMethod()
+ } as? PaymentMethodAvailabilityCheck
+
+ return availabilityCheck ?: NotAvailablePaymentMethod()
+}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt
index bee8a035a6..73d3783579 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt
@@ -46,7 +46,6 @@ import com.adyen.checkout.dropin.R
import com.adyen.checkout.dropin.RecurringDropInServiceResult
import com.adyen.checkout.dropin.SessionDropInServiceResult
import com.adyen.checkout.dropin.databinding.ActivityDropInBinding
-import com.adyen.checkout.dropin.internal.provider.checkCompileOnly
import com.adyen.checkout.dropin.internal.provider.getFragmentForPaymentMethod
import com.adyen.checkout.dropin.internal.provider.getFragmentForStoredPaymentMethod
import com.adyen.checkout.dropin.internal.service.BaseDropInService
@@ -56,6 +55,7 @@ import com.adyen.checkout.dropin.internal.ui.model.DropInActivityEvent
import com.adyen.checkout.dropin.internal.ui.model.DropInDestination
import com.adyen.checkout.dropin.internal.ui.model.GiftCardPaymentConfirmationData
import com.adyen.checkout.dropin.internal.util.DropInPrefs
+import com.adyen.checkout.dropin.internal.util.checkCompileOnly
import com.adyen.checkout.giftcard.GiftCardComponentState
import com.adyen.checkout.redirect.RedirectComponent
import com.adyen.checkout.sessions.core.CheckoutSession
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt
index e33e61c53b..a87030bc12 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt
@@ -32,11 +32,11 @@ import com.adyen.checkout.core.internal.util.Logger
import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.dropin.R
import com.adyen.checkout.dropin.getDropInConfiguration
-import com.adyen.checkout.dropin.internal.provider.checkCompileOnly
import com.adyen.checkout.dropin.internal.ui.model.DropInActivityEvent
import com.adyen.checkout.dropin.internal.ui.model.DropInDestination
import com.adyen.checkout.dropin.internal.ui.model.GiftCardPaymentConfirmationData
import com.adyen.checkout.dropin.internal.ui.model.OrderModel
+import com.adyen.checkout.dropin.internal.util.checkCompileOnly
import com.adyen.checkout.dropin.internal.util.isStoredPaymentSupported
import com.adyen.checkout.giftcard.GiftCardComponentState
import com.adyen.checkout.giftcard.internal.util.GiftCardBalanceStatus
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/util/CheckCompileOnly.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/util/CheckCompileOnly.kt
new file mode 100644
index 0000000000..3998769aa0
--- /dev/null
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/util/CheckCompileOnly.kt
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2023 Adyen N.V.
+ *
+ * This file is open source and available under the MIT license. See the LICENSE file for more info.
+ *
+ * Created by oscars on 8/12/2023.
+ */
+
+package com.adyen.checkout.dropin.internal.util
+
+import com.adyen.checkout.core.internal.util.runCompileOnly
+
+internal inline fun checkCompileOnly(block: () -> Boolean): Boolean {
+ return runCompileOnly(block) ?: false
+}
From 49abd53a2ffe8e9a2d353426bc2ec2651caceed3 Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Fri, 8 Dec 2023 15:54:18 +0100
Subject: [PATCH 042/255] Use payment method type as key in
CheckoutConfiguration
This allows us to give different configurations based on the payment
method. This is especially useful for InstantPaymentComponent.
COAND-811
---
.../adyen3ds2/Adyen3DS2Configuration.kt | 4 +--
.../ach/ACHDirectDebitConfiguration.kt | 5 +--
.../checkout/await/AwaitConfiguration.kt | 4 +--
.../bacs/BacsDirectDebitConfiguration.kt | 9 ++---
.../adyen/checkout/bcmc/BcmcConfiguration.kt | 5 +--
.../adyen/checkout/blik/BlikConfiguration.kt | 5 +--
.../checkout/boleto/BoletoConfiguration.kt | 10 ++++--
.../adyen/checkout/card/CardConfiguration.kt | 5 +--
.../cashapppay/CashAppPayConfiguration.kt | 5 +--
.../components/core/CheckoutConfiguration.kt | 33 ++++++++++++-------
.../ConvenienceStoresJPConfiguration.kt | 5 +--
.../checkout/dotpay/DotpayConfiguration.kt | 5 +--
.../checkout/dropin/DropInConfiguration.kt | 16 +++++----
.../entercash/EntercashConfiguration.kt | 7 ++--
.../adyen/checkout/eps/EPSConfiguration.kt | 5 +--
.../giftcard/GiftCardConfiguration.kt | 9 ++---
.../googlepay/GooglePayConfiguration.kt | 10 ++++--
.../checkout/ideal/IdealConfiguration.kt | 5 +--
.../instant/InstantPaymentConfiguration.kt | 17 ++++++----
.../checkout/mbway/MBWayConfiguration.kt | 5 +--
.../checkout/molpay/MolpayConfiguration.kt | 10 ++++--
.../OnlineBankingCZConfiguration.kt | 5 +--
.../OnlineBankingJPConfiguration.kt | 7 ++--
.../OnlineBankingPLConfiguration.kt | 5 +--
.../OnlineBankingSKConfiguration.kt | 5 +--
.../openbanking/OpenBankingConfiguration.kt | 5 +--
.../paybybank/PayByBankConfiguration.kt | 5 +--
.../checkout/payeasy/PayEasyConfiguration.kt | 7 ++--
.../checkout/qrcode/QRCodeConfiguration.kt | 4 +--
.../redirect/RedirectConfiguration.kt | 4 +--
.../adyen/checkout/sepa/SepaConfiguration.kt | 5 +--
.../seveneleven/SevenElevenConfiguration.kt | 5 +--
.../adyen/checkout/upi/UPIConfiguration.kt | 10 ++++--
.../checkout/voucher/VoucherConfiguration.kt | 4 +--
.../wechatpay/WeChatPayActionConfiguration.kt | 4 +--
35 files changed, 159 insertions(+), 95 deletions(-)
diff --git a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt
index 6962db68eb..20db7eb887 100644
--- a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt
+++ b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt
@@ -118,10 +118,10 @@ fun CheckoutConfiguration.adyen3DS2Configuration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addActionConfiguration(config)
return this
}
fun CheckoutConfiguration.getAdyen3DS2Configuration(): Adyen3DS2Configuration? {
- return getConfiguration(Adyen3DS2Configuration::class)
+ return getActionConfiguration(Adyen3DS2Configuration::class.java)
}
diff --git a/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt b/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt
index 4045bd3ce6..4a4e9076c7 100644
--- a/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt
+++ b/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt
@@ -14,6 +14,7 @@ import com.adyen.checkout.action.core.internal.ActionHandlingPaymentMethodConfig
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.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -140,10 +141,10 @@ fun CheckoutConfiguration.ACHDirectDebitConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.ACH, config)
return this
}
fun CheckoutConfiguration.getACHDirectDebitConfiguration(): ACHDirectDebitConfiguration? {
- return getConfiguration(ACHDirectDebitConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.ACH)
}
diff --git a/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt b/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt
index 80bdd4cdf1..6d74d82b73 100644
--- a/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt
+++ b/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt
@@ -82,10 +82,10 @@ fun CheckoutConfiguration.awaitConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addActionConfiguration(config)
return this
}
fun CheckoutConfiguration.getAwaitConfiguration(): AwaitConfiguration? {
- return getConfiguration(AwaitConfiguration::class)
+ return getActionConfiguration(AwaitConfiguration::class.java)
}
diff --git a/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt b/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt
index a7904d30d4..67ac38dd70 100644
--- a/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt
+++ b/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt
@@ -14,6 +14,7 @@ import com.adyen.checkout.action.core.internal.ActionHandlingPaymentMethodConfig
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.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -55,7 +56,7 @@ class BacsDirectDebitConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -68,7 +69,7 @@ class BacsDirectDebitConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
/**
@@ -107,10 +108,10 @@ fun CheckoutConfiguration.bacsDirectDebitConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.BACS, config)
return this
}
fun CheckoutConfiguration.getBacsDirectDebitConfiguration(): BacsDirectDebitConfiguration? {
- return getConfiguration(BacsDirectDebitConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.BACS)
}
diff --git a/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt b/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt
index 95048e97df..ea11c4d740 100644
--- a/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt
+++ b/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt
@@ -14,6 +14,7 @@ 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.PaymentComponentData
+import com.adyen.checkout.components.core.PaymentMethodTypes
import com.adyen.checkout.components.core.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -162,10 +163,10 @@ fun CheckoutConfiguration.bcmcConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.BCMC, config)
return this
}
fun CheckoutConfiguration.getBcmcConfiguration(): BcmcConfiguration? {
- return getConfiguration(BcmcConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.BCMC)
}
diff --git a/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt b/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt
index 0925d0e775..f5d94d5c65 100644
--- a/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt
+++ b/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.action.core.internal.ActionHandlingPaymentMethodConfig
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.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -106,10 +107,10 @@ fun CheckoutConfiguration.blikConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.BLIK, config)
return this
}
fun CheckoutConfiguration.getBlikConfiguration(): BlikConfiguration? {
- return getConfiguration(BlikConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.BLIK)
}
diff --git a/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt b/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt
index 5a31296614..003b1500be 100644
--- a/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt
+++ b/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt
@@ -118,10 +118,16 @@ fun CheckoutConfiguration.boletoConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+
+ BoletoComponent.PAYMENT_METHOD_TYPES.forEach { key ->
+ addConfiguration(key, config)
+ }
+
return this
}
fun CheckoutConfiguration.getBoletoConfiguration(): BoletoConfiguration? {
- return getConfiguration(BoletoConfiguration::class)
+ return BoletoComponent.PAYMENT_METHOD_TYPES.firstNotNullOfOrNull { key ->
+ getConfiguration(key)
+ }
}
diff --git a/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt b/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt
index e97e366417..c7361842fb 100644
--- a/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt
+++ b/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt
@@ -15,6 +15,7 @@ import com.adyen.checkout.components.core.AnalyticsConfiguration
import com.adyen.checkout.components.core.CheckoutConfiguration
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.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -304,10 +305,10 @@ fun CheckoutConfiguration.cardConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.SCHEME, config)
return this
}
fun CheckoutConfiguration.getCardConfiguration(): CardConfiguration? {
- return getConfiguration(CardConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.SCHEME)
}
diff --git a/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt b/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt
index ce6eff48a2..880cd53460 100644
--- a/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt
+++ b/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt
@@ -14,6 +14,7 @@ import com.adyen.checkout.action.core.internal.ActionHandlingPaymentMethodConfig
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.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -170,10 +171,10 @@ fun CheckoutConfiguration.cashAppPayConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.CASH_APP_PAY, config)
return this
}
fun CheckoutConfiguration.getCashAppPayConfiguration(): CashAppPayConfiguration? {
- return getConfiguration(CashAppPayConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.CASH_APP_PAY)
}
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt b/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
index f3c53e30f1..3280a4c0fb 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/CheckoutConfiguration.kt
@@ -17,7 +17,6 @@ import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.core.Environment
import kotlinx.parcelize.IgnoredOnParcel
import java.util.Locale
-import kotlin.reflect.KClass
class CheckoutConfiguration(
override val shopperLocale: Locale,
@@ -29,7 +28,7 @@ class CheckoutConfiguration(
private val config: CheckoutConfiguration.() -> Unit = {},
) : Configuration {
- private val availableConfigurations = mutableMapOf, Configuration>()
+ private val availableConfigurations = mutableMapOf()
init {
this.apply(config)
@@ -37,7 +36,7 @@ class CheckoutConfiguration(
// We need custom parcelization for this class to parcelize availableConfigurations.
@SuppressLint("ParcelClassLoader")
- @Suppress("UNCHECKED_CAST")
+ @Suppress("UNCHECKED_CAST", "DEPRECATION")
private constructor(parcel: Parcel) : this(
shopperLocale = parcel.readSerializable() as Locale,
environment = parcel.readParcelable(Environment::class.java.classLoader)!!,
@@ -48,20 +47,31 @@ class CheckoutConfiguration(
val size = parcel.readInt()
repeat(size) {
- val clazz = parcel.readSerializable() as Class
- val config = parcel.readParcelable(clazz.classLoader)!!
- availableConfigurations[config::class] = config
+ val key = parcel.readString()!!
+ val configClass = parcel.readSerializable() as Class
+ val config = parcel.readParcelable(configClass.classLoader)!!
+ availableConfigurations[key] = config
}
}
- fun addConfiguration(configuration: Configuration) {
- availableConfigurations[configuration::class] = configuration
+ fun addConfiguration(key: String, configuration: Configuration) {
+ availableConfigurations[key] = configuration
+ }
+
+ fun addActionConfiguration(configuration: Configuration) {
+ availableConfigurations[configuration::class.java.simpleName] = configuration
+ }
+
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ fun getConfiguration(key: String): T? {
+ @Suppress("UNCHECKED_CAST")
+ return availableConfigurations[key] as? T
}
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
- fun getConfiguration(configKlass: KClass): T? {
+ fun getActionConfiguration(configClass: Class): T? {
@Suppress("UNCHECKED_CAST")
- return availableConfigurations[configKlass] as? T
+ return availableConfigurations[configClass.simpleName] as? T
}
override fun writeToParcel(dest: Parcel, flags: Int) {
@@ -72,7 +82,8 @@ class CheckoutConfiguration(
dest.writeParcelable(analyticsConfiguration, flags)
dest.writeInt(availableConfigurations.size)
availableConfigurations.forEach {
- dest.writeSerializable(it.key.java)
+ dest.writeString(it.key)
+ dest.writeSerializable(it.value::class.java)
dest.writeParcelable(it.value, flags)
}
}
diff --git a/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt b/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt
index dbaf6c0570..8b61b5a656 100644
--- a/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt
+++ b/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.econtext.internal.EContextConfiguration
import kotlinx.parcelize.Parcelize
@@ -88,10 +89,10 @@ fun CheckoutConfiguration.convenienceStoresJPConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.ECONTEXT_STORES, config)
return this
}
fun CheckoutConfiguration.getConvenienceStoresJPConfiguration(): ConvenienceStoresJPConfiguration? {
- return getConfiguration(ConvenienceStoresJPConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.ECONTEXT_STORES)
}
diff --git a/dotpay/src/main/java/com/adyen/checkout/dotpay/DotpayConfiguration.kt b/dotpay/src/main/java/com/adyen/checkout/dotpay/DotpayConfiguration.kt
index d945b67f9d..c9bf539752 100644
--- a/dotpay/src/main/java/com/adyen/checkout/dotpay/DotpayConfiguration.kt
+++ b/dotpay/src/main/java/com/adyen/checkout/dotpay/DotpayConfiguration.kt
@@ -12,6 +12,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -92,10 +93,10 @@ fun CheckoutConfiguration.dotpayConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.DOTPAY, config)
return this
}
fun CheckoutConfiguration.getDotpayConfiguration(): DotpayConfiguration? {
- return getConfiguration(DotpayConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.DOTPAY)
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
index 4b2f5a01de..ae13cb1063 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
@@ -88,14 +88,14 @@ class DropInConfiguration private constructor(
amount = amount,
analyticsConfiguration = analyticsConfiguration,
) {
- addConfiguration(this@DropInConfiguration)
+ addConfiguration(DROP_IN_CONFIG_KEY, this@DropInConfiguration)
- availablePaymentConfigs.values.forEach { paymentConfig ->
- addConfiguration(paymentConfig)
+ availablePaymentConfigs.forEach { (key, paymentConfig) ->
+ addConfiguration(key, paymentConfig)
}
- genericActionConfiguration.getAllConfigurations().forEach { actionConfig ->
- addConfiguration(actionConfig)
+ genericActionConfiguration.getAllConfigurations().forEach { config ->
+ addActionConfiguration(config)
}
}
}
@@ -442,16 +442,18 @@ class DropInConfiguration private constructor(
}
}
+private const val DROP_IN_CONFIG_KEY = "DROP_IN_CONFIG_KEY"
+
fun CheckoutConfiguration.dropInConfiguration(
configuration: Builder.() -> Unit = {}
): CheckoutConfiguration {
val config = Builder(shopperLocale, environment, clientKey)
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(DROP_IN_CONFIG_KEY, config)
return this
}
fun CheckoutConfiguration.getDropInConfiguration(): DropInConfiguration? {
- return getConfiguration(DropInConfiguration::class)
+ return getConfiguration(DROP_IN_CONFIG_KEY)
}
diff --git a/entercash/src/main/java/com/adyen/checkout/entercash/EntercashConfiguration.kt b/entercash/src/main/java/com/adyen/checkout/entercash/EntercashConfiguration.kt
index 44e25adb90..b127a23d0d 100644
--- a/entercash/src/main/java/com/adyen/checkout/entercash/EntercashConfiguration.kt
+++ b/entercash/src/main/java/com/adyen/checkout/entercash/EntercashConfiguration.kt
@@ -12,6 +12,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -50,7 +51,7 @@ class EntercashConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -92,10 +93,10 @@ fun CheckoutConfiguration.entercashConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.ENTERCASH, config)
return this
}
fun CheckoutConfiguration.getEntercashConfiguration(): EntercashConfiguration? {
- return getConfiguration(EntercashConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.ENTERCASH)
}
diff --git a/eps/src/main/java/com/adyen/checkout/eps/EPSConfiguration.kt b/eps/src/main/java/com/adyen/checkout/eps/EPSConfiguration.kt
index 7d94d4348b..04dd5d107f 100644
--- a/eps/src/main/java/com/adyen/checkout/eps/EPSConfiguration.kt
+++ b/eps/src/main/java/com/adyen/checkout/eps/EPSConfiguration.kt
@@ -12,6 +12,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -104,10 +105,10 @@ fun CheckoutConfiguration.EPSConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.EPS, config)
return this
}
fun CheckoutConfiguration.getEPSConfiguration(): EPSConfiguration? {
- return getConfiguration(EPSConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.EPS)
}
diff --git a/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt b/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt
index 55d0425bf2..3bcf2fc356 100644
--- a/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt
+++ b/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.action.core.internal.ActionHandlingPaymentMethodConfig
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.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -56,7 +57,7 @@ class GiftCardConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -69,7 +70,7 @@ class GiftCardConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
/**
@@ -122,10 +123,10 @@ fun CheckoutConfiguration.giftCardConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.GIFTCARD, config)
return this
}
fun CheckoutConfiguration.getGiftCardConfiguration(): GiftCardConfiguration? {
- return getConfiguration(GiftCardConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.GIFTCARD)
}
diff --git a/googlepay/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.kt b/googlepay/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.kt
index c8772b3548..9612beadea 100644
--- a/googlepay/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.kt
+++ b/googlepay/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.kt
@@ -395,10 +395,16 @@ fun CheckoutConfiguration.googlePayConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+
+ GooglePayComponent.PAYMENT_METHOD_TYPES.forEach { key ->
+ addConfiguration(key, config)
+ }
+
return this
}
fun CheckoutConfiguration.getGooglePayConfiguration(): GooglePayConfiguration? {
- return getConfiguration(GooglePayConfiguration::class)
+ return GooglePayComponent.PAYMENT_METHOD_TYPES.firstNotNullOfOrNull { key ->
+ getConfiguration(key)
+ }
}
diff --git a/ideal/src/main/java/com/adyen/checkout/ideal/IdealConfiguration.kt b/ideal/src/main/java/com/adyen/checkout/ideal/IdealConfiguration.kt
index 412a061335..2b9c7832a1 100644
--- a/ideal/src/main/java/com/adyen/checkout/ideal/IdealConfiguration.kt
+++ b/ideal/src/main/java/com/adyen/checkout/ideal/IdealConfiguration.kt
@@ -12,6 +12,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -92,10 +93,10 @@ fun CheckoutConfiguration.idealConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.IDEAL, config)
return this
}
fun CheckoutConfiguration.getIdealConfiguration(): IdealConfiguration? {
- return getConfiguration(IdealConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.IDEAL)
}
diff --git a/instant/src/main/java/com/adyen/checkout/instant/InstantPaymentConfiguration.kt b/instant/src/main/java/com/adyen/checkout/instant/InstantPaymentConfiguration.kt
index ec32797baa..73ad38c09a 100644
--- a/instant/src/main/java/com/adyen/checkout/instant/InstantPaymentConfiguration.kt
+++ b/instant/src/main/java/com/adyen/checkout/instant/InstantPaymentConfiguration.kt
@@ -47,7 +47,7 @@ class InstantPaymentConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -60,7 +60,7 @@ class InstantPaymentConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
override fun buildInternal(): InstantPaymentConfiguration {
@@ -76,8 +76,11 @@ class InstantPaymentConfiguration private constructor(
}
}
+private const val GLOBAL_INSTANT_CONFIG_KEY = "GLOBAL_INSTANT_CONFIG_KEY"
+
fun CheckoutConfiguration.instantPaymentConfiguration(
- configuration: InstantPaymentConfiguration.Builder.() -> Unit = {}
+ paymentMethod: String = GLOBAL_INSTANT_CONFIG_KEY,
+ configuration: InstantPaymentConfiguration.Builder.() -> Unit = {},
): CheckoutConfiguration {
val config = InstantPaymentConfiguration.Builder(shopperLocale, environment, clientKey)
.apply {
@@ -86,10 +89,12 @@ fun CheckoutConfiguration.instantPaymentConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(paymentMethod, config)
return this
}
-fun CheckoutConfiguration.getInstantPaymentConfiguration(): InstantPaymentConfiguration? {
- return getConfiguration(InstantPaymentConfiguration::class)
+fun CheckoutConfiguration.getInstantPaymentConfiguration(
+ paymentMethod: String = GLOBAL_INSTANT_CONFIG_KEY,
+): InstantPaymentConfiguration? {
+ return getConfiguration(paymentMethod)
}
diff --git a/mbway/src/main/java/com/adyen/checkout/mbway/MBWayConfiguration.kt b/mbway/src/main/java/com/adyen/checkout/mbway/MBWayConfiguration.kt
index 5e982381f0..75f7d92a55 100644
--- a/mbway/src/main/java/com/adyen/checkout/mbway/MBWayConfiguration.kt
+++ b/mbway/src/main/java/com/adyen/checkout/mbway/MBWayConfiguration.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.action.core.internal.ActionHandlingPaymentMethodConfig
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.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -107,10 +108,10 @@ fun CheckoutConfiguration.MBWayConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.MB_WAY, config)
return this
}
fun CheckoutConfiguration.getMBWayConfiguration(): MBWayConfiguration? {
- return getConfiguration(MBWayConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.MB_WAY)
}
diff --git a/molpay/src/main/java/com/adyen/checkout/molpay/MolpayConfiguration.kt b/molpay/src/main/java/com/adyen/checkout/molpay/MolpayConfiguration.kt
index 7a855acb24..8dc8fbca85 100644
--- a/molpay/src/main/java/com/adyen/checkout/molpay/MolpayConfiguration.kt
+++ b/molpay/src/main/java/com/adyen/checkout/molpay/MolpayConfiguration.kt
@@ -92,10 +92,16 @@ fun CheckoutConfiguration.molpayConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+
+ MolpayComponent.PAYMENT_METHOD_TYPES.forEach { key ->
+ addConfiguration(key, config)
+ }
+
return this
}
fun CheckoutConfiguration.getMolpayConfiguration(): MolpayConfiguration? {
- return getConfiguration(MolpayConfiguration::class)
+ return MolpayComponent.PAYMENT_METHOD_TYPES.firstNotNullOfOrNull { key ->
+ getConfiguration(key)
+ }
}
diff --git a/online-banking-cz/src/main/java/com/adyen/checkout/onlinebankingcz/OnlineBankingCZConfiguration.kt b/online-banking-cz/src/main/java/com/adyen/checkout/onlinebankingcz/OnlineBankingCZConfiguration.kt
index 029282055e..f9a7ddaf32 100644
--- a/online-banking-cz/src/main/java/com/adyen/checkout/onlinebankingcz/OnlineBankingCZConfiguration.kt
+++ b/online-banking-cz/src/main/java/com/adyen/checkout/onlinebankingcz/OnlineBankingCZConfiguration.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.onlinebankingcore.internal.OnlineBankingConfiguration
import kotlinx.parcelize.Parcelize
@@ -88,10 +89,10 @@ fun CheckoutConfiguration.onlineBankingCZConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.ONLINE_BANKING_CZ, config)
return this
}
fun CheckoutConfiguration.getOnlineBankingCZConfiguration(): OnlineBankingCZConfiguration? {
- return getConfiguration(OnlineBankingCZConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.ONLINE_BANKING_CZ)
}
diff --git a/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt b/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt
index be87e43279..2be43a3d70 100644
--- a/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt
+++ b/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.econtext.internal.EContextConfiguration
import kotlinx.parcelize.Parcelize
@@ -48,7 +49,7 @@ class OnlineBankingJPConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -88,10 +89,10 @@ fun CheckoutConfiguration.onlineBankingJPConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.ECONTEXT_ONLINE, config)
return this
}
fun CheckoutConfiguration.getOnlineBankingJPConfiguration(): OnlineBankingJPConfiguration? {
- return getConfiguration(OnlineBankingJPConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.ECONTEXT_ONLINE)
}
diff --git a/online-banking-pl/src/main/java/com/adyen/checkout/onlinebankingpl/OnlineBankingPLConfiguration.kt b/online-banking-pl/src/main/java/com/adyen/checkout/onlinebankingpl/OnlineBankingPLConfiguration.kt
index e0a6a05229..bfdb63b693 100644
--- a/online-banking-pl/src/main/java/com/adyen/checkout/onlinebankingpl/OnlineBankingPLConfiguration.kt
+++ b/online-banking-pl/src/main/java/com/adyen/checkout/onlinebankingpl/OnlineBankingPLConfiguration.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -93,10 +94,10 @@ fun CheckoutConfiguration.onlineBankingPLConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.ONLINE_BANKING_PL, config)
return this
}
fun CheckoutConfiguration.getOnlineBankingPLConfiguration(): OnlineBankingPLConfiguration? {
- return getConfiguration(OnlineBankingPLConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.ONLINE_BANKING_PL)
}
diff --git a/online-banking-sk/src/main/java/com/adyen/checkout/onlinebankingsk/OnlineBankingSKConfiguration.kt b/online-banking-sk/src/main/java/com/adyen/checkout/onlinebankingsk/OnlineBankingSKConfiguration.kt
index 14e774d463..e02325e79a 100644
--- a/online-banking-sk/src/main/java/com/adyen/checkout/onlinebankingsk/OnlineBankingSKConfiguration.kt
+++ b/online-banking-sk/src/main/java/com/adyen/checkout/onlinebankingsk/OnlineBankingSKConfiguration.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.onlinebankingcore.internal.OnlineBankingConfiguration
import kotlinx.parcelize.Parcelize
@@ -88,10 +89,10 @@ fun CheckoutConfiguration.onlineBankingSKConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.ONLINE_BANKING_SK, config)
return this
}
fun CheckoutConfiguration.getOnlineBankingSKConfiguration(): OnlineBankingSKConfiguration? {
- return getConfiguration(OnlineBankingSKConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.ONLINE_BANKING_SK)
}
diff --git a/openbanking/src/main/java/com/adyen/checkout/openbanking/OpenBankingConfiguration.kt b/openbanking/src/main/java/com/adyen/checkout/openbanking/OpenBankingConfiguration.kt
index bb292be87e..47ff6e313c 100644
--- a/openbanking/src/main/java/com/adyen/checkout/openbanking/OpenBankingConfiguration.kt
+++ b/openbanking/src/main/java/com/adyen/checkout/openbanking/OpenBankingConfiguration.kt
@@ -12,6 +12,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.issuerlist.IssuerListViewType
import com.adyen.checkout.issuerlist.internal.IssuerListConfiguration
@@ -92,10 +93,10 @@ fun CheckoutConfiguration.openBankingConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.OPEN_BANKING, config)
return this
}
fun CheckoutConfiguration.getOpenBankingConfiguration(): OpenBankingConfiguration? {
- return getConfiguration(OpenBankingConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.OPEN_BANKING)
}
diff --git a/paybybank/src/main/java/com/adyen/checkout/paybybank/PayByBankConfiguration.kt b/paybybank/src/main/java/com/adyen/checkout/paybybank/PayByBankConfiguration.kt
index 2eb6af6235..4e9c5fac4e 100644
--- a/paybybank/src/main/java/com/adyen/checkout/paybybank/PayByBankConfiguration.kt
+++ b/paybybank/src/main/java/com/adyen/checkout/paybybank/PayByBankConfiguration.kt
@@ -14,6 +14,7 @@ import com.adyen.checkout.action.core.internal.ActionHandlingPaymentMethodConfig
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.core.Environment
import kotlinx.parcelize.Parcelize
@@ -85,10 +86,10 @@ fun CheckoutConfiguration.payByBankConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.PAY_BY_BANK, config)
return this
}
fun CheckoutConfiguration.getPayByBankConfiguration(): PayByBankConfiguration? {
- return getConfiguration(PayByBankConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.PAY_BY_BANK)
}
diff --git a/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt b/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt
index 81ffa09b90..c56682848d 100644
--- a/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt
+++ b/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.econtext.internal.EContextConfiguration
import kotlinx.parcelize.Parcelize
@@ -48,7 +49,7 @@ class PayEasyConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -88,10 +89,10 @@ fun CheckoutConfiguration.payEasyConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.ECONTEXT_ATM, config)
return this
}
fun CheckoutConfiguration.getPayEasyConfiguration(): PayEasyConfiguration? {
- return getConfiguration(PayEasyConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.ECONTEXT_ATM)
}
diff --git a/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt b/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt
index 2326712479..9ed8c61622 100644
--- a/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt
+++ b/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt
@@ -83,10 +83,10 @@ fun CheckoutConfiguration.QRCodeConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addActionConfiguration(config)
return this
}
fun CheckoutConfiguration.getQRCodeConfiguration(): QRCodeConfiguration? {
- return getConfiguration(QRCodeConfiguration::class)
+ return getActionConfiguration(QRCodeConfiguration::class.java)
}
diff --git a/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt b/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt
index 94cbaa2b0d..2736943be0 100644
--- a/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt
+++ b/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt
@@ -82,10 +82,10 @@ fun CheckoutConfiguration.redirectConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addActionConfiguration(config)
return this
}
fun CheckoutConfiguration.getRedirectConfiguration(): RedirectConfiguration? {
- return getConfiguration(RedirectConfiguration::class)
+ return getActionConfiguration(RedirectConfiguration::class.java)
}
diff --git a/sepa/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.kt b/sepa/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.kt
index 92c79ea61e..61819672a0 100644
--- a/sepa/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.kt
+++ b/sepa/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.action.core.internal.ActionHandlingPaymentMethodConfig
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.ButtonConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -106,10 +107,10 @@ fun CheckoutConfiguration.sepaConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.SEPA, config)
return this
}
fun CheckoutConfiguration.getSepaConfiguration(): SepaConfiguration? {
- return getConfiguration(SepaConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.SEPA)
}
diff --git a/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt b/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt
index af3b8ee8a6..a92ed5eb80 100644
--- a/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt
+++ b/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
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.core.Environment
import com.adyen.checkout.econtext.internal.EContextConfiguration
import kotlinx.parcelize.Parcelize
@@ -88,10 +89,10 @@ fun CheckoutConfiguration.sevenElevenConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addConfiguration(PaymentMethodTypes.ECONTEXT_SEVEN_ELEVEN, config)
return this
}
fun CheckoutConfiguration.getSevenElevenConfiguration(): SevenElevenConfiguration? {
- return getConfiguration(SevenElevenConfiguration::class)
+ return getConfiguration(PaymentMethodTypes.ECONTEXT_SEVEN_ELEVEN)
}
diff --git a/upi/src/main/java/com/adyen/checkout/upi/UPIConfiguration.kt b/upi/src/main/java/com/adyen/checkout/upi/UPIConfiguration.kt
index 7854dc62d9..9ffe937372 100644
--- a/upi/src/main/java/com/adyen/checkout/upi/UPIConfiguration.kt
+++ b/upi/src/main/java/com/adyen/checkout/upi/UPIConfiguration.kt
@@ -106,10 +106,16 @@ fun CheckoutConfiguration.UPIConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+
+ UPIComponent.PAYMENT_METHOD_TYPES.forEach { key ->
+ addConfiguration(key, config)
+ }
+
return this
}
fun CheckoutConfiguration.getUPIConfiguration(): UPIConfiguration? {
- return getConfiguration(UPIConfiguration::class)
+ return UPIComponent.PAYMENT_METHOD_TYPES.firstNotNullOfOrNull { key ->
+ getConfiguration(key)
+ }
}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt b/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt
index 29461cee46..ff06ef92e3 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt
@@ -83,10 +83,10 @@ fun CheckoutConfiguration.voucherConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addActionConfiguration(config)
return this
}
fun CheckoutConfiguration.getVoucherConfiguration(): VoucherConfiguration? {
- return getConfiguration(VoucherConfiguration::class)
+ return getActionConfiguration(VoucherConfiguration::class.java)
}
diff --git a/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt b/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt
index cb238ae269..7e51f5f984 100644
--- a/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt
+++ b/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt
@@ -82,10 +82,10 @@ fun CheckoutConfiguration.weChatPayActionConfiguration(
}
.apply(configuration)
.build()
- addConfiguration(config)
+ addActionConfiguration(config)
return this
}
fun CheckoutConfiguration.getWeChatPayActionConfiguration(): WeChatPayActionConfiguration? {
- return getConfiguration(WeChatPayActionConfiguration::class)
+ return getActionConfiguration(WeChatPayActionConfiguration::class.java)
}
From c5e26af7099f9fc201551b8935118f6894beac8f Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Tue, 12 Dec 2023 17:42:21 +0100
Subject: [PATCH 043/255] Replace usage of DropInConfiguration with
CheckoutConfiguration
COAND-811
---
.../data/api/OrderStatusRepository.kt | 5 +-
.../checkout/dropin/DropInConfiguration.kt | 8 --
.../provider/ComponentParsingProvider.kt | 72 ++++++------
.../provider/ConfigurationParsingProvider.kt | 108 +++++++++---------
.../PaymentMethodAvailabilityProvider.kt | 29 ++---
.../ui/ActionComponentDialogFragment.kt | 24 ++--
.../ui/BaseComponentDialogFragment.kt | 4 +-
.../dropin/internal/ui/DropInActivity.kt | 5 +-
.../dropin/internal/ui/DropInViewModel.kt | 20 ++--
.../ui/GiftCardComponentDialogFragment.kt | 2 +-
...ftCardPaymentConfirmationDialogFragment.kt | 4 +-
.../ui/GooglePayComponentDialogFragment.kt | 2 +-
.../ui/PaymentMethodListDialogFragment.kt | 24 ++--
.../ui/PaymentMethodsListViewModel.kt | 38 +++---
.../PreselectedStoredPaymentMethodFragment.kt | 16 +--
.../ui/PreselectedStoredPaymentViewModel.kt | 12 +-
.../dropin/internal/ConfigurationProvider.kt | 55 ++++-----
.../ui/PaymentMethodsListViewModelTest.kt | 101 ++++++++--------
.../PreselectedStoredPaymentViewModelTest.kt | 15 +--
19 files changed, 264 insertions(+), 280 deletions(-)
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/internal/data/api/OrderStatusRepository.kt b/components-core/src/main/java/com/adyen/checkout/components/core/internal/data/api/OrderStatusRepository.kt
index 25a0ce0b38..03d5c6647e 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/internal/data/api/OrderStatusRepository.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/internal/data/api/OrderStatusRepository.kt
@@ -9,7 +9,6 @@
package com.adyen.checkout.components.core.internal.data.api
import androidx.annotation.RestrictTo
-import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.components.core.internal.data.model.OrderStatusRequest
import com.adyen.checkout.components.core.internal.data.model.OrderStatusResponse
import com.adyen.checkout.core.internal.util.LogUtil
@@ -22,7 +21,7 @@ class OrderStatusRepository(
) {
suspend fun getOrderStatus(
- configuration: Configuration,
+ clientKey: String,
orderData: String
): Result = runSuspendCatching {
Logger.d(TAG, "Getting order status")
@@ -30,7 +29,7 @@ class OrderStatusRepository(
val request = OrderStatusRequest(orderData)
orderStatusService.getOrderStatus(
request,
- configuration.clientKey
+ clientKey
)
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
index ae13cb1063..489a38f841 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
@@ -72,14 +72,6 @@ class DropInConfiguration private constructor(
internal val overriddenPaymentMethodInformation: HashMap,
) : Configuration {
- internal fun getConfigurationForPaymentMethod(paymentMethod: String): T? {
- if (availablePaymentConfigs.containsKey(paymentMethod)) {
- @Suppress("UNCHECKED_CAST")
- return availablePaymentConfigs[paymentMethod] as T
- }
- return null
- }
-
internal fun toCheckoutConfiguration(): CheckoutConfiguration {
return CheckoutConfiguration(
shopperLocale = shopperLocale,
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
index 5ff742e55c..34b72b279b 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
@@ -38,6 +38,7 @@ import com.adyen.checkout.cashapppay.CashAppPayComponentState
import com.adyen.checkout.cashapppay.CashAppPayConfiguration
import com.adyen.checkout.cashapppay.internal.provider.CashAppPayComponentProvider
import com.adyen.checkout.components.core.Amount
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.ComponentCallback
import com.adyen.checkout.components.core.PaymentMethod
import com.adyen.checkout.components.core.StoredPaymentMethod
@@ -54,6 +55,7 @@ import com.adyen.checkout.dotpay.DotpayComponentState
import com.adyen.checkout.dotpay.DotpayConfiguration
import com.adyen.checkout.dotpay.internal.provider.DotpayComponentProvider
import com.adyen.checkout.dropin.DropInConfiguration
+import com.adyen.checkout.dropin.getDropInConfiguration
import com.adyen.checkout.dropin.internal.ui.model.DropInComponentParams
import com.adyen.checkout.dropin.internal.ui.model.DropInComponentParamsMapper
import com.adyen.checkout.dropin.internal.util.checkCompileOnly
@@ -143,19 +145,19 @@ import com.adyen.checkout.upi.internal.provider.UPIComponentProvider
internal fun getComponentFor(
fragment: Fragment,
storedPaymentMethod: StoredPaymentMethod,
- dropInConfiguration: DropInConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
amount: Amount?,
componentCallback: ComponentCallback<*>,
sessionDetails: SessionDetails?,
analyticsRepository: AnalyticsRepository,
onRedirect: () -> Unit,
): PaymentComponent {
- val dropInParams = dropInConfiguration.mapToParams(amount)
+ val dropInParams = checkoutConfiguration.getDropInConfiguration()?.mapToParams(amount)
val sessionParams = sessionDetails?.mapToParams(amount)
return when {
checkCompileOnly { ACHDirectDebitComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
val achConfig: ACHDirectDebitConfiguration =
- getConfigurationForPaymentMethod(storedPaymentMethod, dropInConfiguration)
+ getConfigurationForPaymentMethod(storedPaymentMethod, checkoutConfiguration)
ACHDirectDebitComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
storedPaymentMethod = storedPaymentMethod,
@@ -167,7 +169,7 @@ internal fun getComponentFor(
checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
val cardConfig: CardConfiguration =
- getConfigurationForPaymentMethod(storedPaymentMethod, dropInConfiguration)
+ getConfigurationForPaymentMethod(storedPaymentMethod, checkoutConfiguration)
CardComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
storedPaymentMethod = storedPaymentMethod,
@@ -179,7 +181,7 @@ internal fun getComponentFor(
checkCompileOnly { CashAppPayComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
val cashAppPayConfig: CashAppPayConfiguration =
- getConfigurationForPaymentMethod(storedPaymentMethod, dropInConfiguration)
+ getConfigurationForPaymentMethod(storedPaymentMethod, checkoutConfiguration)
CashAppPayComponentProvider(dropInParams, sessionParams).get(
fragment = fragment,
storedPaymentMethod = storedPaymentMethod,
@@ -191,7 +193,7 @@ internal fun getComponentFor(
checkCompileOnly { BlikComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
val blikConfig: BlikConfiguration =
- getConfigurationForPaymentMethod(storedPaymentMethod, dropInConfiguration)
+ getConfigurationForPaymentMethod(storedPaymentMethod, checkoutConfiguration)
BlikComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
storedPaymentMethod = storedPaymentMethod,
@@ -220,20 +222,20 @@ internal fun getComponentFor(
internal fun getComponentFor(
fragment: Fragment,
paymentMethod: PaymentMethod,
- dropInConfiguration: DropInConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
amount: Amount?,
componentCallback: ComponentCallback<*>,
sessionDetails: SessionDetails?,
analyticsRepository: AnalyticsRepository,
onRedirect: () -> Unit,
): PaymentComponent {
- val dropInParams = dropInConfiguration.mapToParams(amount)
+ val dropInParams = checkoutConfiguration.getDropInConfiguration()?.mapToParams(amount)
val sessionParams = sessionDetails?.mapToParams(amount)
val context = fragment.requireContext()
return when {
checkCompileOnly { ACHDirectDebitComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val configuration: ACHDirectDebitConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
ACHDirectDebitComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -244,7 +246,7 @@ internal fun getComponentFor(
checkCompileOnly { BacsDirectDebitComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val bacsConfiguration: BacsDirectDebitConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
BacsDirectDebitComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -255,7 +257,7 @@ internal fun getComponentFor(
checkCompileOnly { BcmcComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val bcmcConfiguration: BcmcConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
BcmcComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -266,7 +268,7 @@ internal fun getComponentFor(
checkCompileOnly { BlikComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val blikConfiguration: BlikConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
BlikComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -277,7 +279,7 @@ internal fun getComponentFor(
checkCompileOnly { BoletoComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val boletoConfiguration: BoletoConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
BoletoComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -288,7 +290,7 @@ internal fun getComponentFor(
checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val cardConfig: CardConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
CardComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -299,7 +301,7 @@ internal fun getComponentFor(
checkCompileOnly { CashAppPayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val cashAppPayConfiguration: CashAppPayConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
CashAppPayComponentProvider(dropInParams, sessionParams).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -310,7 +312,7 @@ internal fun getComponentFor(
checkCompileOnly { ConvenienceStoresJPComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val convenienceStoresJPConfiguration: ConvenienceStoresJPConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
ConvenienceStoresJPComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -321,7 +323,7 @@ internal fun getComponentFor(
checkCompileOnly { DotpayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val dotpayConfig: DotpayConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
DotpayComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -332,7 +334,7 @@ internal fun getComponentFor(
checkCompileOnly { EntercashComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val entercashConfig: EntercashConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
EntercashComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -343,7 +345,7 @@ internal fun getComponentFor(
checkCompileOnly { EPSComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val epsConfig: EPSConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
EPSComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -354,7 +356,7 @@ internal fun getComponentFor(
checkCompileOnly { GiftCardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val giftcardConfiguration: GiftCardConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
GiftCardComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -365,7 +367,7 @@ internal fun getComponentFor(
checkCompileOnly { GooglePayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val googlePayConfiguration: GooglePayConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
GooglePayComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -376,7 +378,7 @@ internal fun getComponentFor(
checkCompileOnly { IdealComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val idealConfig: IdealConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
IdealComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -387,7 +389,7 @@ internal fun getComponentFor(
checkCompileOnly { InstantPaymentComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val instantPaymentConfiguration: InstantPaymentConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
InstantPaymentComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -398,7 +400,7 @@ internal fun getComponentFor(
checkCompileOnly { MBWayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val mbWayConfiguration: MBWayConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
MBWayComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -409,7 +411,7 @@ internal fun getComponentFor(
checkCompileOnly { MolpayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val molpayConfig: MolpayConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
MolpayComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -420,7 +422,7 @@ internal fun getComponentFor(
checkCompileOnly { OnlineBankingCZComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val onlineBankingCZConfig: OnlineBankingCZConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
OnlineBankingCZComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -431,7 +433,7 @@ internal fun getComponentFor(
checkCompileOnly { OnlineBankingJPComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val onlineBankingJPConfig: OnlineBankingJPConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
OnlineBankingJPComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -442,7 +444,7 @@ internal fun getComponentFor(
checkCompileOnly { OnlineBankingPLComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val onlineBankingPLConfig: OnlineBankingPLConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
OnlineBankingPLComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -453,7 +455,7 @@ internal fun getComponentFor(
checkCompileOnly { OnlineBankingSKComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val onlineBankingSKConfig: OnlineBankingSKConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
OnlineBankingSKComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -464,7 +466,7 @@ internal fun getComponentFor(
checkCompileOnly { OpenBankingComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val openBankingConfig: OpenBankingConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
OpenBankingComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -475,7 +477,7 @@ internal fun getComponentFor(
checkCompileOnly { PayByBankComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val payByBankConfig: PayByBankConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
PayByBankComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -486,7 +488,7 @@ internal fun getComponentFor(
checkCompileOnly { PayEasyComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val payEasyConfiguration: PayEasyConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
PayEasyComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -497,7 +499,7 @@ internal fun getComponentFor(
checkCompileOnly { SepaComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val sepaConfiguration: SepaConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
SepaComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -508,7 +510,7 @@ internal fun getComponentFor(
checkCompileOnly { SevenElevenComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val sevenElevenConfiguration: SevenElevenConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
SevenElevenComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
@@ -519,7 +521,7 @@ internal fun getComponentFor(
checkCompileOnly { UPIComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val upiConfiguration: UPIConfiguration =
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
+ getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
UPIComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt
index 6b7fa80230..e1d0de2fd1 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt
@@ -23,6 +23,7 @@ import com.adyen.checkout.card.CardComponent
import com.adyen.checkout.card.CardConfiguration
import com.adyen.checkout.cashapppay.CashAppPayComponent
import com.adyen.checkout.cashapppay.CashAppPayConfiguration
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethod
import com.adyen.checkout.components.core.StoredPaymentMethod
import com.adyen.checkout.components.core.internal.BaseConfigurationBuilder
@@ -32,7 +33,6 @@ import com.adyen.checkout.conveniencestoresjp.ConvenienceStoresJPConfiguration
import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.dotpay.DotpayComponent
import com.adyen.checkout.dotpay.DotpayConfiguration
-import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.dropin.internal.util.checkCompileOnly
import com.adyen.checkout.entercash.EntercashComponent
import com.adyen.checkout.entercash.EntercashConfiguration
@@ -73,13 +73,13 @@ import com.adyen.checkout.upi.UPIConfiguration
internal inline fun getConfigurationForPaymentMethod(
paymentMethod: PaymentMethod,
- dropInConfiguration: DropInConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
context: Context,
): T {
val paymentMethodType = paymentMethod.type ?: throw CheckoutException("Payment method type is null")
- return dropInConfiguration.getConfigurationForPaymentMethod(paymentMethodType) ?: getDefaultConfigForPaymentMethod(
+ return checkoutConfiguration.getConfiguration(paymentMethodType) ?: getDefaultConfigForPaymentMethod(
paymentMethod,
- dropInConfiguration,
+ checkoutConfiguration,
context,
)
}
@@ -87,12 +87,12 @@ internal inline fun getConfigurationForPaymentMethod
@Suppress("LongMethod", "CyclomaticComplexMethod")
internal fun getDefaultConfigForPaymentMethod(
paymentMethod: PaymentMethod,
- dropInConfiguration: DropInConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
context: Context,
): T {
- val shopperLocale = dropInConfiguration.shopperLocale
- val environment = dropInConfiguration.environment
- val clientKey = dropInConfiguration.clientKey
+ val shopperLocale = checkoutConfiguration.shopperLocale
+ val environment = checkoutConfiguration.environment
+ val clientKey = checkoutConfiguration.clientKey
// get default builder for Configuration type
val builder: BaseConfigurationBuilder<*, *> = when {
@@ -100,49 +100,49 @@ internal fun getDefaultConfigForPaymentMethod(
ACHDirectDebitConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { BacsDirectDebitComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
BacsDirectDebitConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { BcmcComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
BcmcConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { BlikComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
BlikConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { BoletoComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
BoletoConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
CardConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { CashAppPayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
CashAppPayConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
.setReturnUrl(CashAppPayComponent.getReturnUrl(context))
@@ -150,133 +150,133 @@ internal fun getDefaultConfigForPaymentMethod(
ConvenienceStoresJPConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { DotpayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
DotpayConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { EntercashComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
EntercashConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { EPSComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
EPSConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { GiftCardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
GiftCardConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { GooglePayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
GooglePayConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { IdealComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
IdealConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { InstantPaymentComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
InstantPaymentConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { MBWayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
MBWayConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { MolpayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
MolpayConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { OnlineBankingCZComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
OnlineBankingCZConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { OnlineBankingJPComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
OnlineBankingJPConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { OnlineBankingPLComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
OnlineBankingPLConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { OnlineBankingSKComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
OnlineBankingSKConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { OpenBankingComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
OpenBankingConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { PayByBankComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
PayByBankConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { PayEasyComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
PayEasyConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { SepaComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
SepaConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { SevenElevenComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
SevenElevenConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { UPIComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } ->
@@ -295,54 +295,54 @@ internal fun getDefaultConfigForPaymentMethod(
internal inline fun getConfigurationForPaymentMethod(
storedPaymentMethod: StoredPaymentMethod,
- dropInConfiguration: DropInConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
): T {
val storedPaymentMethodType = storedPaymentMethod.type ?: throw CheckoutException("Payment method type is null")
- return dropInConfiguration.getConfigurationForPaymentMethod(storedPaymentMethodType)
- ?: getDefaultConfigForPaymentMethod(
- storedPaymentMethod = storedPaymentMethod,
- dropInConfiguration = dropInConfiguration
- )
+ return checkoutConfiguration.getConfiguration(storedPaymentMethodType) ?: getDefaultConfigForPaymentMethod(
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = checkoutConfiguration,
+ )
}
internal fun getDefaultConfigForPaymentMethod(
storedPaymentMethod: StoredPaymentMethod,
- dropInConfiguration: DropInConfiguration
+ checkoutConfiguration: CheckoutConfiguration,
): T {
- val shopperLocale = dropInConfiguration.shopperLocale
- val environment = dropInConfiguration.environment
- val clientKey = dropInConfiguration.clientKey
+ val shopperLocale = checkoutConfiguration.shopperLocale
+ val environment = checkoutConfiguration.environment
+ val clientKey = checkoutConfiguration.clientKey
+
val builder: BaseConfigurationBuilder<*, *> = when {
checkCompileOnly { ACHDirectDebitComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
ACHDirectDebitConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { BlikComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
BlikConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
CardConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
checkCompileOnly { CashAppPayComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } ->
CashAppPayConfiguration.Builder(
shopperLocale = shopperLocale,
environment = environment,
- clientKey = clientKey
+ clientKey = clientKey,
)
else -> throw CheckoutException(
- errorMessage = "Unable to find component configuration for storedPaymentMethod - $storedPaymentMethod"
+ errorMessage = "Unable to find component configuration for storedPaymentMethod - $storedPaymentMethod",
)
}
@Suppress("UNCHECKED_CAST")
@@ -351,13 +351,7 @@ internal fun getDefaultConfigForPaymentMethod(
internal inline fun getConfigurationForPaymentMethodOrNull(
paymentMethod: PaymentMethod,
- dropInConfiguration: DropInConfiguration,
- context: Context,
+ checkoutConfiguration: CheckoutConfiguration,
): T? {
- @Suppress("SwallowedException")
- return try {
- getConfigurationForPaymentMethod(paymentMethod, dropInConfiguration, context)
- } catch (e: CheckoutException) {
- null
- }
+ return checkoutConfiguration.getConfiguration(paymentMethod.type ?: "")
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt
index e613cc6ec1..c926bbd1c3 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt
@@ -9,7 +9,7 @@
package com.adyen.checkout.dropin.internal.provider
import android.app.Application
-import com.adyen.checkout.components.core.Amount
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.ComponentAvailableCallback
import com.adyen.checkout.components.core.PaymentMethod
import com.adyen.checkout.components.core.PaymentMethodTypes
@@ -17,14 +17,13 @@ import com.adyen.checkout.components.core.internal.AlwaysAvailablePaymentMethod
import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.components.core.internal.NotAvailablePaymentMethod
import com.adyen.checkout.components.core.internal.PaymentMethodAvailabilityCheck
+import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.internal.util.LogUtil
import com.adyen.checkout.core.internal.util.Logger
import com.adyen.checkout.core.internal.util.runCompileOnly
-import com.adyen.checkout.dropin.DropInConfiguration
+import com.adyen.checkout.dropin.internal.ui.model.DropInComponentParams
import com.adyen.checkout.googlepay.internal.provider.GooglePayComponentProvider
-import com.adyen.checkout.sessions.core.internal.data.model.SessionDetails
-import com.adyen.checkout.sessions.core.internal.data.model.mapToParams
import com.adyen.checkout.wechatpay.WeChatPayProvider
private val TAG = LogUtil.getTag()
@@ -33,9 +32,9 @@ private val TAG = LogUtil.getTag()
internal fun checkPaymentMethodAvailability(
application: Application,
paymentMethod: PaymentMethod,
- dropInConfiguration: DropInConfiguration,
- amount: Amount?,
- sessionDetails: SessionDetails?,
+ checkoutConfiguration: CheckoutConfiguration,
+ dropInComponentParams: DropInComponentParams,
+ sessionParams: SessionParams?,
callback: ComponentAvailableCallback,
) {
try {
@@ -43,9 +42,9 @@ internal fun checkPaymentMethodAvailability(
val type = paymentMethod.type ?: throw CheckoutException("PaymentMethod type is null")
- val availabilityCheck = getPaymentMethodAvailabilityCheck(dropInConfiguration, type, amount, sessionDetails)
+ val availabilityCheck = getPaymentMethodAvailabilityCheck(dropInComponentParams, type, sessionParams)
val configuration =
- getConfigurationForPaymentMethodOrNull(paymentMethod, dropInConfiguration, application)
+ getConfigurationForPaymentMethodOrNull(paymentMethod, checkoutConfiguration)
availabilityCheck.isAvailable(application, paymentMethod, configuration, callback)
} catch (e: CheckoutException) {
@@ -57,20 +56,16 @@ internal fun checkPaymentMethodAvailability(
/**
* Provides the [PaymentMethodAvailabilityCheck] class for the specified [paymentMethodType], if available.
*/
-internal fun getPaymentMethodAvailabilityCheck(
- dropInConfiguration: DropInConfiguration,
+private fun getPaymentMethodAvailabilityCheck(
+ dropInComponentParams: DropInComponentParams,
paymentMethodType: String,
- amount: Amount?,
- sessionDetails: SessionDetails?,
+ sessionParams: SessionParams?,
): PaymentMethodAvailabilityCheck {
- val dropInParams = dropInConfiguration.mapToParams(amount)
- val sessionParams = sessionDetails?.mapToParams(amount)
-
@Suppress("UNCHECKED_CAST")
val availabilityCheck = when (paymentMethodType) {
PaymentMethodTypes.GOOGLE_PAY,
PaymentMethodTypes.GOOGLE_PAY_LEGACY -> runCompileOnly {
- GooglePayComponentProvider(dropInParams, sessionParams)
+ GooglePayComponentProvider(dropInComponentParams, sessionParams)
}
PaymentMethodTypes.WECHAT_PAY_SDK -> runCompileOnly { WeChatPayProvider() }
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/ActionComponentDialogFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/ActionComponentDialogFragment.kt
index ae6a2efafb..9203bdf57b 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/ActionComponentDialogFragment.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/ActionComponentDialogFragment.kt
@@ -25,6 +25,7 @@ import com.adyen.checkout.action.core.GenericActionConfiguration
import com.adyen.checkout.action.core.internal.provider.GenericActionComponentProvider
import com.adyen.checkout.components.core.ActionComponentCallback
import com.adyen.checkout.components.core.ActionComponentData
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.ComponentError
import com.adyen.checkout.components.core.action.Action
import com.adyen.checkout.core.PermissionHandlerCallback
@@ -34,7 +35,6 @@ import com.adyen.checkout.core.internal.util.LogUtil
import com.adyen.checkout.core.internal.util.Logger
import com.adyen.checkout.dropin.R
import com.adyen.checkout.dropin.databinding.FragmentGenericActionComponentBinding
-import com.adyen.checkout.dropin.internal.provider.mapToParams
import com.adyen.checkout.dropin.internal.util.arguments
import com.google.android.material.bottomsheet.BottomSheetBehavior
import kotlinx.coroutines.flow.launchIn
@@ -51,7 +51,7 @@ internal class ActionComponentDialogFragment :
private val actionComponentViewModel: ActionComponentViewModel by viewModels()
private val action: Action by arguments(ACTION)
- private val actionConfiguration: GenericActionConfiguration by arguments(ACTION_CONFIGURATION)
+ private val checkoutConfiguration: CheckoutConfiguration by arguments(CHECKOUT_CONFIGURATION)
private lateinit var actionComponent: GenericActionComponent
private var permissionCallback: PermissionHandlerCallback? = null
@@ -94,10 +94,10 @@ internal class ActionComponentDialogFragment :
binding.header.isVisible = false
try {
- val componentParams = dropInViewModel.dropInConfiguration.mapToParams(dropInViewModel.amount)
- actionComponent = GenericActionComponentProvider(componentParams).get(
+ actionComponent = GenericActionComponentProvider(dropInViewModel.dropInComponentParams).get(
fragment = this,
- configuration = actionConfiguration,
+ // TODO: Pass checkoutConfig when components accept it
+ configuration = createActionConfiguration(),
callback = this,
)
@@ -116,6 +116,14 @@ internal class ActionComponentDialogFragment :
}
}
+ private fun createActionConfiguration(): GenericActionConfiguration {
+ return GenericActionConfiguration.Builder(
+ checkoutConfiguration.shopperLocale,
+ checkoutConfiguration.environment,
+ checkoutConfiguration.clientKey,
+ ).build()
+ }
+
override fun onAdditionalDetails(actionComponentData: ActionComponentData) {
onActionComponentDataChanged(actionComponentData)
}
@@ -218,15 +226,15 @@ internal class ActionComponentDialogFragment :
private val TAG = LogUtil.getTag()
const val ACTION = "ACTION"
- const val ACTION_CONFIGURATION = "ACTION_CONFIGURATION"
+ const val CHECKOUT_CONFIGURATION = "CHECKOUT_CONFIGURATION"
fun newInstance(
action: Action,
- actionConfiguration: GenericActionConfiguration
+ checkoutConfiguration: CheckoutConfiguration,
): ActionComponentDialogFragment {
val args = Bundle()
args.putParcelable(ACTION, action)
- args.putParcelable(ACTION_CONFIGURATION, actionConfiguration)
+ args.putParcelable(CHECKOUT_CONFIGURATION, checkoutConfiguration)
val componentDialogFragment = ActionComponentDialogFragment()
componentDialogFragment.arguments = args
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/BaseComponentDialogFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/BaseComponentDialogFragment.kt
index 0984e20207..3199db0779 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/BaseComponentDialogFragment.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/BaseComponentDialogFragment.kt
@@ -110,7 +110,7 @@ internal abstract class BaseComponentDialogFragment :
getComponentFor(
fragment = this,
storedPaymentMethod = storedPaymentMethod,
- dropInConfiguration = dropInViewModel.dropInConfiguration,
+ checkoutConfiguration = dropInViewModel.checkoutConfiguration,
amount = dropInViewModel.amount,
componentCallback = this,
sessionDetails = dropInViewModel.sessionDetails,
@@ -122,7 +122,7 @@ internal abstract class BaseComponentDialogFragment :
fragment = this,
paymentMethod = paymentMethod,
sessionDetails = dropInViewModel.sessionDetails,
- dropInConfiguration = dropInViewModel.dropInConfiguration,
+ checkoutConfiguration = dropInViewModel.checkoutConfiguration,
amount = dropInViewModel.amount,
componentCallback = this,
analyticsRepository = dropInViewModel.analyticsRepository,
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt
index 73d3783579..1344b9f166 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInActivity.kt
@@ -216,7 +216,7 @@ internal class DropInActivity :
context = this,
connection = serviceConnection,
merchantService = dropInViewModel.serviceComponentName,
- additionalData = dropInViewModel.dropInConfiguration.additionalDataForDropInService,
+ additionalData = dropInViewModel.dropInComponentParams.additionalDataForDropInService,
)
if (bound) {
serviceBound = true
@@ -472,8 +472,7 @@ internal class DropInActivity :
Logger.d(TAG, "showActionDialog")
setLoading(false)
hideAllScreens()
- val actionConfiguration = dropInViewModel.dropInConfiguration.genericActionConfiguration
- val actionFragment = ActionComponentDialogFragment.newInstance(action, actionConfiguration)
+ val actionFragment = ActionComponentDialogFragment.newInstance(action, dropInViewModel.checkoutConfiguration)
actionFragment.show(supportFragmentManager, ACTION_FRAGMENT_TAG)
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt
index a87030bc12..ac26de2dd7 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/DropInViewModel.kt
@@ -29,10 +29,11 @@ import com.adyen.checkout.components.core.paymentmethod.GiftCardPaymentMethod
import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.internal.util.LogUtil
import com.adyen.checkout.core.internal.util.Logger
-import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.dropin.R
import com.adyen.checkout.dropin.getDropInConfiguration
+import com.adyen.checkout.dropin.internal.provider.mapToParams
import com.adyen.checkout.dropin.internal.ui.model.DropInActivityEvent
+import com.adyen.checkout.dropin.internal.ui.model.DropInComponentParams
import com.adyen.checkout.dropin.internal.ui.model.DropInDestination
import com.adyen.checkout.dropin.internal.ui.model.GiftCardPaymentConfirmationData
import com.adyen.checkout.dropin.internal.ui.model.OrderModel
@@ -61,7 +62,8 @@ internal class DropInViewModel(
val checkoutConfiguration: CheckoutConfiguration = requireNotNull(bundleHandler.checkoutConfiguration)
- val dropInConfiguration: DropInConfiguration = requireNotNull(checkoutConfiguration.getDropInConfiguration())
+ val dropInComponentParams: DropInComponentParams =
+ requireNotNull(checkoutConfiguration.getDropInConfiguration()).mapToParams(checkoutConfiguration.amount)
val serviceComponentName: ComponentName = requireNotNull(bundleHandler.serviceComponentName)
@@ -123,7 +125,7 @@ internal class DropInViewModel(
fun shouldShowPreselectedStored(): Boolean {
return getStoredPaymentMethods().any { it.isStoredPaymentSupported() } &&
- dropInConfiguration.showPreselectedStoredPaymentMethod
+ dropInComponentParams.showPreselectedStoredPaymentMethod
}
fun getPreselectedStoredPaymentMethod(): StoredPaymentMethod {
@@ -137,7 +139,7 @@ internal class DropInViewModel(
}
fun shouldSkipToSinglePaymentMethod(): Boolean {
- if (!dropInConfiguration.skipListWhenSinglePaymentMethod) return false
+ if (!dropInComponentParams.skipListWhenSinglePaymentMethod) return false
val noStored = getStoredPaymentMethods().isEmpty()
val singlePm = getPaymentMethods().size == 1
@@ -155,7 +157,7 @@ internal class DropInViewModel(
}
private fun getInitialAmount(): Amount? {
- return sessionDetails?.amount ?: dropInConfiguration.amount
+ return sessionDetails?.amount ?: dropInComponentParams.amount
}
fun onCreated() {
@@ -172,8 +174,8 @@ internal class DropInViewModel(
val event = DropInActivityEvent.SessionServiceConnected(
sessionModel = sessionModel,
- clientKey = dropInConfiguration.clientKey,
- environment = dropInConfiguration.environment,
+ clientKey = dropInComponentParams.clientKey,
+ environment = dropInComponentParams.environment,
isFlowTakenOver = isSessionsFlowTakenOver,
)
sendEvent(event)
@@ -293,7 +295,7 @@ internal class DropInViewModel(
return GiftCardPaymentConfirmationData(
amountPaid = giftCardBalanceStatus.amountPaid,
remainingBalance = giftCardBalanceStatus.remainingBalance,
- shopperLocale = dropInConfiguration.shopperLocale,
+ shopperLocale = dropInComponentParams.shopperLocale,
brand = giftCardComponentState.data.paymentMethod?.brand.orEmpty(),
lastFourDigits = giftCardComponentState.lastFourDigits.orEmpty(),
)
@@ -381,7 +383,7 @@ internal class DropInViewModel(
private suspend fun getOrderDetails(orderResponse: OrderResponse?): OrderModel? {
if (orderResponse == null) return null
- return orderStatusRepository.getOrderStatus(dropInConfiguration, orderResponse.orderData)
+ return orderStatusRepository.getOrderStatus(dropInComponentParams.clientKey, orderResponse.orderData)
.fold(
onSuccess = { statusResponse ->
OrderModel(
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GiftCardComponentDialogFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GiftCardComponentDialogFragment.kt
index 3b6af93bb2..df96f313c7 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GiftCardComponentDialogFragment.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GiftCardComponentDialogFragment.kt
@@ -70,7 +70,7 @@ internal class GiftCardComponentDialogFragment : DropInBottomSheetDialogFragment
giftCardComponent = getComponentFor(
fragment = this,
paymentMethod = paymentMethod,
- dropInConfiguration = dropInViewModel.dropInConfiguration,
+ checkoutConfiguration = dropInViewModel.checkoutConfiguration,
amount = dropInViewModel.amount,
componentCallback = this,
sessionDetails = dropInViewModel.sessionDetails,
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GiftCardPaymentConfirmationDialogFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GiftCardPaymentConfirmationDialogFragment.kt
index 87d0bcb6b2..877e37c14c 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GiftCardPaymentConfirmationDialogFragment.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GiftCardPaymentConfirmationDialogFragment.kt
@@ -80,7 +80,7 @@ internal class GiftCardPaymentConfirmationDialogFragment : DropInBottomSheetDial
amount = it.amount,
transactionLimit = it.transactionLimit,
shopperLocale = giftCardPaymentConfirmationData.shopperLocale,
- environment = dropInViewModel.dropInConfiguration.environment,
+ environment = dropInViewModel.dropInComponentParams.environment,
)
}
val currentPaymentMethod = GiftCardPaymentMethodModel(
@@ -89,7 +89,7 @@ internal class GiftCardPaymentConfirmationDialogFragment : DropInBottomSheetDial
amount = null,
transactionLimit = null,
shopperLocale = null,
- environment = dropInViewModel.dropInConfiguration.environment,
+ environment = dropInViewModel.dropInComponentParams.environment,
)
val paymentMethods = alreadyPaidMethods + currentPaymentMethod
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GooglePayComponentDialogFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GooglePayComponentDialogFragment.kt
index ce94336c0d..5150ed4616 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GooglePayComponentDialogFragment.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/GooglePayComponentDialogFragment.kt
@@ -73,7 +73,7 @@ internal class GooglePayComponentDialogFragment :
component = getComponentFor(
fragment = this,
paymentMethod = paymentMethod,
- dropInConfiguration = dropInViewModel.dropInConfiguration,
+ checkoutConfiguration = dropInViewModel.checkoutConfiguration,
amount = dropInViewModel.amount,
componentCallback = this,
sessionDetails = dropInViewModel.sessionDetails,
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodListDialogFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodListDialogFragment.kt
index de7ce56339..be719d700d 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodListDialogFragment.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodListDialogFragment.kt
@@ -66,8 +66,8 @@ internal class PaymentMethodListDialogFragment :
paymentMethods = dropInViewModel.getPaymentMethods(),
storedPaymentMethods = dropInViewModel.getStoredPaymentMethods(),
order = dropInViewModel.currentOrder,
- dropInConfiguration = dropInViewModel.dropInConfiguration,
- amount = dropInViewModel.amount,
+ checkoutConfiguration = dropInViewModel.checkoutConfiguration,
+ dropInComponentParams = dropInViewModel.dropInComponentParams,
sessionDetails = dropInViewModel.sessionDetails,
)
}
@@ -157,7 +157,7 @@ internal class PaymentMethodListDialogFragment :
component = getComponentFor(
fragment = this,
storedPaymentMethod = storedPaymentMethod,
- dropInConfiguration = dropInViewModel.dropInConfiguration,
+ checkoutConfiguration = dropInViewModel.checkoutConfiguration,
amount = dropInViewModel.amount,
componentCallback = paymentMethodsListViewModel,
sessionDetails = dropInViewModel.sessionDetails,
@@ -172,8 +172,8 @@ internal class PaymentMethodListDialogFragment :
.setTitle(
String.format(
resources.getString(R.string.checkout_stored_payment_confirmation_message),
- paymentMethodName
- )
+ paymentMethodName,
+ ),
)
.setNegativeButton(R.string.checkout_stored_payment_confirmation_cancel_button) { dialog, _ ->
dialog.dismiss()
@@ -181,9 +181,9 @@ internal class PaymentMethodListDialogFragment :
.setPositiveButton(
PayButtonFormatter.getPayButtonText(
amount = dropInViewModel.amount,
- locale = dropInViewModel.dropInConfiguration.shopperLocale,
+ locale = dropInViewModel.dropInComponentParams.shopperLocale,
localizedContext = requireContext(),
- )
+ ),
) { dialog, _ ->
dialog.dismiss()
paymentMethodsListViewModel.onClickConfirmationButton()
@@ -194,8 +194,8 @@ internal class PaymentMethodListDialogFragment :
dialog.setMessage(
requireActivity().getString(
R.string.last_four_digits_format,
- storedPaymentMethodModel.lastFour
- )
+ storedPaymentMethodModel.lastFour,
+ ),
)
}
@@ -207,8 +207,8 @@ internal class PaymentMethodListDialogFragment :
dialog.setMessage(
requireActivity().getString(
R.string.last_four_digits_format,
- storedPaymentMethodModel.lastFour
- )
+ storedPaymentMethodModel.lastFour,
+ ),
)
}
}
@@ -230,7 +230,7 @@ internal class PaymentMethodListDialogFragment :
override fun onStoredPaymentMethodRemoved(storedPaymentMethodModel: StoredPaymentMethodModel) {
val storedPaymentMethod = StoredPaymentMethod(
- id = storedPaymentMethodModel.id
+ id = storedPaymentMethodModel.id,
)
protocol.removeStoredPaymentMethod(storedPaymentMethod)
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModel.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModel.kt
index 7c3a9fd8ac..9460f50c4a 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModel.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModel.kt
@@ -11,7 +11,7 @@ package com.adyen.checkout.dropin.internal.ui
import android.app.Application
import androidx.lifecycle.ViewModel
import com.adyen.checkout.components.core.ActionComponentData
-import com.adyen.checkout.components.core.Amount
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.ComponentAvailableCallback
import com.adyen.checkout.components.core.ComponentCallback
import com.adyen.checkout.components.core.ComponentError
@@ -24,9 +24,9 @@ import com.adyen.checkout.components.core.internal.util.CurrencyUtils
import com.adyen.checkout.components.core.internal.util.bufferedChannel
import com.adyen.checkout.core.internal.util.LogUtil
import com.adyen.checkout.core.internal.util.Logger
-import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.dropin.R
import com.adyen.checkout.dropin.internal.provider.checkPaymentMethodAvailability
+import com.adyen.checkout.dropin.internal.ui.model.DropInComponentParams
import com.adyen.checkout.dropin.internal.ui.model.GiftCardPaymentMethodModel
import com.adyen.checkout.dropin.internal.ui.model.OrderModel
import com.adyen.checkout.dropin.internal.ui.model.PaymentMethodHeader
@@ -37,6 +37,7 @@ import com.adyen.checkout.dropin.internal.ui.model.StoredPaymentMethodModel
import com.adyen.checkout.dropin.internal.util.isStoredPaymentSupported
import com.adyen.checkout.dropin.internal.util.mapStoredModel
import com.adyen.checkout.sessions.core.internal.data.model.SessionDetails
+import com.adyen.checkout.sessions.core.internal.data.model.mapToParams
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
@@ -49,8 +50,8 @@ internal class PaymentMethodsListViewModel(
private val paymentMethods: List,
storedPaymentMethods: List,
private val order: OrderModel?,
- private val dropInConfiguration: DropInConfiguration,
- private val amount: Amount?,
+ private val checkoutConfiguration: CheckoutConfiguration,
+ private val dropInComponentParams: DropInComponentParams,
private val sessionDetails: SessionDetails?,
) : ViewModel(), ComponentAvailableCallback, ComponentCallback> {
@@ -75,6 +76,7 @@ internal class PaymentMethodsListViewModel(
}
private fun setupPaymentMethods(paymentMethods: List) {
+ val sessionParams = sessionDetails?.mapToParams(checkoutConfiguration.amount)
paymentMethods.forEach { paymentMethod ->
val type = requireNotNull(paymentMethod.type) { "PaymentMethod type is null" }
@@ -84,16 +86,18 @@ internal class PaymentMethodsListViewModel(
checkPaymentMethodAvailability(
application = application,
paymentMethod = paymentMethod,
- dropInConfiguration = dropInConfiguration,
- amount = amount,
- sessionDetails = sessionDetails,
- callback = this
+ checkoutConfiguration = checkoutConfiguration,
+ dropInComponentParams = dropInComponentParams,
+ sessionParams = sessionParams,
+ callback = this,
)
}
+
PaymentMethodTypes.UNSUPPORTED_PAYMENT_METHODS.contains(type) -> {
Logger.e(TAG, "PaymentMethod not yet supported - $type")
paymentMethodsAvailabilityMap[paymentMethod] = false
}
+
else -> {
Logger.d(TAG, "No availability check required - $type")
paymentMethodsAvailabilityMap[paymentMethod] = true
@@ -126,9 +130,9 @@ internal class PaymentMethodsListViewModel(
}
// payment notes
order?.remainingAmount?.let { remainingAmount ->
- val value = CurrencyUtils.formatAmount(remainingAmount, dropInConfiguration.shopperLocale)
+ val value = CurrencyUtils.formatAmount(remainingAmount, checkoutConfiguration.shopperLocale)
add(
- PaymentMethodNote(application.getString(R.string.checkout_giftcard_pay_remaining_amount, value))
+ PaymentMethodNote(application.getString(R.string.checkout_giftcard_pay_remaining_amount, value)),
)
}
// stored payment methods
@@ -184,8 +188,8 @@ internal class PaymentMethodsListViewModel(
eventsChannel.trySend(
PaymentMethodListStoredEvent.ShowConfirmationPopup(
storedPaymentMethod.name ?: "",
- storedPaymentMethodModel
- )
+ storedPaymentMethodModel,
+ ),
)
} else {
eventsChannel.trySend(PaymentMethodListStoredEvent.ShowStoredComponentDialog(storedPaymentMethod))
@@ -211,8 +215,8 @@ internal class PaymentMethodsListViewModel(
mapNotNull { storedPaymentMethod ->
if (storedPaymentMethod.isStoredPaymentSupported()) {
storedPaymentMethod.mapStoredModel(
- dropInConfiguration.isRemovingStoredPaymentMethodsEnabled,
- dropInConfiguration.environment,
+ dropInComponentParams.isRemovingStoredPaymentMethodsEnabled,
+ checkoutConfiguration.environment,
)
} else {
null
@@ -233,7 +237,7 @@ internal class PaymentMethodsListViewModel(
name = name.orEmpty(),
icon = icon.orEmpty(),
drawIconBorder = drawIconBorder,
- environment = dropInConfiguration.environment,
+ environment = checkoutConfiguration.environment,
)
}
@@ -244,8 +248,8 @@ internal class PaymentMethodsListViewModel(
lastFour = it.lastFour,
amount = it.amount,
transactionLimit = it.transactionLimit,
- shopperLocale = dropInConfiguration.shopperLocale,
- environment = dropInConfiguration.environment,
+ shopperLocale = checkoutConfiguration.shopperLocale,
+ environment = checkoutConfiguration.environment,
)
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentMethodFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentMethodFragment.kt
index 1bcc7bbf13..c98c78839a 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentMethodFragment.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentMethodFragment.kt
@@ -44,7 +44,7 @@ internal class PreselectedStoredPaymentMethodFragment : DropInBottomSheetDialogF
PreselectedStoredPaymentViewModel(
storedPaymentMethod,
dropInViewModel.amount,
- dropInViewModel.dropInConfiguration,
+ dropInViewModel.dropInComponentParams,
)
}
@@ -77,7 +77,7 @@ internal class PreselectedStoredPaymentMethodFragment : DropInBottomSheetDialogF
component = getComponentFor(
fragment = this,
storedPaymentMethod = storedPaymentMethod,
- dropInConfiguration = dropInViewModel.dropInConfiguration,
+ checkoutConfiguration = dropInViewModel.checkoutConfiguration,
amount = dropInViewModel.amount,
componentCallback = storedPaymentViewModel,
sessionDetails = dropInViewModel.sessionDetails,
@@ -93,7 +93,7 @@ internal class PreselectedStoredPaymentMethodFragment : DropInBottomSheetDialogF
binding.paymentMethodsListHeader.paymentMethodHeaderTitle.setText(R.string.store_payment_methods_header)
val isRemovingStoredPaymentMethodsEnabled =
- dropInViewModel.dropInConfiguration.isRemovingStoredPaymentMethodsEnabled
+ dropInViewModel.dropInComponentParams.isRemovingStoredPaymentMethodsEnabled
binding.storedPaymentMethodItem.swipeToRevealLayout.setDragLocked(!isRemovingStoredPaymentMethodsEnabled)
if (isRemovingStoredPaymentMethodsEnabled) {
binding.storedPaymentMethodItem.paymentMethodItemUnderlayButton.setOnClickListener {
@@ -124,7 +124,7 @@ internal class PreselectedStoredPaymentMethodFragment : DropInBottomSheetDialogF
binding.storedPaymentMethodItem.textViewTitle.text =
requireActivity().getString(R.string.last_four_digits_format, storedPaymentMethodModel.lastFour)
binding.storedPaymentMethodItem.imageViewLogo.loadLogo(
- environment = dropInViewModel.dropInConfiguration.environment,
+ environment = dropInViewModel.dropInComponentParams.environment,
txVariant = storedPaymentMethodModel.imageId,
)
binding.storedPaymentMethodItem.textViewDetail.text =
@@ -136,10 +136,10 @@ internal class PreselectedStoredPaymentMethodFragment : DropInBottomSheetDialogF
binding.storedPaymentMethodItem.textViewTitle.text =
requireActivity().getString(
R.string.last_four_digits_format,
- storedPaymentMethodModel.lastFour
+ storedPaymentMethodModel.lastFour,
)
binding.storedPaymentMethodItem.imageViewLogo.loadLogo(
- environment = dropInViewModel.dropInConfiguration.environment,
+ environment = dropInViewModel.dropInComponentParams.environment,
txVariant = storedPaymentMethodModel.imageId,
)
binding.storedPaymentMethodItem.textViewDetail.isVisible = false
@@ -151,7 +151,7 @@ internal class PreselectedStoredPaymentMethodFragment : DropInBottomSheetDialogF
!storedPaymentMethodModel.description.isNullOrEmpty()
binding.storedPaymentMethodItem.textViewDetail.text = storedPaymentMethodModel.description
binding.storedPaymentMethodItem.imageViewLogo.loadLogo(
- environment = dropInViewModel.dropInConfiguration.environment,
+ environment = dropInViewModel.dropInComponentParams.environment,
txVariant = storedPaymentMethodModel.imageId,
)
}
@@ -213,7 +213,7 @@ internal class PreselectedStoredPaymentMethodFragment : DropInBottomSheetDialogF
.setMessage(R.string.checkout_remove_stored_payment_method_body)
.setPositiveButton(R.string.checkout_giftcard_remove_gift_cards_positive_button) { dialog, _ ->
val storedPaymentMethod = StoredPaymentMethod(
- id = storedPaymentMethod.id
+ id = storedPaymentMethod.id,
)
protocol.removeStoredPaymentMethod(storedPaymentMethod)
dialog.dismiss()
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentViewModel.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentViewModel.kt
index 16ae431946..4d041717e5 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentViewModel.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentViewModel.kt
@@ -17,8 +17,8 @@ import com.adyen.checkout.components.core.ComponentError
import com.adyen.checkout.components.core.PaymentComponentState
import com.adyen.checkout.components.core.StoredPaymentMethod
import com.adyen.checkout.components.core.internal.util.bufferedChannel
-import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.dropin.R
+import com.adyen.checkout.dropin.internal.ui.model.DropInComponentParams
import com.adyen.checkout.dropin.internal.ui.model.StoredPaymentMethodModel
import com.adyen.checkout.dropin.internal.util.mapStoredModel
import kotlinx.coroutines.channels.Channel
@@ -30,7 +30,7 @@ import java.util.Locale
internal class PreselectedStoredPaymentViewModel(
private val storedPaymentMethod: StoredPaymentMethod,
private val amount: Amount?,
- private val dropInConfiguration: DropInConfiguration,
+ private val dropInComponentParams: DropInComponentParams,
) : ViewModel(), ComponentCallback> {
private val _uiStateFlow = MutableStateFlow(getInitialUIState())
@@ -43,12 +43,12 @@ internal class PreselectedStoredPaymentViewModel(
private fun getInitialUIState(): PreselectedStoredState {
val storedPaymentMethodModel = storedPaymentMethod.mapStoredModel(
- dropInConfiguration.isRemovingStoredPaymentMethodsEnabled,
- dropInConfiguration.environment,
+ dropInComponentParams.isRemovingStoredPaymentMethodsEnabled,
+ dropInComponentParams.environment,
)
return PreselectedStoredState(
storedPaymentMethodModel = storedPaymentMethodModel,
- buttonState = ButtonState.ContinueButton()
+ buttonState = ButtonState.ContinueButton(),
)
}
@@ -77,7 +77,7 @@ internal class PreselectedStoredPaymentViewModel(
ButtonState.ContinueButton()
} else {
// component does not require user input -> treat it as a normal Pay button
- ButtonState.PayButton(amount, dropInConfiguration.shopperLocale)
+ ButtonState.PayButton(amount, dropInComponentParams.shopperLocale)
}
}
diff --git a/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ConfigurationProvider.kt b/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ConfigurationProvider.kt
index e15189725d..4afdef6489 100644
--- a/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ConfigurationProvider.kt
+++ b/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ConfigurationProvider.kt
@@ -8,53 +8,38 @@
package com.adyen.checkout.dropin.internal
-import com.adyen.checkout.bcmc.BcmcConfiguration
-import com.adyen.checkout.card.CardConfiguration
+import com.adyen.checkout.bcmc.bcmcConfiguration
+import com.adyen.checkout.card.cardConfiguration
import com.adyen.checkout.components.core.Amount
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.core.Environment
-import com.adyen.checkout.core.exception.CheckoutException
-import com.adyen.checkout.core.internal.util.LogUtil
-import com.adyen.checkout.core.internal.util.Logger
-import com.adyen.checkout.dropin.DropInConfiguration
-import com.adyen.checkout.googlepay.GooglePayConfiguration
+import com.adyen.checkout.dropin.dropInConfiguration
+import com.adyen.checkout.googlepay.googlePayConfiguration
import java.util.Locale
internal object ConfigurationProvider {
+
private const val TEST_CLIENT_KEY = "test_qwertyuiopasdfghjklzxcvbnmqwerty"
- private val TAG = LogUtil.getTag()
private val shopperLocale = Locale.US
private val amount = Amount(currency = "EUR", value = 1337)
private val environment = Environment.TEST
- internal fun getDropInConfiguration(): DropInConfiguration {
- val dropInConfigurationBuilder = DropInConfiguration.Builder(
- shopperLocale,
- environment,
- TEST_CLIENT_KEY,
- )
- .addCardConfiguration(getCardConfiguration())
- .addBcmcConfiguration(getBcmcConfiguration())
- .addGooglePayConfiguration(getGooglePayConfiguration())
- .setEnableRemovingStoredPaymentMethods(true)
-
- try {
- dropInConfigurationBuilder.setAmount(amount)
- } catch (e: CheckoutException) {
- Logger.e(TAG, "Amount $amount not valid", e)
+ fun getCheckoutConfiguration() = CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = TEST_CLIENT_KEY,
+ amount = amount,
+ ) {
+ dropInConfiguration {
+ setEnableRemovingStoredPaymentMethods(true)
}
- return dropInConfigurationBuilder.build()
- }
-
- private fun getCardConfiguration(): CardConfiguration =
- CardConfiguration.Builder(shopperLocale, environment, TEST_CLIENT_KEY).build()
+ cardConfiguration()
- private fun getBcmcConfiguration(): BcmcConfiguration =
- BcmcConfiguration.Builder(shopperLocale, environment, TEST_CLIENT_KEY).build()
+ bcmcConfiguration()
- private fun getGooglePayConfiguration(): GooglePayConfiguration =
- GooglePayConfiguration.Builder(shopperLocale, environment, TEST_CLIENT_KEY)
- .setCountryCode("NL")
- .setAmount(amount)
- .build()
+ googlePayConfiguration {
+ setCountryCode("NL")
+ }
+ }
}
diff --git a/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModelTest.kt b/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModelTest.kt
index 51a02eee66..252a6b1845 100644
--- a/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModelTest.kt
+++ b/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ui/PaymentMethodsListViewModelTest.kt
@@ -12,13 +12,16 @@ import android.app.Application
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import app.cash.turbine.test
import com.adyen.checkout.components.core.Amount
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethod
import com.adyen.checkout.components.core.StoredPaymentMethod
import com.adyen.checkout.dropin.DropInConfiguration
+import com.adyen.checkout.dropin.getDropInConfiguration
import com.adyen.checkout.dropin.internal.ConfigurationProvider
import com.adyen.checkout.dropin.internal.DataProvider
import com.adyen.checkout.dropin.internal.Helpers.mapToPaymentMethodModelList
import com.adyen.checkout.dropin.internal.Helpers.mapToStoredPaymentMethodsModelList
+import com.adyen.checkout.dropin.internal.provider.mapToParams
import com.adyen.checkout.dropin.internal.ui.model.GiftCardPaymentMethodModel
import com.adyen.checkout.dropin.internal.ui.model.OrderModel
import com.adyen.checkout.dropin.internal.ui.model.PaymentMethodHeader
@@ -51,7 +54,8 @@ internal class PaymentMethodsListViewModelTest(
@get:Rule
var instantTaskExecutorRule = InstantTaskExecutorRule()
- private lateinit var configuration: DropInConfiguration
+ private lateinit var checkoutConfiguration: CheckoutConfiguration
+ private lateinit var dropInConfiguration: DropInConfiguration
private lateinit var amount: Amount
private lateinit var paymentMethods: List
private lateinit var storedPaymentMethods: MutableList
@@ -61,7 +65,8 @@ internal class PaymentMethodsListViewModelTest(
@BeforeEach
fun setup() {
- configuration = ConfigurationProvider.getDropInConfiguration()
+ checkoutConfiguration = ConfigurationProvider.getCheckoutConfiguration()
+ dropInConfiguration = checkoutConfiguration.getDropInConfiguration()!!
amount = Amount(currency = "EUR", value = 1234567)
paymentMethods = DataProvider.getPaymentMethodsList()
storedPaymentMethods = DataProvider.getStoredPaymentMethods().toMutableList()
@@ -72,8 +77,8 @@ internal class PaymentMethodsListViewModelTest(
paymentMethods = paymentMethods,
storedPaymentMethods = storedPaymentMethods,
order = order,
- dropInConfiguration = configuration,
- amount = amount,
+ checkoutConfiguration = checkoutConfiguration,
+ dropInComponentParams = dropInConfiguration.mapToParams(amount),
sessionDetails = sessionDetails,
)
}
@@ -82,7 +87,7 @@ internal class PaymentMethodsListViewModelTest(
fun `test remove stored payment method success`() = runTest {
viewModel.paymentMethodsFlow.test {
val paymentMethods = storedPaymentMethods
- .mapToStoredPaymentMethodsModelList(configuration.isRemovingStoredPaymentMethodsEnabled)
+ .mapToStoredPaymentMethodsModelList(dropInConfiguration.isRemovingStoredPaymentMethodsEnabled)
val storedPaymentMethod = paymentMethods[0]
viewModel.removePaymentMethodWithId(storedPaymentMethod.id)
@@ -128,8 +133,8 @@ internal class PaymentMethodsListViewModelTest(
paymentMethods = paymentMethods,
storedPaymentMethods = storedPaymentMethods,
order = order,
- dropInConfiguration = configuration,
- amount = amount,
+ checkoutConfiguration = checkoutConfiguration,
+ dropInComponentParams = dropInConfiguration.mapToParams(amount),
sessionDetails = sessionDetails,
)
@@ -154,8 +159,8 @@ internal class PaymentMethodsListViewModelTest(
paymentMethods = paymentMethods,
storedPaymentMethods = storedPaymentMethods,
order = order,
- dropInConfiguration = configuration,
- amount = amount,
+ checkoutConfiguration = checkoutConfiguration,
+ dropInComponentParams = dropInConfiguration.mapToParams(amount),
sessionDetails = sessionDetails,
)
@@ -171,30 +176,29 @@ internal class PaymentMethodsListViewModelTest(
}
@Test
- fun `order is null, then payment method flow won't contain gift cards or payment method note`() =
- runTest {
- order = null
+ fun `order is null, then payment method flow won't contain gift cards or payment method note`() = runTest {
+ order = null
- viewModel = PaymentMethodsListViewModel(
- application = application,
- paymentMethods = paymentMethods,
- storedPaymentMethods = storedPaymentMethods,
- order = order,
- dropInConfiguration = configuration,
- amount = amount,
- sessionDetails = sessionDetails,
- )
+ viewModel = PaymentMethodsListViewModel(
+ application = application,
+ paymentMethods = paymentMethods,
+ storedPaymentMethods = storedPaymentMethods,
+ order = order,
+ checkoutConfiguration = checkoutConfiguration,
+ dropInComponentParams = dropInConfiguration.mapToParams(amount),
+ sessionDetails = sessionDetails,
+ )
- viewModel.paymentMethodsFlow.test {
- with(expectMostRecentItem()) {
- assertTrue(filterIsInstance().isNotEmpty())
- assertTrue(filterIsInstance().isNotEmpty())
- assertTrue(filterIsInstance().isNotEmpty())
- assertTrue(filterIsInstance().isEmpty())
- assertTrue(filterIsInstance().isEmpty())
- }
+ viewModel.paymentMethodsFlow.test {
+ with(expectMostRecentItem()) {
+ assertTrue(filterIsInstance().isNotEmpty())
+ assertTrue(filterIsInstance().isNotEmpty())
+ assertTrue(filterIsInstance().isNotEmpty())
+ assertTrue(filterIsInstance().isEmpty())
+ assertTrue(filterIsInstance().isEmpty())
}
}
+ }
@Test
fun `stored and normal payment methods lists are empty, then payment method flow won't contain stored or normal payment methods`() =
@@ -207,8 +211,8 @@ internal class PaymentMethodsListViewModelTest(
paymentMethods = paymentMethods,
storedPaymentMethods = storedPaymentMethods,
order = order,
- dropInConfiguration = configuration,
- amount = amount,
+ checkoutConfiguration = checkoutConfiguration,
+ dropInComponentParams = dropInConfiguration.mapToParams(amount),
sessionDetails = sessionDetails,
)
@@ -224,27 +228,26 @@ internal class PaymentMethodsListViewModelTest(
}
@Test
- fun `all payment methods are empty, then payment method flow will be empty`() =
- runTest {
- storedPaymentMethods = mutableListOf()
- paymentMethods = emptyList()
- order = null
+ fun `all payment methods are empty, then payment method flow will be empty`() = runTest {
+ storedPaymentMethods = mutableListOf()
+ paymentMethods = emptyList()
+ order = null
- viewModel = PaymentMethodsListViewModel(
- application = application,
- paymentMethods = paymentMethods,
- storedPaymentMethods = storedPaymentMethods,
- order = order,
- dropInConfiguration = configuration,
- amount = amount,
- sessionDetails = sessionDetails,
- )
+ viewModel = PaymentMethodsListViewModel(
+ application = application,
+ paymentMethods = paymentMethods,
+ storedPaymentMethods = storedPaymentMethods,
+ order = order,
+ checkoutConfiguration = checkoutConfiguration,
+ dropInComponentParams = dropInConfiguration.mapToParams(amount),
+ sessionDetails = sessionDetails,
+ )
- viewModel.paymentMethodsFlow.test {
- with(expectMostRecentItem()) {
- assertTrue(isEmpty())
- }
+ viewModel.paymentMethodsFlow.test {
+ with(expectMostRecentItem()) {
+ assertTrue(isEmpty())
}
}
+ }
}
}
diff --git a/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentViewModelTest.kt b/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentViewModelTest.kt
index 3f6988e16d..eaeb7b666b 100644
--- a/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentViewModelTest.kt
+++ b/drop-in/src/test/java/com/adyen/checkout/dropin/internal/ui/PreselectedStoredPaymentViewModelTest.kt
@@ -17,9 +17,9 @@ import com.adyen.checkout.components.core.StoredPaymentMethod
import com.adyen.checkout.core.Environment
import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.dropin.DropInConfiguration
+import com.adyen.checkout.dropin.internal.provider.mapToParams
import com.adyen.checkout.dropin.internal.ui.model.GenericStoredModel
import com.adyen.checkout.test.TestDispatcherExtension
-import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
@@ -31,11 +31,11 @@ import org.junit.jupiter.api.fail
import org.mockito.junit.jupiter.MockitoExtension
import java.util.Locale
-@OptIn(ExperimentalCoroutinesApi::class)
@ExtendWith(MockitoExtension::class, TestDispatcherExtension::class)
internal class PreselectedStoredPaymentViewModelTest {
private val storedPaymentMethod = StoredPaymentMethod()
- private val dropInConfiguration = DropInConfiguration.Builder(Locale.US, Environment.TEST, TEST_CLIENT_KEY).build()
+ private val dropInComponentParams =
+ DropInConfiguration.Builder(Locale.US, Environment.TEST, TEST_CLIENT_KEY).build().mapToParams(Amount())
private lateinit var viewModel: PreselectedStoredPaymentViewModel
@@ -44,24 +44,25 @@ internal class PreselectedStoredPaymentViewModelTest {
viewModel = PreselectedStoredPaymentViewModel(
storedPaymentMethod,
TEST_AMOUNT,
- dropInConfiguration,
+ dropInComponentParams,
)
}
@Test
fun `when view model is initialized then uiStateFlow has a matching initial value`() = runTest {
- val dropInConfiguration = DropInConfiguration.Builder(
+ val dropInComponentParams = DropInConfiguration.Builder(
Locale.US,
Environment.TEST,
- TEST_CLIENT_KEY
+ TEST_CLIENT_KEY,
)
.setEnableRemovingStoredPaymentMethods(true)
.build()
+ .mapToParams(Amount())
viewModel = PreselectedStoredPaymentViewModel(
storedPaymentMethod,
TEST_AMOUNT,
- dropInConfiguration,
+ dropInComponentParams,
)
viewModel.uiStateFlow.test {
From 6a7b66eb7cb6049ea00073ee1d9e01872a4626f1 Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Wed, 3 Jan 2024 16:23:33 +0100
Subject: [PATCH 044/255] Make CardComponent accept CheckoutConfiguration
COAND-811
---
.../adyen3ds2/Adyen3DS2Configuration.kt | 12 ++
.../provider/Adyen3DS2ComponentProvider.kt | 53 +++++-
.../model/Adyen3DS2ComponentParamsMapper.kt | 34 ++--
.../action/core/GenericActionConfiguration.kt | 23 ++-
.../GenericActionComponentProvider.kt | 51 +++++-
.../internal/ui/ActionDelegateProvider.kt | 129 ++------------
.../ui/DefaultGenericActionDelegate.kt | 6 +-
.../checkout/await/AwaitConfiguration.kt | 12 ++
.../provider/AwaitComponentProvider.kt | 52 +++++-
.../adyen/checkout/card/CardConfiguration.kt | 16 ++
.../provider/CardComponentProvider.kt | 164 ++++++++++++++----
.../ui/model/CardComponentParamsMapper.kt | 97 +++++------
.../provider/ActionComponentProvider.kt | 108 +++++++++++-
.../provider/PaymentComponentProvider.kt | 114 ++++++++++++
.../StoredPaymentComponentProvider.kt | 114 ++++++++++++
.../ui/model/GenericComponentParamsMapper.kt | 1 +
.../provider/ComponentParsingProvider.kt | 4 +-
.../checkout/example/ui/card/CardActivity.kt | 2 +-
.../ui/card/SessionsCardTakenOverActivity.kt | 2 +-
.../checkout/qrcode/QRCodeConfiguration.kt | 12 ++
.../provider/QRCodeComponentProvider.kt | 52 +++++-
.../redirect/RedirectConfiguration.kt | 16 +-
.../provider/RedirectComponentProvider.kt | 50 +++++-
.../SessionPaymentComponentProvider.kt | 117 +++++++++++++
.../SessionStoredPaymentComponentProvider.kt | 120 +++++++++++++
.../checkout/voucher/VoucherConfiguration.kt | 12 ++
.../provider/VoucherComponentProvider.kt | 46 ++++-
.../wechatpay/WeChatPayActionConfiguration.kt | 12 ++
.../WeChatPayActionComponentProvider.kt | 50 +++++-
29 files changed, 1177 insertions(+), 304 deletions(-)
diff --git a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt
index 20db7eb887..8b9a33579c 100644
--- a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt
+++ b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Configuration.kt
@@ -125,3 +125,15 @@ fun CheckoutConfiguration.adyen3DS2Configuration(
fun CheckoutConfiguration.getAdyen3DS2Configuration(): Adyen3DS2Configuration? {
return getActionConfiguration(Adyen3DS2Configuration::class.java)
}
+
+internal fun Adyen3DS2Configuration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addActionConfiguration(this@toCheckoutConfiguration)
+ }
+}
diff --git a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/internal/provider/Adyen3DS2ComponentProvider.kt b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/internal/provider/Adyen3DS2ComponentProvider.kt
index 4fab618e76..82885b8767 100644
--- a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/internal/provider/Adyen3DS2ComponentProvider.kt
+++ b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/internal/provider/Adyen3DS2ComponentProvider.kt
@@ -23,7 +23,9 @@ import com.adyen.checkout.adyen3ds2.internal.data.model.Adyen3DS2Serializer
import com.adyen.checkout.adyen3ds2.internal.ui.Adyen3DS2Delegate
import com.adyen.checkout.adyen3ds2.internal.ui.DefaultAdyen3DS2Delegate
import com.adyen.checkout.adyen3ds2.internal.ui.model.Adyen3DS2ComponentParamsMapper
+import com.adyen.checkout.adyen3ds2.toCheckoutConfiguration
import com.adyen.checkout.components.core.ActionComponentCallback
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.action.Action
import com.adyen.checkout.components.core.action.Threeds2Action
import com.adyen.checkout.components.core.action.Threeds2ChallengeAction
@@ -49,23 +51,24 @@ constructor(
overrideSessionParams: SessionParams? = null,
) : ActionComponentProvider {
- private val componentParamsMapper = Adyen3DS2ComponentParamsMapper(overrideComponentParams, overrideSessionParams)
+ private val componentParamsMapper =
+ Adyen3DS2ComponentParamsMapper(overrideComponentParams != null, overrideSessionParams)
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
application: Application,
- configuration: Adyen3DS2Configuration,
+ checkoutConfiguration: CheckoutConfiguration,
callback: ActionComponentCallback,
- key: String?,
+ key: String?
): Adyen3DS2Component {
val threeDS2Factory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val adyen3DS2Delegate = getDelegate(configuration, savedStateHandle, application)
+ val adyen3DS2Delegate = getDelegate(checkoutConfiguration, savedStateHandle, application)
Adyen3DS2Component(
delegate = adyen3DS2Delegate,
- actionComponentEventHandler = DefaultActionComponentEventHandler(callback)
+ actionComponentEventHandler = DefaultActionComponentEventHandler(callback),
)
}
return ViewModelProvider(viewModelStoreOwner, threeDS2Factory)[key, Adyen3DS2Component::class.java]
@@ -75,12 +78,12 @@ constructor(
}
override fun getDelegate(
- configuration: Adyen3DS2Configuration,
+ checkoutConfiguration: CheckoutConfiguration,
savedStateHandle: SavedStateHandle,
- application: Application,
+ application: Application
): Adyen3DS2Delegate {
val componentParams = componentParamsMapper.mapToParams(
- adyen3DS2Configuration = configuration,
+ checkoutConfiguration = checkoutConfiguration,
sessionParams = null,
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
@@ -104,11 +107,43 @@ constructor(
)
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ application: Application,
+ configuration: Adyen3DS2Configuration,
+ callback: ActionComponentCallback,
+ key: String?,
+ ): Adyen3DS2Component {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ application = application,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ callback = callback,
+ key = key,
+ )
+ }
+
+ override fun getDelegate(
+ configuration: Adyen3DS2Configuration,
+ savedStateHandle: SavedStateHandle,
+ application: Application,
+ ): Adyen3DS2Delegate {
+ return getDelegate(
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ savedStateHandle = savedStateHandle,
+ application = application,
+ )
+ }
+
override val supportedActionTypes: List
get() = listOf(
Threeds2FingerprintAction.ACTION_TYPE,
Threeds2ChallengeAction.ACTION_TYPE,
- Threeds2Action.ACTION_TYPE
+ Threeds2Action.ACTION_TYPE,
)
override fun canHandleAction(action: Action): Boolean {
diff --git a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/internal/ui/model/Adyen3DS2ComponentParamsMapper.kt b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/internal/ui/model/Adyen3DS2ComponentParamsMapper.kt
index c17730ced5..c93a256f25 100644
--- a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/internal/ui/model/Adyen3DS2ComponentParamsMapper.kt
+++ b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/internal/ui/model/Adyen3DS2ComponentParamsMapper.kt
@@ -9,55 +9,41 @@
package com.adyen.checkout.adyen3ds2.internal.ui.model
import androidx.annotation.VisibleForTesting
-import com.adyen.checkout.adyen3ds2.Adyen3DS2Configuration
+import com.adyen.checkout.adyen3ds2.getAdyen3DS2Configuration
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParams
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
internal class Adyen3DS2ComponentParamsMapper(
- private val overrideComponentParams: ComponentParams?,
+ private val isCreatedByDropIn: Boolean,
private val overrideSessionParams: SessionParams?,
) {
fun mapToParams(
- adyen3DS2Configuration: Adyen3DS2Configuration,
+ checkoutConfiguration: CheckoutConfiguration,
sessionParams: SessionParams?,
): Adyen3DS2ComponentParams {
- return adyen3DS2Configuration
+ return checkoutConfiguration
.mapToParamsInternal()
- .override(overrideComponentParams)
.override(sessionParams ?: overrideSessionParams)
}
- private fun Adyen3DS2Configuration.mapToParamsInternal(): Adyen3DS2ComponentParams {
+ private fun CheckoutConfiguration.mapToParamsInternal(): Adyen3DS2ComponentParams {
+ val adyen3ds2Configuration = getAdyen3DS2Configuration()
return Adyen3DS2ComponentParams(
shopperLocale = shopperLocale,
environment = environment,
clientKey = clientKey,
analyticsParams = AnalyticsParams(analyticsConfiguration),
- isCreatedByDropIn = false,
+ isCreatedByDropIn = isCreatedByDropIn,
amount = amount,
- uiCustomization = uiCustomization,
- threeDSRequestorAppURL = threeDSRequestorAppURL,
+ uiCustomization = adyen3ds2Configuration?.uiCustomization,
+ threeDSRequestorAppURL = adyen3ds2Configuration?.threeDSRequestorAppURL,
// Hardcoded for now, but in the feature we could make this configurable
deviceParameterBlockList = DEVICE_PARAMETER_BLOCK_LIST,
)
}
- private fun Adyen3DS2ComponentParams.override(
- overrideComponentParams: ComponentParams?
- ): Adyen3DS2ComponentParams {
- if (overrideComponentParams == null) return this
- return copy(
- shopperLocale = overrideComponentParams.shopperLocale,
- environment = overrideComponentParams.environment,
- clientKey = overrideComponentParams.clientKey,
- analyticsParams = overrideComponentParams.analyticsParams,
- isCreatedByDropIn = overrideComponentParams.isCreatedByDropIn,
- amount = overrideComponentParams.amount,
- )
- }
-
private fun Adyen3DS2ComponentParams.override(
sessionParams: SessionParams? = null
): Adyen3DS2ComponentParams {
diff --git a/action-core/src/main/java/com/adyen/checkout/action/core/GenericActionConfiguration.kt b/action-core/src/main/java/com/adyen/checkout/action/core/GenericActionConfiguration.kt
index b9d1832f62..1fb73ac63a 100644
--- a/action-core/src/main/java/com/adyen/checkout/action/core/GenericActionConfiguration.kt
+++ b/action-core/src/main/java/com/adyen/checkout/action/core/GenericActionConfiguration.kt
@@ -16,6 +16,7 @@ import com.adyen.checkout.adyen3ds2.Adyen3DS2Configuration
import com.adyen.checkout.await.AwaitConfiguration
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.internal.ActionComponent
import com.adyen.checkout.components.core.internal.BaseConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
@@ -45,14 +46,6 @@ class GenericActionConfiguration private constructor(
private val availableActionConfigs: HashMap, Configuration>,
) : Configuration {
- internal inline fun getConfigurationForAction(): T? {
- val actionClass = T::class.java
- if (availableActionConfigs.containsKey(actionClass)) {
- return availableActionConfigs[actionClass] as T
- }
- return null
- }
-
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun getAllConfigurations(): List = availableActionConfigs.values.toList()
@@ -154,3 +147,17 @@ class GenericActionConfiguration private constructor(
}
}
}
+
+internal fun GenericActionConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ this@toCheckoutConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/action-core/src/main/java/com/adyen/checkout/action/core/internal/provider/GenericActionComponentProvider.kt b/action-core/src/main/java/com/adyen/checkout/action/core/internal/provider/GenericActionComponentProvider.kt
index 6615b310a2..c6b3f9cf08 100644
--- a/action-core/src/main/java/com/adyen/checkout/action/core/internal/provider/GenericActionComponentProvider.kt
+++ b/action-core/src/main/java/com/adyen/checkout/action/core/internal/provider/GenericActionComponentProvider.kt
@@ -21,7 +21,9 @@ import com.adyen.checkout.action.core.internal.DefaultActionHandlingComponent
import com.adyen.checkout.action.core.internal.ui.ActionDelegateProvider
import com.adyen.checkout.action.core.internal.ui.DefaultGenericActionDelegate
import com.adyen.checkout.action.core.internal.ui.GenericActionDelegate
+import com.adyen.checkout.action.core.toCheckoutConfiguration
import com.adyen.checkout.components.core.ActionComponentCallback
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.action.Action
import com.adyen.checkout.components.core.action.AwaitAction
import com.adyen.checkout.components.core.action.QrCodeAction
@@ -42,6 +44,7 @@ import com.adyen.checkout.components.core.internal.util.viewModelFactory
class GenericActionComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
+ // TODO: Replace with isCreatedByDropIn: Boolean = false,
overrideComponentParams: ComponentParams? = null,
) : ActionComponentProvider {
@@ -52,16 +55,16 @@ constructor(
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
application: Application,
- configuration: GenericActionConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
callback: ActionComponentCallback,
- key: String?,
+ key: String?
): GenericActionComponent {
val genericActionFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val genericActionDelegate = getDelegate(configuration, savedStateHandle, application)
+ val genericActionDelegate = getDelegate(checkoutConfiguration, savedStateHandle, application)
GenericActionComponent(
genericActionDelegate = genericActionDelegate,
actionHandlingComponent = DefaultActionHandlingComponent(genericActionDelegate, null),
- actionComponentEventHandler = DefaultActionComponentEventHandler(callback)
+ actionComponentEventHandler = DefaultActionComponentEventHandler(callback),
)
}
return ViewModelProvider(viewModelStoreOwner, genericActionFactory)[key, GenericActionComponent::class.java]
@@ -71,17 +74,49 @@ constructor(
}
override fun getDelegate(
- configuration: GenericActionConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
savedStateHandle: SavedStateHandle,
application: Application
): GenericActionDelegate {
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
return DefaultGenericActionDelegate(
observerRepository = ActionObserverRepository(),
savedStateHandle = savedStateHandle,
- configuration = configuration,
+ checkoutConfiguration = checkoutConfiguration,
componentParams = componentParams,
- actionDelegateProvider = ActionDelegateProvider(componentParams, null)
+ actionDelegateProvider = ActionDelegateProvider(componentParams, null),
+ )
+ }
+
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ application: Application,
+ configuration: GenericActionConfiguration,
+ callback: ActionComponentCallback,
+ key: String?,
+ ): GenericActionComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ application = application,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ callback = callback,
+ key = key,
+ )
+ }
+
+ override fun getDelegate(
+ configuration: GenericActionConfiguration,
+ savedStateHandle: SavedStateHandle,
+ application: Application
+ ): GenericActionDelegate {
+ return getDelegate(
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ savedStateHandle = savedStateHandle,
+ application = application,
)
}
diff --git a/action-core/src/main/java/com/adyen/checkout/action/core/internal/ui/ActionDelegateProvider.kt b/action-core/src/main/java/com/adyen/checkout/action/core/internal/ui/ActionDelegateProvider.kt
index 4da2b00642..6466cade39 100644
--- a/action-core/src/main/java/com/adyen/checkout/action/core/internal/ui/ActionDelegateProvider.kt
+++ b/action-core/src/main/java/com/adyen/checkout/action/core/internal/ui/ActionDelegateProvider.kt
@@ -10,11 +10,9 @@ package com.adyen.checkout.action.core.internal.ui
import android.app.Application
import androidx.lifecycle.SavedStateHandle
-import com.adyen.checkout.action.core.GenericActionConfiguration
-import com.adyen.checkout.adyen3ds2.Adyen3DS2Configuration
import com.adyen.checkout.adyen3ds2.internal.provider.Adyen3DS2ComponentProvider
-import com.adyen.checkout.await.AwaitConfiguration
import com.adyen.checkout.await.internal.provider.AwaitComponentProvider
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.action.Action
import com.adyen.checkout.components.core.action.AwaitAction
import com.adyen.checkout.components.core.action.BaseThreeds2Action
@@ -22,20 +20,13 @@ import com.adyen.checkout.components.core.action.QrCodeAction
import com.adyen.checkout.components.core.action.RedirectAction
import com.adyen.checkout.components.core.action.SdkAction
import com.adyen.checkout.components.core.action.VoucherAction
-import com.adyen.checkout.components.core.internal.BaseConfigurationBuilder
-import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.components.core.internal.ui.ActionDelegate
import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.core.exception.CheckoutException
-import com.adyen.checkout.core.internal.util.runCompileOnly
-import com.adyen.checkout.qrcode.QRCodeConfiguration
import com.adyen.checkout.qrcode.internal.provider.QRCodeComponentProvider
-import com.adyen.checkout.redirect.RedirectConfiguration
import com.adyen.checkout.redirect.internal.provider.RedirectComponentProvider
-import com.adyen.checkout.voucher.VoucherConfiguration
import com.adyen.checkout.voucher.internal.provider.VoucherComponentProvider
-import com.adyen.checkout.wechatpay.WeChatPayActionConfiguration
import com.adyen.checkout.wechatpay.internal.provider.WeChatPayActionComponentProvider
internal class ActionDelegateProvider(
@@ -45,116 +36,24 @@ internal class ActionDelegateProvider(
fun getDelegate(
action: Action,
- configuration: GenericActionConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
savedStateHandle: SavedStateHandle,
application: Application,
): ActionDelegate {
- return when (action) {
- is AwaitAction -> {
- AwaitComponentProvider(overrideComponentParams, overrideSessionParams).getDelegate(
- getConfigurationForAction(configuration),
- savedStateHandle,
- application
- )
- }
-
- is QrCodeAction -> {
- QRCodeComponentProvider(overrideComponentParams, overrideSessionParams).getDelegate(
- getConfigurationForAction(configuration),
- savedStateHandle,
- application
- )
- }
-
- is RedirectAction -> {
- RedirectComponentProvider(overrideComponentParams, overrideSessionParams).getDelegate(
- getConfigurationForAction(configuration),
- savedStateHandle,
- application
- )
- }
-
- is BaseThreeds2Action -> {
- Adyen3DS2ComponentProvider(overrideComponentParams, overrideSessionParams).getDelegate(
- getConfigurationForAction(configuration),
- savedStateHandle,
- application
- )
- }
-
- is VoucherAction -> {
- VoucherComponentProvider(overrideComponentParams, overrideSessionParams).getDelegate(
- getConfigurationForAction(configuration),
- savedStateHandle,
- application
- )
- }
-
- is SdkAction<*> -> {
- WeChatPayActionComponentProvider(overrideComponentParams, overrideSessionParams).getDelegate(
- getConfigurationForAction(configuration),
- savedStateHandle,
- application
- )
- }
-
+ val provider = when (action) {
+ is AwaitAction -> AwaitComponentProvider(overrideComponentParams, overrideSessionParams)
+ is QrCodeAction -> QRCodeComponentProvider(overrideComponentParams, overrideSessionParams)
+ is RedirectAction -> RedirectComponentProvider(overrideComponentParams, overrideSessionParams)
+ is BaseThreeds2Action -> Adyen3DS2ComponentProvider(overrideComponentParams, overrideSessionParams)
+ is VoucherAction -> VoucherComponentProvider(overrideComponentParams, overrideSessionParams)
+ is SdkAction<*> -> WeChatPayActionComponentProvider(overrideComponentParams, overrideSessionParams)
else -> throw CheckoutException("Can't find delegate for action: ${action.type}")
}
- }
-
- private inline fun getConfigurationForAction(
- configuration: GenericActionConfiguration
- ): T {
- return configuration.getConfigurationForAction() ?: getDefaultConfiguration(configuration)
- }
-
- private inline fun getDefaultConfiguration(
- configuration: Configuration
- ): T {
- val shopperLocale = configuration.shopperLocale
- val environment = configuration.environment
- val clientKey = configuration.clientKey
-
- val builder: BaseConfigurationBuilder<*, *> = when (T::class) {
- runCompileOnly { AwaitConfiguration::class } -> AwaitConfiguration.Builder(
- shopperLocale,
- environment,
- clientKey
- )
-
- runCompileOnly { RedirectConfiguration::class } -> RedirectConfiguration.Builder(
- shopperLocale,
- environment,
- clientKey
- )
-
- runCompileOnly { QRCodeConfiguration::class } -> QRCodeConfiguration.Builder(
- shopperLocale,
- environment,
- clientKey
- )
-
- runCompileOnly { Adyen3DS2Configuration::class } -> Adyen3DS2Configuration.Builder(
- shopperLocale,
- environment,
- clientKey
- )
-
- runCompileOnly { WeChatPayActionConfiguration::class } -> WeChatPayActionConfiguration.Builder(
- shopperLocale,
- environment,
- clientKey
- )
-
- runCompileOnly { VoucherConfiguration::class } -> VoucherConfiguration.Builder(
- shopperLocale,
- environment,
- clientKey
- )
-
- else -> throw CheckoutException("Unable to find component configuration for class - ${T::class}")
- }
- return builder.build() as T
+ return provider.getDelegate(
+ checkoutConfiguration = checkoutConfiguration,
+ savedStateHandle = savedStateHandle,
+ application = application,
+ )
}
}
diff --git a/action-core/src/main/java/com/adyen/checkout/action/core/internal/ui/DefaultGenericActionDelegate.kt b/action-core/src/main/java/com/adyen/checkout/action/core/internal/ui/DefaultGenericActionDelegate.kt
index 726885aab8..d903837cd4 100644
--- a/action-core/src/main/java/com/adyen/checkout/action/core/internal/ui/DefaultGenericActionDelegate.kt
+++ b/action-core/src/main/java/com/adyen/checkout/action/core/internal/ui/DefaultGenericActionDelegate.kt
@@ -12,9 +12,9 @@ import android.app.Activity
import android.content.Intent
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.SavedStateHandle
-import com.adyen.checkout.action.core.GenericActionConfiguration
import com.adyen.checkout.adyen3ds2.internal.ui.Adyen3DS2Delegate
import com.adyen.checkout.components.core.ActionComponentData
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.action.Action
import com.adyen.checkout.components.core.action.Threeds2ChallengeAction
import com.adyen.checkout.components.core.internal.ActionComponentEvent
@@ -48,7 +48,7 @@ import kotlinx.coroutines.flow.receiveAsFlow
internal class DefaultGenericActionDelegate(
private val observerRepository: ActionObserverRepository,
private val savedStateHandle: SavedStateHandle,
- private val configuration: GenericActionConfiguration,
+ private val checkoutConfiguration: CheckoutConfiguration,
override val componentParams: GenericComponentParams,
private val actionDelegateProvider: ActionDelegateProvider,
) : GenericActionDelegate {
@@ -110,7 +110,7 @@ internal class DefaultGenericActionDelegate(
} else {
val delegate = actionDelegateProvider.getDelegate(
action = action,
- configuration = configuration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = activity.application
)
diff --git a/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt b/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt
index 6d74d82b73..f32e16642e 100644
--- a/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt
+++ b/await/src/main/java/com/adyen/checkout/await/AwaitConfiguration.kt
@@ -89,3 +89,15 @@ fun CheckoutConfiguration.awaitConfiguration(
fun CheckoutConfiguration.getAwaitConfiguration(): AwaitConfiguration? {
return getActionConfiguration(AwaitConfiguration::class.java)
}
+
+internal fun AwaitConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addActionConfiguration(this@toCheckoutConfiguration)
+ }
+}
diff --git a/await/src/main/java/com/adyen/checkout/await/internal/provider/AwaitComponentProvider.kt b/await/src/main/java/com/adyen/checkout/await/internal/provider/AwaitComponentProvider.kt
index c43dfee339..749c92b60c 100644
--- a/await/src/main/java/com/adyen/checkout/await/internal/provider/AwaitComponentProvider.kt
+++ b/await/src/main/java/com/adyen/checkout/await/internal/provider/AwaitComponentProvider.kt
@@ -19,7 +19,9 @@ import com.adyen.checkout.await.AwaitComponent
import com.adyen.checkout.await.AwaitConfiguration
import com.adyen.checkout.await.internal.ui.AwaitDelegate
import com.adyen.checkout.await.internal.ui.DefaultAwaitDelegate
+import com.adyen.checkout.await.toCheckoutConfiguration
import com.adyen.checkout.components.core.ActionComponentCallback
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethodTypes
import com.adyen.checkout.components.core.action.Action
import com.adyen.checkout.components.core.action.AwaitAction
@@ -53,15 +55,15 @@ constructor(
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
application: Application,
- configuration: AwaitConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
callback: ActionComponentCallback,
- key: String?,
+ key: String?
): AwaitComponent {
val awaitFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val awaitDelegate = getDelegate(configuration, savedStateHandle, application)
+ val awaitDelegate = getDelegate(checkoutConfiguration, savedStateHandle, application)
AwaitComponent(
awaitDelegate,
- DefaultActionComponentEventHandler(callback)
+ DefaultActionComponentEventHandler(callback),
)
}
return ViewModelProvider(viewModelStoreOwner, awaitFactory)[key, AwaitComponent::class.java].also { component ->
@@ -70,20 +72,52 @@ constructor(
}
override fun getDelegate(
- configuration: AwaitConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
savedStateHandle: SavedStateHandle,
- application: Application,
+ application: Application
): AwaitDelegate {
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
val statusService = StatusService(httpClient)
- val statusRepository = DefaultStatusRepository(statusService, configuration.clientKey)
+ val statusRepository = DefaultStatusRepository(statusService, componentParams.clientKey)
val paymentDataRepository = PaymentDataRepository(savedStateHandle)
return DefaultAwaitDelegate(
observerRepository = ActionObserverRepository(),
componentParams = componentParams,
statusRepository = statusRepository,
- paymentDataRepository = paymentDataRepository
+ paymentDataRepository = paymentDataRepository,
+ )
+ }
+
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ application: Application,
+ configuration: AwaitConfiguration,
+ callback: ActionComponentCallback,
+ key: String?,
+ ): AwaitComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ application = application,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ callback = callback,
+ key = key,
+ )
+ }
+
+ override fun getDelegate(
+ configuration: AwaitConfiguration,
+ savedStateHandle: SavedStateHandle,
+ application: Application,
+ ): AwaitDelegate {
+ return getDelegate(
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ savedStateHandle = savedStateHandle,
+ application = application,
)
}
diff --git a/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt b/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt
index c7361842fb..9a0dc80f4e 100644
--- a/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt
+++ b/card/src/main/java/com/adyen/checkout/card/CardConfiguration.kt
@@ -312,3 +312,19 @@ fun CheckoutConfiguration.cardConfiguration(
fun CheckoutConfiguration.getCardConfiguration(): CardConfiguration? {
return getConfiguration(PaymentMethodTypes.SCHEME)
}
+
+internal fun CardConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addConfiguration(PaymentMethodTypes.SCHEME, this@toCheckoutConfiguration)
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt b/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt
index ced949a235..50de56cdee 100644
--- a/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt
+++ b/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt
@@ -25,6 +25,8 @@ import com.adyen.checkout.card.internal.ui.DefaultCardDelegate
import com.adyen.checkout.card.internal.ui.StoredCardDelegate
import com.adyen.checkout.card.internal.ui.model.CardComponentParamsMapper
import com.adyen.checkout.card.internal.ui.model.InstallmentsParamsMapper
+import com.adyen.checkout.card.toCheckoutConfiguration
+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
@@ -40,7 +42,6 @@ import com.adyen.checkout.components.core.internal.data.api.DefaultPublicKeyRepo
import com.adyen.checkout.components.core.internal.data.api.PublicKeyService
import com.adyen.checkout.components.core.internal.provider.PaymentComponentProvider
import com.adyen.checkout.components.core.internal.provider.StoredPaymentComponentProvider
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.internal.util.get
import com.adyen.checkout.components.core.internal.util.viewModelFactory
@@ -65,39 +66,39 @@ import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
class CardComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
overrideSessionParams: SessionParams? = null,
+ isCreatedByDropIn: Boolean = false,
private val analyticsRepository: AnalyticsRepository? = null,
) :
PaymentComponentProvider<
CardComponent,
CardConfiguration,
CardComponentState,
- ComponentCallback
+ ComponentCallback,
>,
StoredPaymentComponentProvider<
CardComponent,
CardConfiguration,
CardComponentState,
- ComponentCallback
+ ComponentCallback,
>,
SessionPaymentComponentProvider<
CardComponent,
CardConfiguration,
CardComponentState,
- SessionComponentCallback
+ SessionComponentCallback,
>,
SessionStoredPaymentComponentProvider<
CardComponent,
CardConfiguration,
CardComponentState,
- SessionComponentCallback
+ SessionComponentCallback,
> {
private val componentParamsMapper = CardComponentParamsMapper(
installmentsParamsMapper = InstallmentsParamsMapper(),
- overrideComponentParams = overrideComponentParams,
- overrideSessionParams = overrideSessionParams
+ isCreatedByDropIn = isCreatedByDropIn,
+ overrideSessionParams = overrideSessionParams,
)
@Suppress("LongParameterList", "LongMethod")
@@ -106,7 +107,7 @@ constructor(
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
paymentMethod: PaymentMethod,
- configuration: CardConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: ComponentCallback,
order: Order?,
@@ -116,9 +117,9 @@ constructor(
val factory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParamsDefault(
- configuration,
- paymentMethod,
- null,
+ checkoutConfiguration = checkoutConfiguration,
+ paymentMethod = paymentMethod,
+ sessionParams = null,
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
val genericEncryptor = GenericEncryptorFactory.provide()
@@ -138,7 +139,7 @@ constructor(
paymentMethod = paymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -155,11 +156,11 @@ constructor(
cardValidationMapper = cardValidationMapper,
cardEncryptor = cardEncryptor,
genericEncryptor = genericEncryptor,
- submitHandler = SubmitHandler(savedStateHandle)
+ submitHandler = SubmitHandler(savedStateHandle),
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -184,10 +185,35 @@ constructor(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
- checkoutSession: CheckoutSession,
paymentMethod: PaymentMethod,
configuration: CardConfiguration,
application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?
+ ): CardComponent {
+ return get(
+ savedStateRegistryOwner,
+ viewModelStoreOwner,
+ lifecycleOwner,
+ paymentMethod,
+ configuration.toCheckoutConfiguration(),
+ application,
+ componentCallback,
+ order,
+ key,
+ )
+ }
+
+ @Suppress("LongParameterList", "LongMethod")
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ application: Application,
componentCallback: SessionComponentCallback,
key: String?
): CardComponent {
@@ -195,7 +221,7 @@ constructor(
val factory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParamsDefault(
- cardConfiguration = configuration,
+ checkoutConfiguration = checkoutConfiguration,
paymentMethod = paymentMethod,
sessionParams = SessionParamsFactory.create(checkoutSession),
)
@@ -218,7 +244,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -235,11 +261,11 @@ constructor(
cardValidationMapper = cardValidationMapper,
cardEncryptor = cardEncryptor,
genericEncryptor = genericEncryptor,
- submitHandler = SubmitHandler(savedStateHandle)
+ submitHandler = SubmitHandler(savedStateHandle),
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -254,7 +280,7 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionComponentEventHandler = SessionComponentEventHandler(
sessionInteractor = sessionInteractor,
@@ -276,13 +302,38 @@ constructor(
}
}
+ @Suppress("LongParameterList")
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ configuration: CardConfiguration,
+ application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): CardComponent {
+ return get(
+ savedStateRegistryOwner,
+ viewModelStoreOwner,
+ lifecycleOwner,
+ checkoutSession,
+ paymentMethod,
+ configuration.toCheckoutConfiguration(),
+ application,
+ componentCallback,
+ key,
+ )
+ }
+
@Suppress("LongParameterList", "LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
storedPaymentMethod: StoredPaymentMethod,
- configuration: CardConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: ComponentCallback,
order: Order?,
@@ -291,7 +342,7 @@ constructor(
assertSupported(storedPaymentMethod)
val factory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParamsStored(configuration, null)
+ val componentParams = componentParamsMapper.mapToParamsStored(checkoutConfiguration, null)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
val publicKeyService = PublicKeyService(httpClient)
val publicKeyRepository = DefaultPublicKeyRepository(publicKeyService)
@@ -304,7 +355,7 @@ constructor(
storedPaymentMethod = storedPaymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -317,11 +368,11 @@ constructor(
analyticsRepository = analyticsRepository,
cardEncryptor = cardEncryptor,
publicKeyRepository = publicKeyRepository,
- submitHandler = SubmitHandler(savedStateHandle)
+ submitHandler = SubmitHandler(savedStateHandle),
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -341,6 +392,31 @@ constructor(
}
}
+ @Suppress("LongParameterList")
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ storedPaymentMethod: StoredPaymentMethod,
+ configuration: CardConfiguration,
+ application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?
+ ): CardComponent {
+ return get(
+ savedStateRegistryOwner,
+ viewModelStoreOwner,
+ lifecycleOwner,
+ storedPaymentMethod,
+ configuration.toCheckoutConfiguration(),
+ application,
+ componentCallback,
+ order,
+ key,
+ )
+ }
+
@Suppress("LongParameterList", "LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
@@ -348,7 +424,7 @@ constructor(
lifecycleOwner: LifecycleOwner,
checkoutSession: CheckoutSession,
storedPaymentMethod: StoredPaymentMethod,
- configuration: CardConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: SessionComponentCallback,
key: String?
@@ -357,7 +433,7 @@ constructor(
val factory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParamsStored(
- cardConfiguration = configuration,
+ checkoutConfiguration = checkoutConfiguration,
sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
@@ -373,7 +449,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -386,11 +462,11 @@ constructor(
analyticsRepository = analyticsRepository,
cardEncryptor = cardEncryptor,
publicKeyRepository = publicKeyRepository,
- submitHandler = SubmitHandler(savedStateHandle)
+ submitHandler = SubmitHandler(savedStateHandle),
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -405,7 +481,7 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionComponentEventHandler = SessionComponentEventHandler(
sessionInteractor = sessionInteractor,
@@ -427,6 +503,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ storedPaymentMethod: StoredPaymentMethod,
+ configuration: CardConfiguration,
+ application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): CardComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ checkoutSession = checkoutSession,
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
private fun assertSupported(paymentMethod: PaymentMethod) {
if (!isPaymentMethodSupported(paymentMethod)) {
throw ComponentException("Unsupported payment method ${paymentMethod.type}")
diff --git a/card/src/main/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapper.kt b/card/src/main/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapper.kt
index 726a6f57c6..022f2abd76 100644
--- a/card/src/main/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapper.kt
+++ b/card/src/main/java/com/adyen/checkout/card/internal/ui/model/CardComponentParamsMapper.kt
@@ -13,9 +13,10 @@ import com.adyen.checkout.card.CardBrand
import com.adyen.checkout.card.CardConfiguration
import com.adyen.checkout.card.KCPAuthVisibility
import com.adyen.checkout.card.SocialSecurityNumberVisibility
+import com.adyen.checkout.card.getCardConfiguration
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethod
import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParams
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.core.internal.util.LogUtil
import com.adyen.checkout.core.internal.util.Logger
@@ -25,79 +26,78 @@ import com.adyen.checkout.ui.core.internal.ui.model.AddressParams
@Suppress("TooManyFunctions")
internal class CardComponentParamsMapper(
private val installmentsParamsMapper: InstallmentsParamsMapper,
- private val overrideComponentParams: ComponentParams?,
+ private val isCreatedByDropIn: Boolean,
private val overrideSessionParams: SessionParams?,
) {
fun mapToParamsDefault(
- cardConfiguration: CardConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
paymentMethod: PaymentMethod,
sessionParams: SessionParams?,
): CardComponentParams {
- val supportedCardBrands = cardConfiguration.getSupportedCardBrands(paymentMethod)
return mapToParams(
- cardConfiguration,
- supportedCardBrands,
+ checkoutConfiguration,
+ paymentMethod,
sessionParams,
)
}
fun mapToParamsStored(
- cardConfiguration: CardConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
sessionParams: SessionParams?,
): CardComponentParams {
- val supportedCardBrands = cardConfiguration.getSupportedCardBrandsStored()
return mapToParams(
- cardConfiguration,
- supportedCardBrands,
+ checkoutConfiguration,
+ null,
sessionParams,
)
}
private fun mapToParams(
- cardConfiguration: CardConfiguration,
- supportedCardBrands: List,
+ checkoutConfiguration: CheckoutConfiguration,
+ paymentMethod: PaymentMethod?,
sessionParams: SessionParams?,
): CardComponentParams {
- return cardConfiguration
- .mapToParamsInternal(supportedCardBrands)
- .override(overrideComponentParams)
+ return checkoutConfiguration
+ .mapToParamsInternal(paymentMethod)
.override(sessionParams ?: overrideSessionParams)
}
- private fun CardConfiguration.mapToParamsInternal(
- supportedCardBrands: List,
+ private fun CheckoutConfiguration.mapToParamsInternal(
+ paymentMethod: PaymentMethod?,
): CardComponentParams {
+ val cardConfiguration = getCardConfiguration()
return CardComponentParams(
shopperLocale = shopperLocale,
environment = environment,
clientKey = clientKey,
analyticsParams = AnalyticsParams(analyticsConfiguration),
- isCreatedByDropIn = false,
+ isCreatedByDropIn = isCreatedByDropIn,
amount = amount,
- isHolderNameRequired = isHolderNameRequired ?: false,
- isSubmitButtonVisible = isSubmitButtonVisible ?: true,
- supportedCardBrands = supportedCardBrands,
- shopperReference = shopperReference,
- isStorePaymentFieldVisible = isStorePaymentFieldVisible ?: true,
- socialSecurityNumberVisibility = socialSecurityNumberVisibility ?: SocialSecurityNumberVisibility.HIDE,
- kcpAuthVisibility = kcpAuthVisibility ?: KCPAuthVisibility.HIDE,
+ isHolderNameRequired = cardConfiguration?.isHolderNameRequired ?: false,
+ isSubmitButtonVisible = cardConfiguration?.isSubmitButtonVisible ?: true,
+ supportedCardBrands = getSupportedCardBrands(paymentMethod),
+ shopperReference = cardConfiguration?.shopperReference,
+ isStorePaymentFieldVisible = cardConfiguration?.isStorePaymentFieldVisible ?: true,
+ socialSecurityNumberVisibility = cardConfiguration?.socialSecurityNumberVisibility
+ ?: SocialSecurityNumberVisibility.HIDE,
+ kcpAuthVisibility = cardConfiguration?.kcpAuthVisibility ?: KCPAuthVisibility.HIDE,
installmentParams = installmentsParamsMapper.mapToInstallmentParams(
- installmentConfiguration = installmentConfiguration,
+ installmentConfiguration = cardConfiguration?.installmentConfiguration,
amount = amount,
- shopperLocale = shopperLocale
+ shopperLocale = shopperLocale,
),
- addressParams = addressConfiguration?.mapToAddressParam() ?: AddressParams.None,
- cvcVisibility = if (isHideCvc == true) {
+ addressParams = cardConfiguration?.addressConfiguration?.mapToAddressParam() ?: AddressParams.None,
+ cvcVisibility = if (cardConfiguration?.isHideCvc == true) {
CVCVisibility.ALWAYS_HIDE
} else {
CVCVisibility.ALWAYS_SHOW
},
- storedCVCVisibility = if (isHideCvcStoredCard == true) {
+ storedCVCVisibility = if (cardConfiguration?.isHideCvcStoredCard == true) {
StoredCVCVisibility.HIDE
} else {
StoredCVCVisibility.SHOW
- }
+ },
)
}
@@ -106,18 +106,19 @@ internal class CardComponentParamsMapper(
* Priority is: Custom -> PaymentMethod.brands -> Default
* remove restricted card type
*/
- private fun CardConfiguration.getSupportedCardBrands(
- paymentMethod: PaymentMethod
+ private fun CheckoutConfiguration.getSupportedCardBrands(
+ paymentMethod: PaymentMethod?
): List {
+ val test = getCardConfiguration()?.supportedCardBrands
return when {
- !supportedCardBrands.isNullOrEmpty() -> {
+ !test.isNullOrEmpty() -> {
Logger.v(TAG, "Reading supportedCardTypes from configuration")
- supportedCardBrands
+ test
}
- paymentMethod.brands.orEmpty().isNotEmpty() -> {
+ paymentMethod?.brands.orEmpty().isNotEmpty() -> {
Logger.v(TAG, "Reading supportedCardTypes from API brands")
- paymentMethod.brands.orEmpty().map {
+ paymentMethod?.brands.orEmpty().map {
CardBrand(txVariant = it)
}
}
@@ -129,35 +130,17 @@ internal class CardComponentParamsMapper(
}.removeRestrictedCards()
}
- private fun CardConfiguration.getSupportedCardBrandsStored(): List {
- return supportedCardBrands.orEmpty().removeRestrictedCards()
- }
-
private fun List.removeRestrictedCards(): List {
return this.filter { !RestrictedCardType.isRestrictedCardType(it.txVariant) }
}
- private fun CardComponentParams.override(
- overrideComponentParams: ComponentParams?
- ): CardComponentParams {
- if (overrideComponentParams == null) return this
- return copy(
- shopperLocale = overrideComponentParams.shopperLocale,
- environment = overrideComponentParams.environment,
- clientKey = overrideComponentParams.clientKey,
- analyticsParams = overrideComponentParams.analyticsParams,
- isCreatedByDropIn = overrideComponentParams.isCreatedByDropIn,
- amount = overrideComponentParams.amount,
- )
- }
-
private fun AddressConfiguration.mapToAddressParam(): AddressParams {
return when (this) {
is AddressConfiguration.FullAddress -> {
AddressParams.FullAddress(
defaultCountryCode,
supportedCountryCodes,
- addressFieldPolicy.mapToAddressParamFieldPolicy()
+ addressFieldPolicy.mapToAddressParamFieldPolicy(),
)
}
@@ -199,7 +182,7 @@ internal class CardComponentParamsMapper(
installmentParams = installmentsParamsMapper.mapToInstallmentParams(
installmentConfiguration = sessionParams.installmentConfiguration,
amount = sessionParams.amount ?: amount,
- shopperLocale = shopperLocale
+ shopperLocale = shopperLocale,
),
amount = sessionParams.amount ?: amount,
)
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/ActionComponentProvider.kt b/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/ActionComponentProvider.kt
index 3e7cae34e0..a545e18894 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/ActionComponentProvider.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/ActionComponentProvider.kt
@@ -16,6 +16,7 @@ import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModelStoreOwner
import androidx.savedstate.SavedStateRegistryOwner
import com.adyen.checkout.components.core.ActionComponentCallback
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.action.Action
import com.adyen.checkout.components.core.internal.ActionComponent
import com.adyen.checkout.components.core.internal.Configuration
@@ -28,6 +29,106 @@ interface ActionComponentProvider<
DelegateT : ActionDelegate
> : ComponentProvider {
+ //region CheckoutConfiguration
+
+ /**
+ * Get an [ActionComponent].
+ *
+ * @param fragment The Fragment to associate the lifecycle.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param callback The callback to handle events from the [ActionComponent].
+ * @param key The key to use to identify the [ActionComponent].
+ *
+ * NOTE: By default only one [ActionComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [ActionComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ fun get(
+ fragment: Fragment,
+ checkoutConfiguration: CheckoutConfiguration,
+ callback: ActionComponentCallback,
+ key: String? = null,
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = fragment,
+ viewModelStoreOwner = fragment,
+ lifecycleOwner = fragment.viewLifecycleOwner,
+ application = fragment.requireApplication(),
+ checkoutConfiguration = checkoutConfiguration,
+ callback = callback,
+ key = key,
+ )
+ }
+
+ /**
+ * Get an [ActionComponent].
+ *
+ * @param activity The Activity to associate the lifecycle.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param callback The callback to handle events from the [ActionComponent].
+ * @param key The key to use to identify the [ActionComponent].
+ *
+ * NOTE: By default only one [ActionComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [ActionComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ fun get(
+ activity: ComponentActivity,
+ checkoutConfiguration: CheckoutConfiguration,
+ callback: ActionComponentCallback,
+ key: String? = null,
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = activity,
+ viewModelStoreOwner = activity,
+ lifecycleOwner = activity,
+ application = activity.application,
+ checkoutConfiguration = checkoutConfiguration,
+ callback = callback,
+ key = key,
+ )
+ }
+
+ /**
+ * Get an [ActionComponent].
+ *
+ * @param savedStateRegistryOwner The owner of the SavedStateRegistry, normally an Activity or Fragment.
+ * @param viewModelStoreOwner A scope that owns ViewModelStore, normally an Activity or Fragment.
+ * @param lifecycleOwner The lifecycle owner, normally an Activity or Fragment.
+ * @param application Your main application class.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param callback The callback to handle events from the [ActionComponent].
+ * @param key The key to use to identify the [ActionComponent].
+ *
+ * NOTE: By default only one [ActionComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [ActionComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ application: Application,
+ checkoutConfiguration: CheckoutConfiguration,
+ callback: ActionComponentCallback,
+ key: String? = null,
+ ): ComponentT
+
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ fun getDelegate(
+ checkoutConfiguration: CheckoutConfiguration,
+ savedStateHandle: SavedStateHandle,
+ application: Application
+ ): DelegateT
+
+ //endregion
+
+ //region Component specific configuration
+
/**
* Get an [ActionComponent].
*
@@ -54,7 +155,7 @@ interface ActionComponentProvider<
application = fragment.requireApplication(),
configuration = configuration,
callback = callback,
- key = key
+ key = key,
)
}
@@ -84,7 +185,7 @@ interface ActionComponentProvider<
application = activity.application,
configuration = configuration,
callback = callback,
- key = key
+ key = key,
)
}
@@ -115,6 +216,7 @@ interface ActionComponentProvider<
key: String? = null,
): ComponentT
+ // TODO: is this still needed?
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun getDelegate(
configuration: ConfigurationT,
@@ -122,6 +224,8 @@ interface ActionComponentProvider<
application: Application,
): DelegateT
+ //endregion
+
/**
* Checks if the provided component can handle a given action.
*
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/PaymentComponentProvider.kt b/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/PaymentComponentProvider.kt
index d3da63fbbf..8a87510ee6 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/PaymentComponentProvider.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/PaymentComponentProvider.kt
@@ -13,6 +13,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewModelStoreOwner
import androidx.savedstate.SavedStateRegistryOwner
+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.PaymentComponentState
@@ -29,6 +30,117 @@ interface PaymentComponentProvider<
> :
ComponentProvider {
+ //region CheckoutConfiguration
+
+ /**
+ * Get a [PaymentComponent].
+ *
+ * @param fragment The Fragment to associate the lifecycle.
+ * @param paymentMethod The corresponding [PaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param callback The callback to handle events from the [PaymentComponent].
+ * @param order An [Order] in case of an ongoing partial payment flow.
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ fragment: Fragment,
+ paymentMethod: PaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ callback: ComponentCallbackT,
+ order: Order? = null,
+ key: String? = null,
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = fragment,
+ viewModelStoreOwner = fragment,
+ lifecycleOwner = fragment.viewLifecycleOwner,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = checkoutConfiguration,
+ application = fragment.requireApplication(),
+ componentCallback = callback,
+ order = order,
+ key = key,
+ )
+ }
+
+ /**
+ * Get a [PaymentComponent].
+ *
+ * @param activity The Activity to associate the lifecycle.
+ * @param paymentMethod The corresponding [PaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param callback The callback to handle events from the [PaymentComponent].
+ * @param order An [Order] in case of an ongoing partial payment flow.
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ activity: ComponentActivity,
+ paymentMethod: PaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ callback: ComponentCallbackT,
+ order: Order? = null,
+ key: String? = null,
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = activity,
+ viewModelStoreOwner = activity,
+ lifecycleOwner = activity,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = checkoutConfiguration,
+ application = activity.application,
+ componentCallback = callback,
+ order = order,
+ key = key,
+ )
+ }
+
+ /**
+ * Get a [PaymentComponent].
+ *
+ * @param savedStateRegistryOwner The owner of the SavedStateRegistry, normally an Activity or Fragment.
+ * @param viewModelStoreOwner A scope that owns ViewModelStore, normally an Activity or Fragment.
+ * @param lifecycleOwner The lifecycle owner, normally an Activity or Fragment.
+ * @param paymentMethod The corresponding [PaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param application Your main application class.
+ * @param componentCallback The callback to handle events from the [PaymentComponent].
+ * @param order An [Order] in case of an ongoing partial payment flow.
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ paymentMethod: PaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ application: Application,
+ componentCallback: ComponentCallbackT,
+ order: Order?,
+ key: String?,
+ ): ComponentT
+
+ //endregion
+
+ //region Payment method specific configuration
+
/**
* Get a [PaymentComponent].
*
@@ -134,6 +246,8 @@ interface PaymentComponentProvider<
key: String?,
): ComponentT
+ //endregion
+
/**
* Checks if the provided component can handle a given payment method.
*/
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/StoredPaymentComponentProvider.kt b/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/StoredPaymentComponentProvider.kt
index 5167df31e8..14842a2c0b 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/StoredPaymentComponentProvider.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/internal/provider/StoredPaymentComponentProvider.kt
@@ -13,6 +13,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewModelStoreOwner
import androidx.savedstate.SavedStateRegistryOwner
+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.PaymentComponentState
@@ -28,6 +29,117 @@ interface StoredPaymentComponentProvider<
ComponentCallbackT : ComponentCallback
> {
+ //region CheckoutConfiguration
+
+ /**
+ * Get a [PaymentComponent] with a stored payment method.
+ *
+ * @param fragment The Fragment to associate the lifecycle.
+ * @param storedPaymentMethod The corresponding [StoredPaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param callback The callback to handle events from the [PaymentComponent].
+ * @param order An [Order] in case of an ongoing partial payment flow.
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ fragment: Fragment,
+ storedPaymentMethod: StoredPaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ callback: ComponentCallbackT,
+ order: Order? = null,
+ key: String? = null,
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = fragment,
+ viewModelStoreOwner = fragment,
+ lifecycleOwner = fragment.viewLifecycleOwner,
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = checkoutConfiguration,
+ application = fragment.requireApplication(),
+ componentCallback = callback,
+ order = order,
+ key = key,
+ )
+ }
+
+ /**
+ * Get a [PaymentComponent] with a stored payment method.
+ *
+ * @param activity The Activity to associate the lifecycle.
+ * @param storedPaymentMethod The corresponding [StoredPaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param callback The callback to handle events from the [PaymentComponent].
+ * @param order An [Order] in case of an ongoing partial payment flow.
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ activity: ComponentActivity,
+ storedPaymentMethod: StoredPaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ callback: ComponentCallbackT,
+ order: Order? = null,
+ key: String? = null,
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = activity,
+ viewModelStoreOwner = activity,
+ lifecycleOwner = activity,
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = checkoutConfiguration,
+ application = activity.application,
+ componentCallback = callback,
+ order = order,
+ key = key,
+ )
+ }
+
+ /**
+ * Get a [PaymentComponent] with a stored payment method.
+ *
+ * @param savedStateRegistryOwner The owner of the SavedStateRegistry, normally an Activity or Fragment.
+ * @param viewModelStoreOwner A scope that owns ViewModelStore, normally an Activity or Fragment.
+ * @param lifecycleOwner The lifecycle owner, normally an Activity or Fragment.
+ * @param storedPaymentMethod The corresponding [StoredPaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param application Your main application class.
+ * @param componentCallback The callback to handle events from the [PaymentComponent].
+ * @param order An [Order] in case of an ongoing partial payment flow.
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ storedPaymentMethod: StoredPaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ application: Application,
+ componentCallback: ComponentCallbackT,
+ order: Order?,
+ key: String?,
+ ): ComponentT
+
+ //endregion
+
+ //region Payment method specific configuration
+
/**
* Get a [PaymentComponent] with a stored payment method.
*
@@ -133,6 +245,8 @@ interface StoredPaymentComponentProvider<
key: String?,
): ComponentT
+ //endregion
+
/**
* Checks if the provided component can handle a given stored payment method.
*/
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/GenericComponentParamsMapper.kt b/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/GenericComponentParamsMapper.kt
index 5a38ef2c39..b39149494d 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/GenericComponentParamsMapper.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/GenericComponentParamsMapper.kt
@@ -13,6 +13,7 @@ import com.adyen.checkout.components.core.internal.Configuration
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
class GenericComponentParamsMapper(
+ // TODO: Replace with just CheckoutConfiguration
private val overrideComponentParams: ComponentParams?,
private val overrideSessionParams: SessionParams?,
) {
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
index 34b72b279b..c2b8bd25ca 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
@@ -170,7 +170,7 @@ internal fun getComponentFor(
checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
val cardConfig: CardConfiguration =
getConfigurationForPaymentMethod(storedPaymentMethod, checkoutConfiguration)
- CardComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ CardComponentProvider(sessionParams, true, analyticsRepository).get(
fragment = fragment,
storedPaymentMethod = storedPaymentMethod,
configuration = cardConfig,
@@ -291,7 +291,7 @@ internal fun getComponentFor(
checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val cardConfig: CardConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- CardComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ CardComponentProvider(sessionParams, true, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = cardConfig,
diff --git a/example-app/src/main/java/com/adyen/checkout/example/ui/card/CardActivity.kt b/example-app/src/main/java/com/adyen/checkout/example/ui/card/CardActivity.kt
index 051aaedacc..9fc8996d53 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/ui/card/CardActivity.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/ui/card/CardActivity.kt
@@ -92,7 +92,7 @@ class CardActivity : AppCompatActivity() {
val cardComponent = CardComponent.PROVIDER.get(
activity = this,
paymentMethod = cardComponentData.paymentMethod,
- configuration = checkoutConfigurationProvider.getCardConfiguration(),
+ checkoutConfiguration = checkoutConfigurationProvider.checkoutConfig,
callback = cardComponentData.callback,
)
diff --git a/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardTakenOverActivity.kt b/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardTakenOverActivity.kt
index f390faf020..a5173126eb 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardTakenOverActivity.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/ui/card/SessionsCardTakenOverActivity.kt
@@ -101,7 +101,7 @@ class SessionsCardTakenOverActivity : AppCompatActivity() {
activity = this,
checkoutSession = sessionsCardComponentData.checkoutSession,
paymentMethod = sessionsCardComponentData.paymentMethod,
- configuration = checkoutConfigurationProvider.getCardConfiguration(),
+ checkoutConfiguration = checkoutConfigurationProvider.checkoutConfig,
componentCallback = sessionsCardComponentData.callback
)
diff --git a/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt b/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt
index 9ed8c61622..fff3c16261 100644
--- a/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt
+++ b/qr-code/src/main/java/com/adyen/checkout/qrcode/QRCodeConfiguration.kt
@@ -90,3 +90,15 @@ fun CheckoutConfiguration.QRCodeConfiguration(
fun CheckoutConfiguration.getQRCodeConfiguration(): QRCodeConfiguration? {
return getActionConfiguration(QRCodeConfiguration::class.java)
}
+
+internal fun QRCodeConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addActionConfiguration(this@toCheckoutConfiguration)
+ }
+}
diff --git a/qr-code/src/main/java/com/adyen/checkout/qrcode/internal/provider/QRCodeComponentProvider.kt b/qr-code/src/main/java/com/adyen/checkout/qrcode/internal/provider/QRCodeComponentProvider.kt
index a78408da19..b373e9f271 100644
--- a/qr-code/src/main/java/com/adyen/checkout/qrcode/internal/provider/QRCodeComponentProvider.kt
+++ b/qr-code/src/main/java/com/adyen/checkout/qrcode/internal/provider/QRCodeComponentProvider.kt
@@ -16,6 +16,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStoreOwner
import androidx.savedstate.SavedStateRegistryOwner
import com.adyen.checkout.components.core.ActionComponentCallback
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.action.Action
import com.adyen.checkout.components.core.action.QrCodeAction
import com.adyen.checkout.components.core.internal.ActionObserverRepository
@@ -35,6 +36,7 @@ import com.adyen.checkout.qrcode.QRCodeConfiguration
import com.adyen.checkout.qrcode.internal.QRCodeCountDownTimer
import com.adyen.checkout.qrcode.internal.ui.DefaultQRCodeDelegate
import com.adyen.checkout.qrcode.internal.ui.QRCodeDelegate
+import com.adyen.checkout.qrcode.toCheckoutConfiguration
import com.adyen.checkout.ui.core.internal.DefaultRedirectHandler
import com.adyen.checkout.ui.core.internal.util.ImageSaver
@@ -52,15 +54,15 @@ constructor(
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
application: Application,
- configuration: QRCodeConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
callback: ActionComponentCallback,
- key: String?,
+ key: String?
): QRCodeComponent {
val qrCodeFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val qrCodeDelegate = getDelegate(configuration, savedStateHandle, application)
+ val qrCodeDelegate = getDelegate(checkoutConfiguration, savedStateHandle, application)
QRCodeComponent(
delegate = qrCodeDelegate,
- actionComponentEventHandler = DefaultActionComponentEventHandler(callback)
+ actionComponentEventHandler = DefaultActionComponentEventHandler(callback),
)
}
return ViewModelProvider(viewModelStoreOwner, qrCodeFactory)[key, QRCodeComponent::class.java]
@@ -70,14 +72,14 @@ constructor(
}
override fun getDelegate(
- configuration: QRCodeConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
savedStateHandle: SavedStateHandle,
- application: Application,
+ application: Application
): QRCodeDelegate {
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
val statusService = StatusService(httpClient)
- val statusRepository = DefaultStatusRepository(statusService, configuration.clientKey)
+ val statusRepository = DefaultStatusRepository(statusService, componentParams.clientKey)
val countDownTimer = QRCodeCountDownTimer()
val redirectHandler = DefaultRedirectHandler()
val paymentDataRepository = PaymentDataRepository(savedStateHandle)
@@ -89,7 +91,39 @@ constructor(
statusCountDownTimer = countDownTimer,
redirectHandler = redirectHandler,
paymentDataRepository = paymentDataRepository,
- imageSaver = ImageSaver()
+ imageSaver = ImageSaver(),
+ )
+ }
+
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ application: Application,
+ configuration: QRCodeConfiguration,
+ callback: ActionComponentCallback,
+ key: String?,
+ ): QRCodeComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ application = application,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ callback = callback,
+ key = key,
+ )
+ }
+
+ override fun getDelegate(
+ configuration: QRCodeConfiguration,
+ savedStateHandle: SavedStateHandle,
+ application: Application,
+ ): QRCodeDelegate {
+ return getDelegate(
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ savedStateHandle = savedStateHandle,
+ application = application,
)
}
diff --git a/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt b/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt
index 2736943be0..926ed7d32e 100644
--- a/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt
+++ b/redirect/src/main/java/com/adyen/checkout/redirect/RedirectConfiguration.kt
@@ -44,7 +44,7 @@ class RedirectConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -57,7 +57,7 @@ class RedirectConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
override fun buildInternal(): RedirectConfiguration {
@@ -89,3 +89,15 @@ fun CheckoutConfiguration.redirectConfiguration(
fun CheckoutConfiguration.getRedirectConfiguration(): RedirectConfiguration? {
return getActionConfiguration(RedirectConfiguration::class.java)
}
+
+internal fun RedirectConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addActionConfiguration(this@toCheckoutConfiguration)
+ }
+}
diff --git a/redirect/src/main/java/com/adyen/checkout/redirect/internal/provider/RedirectComponentProvider.kt b/redirect/src/main/java/com/adyen/checkout/redirect/internal/provider/RedirectComponentProvider.kt
index 6a01d7ff4d..4efd87be58 100644
--- a/redirect/src/main/java/com/adyen/checkout/redirect/internal/provider/RedirectComponentProvider.kt
+++ b/redirect/src/main/java/com/adyen/checkout/redirect/internal/provider/RedirectComponentProvider.kt
@@ -16,6 +16,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStoreOwner
import androidx.savedstate.SavedStateRegistryOwner
import com.adyen.checkout.components.core.ActionComponentCallback
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.action.Action
import com.adyen.checkout.components.core.action.RedirectAction
import com.adyen.checkout.components.core.internal.ActionObserverRepository
@@ -31,6 +32,7 @@ import com.adyen.checkout.redirect.RedirectComponent
import com.adyen.checkout.redirect.RedirectConfiguration
import com.adyen.checkout.redirect.internal.ui.DefaultRedirectDelegate
import com.adyen.checkout.redirect.internal.ui.RedirectDelegate
+import com.adyen.checkout.redirect.toCheckoutConfiguration
import com.adyen.checkout.ui.core.internal.DefaultRedirectHandler
class RedirectComponentProvider
@@ -47,15 +49,15 @@ constructor(
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
application: Application,
- configuration: RedirectConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
callback: ActionComponentCallback,
- key: String?,
+ key: String?
): RedirectComponent {
val redirectFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val redirectDelegate = getDelegate(configuration, savedStateHandle, application)
+ val redirectDelegate = getDelegate(checkoutConfiguration, savedStateHandle, application)
RedirectComponent(
delegate = redirectDelegate,
- actionComponentEventHandler = DefaultActionComponentEventHandler(callback)
+ actionComponentEventHandler = DefaultActionComponentEventHandler(callback),
)
}
return ViewModelProvider(viewModelStoreOwner, redirectFactory)[key, RedirectComponent::class.java]
@@ -65,18 +67,50 @@ constructor(
}
override fun getDelegate(
- configuration: RedirectConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
savedStateHandle: SavedStateHandle,
- application: Application,
+ application: Application
): RedirectDelegate {
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
val redirectHandler = DefaultRedirectHandler()
val paymentDataRepository = PaymentDataRepository(savedStateHandle)
return DefaultRedirectDelegate(
observerRepository = ActionObserverRepository(),
componentParams = componentParams,
redirectHandler = redirectHandler,
- paymentDataRepository = paymentDataRepository
+ paymentDataRepository = paymentDataRepository,
+ )
+ }
+
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ application: Application,
+ configuration: RedirectConfiguration,
+ callback: ActionComponentCallback,
+ key: String?,
+ ): RedirectComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ application = application,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ callback = callback,
+ key = key,
+ )
+ }
+
+ override fun getDelegate(
+ configuration: RedirectConfiguration,
+ savedStateHandle: SavedStateHandle,
+ application: Application,
+ ): RedirectDelegate {
+ return getDelegate(
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ savedStateHandle = savedStateHandle,
+ application = application,
)
}
diff --git a/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/provider/SessionPaymentComponentProvider.kt b/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/provider/SessionPaymentComponentProvider.kt
index 9d5b3a1241..0b588e7ea9 100644
--- a/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/provider/SessionPaymentComponentProvider.kt
+++ b/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/provider/SessionPaymentComponentProvider.kt
@@ -14,6 +14,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewModelStoreOwner
import androidx.savedstate.SavedStateRegistryOwner
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentComponentState
import com.adyen.checkout.components.core.PaymentMethod
import com.adyen.checkout.components.core.internal.Configuration
@@ -29,6 +30,120 @@ interface SessionPaymentComponentProvider<
ComponentCallbackT : SessionComponentCallback
> {
+ //region CheckoutConfiguration
+
+ /**
+ * Get a [PaymentComponent] with a checkout session. You only need to integrate with the /sessions endpoint to
+ * create a session and the component will automatically handle the rest of the payment flow.
+ *
+ * @param fragment The Fragment to associate the lifecycle.
+ * @param checkoutSession The [CheckoutSession] object to launch this component.
+ * @param paymentMethod The corresponding [PaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param componentCallback The callback to handle events from the [PaymentComponent].
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ fragment: Fragment,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ componentCallback: ComponentCallbackT,
+ key: String? = null,
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = fragment,
+ viewModelStoreOwner = fragment,
+ lifecycleOwner = fragment.viewLifecycleOwner,
+ checkoutSession = checkoutSession,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = checkoutConfiguration,
+ application = fragment.requireApplication(),
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
+ /**
+ * Get a [PaymentComponent] with a checkout session. You only need to integrate with the /sessions endpoint to
+ * create a session and the component will automatically handle the rest of the payment flow.
+ *
+ * @param activity The Activity to associate the lifecycle.
+ * @param checkoutSession The [CheckoutSession] object to launch this component.
+ * @param paymentMethod The corresponding [PaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param componentCallback The callback to handle events from the [PaymentComponent].
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ activity: ComponentActivity,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ componentCallback: ComponentCallbackT,
+ key: String? = null,
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = activity,
+ viewModelStoreOwner = activity,
+ lifecycleOwner = activity,
+ checkoutSession = checkoutSession,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = checkoutConfiguration,
+ application = activity.application,
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
+ /**
+ * Get a [PaymentComponent] with a checkout session. You only need to integrate with the /sessions endpoint to
+ * create a session and the component will automatically handle the rest of the payment flow.
+ *
+ * @param savedStateRegistryOwner The owner of the SavedStateRegistry, normally an Activity or Fragment.
+ * @param viewModelStoreOwner A scope that owns ViewModelStore, normally an Activity or Fragment.
+ * @param lifecycleOwner The lifecycle owner, normally an Activity or Fragment.
+ * @param checkoutSession The [CheckoutSession] object to launch this component.
+ * @param paymentMethod The corresponding [PaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param application Your main application class.
+ * @param componentCallback The callback to handle events from the [PaymentComponent].
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ application: Application,
+ componentCallback: ComponentCallbackT,
+ key: String?,
+ ): ComponentT
+
+ //endregion
+
+ //region Payment method specific configuration
+
/**
* Get a [PaymentComponent] with a checkout session. You only need to integrate with the /sessions endpoint to
* create a session and the component will automatically handle the rest of the payment flow.
@@ -136,4 +251,6 @@ interface SessionPaymentComponentProvider<
componentCallback: ComponentCallbackT,
key: String?,
): ComponentT
+
+ //endregion
}
diff --git a/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/provider/SessionStoredPaymentComponentProvider.kt b/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/provider/SessionStoredPaymentComponentProvider.kt
index 321b3cf944..cded6d2e5f 100644
--- a/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/provider/SessionStoredPaymentComponentProvider.kt
+++ b/sessions-core/src/main/java/com/adyen/checkout/sessions/core/internal/provider/SessionStoredPaymentComponentProvider.kt
@@ -14,6 +14,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewModelStoreOwner
import androidx.savedstate.SavedStateRegistryOwner
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentComponentState
import com.adyen.checkout.components.core.StoredPaymentMethod
import com.adyen.checkout.components.core.internal.Configuration
@@ -29,6 +30,123 @@ interface SessionStoredPaymentComponentProvider<
ComponentCallbackT : SessionComponentCallback
> {
+ //region CheckoutConfiguration
+
+ /**
+ * Get a [PaymentComponent] with a stored payment method and a checkout session. You only need to integrate with
+ * the /sessions endpoint to create a session and the component will automatically handle the rest of the payment
+ * flow.
+ *
+ * @param fragment The Fragment to associate the lifecycle.
+ * @param checkoutSession The [CheckoutSession] object to launch this component.
+ * @param storedPaymentMethod The corresponding [StoredPaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param componentCallback The callback to handle events from the [PaymentComponent].
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ fragment: Fragment,
+ checkoutSession: CheckoutSession,
+ storedPaymentMethod: StoredPaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ componentCallback: ComponentCallbackT,
+ key: String? = null,
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = fragment,
+ viewModelStoreOwner = fragment,
+ lifecycleOwner = fragment.viewLifecycleOwner,
+ checkoutSession = checkoutSession,
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = checkoutConfiguration,
+ application = fragment.requireApplication(),
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
+ /**
+ * Get a [PaymentComponent] with a stored payment method and a checkout session. You only need to integrate with
+ * the /sessions endpoint to create a session and the component will automatically handle the rest of the payment
+ * flow.
+ *
+ * @param activity The Activity to associate the lifecycle.
+ * @param checkoutSession The [CheckoutSession] object to launch this component.
+ * @param storedPaymentMethod The corresponding [StoredPaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param componentCallback The callback to handle events from the [PaymentComponent].
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ activity: ComponentActivity,
+ checkoutSession: CheckoutSession,
+ storedPaymentMethod: StoredPaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ componentCallback: ComponentCallbackT,
+ key: String? = null,
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = activity,
+ viewModelStoreOwner = activity,
+ lifecycleOwner = activity,
+ checkoutSession = checkoutSession,
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = checkoutConfiguration,
+ application = activity.application,
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
+ /**
+ * Get a [PaymentComponent] with a stored payment method and a checkout session. You only need to integrate with
+ * the /sessions endpoint to create a session and the component will automatically handle the rest of the payment
+ * flow.
+ *
+ * @param savedStateRegistryOwner The owner of the SavedStateRegistry, normally an Activity or Fragment.
+ * @param viewModelStoreOwner A scope that owns ViewModelStore, normally an Activity or Fragment.
+ * @param lifecycleOwner The lifecycle owner, normally an Activity or Fragment.
+ * @param checkoutSession The [CheckoutSession] object to launch this component.
+ * @param storedPaymentMethod The corresponding [StoredPaymentMethod] object.
+ * @param checkoutConfiguration The [CheckoutConfiguration].
+ * @param application Your main application class.
+ * @param componentCallback The callback to handle events from the [PaymentComponent].
+ * @param key The key to use to identify the [PaymentComponent].
+ *
+ * NOTE: By default only one [PaymentComponent] will be created per lifecycle. Use [key] in case you need to
+ * instantiate multiple [PaymentComponent]s in the same lifecycle.
+ *
+ * @return The Component
+ */
+ @Suppress("LongParameterList")
+ fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ storedPaymentMethod: StoredPaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ application: Application,
+ componentCallback: ComponentCallbackT,
+ key: String?,
+ ): ComponentT
+
+ //endregion
+
+ //region Payment method specific configuration
+
/**
* Get a [PaymentComponent] with a stored payment method and a checkout session. You only need to integrate with
* the /sessions endpoint to create a session and the component will automatically handle the rest of the payment
@@ -139,4 +257,6 @@ interface SessionStoredPaymentComponentProvider<
componentCallback: ComponentCallbackT,
key: String?,
): ComponentT
+
+ //endregion
}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt b/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt
index ff06ef92e3..4a3ec54e88 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/VoucherConfiguration.kt
@@ -90,3 +90,15 @@ fun CheckoutConfiguration.voucherConfiguration(
fun CheckoutConfiguration.getVoucherConfiguration(): VoucherConfiguration? {
return getActionConfiguration(VoucherConfiguration::class.java)
}
+
+internal fun VoucherConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addActionConfiguration(this@toCheckoutConfiguration)
+ }
+}
diff --git a/voucher/src/main/java/com/adyen/checkout/voucher/internal/provider/VoucherComponentProvider.kt b/voucher/src/main/java/com/adyen/checkout/voucher/internal/provider/VoucherComponentProvider.kt
index 59966100a4..5f26210bf8 100644
--- a/voucher/src/main/java/com/adyen/checkout/voucher/internal/provider/VoucherComponentProvider.kt
+++ b/voucher/src/main/java/com/adyen/checkout/voucher/internal/provider/VoucherComponentProvider.kt
@@ -16,6 +16,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStoreOwner
import androidx.savedstate.SavedStateRegistryOwner
import com.adyen.checkout.components.core.ActionComponentCallback
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethodTypes
import com.adyen.checkout.components.core.action.Action
import com.adyen.checkout.components.core.action.VoucherAction
@@ -33,6 +34,7 @@ import com.adyen.checkout.voucher.VoucherComponent
import com.adyen.checkout.voucher.VoucherConfiguration
import com.adyen.checkout.voucher.internal.ui.DefaultVoucherDelegate
import com.adyen.checkout.voucher.internal.ui.VoucherDelegate
+import com.adyen.checkout.voucher.toCheckoutConfiguration
class VoucherComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@@ -48,12 +50,12 @@ constructor(
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
application: Application,
- configuration: VoucherConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
callback: ActionComponentCallback,
- key: String?,
+ key: String?
): VoucherComponent {
val voucherFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val voucherDelegate = getDelegate(configuration, savedStateHandle, application)
+ val voucherDelegate = getDelegate(checkoutConfiguration, savedStateHandle, application)
VoucherComponent(
delegate = voucherDelegate,
actionComponentEventHandler = DefaultActionComponentEventHandler(callback),
@@ -66,11 +68,11 @@ constructor(
}
override fun getDelegate(
- configuration: VoucherConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
savedStateHandle: SavedStateHandle,
- application: Application,
+ application: Application
): VoucherDelegate {
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
return DefaultVoucherDelegate(
observerRepository = ActionObserverRepository(),
componentParams = componentParams,
@@ -79,6 +81,38 @@ constructor(
)
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ application: Application,
+ configuration: VoucherConfiguration,
+ callback: ActionComponentCallback,
+ key: String?,
+ ): VoucherComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ application = application,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ callback = callback,
+ key = key,
+ )
+ }
+
+ override fun getDelegate(
+ configuration: VoucherConfiguration,
+ savedStateHandle: SavedStateHandle,
+ application: Application,
+ ): VoucherDelegate {
+ return getDelegate(
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ savedStateHandle = savedStateHandle,
+ application = application,
+ )
+ }
+
override val supportedActionTypes: List
get() = listOf(VoucherAction.ACTION_TYPE)
diff --git a/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt b/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt
index 7e51f5f984..38ae3280cf 100644
--- a/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt
+++ b/wechatpay/src/main/java/com/adyen/checkout/wechatpay/WeChatPayActionConfiguration.kt
@@ -89,3 +89,15 @@ fun CheckoutConfiguration.weChatPayActionConfiguration(
fun CheckoutConfiguration.getWeChatPayActionConfiguration(): WeChatPayActionConfiguration? {
return getActionConfiguration(WeChatPayActionConfiguration::class.java)
}
+
+internal fun WeChatPayActionConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addActionConfiguration(this@toCheckoutConfiguration)
+ }
+}
diff --git a/wechatpay/src/main/java/com/adyen/checkout/wechatpay/internal/provider/WeChatPayActionComponentProvider.kt b/wechatpay/src/main/java/com/adyen/checkout/wechatpay/internal/provider/WeChatPayActionComponentProvider.kt
index fdcacd7586..331d2e4e75 100644
--- a/wechatpay/src/main/java/com/adyen/checkout/wechatpay/internal/provider/WeChatPayActionComponentProvider.kt
+++ b/wechatpay/src/main/java/com/adyen/checkout/wechatpay/internal/provider/WeChatPayActionComponentProvider.kt
@@ -16,6 +16,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStoreOwner
import androidx.savedstate.SavedStateRegistryOwner
import com.adyen.checkout.components.core.ActionComponentCallback
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethodTypes
import com.adyen.checkout.components.core.action.Action
import com.adyen.checkout.components.core.action.SdkAction
@@ -33,6 +34,7 @@ import com.adyen.checkout.wechatpay.WeChatPayActionConfiguration
import com.adyen.checkout.wechatpay.internal.ui.DefaultWeChatDelegate
import com.adyen.checkout.wechatpay.internal.ui.WeChatDelegate
import com.adyen.checkout.wechatpay.internal.util.WeChatPayRequestGenerator
+import com.adyen.checkout.wechatpay.toCheckoutConfiguration
import com.tencent.mm.opensdk.openapi.IWXAPI
import com.tencent.mm.opensdk.openapi.WXAPIFactory
@@ -50,15 +52,15 @@ constructor(
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
application: Application,
- configuration: WeChatPayActionConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
callback: ActionComponentCallback,
- key: String?,
+ key: String?
): WeChatPayActionComponent {
val weChatFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val weChatDelegate = getDelegate(configuration, savedStateHandle, application)
+ val weChatDelegate = getDelegate(checkoutConfiguration, savedStateHandle, application)
WeChatPayActionComponent(
delegate = weChatDelegate,
- actionComponentEventHandler = DefaultActionComponentEventHandler(callback)
+ actionComponentEventHandler = DefaultActionComponentEventHandler(callback),
)
}
@@ -69,11 +71,11 @@ constructor(
}
override fun getDelegate(
- configuration: WeChatPayActionConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
savedStateHandle: SavedStateHandle,
- application: Application,
+ application: Application
): WeChatDelegate {
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
val iwxApi: IWXAPI = WXAPIFactory.createWXAPI(application, null, true)
val requestGenerator = WeChatPayRequestGenerator()
val paymentDataRepository = PaymentDataRepository(savedStateHandle)
@@ -82,7 +84,39 @@ constructor(
componentParams = componentParams,
iwxApi = iwxApi,
payRequestGenerator = requestGenerator,
- paymentDataRepository = paymentDataRepository
+ paymentDataRepository = paymentDataRepository,
+ )
+ }
+
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ application: Application,
+ configuration: WeChatPayActionConfiguration,
+ callback: ActionComponentCallback,
+ key: String?,
+ ): WeChatPayActionComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ application = application,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ callback = callback,
+ key = key,
+ )
+ }
+
+ override fun getDelegate(
+ configuration: WeChatPayActionConfiguration,
+ savedStateHandle: SavedStateHandle,
+ application: Application,
+ ): WeChatDelegate {
+ return getDelegate(
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ savedStateHandle = savedStateHandle,
+ application = application,
)
}
From 4632438dd5ad59c63ff5191647ca88ee6bb46285 Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Thu, 4 Jan 2024 13:09:42 +0100
Subject: [PATCH 045/255] Make ACHDirectDebitComponent accept
CheckoutConfiguration
COAND-811
---
.../ach/ACHDirectDebitConfiguration.kt | 16 +-
.../ACHDirectDebitComponentProvider.kt | 182 ++++++++++++++----
.../ACHDirectDebitComponentParamsMapper.kt | 41 ++--
.../provider/CardComponentProvider.kt | 1 +
.../provider/ComponentParsingProvider.kt | 4 +-
5 files changed, 174 insertions(+), 70 deletions(-)
diff --git a/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt b/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt
index 4a4e9076c7..0363ab21f0 100644
--- a/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt
+++ b/ach/src/main/java/com/adyen/checkout/ach/ACHDirectDebitConfiguration.kt
@@ -60,7 +60,7 @@ class ACHDirectDebitConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -73,7 +73,7 @@ class ACHDirectDebitConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
/**
@@ -124,7 +124,7 @@ class ACHDirectDebitConfiguration private constructor(
isSubmitButtonVisible = isSubmitButtonVisible,
genericActionConfiguration = genericActionConfigurationBuilder.build(),
addressConfiguration = addressConfiguration,
- isStorePaymentFieldVisible = isStorePaymentFieldVisible
+ isStorePaymentFieldVisible = isStorePaymentFieldVisible,
)
}
}
@@ -148,3 +148,13 @@ fun CheckoutConfiguration.ACHDirectDebitConfiguration(
fun CheckoutConfiguration.getACHDirectDebitConfiguration(): ACHDirectDebitConfiguration? {
return getConfiguration(PaymentMethodTypes.ACH)
}
+
+internal fun ACHDirectDebitConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(shopperLocale, environment, clientKey, amount, analyticsConfiguration) {
+ addConfiguration(PaymentMethodTypes.ACH, this@toCheckoutConfiguration)
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/ach/src/main/java/com/adyen/checkout/ach/internal/provider/ACHDirectDebitComponentProvider.kt b/ach/src/main/java/com/adyen/checkout/ach/internal/provider/ACHDirectDebitComponentProvider.kt
index a828293980..37eac5606c 100644
--- a/ach/src/main/java/com/adyen/checkout/ach/internal/provider/ACHDirectDebitComponentProvider.kt
+++ b/ach/src/main/java/com/adyen/checkout/ach/internal/provider/ACHDirectDebitComponentProvider.kt
@@ -20,8 +20,10 @@ import com.adyen.checkout.ach.ACHDirectDebitConfiguration
import com.adyen.checkout.ach.internal.ui.DefaultACHDirectDebitDelegate
import com.adyen.checkout.ach.internal.ui.StoredACHDirectDebitDelegate
import com.adyen.checkout.ach.internal.ui.model.ACHDirectDebitComponentParamsMapper
+import com.adyen.checkout.ach.toCheckoutConfiguration
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
@@ -37,7 +39,6 @@ import com.adyen.checkout.components.core.internal.data.api.DefaultPublicKeyRepo
import com.adyen.checkout.components.core.internal.data.api.PublicKeyService
import com.adyen.checkout.components.core.internal.provider.PaymentComponentProvider
import com.adyen.checkout.components.core.internal.provider.StoredPaymentComponentProvider
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.internal.util.get
import com.adyen.checkout.components.core.internal.util.viewModelFactory
@@ -58,10 +59,11 @@ import com.adyen.checkout.ui.core.internal.data.api.AddressService
import com.adyen.checkout.ui.core.internal.data.api.DefaultAddressRepository
import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
+@Suppress("TooManyFunctions")
class ACHDirectDebitComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
+ isCreatedByDropIn: Boolean = false,
overrideSessionParams: SessionParams? = null,
private val analyticsRepository: AnalyticsRepository? = null,
) :
@@ -69,30 +71,30 @@ constructor(
ACHDirectDebitComponent,
ACHDirectDebitConfiguration,
ACHDirectDebitComponentState,
- ComponentCallback
+ ComponentCallback,
>,
StoredPaymentComponentProvider<
ACHDirectDebitComponent,
ACHDirectDebitConfiguration,
ACHDirectDebitComponentState,
- ComponentCallback
+ ComponentCallback,
>,
SessionPaymentComponentProvider<
ACHDirectDebitComponent,
ACHDirectDebitConfiguration,
ACHDirectDebitComponentState,
- SessionComponentCallback
+ SessionComponentCallback,
>,
SessionStoredPaymentComponentProvider<
ACHDirectDebitComponent,
ACHDirectDebitConfiguration,
ACHDirectDebitComponentState,
- SessionComponentCallback
+ SessionComponentCallback,
> {
private val componentParamsMapper = ACHDirectDebitComponentParamsMapper(
- overrideComponentParams,
- overrideSessionParams
+ isCreatedByDropIn,
+ overrideSessionParams,
)
override fun get(
@@ -100,15 +102,16 @@ constructor(
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
paymentMethod: PaymentMethod,
- configuration: ACHDirectDebitConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: ComponentCallback,
order: Order?,
key: String?,
): ACHDirectDebitComponent {
assertSupported(paymentMethod)
+
val achFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
val publicKeyService = PublicKeyService(httpClient)
val publicKeyRepository = DefaultPublicKeyRepository(publicKeyService)
@@ -123,7 +126,7 @@ constructor(
paymentMethod = paymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -137,11 +140,11 @@ constructor(
submitHandler = SubmitHandler(savedStateHandle),
genericEncryptor = genericEncryptor,
componentParams = componentParams,
- order = order
+ order = order,
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -150,12 +153,12 @@ constructor(
achDirectDebitDelegate = achDelegate,
genericActionDelegate = genericActionDelegate,
actionHandlingComponent = DefaultActionHandlingComponent(genericActionDelegate, achDelegate),
- componentEventHandler = DefaultComponentEventHandler()
+ componentEventHandler = DefaultComponentEventHandler(),
)
}
return ViewModelProvider(
viewModelStoreOwner,
- achFactory
+ achFactory,
)[key, ACHDirectDebitComponent::class.java].also { component ->
component.observe(lifecycleOwner) {
component.componentEventHandler.onPaymentComponentEvent(it, componentCallback)
@@ -163,6 +166,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ paymentMethod: PaymentMethod,
+ configuration: ACHDirectDebitConfiguration,
+ application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?,
+ ): ACHDirectDebitComponent {
+ 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,
@@ -170,16 +197,17 @@ constructor(
lifecycleOwner: LifecycleOwner,
checkoutSession: CheckoutSession,
paymentMethod: PaymentMethod,
- configuration: ACHDirectDebitConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: SessionComponentCallback,
key: String?
): ACHDirectDebitComponent {
assertSupported(paymentMethod)
+
val achFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = configuration,
- sessionParams = SessionParamsFactory.create(checkoutSession)
+ checkoutConfiguration = checkoutConfiguration,
+ sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
val publicKeyService = PublicKeyService(httpClient)
@@ -196,7 +224,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -210,11 +238,11 @@ constructor(
submitHandler = SubmitHandler(savedStateHandle),
genericEncryptor = genericEncryptor,
componentParams = componentParams,
- order = checkoutSession.order
+ order = checkoutSession.order,
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -229,7 +257,7 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionComponentEventHandler = SessionComponentEventHandler(
@@ -244,9 +272,10 @@ constructor(
componentEventHandler = sessionComponentEventHandler,
)
}
+
return ViewModelProvider(
viewModelStoreOwner,
- achFactory
+ achFactory,
)[key, ACHDirectDebitComponent::class.java].also { component ->
component.observe(lifecycleOwner) {
component.componentEventHandler.onPaymentComponentEvent(it, componentCallback)
@@ -254,13 +283,38 @@ constructor(
}
}
+ @Suppress("LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
- storedPaymentMethod: StoredPaymentMethod,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
configuration: ACHDirectDebitConfiguration,
application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): ACHDirectDebitComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ checkoutSession = checkoutSession,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ storedPaymentMethod: StoredPaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ application: Application,
componentCallback: ComponentCallback,
order: Order?,
key: String?
@@ -268,7 +322,7 @@ constructor(
assertSupported(storedPaymentMethod)
val achFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
val analyticsRepository = analyticsRepository ?: DefaultAnalyticsRepository(
analyticsRepositoryData = AnalyticsRepositoryData(
@@ -277,7 +331,7 @@ constructor(
storedPaymentMethod = storedPaymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -287,24 +341,26 @@ constructor(
storedPaymentMethod = storedPaymentMethod,
analyticsRepository = analyticsRepository,
componentParams = componentParams,
- order = order
+ order = order,
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
+
ACHDirectDebitComponent(
achDirectDebitDelegate = achDelegate,
genericActionDelegate = genericActionDelegate,
actionHandlingComponent = DefaultActionHandlingComponent(genericActionDelegate, achDelegate),
- componentEventHandler = DefaultComponentEventHandler()
+ componentEventHandler = DefaultComponentEventHandler(),
)
}
+
return ViewModelProvider(
viewModelStoreOwner,
- achFactory
+ achFactory,
)[key, ACHDirectDebitComponent::class.java].also { component ->
component.observe(lifecycleOwner) {
component.componentEventHandler.onPaymentComponentEvent(it, componentCallback)
@@ -312,6 +368,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ storedPaymentMethod: StoredPaymentMethod,
+ configuration: ACHDirectDebitConfiguration,
+ application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?
+ ): ACHDirectDebitComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ order = order,
+ key = key,
+ )
+ }
+
@Suppress("LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
@@ -319,7 +399,7 @@ constructor(
lifecycleOwner: LifecycleOwner,
checkoutSession: CheckoutSession,
storedPaymentMethod: StoredPaymentMethod,
- configuration: ACHDirectDebitConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: SessionComponentCallback,
key: String?
@@ -328,8 +408,8 @@ constructor(
val achFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = configuration,
- sessionParams = SessionParamsFactory.create(checkoutSession)
+ checkoutConfiguration = checkoutConfiguration,
+ sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
@@ -341,7 +421,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -351,11 +431,11 @@ constructor(
storedPaymentMethod = storedPaymentMethod,
analyticsRepository = analyticsRepository,
componentParams = componentParams,
- order = checkoutSession.order
+ order = checkoutSession.order,
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -371,7 +451,7 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionComponentEventHandler =
@@ -387,9 +467,10 @@ constructor(
componentEventHandler = sessionComponentEventHandler,
)
}
+
return ViewModelProvider(
viewModelStoreOwner,
- achFactory
+ achFactory,
)[key, ACHDirectDebitComponent::class.java].also { component ->
component.observe(lifecycleOwner) {
component.componentEventHandler.onPaymentComponentEvent(it, componentCallback)
@@ -397,6 +478,31 @@ constructor(
}
}
+ @Suppress("LongMethod")
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ storedPaymentMethod: StoredPaymentMethod,
+ configuration: ACHDirectDebitConfiguration,
+ application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): ACHDirectDebitComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ checkoutSession = checkoutSession,
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
private fun assertSupported(paymentMethod: PaymentMethod) {
if (!isPaymentMethodSupported(paymentMethod)) {
throw ComponentException("Unsupported payment method ${paymentMethod.type}")
diff --git a/ach/src/main/java/com/adyen/checkout/ach/internal/ui/model/ACHDirectDebitComponentParamsMapper.kt b/ach/src/main/java/com/adyen/checkout/ach/internal/ui/model/ACHDirectDebitComponentParamsMapper.kt
index 2c04314936..76e675f131 100644
--- a/ach/src/main/java/com/adyen/checkout/ach/internal/ui/model/ACHDirectDebitComponentParamsMapper.kt
+++ b/ach/src/main/java/com/adyen/checkout/ach/internal/ui/model/ACHDirectDebitComponentParamsMapper.kt
@@ -9,42 +9,42 @@
package com.adyen.checkout.ach.internal.ui.model
import com.adyen.checkout.ach.ACHDirectDebitAddressConfiguration
-import com.adyen.checkout.ach.ACHDirectDebitConfiguration
+import com.adyen.checkout.ach.getACHDirectDebitConfiguration
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParams
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.ui.core.internal.ui.model.AddressParams
internal class ACHDirectDebitComponentParamsMapper(
- private val overrideComponentParams: ComponentParams?,
+ private val isCreatedByDropIn: Boolean,
private val overrideSessionParams: SessionParams?,
) {
fun mapToParams(
- configuration: ACHDirectDebitConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
sessionParams: SessionParams?,
): ACHDirectDebitComponentParams {
- return configuration
+ return checkoutConfiguration
.mapToParamsInternal()
- .override(overrideComponentParams)
.override(sessionParams ?: overrideSessionParams)
}
- private fun ACHDirectDebitConfiguration.mapToParamsInternal(): ACHDirectDebitComponentParams {
+ private fun CheckoutConfiguration.mapToParamsInternal(): ACHDirectDebitComponentParams {
+ val achDirectDebitConfiguration = getACHDirectDebitConfiguration()
return ACHDirectDebitComponentParams(
shopperLocale = shopperLocale,
environment = environment,
clientKey = clientKey,
analyticsParams = AnalyticsParams(analyticsConfiguration),
- isCreatedByDropIn = false,
+ isCreatedByDropIn = isCreatedByDropIn,
amount = amount,
- isSubmitButtonVisible = isSubmitButtonVisible ?: true,
- addressParams = addressConfiguration?.mapToAddressParam()
+ isSubmitButtonVisible = achDirectDebitConfiguration?.isSubmitButtonVisible ?: true,
+ addressParams = achDirectDebitConfiguration?.addressConfiguration?.mapToAddressParam()
?: AddressParams.FullAddress(
supportedCountryCodes = DEFAULT_SUPPORTED_COUNTRY_LIST,
- addressFieldPolicy = AddressFieldPolicyParams.Required
+ addressFieldPolicy = AddressFieldPolicyParams.Required,
),
- isStorePaymentFieldVisible = isStorePaymentFieldVisible ?: true,
+ isStorePaymentFieldVisible = achDirectDebitConfiguration?.isStorePaymentFieldVisible ?: true,
)
}
@@ -53,29 +53,16 @@ internal class ACHDirectDebitComponentParamsMapper(
is ACHDirectDebitAddressConfiguration.None -> {
AddressParams.None
}
+
is ACHDirectDebitAddressConfiguration.FullAddress -> {
AddressParams.FullAddress(
supportedCountryCodes = supportedCountryCodes,
- addressFieldPolicy = AddressFieldPolicyParams.Required
+ addressFieldPolicy = AddressFieldPolicyParams.Required,
)
}
}
}
- private fun ACHDirectDebitComponentParams.override(
- overrideComponentParams: ComponentParams?
- ): ACHDirectDebitComponentParams {
- if (overrideComponentParams == null) return this
- return copy(
- shopperLocale = overrideComponentParams.shopperLocale,
- environment = overrideComponentParams.environment,
- clientKey = overrideComponentParams.clientKey,
- analyticsParams = overrideComponentParams.analyticsParams,
- isCreatedByDropIn = overrideComponentParams.isCreatedByDropIn,
- amount = overrideComponentParams.amount,
- )
- }
-
private fun ACHDirectDebitComponentParams.override(
sessionParams: SessionParams? = null
): ACHDirectDebitComponentParams {
diff --git a/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt b/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt
index 50de56cdee..889c4a52d9 100644
--- a/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt
+++ b/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt
@@ -63,6 +63,7 @@ import com.adyen.checkout.ui.core.internal.data.api.AddressService
import com.adyen.checkout.ui.core.internal.data.api.DefaultAddressRepository
import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
+@Suppress("TooManyFunctions")
class CardComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
index c2b8bd25ca..b2af2a0594 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
@@ -158,7 +158,7 @@ internal fun getComponentFor(
checkCompileOnly { ACHDirectDebitComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
val achConfig: ACHDirectDebitConfiguration =
getConfigurationForPaymentMethod(storedPaymentMethod, checkoutConfiguration)
- ACHDirectDebitComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ ACHDirectDebitComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
storedPaymentMethod = storedPaymentMethod,
configuration = achConfig,
@@ -236,7 +236,7 @@ internal fun getComponentFor(
checkCompileOnly { ACHDirectDebitComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val configuration: ACHDirectDebitConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- ACHDirectDebitComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ ACHDirectDebitComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = configuration,
From a8e8215ccaa91c289b9296156aa317defd0ff455 Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Thu, 4 Jan 2024 14:08:35 +0100
Subject: [PATCH 046/255] Make BACS accept CheckoutConfiguration
COAND-811
---
.../bacs/BacsDirectDebitConfiguration.kt | 16 ++++
.../BacsDirectDebitComponentProvider.kt | 83 +++++++++++++++----
2 files changed, 84 insertions(+), 15 deletions(-)
diff --git a/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt b/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt
index 67ac38dd70..712cf4dc35 100644
--- a/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt
+++ b/bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt
@@ -115,3 +115,19 @@ fun CheckoutConfiguration.bacsDirectDebitConfiguration(
fun CheckoutConfiguration.getBacsDirectDebitConfiguration(): BacsDirectDebitConfiguration? {
return getConfiguration(PaymentMethodTypes.BACS)
}
+
+internal fun BacsDirectDebitConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addConfiguration(PaymentMethodTypes.BACS, this@toCheckoutConfiguration)
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/bacs/src/main/java/com/adyen/checkout/bacs/internal/provider/BacsDirectDebitComponentProvider.kt b/bacs/src/main/java/com/adyen/checkout/bacs/internal/provider/BacsDirectDebitComponentProvider.kt
index 2106f96804..a09aa3df9d 100644
--- a/bacs/src/main/java/com/adyen/checkout/bacs/internal/provider/BacsDirectDebitComponentProvider.kt
+++ b/bacs/src/main/java/com/adyen/checkout/bacs/internal/provider/BacsDirectDebitComponentProvider.kt
@@ -20,6 +20,8 @@ import com.adyen.checkout.bacs.BacsDirectDebitComponent
import com.adyen.checkout.bacs.BacsDirectDebitComponentState
import com.adyen.checkout.bacs.BacsDirectDebitConfiguration
import com.adyen.checkout.bacs.internal.ui.DefaultBacsDirectDebitDelegate
+import com.adyen.checkout.bacs.toCheckoutConfiguration
+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
@@ -60,15 +62,16 @@ constructor(
BacsDirectDebitComponent,
BacsDirectDebitConfiguration,
BacsDirectDebitComponentState,
- ComponentCallback
+ ComponentCallback,
>,
SessionPaymentComponentProvider<
BacsDirectDebitComponent,
BacsDirectDebitConfiguration,
BacsDirectDebitComponentState,
- SessionComponentCallback
+ SessionComponentCallback,
> {
+ // TODO: replace override
private val componentParamsMapper = ButtonComponentParamsMapper(overrideComponentParams, overrideSessionParams)
override fun get(
@@ -76,7 +79,7 @@ constructor(
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
paymentMethod: PaymentMethod,
- configuration: BacsDirectDebitConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: ComponentCallback,
order: Order?,
@@ -85,7 +88,7 @@ constructor(
assertSupported(paymentMethod)
val genericFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
val analyticsRepository = analyticsRepository ?: DefaultAnalyticsRepository(
analyticsRepositoryData = AnalyticsRepositoryData(
@@ -94,7 +97,7 @@ constructor(
paymentMethod = paymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -109,7 +112,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -118,7 +121,7 @@ constructor(
bacsDelegate = bacsDelegate,
genericActionDelegate = genericActionDelegate,
actionHandlingComponent = DefaultActionHandlingComponent(genericActionDelegate, bacsDelegate),
- componentEventHandler = DefaultComponentEventHandler()
+ componentEventHandler = DefaultComponentEventHandler(),
)
}
@@ -130,6 +133,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ paymentMethod: PaymentMethod,
+ configuration: BacsDirectDebitConfiguration,
+ application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?
+ ): BacsDirectDebitComponent {
+ 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,
@@ -137,7 +164,7 @@ constructor(
lifecycleOwner: LifecycleOwner,
checkoutSession: CheckoutSession,
paymentMethod: PaymentMethod,
- configuration: BacsDirectDebitConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: SessionComponentCallback,
key: String?
@@ -146,8 +173,8 @@ constructor(
val genericFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = configuration,
- sessionParams = SessionParamsFactory.create(checkoutSession)
+ configuration = checkoutConfiguration,
+ sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
@@ -159,7 +186,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -174,7 +201,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -189,20 +216,21 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionComponentEventHandler = SessionComponentEventHandler(
sessionInteractor = sessionInteractor,
- sessionSavedStateHandleContainer = sessionSavedStateHandleContainer
+ sessionSavedStateHandleContainer = sessionSavedStateHandleContainer,
)
BacsDirectDebitComponent(
bacsDelegate = bacsDelegate,
genericActionDelegate = genericActionDelegate,
actionHandlingComponent = DefaultActionHandlingComponent(genericActionDelegate, bacsDelegate),
- componentEventHandler = sessionComponentEventHandler
+ componentEventHandler = sessionComponentEventHandler,
)
}
+
return ViewModelProvider(viewModelStoreOwner, genericFactory)[key, BacsDirectDebitComponent::class.java]
.also { component ->
component.observe(lifecycleOwner) {
@@ -211,6 +239,31 @@ constructor(
}
}
+ @Suppress("LongMethod")
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ configuration: BacsDirectDebitConfiguration,
+ application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): BacsDirectDebitComponent {
+ 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}")
From 81ed1e3cf8aa6a788698b0a49c57d26f979d6280 Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Thu, 4 Jan 2024 14:21:42 +0100
Subject: [PATCH 047/255] Make BCMC accept CheckoutConfiguration
COAND-811
---
.../adyen/checkout/bcmc/BcmcConfiguration.kt | 16 ++++
.../provider/BcmcComponentProvider.kt | 76 +++++++++++++++----
.../ui/model/BcmcComponentParamsMapper.kt | 44 ++++-------
.../provider/CardComponentProvider.kt | 2 +-
.../provider/ComponentParsingProvider.kt | 6 +-
5 files changed, 97 insertions(+), 47 deletions(-)
diff --git a/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt b/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt
index ea11c4d740..00c1da7c99 100644
--- a/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt
+++ b/bcmc/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.kt
@@ -170,3 +170,19 @@ fun CheckoutConfiguration.bcmcConfiguration(
fun CheckoutConfiguration.getBcmcConfiguration(): BcmcConfiguration? {
return getConfiguration(PaymentMethodTypes.BCMC)
}
+
+internal fun BcmcConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addConfiguration(PaymentMethodTypes.BCMC, this@toCheckoutConfiguration)
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/provider/BcmcComponentProvider.kt b/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/provider/BcmcComponentProvider.kt
index 5729ca54e9..fda6ee9aad 100644
--- a/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/provider/BcmcComponentProvider.kt
+++ b/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/provider/BcmcComponentProvider.kt
@@ -20,10 +20,12 @@ import com.adyen.checkout.bcmc.BcmcComponent
import com.adyen.checkout.bcmc.BcmcComponentState
import com.adyen.checkout.bcmc.BcmcConfiguration
import com.adyen.checkout.bcmc.internal.ui.model.BcmcComponentParamsMapper
+import com.adyen.checkout.bcmc.toCheckoutConfiguration
import com.adyen.checkout.card.internal.data.api.BinLookupService
import com.adyen.checkout.card.internal.data.api.DefaultDetectCardTypeRepository
import com.adyen.checkout.card.internal.ui.CardValidationMapper
import com.adyen.checkout.card.internal.ui.DefaultCardDelegate
+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
@@ -37,7 +39,6 @@ import com.adyen.checkout.components.core.internal.data.api.DefaultAnalyticsRepo
import com.adyen.checkout.components.core.internal.data.api.DefaultPublicKeyRepository
import com.adyen.checkout.components.core.internal.data.api.PublicKeyService
import com.adyen.checkout.components.core.internal.provider.PaymentComponentProvider
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.internal.util.get
import com.adyen.checkout.components.core.internal.util.viewModelFactory
@@ -61,7 +62,7 @@ import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
class BcmcComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
+ isCreatedByDropIn: Boolean = false,
overrideSessionParams: SessionParams? = null,
private val analyticsRepository: AnalyticsRepository? = null,
) :
@@ -78,7 +79,7 @@ constructor(
SessionComponentCallback,
> {
- private val componentParamsMapper = BcmcComponentParamsMapper(overrideComponentParams, overrideSessionParams)
+ private val componentParamsMapper = BcmcComponentParamsMapper(isCreatedByDropIn, overrideSessionParams)
@Suppress("LongMethod")
override fun get(
@@ -86,15 +87,16 @@ constructor(
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
paymentMethod: PaymentMethod,
- configuration: BcmcConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: ComponentCallback,
order: Order?,
key: String?,
): BcmcComponent {
assertSupported(paymentMethod)
+
val bcmcFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(configuration, null, paymentMethod)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null, paymentMethod)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
val publicKeyService = PublicKeyService(httpClient)
val publicKeyRepository = DefaultPublicKeyRepository(publicKeyService)
@@ -134,7 +136,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -146,32 +148,53 @@ constructor(
componentEventHandler = DefaultComponentEventHandler(),
)
}
- return ViewModelProvider(
- viewModelStoreOwner,
- bcmcFactory,
- )[key, BcmcComponent::class.java].also { component ->
+
+ return ViewModelProvider(viewModelStoreOwner, bcmcFactory)[key, BcmcComponent::class.java].also { component ->
component.observe(lifecycleOwner) {
component.componentEventHandler.onPaymentComponentEvent(it, componentCallback)
}
}
}
- @Suppress("LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
- checkoutSession: CheckoutSession,
paymentMethod: PaymentMethod,
configuration: BcmcConfiguration,
application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?,
+ ): BcmcComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ order = order,
+ key = key,
+ )
+ }
+
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ application: Application,
componentCallback: SessionComponentCallback,
key: String?
): BcmcComponent {
assertSupported(paymentMethod)
val bcmcFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- bcmcConfiguration = configuration,
+ checkoutConfiguration = checkoutConfiguration,
sessionParams = SessionParamsFactory.create(checkoutSession),
paymentMethod = paymentMethod,
)
@@ -215,7 +238,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -257,6 +280,31 @@ constructor(
}
}
+ @Suppress("LongMethod")
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ configuration: BcmcConfiguration,
+ application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): BcmcComponent {
+ 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}")
diff --git a/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/ui/model/BcmcComponentParamsMapper.kt b/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/ui/model/BcmcComponentParamsMapper.kt
index 71b9c516a7..07f2fa82a5 100644
--- a/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/ui/model/BcmcComponentParamsMapper.kt
+++ b/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/ui/model/BcmcComponentParamsMapper.kt
@@ -8,7 +8,7 @@
package com.adyen.checkout.bcmc.internal.ui.model
-import com.adyen.checkout.bcmc.BcmcConfiguration
+import com.adyen.checkout.bcmc.getBcmcConfiguration
import com.adyen.checkout.card.CardBrand
import com.adyen.checkout.card.CardType
import com.adyen.checkout.card.KCPAuthVisibility
@@ -16,63 +16,49 @@ import com.adyen.checkout.card.SocialSecurityNumberVisibility
import com.adyen.checkout.card.internal.ui.model.CVCVisibility
import com.adyen.checkout.card.internal.ui.model.CardComponentParams
import com.adyen.checkout.card.internal.ui.model.StoredCVCVisibility
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethod
import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParams
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.ui.core.internal.ui.model.AddressParams
internal class BcmcComponentParamsMapper(
- private val overrideComponentParams: ComponentParams?,
+ private val isCreatedByDropIn: Boolean,
private val overrideSessionParams: SessionParams?,
) {
fun mapToParams(
- bcmcConfiguration: BcmcConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
sessionParams: SessionParams?,
paymentMethod: PaymentMethod
): CardComponentParams {
- return bcmcConfiguration
+ return checkoutConfiguration
.mapToParamsInternal(
- supportedCardBrands = paymentMethod.brands?.map { CardBrand(it) }
+ supportedCardBrands = paymentMethod.brands?.map { CardBrand(it) },
)
- .override(overrideComponentParams)
.override(sessionParams ?: overrideSessionParams)
}
- private fun BcmcConfiguration.mapToParamsInternal(supportedCardBrands: List?): CardComponentParams {
+ private fun CheckoutConfiguration.mapToParamsInternal(supportedCardBrands: List?): CardComponentParams {
+ val bcmcConfiguration = getBcmcConfiguration()
return CardComponentParams(
shopperLocale = shopperLocale,
environment = environment,
clientKey = clientKey,
analyticsParams = AnalyticsParams(analyticsConfiguration),
- isCreatedByDropIn = false,
+ isCreatedByDropIn = isCreatedByDropIn,
amount = amount,
- isSubmitButtonVisible = isSubmitButtonVisible ?: true,
- isHolderNameRequired = isHolderNameRequired ?: false,
- shopperReference = shopperReference,
- isStorePaymentFieldVisible = isStorePaymentFieldVisible ?: false,
+ isSubmitButtonVisible = bcmcConfiguration?.isSubmitButtonVisible ?: true,
+ isHolderNameRequired = bcmcConfiguration?.isHolderNameRequired ?: false,
+ shopperReference = bcmcConfiguration?.shopperReference,
+ isStorePaymentFieldVisible = bcmcConfiguration?.isStorePaymentFieldVisible ?: false,
addressParams = AddressParams.None,
installmentParams = null,
kcpAuthVisibility = KCPAuthVisibility.HIDE,
socialSecurityNumberVisibility = SocialSecurityNumberVisibility.HIDE,
cvcVisibility = CVCVisibility.HIDE_FIRST,
storedCVCVisibility = StoredCVCVisibility.HIDE,
- supportedCardBrands = supportedCardBrands ?: DEFAULT_SUPPORTED_CARD_BRANDS
- )
- }
-
- private fun CardComponentParams.override(
- overrideComponentParams: ComponentParams?
- ): CardComponentParams {
- if (overrideComponentParams == null) return this
- return copy(
- shopperLocale = overrideComponentParams.shopperLocale,
- environment = overrideComponentParams.environment,
- clientKey = overrideComponentParams.clientKey,
- analyticsParams = overrideComponentParams.analyticsParams,
- isCreatedByDropIn = overrideComponentParams.isCreatedByDropIn,
- amount = overrideComponentParams.amount,
+ supportedCardBrands = supportedCardBrands ?: DEFAULT_SUPPORTED_CARD_BRANDS,
)
}
@@ -90,7 +76,7 @@ internal class BcmcComponentParamsMapper(
private val DEFAULT_SUPPORTED_CARD_BRANDS = listOf(
CardBrand(cardType = CardType.BCMC),
CardBrand(cardType = CardType.MAESTRO),
- CardBrand(cardType = CardType.VISA)
+ CardBrand(cardType = CardType.VISA),
)
}
}
diff --git a/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt b/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt
index 889c4a52d9..5473a74684 100644
--- a/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt
+++ b/card/src/main/java/com/adyen/checkout/card/internal/provider/CardComponentProvider.kt
@@ -67,8 +67,8 @@ import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
class CardComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideSessionParams: SessionParams? = null,
isCreatedByDropIn: Boolean = false,
+ overrideSessionParams: SessionParams? = null,
private val analyticsRepository: AnalyticsRepository? = null,
) :
PaymentComponentProvider<
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
index b2af2a0594..3e36a11024 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
@@ -170,7 +170,7 @@ internal fun getComponentFor(
checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
val cardConfig: CardConfiguration =
getConfigurationForPaymentMethod(storedPaymentMethod, checkoutConfiguration)
- CardComponentProvider(sessionParams, true, analyticsRepository).get(
+ CardComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
storedPaymentMethod = storedPaymentMethod,
configuration = cardConfig,
@@ -258,7 +258,7 @@ internal fun getComponentFor(
checkCompileOnly { BcmcComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val bcmcConfiguration: BcmcConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- BcmcComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ BcmcComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = bcmcConfiguration,
@@ -291,7 +291,7 @@ internal fun getComponentFor(
checkCompileOnly { CardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val cardConfig: CardConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- CardComponentProvider(sessionParams, true, analyticsRepository).get(
+ CardComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = cardConfig,
From 6055f47c4c35b80fbdfdccb6a4256ac1d17fa26e Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Thu, 4 Jan 2024 15:05:01 +0100
Subject: [PATCH 048/255] Make Blik accept CheckoutConfiguration
COAND-811
---
.../provider/BcmcComponentProvider.kt | 2 +-
.../adyen/checkout/blik/BlikConfiguration.kt | 20 ++-
.../provider/BlikComponentProvider.kt | 149 +++++++++++++++---
3 files changed, 143 insertions(+), 28 deletions(-)
diff --git a/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/provider/BcmcComponentProvider.kt b/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/provider/BcmcComponentProvider.kt
index fda6ee9aad..b2c86c522c 100644
--- a/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/provider/BcmcComponentProvider.kt
+++ b/bcmc/src/main/java/com/adyen/checkout/bcmc/internal/provider/BcmcComponentProvider.kt
@@ -180,6 +180,7 @@ constructor(
)
}
+ @Suppress("LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
@@ -280,7 +281,6 @@ constructor(
}
}
- @Suppress("LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
diff --git a/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt b/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt
index f5d94d5c65..78ed6b2481 100644
--- a/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt
+++ b/blik/src/main/java/com/adyen/checkout/blik/BlikConfiguration.kt
@@ -55,7 +55,7 @@ class BlikConfiguration private constructor(
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
- clientKey
+ clientKey,
)
/**
@@ -68,7 +68,7 @@ class BlikConfiguration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
- clientKey
+ clientKey,
)
/**
@@ -114,3 +114,19 @@ fun CheckoutConfiguration.blikConfiguration(
fun CheckoutConfiguration.getBlikConfiguration(): BlikConfiguration? {
return getConfiguration(PaymentMethodTypes.BLIK)
}
+
+internal fun BlikConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addConfiguration(PaymentMethodTypes.BLIK, this@toCheckoutConfiguration)
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/blik/src/main/java/com/adyen/checkout/blik/internal/provider/BlikComponentProvider.kt b/blik/src/main/java/com/adyen/checkout/blik/internal/provider/BlikComponentProvider.kt
index 19930ad2b9..aade9569e4 100644
--- a/blik/src/main/java/com/adyen/checkout/blik/internal/provider/BlikComponentProvider.kt
+++ b/blik/src/main/java/com/adyen/checkout/blik/internal/provider/BlikComponentProvider.kt
@@ -21,6 +21,8 @@ import com.adyen.checkout.blik.BlikComponentState
import com.adyen.checkout.blik.BlikConfiguration
import com.adyen.checkout.blik.internal.ui.DefaultBlikDelegate
import com.adyen.checkout.blik.internal.ui.StoredBlikDelegate
+import com.adyen.checkout.blik.toCheckoutConfiguration
+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
@@ -53,6 +55,7 @@ import com.adyen.checkout.sessions.core.internal.provider.SessionStoredPaymentCo
import com.adyen.checkout.sessions.core.internal.ui.model.SessionParamsFactory
import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
+@Suppress("TooManyFunctions")
class BlikComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
@@ -64,25 +67,25 @@ constructor(
BlikComponent,
BlikConfiguration,
BlikComponentState,
- ComponentCallback
+ ComponentCallback,
>,
StoredPaymentComponentProvider<
BlikComponent,
BlikConfiguration,
BlikComponentState,
- ComponentCallback
+ ComponentCallback,
>,
SessionPaymentComponentProvider<
BlikComponent,
BlikConfiguration,
BlikComponentState,
- SessionComponentCallback
+ SessionComponentCallback,
>,
SessionStoredPaymentComponentProvider<
BlikComponent,
BlikConfiguration,
BlikComponentState,
- SessionComponentCallback
+ SessionComponentCallback,
> {
private val componentParamsMapper = ButtonComponentParamsMapper(overrideComponentParams, overrideSessionParams)
@@ -92,7 +95,7 @@ constructor(
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
paymentMethod: PaymentMethod,
- configuration: BlikConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: ComponentCallback,
order: Order?,
@@ -101,7 +104,7 @@ constructor(
assertSupported(paymentMethod)
val genericFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
val analyticsRepository = analyticsRepository ?: DefaultAnalyticsRepository(
analyticsRepositoryData = AnalyticsRepositoryData(
@@ -110,7 +113,7 @@ constructor(
paymentMethod = paymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -125,7 +128,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -134,7 +137,7 @@ constructor(
blikDelegate = blikDelegate,
genericActionDelegate = genericActionDelegate,
actionHandlingComponent = DefaultActionHandlingComponent(genericActionDelegate, blikDelegate),
- componentEventHandler = DefaultComponentEventHandler()
+ componentEventHandler = DefaultComponentEventHandler(),
)
}
@@ -150,17 +153,41 @@ constructor(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
- storedPaymentMethod: StoredPaymentMethod,
+ paymentMethod: PaymentMethod,
configuration: BlikConfiguration,
application: Application,
componentCallback: ComponentCallback,
order: Order?,
key: String?,
+ ): BlikComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ order = order,
+ key = key,
+ )
+ }
+
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ storedPaymentMethod: StoredPaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?,
): BlikComponent {
assertSupported(storedPaymentMethod)
val genericStoredFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
val analyticsRepository = analyticsRepository ?: DefaultAnalyticsRepository(
analyticsRepositoryData = AnalyticsRepositoryData(
@@ -169,7 +196,7 @@ constructor(
storedPaymentMethod = storedPaymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -184,7 +211,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -205,6 +232,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ storedPaymentMethod: StoredPaymentMethod,
+ configuration: BlikConfiguration,
+ application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?,
+ ): BlikComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ order = order,
+ key = key,
+ )
+ }
+
@Suppress("LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
@@ -212,7 +263,7 @@ constructor(
lifecycleOwner: LifecycleOwner,
checkoutSession: CheckoutSession,
paymentMethod: PaymentMethod,
- configuration: BlikConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: SessionComponentCallback,
key: String?
@@ -221,8 +272,8 @@ constructor(
val genericFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = configuration,
- sessionParams = SessionParamsFactory.create(checkoutSession)
+ configuration = checkoutConfiguration,
+ sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
@@ -234,7 +285,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -249,7 +300,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -265,7 +316,7 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionComponentEventHandler = SessionComponentEventHandler(
@@ -289,6 +340,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ configuration: BlikConfiguration,
+ application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): BlikComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ checkoutSession = checkoutSession,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
@Suppress("LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
@@ -296,7 +371,7 @@ constructor(
lifecycleOwner: LifecycleOwner,
checkoutSession: CheckoutSession,
storedPaymentMethod: StoredPaymentMethod,
- configuration: BlikConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: SessionComponentCallback,
key: String?
@@ -305,8 +380,8 @@ constructor(
val genericStoredFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = configuration,
- sessionParams = SessionParamsFactory.create(checkoutSession)
+ configuration = checkoutConfiguration,
+ sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
@@ -318,7 +393,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -333,7 +408,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -349,7 +424,7 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionComponentEventHandler =
@@ -374,6 +449,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ storedPaymentMethod: StoredPaymentMethod,
+ configuration: BlikConfiguration,
+ application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): BlikComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ checkoutSession = checkoutSession,
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
private fun assertSupported(paymentMethod: PaymentMethod) {
if (!isPaymentMethodSupported(paymentMethod)) {
throw ComponentException("Unsupported payment method ${paymentMethod.type}")
From b1785f1e9ad16bf932810b211dd7581a5ef5cb7f Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Thu, 4 Jan 2024 15:20:32 +0100
Subject: [PATCH 049/255] Make Boleto accept CheckoutConfiguration
COAND-811
---
.../checkout/boleto/BoletoConfiguration.kt | 18 +++++
.../provider/BoletoComponentProvider.kt | 81 +++++++++++++++----
.../ui/model/BoletoComponentParamsMapper.kt | 33 +++-----
.../provider/ComponentParsingProvider.kt | 2 +-
4 files changed, 94 insertions(+), 40 deletions(-)
diff --git a/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt b/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt
index 003b1500be..d0b2490332 100644
--- a/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt
+++ b/boleto/src/main/java/com/adyen/checkout/boleto/BoletoConfiguration.kt
@@ -131,3 +131,21 @@ fun CheckoutConfiguration.getBoletoConfiguration(): BoletoConfiguration? {
getConfiguration(key)
}
}
+
+internal fun BoletoConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ BoletoComponent.PAYMENT_METHOD_TYPES.forEach { key ->
+ addConfiguration(key, this@toCheckoutConfiguration)
+ }
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/boleto/src/main/java/com/adyen/checkout/boleto/internal/provider/BoletoComponentProvider.kt b/boleto/src/main/java/com/adyen/checkout/boleto/internal/provider/BoletoComponentProvider.kt
index 87b9d08d80..3b626f6b8e 100644
--- a/boleto/src/main/java/com/adyen/checkout/boleto/internal/provider/BoletoComponentProvider.kt
+++ b/boleto/src/main/java/com/adyen/checkout/boleto/internal/provider/BoletoComponentProvider.kt
@@ -21,6 +21,8 @@ import com.adyen.checkout.boleto.BoletoComponentState
import com.adyen.checkout.boleto.BoletoConfiguration
import com.adyen.checkout.boleto.internal.ui.DefaultBoletoDelegate
import com.adyen.checkout.boleto.internal.ui.model.BoletoComponentParamsMapper
+import com.adyen.checkout.boleto.toCheckoutConfiguration
+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
@@ -32,7 +34,6 @@ import com.adyen.checkout.components.core.internal.data.api.AnalyticsRepositoryD
import com.adyen.checkout.components.core.internal.data.api.AnalyticsService
import com.adyen.checkout.components.core.internal.data.api.DefaultAnalyticsRepository
import com.adyen.checkout.components.core.internal.provider.PaymentComponentProvider
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.internal.util.get
import com.adyen.checkout.components.core.internal.util.viewModelFactory
@@ -54,7 +55,7 @@ import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
class BoletoComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
+ isCreatedByDropIn: Boolean = false,
overrideSessionParams: SessionParams? = null,
private val analyticsRepository: AnalyticsRepository? = null,
) :
@@ -62,23 +63,23 @@ constructor(
BoletoComponent,
BoletoConfiguration,
BoletoComponentState,
- ComponentCallback
+ ComponentCallback,
>,
SessionPaymentComponentProvider<
BoletoComponent,
BoletoConfiguration,
BoletoComponentState,
- SessionComponentCallback
+ SessionComponentCallback,
> {
- private val componentParamsMapper = BoletoComponentParamsMapper(overrideComponentParams, overrideSessionParams)
+ private val componentParamsMapper = BoletoComponentParamsMapper(isCreatedByDropIn, overrideSessionParams)
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
paymentMethod: PaymentMethod,
- configuration: BoletoConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: ComponentCallback,
order: Order?,
@@ -87,7 +88,7 @@ constructor(
assertSupported(paymentMethod)
val boletoFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
val analyticsRepository = analyticsRepository ?: DefaultAnalyticsRepository(
@@ -97,7 +98,7 @@ constructor(
paymentMethod = paymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -112,11 +113,11 @@ constructor(
paymentMethod = paymentMethod,
order = order,
componentParams = componentParams,
- addressRepository = addressRepository
+ addressRepository = addressRepository,
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -137,6 +138,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ paymentMethod: PaymentMethod,
+ configuration: BoletoConfiguration,
+ application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?
+ ): BoletoComponent {
+ 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,
@@ -144,7 +169,7 @@ constructor(
lifecycleOwner: LifecycleOwner,
checkoutSession: CheckoutSession,
paymentMethod: PaymentMethod,
- configuration: BoletoConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: SessionComponentCallback,
key: String?
@@ -153,7 +178,7 @@ constructor(
val genericFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = configuration,
+ configuration = checkoutConfiguration,
sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
@@ -166,7 +191,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -180,11 +205,11 @@ constructor(
paymentMethod = paymentMethod,
order = checkoutSession.order,
componentParams = componentParams,
- addressRepository = addressRepository
+ addressRepository = addressRepository,
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -200,7 +225,7 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionComponentEventHandler =
@@ -225,6 +250,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ configuration: BoletoConfiguration,
+ application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): BoletoComponent {
+ 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}")
diff --git a/boleto/src/main/java/com/adyen/checkout/boleto/internal/ui/model/BoletoComponentParamsMapper.kt b/boleto/src/main/java/com/adyen/checkout/boleto/internal/ui/model/BoletoComponentParamsMapper.kt
index 79b7111617..4749a423d7 100644
--- a/boleto/src/main/java/com/adyen/checkout/boleto/internal/ui/model/BoletoComponentParamsMapper.kt
+++ b/boleto/src/main/java/com/adyen/checkout/boleto/internal/ui/model/BoletoComponentParamsMapper.kt
@@ -8,56 +8,43 @@
package com.adyen.checkout.boleto.internal.ui.model
-import com.adyen.checkout.boleto.BoletoConfiguration
+import com.adyen.checkout.boleto.getBoletoConfiguration
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParams
import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.ui.core.internal.ui.model.AddressParams
internal class BoletoComponentParamsMapper(
- private val overrideComponentParams: ComponentParams?,
+ private val isCreatedByDropIn: Boolean,
private val overrideSessionParams: SessionParams?,
) {
fun mapToParams(
- configuration: BoletoConfiguration,
+ configuration: CheckoutConfiguration,
sessionParams: SessionParams?
): BoletoComponentParams {
return configuration
.mapToParamsInternal()
- .override(overrideComponentParams)
.override(sessionParams ?: overrideSessionParams)
}
- private fun BoletoConfiguration.mapToParamsInternal(): BoletoComponentParams {
+ private fun CheckoutConfiguration.mapToParamsInternal(): BoletoComponentParams {
+ val boletoConfiguration = getBoletoConfiguration()
return BoletoComponentParams(
- isSubmitButtonVisible = isSubmitButtonVisible ?: true,
+ isSubmitButtonVisible = boletoConfiguration?.isSubmitButtonVisible ?: true,
shopperLocale = shopperLocale,
environment = environment,
clientKey = clientKey,
analyticsParams = AnalyticsParams(analyticsConfiguration),
- isCreatedByDropIn = false,
+ isCreatedByDropIn = isCreatedByDropIn,
amount = amount,
addressParams = AddressParams.FullAddress(
defaultCountryCode = BRAZIL_COUNTRY_CODE,
supportedCountryCodes = DEFAULT_SUPPORTED_COUNTRY_LIST,
- addressFieldPolicy = AddressFieldPolicyParams.Required
+ addressFieldPolicy = AddressFieldPolicyParams.Required,
),
- isEmailVisible = isEmailVisible ?: false
- )
- }
-
- private fun BoletoComponentParams.override(
- overrideComponentParams: ComponentParams?
- ): BoletoComponentParams {
- if (overrideComponentParams == null) return this
- return copy(
- shopperLocale = overrideComponentParams.shopperLocale,
- environment = overrideComponentParams.environment,
- clientKey = overrideComponentParams.clientKey,
- analyticsParams = overrideComponentParams.analyticsParams,
- isCreatedByDropIn = overrideComponentParams.isCreatedByDropIn,
- amount = overrideComponentParams.amount,
+ isEmailVisible = boletoConfiguration?.isEmailVisible ?: false,
)
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
index 3e36a11024..7858598818 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
@@ -280,7 +280,7 @@ internal fun getComponentFor(
checkCompileOnly { BoletoComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val boletoConfiguration: BoletoConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- BoletoComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ BoletoComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = boletoConfiguration,
From 7d05604c0b0960ae12dabc19e2b9c8eb52dbd4ba Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Thu, 4 Jan 2024 15:36:23 +0100
Subject: [PATCH 050/255] Make Cash App Pay accept CheckoutConfiguration
COAND-811
---
.../ui/model/BoletoComponentParamsMapper.kt | 1 -
.../cashapppay/CashAppPayConfiguration.kt | 16 ++
.../provider/CashAppPayComponentProvider.kt | 148 +++++++++++++++---
.../model/CashAppPayComponentParamsMapper.kt | 74 ++++-----
.../provider/ComponentParsingProvider.kt | 4 +-
5 files changed, 173 insertions(+), 70 deletions(-)
diff --git a/boleto/src/main/java/com/adyen/checkout/boleto/internal/ui/model/BoletoComponentParamsMapper.kt b/boleto/src/main/java/com/adyen/checkout/boleto/internal/ui/model/BoletoComponentParamsMapper.kt
index 4749a423d7..1b15f61821 100644
--- a/boleto/src/main/java/com/adyen/checkout/boleto/internal/ui/model/BoletoComponentParamsMapper.kt
+++ b/boleto/src/main/java/com/adyen/checkout/boleto/internal/ui/model/BoletoComponentParamsMapper.kt
@@ -11,7 +11,6 @@ package com.adyen.checkout.boleto.internal.ui.model
import com.adyen.checkout.boleto.getBoletoConfiguration
import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParams
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.ui.core.internal.ui.model.AddressParams
diff --git a/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt b/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt
index 880cd53460..ae0ebdb438 100644
--- a/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt
+++ b/cashapppay/src/main/java/com/adyen/checkout/cashapppay/CashAppPayConfiguration.kt
@@ -178,3 +178,19 @@ fun CheckoutConfiguration.cashAppPayConfiguration(
fun CheckoutConfiguration.getCashAppPayConfiguration(): CashAppPayConfiguration? {
return getConfiguration(PaymentMethodTypes.CASH_APP_PAY)
}
+
+internal fun CashAppPayConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addConfiguration(PaymentMethodTypes.CASH_APP_PAY, this@toCheckoutConfiguration)
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/cashapppay/src/main/java/com/adyen/checkout/cashapppay/internal/provider/CashAppPayComponentProvider.kt b/cashapppay/src/main/java/com/adyen/checkout/cashapppay/internal/provider/CashAppPayComponentProvider.kt
index 5dbc76ef5a..9d9cb34052 100644
--- a/cashapppay/src/main/java/com/adyen/checkout/cashapppay/internal/provider/CashAppPayComponentProvider.kt
+++ b/cashapppay/src/main/java/com/adyen/checkout/cashapppay/internal/provider/CashAppPayComponentProvider.kt
@@ -23,6 +23,8 @@ import com.adyen.checkout.cashapppay.CashAppPayConfiguration
import com.adyen.checkout.cashapppay.internal.ui.DefaultCashAppPayDelegate
import com.adyen.checkout.cashapppay.internal.ui.StoredCashAppPayDelegate
import com.adyen.checkout.cashapppay.internal.ui.model.CashAppPayComponentParamsMapper
+import com.adyen.checkout.cashapppay.toCheckoutConfiguration
+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
@@ -36,7 +38,6 @@ import com.adyen.checkout.components.core.internal.data.api.AnalyticsService
import com.adyen.checkout.components.core.internal.data.api.DefaultAnalyticsRepository
import com.adyen.checkout.components.core.internal.provider.PaymentComponentProvider
import com.adyen.checkout.components.core.internal.provider.StoredPaymentComponentProvider
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.internal.util.get
import com.adyen.checkout.components.core.internal.util.viewModelFactory
@@ -54,10 +55,11 @@ import com.adyen.checkout.sessions.core.internal.provider.SessionStoredPaymentCo
import com.adyen.checkout.sessions.core.internal.ui.model.SessionParamsFactory
import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
+@Suppress("TooManyFunctions")
class CashAppPayComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
+ isCreatedByDropIn: Boolean = false,
overrideSessionParams: SessionParams? = null,
private val analyticsRepository: AnalyticsRepository? = null,
) :
@@ -65,35 +67,35 @@ constructor(
CashAppPayComponent,
CashAppPayConfiguration,
CashAppPayComponentState,
- ComponentCallback
+ ComponentCallback,
>,
StoredPaymentComponentProvider<
CashAppPayComponent,
CashAppPayConfiguration,
CashAppPayComponentState,
- ComponentCallback
+ ComponentCallback,
>,
SessionPaymentComponentProvider<
CashAppPayComponent,
CashAppPayConfiguration,
CashAppPayComponentState,
- SessionComponentCallback
+ SessionComponentCallback,
>,
SessionStoredPaymentComponentProvider<
CashAppPayComponent,
CashAppPayConfiguration,
CashAppPayComponentState,
- SessionComponentCallback
+ SessionComponentCallback,
> {
- private val componentParamsMapper = CashAppPayComponentParamsMapper(overrideComponentParams, overrideSessionParams)
+ private val componentParamsMapper = CashAppPayComponentParamsMapper(isCreatedByDropIn, overrideSessionParams)
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
paymentMethod: PaymentMethod,
- configuration: CashAppPayConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: ComponentCallback,
order: Order?,
@@ -102,7 +104,7 @@ constructor(
assertSupported(paymentMethod)
val viewModelFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(configuration, null, paymentMethod)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null, paymentMethod)
val analyticsRepository = analyticsRepository ?: DefaultAnalyticsRepository(
analyticsRepositoryData = AnalyticsRepositoryData(
application = application,
@@ -110,7 +112,7 @@ constructor(
paymentMethod = paymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -126,7 +128,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -151,17 +153,41 @@ constructor(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
- storedPaymentMethod: StoredPaymentMethod,
+ paymentMethod: PaymentMethod,
configuration: CashAppPayConfiguration,
application: Application,
componentCallback: ComponentCallback,
order: Order?,
key: String?
+ ): CashAppPayComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ order = order,
+ key = key,
+ )
+ }
+
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ storedPaymentMethod: StoredPaymentMethod,
+ checkoutConfiguration: CheckoutConfiguration,
+ application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?
): CashAppPayComponent {
assertSupported(storedPaymentMethod)
val viewModelFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(configuration, null, storedPaymentMethod)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null, storedPaymentMethod)
val analyticsRepository = analyticsRepository ?: DefaultAnalyticsRepository(
analyticsRepositoryData = AnalyticsRepositoryData(
application = application,
@@ -169,7 +195,7 @@ constructor(
storedPaymentMethod = storedPaymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -183,7 +209,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -204,6 +230,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ storedPaymentMethod: StoredPaymentMethod,
+ configuration: CashAppPayConfiguration,
+ application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?
+ ): CashAppPayComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ order = order,
+ key = key,
+ )
+ }
+
@Suppress("LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
@@ -211,7 +261,7 @@ constructor(
lifecycleOwner: LifecycleOwner,
checkoutSession: CheckoutSession,
paymentMethod: PaymentMethod,
- configuration: CashAppPayConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: SessionComponentCallback,
key: String?
@@ -220,7 +270,7 @@ constructor(
val viewModelFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = configuration,
+ configuration = checkoutConfiguration,
sessionParams = SessionParamsFactory.create(checkoutSession),
paymentMethod = paymentMethod,
)
@@ -235,7 +285,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -251,7 +301,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -267,7 +317,7 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionComponentEventHandler = SessionComponentEventHandler(
@@ -291,6 +341,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ configuration: CashAppPayConfiguration,
+ application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): CashAppPayComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ checkoutSession = checkoutSession,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
@Suppress("LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
@@ -298,7 +372,7 @@ constructor(
lifecycleOwner: LifecycleOwner,
checkoutSession: CheckoutSession,
storedPaymentMethod: StoredPaymentMethod,
- configuration: CashAppPayConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: SessionComponentCallback,
key: String?
@@ -307,7 +381,7 @@ constructor(
val viewModelFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = configuration,
+ configuration = checkoutConfiguration,
sessionParams = SessionParamsFactory.create(checkoutSession),
paymentMethod = storedPaymentMethod,
)
@@ -322,7 +396,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -336,7 +410,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -352,7 +426,7 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionComponentEventHandler = SessionComponentEventHandler(
@@ -376,6 +450,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ storedPaymentMethod: StoredPaymentMethod,
+ configuration: CashAppPayConfiguration,
+ application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): CashAppPayComponent {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ checkoutSession = checkoutSession,
+ storedPaymentMethod = storedPaymentMethod,
+ checkoutConfiguration = configuration.toCheckoutConfiguration(),
+ application = application,
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
private fun assertSupported(paymentMethod: PaymentMethod) {
if (!isPaymentMethodSupported(paymentMethod)) {
throw ComponentException("Unsupported payment method ${paymentMethod.type}")
diff --git a/cashapppay/src/main/java/com/adyen/checkout/cashapppay/internal/ui/model/CashAppPayComponentParamsMapper.kt b/cashapppay/src/main/java/com/adyen/checkout/cashapppay/internal/ui/model/CashAppPayComponentParamsMapper.kt
index c57e36fcd3..049c2279e1 100644
--- a/cashapppay/src/main/java/com/adyen/checkout/cashapppay/internal/ui/model/CashAppPayComponentParamsMapper.kt
+++ b/cashapppay/src/main/java/com/adyen/checkout/cashapppay/internal/ui/model/CashAppPayComponentParamsMapper.kt
@@ -10,40 +10,40 @@ package com.adyen.checkout.cashapppay.internal.ui.model
import com.adyen.checkout.cashapppay.CashAppPayConfiguration
import com.adyen.checkout.cashapppay.CashAppPayEnvironment
+import com.adyen.checkout.cashapppay.getCashAppPayConfiguration
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentMethod
import com.adyen.checkout.components.core.StoredPaymentMethod
import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParams
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.core.Environment
import com.adyen.checkout.core.exception.ComponentException
internal class CashAppPayComponentParamsMapper(
- private val overrideComponentParams: ComponentParams?,
+ private val isCreatedByDropIn: Boolean,
private val overrideSessionParams: SessionParams?,
) {
@Suppress("ThrowsCount")
fun mapToParams(
- configuration: CashAppPayConfiguration,
+ configuration: CheckoutConfiguration,
sessionParams: SessionParams?,
paymentMethod: PaymentMethod,
): CashAppPayComponentParams {
val params = configuration
.mapToParamsInternal(
clientId = paymentMethod.configuration?.clientId ?: throw ComponentException(
- "Cannot launch Cash App Pay, clientId is missing in the payment method object."
+ "Cannot launch Cash App Pay, clientId is missing in the payment method object.",
),
scopeId = paymentMethod.configuration?.scopeId ?: throw ComponentException(
- "Cannot launch Cash App Pay, scopeId is missing in the payment method object."
+ "Cannot launch Cash App Pay, scopeId is missing in the payment method object.",
),
)
- .override(overrideComponentParams)
.override(sessionParams ?: overrideSessionParams)
if (params.returnUrl == null) {
throw ComponentException(
- "Cannot launch Cash App Pay, set the returnUrl in your CashAppPayConfiguration.Builder"
+ "Cannot launch Cash App Pay, set the returnUrl in your CashAppPayConfiguration.Builder",
)
}
@@ -51,56 +51,46 @@ internal class CashAppPayComponentParamsMapper(
}
fun mapToParams(
- configuration: CashAppPayConfiguration,
+ configuration: CheckoutConfiguration,
sessionParams: SessionParams?,
@Suppress("UNUSED_PARAMETER") paymentMethod: StoredPaymentMethod,
): CashAppPayComponentParams = configuration
// clientId and scopeId are not needed in the stored flow.
.mapToParamsInternal(null, null)
- .override(overrideComponentParams)
.override(sessionParams ?: overrideSessionParams)
- private fun CashAppPayConfiguration.mapToParamsInternal(
+ private fun CheckoutConfiguration.mapToParamsInternal(
clientId: String?,
scopeId: String?,
- ) = CashAppPayComponentParams(
- isSubmitButtonVisible = isSubmitButtonVisible ?: true,
- shopperLocale = shopperLocale,
- environment = environment,
- clientKey = clientKey,
- analyticsParams = AnalyticsParams(analyticsConfiguration),
- isCreatedByDropIn = false,
- amount = amount,
- cashAppPayEnvironment = getCashAppPayEnvironment(),
- returnUrl = returnUrl,
- showStorePaymentField = showStorePaymentField ?: true,
- storePaymentMethod = storePaymentMethod ?: false,
- clientId = clientId,
- scopeId = scopeId,
- )
+ ): CashAppPayComponentParams {
+ val cashAppPayConfiguration = getCashAppPayConfiguration()
+ return CashAppPayComponentParams(
+ isSubmitButtonVisible = cashAppPayConfiguration?.isSubmitButtonVisible ?: true,
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ analyticsParams = AnalyticsParams(analyticsConfiguration),
+ isCreatedByDropIn = isCreatedByDropIn,
+ amount = amount,
+ cashAppPayEnvironment = getCashAppPayEnvironment(cashAppPayConfiguration),
+ returnUrl = cashAppPayConfiguration?.returnUrl,
+ showStorePaymentField = cashAppPayConfiguration?.showStorePaymentField ?: true,
+ storePaymentMethod = cashAppPayConfiguration?.storePaymentMethod ?: false,
+ clientId = clientId,
+ scopeId = scopeId,
+ )
+ }
- private fun CashAppPayConfiguration.getCashAppPayEnvironment(): CashAppPayEnvironment {
+ private fun CheckoutConfiguration.getCashAppPayEnvironment(
+ cashAppPayConfiguration: CashAppPayConfiguration?
+ ): CashAppPayEnvironment {
return when {
- cashAppPayEnvironment != null -> cashAppPayEnvironment
+ cashAppPayConfiguration?.cashAppPayEnvironment != null -> cashAppPayConfiguration.cashAppPayEnvironment
environment == Environment.TEST -> CashAppPayEnvironment.SANDBOX
else -> CashAppPayEnvironment.PRODUCTION
}
}
- private fun CashAppPayComponentParams.override(
- overrideComponentParams: ComponentParams?,
- ): CashAppPayComponentParams {
- if (overrideComponentParams == null) return this
- return copy(
- shopperLocale = overrideComponentParams.shopperLocale,
- environment = overrideComponentParams.environment,
- clientKey = overrideComponentParams.clientKey,
- analyticsParams = overrideComponentParams.analyticsParams,
- isCreatedByDropIn = overrideComponentParams.isCreatedByDropIn,
- amount = overrideComponentParams.amount,
- )
- }
-
private fun CashAppPayComponentParams.override(
sessionParams: SessionParams?,
): CashAppPayComponentParams {
@@ -108,7 +98,7 @@ internal class CashAppPayComponentParamsMapper(
return copy(
amount = sessionParams.amount ?: amount,
showStorePaymentField = sessionParams.enableStoreDetails ?: showStorePaymentField,
- returnUrl = sessionParams.returnUrl ?: returnUrl
+ returnUrl = sessionParams.returnUrl ?: returnUrl,
)
}
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
index 7858598818..a71292e377 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
@@ -182,7 +182,7 @@ internal fun getComponentFor(
checkCompileOnly { CashAppPayComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
val cashAppPayConfig: CashAppPayConfiguration =
getConfigurationForPaymentMethod(storedPaymentMethod, checkoutConfiguration)
- CashAppPayComponentProvider(dropInParams, sessionParams).get(
+ CashAppPayComponentProvider(true, sessionParams).get(
fragment = fragment,
storedPaymentMethod = storedPaymentMethod,
configuration = cashAppPayConfig,
@@ -302,7 +302,7 @@ internal fun getComponentFor(
checkCompileOnly { CashAppPayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val cashAppPayConfiguration: CashAppPayConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- CashAppPayComponentProvider(dropInParams, sessionParams).get(
+ CashAppPayComponentProvider(true, sessionParams).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = cashAppPayConfiguration,
From 812a8f5f51cc63aa70cadcd5e7a6c609cf7423b0 Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Thu, 4 Jan 2024 16:47:44 +0100
Subject: [PATCH 051/255] Make EContext payment methods accept
CheckoutConfiguration
COAND-811
---
.../BacsDirectDebitComponentProvider.kt | 15 ++-
.../provider/BlikComponentProvider.kt | 24 +++--
.../ui/model/ButtonComponentParamsMapper.kt | 31 ++----
.../ConvenienceStoresJPConfiguration.kt | 16 ++++
.../ConvenienceStoresJPComponentProvider.kt | 20 +++-
.../provider/ComponentParsingProvider.kt | 14 +--
.../provider/EContextComponentProvider.kt | 96 +++++++++++++++----
.../OnlineBankingJPConfiguration.kt | 16 ++++
.../OnlineBankingJPComponentProvider.kt | 18 +++-
.../checkout/payeasy/PayEasyConfiguration.kt | 16 ++++
.../provider/PayEasyComponentProvider.kt | 16 +++-
.../seveneleven/SevenElevenConfiguration.kt | 16 ++++
.../provider/SevenElevenComponentProvider.kt | 18 +++-
13 files changed, 240 insertions(+), 76 deletions(-)
diff --git a/bacs/src/main/java/com/adyen/checkout/bacs/internal/provider/BacsDirectDebitComponentProvider.kt b/bacs/src/main/java/com/adyen/checkout/bacs/internal/provider/BacsDirectDebitComponentProvider.kt
index a09aa3df9d..7b4e4b733d 100644
--- a/bacs/src/main/java/com/adyen/checkout/bacs/internal/provider/BacsDirectDebitComponentProvider.kt
+++ b/bacs/src/main/java/com/adyen/checkout/bacs/internal/provider/BacsDirectDebitComponentProvider.kt
@@ -19,6 +19,7 @@ import com.adyen.checkout.action.core.internal.provider.GenericActionComponentPr
import com.adyen.checkout.bacs.BacsDirectDebitComponent
import com.adyen.checkout.bacs.BacsDirectDebitComponentState
import com.adyen.checkout.bacs.BacsDirectDebitConfiguration
+import com.adyen.checkout.bacs.getBacsDirectDebitConfiguration
import com.adyen.checkout.bacs.internal.ui.DefaultBacsDirectDebitDelegate
import com.adyen.checkout.bacs.toCheckoutConfiguration
import com.adyen.checkout.components.core.CheckoutConfiguration
@@ -34,7 +35,6 @@ import com.adyen.checkout.components.core.internal.data.api.AnalyticsService
import com.adyen.checkout.components.core.internal.data.api.DefaultAnalyticsRepository
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.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.internal.util.get
import com.adyen.checkout.components.core.internal.util.viewModelFactory
@@ -54,7 +54,7 @@ import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
class BacsDirectDebitComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
+ isCreatedByDropIn: Boolean = false,
overrideSessionParams: SessionParams? = null,
private val analyticsRepository: AnalyticsRepository? = null,
) :
@@ -72,7 +72,7 @@ constructor(
> {
// TODO: replace override
- private val componentParamsMapper = ButtonComponentParamsMapper(overrideComponentParams, overrideSessionParams)
+ private val componentParamsMapper = ButtonComponentParamsMapper(isCreatedByDropIn, overrideSessionParams)
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
@@ -88,7 +88,11 @@ constructor(
assertSupported(paymentMethod)
val genericFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
+ val componentParams = componentParamsMapper.mapToParams(
+ checkoutConfiguration = checkoutConfiguration,
+ configuration = checkoutConfiguration.getBacsDirectDebitConfiguration(),
+ sessionParams = null,
+ )
val analyticsRepository = analyticsRepository ?: DefaultAnalyticsRepository(
analyticsRepositoryData = AnalyticsRepositoryData(
@@ -173,7 +177,8 @@ constructor(
val genericFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = checkoutConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
+ configuration = checkoutConfiguration.getBacsDirectDebitConfiguration(),
sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
diff --git a/blik/src/main/java/com/adyen/checkout/blik/internal/provider/BlikComponentProvider.kt b/blik/src/main/java/com/adyen/checkout/blik/internal/provider/BlikComponentProvider.kt
index aade9569e4..1c13c89e53 100644
--- a/blik/src/main/java/com/adyen/checkout/blik/internal/provider/BlikComponentProvider.kt
+++ b/blik/src/main/java/com/adyen/checkout/blik/internal/provider/BlikComponentProvider.kt
@@ -19,6 +19,7 @@ import com.adyen.checkout.action.core.internal.provider.GenericActionComponentPr
import com.adyen.checkout.blik.BlikComponent
import com.adyen.checkout.blik.BlikComponentState
import com.adyen.checkout.blik.BlikConfiguration
+import com.adyen.checkout.blik.getBlikConfiguration
import com.adyen.checkout.blik.internal.ui.DefaultBlikDelegate
import com.adyen.checkout.blik.internal.ui.StoredBlikDelegate
import com.adyen.checkout.blik.toCheckoutConfiguration
@@ -37,7 +38,6 @@ import com.adyen.checkout.components.core.internal.data.api.DefaultAnalyticsRepo
import com.adyen.checkout.components.core.internal.provider.PaymentComponentProvider
import com.adyen.checkout.components.core.internal.provider.StoredPaymentComponentProvider
import com.adyen.checkout.components.core.internal.ui.model.ButtonComponentParamsMapper
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.internal.util.get
import com.adyen.checkout.components.core.internal.util.viewModelFactory
@@ -59,7 +59,7 @@ import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
class BlikComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
+ isCreatedByDropIn: Boolean = false,
overrideSessionParams: SessionParams? = null,
private val analyticsRepository: AnalyticsRepository? = null,
) :
@@ -88,7 +88,7 @@ constructor(
SessionComponentCallback,
> {
- private val componentParamsMapper = ButtonComponentParamsMapper(overrideComponentParams, overrideSessionParams)
+ private val componentParamsMapper = ButtonComponentParamsMapper(isCreatedByDropIn, overrideSessionParams)
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
@@ -104,7 +104,11 @@ constructor(
assertSupported(paymentMethod)
val genericFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
+ val componentParams = componentParamsMapper.mapToParams(
+ checkoutConfiguration = checkoutConfiguration,
+ configuration = checkoutConfiguration.getBlikConfiguration(),
+ sessionParams = null,
+ )
val analyticsRepository = analyticsRepository ?: DefaultAnalyticsRepository(
analyticsRepositoryData = AnalyticsRepositoryData(
@@ -187,7 +191,11 @@ constructor(
assertSupported(storedPaymentMethod)
val genericStoredFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
+ val componentParams = componentParamsMapper.mapToParams(
+ checkoutConfiguration = checkoutConfiguration,
+ configuration = checkoutConfiguration.getBlikConfiguration(),
+ sessionParams = null,
+ )
val analyticsRepository = analyticsRepository ?: DefaultAnalyticsRepository(
analyticsRepositoryData = AnalyticsRepositoryData(
@@ -272,7 +280,8 @@ constructor(
val genericFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = checkoutConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
+ configuration = checkoutConfiguration.getBlikConfiguration(),
sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
@@ -380,7 +389,8 @@ constructor(
val genericStoredFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = checkoutConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
+ configuration = checkoutConfiguration.getBlikConfiguration(),
sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/ButtonComponentParamsMapper.kt b/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/ButtonComponentParamsMapper.kt
index d019037425..13db64eb53 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/ButtonComponentParamsMapper.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/internal/ui/model/ButtonComponentParamsMapper.kt
@@ -1,48 +1,35 @@
package com.adyen.checkout.components.core.internal.ui.model
import androidx.annotation.RestrictTo
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.internal.ButtonConfiguration
import com.adyen.checkout.components.core.internal.Configuration
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
class ButtonComponentParamsMapper(
- private val overrideComponentParams: ComponentParams?,
+ private val isCreatedByDropIn: Boolean,
private val overrideSessionParams: SessionParams?,
) {
fun mapToParams(
- configuration: Configuration,
+ checkoutConfiguration: CheckoutConfiguration,
+ configuration: Configuration?,
sessionParams: SessionParams?,
): ButtonComponentParams {
- return configuration
- .mapToParamsInternal()
- .override(overrideComponentParams)
+ return checkoutConfiguration
+ .mapToParamsInternal(configuration)
.override(sessionParams ?: overrideSessionParams)
}
- private fun Configuration.mapToParamsInternal(): ButtonComponentParams {
+ private fun CheckoutConfiguration.mapToParamsInternal(configuration: Configuration?): ButtonComponentParams {
return ButtonComponentParams(
shopperLocale = shopperLocale,
environment = environment,
clientKey = clientKey,
analyticsParams = AnalyticsParams(analyticsConfiguration),
- isCreatedByDropIn = false,
+ isCreatedByDropIn = isCreatedByDropIn,
amount = amount,
- isSubmitButtonVisible = (this as? ButtonConfiguration)?.isSubmitButtonVisible ?: true
- )
- }
-
- private fun ButtonComponentParams.override(
- overrideComponentParams: ComponentParams?
- ): ButtonComponentParams {
- if (overrideComponentParams == null) return this
- return copy(
- shopperLocale = overrideComponentParams.shopperLocale,
- environment = overrideComponentParams.environment,
- clientKey = overrideComponentParams.clientKey,
- analyticsParams = overrideComponentParams.analyticsParams,
- isCreatedByDropIn = overrideComponentParams.isCreatedByDropIn,
- amount = overrideComponentParams.amount
+ isSubmitButtonVisible = (configuration as? ButtonConfiguration)?.isSubmitButtonVisible ?: true,
)
}
diff --git a/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt b/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt
index 8b61b5a656..19bcdc9dff 100644
--- a/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt
+++ b/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/ConvenienceStoresJPConfiguration.kt
@@ -96,3 +96,19 @@ fun CheckoutConfiguration.convenienceStoresJPConfiguration(
fun CheckoutConfiguration.getConvenienceStoresJPConfiguration(): ConvenienceStoresJPConfiguration? {
return getConfiguration(PaymentMethodTypes.ECONTEXT_STORES)
}
+
+internal fun ConvenienceStoresJPConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addConfiguration(PaymentMethodTypes.ECONTEXT_STORES, this@toCheckoutConfiguration)
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/internal/provider/ConvenienceStoresJPComponentProvider.kt b/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/internal/provider/ConvenienceStoresJPComponentProvider.kt
index 10c3f8d04b..bc4f2ff756 100644
--- a/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/internal/provider/ConvenienceStoresJPComponentProvider.kt
+++ b/convenience-stores-jp/src/main/java/com/adyen/checkout/conveniencestoresjp/internal/provider/ConvenienceStoresJPComponentProvider.kt
@@ -11,32 +11,34 @@ package com.adyen.checkout.conveniencestoresjp.internal.provider
import androidx.annotation.RestrictTo
import com.adyen.checkout.action.core.internal.DefaultActionHandlingComponent
import com.adyen.checkout.action.core.internal.ui.GenericActionDelegate
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentComponentData
import com.adyen.checkout.components.core.internal.ComponentEventHandler
import com.adyen.checkout.components.core.internal.data.api.AnalyticsRepository
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.paymentmethod.ConvenienceStoresJPPaymentMethod
import com.adyen.checkout.conveniencestoresjp.ConvenienceStoresJPComponent
import com.adyen.checkout.conveniencestoresjp.ConvenienceStoresJPComponentState
import com.adyen.checkout.conveniencestoresjp.ConvenienceStoresJPConfiguration
+import com.adyen.checkout.conveniencestoresjp.getConvenienceStoresJPConfiguration
+import com.adyen.checkout.conveniencestoresjp.toCheckoutConfiguration
import com.adyen.checkout.econtext.internal.provider.EContextComponentProvider
import com.adyen.checkout.econtext.internal.ui.EContextDelegate
class ConvenienceStoresJPComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
+ isCreatedByDropIn: Boolean = false,
overrideSessionParams: SessionParams? = null,
analyticsRepository: AnalyticsRepository? = null,
) : EContextComponentProvider<
ConvenienceStoresJPComponent,
ConvenienceStoresJPConfiguration,
ConvenienceStoresJPPaymentMethod,
- ConvenienceStoresJPComponentState
+ ConvenienceStoresJPComponentState,
>(
componentClass = ConvenienceStoresJPComponent::class.java,
- overrideComponentParams = overrideComponentParams,
+ isCreatedByDropIn = isCreatedByDropIn,
overrideSessionParams = overrideSessionParams,
analyticsRepository = analyticsRepository,
) {
@@ -57,7 +59,7 @@ constructor(
delegate = delegate,
genericActionDelegate = genericActionDelegate,
actionHandlingComponent = actionHandlingComponent,
- componentEventHandler = componentEventHandler
+ componentEventHandler = componentEventHandler,
)
}
@@ -65,6 +67,14 @@ constructor(
return ConvenienceStoresJPPaymentMethod()
}
+ override fun getConfiguration(checkoutConfiguration: CheckoutConfiguration): ConvenienceStoresJPConfiguration? {
+ return checkoutConfiguration.getConvenienceStoresJPConfiguration()
+ }
+
+ override fun getCheckoutConfiguration(configuration: ConvenienceStoresJPConfiguration): CheckoutConfiguration {
+ return configuration.toCheckoutConfiguration()
+ }
+
override fun getSupportedPaymentMethods(): List {
return ConvenienceStoresJPComponent.PAYMENT_METHOD_TYPES
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
index a71292e377..915504e513 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
@@ -194,7 +194,7 @@ internal fun getComponentFor(
checkCompileOnly { BlikComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
val blikConfig: BlikConfiguration =
getConfigurationForPaymentMethod(storedPaymentMethod, checkoutConfiguration)
- BlikComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ BlikComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
storedPaymentMethod = storedPaymentMethod,
configuration = blikConfig,
@@ -247,7 +247,7 @@ internal fun getComponentFor(
checkCompileOnly { BacsDirectDebitComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val bacsConfiguration: BacsDirectDebitConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- BacsDirectDebitComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ BacsDirectDebitComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = bacsConfiguration,
@@ -269,7 +269,7 @@ internal fun getComponentFor(
checkCompileOnly { BlikComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val blikConfiguration: BlikConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- BlikComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ BlikComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = blikConfiguration,
@@ -313,7 +313,7 @@ internal fun getComponentFor(
checkCompileOnly { ConvenienceStoresJPComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val convenienceStoresJPConfiguration: ConvenienceStoresJPConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- ConvenienceStoresJPComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ ConvenienceStoresJPComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = convenienceStoresJPConfiguration,
@@ -434,7 +434,7 @@ internal fun getComponentFor(
checkCompileOnly { OnlineBankingJPComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val onlineBankingJPConfig: OnlineBankingJPConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- OnlineBankingJPComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ OnlineBankingJPComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = onlineBankingJPConfig,
@@ -489,7 +489,7 @@ internal fun getComponentFor(
checkCompileOnly { PayEasyComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val payEasyConfiguration: PayEasyConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- PayEasyComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ PayEasyComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = payEasyConfiguration,
@@ -511,7 +511,7 @@ internal fun getComponentFor(
checkCompileOnly { SevenElevenComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val sevenElevenConfiguration: SevenElevenConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- SevenElevenComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ SevenElevenComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = sevenElevenConfiguration,
diff --git a/econtext/src/main/java/com/adyen/checkout/econtext/internal/provider/EContextComponentProvider.kt b/econtext/src/main/java/com/adyen/checkout/econtext/internal/provider/EContextComponentProvider.kt
index 39a2110b8c..13f7252a07 100644
--- a/econtext/src/main/java/com/adyen/checkout/econtext/internal/provider/EContextComponentProvider.kt
+++ b/econtext/src/main/java/com/adyen/checkout/econtext/internal/provider/EContextComponentProvider.kt
@@ -17,6 +17,7 @@ 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.action.core.internal.ui.GenericActionDelegate
+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.PaymentComponentData
@@ -32,7 +33,6 @@ import com.adyen.checkout.components.core.internal.data.api.AnalyticsService
import com.adyen.checkout.components.core.internal.data.api.DefaultAnalyticsRepository
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.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.internal.util.get
import com.adyen.checkout.components.core.internal.util.viewModelFactory
@@ -54,7 +54,7 @@ import com.adyen.checkout.sessions.core.internal.provider.SessionPaymentComponen
import com.adyen.checkout.sessions.core.internal.ui.model.SessionParamsFactory
import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
-@Suppress("ktlint:standard:type-parameter-list-spacing")
+@Suppress("TooManyFunctions", "ktlint:standard:type-parameter-list-spacing")
abstract class EContextComponentProvider<
ComponentT : EContextComponent,
ConfigurationT : EContextConfiguration,
@@ -64,7 +64,7 @@ abstract class EContextComponentProvider<
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
private val componentClass: Class,
- overrideComponentParams: ComponentParams?,
+ isCreatedByDropIn: Boolean,
overrideSessionParams: SessionParams?,
private val analyticsRepository: AnalyticsRepository?,
) : PaymentComponentProvider>,
@@ -72,17 +72,17 @@ constructor(
ComponentT,
ConfigurationT,
ComponentStateT,
- SessionComponentCallback
+ SessionComponentCallback,
> {
- private val componentParamsMapper = ButtonComponentParamsMapper(overrideComponentParams, overrideSessionParams)
+ private val componentParamsMapper = ButtonComponentParamsMapper(isCreatedByDropIn, overrideSessionParams)
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
paymentMethod: PaymentMethod,
- configuration: ConfigurationT,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: ComponentCallback,
order: Order?,
@@ -92,7 +92,11 @@ constructor(
val genericFactory: ViewModelProvider.Factory =
viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(
+ checkoutConfiguration = checkoutConfiguration,
+ configuration = getConfiguration(checkoutConfiguration),
+ sessionParams = null,
+ )
val analyticsRepository = analyticsRepository ?: DefaultAnalyticsRepository(
analyticsRepositoryData = AnalyticsRepositoryData(
@@ -101,7 +105,7 @@ constructor(
paymentMethod = paymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -113,11 +117,11 @@ constructor(
analyticsRepository = analyticsRepository,
submitHandler = SubmitHandler(savedStateHandle),
typedPaymentMethodFactory = { createPaymentMethod() },
- componentStateFactory = ::createComponentState
+ componentStateFactory = ::createComponentState,
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -126,7 +130,7 @@ constructor(
delegate = eContextDelegate,
genericActionDelegate = genericActionDelegate,
actionHandlingComponent = DefaultActionHandlingComponent(genericActionDelegate, eContextDelegate),
- componentEventHandler = DefaultComponentEventHandler()
+ componentEventHandler = DefaultComponentEventHandler(),
)
}
return ViewModelProvider(viewModelStoreOwner, genericFactory)[key, componentClass].also { component ->
@@ -136,6 +140,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ paymentMethod: PaymentMethod,
+ configuration: ConfigurationT,
+ application: Application,
+ componentCallback: ComponentCallback,
+ order: Order?,
+ key: String?
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = getCheckoutConfiguration(configuration),
+ application = application,
+ componentCallback = componentCallback,
+ order = order,
+ key = key,
+ )
+ }
+
@Suppress("LongMethod")
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
@@ -143,7 +171,7 @@ constructor(
lifecycleOwner: LifecycleOwner,
checkoutSession: CheckoutSession,
paymentMethod: PaymentMethod,
- configuration: ConfigurationT,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: SessionComponentCallback,
key: String?
@@ -153,8 +181,9 @@ constructor(
val genericFactory: ViewModelProvider.Factory =
viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = configuration,
- sessionParams = SessionParamsFactory.create(checkoutSession)
+ checkoutConfiguration = checkoutConfiguration,
+ configuration = getConfiguration(checkoutConfiguration),
+ sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
@@ -166,7 +195,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -178,11 +207,11 @@ constructor(
analyticsRepository = analyticsRepository,
submitHandler = SubmitHandler(savedStateHandle),
typedPaymentMethodFactory = { createPaymentMethod() },
- componentStateFactory = ::createComponentState
+ componentStateFactory = ::createComponentState,
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -197,11 +226,11 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionComponentEventHandler = SessionComponentEventHandler(
sessionInteractor = sessionInteractor,
- sessionSavedStateHandleContainer = sessionSavedStateHandleContainer
+ sessionSavedStateHandleContainer = sessionSavedStateHandleContainer,
)
createComponent(
@@ -211,6 +240,7 @@ constructor(
componentEventHandler = sessionComponentEventHandler,
)
}
+
return ViewModelProvider(viewModelStoreOwner, genericFactory)[key, componentClass].also { component ->
component.observe(lifecycleOwner) {
component.componentEventHandler.onPaymentComponentEvent(it, componentCallback)
@@ -218,6 +248,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ configuration: ConfigurationT,
+ application: Application,
+ componentCallback: SessionComponentCallback,
+ key: String?
+ ): ComponentT {
+ return get(
+ savedStateRegistryOwner = savedStateRegistryOwner,
+ viewModelStoreOwner = viewModelStoreOwner,
+ lifecycleOwner = lifecycleOwner,
+ checkoutSession = checkoutSession,
+ paymentMethod = paymentMethod,
+ checkoutConfiguration = getCheckoutConfiguration(configuration),
+ application = application,
+ componentCallback = componentCallback,
+ key = key,
+ )
+ }
+
protected abstract fun createComponentState(
data: PaymentComponentData,
isInputValid: Boolean,
@@ -235,6 +289,10 @@ constructor(
abstract fun getSupportedPaymentMethods(): List
+ abstract fun getConfiguration(checkoutConfiguration: CheckoutConfiguration): ConfigurationT?
+
+ abstract fun getCheckoutConfiguration(configuration: ConfigurationT): CheckoutConfiguration
+
private fun assertSupported(paymentMethod: PaymentMethod) {
if (!isPaymentMethodSupported(paymentMethod)) {
throw ComponentException("Unsupported payment method ${paymentMethod.type}")
diff --git a/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt b/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt
index 2be43a3d70..c0d274b64f 100644
--- a/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt
+++ b/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/OnlineBankingJPConfiguration.kt
@@ -96,3 +96,19 @@ fun CheckoutConfiguration.onlineBankingJPConfiguration(
fun CheckoutConfiguration.getOnlineBankingJPConfiguration(): OnlineBankingJPConfiguration? {
return getConfiguration(PaymentMethodTypes.ECONTEXT_ONLINE)
}
+
+internal fun OnlineBankingJPConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addConfiguration(PaymentMethodTypes.ECONTEXT_ONLINE, this@toCheckoutConfiguration)
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/internal/provider/OnlineBankingJPComponentProvider.kt b/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/internal/provider/OnlineBankingJPComponentProvider.kt
index 0fce6f39d7..31402403c0 100644
--- a/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/internal/provider/OnlineBankingJPComponentProvider.kt
+++ b/online-banking-jp/src/main/java/com/adyen/checkout/onlinebankingjp/internal/provider/OnlineBankingJPComponentProvider.kt
@@ -11,10 +11,10 @@ package com.adyen.checkout.onlinebankingjp.internal.provider
import androidx.annotation.RestrictTo
import com.adyen.checkout.action.core.internal.DefaultActionHandlingComponent
import com.adyen.checkout.action.core.internal.ui.GenericActionDelegate
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentComponentData
import com.adyen.checkout.components.core.internal.ComponentEventHandler
import com.adyen.checkout.components.core.internal.data.api.AnalyticsRepository
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.paymentmethod.OnlineBankingJPPaymentMethod
import com.adyen.checkout.econtext.internal.provider.EContextComponentProvider
@@ -22,21 +22,23 @@ import com.adyen.checkout.econtext.internal.ui.EContextDelegate
import com.adyen.checkout.onlinebankingjp.OnlineBankingJPComponent
import com.adyen.checkout.onlinebankingjp.OnlineBankingJPComponentState
import com.adyen.checkout.onlinebankingjp.OnlineBankingJPConfiguration
+import com.adyen.checkout.onlinebankingjp.getOnlineBankingJPConfiguration
+import com.adyen.checkout.onlinebankingjp.toCheckoutConfiguration
class OnlineBankingJPComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
+ isCreatedByDropIn: Boolean = false,
overrideSessionParams: SessionParams? = null,
analyticsRepository: AnalyticsRepository? = null,
) : EContextComponentProvider<
OnlineBankingJPComponent,
OnlineBankingJPConfiguration,
OnlineBankingJPPaymentMethod,
- OnlineBankingJPComponentState
+ OnlineBankingJPComponentState,
>(
componentClass = OnlineBankingJPComponent::class.java,
- overrideComponentParams = overrideComponentParams,
+ isCreatedByDropIn = isCreatedByDropIn,
overrideSessionParams = overrideSessionParams,
analyticsRepository = analyticsRepository,
) {
@@ -65,6 +67,14 @@ constructor(
return OnlineBankingJPPaymentMethod()
}
+ override fun getConfiguration(checkoutConfiguration: CheckoutConfiguration): OnlineBankingJPConfiguration? {
+ return checkoutConfiguration.getOnlineBankingJPConfiguration()
+ }
+
+ override fun getCheckoutConfiguration(configuration: OnlineBankingJPConfiguration): CheckoutConfiguration {
+ return configuration.toCheckoutConfiguration()
+ }
+
override fun getSupportedPaymentMethods(): List {
return OnlineBankingJPComponent.PAYMENT_METHOD_TYPES
}
diff --git a/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt b/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt
index c56682848d..dd6d393ac4 100644
--- a/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt
+++ b/payeasy/src/main/java/com/adyen/checkout/payeasy/PayEasyConfiguration.kt
@@ -96,3 +96,19 @@ fun CheckoutConfiguration.payEasyConfiguration(
fun CheckoutConfiguration.getPayEasyConfiguration(): PayEasyConfiguration? {
return getConfiguration(PaymentMethodTypes.ECONTEXT_ATM)
}
+
+internal fun PayEasyConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addConfiguration(PaymentMethodTypes.ECONTEXT_ATM, this@toCheckoutConfiguration)
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/payeasy/src/main/java/com/adyen/checkout/payeasy/internal/provider/PayEasyComponentProvider.kt b/payeasy/src/main/java/com/adyen/checkout/payeasy/internal/provider/PayEasyComponentProvider.kt
index 6f162c8b9e..0a59e600d1 100644
--- a/payeasy/src/main/java/com/adyen/checkout/payeasy/internal/provider/PayEasyComponentProvider.kt
+++ b/payeasy/src/main/java/com/adyen/checkout/payeasy/internal/provider/PayEasyComponentProvider.kt
@@ -11,10 +11,10 @@ package com.adyen.checkout.payeasy.internal.provider
import androidx.annotation.RestrictTo
import com.adyen.checkout.action.core.internal.DefaultActionHandlingComponent
import com.adyen.checkout.action.core.internal.ui.GenericActionDelegate
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentComponentData
import com.adyen.checkout.components.core.internal.ComponentEventHandler
import com.adyen.checkout.components.core.internal.data.api.AnalyticsRepository
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.paymentmethod.PayEasyPaymentMethod
import com.adyen.checkout.econtext.internal.provider.EContextComponentProvider
@@ -22,16 +22,18 @@ import com.adyen.checkout.econtext.internal.ui.EContextDelegate
import com.adyen.checkout.payeasy.PayEasyComponent
import com.adyen.checkout.payeasy.PayEasyComponentState
import com.adyen.checkout.payeasy.PayEasyConfiguration
+import com.adyen.checkout.payeasy.getPayEasyConfiguration
+import com.adyen.checkout.payeasy.toCheckoutConfiguration
class PayEasyComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
+ isCreatedByDropIn: Boolean = false,
overrideSessionParams: SessionParams? = null,
analyticsRepository: AnalyticsRepository? = null,
) : EContextComponentProvider(
componentClass = PayEasyComponent::class.java,
- overrideComponentParams = overrideComponentParams,
+ isCreatedByDropIn = isCreatedByDropIn,
overrideSessionParams = overrideSessionParams,
analyticsRepository = analyticsRepository,
) {
@@ -60,6 +62,14 @@ constructor(
return PayEasyPaymentMethod()
}
+ override fun getConfiguration(checkoutConfiguration: CheckoutConfiguration): PayEasyConfiguration? {
+ return checkoutConfiguration.getPayEasyConfiguration()
+ }
+
+ override fun getCheckoutConfiguration(configuration: PayEasyConfiguration): CheckoutConfiguration {
+ return configuration.toCheckoutConfiguration()
+ }
+
override fun getSupportedPaymentMethods(): List {
return PayEasyComponent.PAYMENT_METHOD_TYPES
}
diff --git a/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt b/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt
index a92ed5eb80..493b9fcea8 100644
--- a/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt
+++ b/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/SevenElevenConfiguration.kt
@@ -96,3 +96,19 @@ fun CheckoutConfiguration.sevenElevenConfiguration(
fun CheckoutConfiguration.getSevenElevenConfiguration(): SevenElevenConfiguration? {
return getConfiguration(PaymentMethodTypes.ECONTEXT_SEVEN_ELEVEN)
}
+
+internal fun SevenElevenConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addConfiguration(PaymentMethodTypes.ECONTEXT_SEVEN_ELEVEN, this@toCheckoutConfiguration)
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/internal/provider/SevenElevenComponentProvider.kt b/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/internal/provider/SevenElevenComponentProvider.kt
index 00c8235e84..5fa1d3dae5 100644
--- a/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/internal/provider/SevenElevenComponentProvider.kt
+++ b/seven-eleven/src/main/java/com/adyen/checkout/seveneleven/internal/provider/SevenElevenComponentProvider.kt
@@ -11,10 +11,10 @@ package com.adyen.checkout.seveneleven.internal.provider
import androidx.annotation.RestrictTo
import com.adyen.checkout.action.core.internal.DefaultActionHandlingComponent
import com.adyen.checkout.action.core.internal.ui.GenericActionDelegate
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.PaymentComponentData
import com.adyen.checkout.components.core.internal.ComponentEventHandler
import com.adyen.checkout.components.core.internal.data.api.AnalyticsRepository
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.paymentmethod.SevenElevenPaymentMethod
import com.adyen.checkout.econtext.internal.provider.EContextComponentProvider
@@ -22,21 +22,23 @@ import com.adyen.checkout.econtext.internal.ui.EContextDelegate
import com.adyen.checkout.seveneleven.SevenElevenComponent
import com.adyen.checkout.seveneleven.SevenElevenComponentState
import com.adyen.checkout.seveneleven.SevenElevenConfiguration
+import com.adyen.checkout.seveneleven.getSevenElevenConfiguration
+import com.adyen.checkout.seveneleven.toCheckoutConfiguration
class SevenElevenComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
+ isCreatedByDropIn: Boolean = false,
overrideSessionParams: SessionParams? = null,
analyticsRepository: AnalyticsRepository? = null,
) : EContextComponentProvider<
SevenElevenComponent,
SevenElevenConfiguration,
SevenElevenPaymentMethod,
- SevenElevenComponentState
+ SevenElevenComponentState,
>(
componentClass = SevenElevenComponent::class.java,
- overrideComponentParams = overrideComponentParams,
+ isCreatedByDropIn = isCreatedByDropIn,
overrideSessionParams = overrideSessionParams,
analyticsRepository = analyticsRepository,
) {
@@ -65,6 +67,14 @@ constructor(
return SevenElevenPaymentMethod()
}
+ override fun getConfiguration(checkoutConfiguration: CheckoutConfiguration): SevenElevenConfiguration? {
+ return checkoutConfiguration.getSevenElevenConfiguration()
+ }
+
+ override fun getCheckoutConfiguration(configuration: SevenElevenConfiguration): CheckoutConfiguration {
+ return configuration.toCheckoutConfiguration()
+ }
+
override fun getSupportedPaymentMethods(): List {
return SevenElevenComponent.PAYMENT_METHOD_TYPES
}
From 6f247030e1bf4856cfdf50d4064bf680f86b7c3d Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Thu, 4 Jan 2024 16:57:40 +0100
Subject: [PATCH 052/255] Make gift card accept CheckoutConfiguration
COAND-811
---
.../provider/ComponentParsingProvider.kt | 3 +-
.../giftcard/GiftCardConfiguration.kt | 16 ++++
.../provider/GiftCardComponentProvider.kt | 81 +++++++++++++++----
.../ui/model/GiftCardComponentParamsMapper.kt | 33 +++-----
4 files changed, 91 insertions(+), 42 deletions(-)
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
index 915504e513..942ba632fe 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
@@ -152,7 +152,6 @@ internal fun getComponentFor(
analyticsRepository: AnalyticsRepository,
onRedirect: () -> Unit,
): PaymentComponent {
- val dropInParams = checkoutConfiguration.getDropInConfiguration()?.mapToParams(amount)
val sessionParams = sessionDetails?.mapToParams(amount)
return when {
checkCompileOnly { ACHDirectDebitComponent.PROVIDER.isPaymentMethodSupported(storedPaymentMethod) } -> {
@@ -357,7 +356,7 @@ internal fun getComponentFor(
checkCompileOnly { GiftCardComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val giftcardConfiguration: GiftCardConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- GiftCardComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ GiftCardComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = giftcardConfiguration,
diff --git a/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt b/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt
index 3bcf2fc356..6b3964d76c 100644
--- a/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt
+++ b/giftcard/src/main/java/com/adyen/checkout/giftcard/GiftCardConfiguration.kt
@@ -130,3 +130,19 @@ fun CheckoutConfiguration.giftCardConfiguration(
fun CheckoutConfiguration.getGiftCardConfiguration(): GiftCardConfiguration? {
return getConfiguration(PaymentMethodTypes.GIFTCARD)
}
+
+internal fun GiftCardConfiguration.toCheckoutConfiguration(): CheckoutConfiguration {
+ return CheckoutConfiguration(
+ shopperLocale = shopperLocale,
+ environment = environment,
+ clientKey = clientKey,
+ amount = amount,
+ analyticsConfiguration = analyticsConfiguration,
+ ) {
+ addConfiguration(PaymentMethodTypes.GIFTCARD, this@toCheckoutConfiguration)
+
+ genericActionConfiguration.getAllConfigurations().forEach {
+ addActionConfiguration(it)
+ }
+ }
+}
diff --git a/giftcard/src/main/java/com/adyen/checkout/giftcard/internal/provider/GiftCardComponentProvider.kt b/giftcard/src/main/java/com/adyen/checkout/giftcard/internal/provider/GiftCardComponentProvider.kt
index 3346453c19..1d09339d55 100644
--- a/giftcard/src/main/java/com/adyen/checkout/giftcard/internal/provider/GiftCardComponentProvider.kt
+++ b/giftcard/src/main/java/com/adyen/checkout/giftcard/internal/provider/GiftCardComponentProvider.kt
@@ -15,6 +15,7 @@ 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.Order
import com.adyen.checkout.components.core.PaymentMethod
import com.adyen.checkout.components.core.internal.PaymentObserverRepository
@@ -26,7 +27,6 @@ import com.adyen.checkout.components.core.internal.data.api.DefaultAnalyticsRepo
import com.adyen.checkout.components.core.internal.data.api.DefaultPublicKeyRepository
import com.adyen.checkout.components.core.internal.data.api.PublicKeyService
import com.adyen.checkout.components.core.internal.provider.PaymentComponentProvider
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.components.core.internal.util.get
import com.adyen.checkout.components.core.internal.util.viewModelFactory
@@ -43,6 +43,7 @@ import com.adyen.checkout.giftcard.internal.SessionsGiftCardComponentCallbackWra
import com.adyen.checkout.giftcard.internal.SessionsGiftCardComponentEventHandler
import com.adyen.checkout.giftcard.internal.ui.DefaultGiftCardDelegate
import com.adyen.checkout.giftcard.internal.ui.model.GiftCardComponentParamsMapper
+import com.adyen.checkout.giftcard.toCheckoutConfiguration
import com.adyen.checkout.sessions.core.CheckoutSession
import com.adyen.checkout.sessions.core.internal.SessionInteractor
import com.adyen.checkout.sessions.core.internal.SessionSavedStateHandleContainer
@@ -55,7 +56,7 @@ import com.adyen.checkout.ui.core.internal.ui.SubmitHandler
class GiftCardComponentProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
- overrideComponentParams: ComponentParams? = null,
+ isCreatedByDropIn: Boolean = false,
overrideSessionParams: SessionParams? = null,
private val analyticsRepository: AnalyticsRepository? = null,
) :
@@ -63,23 +64,23 @@ constructor(
GiftCardComponent,
GiftCardConfiguration,
GiftCardComponentState,
- GiftCardComponentCallback
+ GiftCardComponentCallback,
>,
SessionPaymentComponentProvider<
GiftCardComponent,
GiftCardConfiguration,
GiftCardComponentState,
- SessionsGiftCardComponentCallback
+ SessionsGiftCardComponentCallback,
> {
- private val componentParamsMapper = GiftCardComponentParamsMapper(overrideComponentParams, overrideSessionParams)
+ private val componentParamsMapper = GiftCardComponentParamsMapper(isCreatedByDropIn, overrideSessionParams)
override fun get(
savedStateRegistryOwner: SavedStateRegistryOwner,
viewModelStoreOwner: ViewModelStoreOwner,
lifecycleOwner: LifecycleOwner,
paymentMethod: PaymentMethod,
- configuration: GiftCardConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: GiftCardComponentCallback,
order: Order?,
@@ -89,7 +90,7 @@ constructor(
val cardEncryptor = CardEncryptorFactory.provide()
val giftCardFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
- val componentParams = componentParamsMapper.mapToParams(configuration, null)
+ val componentParams = componentParamsMapper.mapToParams(checkoutConfiguration, null)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
val publicKeyService = PublicKeyService(httpClient)
@@ -100,7 +101,7 @@ constructor(
paymentMethod = paymentMethod,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -117,7 +118,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -138,6 +139,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ paymentMethod: PaymentMethod,
+ configuration: GiftCardConfiguration,
+ application: Application,
+ componentCallback: GiftCardComponentCallback,
+ order: Order?,
+ key: String?,
+ ): GiftCardComponent {
+ 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,
@@ -145,7 +170,7 @@ constructor(
lifecycleOwner: LifecycleOwner,
checkoutSession: CheckoutSession,
paymentMethod: PaymentMethod,
- configuration: GiftCardConfiguration,
+ checkoutConfiguration: CheckoutConfiguration,
application: Application,
componentCallback: SessionsGiftCardComponentCallback,
key: String?
@@ -155,8 +180,8 @@ constructor(
val cardEncryptor = CardEncryptorFactory.provide()
val giftCardFactory = viewModelFactory(savedStateRegistryOwner, null) { savedStateHandle ->
val componentParams = componentParamsMapper.mapToParams(
- configuration = configuration,
- sessionParams = SessionParamsFactory.create(checkoutSession)
+ configuration = checkoutConfiguration,
+ sessionParams = SessionParamsFactory.create(checkoutSession),
)
val httpClient = HttpClientFactory.getHttpClient(componentParams.environment)
val publicKeyService = PublicKeyService(httpClient)
@@ -169,7 +194,7 @@ constructor(
sessionId = checkoutSession.sessionSetupResponse.id,
),
analyticsService = AnalyticsService(
- HttpClientFactory.getAnalyticsHttpClient(componentParams.environment)
+ HttpClientFactory.getAnalyticsHttpClient(componentParams.environment),
),
analyticsMapper = AnalyticsMapper(),
)
@@ -186,7 +211,7 @@ constructor(
)
val genericActionDelegate = GenericActionComponentProvider(componentParams).getDelegate(
- configuration = configuration.genericActionConfiguration,
+ checkoutConfiguration = checkoutConfiguration,
savedStateHandle = savedStateHandle,
application = application,
)
@@ -202,7 +227,7 @@ constructor(
clientKey = componentParams.clientKey,
),
sessionModel = sessionSavedStateHandleContainer.getSessionModel(),
- isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false
+ isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false,
)
val sessionsGiftCardComponentEventHandler = SessionsGiftCardComponentEventHandler(
@@ -222,7 +247,7 @@ constructor(
.also { component ->
val internalComponentCallback = SessionsGiftCardComponentCallbackWrapper(
component,
- componentCallback
+ componentCallback,
)
component.observe(lifecycleOwner) {
component.componentEventHandler.onPaymentComponentEvent(it, internalComponentCallback)
@@ -230,6 +255,30 @@ constructor(
}
}
+ override fun get(
+ savedStateRegistryOwner: SavedStateRegistryOwner,
+ viewModelStoreOwner: ViewModelStoreOwner,
+ lifecycleOwner: LifecycleOwner,
+ checkoutSession: CheckoutSession,
+ paymentMethod: PaymentMethod,
+ configuration: GiftCardConfiguration,
+ application: Application,
+ componentCallback: SessionsGiftCardComponentCallback,
+ key: String?
+ ): GiftCardComponent {
+ 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}")
diff --git a/giftcard/src/main/java/com/adyen/checkout/giftcard/internal/ui/model/GiftCardComponentParamsMapper.kt b/giftcard/src/main/java/com/adyen/checkout/giftcard/internal/ui/model/GiftCardComponentParamsMapper.kt
index 15b823a712..0e1d050c2c 100644
--- a/giftcard/src/main/java/com/adyen/checkout/giftcard/internal/ui/model/GiftCardComponentParamsMapper.kt
+++ b/giftcard/src/main/java/com/adyen/checkout/giftcard/internal/ui/model/GiftCardComponentParamsMapper.kt
@@ -8,51 +8,36 @@
package com.adyen.checkout.giftcard.internal.ui.model
-import com.adyen.checkout.components.core.internal.ButtonConfiguration
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParams
-import com.adyen.checkout.components.core.internal.ui.model.ComponentParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
-import com.adyen.checkout.giftcard.GiftCardConfiguration
+import com.adyen.checkout.giftcard.getGiftCardConfiguration
internal class GiftCardComponentParamsMapper(
- private val overrideComponentParams: ComponentParams?,
+ private val isCreatedByDropIn: Boolean,
private val overrideSessionParams: SessionParams?,
) {
fun mapToParams(
- configuration: GiftCardConfiguration,
+ configuration: CheckoutConfiguration,
sessionParams: SessionParams?,
): GiftCardComponentParams {
return configuration
.mapToParamsInternal()
- .override(overrideComponentParams)
.override(sessionParams ?: overrideSessionParams)
}
- private fun GiftCardConfiguration.mapToParamsInternal(): GiftCardComponentParams {
+ private fun CheckoutConfiguration.mapToParamsInternal(): GiftCardComponentParams {
+ val giftCardConfiguration = getGiftCardConfiguration()
return GiftCardComponentParams(
shopperLocale = shopperLocale,
environment = environment,
clientKey = clientKey,
analyticsParams = AnalyticsParams(analyticsConfiguration),
- isCreatedByDropIn = false,
+ isCreatedByDropIn = isCreatedByDropIn,
amount = amount,
- isSubmitButtonVisible = (this as? ButtonConfiguration)?.isSubmitButtonVisible ?: true,
- isPinRequired = isPinRequired ?: true,
- )
- }
-
- private fun GiftCardComponentParams.override(
- overrideComponentParams: ComponentParams?
- ): GiftCardComponentParams {
- if (overrideComponentParams == null) return this
- return copy(
- shopperLocale = overrideComponentParams.shopperLocale,
- environment = overrideComponentParams.environment,
- clientKey = overrideComponentParams.clientKey,
- analyticsParams = overrideComponentParams.analyticsParams,
- isCreatedByDropIn = overrideComponentParams.isCreatedByDropIn,
- amount = overrideComponentParams.amount
+ isSubmitButtonVisible = giftCardConfiguration?.isSubmitButtonVisible ?: true,
+ isPinRequired = giftCardConfiguration?.isPinRequired ?: true,
)
}
From 7bdf83b212281aa63946bbe1a73b01df917710d4 Mon Sep 17 00:00:00 2001
From: Oscar Spruit
Date: Thu, 4 Jan 2024 17:19:15 +0100
Subject: [PATCH 053/255] Make Google Pay accept CheckoutConfiguration
COAND-811
---
.../internal/AlwaysAvailablePaymentMethod.kt | 7 +-
.../internal/NotAvailablePaymentMethod.kt | 7 +-
.../PaymentMethodAvailabilityCheck.kt | 10 +-
.../provider/ComponentParsingProvider.kt | 2 +-
.../provider/ConfigurationParsingProvider.kt | 7 --
.../PaymentMethodAvailabilityProvider.kt | 17 +---
.../ui/PaymentMethodsListViewModel.kt | 1 -
.../googlepay/GooglePayConfiguration.kt | 18 ++++
.../provider/GooglePayComponentProvider.kt | 97 +++++++++++++------
.../model/GooglePayComponentParamsMapper.kt | 76 ++++++---------
.../checkout/wechatpay/WeChatPayProvider.kt | 12 +--
11 files changed, 144 insertions(+), 110 deletions(-)
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/internal/AlwaysAvailablePaymentMethod.kt b/components-core/src/main/java/com/adyen/checkout/components/core/internal/AlwaysAvailablePaymentMethod.kt
index dabb494fcc..7da00421e6 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/internal/AlwaysAvailablePaymentMethod.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/internal/AlwaysAvailablePaymentMethod.kt
@@ -10,16 +10,17 @@ package com.adyen.checkout.components.core.internal
import android.app.Application
import androidx.annotation.RestrictTo
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.ComponentAvailableCallback
import com.adyen.checkout.components.core.PaymentMethod
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
-class AlwaysAvailablePaymentMethod : PaymentMethodAvailabilityCheck {
+class AlwaysAvailablePaymentMethod : PaymentMethodAvailabilityCheck {
override fun isAvailable(
- applicationContext: Application,
+ application: Application,
paymentMethod: PaymentMethod,
- configuration: Configuration?,
+ checkoutConfiguration: CheckoutConfiguration,
callback: ComponentAvailableCallback
) {
callback.onAvailabilityResult(true, paymentMethod)
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/internal/NotAvailablePaymentMethod.kt b/components-core/src/main/java/com/adyen/checkout/components/core/internal/NotAvailablePaymentMethod.kt
index e7e249989c..693532895e 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/internal/NotAvailablePaymentMethod.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/internal/NotAvailablePaymentMethod.kt
@@ -10,16 +10,17 @@ package com.adyen.checkout.components.core.internal
import android.app.Application
import androidx.annotation.RestrictTo
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.ComponentAvailableCallback
import com.adyen.checkout.components.core.PaymentMethod
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
-class NotAvailablePaymentMethod : PaymentMethodAvailabilityCheck {
+class NotAvailablePaymentMethod : PaymentMethodAvailabilityCheck {
override fun isAvailable(
- applicationContext: Application,
+ application: Application,
paymentMethod: PaymentMethod,
- configuration: Configuration?,
+ checkoutConfiguration: CheckoutConfiguration,
callback: ComponentAvailableCallback
) {
callback.onAvailabilityResult(false, paymentMethod)
diff --git a/components-core/src/main/java/com/adyen/checkout/components/core/internal/PaymentMethodAvailabilityCheck.kt b/components-core/src/main/java/com/adyen/checkout/components/core/internal/PaymentMethodAvailabilityCheck.kt
index 285b133a3f..8c082799f1 100644
--- a/components-core/src/main/java/com/adyen/checkout/components/core/internal/PaymentMethodAvailabilityCheck.kt
+++ b/components-core/src/main/java/com/adyen/checkout/components/core/internal/PaymentMethodAvailabilityCheck.kt
@@ -8,20 +8,18 @@
package com.adyen.checkout.components.core.internal
import android.app.Application
+import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.ComponentAvailableCallback
import com.adyen.checkout.components.core.PaymentMethod
/**
* Specifies whether a certain payment method is available for use with the provided parameters.
- *
- * @param ConfigurationT The Configuration for the Component corresponding to this payment method. Simply use
- * [Configuration] if not applicable.
*/
-interface PaymentMethodAvailabilityCheck {
+interface PaymentMethodAvailabilityCheck {
fun isAvailable(
- applicationContext: Application,
+ application: Application,
paymentMethod: PaymentMethod,
- configuration: ConfigurationT?,
+ checkoutConfiguration: CheckoutConfiguration,
callback: ComponentAvailableCallback
)
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
index 942ba632fe..b82dc6ae1a 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ComponentParsingProvider.kt
@@ -367,7 +367,7 @@ internal fun getComponentFor(
checkCompileOnly { GooglePayComponent.PROVIDER.isPaymentMethodSupported(paymentMethod) } -> {
val googlePayConfiguration: GooglePayConfiguration =
getConfigurationForPaymentMethod(paymentMethod, checkoutConfiguration, context)
- GooglePayComponentProvider(dropInParams, sessionParams, analyticsRepository).get(
+ GooglePayComponentProvider(true, sessionParams, analyticsRepository).get(
fragment = fragment,
paymentMethod = paymentMethod,
configuration = googlePayConfiguration,
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt
index e1d0de2fd1..e2f9315195 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/ConfigurationParsingProvider.kt
@@ -348,10 +348,3 @@ internal fun getDefaultConfigForPaymentMethod(
@Suppress("UNCHECKED_CAST")
return builder.build() as T
}
-
-internal inline fun getConfigurationForPaymentMethodOrNull(
- paymentMethod: PaymentMethod,
- checkoutConfiguration: CheckoutConfiguration,
-): T? {
- return checkoutConfiguration.getConfiguration(paymentMethod.type ?: "")
-}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt
index c926bbd1c3..efe311e0b4 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/internal/provider/PaymentMethodAvailabilityProvider.kt
@@ -14,7 +14,6 @@ import com.adyen.checkout.components.core.ComponentAvailableCallback
import com.adyen.checkout.components.core.PaymentMethod
import com.adyen.checkout.components.core.PaymentMethodTypes
import com.adyen.checkout.components.core.internal.AlwaysAvailablePaymentMethod
-import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.components.core.internal.NotAvailablePaymentMethod
import com.adyen.checkout.components.core.internal.PaymentMethodAvailabilityCheck
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
@@ -22,7 +21,6 @@ import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.internal.util.LogUtil
import com.adyen.checkout.core.internal.util.Logger
import com.adyen.checkout.core.internal.util.runCompileOnly
-import com.adyen.checkout.dropin.internal.ui.model.DropInComponentParams
import com.adyen.checkout.googlepay.internal.provider.GooglePayComponentProvider
import com.adyen.checkout.wechatpay.WeChatPayProvider
@@ -33,7 +31,6 @@ internal fun checkPaymentMethodAvailability(
application: Application,
paymentMethod: PaymentMethod,
checkoutConfiguration: CheckoutConfiguration,
- dropInComponentParams: DropInComponentParams,
sessionParams: SessionParams?,
callback: ComponentAvailableCallback,
) {
@@ -42,11 +39,9 @@ internal fun checkPaymentMethodAvailability(
val type = paymentMethod.type ?: throw CheckoutException("PaymentMethod type is null")
- val availabilityCheck = getPaymentMethodAvailabilityCheck(dropInComponentParams, type, sessionParams)
- val configuration =
- getConfigurationForPaymentMethodOrNull(paymentMethod, checkoutConfiguration)
+ val availabilityCheck = getPaymentMethodAvailabilityCheck(type, sessionParams)
- availabilityCheck.isAvailable(application, paymentMethod, configuration, callback)
+ availabilityCheck.isAvailable(application, paymentMethod, checkoutConfiguration, callback)
} catch (e: CheckoutException) {
Logger.e(TAG, "Unable to initiate ${paymentMethod.type}", e)
callback.onAvailabilityResult(false, paymentMethod)
@@ -57,20 +52,18 @@ internal fun checkPaymentMethodAvailability(
* Provides the [PaymentMethodAvailabilityCheck] class for the specified [paymentMethodType], if available.
*/
private fun getPaymentMethodAvailabilityCheck(
- dropInComponentParams: DropInComponentParams,
paymentMethodType: String,
sessionParams: SessionParams?,
-): PaymentMethodAvailabilityCheck