@stripe/stripe-react-native 0.57.3 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +2 -0
- package/android/gradle.properties +1 -1
- package/android/src/main/AndroidManifest.xml +27 -1
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +0 -3
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +7 -3
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +8 -0
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +12 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +26 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfig.kt +147 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementView.kt +164 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementViewManager.kt +65 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +60 -31
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +17 -5
- package/android/src/main/java/com/reactnativestripesdk/StripeConnectDeepLinkInterceptorActivity.kt +77 -0
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +334 -24
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +3 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +8 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +0 -2
- package/android/src/main/res/xml/file_paths.xml +4 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/PaymentMethodMessagingElementViewManagerDelegate.java +36 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/PaymentMethodMessagingElementViewManagerInterface.java +18 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +20 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +175 -1
- package/android/src/test/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfigTest.kt +543 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +70 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +13 -19
- package/ios/CustomerSheet/CustomerSheetUtils.swift +4 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +2 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +13 -1
- package/ios/PaymentMethodMessagingElementConfig.swift +116 -0
- package/ios/PaymentMethodMessagingElementHandler.m +9 -0
- package/ios/PaymentMethodMessagingElementView.swift +139 -0
- package/ios/StripeSdk.mm +40 -0
- package/ios/StripeSdkEmitter.swift +2 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +1 -0
- package/ios/StripeSdkImpl+Embedded.swift +8 -1
- package/ios/StripeSdkImpl+PaymentSheet.swift +44 -1
- package/ios/StripeSdkImpl.swift +158 -2
- package/jest/mock.js +26 -0
- package/jest/setup.js +30 -0
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/connect/Components.js +1 -1
- package/lib/commonjs/connect/Components.js.map +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/commonjs/connect/EmbeddedComponent.js +10 -5
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -1
- package/lib/commonjs/connect/NavigationBar.js +1 -1
- package/lib/commonjs/connect/NavigationBar.js.map +1 -1
- package/lib/commonjs/connect/analytics/AnalyticsClient.js +2 -0
- package/lib/commonjs/connect/analytics/AnalyticsClient.js.map +1 -0
- package/lib/commonjs/connect/analytics/ComponentAnalyticsClient.js +2 -0
- package/lib/commonjs/connect/analytics/ComponentAnalyticsClient.js.map +1 -0
- package/lib/commonjs/connect/analytics/events.js +2 -0
- package/lib/commonjs/connect/analytics/events.js.map +1 -0
- package/lib/commonjs/connect/testUtils.js +2 -0
- package/lib/commonjs/connect/testUtils.js.map +1 -0
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/hooks/useStripe.js +1 -1
- package/lib/commonjs/hooks/useStripe.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +1 -1
- package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +2 -0
- package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/FinancialConnections.js.map +1 -1
- package/lib/commonjs/types/PaymentSheet.js +1 -1
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/components/PaymentMethodMessagingElementComponent.js +2 -0
- package/lib/commonjs/types/components/PaymentMethodMessagingElementComponent.js.map +1 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/connect/Components.js +1 -1
- package/lib/module/connect/Components.js.map +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/module/connect/EmbeddedComponent.js +10 -5
- package/lib/module/connect/EmbeddedComponent.js.map +1 -1
- package/lib/module/connect/ModalCloseButton.js +1 -1
- package/lib/module/connect/ModalCloseButton.js.map +1 -1
- package/lib/module/connect/NavigationBar.js +1 -1
- package/lib/module/connect/NavigationBar.js.map +1 -1
- package/lib/module/connect/analytics/AnalyticsClient.js +2 -0
- package/lib/module/connect/analytics/AnalyticsClient.js.map +1 -0
- package/lib/module/connect/analytics/ComponentAnalyticsClient.js +2 -0
- package/lib/module/connect/analytics/ComponentAnalyticsClient.js.map +1 -0
- package/lib/module/connect/analytics/events.js +2 -0
- package/lib/module/connect/analytics/events.js.map +1 -0
- package/lib/module/connect/testUtils.js +2 -0
- package/lib/module/connect/testUtils.js.map +1 -0
- package/lib/module/events.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/hooks/useStripe.js +1 -1
- package/lib/module/hooks/useStripe.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeNavigationBar.js +1 -1
- package/lib/module/specs/NativePaymentMethodMessagingElement.js +2 -0
- package/lib/module/specs/NativePaymentMethodMessagingElement.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/FinancialConnections.js.map +1 -1
- package/lib/module/types/PaymentSheet.js +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/components/PaymentMethodMessagingElementComponent.js +2 -0
- package/lib/module/types/components/PaymentMethodMessagingElementComponent.js.map +1 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/connect/Components.d.ts +91 -0
- package/lib/typescript/src/connect/Components.d.ts.map +1 -1
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +61 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -1
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -1
- package/lib/typescript/src/connect/analytics/AnalyticsClient.d.ts +32 -0
- package/lib/typescript/src/connect/analytics/AnalyticsClient.d.ts.map +1 -0
- package/lib/typescript/src/connect/analytics/ComponentAnalyticsClient.d.ts +94 -0
- package/lib/typescript/src/connect/analytics/ComponentAnalyticsClient.d.ts.map +1 -0
- package/lib/typescript/src/connect/analytics/events.d.ts +215 -0
- package/lib/typescript/src/connect/analytics/events.d.ts.map +1 -0
- package/lib/typescript/src/connect/connectTypes.d.ts +5 -1
- package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -1
- package/lib/typescript/src/connect/testUtils.d.ts +45 -0
- package/lib/typescript/src/connect/testUtils.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +2 -0
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts +13 -1
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useStripe.d.ts +2 -1
- package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePaymentMethodMessagingElement.d.ts +16 -0
- package/lib/typescript/src/specs/NativePaymentMethodMessagingElement.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +16 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/CustomerSheet.d.ts +5 -0
- package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +11 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/types/Errors.d.ts +4 -0
- package/lib/typescript/src/types/Errors.d.ts.map +1 -1
- package/lib/typescript/src/types/FinancialConnections.d.ts +2 -0
- package/lib/typescript/src/types/FinancialConnections.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentSheet.d.ts +35 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/components/PaymentMethodMessagingElementComponent.d.ts +69 -0
- package/lib/typescript/src/types/components/PaymentMethodMessagingElementComponent.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +8 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +4 -1
- package/src/connect/Components.tsx +109 -11
- package/src/connect/ConnectComponentsProvider.tsx +69 -2
- package/src/connect/EmbeddedComponent.tsx +458 -23
- package/src/connect/analytics/AnalyticsClient.ts +75 -0
- package/src/connect/analytics/ComponentAnalyticsClient.ts +315 -0
- package/src/connect/analytics/events.ts +253 -0
- package/src/connect/connectTypes.ts +5 -1
- package/src/connect/testUtils.ts +37 -0
- package/src/events.ts +2 -0
- package/src/functions.ts +10 -0
- package/src/hooks/useStripe.tsx +8 -0
- package/src/specs/NativePaymentMethodMessagingElement.ts +25 -0
- package/src/specs/NativeStripeSdkModule.ts +21 -1
- package/src/types/CustomerSheet.ts +5 -0
- package/src/types/EmbeddedPaymentElement.tsx +11 -1
- package/src/types/Errors.ts +5 -0
- package/src/types/FinancialConnections.ts +2 -0
- package/src/types/PaymentSheet.ts +38 -1
- package/src/types/components/PaymentMethodMessagingElementComponent.tsx +74 -0
- package/src/types/index.ts +11 -0
- package/stripe-react-native.podspec +1 -1
|
@@ -3,17 +3,20 @@ package com.reactnativestripesdk
|
|
|
3
3
|
import com.reactnativestripesdk.utils.PaymentSheetException
|
|
4
4
|
import com.reactnativestripesdk.utils.readableArrayOf
|
|
5
5
|
import com.reactnativestripesdk.utils.readableMapOf
|
|
6
|
+
import com.stripe.android.model.PaymentMethod
|
|
6
7
|
import com.stripe.android.paymentelement.PaymentMethodOptionsSetupFutureUsagePreview
|
|
8
|
+
import com.stripe.android.paymentsheet.CardFundingFilteringPrivatePreview
|
|
7
9
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
8
10
|
import org.junit.Assert.assertEquals
|
|
9
11
|
import org.junit.Assert.assertNotNull
|
|
10
12
|
import org.junit.Assert.assertNull
|
|
13
|
+
import org.junit.Assert.assertTrue
|
|
11
14
|
import org.junit.Test
|
|
12
15
|
import org.junit.runner.RunWith
|
|
13
16
|
import org.robolectric.RobolectricTestRunner
|
|
14
17
|
|
|
15
18
|
@RunWith(RobolectricTestRunner::class)
|
|
16
|
-
@OptIn(PaymentMethodOptionsSetupFutureUsagePreview::class)
|
|
19
|
+
@OptIn(PaymentMethodOptionsSetupFutureUsagePreview::class, CardFundingFilteringPrivatePreview::class)
|
|
17
20
|
class PaymentElementConfigTest {
|
|
18
21
|
// ============================================
|
|
19
22
|
// buildIntentConfiguration Tests
|
|
@@ -973,4 +976,175 @@ class PaymentElementConfigTest {
|
|
|
973
976
|
val result = buildBillingDetailsCollectionConfiguration(params)
|
|
974
977
|
assertNotNull(result)
|
|
975
978
|
}
|
|
979
|
+
|
|
980
|
+
// ============================================
|
|
981
|
+
// mapToAllowedCardFundingTypes Tests
|
|
982
|
+
// ============================================
|
|
983
|
+
|
|
984
|
+
@Test
|
|
985
|
+
fun mapToAllowedCardFundingTypes_NullParams_ReturnsNull() {
|
|
986
|
+
val result = mapToAllowedCardFundingTypes(null)
|
|
987
|
+
assertNull(result)
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
@Test
|
|
991
|
+
fun mapToAllowedCardFundingTypes_NoCardFundingFiltering_ReturnsNull() {
|
|
992
|
+
val params =
|
|
993
|
+
readableMapOf(
|
|
994
|
+
"someOtherKey" to "value",
|
|
995
|
+
)
|
|
996
|
+
val result = mapToAllowedCardFundingTypes(params)
|
|
997
|
+
assertNull(result)
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
@Test
|
|
1001
|
+
fun mapToAllowedCardFundingTypes_DebitOnly_ReturnsList() {
|
|
1002
|
+
val params =
|
|
1003
|
+
readableMapOf(
|
|
1004
|
+
"cardFundingFiltering" to
|
|
1005
|
+
readableMapOf(
|
|
1006
|
+
"allowedCardFundingTypes" to readableArrayOf("debit"),
|
|
1007
|
+
),
|
|
1008
|
+
)
|
|
1009
|
+
val result = mapToAllowedCardFundingTypes(params)
|
|
1010
|
+
assertNotNull(result)
|
|
1011
|
+
assertEquals(1, result?.size)
|
|
1012
|
+
assertEquals(PaymentSheet.CardFundingType.Debit, result?.get(0))
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
@Test
|
|
1016
|
+
fun mapToAllowedCardFundingTypes_CreditOnly_ReturnsList() {
|
|
1017
|
+
val params =
|
|
1018
|
+
readableMapOf(
|
|
1019
|
+
"cardFundingFiltering" to
|
|
1020
|
+
readableMapOf(
|
|
1021
|
+
"allowedCardFundingTypes" to readableArrayOf("credit"),
|
|
1022
|
+
),
|
|
1023
|
+
)
|
|
1024
|
+
val result = mapToAllowedCardFundingTypes(params)
|
|
1025
|
+
assertNotNull(result)
|
|
1026
|
+
assertEquals(1, result?.size)
|
|
1027
|
+
assertEquals(PaymentSheet.CardFundingType.Credit, result?.get(0))
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
@Test
|
|
1031
|
+
fun mapToAllowedCardFundingTypes_MultipleTypes_ReturnsList() {
|
|
1032
|
+
val params =
|
|
1033
|
+
readableMapOf(
|
|
1034
|
+
"cardFundingFiltering" to
|
|
1035
|
+
readableMapOf(
|
|
1036
|
+
"allowedCardFundingTypes" to readableArrayOf("debit", "credit", "prepaid"),
|
|
1037
|
+
),
|
|
1038
|
+
)
|
|
1039
|
+
val result = mapToAllowedCardFundingTypes(params)
|
|
1040
|
+
assertNotNull(result)
|
|
1041
|
+
assertEquals(3, result?.size)
|
|
1042
|
+
assertTrue(result!!.contains(PaymentSheet.CardFundingType.Debit))
|
|
1043
|
+
assertTrue(result.contains(PaymentSheet.CardFundingType.Credit))
|
|
1044
|
+
assertTrue(result.contains(PaymentSheet.CardFundingType.Prepaid))
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
@Test
|
|
1048
|
+
fun mapToAllowedCardFundingTypes_AllFourTypes_ReturnsList() {
|
|
1049
|
+
val params =
|
|
1050
|
+
readableMapOf(
|
|
1051
|
+
"cardFundingFiltering" to
|
|
1052
|
+
readableMapOf(
|
|
1053
|
+
"allowedCardFundingTypes" to readableArrayOf("debit", "credit", "prepaid", "unknown"),
|
|
1054
|
+
),
|
|
1055
|
+
)
|
|
1056
|
+
val result = mapToAllowedCardFundingTypes(params)
|
|
1057
|
+
assertNotNull(result)
|
|
1058
|
+
assertEquals(4, result?.size)
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
@Test
|
|
1062
|
+
fun mapToAllowedCardFundingTypes_EmptyArray_ReturnsNull() {
|
|
1063
|
+
val params =
|
|
1064
|
+
readableMapOf(
|
|
1065
|
+
"cardFundingFiltering" to
|
|
1066
|
+
readableMapOf(
|
|
1067
|
+
"allowedCardFundingTypes" to readableArrayOf(),
|
|
1068
|
+
),
|
|
1069
|
+
)
|
|
1070
|
+
val result = mapToAllowedCardFundingTypes(params)
|
|
1071
|
+
assertNull(result)
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
@Test
|
|
1075
|
+
fun mapToAllowedCardFundingTypes_InvalidTypes_Filtered() {
|
|
1076
|
+
val params =
|
|
1077
|
+
readableMapOf(
|
|
1078
|
+
"cardFundingFiltering" to
|
|
1079
|
+
readableMapOf(
|
|
1080
|
+
"allowedCardFundingTypes" to readableArrayOf("invalid", "debit", "not_a_type"),
|
|
1081
|
+
),
|
|
1082
|
+
)
|
|
1083
|
+
val result = mapToAllowedCardFundingTypes(params)
|
|
1084
|
+
assertNotNull(result)
|
|
1085
|
+
assertEquals(1, result?.size)
|
|
1086
|
+
assertEquals(PaymentSheet.CardFundingType.Debit, result?.get(0))
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
@Test
|
|
1090
|
+
fun mapToAllowedCardFundingTypes_OnlyInvalidTypes_ReturnsNull() {
|
|
1091
|
+
val params =
|
|
1092
|
+
readableMapOf(
|
|
1093
|
+
"cardFundingFiltering" to
|
|
1094
|
+
readableMapOf(
|
|
1095
|
+
"allowedCardFundingTypes" to readableArrayOf("invalid", "not_valid"),
|
|
1096
|
+
),
|
|
1097
|
+
)
|
|
1098
|
+
val result = mapToAllowedCardFundingTypes(params)
|
|
1099
|
+
assertNull(result)
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
// ============================================
|
|
1103
|
+
// computeTermsDisplayForUserKey Tests
|
|
1104
|
+
// ============================================
|
|
1105
|
+
|
|
1106
|
+
@Test
|
|
1107
|
+
fun computeTermsDisplayForUserKey_UserKey_ReturnsCardNever() {
|
|
1108
|
+
val result = computeTermsDisplayForUserKey("uk_test_123")
|
|
1109
|
+
assertEquals(1, result.size)
|
|
1110
|
+
assertEquals(PaymentSheet.TermsDisplay.NEVER, result[PaymentMethod.Type.Card])
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
@Test
|
|
1114
|
+
fun computeTermsDisplayForUserKey_LiveUserKey_ReturnsCardNever() {
|
|
1115
|
+
val result = computeTermsDisplayForUserKey("uk_live_456")
|
|
1116
|
+
assertEquals(1, result.size)
|
|
1117
|
+
assertEquals(PaymentSheet.TermsDisplay.NEVER, result[PaymentMethod.Type.Card])
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
@Test
|
|
1121
|
+
fun computeTermsDisplayForUserKey_PublishableKey_ReturnsEmpty() {
|
|
1122
|
+
val result = computeTermsDisplayForUserKey("pk_test_123")
|
|
1123
|
+
assertTrue(result.isEmpty())
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
@Test
|
|
1127
|
+
fun computeTermsDisplayForUserKey_LivePublishableKey_ReturnsEmpty() {
|
|
1128
|
+
val result = computeTermsDisplayForUserKey("pk_live_456")
|
|
1129
|
+
assertTrue(result.isEmpty())
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
@Test
|
|
1133
|
+
fun computeTermsDisplayForUserKey_EmptyKey_ReturnsEmpty() {
|
|
1134
|
+
val result = computeTermsDisplayForUserKey("")
|
|
1135
|
+
assertTrue(result.isEmpty())
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
@Test
|
|
1139
|
+
fun mapToAllowedCardFundingTypes_MissingAllowedCardFundingTypes_ReturnsNull() {
|
|
1140
|
+
val params =
|
|
1141
|
+
readableMapOf(
|
|
1142
|
+
"cardFundingFiltering" to
|
|
1143
|
+
readableMapOf(
|
|
1144
|
+
"someOtherKey" to "value",
|
|
1145
|
+
),
|
|
1146
|
+
)
|
|
1147
|
+
val result = mapToAllowedCardFundingTypes(params)
|
|
1148
|
+
assertNull(result)
|
|
1149
|
+
}
|
|
976
1150
|
}
|