@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.
Files changed (233) hide show
  1. package/android/build.gradle +2 -0
  2. package/android/gradle.properties +1 -1
  3. package/android/src/main/AndroidManifest.xml +27 -1
  4. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +0 -3
  5. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +7 -3
  6. package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +8 -0
  7. package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +12 -1
  8. package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +26 -0
  9. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfig.kt +147 -0
  10. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementView.kt +164 -0
  11. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementViewManager.kt +65 -0
  12. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +1 -1
  13. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +60 -31
  14. package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +17 -5
  15. package/android/src/main/java/com/reactnativestripesdk/StripeConnectDeepLinkInterceptorActivity.kt +77 -0
  16. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +334 -24
  17. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +1 -0
  18. package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +3 -0
  19. package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +8 -0
  20. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +0 -2
  21. package/android/src/main/res/xml/file_paths.xml +4 -0
  22. package/android/src/oldarch/java/com/facebook/react/viewmanagers/PaymentMethodMessagingElementViewManagerDelegate.java +36 -0
  23. package/android/src/oldarch/java/com/facebook/react/viewmanagers/PaymentMethodMessagingElementViewManagerInterface.java +18 -0
  24. package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +20 -0
  25. package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +175 -1
  26. package/android/src/test/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfigTest.kt +543 -0
  27. package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +70 -0
  28. package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +13 -19
  29. package/ios/CustomerSheet/CustomerSheetUtils.swift +4 -0
  30. package/ios/OldArch/StripeSdkEventEmitterCompat.h +2 -0
  31. package/ios/OldArch/StripeSdkEventEmitterCompat.m +13 -1
  32. package/ios/PaymentMethodMessagingElementConfig.swift +116 -0
  33. package/ios/PaymentMethodMessagingElementHandler.m +9 -0
  34. package/ios/PaymentMethodMessagingElementView.swift +139 -0
  35. package/ios/StripeSdk.mm +40 -0
  36. package/ios/StripeSdkEmitter.swift +2 -0
  37. package/ios/StripeSdkImpl+CustomerSheet.swift +1 -0
  38. package/ios/StripeSdkImpl+Embedded.swift +8 -1
  39. package/ios/StripeSdkImpl+PaymentSheet.swift +44 -1
  40. package/ios/StripeSdkImpl.swift +158 -2
  41. package/jest/mock.js +26 -0
  42. package/jest/setup.js +30 -0
  43. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  44. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  45. package/lib/commonjs/components/AddressSheet.js +1 -1
  46. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  47. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  48. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  49. package/lib/commonjs/components/CardField.js +1 -1
  50. package/lib/commonjs/components/CardField.js.map +1 -1
  51. package/lib/commonjs/components/CardForm.js +1 -1
  52. package/lib/commonjs/components/CardForm.js.map +1 -1
  53. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  54. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  55. package/lib/commonjs/components/StripeContainer.js +1 -1
  56. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  57. package/lib/commonjs/connect/Components.js +1 -1
  58. package/lib/commonjs/connect/Components.js.map +1 -1
  59. package/lib/commonjs/connect/ConnectComponentsProvider.js +1 -1
  60. package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -1
  61. package/lib/commonjs/connect/EmbeddedComponent.js +10 -5
  62. package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
  63. package/lib/commonjs/connect/ModalCloseButton.js +1 -1
  64. package/lib/commonjs/connect/ModalCloseButton.js.map +1 -1
  65. package/lib/commonjs/connect/NavigationBar.js +1 -1
  66. package/lib/commonjs/connect/NavigationBar.js.map +1 -1
  67. package/lib/commonjs/connect/analytics/AnalyticsClient.js +2 -0
  68. package/lib/commonjs/connect/analytics/AnalyticsClient.js.map +1 -0
  69. package/lib/commonjs/connect/analytics/ComponentAnalyticsClient.js +2 -0
  70. package/lib/commonjs/connect/analytics/ComponentAnalyticsClient.js.map +1 -0
  71. package/lib/commonjs/connect/analytics/events.js +2 -0
  72. package/lib/commonjs/connect/analytics/events.js.map +1 -0
  73. package/lib/commonjs/connect/testUtils.js +2 -0
  74. package/lib/commonjs/connect/testUtils.js.map +1 -0
  75. package/lib/commonjs/events.js.map +1 -1
  76. package/lib/commonjs/functions.js +1 -1
  77. package/lib/commonjs/functions.js.map +1 -1
  78. package/lib/commonjs/helpers.js +1 -1
  79. package/lib/commonjs/hooks/useStripe.js +1 -1
  80. package/lib/commonjs/hooks/useStripe.js.map +1 -1
  81. package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
  82. package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
  83. package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
  84. package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
  85. package/lib/commonjs/specs/NativeCardField.js +1 -1
  86. package/lib/commonjs/specs/NativeCardField.js.map +1 -1
  87. package/lib/commonjs/specs/NativeCardForm.js +1 -1
  88. package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
  89. package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +1 -1
  90. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
  91. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  92. package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
  93. package/lib/commonjs/specs/NativeNavigationBar.js +1 -1
  94. package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +2 -0
  95. package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js.map +1 -0
  96. package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
  97. package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
  98. package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
  99. package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
  100. package/lib/commonjs/types/Errors.js +1 -1
  101. package/lib/commonjs/types/Errors.js.map +1 -1
  102. package/lib/commonjs/types/FinancialConnections.js.map +1 -1
  103. package/lib/commonjs/types/PaymentSheet.js +1 -1
  104. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  105. package/lib/commonjs/types/components/PaymentMethodMessagingElementComponent.js +2 -0
  106. package/lib/commonjs/types/components/PaymentMethodMessagingElementComponent.js.map +1 -0
  107. package/lib/commonjs/types/index.js.map +1 -1
  108. package/lib/module/components/AddToWalletButton.js +1 -1
  109. package/lib/module/components/AddToWalletButton.js.map +1 -1
  110. package/lib/module/components/AddressSheet.js +1 -1
  111. package/lib/module/components/AddressSheet.js.map +1 -1
  112. package/lib/module/components/AuBECSDebitForm.js +1 -1
  113. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  114. package/lib/module/components/CardField.js +1 -1
  115. package/lib/module/components/CardField.js.map +1 -1
  116. package/lib/module/components/CardForm.js +1 -1
  117. package/lib/module/components/CardForm.js.map +1 -1
  118. package/lib/module/components/PlatformPayButton.js +1 -1
  119. package/lib/module/components/PlatformPayButton.js.map +1 -1
  120. package/lib/module/components/StripeContainer.js +1 -1
  121. package/lib/module/components/StripeContainer.js.map +1 -1
  122. package/lib/module/connect/Components.js +1 -1
  123. package/lib/module/connect/Components.js.map +1 -1
  124. package/lib/module/connect/ConnectComponentsProvider.js +1 -1
  125. package/lib/module/connect/ConnectComponentsProvider.js.map +1 -1
  126. package/lib/module/connect/EmbeddedComponent.js +10 -5
  127. package/lib/module/connect/EmbeddedComponent.js.map +1 -1
  128. package/lib/module/connect/ModalCloseButton.js +1 -1
  129. package/lib/module/connect/ModalCloseButton.js.map +1 -1
  130. package/lib/module/connect/NavigationBar.js +1 -1
  131. package/lib/module/connect/NavigationBar.js.map +1 -1
  132. package/lib/module/connect/analytics/AnalyticsClient.js +2 -0
  133. package/lib/module/connect/analytics/AnalyticsClient.js.map +1 -0
  134. package/lib/module/connect/analytics/ComponentAnalyticsClient.js +2 -0
  135. package/lib/module/connect/analytics/ComponentAnalyticsClient.js.map +1 -0
  136. package/lib/module/connect/analytics/events.js +2 -0
  137. package/lib/module/connect/analytics/events.js.map +1 -0
  138. package/lib/module/connect/testUtils.js +2 -0
  139. package/lib/module/connect/testUtils.js.map +1 -0
  140. package/lib/module/events.js.map +1 -1
  141. package/lib/module/functions.js +1 -1
  142. package/lib/module/functions.js.map +1 -1
  143. package/lib/module/helpers.js +1 -1
  144. package/lib/module/hooks/useStripe.js +1 -1
  145. package/lib/module/hooks/useStripe.js.map +1 -1
  146. package/lib/module/specs/NativeAddToWalletButton.js +1 -1
  147. package/lib/module/specs/NativeAddressSheet.js +1 -1
  148. package/lib/module/specs/NativeApplePayButton.js +1 -1
  149. package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
  150. package/lib/module/specs/NativeCardField.js +1 -1
  151. package/lib/module/specs/NativeCardField.js.map +1 -1
  152. package/lib/module/specs/NativeCardForm.js +1 -1
  153. package/lib/module/specs/NativeCardForm.js.map +1 -1
  154. package/lib/module/specs/NativeConnectAccountOnboardingView.js +1 -1
  155. package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
  156. package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  157. package/lib/module/specs/NativeGooglePayButton.js +1 -1
  158. package/lib/module/specs/NativeNavigationBar.js +1 -1
  159. package/lib/module/specs/NativePaymentMethodMessagingElement.js +2 -0
  160. package/lib/module/specs/NativePaymentMethodMessagingElement.js.map +1 -0
  161. package/lib/module/specs/NativeStripeContainer.js +1 -1
  162. package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
  163. package/lib/module/types/EmbeddedPaymentElement.js +1 -1
  164. package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
  165. package/lib/module/types/Errors.js +1 -1
  166. package/lib/module/types/Errors.js.map +1 -1
  167. package/lib/module/types/FinancialConnections.js.map +1 -1
  168. package/lib/module/types/PaymentSheet.js +1 -1
  169. package/lib/module/types/PaymentSheet.js.map +1 -1
  170. package/lib/module/types/components/PaymentMethodMessagingElementComponent.js +2 -0
  171. package/lib/module/types/components/PaymentMethodMessagingElementComponent.js.map +1 -0
  172. package/lib/module/types/index.js.map +1 -1
  173. package/lib/typescript/src/connect/Components.d.ts +91 -0
  174. package/lib/typescript/src/connect/Components.d.ts.map +1 -1
  175. package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +61 -0
  176. package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -1
  177. package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -1
  178. package/lib/typescript/src/connect/analytics/AnalyticsClient.d.ts +32 -0
  179. package/lib/typescript/src/connect/analytics/AnalyticsClient.d.ts.map +1 -0
  180. package/lib/typescript/src/connect/analytics/ComponentAnalyticsClient.d.ts +94 -0
  181. package/lib/typescript/src/connect/analytics/ComponentAnalyticsClient.d.ts.map +1 -0
  182. package/lib/typescript/src/connect/analytics/events.d.ts +215 -0
  183. package/lib/typescript/src/connect/analytics/events.d.ts.map +1 -0
  184. package/lib/typescript/src/connect/connectTypes.d.ts +5 -1
  185. package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -1
  186. package/lib/typescript/src/connect/testUtils.d.ts +45 -0
  187. package/lib/typescript/src/connect/testUtils.d.ts.map +1 -0
  188. package/lib/typescript/src/events.d.ts +2 -0
  189. package/lib/typescript/src/events.d.ts.map +1 -1
  190. package/lib/typescript/src/functions.d.ts +13 -1
  191. package/lib/typescript/src/functions.d.ts.map +1 -1
  192. package/lib/typescript/src/hooks/useStripe.d.ts +2 -1
  193. package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -1
  194. package/lib/typescript/src/specs/NativePaymentMethodMessagingElement.d.ts +16 -0
  195. package/lib/typescript/src/specs/NativePaymentMethodMessagingElement.d.ts.map +1 -0
  196. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +16 -1
  197. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
  198. package/lib/typescript/src/types/CustomerSheet.d.ts +5 -0
  199. package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -1
  200. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +11 -1
  201. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
  202. package/lib/typescript/src/types/Errors.d.ts +4 -0
  203. package/lib/typescript/src/types/Errors.d.ts.map +1 -1
  204. package/lib/typescript/src/types/FinancialConnections.d.ts +2 -0
  205. package/lib/typescript/src/types/FinancialConnections.d.ts.map +1 -1
  206. package/lib/typescript/src/types/PaymentSheet.d.ts +35 -0
  207. package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
  208. package/lib/typescript/src/types/components/PaymentMethodMessagingElementComponent.d.ts +69 -0
  209. package/lib/typescript/src/types/components/PaymentMethodMessagingElementComponent.d.ts.map +1 -0
  210. package/lib/typescript/src/types/index.d.ts +8 -1
  211. package/lib/typescript/src/types/index.d.ts.map +1 -1
  212. package/package.json +4 -1
  213. package/src/connect/Components.tsx +109 -11
  214. package/src/connect/ConnectComponentsProvider.tsx +69 -2
  215. package/src/connect/EmbeddedComponent.tsx +458 -23
  216. package/src/connect/analytics/AnalyticsClient.ts +75 -0
  217. package/src/connect/analytics/ComponentAnalyticsClient.ts +315 -0
  218. package/src/connect/analytics/events.ts +253 -0
  219. package/src/connect/connectTypes.ts +5 -1
  220. package/src/connect/testUtils.ts +37 -0
  221. package/src/events.ts +2 -0
  222. package/src/functions.ts +10 -0
  223. package/src/hooks/useStripe.tsx +8 -0
  224. package/src/specs/NativePaymentMethodMessagingElement.ts +25 -0
  225. package/src/specs/NativeStripeSdkModule.ts +21 -1
  226. package/src/types/CustomerSheet.ts +5 -0
  227. package/src/types/EmbeddedPaymentElement.tsx +11 -1
  228. package/src/types/Errors.ts +5 -0
  229. package/src/types/FinancialConnections.ts +2 -0
  230. package/src/types/PaymentSheet.ts +38 -1
  231. package/src/types/components/PaymentMethodMessagingElementComponent.tsx +74 -0
  232. package/src/types/index.ts +11 -0
  233. 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
  }