@stripe/stripe-react-native 0.55.1 → 0.56.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 (101) hide show
  1. package/android/.idea/AndroidProjectSystem.xml +6 -0
  2. package/android/.idea/caches/deviceStreaming.xml +703 -0
  3. package/android/.idea/compiler.xml +6 -0
  4. package/android/.idea/gradle.xml +18 -0
  5. package/android/.idea/migrations.xml +10 -0
  6. package/android/.idea/misc.xml +10 -0
  7. package/android/.idea/runConfigurations.xml +17 -0
  8. package/android/.idea/vcs.xml +6 -0
  9. package/android/gradle.properties +1 -1
  10. package/android/local.properties +8 -0
  11. package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +8 -0
  12. package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +3 -2
  13. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +46 -0
  14. package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +72 -34
  15. package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +37 -0
  16. package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerDelegate.java +12 -0
  17. package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerInterface.java +4 -0
  18. package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +8 -64
  19. package/ios/ApplePayButtonManager.m +1 -1
  20. package/ios/ApplePayButtonView.swift +2 -2
  21. package/ios/NewArch/ApplePayButtonComponentView.mm +1 -1
  22. package/ios/OldArch/StripeSdkEventEmitterCompat.h +2 -0
  23. package/ios/OldArch/StripeSdkEventEmitterCompat.m +12 -0
  24. package/ios/StripeSdk.mm +14 -0
  25. package/ios/StripeSdkEmitter.swift +2 -0
  26. package/ios/StripeSdkImpl+CustomerSheet.swift +70 -19
  27. package/ios/StripeSdkImpl+PaymentSheet.swift +14 -5
  28. package/ios/StripeSdkImpl.swift +3 -1
  29. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  30. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  31. package/lib/commonjs/components/AddressSheet.js +1 -1
  32. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  33. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  34. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  35. package/lib/commonjs/components/CardField.js +1 -1
  36. package/lib/commonjs/components/CardField.js.map +1 -1
  37. package/lib/commonjs/components/CardForm.js +1 -1
  38. package/lib/commonjs/components/CardForm.js.map +1 -1
  39. package/lib/commonjs/components/CustomerSheet.js +1 -1
  40. package/lib/commonjs/components/CustomerSheet.js.map +1 -1
  41. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  42. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  43. package/lib/commonjs/components/StripeContainer.js +1 -1
  44. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  45. package/lib/commonjs/events.js.map +1 -1
  46. package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
  47. package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -1
  48. package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
  49. package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
  50. package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
  51. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  52. package/lib/module/components/AddToWalletButton.js +1 -1
  53. package/lib/module/components/AddToWalletButton.js.map +1 -1
  54. package/lib/module/components/AddressSheet.js +1 -1
  55. package/lib/module/components/AddressSheet.js.map +1 -1
  56. package/lib/module/components/AuBECSDebitForm.js +1 -1
  57. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  58. package/lib/module/components/CardField.js +1 -1
  59. package/lib/module/components/CardField.js.map +1 -1
  60. package/lib/module/components/CardForm.js +1 -1
  61. package/lib/module/components/CardForm.js.map +1 -1
  62. package/lib/module/components/CustomerSheet.js +1 -1
  63. package/lib/module/components/CustomerSheet.js.map +1 -1
  64. package/lib/module/components/PlatformPayButton.js +1 -1
  65. package/lib/module/components/PlatformPayButton.js.map +1 -1
  66. package/lib/module/components/StripeContainer.js +1 -1
  67. package/lib/module/components/StripeContainer.js.map +1 -1
  68. package/lib/module/events.js.map +1 -1
  69. package/lib/module/specs/NativeApplePayButton.js +1 -1
  70. package/lib/module/specs/NativeApplePayButton.js.map +1 -1
  71. package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
  72. package/lib/module/types/EmbeddedPaymentElement.js +1 -1
  73. package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
  74. package/lib/module/types/PaymentSheet.js.map +1 -1
  75. package/lib/typescript/src/components/CustomerSheet.d.ts +1 -1
  76. package/lib/typescript/src/components/CustomerSheet.d.ts.map +1 -1
  77. package/lib/typescript/src/events.d.ts +2 -0
  78. package/lib/typescript/src/events.d.ts.map +1 -1
  79. package/lib/typescript/src/specs/NativeApplePayButton.d.ts +1 -1
  80. package/lib/typescript/src/specs/NativeApplePayButton.d.ts.map +1 -1
  81. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -1
  82. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
  83. package/lib/typescript/src/types/ConfirmationToken.d.ts +0 -3
  84. package/lib/typescript/src/types/ConfirmationToken.d.ts.map +1 -1
  85. package/lib/typescript/src/types/CustomerSheet.d.ts +70 -12
  86. package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -1
  87. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +2 -4
  88. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
  89. package/lib/typescript/src/types/PaymentSheet.d.ts +1 -6
  90. package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
  91. package/package.json +1 -1
  92. package/src/components/CustomerSheet.tsx +65 -9
  93. package/src/components/PlatformPayButton.tsx +1 -1
  94. package/src/events.ts +2 -0
  95. package/src/specs/NativeApplePayButton.ts +1 -1
  96. package/src/specs/NativeStripeSdkModule.ts +7 -0
  97. package/src/types/ConfirmationToken.ts +0 -3
  98. package/src/types/CustomerSheet.ts +80 -12
  99. package/src/types/EmbeddedPaymentElement.tsx +2 -4
  100. package/src/types/PaymentSheet.ts +1 -6
  101. package/stripe-react-native.podspec +1 -1
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="CompilerConfiguration">
4
+ <bytecodeTargetLevel target="1.6" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GradleMigrationSettings" migrationVersion="1" />
4
+ <component name="GradleSettings">
5
+ <option name="linkedExternalProjectsSettings">
6
+ <GradleProjectSettings>
7
+ <option name="testRunner" value="CHOOSE_PER_TEST" />
8
+ <option name="externalProjectPath" value="$PROJECT_DIR$" />
9
+ <option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
10
+ <option name="modules">
11
+ <set>
12
+ <option value="$PROJECT_DIR$" />
13
+ </set>
14
+ </option>
15
+ </GradleProjectSettings>
16
+ </option>
17
+ </component>
18
+ </project>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectMigrations">
4
+ <option name="MigrateToGradleLocalJavaHome">
5
+ <set>
6
+ <option value="$PROJECT_DIR$" />
7
+ </set>
8
+ </option>
9
+ </component>
10
+ </project>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ExternalStorageConfigurationManager" enabled="true" />
4
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
5
+ <output url="file://$PROJECT_DIR$/build/classes" />
6
+ </component>
7
+ <component name="ProjectType">
8
+ <option name="id" value="Android" />
9
+ </component>
10
+ </project>
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="RunConfigurationProducerService">
4
+ <option name="ignoredProducers">
5
+ <set>
6
+ <option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
7
+ <option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
8
+ <option value="com.intellij.execution.junit.PatternConfigurationProducer" />
9
+ <option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
10
+ <option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
11
+ <option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
12
+ <option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
13
+ <option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
14
+ </set>
15
+ </option>
16
+ </component>
17
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5
+ </component>
6
+ </project>
@@ -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=21.29.0
6
+ StripeSdk_stripeVersion=21.29.+
@@ -0,0 +1,8 @@
1
+ ## This file must *NOT* be checked into Version Control Systems,
2
+ # as it contains information specific to your local configuration.
3
+ #
4
+ # Location of the SDK. This is only used by Gradle.
5
+ # For customization when using a Version Control System, please read the
6
+ # header note.
7
+ #Fri Aug 30 15:10:34 EDT 2024
8
+ sdk.dir=/Users/samer/Library/Android/sdk
@@ -60,6 +60,14 @@ class EventEmitterCompat(
60
60
  invoke("onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback")
61
61
  }
62
62
 
63
+ fun emitOnCustomerSessionProviderSetupIntentClientSecret() {
64
+ invoke("onCustomerSessionProviderSetupIntentClientSecret")
65
+ }
66
+
67
+ fun emitOnCustomerSessionProviderCustomerSessionClientSecret() {
68
+ invoke("onCustomerSessionProviderCustomerSessionClientSecret")
69
+ }
70
+
63
71
  fun emitEmbeddedPaymentElementDidUpdateHeight(value: ReadableMap?) {
64
72
  invoke("embeddedPaymentElementDidUpdateHeight", value)
65
73
  }
@@ -107,7 +107,8 @@ abstract class StripeAbstractComposeView(
107
107
  }
108
108
 
109
109
  fun handleOnDropViewInstance() {
110
- // Update the lifecycle state to DESTROYED to cause the composition to be destroyed.
111
- lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
110
+ if (lifecycleRegistry.currentState.isAtLeast(Lifecycle.State.CREATED)) {
111
+ lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
112
+ }
112
113
  }
113
114
  }
@@ -55,6 +55,7 @@ import com.stripe.android.PaymentConfiguration
55
55
  import com.stripe.android.Stripe
56
56
  import com.stripe.android.core.ApiVersion
57
57
  import com.stripe.android.core.AppInfo
58
+ import com.stripe.android.customersheet.CustomerSheet
58
59
  import com.stripe.android.googlepaylauncher.GooglePayLauncher
59
60
  import com.stripe.android.model.BankAccountTokenParams
60
61
  import com.stripe.android.model.CardParams
@@ -65,6 +66,7 @@ import com.stripe.android.model.PaymentMethod
65
66
  import com.stripe.android.model.SetupIntent
66
67
  import com.stripe.android.model.Token
67
68
  import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
69
+ import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi
68
70
  import com.stripe.android.paymentsheet.PaymentSheet
69
71
  import kotlinx.coroutines.CompletableDeferred
70
72
  import kotlinx.coroutines.CoroutineScope
@@ -1285,6 +1287,50 @@ class StripeSdkModule(
1285
1287
  }
1286
1288
  }
1287
1289
 
1290
+ @OptIn(ExperimentalCustomerSessionApi::class)
1291
+ @ReactMethod
1292
+ override fun clientSecretProviderSetupIntentClientSecretCallback(
1293
+ setupIntentClientSecret: String,
1294
+ promise: Promise,
1295
+ ) {
1296
+ customerSheetFragment?.let {
1297
+ it.customerSessionProvider?.provideSetupIntentClientSecretCallback?.complete(setupIntentClientSecret)
1298
+ } ?: run {
1299
+ promise.resolve(CustomerSheetFragment.createMissingInitError())
1300
+ return
1301
+ }
1302
+ }
1303
+
1304
+ @OptIn(ExperimentalCustomerSessionApi::class)
1305
+ @ReactMethod
1306
+ override fun clientSecretProviderCustomerSessionClientSecretCallback(
1307
+ customerSessionClientSecretJson: ReadableMap,
1308
+ promise: Promise,
1309
+ ) {
1310
+ val clientSecret = customerSessionClientSecretJson.getString("clientSecret")
1311
+ val customerId = customerSessionClientSecretJson.getString("customerId")
1312
+
1313
+ if (clientSecret.isNullOrEmpty() || customerId.isNullOrEmpty()) {
1314
+ Log.e(
1315
+ "StripeReactNative",
1316
+ "Invalid CustomerSessionClientSecret format",
1317
+ )
1318
+ return
1319
+ }
1320
+
1321
+ customerSheetFragment?.let {
1322
+ it.customerSessionProvider?.providesCustomerSessionClientSecretCallback?.complete(
1323
+ CustomerSheet.CustomerSessionClientSecret.create(
1324
+ customerId = customerId!!,
1325
+ clientSecret = clientSecret!!,
1326
+ ),
1327
+ )
1328
+ } ?: run {
1329
+ promise.resolve(CustomerSheetFragment.createMissingInitError())
1330
+ return
1331
+ }
1332
+ }
1333
+
1288
1334
  @ReactMethod
1289
1335
  override fun createEmbeddedPaymentElement(
1290
1336
  intentConfig: ReadableMap,
@@ -13,6 +13,7 @@ import com.facebook.react.bridge.ReactApplicationContext
13
13
  import com.facebook.react.bridge.WritableMap
14
14
  import com.facebook.react.bridge.WritableNativeMap
15
15
  import com.reactnativestripesdk.ReactNativeCustomerAdapter
16
+ import com.reactnativestripesdk.ReactNativeCustomerSessionProvider
16
17
  import com.reactnativestripesdk.buildPaymentSheetAppearance
17
18
  import com.reactnativestripesdk.getBase64FromBitmap
18
19
  import com.reactnativestripesdk.getBitmapFromDrawable
@@ -34,15 +35,17 @@ import com.stripe.android.customersheet.CustomerSheet
34
35
  import com.stripe.android.customersheet.CustomerSheetResult
35
36
  import com.stripe.android.customersheet.PaymentOptionSelection
36
37
  import com.stripe.android.model.PaymentMethod
38
+ import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi
37
39
  import com.stripe.android.paymentsheet.PaymentSheet
38
40
  import kotlinx.coroutines.CoroutineScope
39
41
  import kotlinx.coroutines.Dispatchers
40
42
  import kotlinx.coroutines.launch
41
43
 
42
- @OptIn(ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi::class)
44
+ @OptIn(ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi::class, ExperimentalCustomerSessionApi::class)
43
45
  class CustomerSheetFragment : StripeFragment() {
44
46
  private var customerSheet: CustomerSheet? = null
45
47
  internal var customerAdapter: ReactNativeCustomerAdapter? = null
48
+ internal var customerSessionProvider: ReactNativeCustomerSessionProvider? = null
46
49
  internal var context: ReactApplicationContext? = null
47
50
  internal var initPromise: Promise? = null
48
51
  private var presentPromise: Promise? = null
@@ -73,28 +76,9 @@ class CustomerSheetFragment : StripeFragment() {
73
76
  val googlePayEnabled = arguments?.getBoolean("googlePayEnabled") ?: false
74
77
  val billingDetailsBundle = arguments?.getBundle("defaultBillingDetails")
75
78
  val billingConfigParams = arguments?.getBundle("billingDetailsCollectionConfiguration")
76
- val setupIntentClientSecret = arguments?.getString("setupIntentClientSecret")
77
- val customerId = arguments?.getString("customerId")
78
- val customerEphemeralKeySecret = arguments?.getString("customerEphemeralKeySecret")
79
- val customerAdapterOverrideParams = arguments?.getBundle("customerAdapter")
80
79
  val allowsRemovalOfLastSavedPaymentMethod =
81
80
  arguments?.getBoolean("allowsRemovalOfLastSavedPaymentMethod", true) ?: true
82
81
  val paymentMethodOrder = arguments?.getStringArrayList("paymentMethodOrder")
83
- if (customerId == null) {
84
- initPromise.resolve(
85
- createError(ErrorType.Failed.toString(), "You must provide a value for `customerId`"),
86
- )
87
- return
88
- }
89
- if (customerEphemeralKeySecret == null) {
90
- initPromise.resolve(
91
- createError(
92
- ErrorType.Failed.toString(),
93
- "You must provide a value for `customerEphemeralKeySecret`",
94
- ),
95
- )
96
- return
97
- }
98
82
 
99
83
  val appearance =
100
84
  try {
@@ -125,21 +109,62 @@ class CustomerSheetFragment : StripeFragment() {
125
109
  )
126
110
  }
127
111
 
128
- val customerAdapter =
129
- createCustomerAdapter(
130
- context,
131
- customerId,
132
- customerEphemeralKeySecret,
133
- setupIntentClientSecret,
134
- customerAdapterOverrideParams,
135
- ).also { this.customerAdapter = it }
136
-
137
- customerSheet =
138
- CustomerSheet.create(
139
- fragment = this,
140
- customerAdapter = customerAdapter,
141
- callback = ::handleResult,
112
+ val customerEphemeralKeySecret = arguments?.getString("customerEphemeralKeySecret")
113
+ val intentConfiguration = createIntentConfiguration(arguments?.getBundle("intentConfiguration"))
114
+ if (customerEphemeralKeySecret == null && intentConfiguration == null) {
115
+ initPromise.resolve(
116
+ createError(
117
+ ErrorType.Failed.toString(),
118
+ "You must provide either `customerEphemeralKeySecret` or `intentConfiguration`",
119
+ ),
142
120
  )
121
+ return
122
+ } else if (customerEphemeralKeySecret == null) {
123
+ val customerSessionProvider =
124
+ ReactNativeCustomerSessionProvider(
125
+ context = context,
126
+ intentConfiguration = intentConfiguration!!,
127
+ ).also { this.customerSessionProvider = it }
128
+
129
+ customerSheet =
130
+ CustomerSheet.create(
131
+ fragment = this,
132
+ customerSessionProvider = customerSessionProvider,
133
+ callback = ::handleResult,
134
+ )
135
+ } else if (intentConfiguration == null) {
136
+ val customerId = arguments?.getString("customerId")
137
+ if (customerId == null) {
138
+ initPromise.resolve(
139
+ createError(ErrorType.Failed.toString(), "When using `customerEphemeralKeySecret` you must provide a value for `customerId`"),
140
+ )
141
+ return
142
+ }
143
+ val setupIntentClientSecret = arguments?.getString("setupIntentClientSecret")
144
+ val customerAdapterOverrideParams = arguments?.getBundle("customerAdapter")
145
+ val customerAdapter =
146
+ createCustomerAdapter(
147
+ context,
148
+ customerId!!,
149
+ customerEphemeralKeySecret,
150
+ setupIntentClientSecret,
151
+ customerAdapterOverrideParams,
152
+ ).also { this.customerAdapter = it }
153
+
154
+ customerSheet =
155
+ CustomerSheet.create(
156
+ fragment = this,
157
+ customerAdapter = customerAdapter,
158
+ callback = ::handleResult,
159
+ )
160
+ } else {
161
+ initPromise.resolve(
162
+ createError(
163
+ ErrorType.Failed.toString(),
164
+ "You must provide either `customerEphemeralKeySecret` or `intentConfiguration`, but not both",
165
+ ),
166
+ )
167
+ }
143
168
 
144
169
  customerSheet?.configure(configuration.build())
145
170
 
@@ -389,6 +414,19 @@ class CustomerSheetFragment : StripeFragment() {
389
414
  return paymentOptionResult
390
415
  }
391
416
 
417
+ internal fun createIntentConfiguration(intentConfigurationBundle: Bundle?): CustomerSheet.IntentConfiguration? =
418
+ intentConfigurationBundle?.let { bundle ->
419
+ val onBehalfOf = bundle?.getString("onBehalfOf")
420
+ CustomerSheet.IntentConfiguration
421
+ .Builder()
422
+ .paymentMethodTypes(bundle?.getStringArrayList("paymentMethodTypes") ?: emptyList())
423
+ .apply {
424
+ if (onBehalfOf != null) {
425
+ this.onBehalfOf(onBehalfOf!!)
426
+ }
427
+ }.build()
428
+ }
429
+
392
430
  private fun buildResult(
393
431
  label: String,
394
432
  drawable: Drawable,
@@ -0,0 +1,37 @@
1
+ package com.reactnativestripesdk
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.stripe.android.customersheet.CustomerSheet
5
+ import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi
6
+ import kotlinx.coroutines.CompletableDeferred
7
+
8
+ @OptIn(ExperimentalCustomerSessionApi::class)
9
+ class ReactNativeCustomerSessionProvider(
10
+ val context: ReactApplicationContext,
11
+ val intentConfiguration: CustomerSheet.IntentConfiguration,
12
+ ) : CustomerSheet.CustomerSessionProvider() {
13
+ private val stripeSdkModule = context.getNativeModule(StripeSdkModule::class.java)
14
+
15
+ internal var provideSetupIntentClientSecretCallback: CompletableDeferred<String>? = null
16
+ internal var providesCustomerSessionClientSecretCallback: CompletableDeferred<CustomerSheet.CustomerSessionClientSecret>? = null
17
+
18
+ override suspend fun intentConfiguration(): Result<CustomerSheet.IntentConfiguration> = Result.success(intentConfiguration)
19
+
20
+ override suspend fun provideSetupIntentClientSecret(customerId: String): Result<String> {
21
+ CompletableDeferred<String>().also {
22
+ provideSetupIntentClientSecretCallback = it
23
+ stripeSdkModule?.eventEmitter?.emitOnCustomerSessionProviderSetupIntentClientSecret()
24
+ val resultFromJavascript = it.await()
25
+ return Result.success(resultFromJavascript)
26
+ }
27
+ }
28
+
29
+ override suspend fun providesCustomerSessionClientSecret(): Result<CustomerSheet.CustomerSessionClientSecret> {
30
+ CompletableDeferred<CustomerSheet.CustomerSessionClientSecret>().also {
31
+ providesCustomerSessionClientSecretCallback = it
32
+ stripeSdkModule?.eventEmitter?.emitOnCustomerSessionProviderCustomerSessionClientSecret()
33
+ val resultFromJavascript = it.await()
34
+ return Result.success(resultFromJavascript)
35
+ }
36
+ }
37
+ }
@@ -34,6 +34,18 @@ public class ApplePayButtonManagerDelegate<T extends View, U extends BaseViewMan
34
34
  case "borderRadius":
35
35
  mViewManager.setBorderRadius(view, value == null ? 4 : ((Double) value).intValue());
36
36
  break;
37
+ case "hasShippingMethodCallback":
38
+ mViewManager.setHasShippingMethodCallback(view, value == null ? false : (boolean) value);
39
+ break;
40
+ case "hasShippingContactCallback":
41
+ mViewManager.setHasShippingContactCallback(view, value == null ? false : (boolean) value);
42
+ break;
43
+ case "hasCouponCodeCallback":
44
+ mViewManager.setHasCouponCodeCallback(view, value == null ? false : (boolean) value);
45
+ break;
46
+ case "hasOrderTrackingCallback":
47
+ mViewManager.setHasOrderTrackingCallback(view, value == null ? false : (boolean) value);
48
+ break;
37
49
  default:
38
50
  super.setProperty(view, propName, value);
39
51
  }
@@ -16,4 +16,8 @@ public interface ApplePayButtonManagerInterface<T extends View> {
16
16
  void setType(T view, int value);
17
17
  void setButtonStyle(T view, int value);
18
18
  void setBorderRadius(T view, int value);
19
+ void setHasShippingMethodCallback(T view, boolean value);
20
+ void setHasShippingContactCallback(T view, boolean value);
21
+ void setHasCouponCodeCallback(T view, boolean value);
22
+ void setHasOrderTrackingCallback(T view, boolean value);
19
23
  }
@@ -54,70 +54,6 @@ public abstract class NativeStripeSdkModuleSpec extends ReactContextBaseJavaModu
54
54
  invoke(eventName, null);
55
55
  }
56
56
 
57
- protected final void emitOnConfirmHandlerCallback(ReadableMap value) {
58
- invoke("onConfirmHandlerCallback", value);
59
- }
60
-
61
- protected final void emitOnFinancialConnectionsEvent(ReadableMap value) {
62
- invoke("onFinancialConnectionsEvent", value);
63
- }
64
-
65
- protected final void emitOnOrderTrackingCallback() {
66
- invoke("onOrderTrackingCallback");
67
- }
68
-
69
- protected final void emitOnCustomerAdapterFetchPaymentMethodsCallback() {
70
- invoke("onCustomerAdapterFetchPaymentMethodsCallback");
71
- }
72
-
73
- protected final void emitOnCustomerAdapterAttachPaymentMethodCallback(ReadableMap value) {
74
- invoke("onCustomerAdapterAttachPaymentMethodCallback", value);
75
- }
76
-
77
- protected final void emitOnCustomerAdapterDetachPaymentMethodCallback(ReadableMap value) {
78
- invoke("onCustomerAdapterDetachPaymentMethodCallback", value);
79
- }
80
-
81
- protected final void emitOnCustomerAdapterSetSelectedPaymentOptionCallback(ReadableMap value) {
82
- invoke("onCustomerAdapterSetSelectedPaymentOptionCallback", value);
83
- }
84
-
85
- protected final void emitOnCustomerAdapterFetchSelectedPaymentOptionCallback() {
86
- invoke("onCustomerAdapterFetchSelectedPaymentOptionCallback");
87
- }
88
-
89
- protected final void emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback() {
90
- invoke("onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback");
91
- }
92
-
93
- protected final void emitEmbeddedPaymentElementDidUpdateHeight(ReadableMap value) {
94
- invoke("embeddedPaymentElementDidUpdateHeight", value);
95
- }
96
-
97
- protected final void emitEmbeddedPaymentElementWillPresent() {
98
- invoke("embeddedPaymentElementWillPresent");
99
- }
100
-
101
- protected final void emitEmbeddedPaymentElementDidUpdatePaymentOption(ReadableMap value) {
102
- invoke("embeddedPaymentElementDidUpdatePaymentOption", value);
103
- }
104
-
105
- protected final void emitEmbeddedPaymentElementFormSheetConfirmComplete(ReadableMap value) {
106
- invoke("embeddedPaymentElementFormSheetConfirmComplete", value);
107
- }
108
-
109
- protected final void emitEmbeddedPaymentElementRowSelectionImmediateAction() {
110
- invoke("embeddedPaymentElementRowSelectionImmediateAction");
111
- }
112
-
113
- protected final void emitEmbeddedPaymentElementLoadingFailed(ReadableMap value) {
114
- invoke("embeddedPaymentElementLoadingFailed", value);
115
- }
116
-
117
- protected final void emitOnCustomPaymentMethodConfirmHandlerCallback(ReadableMap value) {
118
- invoke("onCustomPaymentMethodConfirmHandlerCallback", value);
119
- }
120
-
121
57
  @ReactMethod
122
58
  @DoNotStrip
123
59
  public abstract void initialise(ReadableMap params, Promise promise);
@@ -304,6 +240,14 @@ public abstract class NativeStripeSdkModuleSpec extends ReactContextBaseJavaModu
304
240
  @DoNotStrip
305
241
  public abstract void customerAdapterSetupIntentClientSecretForCustomerAttachCallback(String clientSecret, Promise promise);
306
242
 
243
+ @ReactMethod
244
+ @DoNotStrip
245
+ public abstract void clientSecretProviderSetupIntentClientSecretCallback(String setupIntentClientSecret, Promise promise);
246
+
247
+ @ReactMethod
248
+ @DoNotStrip
249
+ public abstract void clientSecretProviderCustomerSessionClientSecretCallback(ReadableMap customerSessionClientSecret, Promise promise);
250
+
307
251
  @ReactMethod
308
252
  @DoNotStrip
309
253
  public abstract void createEmbeddedPaymentElement(ReadableMap intentConfig, ReadableMap configuration, Promise promise);
@@ -5,7 +5,7 @@
5
5
  @interface RCT_EXTERN_MODULE(ApplePayButtonManager, RCTViewManager)
6
6
  RCT_EXPORT_VIEW_PROPERTY(type, NSNumber)
7
7
  RCT_EXPORT_VIEW_PROPERTY(buttonStyle, NSNumber)
8
- RCT_EXPORT_VIEW_PROPERTY(borderRadius, NSNumber)
8
+ RCT_EXPORT_VIEW_PROPERTY(buttonBorderRadius, NSNumber)
9
9
  RCT_EXPORT_VIEW_PROPERTY(disabled, BOOL)
10
10
  RCT_EXPORT_VIEW_PROPERTY(onShippingMethodSelectedAction, RCTDirectEventBlock)
11
11
  RCT_EXPORT_VIEW_PROPERTY(onShippingContactSelectedAction, RCTDirectEventBlock)
@@ -18,7 +18,7 @@ public class ApplePayButtonView: UIView {
18
18
 
19
19
  @objc public var type: NSNumber?
20
20
  @objc public var buttonStyle: NSNumber?
21
- @objc public var borderRadius: NSNumber?
21
+ @objc public var buttonBorderRadius: NSNumber?
22
22
  @objc public var disabled = false
23
23
 
24
24
  @objc func handleApplePayButtonTapped() {
@@ -37,7 +37,7 @@ public class ApplePayButtonView: UIView {
37
37
  let paymentButtonStyle = PKPaymentButtonStyle(rawValue: self.buttonStyle as? Int ?? 2) ?? .black
38
38
  self.applePayButton = PKPaymentButton(paymentButtonType: paymentButtonType, paymentButtonStyle: paymentButtonStyle)
39
39
  if #available(iOS 12.0, *) {
40
- self.applePayButton?.cornerRadius = self.borderRadius as? CGFloat ?? 4.0
40
+ self.applePayButton?.cornerRadius = self.buttonBorderRadius as? CGFloat ?? 4.0
41
41
  }
42
42
 
43
43
  if let applePayButton = self.applePayButton {
@@ -96,7 +96,7 @@ using namespace facebook::react;
96
96
  _view.type = @(newViewProps.type);
97
97
  _view.buttonStyle = @(newViewProps.buttonStyle);
98
98
  _view.disabled = newViewProps.disabled;
99
- _view.borderRadius = @(newViewProps.borderRadius);
99
+ _view.buttonBorderRadius = @(newViewProps.buttonBorderRadius);
100
100
 
101
101
  // Set the boolean flags from props
102
102
  _view.hasShippingMethodCallback = newViewProps.hasShippingMethodCallback;
@@ -14,6 +14,8 @@
14
14
  - (void)emitOnCustomerAdapterSetSelectedPaymentOptionCallback:(NSDictionary *)value;
15
15
  - (void)emitOnCustomerAdapterFetchSelectedPaymentOptionCallback;
16
16
  - (void)emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback;
17
+ - (void)emitOnCustomerSessionProviderSetupIntentClientSecret;
18
+ - (void)emitOnCustomerSessionProviderCustomerSessionClientSecret;
17
19
  - (void)emitEmbeddedPaymentElementDidUpdateHeight:(NSDictionary *)value;
18
20
  - (void)emitEmbeddedPaymentElementWillPresent;
19
21
  - (void)emitEmbeddedPaymentElementDidUpdatePaymentOption:(NSDictionary *)value;
@@ -14,6 +14,8 @@
14
14
  @"onCustomerAdapterSetSelectedPaymentOptionCallback",
15
15
  @"onCustomerAdapterFetchSelectedPaymentOptionCallback",
16
16
  @"onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback",
17
+ @"onCustomerSessionProviderSetupIntentClientSecret",
18
+ @"onCustomerSessionProviderCustomerSessionClientSecret",
17
19
  @"onFinancialConnectionsEvent",
18
20
  @"embeddedPaymentElementDidUpdateHeight",
19
21
  @"embeddedPaymentElementWillPresent",
@@ -75,6 +77,16 @@
75
77
  [self sendEventWithName:@"onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback" body:@{}];
76
78
  }
77
79
 
80
+ - (void)emitOnCustomerSessionProviderSetupIntentClientSecret
81
+ {
82
+ [self sendEventWithName:@"onCustomerSessionProviderSetupIntentClientSecret" body:@{}];
83
+ }
84
+
85
+ - (void)emitOnCustomerSessionProviderCustomerSessionClientSecret
86
+ {
87
+ [self sendEventWithName:@"onCustomerSessionProviderCustomerSessionClientSecret" body:@{}];
88
+ }
89
+
78
90
  - (void)emitEmbeddedPaymentElementDidUpdateHeight:(NSDictionary *)value
79
91
  {
80
92
  [self sendEventWithName:@"embeddedPaymentElementDidUpdateHeight" body:value];
package/ios/StripeSdk.mm CHANGED
@@ -214,6 +214,20 @@ RCT_EXPORT_METHOD(customerAdapterSetupIntentClientSecretForCustomerAttachCallbac
214
214
  rejecter:reject];
215
215
  }
216
216
 
217
+ RCT_EXPORT_METHOD(clientSecretProviderSetupIntentClientSecretCallback:(nonnull NSString *)setupIntentClientSecret
218
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
219
+ reject:(nonnull RCTPromiseRejectBlock)reject)
220
+ {
221
+ [StripeSdkImpl.shared clientSecretProviderSetupIntentClientSecretCallback:setupIntentClientSecret resolver:resolve rejecter:reject];
222
+ }
223
+
224
+ RCT_EXPORT_METHOD(clientSecretProviderCustomerSessionClientSecretCallback:(nonnull NSDictionary *)customerSessionClientSecret
225
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
226
+ reject:(nonnull RCTPromiseRejectBlock)reject)
227
+ {
228
+ [StripeSdkImpl.shared clientSecretProviderCustomerSessionClientSecretCallback:customerSessionClientSecret resolver:resolve rejecter:reject];
229
+ }
230
+
217
231
  RCT_EXPORT_METHOD(dismissPlatformPay:(nonnull RCTPromiseResolveBlock)resolve
218
232
  reject:(nonnull RCTPromiseRejectBlock)reject)
219
233
  {
@@ -11,6 +11,8 @@ import Foundation
11
11
  func emitOnCustomerAdapterSetSelectedPaymentOptionCallback(_ value: [String: Any])
12
12
  func emitOnCustomerAdapterFetchSelectedPaymentOptionCallback()
13
13
  func emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback()
14
+ func emitOnCustomerSessionProviderSetupIntentClientSecret()
15
+ func emitOnCustomerSessionProviderCustomerSessionClientSecret()
14
16
  func emitEmbeddedPaymentElementDidUpdateHeight(_ value: [String: Any])
15
17
  func emitEmbeddedPaymentElementWillPresent()
16
18
  func emitEmbeddedPaymentElementDidUpdatePaymentOption(_ value: [String: Any])