@stripe/stripe-react-native 0.62.0 → 0.64.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 (184) hide show
  1. package/android/gradle.properties +1 -1
  2. package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -0
  3. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +22 -0
  4. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +6 -0
  5. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +5 -5
  6. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +2 -0
  7. package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +8 -11
  8. package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +47 -0
  9. package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +21 -2
  10. package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +33 -0
  11. package/android/src/test/java/com/reactnativestripesdk/mappers/OnrampMappersTest.kt +301 -0
  12. package/ios/AddressSheet/AddressSheetUtils.swift +23 -0
  13. package/ios/AddressSheet/AddressSheetView.swift +9 -14
  14. package/ios/Mappers.swift +74 -0
  15. package/ios/PaymentMethodFactory.swift +19 -0
  16. package/ios/StripeOnrampSdk.h +3 -4
  17. package/ios/StripeSdk-Bridging-Header.h +1 -0
  18. package/ios/StripeSdk.mm +1 -1
  19. package/ios/StripeSdkImpl.swift +38 -10
  20. package/ios/StripeSwiftInterop.h +1 -0
  21. package/jest/mock.js +2 -0
  22. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  23. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  24. package/lib/commonjs/components/AddressSheet.js +1 -1
  25. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  26. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  27. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  28. package/lib/commonjs/components/CardField.js +1 -1
  29. package/lib/commonjs/components/CardField.js.map +1 -1
  30. package/lib/commonjs/components/CardForm.js +1 -1
  31. package/lib/commonjs/components/CardForm.js.map +1 -1
  32. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  33. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  34. package/lib/commonjs/components/StripeContainer.js +1 -1
  35. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  36. package/lib/commonjs/components/StripeProvider.js +1 -1
  37. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  38. package/lib/commonjs/connect/Components.js +1 -1
  39. package/lib/commonjs/connect/Components.js.map +1 -1
  40. package/lib/commonjs/connect/ConnectComponentsProvider.js +1 -1
  41. package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -1
  42. package/lib/commonjs/connect/EmbeddedComponent.js +1 -1
  43. package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
  44. package/lib/commonjs/connect/ModalCloseButton.js +1 -1
  45. package/lib/commonjs/connect/ModalCloseButton.js.map +1 -1
  46. package/lib/commonjs/connect/NavigationBar.js +1 -1
  47. package/lib/commonjs/connect/NavigationBar.js.map +1 -1
  48. package/lib/commonjs/connect/testUtils.js +1 -1
  49. package/lib/commonjs/connect/testUtils.js.map +1 -1
  50. package/lib/commonjs/events.js +1 -1
  51. package/lib/commonjs/events.js.map +1 -1
  52. package/lib/commonjs/functions.js +1 -1
  53. package/lib/commonjs/functions.js.map +1 -1
  54. package/lib/commonjs/helpers.js +1 -1
  55. package/lib/commonjs/hooks/useOnramp.js +1 -1
  56. package/lib/commonjs/hooks/useOnramp.js.map +1 -1
  57. package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
  58. package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
  59. package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
  60. package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
  61. package/lib/commonjs/specs/NativeCardField.js +1 -1
  62. package/lib/commonjs/specs/NativeCardField.js.map +1 -1
  63. package/lib/commonjs/specs/NativeCardForm.js +1 -1
  64. package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
  65. package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +1 -1
  66. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
  67. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  68. package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
  69. package/lib/commonjs/specs/NativeNavigationBar.js +1 -1
  70. package/lib/commonjs/specs/NativeOnrampSdkModule.js +1 -1
  71. package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -1
  72. package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +1 -1
  73. package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
  74. package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
  75. package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
  76. package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
  77. package/lib/commonjs/types/Onramp.js.map +1 -1
  78. package/lib/commonjs/types/PaymentIntent.js.map +1 -1
  79. package/lib/module/components/AddToWalletButton.js +1 -1
  80. package/lib/module/components/AddToWalletButton.js.map +1 -1
  81. package/lib/module/components/AddressSheet.js +1 -1
  82. package/lib/module/components/AddressSheet.js.map +1 -1
  83. package/lib/module/components/AuBECSDebitForm.js +1 -1
  84. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  85. package/lib/module/components/CardField.js +1 -1
  86. package/lib/module/components/CardField.js.map +1 -1
  87. package/lib/module/components/CardForm.js +1 -1
  88. package/lib/module/components/CardForm.js.map +1 -1
  89. package/lib/module/components/PlatformPayButton.js +1 -1
  90. package/lib/module/components/PlatformPayButton.js.map +1 -1
  91. package/lib/module/components/StripeContainer.js +1 -1
  92. package/lib/module/components/StripeContainer.js.map +1 -1
  93. package/lib/module/components/StripeProvider.js +1 -1
  94. package/lib/module/components/StripeProvider.js.map +1 -1
  95. package/lib/module/connect/Components.js +1 -1
  96. package/lib/module/connect/Components.js.map +1 -1
  97. package/lib/module/connect/ConnectComponentsProvider.js +1 -1
  98. package/lib/module/connect/ConnectComponentsProvider.js.map +1 -1
  99. package/lib/module/connect/EmbeddedComponent.js +1 -1
  100. package/lib/module/connect/EmbeddedComponent.js.map +1 -1
  101. package/lib/module/connect/ModalCloseButton.js +1 -1
  102. package/lib/module/connect/ModalCloseButton.js.map +1 -1
  103. package/lib/module/connect/NavigationBar.js +1 -1
  104. package/lib/module/connect/NavigationBar.js.map +1 -1
  105. package/lib/module/connect/testUtils.js +1 -1
  106. package/lib/module/connect/testUtils.js.map +1 -1
  107. package/lib/module/events.js +1 -1
  108. package/lib/module/events.js.map +1 -1
  109. package/lib/module/functions.js +1 -1
  110. package/lib/module/functions.js.map +1 -1
  111. package/lib/module/helpers.js +1 -1
  112. package/lib/module/hooks/useOnramp.js +1 -1
  113. package/lib/module/hooks/useOnramp.js.map +1 -1
  114. package/lib/module/specs/NativeAddToWalletButton.js +1 -1
  115. package/lib/module/specs/NativeAddressSheet.js +1 -1
  116. package/lib/module/specs/NativeApplePayButton.js +1 -1
  117. package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
  118. package/lib/module/specs/NativeCardField.js +1 -1
  119. package/lib/module/specs/NativeCardField.js.map +1 -1
  120. package/lib/module/specs/NativeCardForm.js +1 -1
  121. package/lib/module/specs/NativeCardForm.js.map +1 -1
  122. package/lib/module/specs/NativeConnectAccountOnboardingView.js +1 -1
  123. package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
  124. package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  125. package/lib/module/specs/NativeGooglePayButton.js +1 -1
  126. package/lib/module/specs/NativeNavigationBar.js +1 -1
  127. package/lib/module/specs/NativeOnrampSdkModule.js +1 -1
  128. package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -1
  129. package/lib/module/specs/NativePaymentMethodMessagingElement.js +1 -1
  130. package/lib/module/specs/NativeStripeContainer.js +1 -1
  131. package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
  132. package/lib/module/types/EmbeddedPaymentElement.js +1 -1
  133. package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
  134. package/lib/module/types/Onramp.js.map +1 -1
  135. package/lib/module/types/PaymentIntent.js.map +1 -1
  136. package/lib/typescript/src/connect/connectTypes.d.ts +76 -0
  137. package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -1
  138. package/lib/typescript/src/connect/testUtils.d.ts +4 -0
  139. package/lib/typescript/src/connect/testUtils.d.ts.map +1 -1
  140. package/lib/typescript/src/events.d.ts +5 -3
  141. package/lib/typescript/src/events.d.ts.map +1 -1
  142. package/lib/typescript/src/functions.d.ts +2 -0
  143. package/lib/typescript/src/functions.d.ts.map +1 -1
  144. package/lib/typescript/src/hooks/useOnramp.d.ts +8 -3
  145. package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -1
  146. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +3 -3
  147. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -1
  148. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -1
  149. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
  150. package/lib/typescript/src/types/NextAction.d.ts +8 -1
  151. package/lib/typescript/src/types/NextAction.d.ts.map +1 -1
  152. package/lib/typescript/src/types/Onramp.d.ts +40 -1
  153. package/lib/typescript/src/types/Onramp.d.ts.map +1 -1
  154. package/lib/typescript/src/types/PaymentIntent.d.ts +11 -1
  155. package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
  156. package/lib/typescript/src/types/PaymentMethod.d.ts +10 -2
  157. package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -1
  158. package/package.json +1 -1
  159. package/src/components/StripeProvider.tsx +1 -1
  160. package/src/connect/connectTypes.ts +88 -0
  161. package/src/connect/testUtils.ts +2 -0
  162. package/src/events.ts +14 -11
  163. package/src/functions.ts +1 -1
  164. package/src/hooks/useOnramp.tsx +38 -23
  165. package/src/specs/NativeOnrampSdkModule.ts +3 -3
  166. package/src/specs/NativeStripeSdkModule.ts +3 -1
  167. package/src/types/NextAction.ts +9 -0
  168. package/src/types/Onramp.ts +45 -1
  169. package/src/types/PaymentIntent.ts +10 -0
  170. package/src/types/PaymentMethod.ts +9 -0
  171. package/stripe-react-native.podspec +1 -1
  172. package/android/.idea/.name +0 -1
  173. package/android/.idea/AndroidProjectSystem.xml +0 -6
  174. package/android/.idea/android.iml +0 -9
  175. package/android/.idea/caches/deviceStreaming.xml +0 -1550
  176. package/android/.idea/compiler.xml +0 -6
  177. package/android/.idea/gradle.xml +0 -19
  178. package/android/.idea/kotlinc.xml +0 -7
  179. package/android/.idea/migrations.xml +0 -10
  180. package/android/.idea/misc.xml +0 -10
  181. package/android/.idea/runConfigurations.xml +0 -17
  182. package/android/.idea/vcs.xml +0 -6
  183. package/android/local.properties +0 -8
  184. package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +0 -149
@@ -3,4 +3,4 @@ StripeSdk_compileSdkVersion=30
3
3
  StripeSdk_targetSdkVersion=28
4
4
  StripeSdk_minSdkVersion=21
5
5
  # Keep StripeSdk_stripeVersion in sync with https://github.com/stripe/stripe-identity-react-native/blob/main/android/gradle.properties
6
- StripeSdk_stripeVersion=23.2.+
6
+ StripeSdk_stripeVersion=23.4.+
@@ -99,4 +99,8 @@ class EventEmitterCompat(
99
99
  fun emitPaymentMethodMessagingElementConfigureResult(value: ReadableMap?) {
100
100
  invoke("paymentMethodMessagingElementConfigureResult", value)
101
101
  }
102
+
103
+ fun emitOnCheckoutClientSecretRequested(value: ReadableMap?) {
104
+ invoke("onCheckoutClientSecretRequested", value)
105
+ }
102
106
  }
@@ -42,6 +42,7 @@ class PaymentMethodCreateParamsFactory(
42
42
  PaymentMethod.Type.Bancontact -> createBancontactParams()
43
43
  PaymentMethod.Type.Billie -> createBillieParams()
44
44
  PaymentMethod.Type.SepaDebit -> createSepaParams()
45
+ PaymentMethod.Type.Multibanco -> createMultibancoParams()
45
46
  PaymentMethod.Type.Oxxo -> createOXXOParams()
46
47
  PaymentMethod.Type.Eps -> createEPSParams()
47
48
  PaymentMethod.Type.GrabPay -> createGrabPayParams()
@@ -131,6 +132,26 @@ class PaymentMethodCreateParamsFactory(
131
132
  throw PaymentMethodCreateParamsException("You must provide billing details")
132
133
  }
133
134
 
135
+ @Throws(PaymentMethodCreateParamsException::class)
136
+ private fun createMultibancoParams(): PaymentMethodCreateParams {
137
+ billingDetailsParams?.let {
138
+ if (it.email.isNullOrBlank()) {
139
+ throw PaymentMethodCreateParamsException(
140
+ "When creating a Multibanco payment method, you must provide the following billing details: email",
141
+ )
142
+ }
143
+
144
+ return PaymentMethodCreateParams.createMultibanco(
145
+ billingDetails = it,
146
+ metadata = metadataParams,
147
+ )
148
+ }
149
+
150
+ throw PaymentMethodCreateParamsException(
151
+ "When creating a Multibanco payment method, you must provide the following billing details: email",
152
+ )
153
+ }
154
+
134
155
  @Throws(PaymentMethodCreateParamsException::class)
135
156
  private fun createEPSParams(): PaymentMethodCreateParams {
136
157
  billingDetailsParams?.let {
@@ -255,6 +276,7 @@ class PaymentMethodCreateParamsFactory(
255
276
  PaymentMethod.Type.Bancontact,
256
277
  PaymentMethod.Type.Billie,
257
278
  PaymentMethod.Type.SepaDebit,
279
+ PaymentMethod.Type.Multibanco,
258
280
  PaymentMethod.Type.Oxxo,
259
281
  PaymentMethod.Type.Eps,
260
282
  PaymentMethod.Type.GrabPay,
@@ -25,6 +25,7 @@ import com.facebook.react.bridge.UiThreadUtil
25
25
  import com.facebook.react.bridge.WritableMap
26
26
  import com.facebook.react.bridge.WritableNativeMap
27
27
  import com.facebook.react.module.annotations.ReactModule
28
+ import com.facebook.react.modules.systeminfo.ReactNativeVersion
28
29
  import com.reactnativestripesdk.addresssheet.AddressLauncherManager
29
30
  import com.reactnativestripesdk.customersheet.CustomerSheetManager
30
31
  import com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy
@@ -213,6 +214,11 @@ class StripeSdkModule(
213
214
  ).toString()
214
215
  ),
215
216
  "appVersion" to (packageInfo?.versionName ?: ""),
217
+ "isNewArchitecture" to BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
218
+ "reactNativeVersion" to
219
+ with(ReactNativeVersion.VERSION) {
220
+ "${get("major")}.${get("minor")}.${get("patch")}"
221
+ },
216
222
  ),
217
223
  )
218
224
  }
@@ -20,7 +20,7 @@ class StripeSdkPackage : BaseReactPackage() {
20
20
  when (name) {
21
21
  StripeSdkModule.NAME -> StripeSdkModule(reactContext)
22
22
  NativeOnrampSdkModuleSpec.NAME -> {
23
- val onrampModuleClass = getOnrampModuleClass()
23
+ val onrampModuleClass = getOnrampModuleClass() ?: return null
24
24
  val constructor = onrampModuleClass.getConstructor(ReactApplicationContext::class.java)
25
25
  constructor.newInstance(reactContext) as NativeModule
26
26
  }
@@ -29,10 +29,10 @@ class StripeSdkPackage : BaseReactPackage() {
29
29
 
30
30
  override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
31
31
  val moduleList: Array<Class<out NativeModule?>> =
32
- arrayOf(
32
+ listOfNotNull(
33
33
  StripeSdkModule::class.java,
34
34
  getOnrampModuleClass(),
35
- )
35
+ ).toTypedArray()
36
36
  val reactModuleInfoMap: MutableMap<String, ReactModuleInfo> = HashMap()
37
37
  for (moduleClass in moduleList) {
38
38
  val reactModule = moduleClass.getAnnotation(ReactModule::class.java) ?: continue
@@ -63,12 +63,12 @@ class StripeSdkPackage : BaseReactPackage() {
63
63
  PaymentMethodMessagingElementViewManager(),
64
64
  )
65
65
 
66
- private fun getOnrampModuleClass(): Class<out NativeModule?> {
66
+ private fun getOnrampModuleClass(): Class<out NativeModule?>? {
67
67
  if (BuildConfig.IS_ONRAMP_INCLUDED) {
68
68
  @Suppress("UNCHECKED_CAST")
69
69
  return Class.forName("com.reactnativestripesdk.OnrampSdkModule") as Class<out NativeModule?>
70
70
  } else {
71
- return FakeOnrampSdkModule::class.java
71
+ return null
72
72
  }
73
73
  }
74
74
  }
@@ -140,6 +140,7 @@ internal fun mapPaymentMethodType(type: PaymentMethod.Type?): String =
140
140
  PaymentMethod.Type.GrabPay -> "GrabPay"
141
141
  PaymentMethod.Type.Ideal -> "Ideal"
142
142
  PaymentMethod.Type.Netbanking -> "Netbanking"
143
+ PaymentMethod.Type.Multibanco -> "Multibanco"
143
144
  PaymentMethod.Type.Oxxo -> "Oxxo"
144
145
  PaymentMethod.Type.P24 -> "P24"
145
146
  PaymentMethod.Type.SepaDebit -> "SepaDebit"
@@ -171,6 +172,7 @@ internal fun mapToPaymentMethodType(type: String?): PaymentMethod.Type? =
171
172
  "Fpx" -> PaymentMethod.Type.Fpx
172
173
  "GrabPay" -> PaymentMethod.Type.GrabPay
173
174
  "Netbanking" -> PaymentMethod.Type.Netbanking
175
+ "Multibanco" -> PaymentMethod.Type.Multibanco
174
176
  "Oxxo" -> PaymentMethod.Type.Oxxo
175
177
  "P24" -> PaymentMethod.Type.P24
176
178
  "SepaDebit" -> PaymentMethod.Type.SepaDebit
@@ -18,7 +18,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
18
18
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
19
19
  import com.facebook.react.bridge.ReactMethod;
20
20
  import com.facebook.react.bridge.ReadableMap;
21
- import com.facebook.react.modules.core.DeviceEventManagerModule;
22
21
  import com.facebook.react.turbomodule.core.interfaces.TurboModule;
23
22
  import javax.annotation.Nonnull;
24
23
 
@@ -34,16 +33,6 @@ public abstract class NativeOnrampSdkModuleSpec extends ReactContextBaseJavaModu
34
33
  return NAME;
35
34
  }
36
35
 
37
- private void invoke(String eventName, Object params) {
38
- getReactApplicationContext()
39
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
40
- .emit(eventName, params);
41
- }
42
-
43
- protected final void emitOnCheckoutClientSecretRequested(ReadableMap value) {
44
- invoke("onCheckoutClientSecretRequested", value);
45
- }
46
-
47
36
  @ReactMethod
48
37
  @DoNotStrip
49
38
  public abstract void initialise(ReadableMap params, Promise promise);
@@ -111,4 +100,12 @@ public abstract class NativeOnrampSdkModuleSpec extends ReactContextBaseJavaModu
111
100
  @ReactMethod
112
101
  @DoNotStrip
113
102
  public abstract void logout(Promise promise);
103
+
104
+ @ReactMethod
105
+ @DoNotStrip
106
+ public abstract void addListener(String eventType);
107
+
108
+ @ReactMethod
109
+ @DoNotStrip
110
+ public abstract void removeListeners(double count);
114
111
  }
@@ -1,8 +1,13 @@
1
+ @file:OptIn(ExperimentalCryptoOnramp::class)
2
+
1
3
  package com.reactnativestripesdk
2
4
 
3
5
  import android.annotation.SuppressLint
4
6
  import androidx.compose.ui.graphics.Color
7
+ import com.facebook.react.bridge.Arguments
5
8
  import com.facebook.react.bridge.ReadableMap
9
+ import com.stripe.android.crypto.onramp.ExperimentalCryptoOnramp
10
+ import com.stripe.android.crypto.onramp.model.KycInfo
6
11
  import com.stripe.android.crypto.onramp.model.OnrampConfiguration
7
12
  import com.stripe.android.crypto.onramp.model.PaymentMethodDisplayData
8
13
  import com.stripe.android.googlepaylauncher.GooglePayEnvironment
@@ -11,6 +16,8 @@ import com.stripe.android.link.LinkAppearance
11
16
  import com.stripe.android.link.LinkAppearance.Colors
12
17
  import com.stripe.android.link.LinkAppearance.PrimaryButton
13
18
  import com.stripe.android.link.LinkAppearance.Style
19
+ import com.stripe.android.model.DateOfBirth
20
+ import com.stripe.android.paymentsheet.PaymentSheet
14
21
 
15
22
  @SuppressLint("RestrictedApi")
16
23
  internal fun mapConfig(
@@ -47,6 +54,8 @@ internal fun mapGooglePayConfig(params: ReadableMap?): GooglePayPaymentMethodLau
47
54
  val merchantName = params.getString("merchantName") ?: return null
48
55
  val existingPaymentMethodRequired =
49
56
  params.hasKey("existingPaymentMethodRequired") && params.getBoolean("existingPaymentMethodRequired")
57
+ val isEmailRequired = if (params.hasKey("isEmailRequired")) params.getBoolean("isEmailRequired") else false
58
+ val allowCreditCards = if (params.hasKey("allowCreditCards")) params.getBoolean("allowCreditCards") else true
50
59
 
51
60
  val billingAddressConfig =
52
61
  mapGooglePayBillingAddressConfig(params.getMap("billingAddressConfig"))
@@ -55,6 +64,8 @@ internal fun mapGooglePayConfig(params: ReadableMap?): GooglePayPaymentMethodLau
55
64
  environment = if (testEnv) GooglePayEnvironment.Test else GooglePayEnvironment.Production,
56
65
  merchantCountryCode = merchantCountryCode,
57
66
  merchantName = merchantName,
67
+ isEmailRequired = isEmailRequired,
68
+ allowCreditCards = allowCreditCards,
58
69
  billingAddressConfig = billingAddressConfig,
59
70
  existingPaymentMethodRequired = existingPaymentMethodRequired,
60
71
  )
@@ -148,6 +159,7 @@ internal fun mapAppearance(appearanceMap: ReadableMap): LinkAppearance {
148
159
  .primaryButton(primaryButton)
149
160
  }
150
161
 
162
+ @OptIn(ExperimentalCryptoOnramp::class)
151
163
  @SuppressLint("RestrictedApi")
152
164
  internal fun mapPaymentDetailsType(type: PaymentMethodDisplayData.Type): String =
153
165
  when (type) {
@@ -155,3 +167,38 @@ internal fun mapPaymentDetailsType(type: PaymentMethodDisplayData.Type): String
155
167
  PaymentMethodDisplayData.Type.BankAccount -> "BankAccount"
156
168
  PaymentMethodDisplayData.Type.GooglePay -> "GooglePay"
157
169
  }
170
+
171
+ @OptIn(ExperimentalCryptoOnramp::class)
172
+ @SuppressLint("RestrictedApi")
173
+ internal fun mapFromKycInfo(kycInfo: KycInfo): ReadableMap {
174
+ val result = Arguments.createMap()
175
+
176
+ kycInfo.firstName?.let { result.putString("firstName", it) }
177
+ kycInfo.lastName?.let { result.putString("lastName", it) }
178
+ kycInfo.idNumber?.let { result.putString("idNumber", it) }
179
+ kycInfo.address?.let { result.putMap("address", mapFromKycAddress(it)) }
180
+ kycInfo.dateOfBirth?.let { result.putMap("dateOfBirth", mapFromDateOfBirth(it)) }
181
+
182
+ return result
183
+ }
184
+
185
+ private fun mapFromKycAddress(address: PaymentSheet.Address): ReadableMap {
186
+ val result = Arguments.createMap()
187
+
188
+ address.city?.let { result.putString("city", it) }
189
+ address.country?.let { result.putString("country", it) }
190
+ address.line1?.let { result.putString("line1", it) }
191
+ address.line2?.let { result.putString("line2", it) }
192
+ address.postalCode?.let { result.putString("postalCode", it) }
193
+ address.state?.let { result.putString("state", it) }
194
+
195
+ return result
196
+ }
197
+
198
+ private fun mapFromDateOfBirth(dateOfBirth: DateOfBirth): ReadableMap {
199
+ val result = Arguments.createMap()
200
+ result.putInt("day", dateOfBirth.day)
201
+ result.putInt("month", dateOfBirth.month)
202
+ result.putInt("year", dateOfBirth.year)
203
+ return result
204
+ }
@@ -1,3 +1,5 @@
1
+ @file:OptIn(ExperimentalCryptoOnramp::class)
2
+
1
3
  package com.reactnativestripesdk
2
4
 
3
5
  import android.annotation.SuppressLint
@@ -23,6 +25,7 @@ import com.reactnativestripesdk.utils.createOnrampNotConfiguredError
23
25
  import com.reactnativestripesdk.utils.createResult
24
26
  import com.reactnativestripesdk.utils.getValOr
25
27
  import com.reactnativestripesdk.utils.mapToPaymentSheetAddress
28
+ import com.stripe.android.crypto.onramp.ExperimentalCryptoOnramp
26
29
  import com.stripe.android.crypto.onramp.OnrampCoordinator
27
30
  import com.stripe.android.crypto.onramp.model.CryptoNetwork
28
31
  import com.stripe.android.crypto.onramp.model.KycInfo
@@ -57,10 +60,12 @@ import kotlinx.coroutines.withContext
57
60
  import kotlinx.coroutines.withTimeout
58
61
 
59
62
  @SuppressLint("RestrictedApi")
63
+ @OptIn(ExperimentalCryptoOnramp::class)
60
64
  @ReactModule(name = NativeOnrampSdkModuleSpec.NAME)
61
65
  class OnrampSdkModule(
62
66
  reactContext: ReactApplicationContext,
63
67
  ) : NativeOnrampSdkModuleSpec(reactContext) {
68
+ private val eventEmitterCompat = EventEmitterCompat(reactContext)
64
69
  private lateinit var publishableKey: String
65
70
  private var stripeAccountId: String? = null
66
71
 
@@ -142,7 +147,7 @@ class OnrampSdkModule(
142
147
  val params = Arguments.createMap()
143
148
  params.putString("onrampSessionId", sessionId)
144
149
 
145
- emitOnCheckoutClientSecretRequested(params)
150
+ eventEmitterCompat.emitOnCheckoutClientSecretRequested(params)
146
151
 
147
152
  checkoutClientSecretDeferred!!.await()
148
153
  }
@@ -413,6 +418,7 @@ class OnrampSdkModule(
413
418
  }
414
419
  val currencyCode = googlePayParams.getString("currencyCode") ?: ""
415
420
  val amount = googlePayParams.getDouble("amount").toLong()
421
+
416
422
  val transactionId = googlePayParams.getString("transactionId")
417
423
  val label = googlePayParams.getString("label")
418
424
 
@@ -632,6 +638,16 @@ class OnrampSdkModule(
632
638
  }
633
639
  }
634
640
 
641
+ @ReactMethod
642
+ override fun addListener(eventType: String?) {
643
+ // noop, iOS only
644
+ }
645
+
646
+ @ReactMethod
647
+ override fun removeListeners(count: Double) {
648
+ // noop, iOS only
649
+ }
650
+
635
651
  private fun handleOnrampIdentityVerificationResult(
636
652
  result: OnrampVerifyIdentityResult,
637
653
  promise: Promise,
@@ -707,7 +723,10 @@ class OnrampSdkModule(
707
723
  result.displayData.sublabel?.let { displayData.putString("sublabel", it) }
708
724
  displayData.putString("type", mapPaymentDetailsType(result.displayData.type))
709
725
 
710
- promise.resolve(createResult("displayData", displayData))
726
+ val map = Arguments.createMap()
727
+ map.putMap("displayData", displayData)
728
+ result.kycInfo?.let { map.putMap("kycInfo", mapFromKycInfo(it)) }
729
+ promise.resolve(map)
711
730
  }
712
731
  }
713
732
 
@@ -3,13 +3,18 @@ package com.reactnativestripesdk.mappers
3
3
  import android.annotation.SuppressLint
4
4
  import com.facebook.react.bridge.WritableMap
5
5
  import com.reactnativestripesdk.utils.createCanAddCardResult
6
+ import com.reactnativestripesdk.utils.mapNextAction
7
+ import com.reactnativestripesdk.utils.mapPaymentMethodType
6
8
  import com.reactnativestripesdk.utils.mapToAddress
7
9
  import com.reactnativestripesdk.utils.mapToBillingDetails
10
+ import com.reactnativestripesdk.utils.mapToPaymentMethodType
8
11
  import com.reactnativestripesdk.utils.mapToPreferredNetworks
9
12
  import com.reactnativestripesdk.utils.parseCustomPaymentMethods
10
13
  import com.reactnativestripesdk.utils.readableArrayOf
11
14
  import com.reactnativestripesdk.utils.readableMapOf
12
15
  import com.stripe.android.model.CardBrand
16
+ import com.stripe.android.model.PaymentMethod
17
+ import com.stripe.android.model.StripeIntent
13
18
  import org.junit.Assert
14
19
  import org.junit.Assert.assertEquals
15
20
  import org.junit.Assert.assertFalse
@@ -80,6 +85,34 @@ class MappersTest {
80
85
  Assert.assertNull(details?.getMap("token"))
81
86
  }
82
87
 
88
+ @Test
89
+ fun mapPaymentMethodType_Multibanco_ReturnsString() {
90
+ assertEquals("Multibanco", mapPaymentMethodType(PaymentMethod.Type.Multibanco))
91
+ }
92
+
93
+ @Test
94
+ fun mapToPaymentMethodType_Multibanco_ReturnsType() {
95
+ assertEquals(PaymentMethod.Type.Multibanco, mapToPaymentMethodType("Multibanco"))
96
+ }
97
+
98
+ @Test
99
+ fun mapNextAction_DisplayMultibancoDetails_ReturnsVoucherUrl() {
100
+ val result =
101
+ mapNextAction(
102
+ StripeIntent.NextActionType.DisplayMultibancoDetails,
103
+ StripeIntent.NextActionData.DisplayMultibancoDetails(
104
+ hostedVoucherUrl = "https://payments.stripe.com/multibanco/voucher",
105
+ ),
106
+ )
107
+
108
+ assertNotNull(result)
109
+ assertEquals("multibanco", result?.getString("type"))
110
+ assertEquals(
111
+ "https://payments.stripe.com/multibanco/voucher",
112
+ result?.getString("voucherURL"),
113
+ )
114
+ }
115
+
83
116
  // ============================================
84
117
  // mapToPreferredNetworks Tests
85
118
  // ============================================