@stripe/stripe-react-native 0.56.0 → 0.57.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/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +4 -3
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +7 -6
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +11 -11
- package/android/src/main/java/com/reactnativestripesdk/{CollectBankAccountLauncherFragment.kt → CollectBankAccountLauncherManager.kt} +21 -44
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +17 -24
- package/android/src/main/java/com/reactnativestripesdk/{FinancialConnectionsSheetFragment.kt → FinancialConnectionsSheetManager.kt} +30 -77
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +107 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherManager.kt +37 -0
- package/android/src/main/java/com/reactnativestripesdk/{PaymentLauncherFragment.kt → PaymentLauncherManager.kt} +39 -77
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +8 -20
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +366 -483
- package/android/src/main/java/com/reactnativestripesdk/{PaymentSheetFragment.kt → PaymentSheetManager.kt} +79 -88
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +176 -219
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt +78 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +48 -35
- package/android/src/main/java/com/reactnativestripesdk/customersheet/{CustomerSheetFragment.kt → CustomerSheetManager.kt} +70 -85
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +0 -2
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +47 -12
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +87 -142
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeUIManager.kt +62 -0
- package/ios/AddressSheet/AddressSheetView.swift +1 -1
- package/ios/FinancialConnections.swift +2 -2
- package/ios/Mappers.swift +2 -4
- package/ios/PaymentMethodFactory.swift +0 -17
- package/ios/PushProvisioning/AddToWalletButtonView.swift +1 -1
- package/ios/StripeSdkImpl+CustomerSheet.swift +1 -1
- package/ios/StripeSdkImpl+PaymentSheet.swift +15 -8
- package/ios/StripeSdkImpl.swift +6 -6
- 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/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/PaymentIntent.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/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/typescript/src/types/PaymentIntent.d.ts +1 -9
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentMethod.d.ts +2 -8
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/types/PaymentIntent.ts +0 -10
- package/src/types/PaymentMethod.ts +0 -9
- package/stripe-react-native.podspec +1 -1
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/caches/deviceStreaming.xml +0 -703
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -18
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -10
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +0 -146
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +0 -68
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +0 -102
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeFragment.kt +0 -52
|
@@ -20,21 +20,21 @@ import com.facebook.react.bridge.UiThreadUtil
|
|
|
20
20
|
import com.facebook.react.bridge.WritableMap
|
|
21
21
|
import com.facebook.react.bridge.WritableNativeMap
|
|
22
22
|
import com.facebook.react.module.annotations.ReactModule
|
|
23
|
-
import com.reactnativestripesdk.addresssheet.
|
|
24
|
-
import com.reactnativestripesdk.customersheet.
|
|
23
|
+
import com.reactnativestripesdk.addresssheet.AddressLauncherManager
|
|
24
|
+
import com.reactnativestripesdk.customersheet.CustomerSheetManager
|
|
25
25
|
import com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy
|
|
26
26
|
import com.reactnativestripesdk.utils.ConfirmPaymentErrorType
|
|
27
27
|
import com.reactnativestripesdk.utils.CreateTokenErrorType
|
|
28
28
|
import com.reactnativestripesdk.utils.ErrorType
|
|
29
29
|
import com.reactnativestripesdk.utils.GooglePayErrorType
|
|
30
|
+
import com.reactnativestripesdk.utils.StripeUIManager
|
|
30
31
|
import com.reactnativestripesdk.utils.createCanAddCardResult
|
|
31
32
|
import com.reactnativestripesdk.utils.createError
|
|
32
33
|
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
33
34
|
import com.reactnativestripesdk.utils.createMissingInitError
|
|
34
35
|
import com.reactnativestripesdk.utils.createResult
|
|
35
36
|
import com.reactnativestripesdk.utils.getBooleanOr
|
|
36
|
-
import com.reactnativestripesdk.utils.
|
|
37
|
-
import com.reactnativestripesdk.utils.getMapOrNull
|
|
37
|
+
import com.reactnativestripesdk.utils.getIntOrNull
|
|
38
38
|
import com.reactnativestripesdk.utils.getValOr
|
|
39
39
|
import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
|
|
40
40
|
import com.reactnativestripesdk.utils.mapFromPaymentMethod
|
|
@@ -46,8 +46,6 @@ import com.reactnativestripesdk.utils.mapToPaymentMethodType
|
|
|
46
46
|
import com.reactnativestripesdk.utils.mapToReturnURL
|
|
47
47
|
import com.reactnativestripesdk.utils.mapToShippingDetails
|
|
48
48
|
import com.reactnativestripesdk.utils.mapToUICustomization
|
|
49
|
-
import com.reactnativestripesdk.utils.removeFragment
|
|
50
|
-
import com.reactnativestripesdk.utils.toBundleObject
|
|
51
49
|
import com.stripe.android.ApiResultCallback
|
|
52
50
|
import com.stripe.android.GooglePayJsonFactory
|
|
53
51
|
import com.stripe.android.PaymentAuthConfig
|
|
@@ -55,6 +53,7 @@ import com.stripe.android.PaymentConfiguration
|
|
|
55
53
|
import com.stripe.android.Stripe
|
|
56
54
|
import com.stripe.android.core.ApiVersion
|
|
57
55
|
import com.stripe.android.core.AppInfo
|
|
56
|
+
import com.stripe.android.core.reactnative.ReactNativeSdkInternal
|
|
58
57
|
import com.stripe.android.customersheet.CustomerSheet
|
|
59
58
|
import com.stripe.android.googlepaylauncher.GooglePayLauncher
|
|
60
59
|
import com.stripe.android.model.BankAccountTokenParams
|
|
@@ -66,7 +65,6 @@ import com.stripe.android.model.PaymentMethod
|
|
|
66
65
|
import com.stripe.android.model.SetupIntent
|
|
67
66
|
import com.stripe.android.model.Token
|
|
68
67
|
import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
|
|
69
|
-
import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi
|
|
70
68
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
71
69
|
import kotlinx.coroutines.CompletableDeferred
|
|
72
70
|
import kotlinx.coroutines.CoroutineScope
|
|
@@ -75,6 +73,7 @@ import kotlinx.coroutines.launch
|
|
|
75
73
|
import org.json.JSONObject
|
|
76
74
|
|
|
77
75
|
@ReactModule(name = StripeSdkModule.NAME)
|
|
76
|
+
@OptIn(ReactNativeSdkInternal::class)
|
|
78
77
|
class StripeSdkModule(
|
|
79
78
|
reactContext: ReactApplicationContext,
|
|
80
79
|
) : NativeStripeSdkModuleSpec(reactContext) {
|
|
@@ -89,11 +88,15 @@ class StripeSdkModule(
|
|
|
89
88
|
private var createPlatformPayPaymentMethodPromise: Promise? = null
|
|
90
89
|
private var platformPayUsesDeprecatedTokenFlow = false
|
|
91
90
|
|
|
92
|
-
private
|
|
93
|
-
private var
|
|
94
|
-
private var
|
|
91
|
+
private val stripeUIManagers = mutableListOf<StripeUIManager>()
|
|
92
|
+
private var paymentSheetManager: PaymentSheetManager? = null
|
|
93
|
+
private var paymentLauncherManager: PaymentLauncherManager? = null
|
|
94
|
+
private var collectBankAccountLauncherManager: CollectBankAccountLauncherManager? = null
|
|
95
|
+
private var financialConnectionsSheetManager: FinancialConnectionsSheetManager? = null
|
|
96
|
+
private var googlePayLauncherManager: GooglePayLauncherManager? = null
|
|
97
|
+
private var googlePayPaymentMethodLauncherManager: GooglePayPaymentMethodLauncherManager? = null
|
|
95
98
|
|
|
96
|
-
private var
|
|
99
|
+
private var customerSheetManager: CustomerSheetManager? = null
|
|
97
100
|
|
|
98
101
|
internal var embeddedIntentCreationCallback = CompletableDeferred<ReadableMap>()
|
|
99
102
|
internal var embeddedConfirmationTokenCreationCallback = CompletableDeferred<ReadableMap>()
|
|
@@ -104,20 +107,6 @@ class StripeSdkModule(
|
|
|
104
107
|
|
|
105
108
|
val eventEmitter: EventEmitterCompat by lazy { EventEmitterCompat(reactApplicationContext) }
|
|
106
109
|
|
|
107
|
-
// If you create a new Fragment, you must put the tag here, otherwise result callbacks for that
|
|
108
|
-
// Fragment will not work on RN < 0.65
|
|
109
|
-
private val allStripeFragmentTags: List<String>
|
|
110
|
-
get() =
|
|
111
|
-
listOf(
|
|
112
|
-
PaymentSheetFragment.TAG,
|
|
113
|
-
PaymentLauncherFragment.TAG,
|
|
114
|
-
CollectBankAccountLauncherFragment.TAG,
|
|
115
|
-
FinancialConnectionsSheetFragment.TAG,
|
|
116
|
-
AddressLauncherFragment.TAG,
|
|
117
|
-
GooglePayLauncherFragment.TAG,
|
|
118
|
-
CustomerSheetFragment.TAG,
|
|
119
|
-
)
|
|
120
|
-
|
|
121
110
|
private val mActivityEventListener =
|
|
122
111
|
object : BaseActivityEventListener() {
|
|
123
112
|
override fun onActivityResult(
|
|
@@ -145,10 +134,6 @@ class StripeSdkModule(
|
|
|
145
134
|
)
|
|
146
135
|
}
|
|
147
136
|
}
|
|
148
|
-
|
|
149
|
-
else -> {
|
|
150
|
-
dispatchActivityResultsToFragments(requestCode, resultCode, data)
|
|
151
|
-
}
|
|
152
137
|
}
|
|
153
138
|
}
|
|
154
139
|
}
|
|
@@ -158,19 +143,22 @@ class StripeSdkModule(
|
|
|
158
143
|
reactContext.addActivityEventListener(mActivityEventListener)
|
|
159
144
|
}
|
|
160
145
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
146
|
+
override fun invalidate() {
|
|
147
|
+
super.invalidate()
|
|
148
|
+
|
|
149
|
+
stripeUIManagers.forEach { it.destroy() }
|
|
150
|
+
stripeUIManagers.clear()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private fun registerStripeUIManager(uiManager: StripeUIManager) {
|
|
154
|
+
uiManager.create()
|
|
155
|
+
stripeUIManagers.add(uiManager)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private fun unregisterStripeUIManager(uiManager: StripeUIManager?) {
|
|
159
|
+
val uiManager = uiManager ?: return
|
|
160
|
+
uiManager.destroy()
|
|
161
|
+
stripeUIManagers.remove(uiManager)
|
|
174
162
|
}
|
|
175
163
|
|
|
176
164
|
private fun configure3dSecure(params: ReadableMap) {
|
|
@@ -205,18 +193,18 @@ class StripeSdkModule(
|
|
|
205
193
|
promise: Promise,
|
|
206
194
|
) {
|
|
207
195
|
val publishableKey = getValOr(params, "publishableKey", null) as String
|
|
208
|
-
val appInfo =
|
|
196
|
+
val appInfo = params.getMap("appInfo") as ReadableMap
|
|
209
197
|
this.stripeAccountId = getValOr(params, "stripeAccountId", null)
|
|
210
198
|
val urlScheme = getValOr(params, "urlScheme", null)
|
|
211
|
-
val setReturnUrlSchemeOnAndroid =
|
|
199
|
+
val setReturnUrlSchemeOnAndroid = params.getBooleanOr("setReturnUrlSchemeOnAndroid", false)
|
|
212
200
|
this.urlScheme = if (setReturnUrlSchemeOnAndroid) urlScheme else null
|
|
213
201
|
|
|
214
|
-
|
|
202
|
+
params.getMap("threeDSecureParams")?.let {
|
|
215
203
|
configure3dSecure(it)
|
|
216
204
|
}
|
|
217
205
|
|
|
218
206
|
this.publishableKey = publishableKey
|
|
219
|
-
|
|
207
|
+
AddressLauncherManager.publishableKey = publishableKey
|
|
220
208
|
|
|
221
209
|
val name = getValOr(appInfo, "name", "") as String
|
|
222
210
|
val partnerId = getValOr(appInfo, "partnerId", "")
|
|
@@ -239,28 +227,11 @@ class StripeSdkModule(
|
|
|
239
227
|
params: ReadableMap,
|
|
240
228
|
promise: Promise,
|
|
241
229
|
) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// Handle custom payment methods separately since toBundleObject cannot handle arrays of objects
|
|
247
|
-
val customPaymentMethodConfig = params.getMap("customPaymentMethodConfiguration")
|
|
248
|
-
if (customPaymentMethodConfig != null) {
|
|
249
|
-
// Store the original ReadableMap for custom payment methods
|
|
250
|
-
bundle.putSerializable("customPaymentMethodConfigurationReadableMap", customPaymentMethodConfig.toHashMap())
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
paymentSheetFragment =
|
|
254
|
-
PaymentSheetFragment.create(reactApplicationContext, bundle, promise)
|
|
255
|
-
try {
|
|
256
|
-
activity.supportFragmentManager
|
|
257
|
-
.beginTransaction()
|
|
258
|
-
.add(paymentSheetFragment!!, PaymentSheetFragment.TAG)
|
|
259
|
-
.commit()
|
|
260
|
-
} catch (error: IllegalStateException) {
|
|
261
|
-
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
230
|
+
unregisterStripeUIManager(paymentSheetManager)
|
|
231
|
+
paymentSheetManager =
|
|
232
|
+
PaymentSheetManager(reactApplicationContext, params, promise).also {
|
|
233
|
+
registerStripeUIManager(it)
|
|
262
234
|
}
|
|
263
|
-
}
|
|
264
235
|
}
|
|
265
236
|
|
|
266
237
|
@ReactMethod
|
|
@@ -268,30 +239,30 @@ class StripeSdkModule(
|
|
|
268
239
|
options: ReadableMap,
|
|
269
240
|
promise: Promise,
|
|
270
241
|
) {
|
|
271
|
-
if (
|
|
272
|
-
promise.resolve(
|
|
242
|
+
if (paymentSheetManager == null) {
|
|
243
|
+
promise.resolve(PaymentSheetManager.createMissingInitError())
|
|
273
244
|
return
|
|
274
245
|
}
|
|
275
246
|
|
|
276
247
|
val timeoutKey = "timeout"
|
|
277
248
|
if (options.hasKey(timeoutKey)) {
|
|
278
|
-
|
|
249
|
+
paymentSheetManager?.presentWithTimeout(
|
|
279
250
|
options.getInt(timeoutKey).toLong(),
|
|
280
251
|
promise,
|
|
281
252
|
)
|
|
282
253
|
} else {
|
|
283
|
-
|
|
254
|
+
paymentSheetManager?.present(promise)
|
|
284
255
|
}
|
|
285
256
|
}
|
|
286
257
|
|
|
287
258
|
@ReactMethod
|
|
288
259
|
override fun confirmPaymentSheetPayment(promise: Promise) {
|
|
289
|
-
if (
|
|
290
|
-
promise.resolve(
|
|
260
|
+
if (paymentSheetManager == null) {
|
|
261
|
+
promise.resolve(PaymentSheetManager.createMissingInitError())
|
|
291
262
|
return
|
|
292
263
|
}
|
|
293
264
|
|
|
294
|
-
|
|
265
|
+
paymentSheetManager?.confirmPayment(promise)
|
|
295
266
|
}
|
|
296
267
|
|
|
297
268
|
@ReactMethod
|
|
@@ -307,12 +278,12 @@ class StripeSdkModule(
|
|
|
307
278
|
) {
|
|
308
279
|
embeddedIntentCreationCallback.complete(params)
|
|
309
280
|
|
|
310
|
-
if (
|
|
311
|
-
promise.resolve(
|
|
281
|
+
if (paymentSheetManager == null) {
|
|
282
|
+
promise.resolve(PaymentSheetManager.createMissingInitError())
|
|
312
283
|
return
|
|
313
284
|
}
|
|
314
285
|
|
|
315
|
-
|
|
286
|
+
paymentSheetManager?.paymentSheetIntentCreationCallback?.complete(params)
|
|
316
287
|
}
|
|
317
288
|
|
|
318
289
|
@ReactMethod
|
|
@@ -335,12 +306,12 @@ class StripeSdkModule(
|
|
|
335
306
|
embeddedConfirmationTokenCreationCallback.complete(params)
|
|
336
307
|
paymentSheetConfirmationTokenCreationCallback.complete(params)
|
|
337
308
|
|
|
338
|
-
if (
|
|
339
|
-
promise.resolve(
|
|
309
|
+
if (paymentSheetManager == null) {
|
|
310
|
+
promise.resolve(PaymentSheetManager.createMissingInitError())
|
|
340
311
|
return
|
|
341
312
|
}
|
|
342
313
|
|
|
343
|
-
|
|
314
|
+
paymentSheetManager?.paymentSheetConfirmationTokenCreationCallback?.complete(params)
|
|
344
315
|
}
|
|
345
316
|
|
|
346
317
|
@ReactMethod
|
|
@@ -359,7 +330,7 @@ class StripeSdkModule(
|
|
|
359
330
|
)
|
|
360
331
|
return
|
|
361
332
|
}
|
|
362
|
-
val paymentMethodData =
|
|
333
|
+
val paymentMethodData = data.getMap("paymentMethodData")
|
|
363
334
|
val factory =
|
|
364
335
|
PaymentMethodCreateParamsFactory(paymentMethodData, options, cardFieldView, cardFormView)
|
|
365
336
|
try {
|
|
@@ -494,7 +465,7 @@ class StripeSdkModule(
|
|
|
494
465
|
}
|
|
495
466
|
|
|
496
467
|
val cardAddress = cardFieldView?.cardAddress ?: cardFormView?.cardAddress
|
|
497
|
-
val address =
|
|
468
|
+
val address = params.getMap("address")
|
|
498
469
|
val cardParams =
|
|
499
470
|
CardParams(
|
|
500
471
|
number = cardParamsMap["number"] as String,
|
|
@@ -549,15 +520,19 @@ class StripeSdkModule(
|
|
|
549
520
|
returnUrl: String?,
|
|
550
521
|
promise: Promise,
|
|
551
522
|
) {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
523
|
+
unregisterStripeUIManager(paymentSheetManager)
|
|
524
|
+
paymentLauncherManager =
|
|
525
|
+
PaymentLauncherManager
|
|
526
|
+
.forNextActionPayment(
|
|
527
|
+
context = reactApplicationContext,
|
|
528
|
+
stripe,
|
|
529
|
+
publishableKey,
|
|
530
|
+
stripeAccountId,
|
|
531
|
+
paymentIntentClientSecret,
|
|
532
|
+
).also {
|
|
533
|
+
registerStripeUIManager(it)
|
|
534
|
+
it.present(promise)
|
|
535
|
+
}
|
|
561
536
|
}
|
|
562
537
|
|
|
563
538
|
@ReactMethod
|
|
@@ -566,15 +541,19 @@ class StripeSdkModule(
|
|
|
566
541
|
returnUrl: String?,
|
|
567
542
|
promise: Promise,
|
|
568
543
|
) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
544
|
+
unregisterStripeUIManager(paymentLauncherManager)
|
|
545
|
+
paymentLauncherManager =
|
|
546
|
+
PaymentLauncherManager
|
|
547
|
+
.forNextActionSetup(
|
|
548
|
+
context = reactApplicationContext,
|
|
549
|
+
stripe,
|
|
550
|
+
publishableKey,
|
|
551
|
+
stripeAccountId,
|
|
552
|
+
setupIntentClientSecret,
|
|
553
|
+
).also {
|
|
554
|
+
registerStripeUIManager(it)
|
|
555
|
+
it.present(promise)
|
|
556
|
+
}
|
|
578
557
|
}
|
|
579
558
|
|
|
580
559
|
// TODO: Uncomment when WeChat is re-enabled in stripe-ios
|
|
@@ -603,7 +582,7 @@ class StripeSdkModule(
|
|
|
603
582
|
options: ReadableMap?,
|
|
604
583
|
promise: Promise,
|
|
605
584
|
) {
|
|
606
|
-
val paymentMethodData =
|
|
585
|
+
val paymentMethodData = params?.getMap("paymentMethodData")
|
|
607
586
|
val paymentMethodType =
|
|
608
587
|
if (params != null) {
|
|
609
588
|
mapToPaymentMethodType(params.getString("paymentMethodType")) ?: run {
|
|
@@ -643,17 +622,21 @@ class StripeSdkModule(
|
|
|
643
622
|
confirmParams.returnUrl = mapToReturnURL(urlScheme)
|
|
644
623
|
}
|
|
645
624
|
confirmParams.shipping =
|
|
646
|
-
mapToShippingDetails(
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
625
|
+
mapToShippingDetails(paymentMethodData?.getMap("shippingDetails"))
|
|
626
|
+
unregisterStripeUIManager(paymentLauncherManager)
|
|
627
|
+
paymentLauncherManager =
|
|
628
|
+
PaymentLauncherManager
|
|
629
|
+
.forPayment(
|
|
630
|
+
context = reactApplicationContext,
|
|
631
|
+
stripe,
|
|
632
|
+
publishableKey,
|
|
633
|
+
stripeAccountId,
|
|
634
|
+
paymentIntentClientSecret,
|
|
635
|
+
confirmParams,
|
|
636
|
+
).also {
|
|
637
|
+
registerStripeUIManager(it)
|
|
638
|
+
it.present(promise)
|
|
639
|
+
}
|
|
657
640
|
} catch (error: PaymentMethodCreateParamsException) {
|
|
658
641
|
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), error))
|
|
659
642
|
}
|
|
@@ -701,7 +684,7 @@ class StripeSdkModule(
|
|
|
701
684
|
|
|
702
685
|
val factory =
|
|
703
686
|
PaymentMethodCreateParamsFactory(
|
|
704
|
-
|
|
687
|
+
params.getMap("paymentMethodData"),
|
|
705
688
|
options,
|
|
706
689
|
cardFieldView,
|
|
707
690
|
cardFormView,
|
|
@@ -717,16 +700,20 @@ class StripeSdkModule(
|
|
|
717
700
|
urlScheme?.let {
|
|
718
701
|
confirmParams.returnUrl = mapToReturnURL(urlScheme)
|
|
719
702
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
703
|
+
unregisterStripeUIManager(paymentLauncherManager)
|
|
704
|
+
paymentLauncherManager =
|
|
705
|
+
PaymentLauncherManager
|
|
706
|
+
.forSetup(
|
|
707
|
+
context = reactApplicationContext,
|
|
708
|
+
stripe,
|
|
709
|
+
publishableKey,
|
|
710
|
+
stripeAccountId,
|
|
711
|
+
setupIntentClientSecret,
|
|
712
|
+
confirmParams,
|
|
713
|
+
).also {
|
|
714
|
+
registerStripeUIManager(it)
|
|
715
|
+
it.present(promise)
|
|
716
|
+
}
|
|
730
717
|
} catch (error: PaymentMethodCreateParamsException) {
|
|
731
718
|
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), error))
|
|
732
719
|
}
|
|
@@ -738,24 +725,16 @@ class StripeSdkModule(
|
|
|
738
725
|
promise: Promise,
|
|
739
726
|
) {
|
|
740
727
|
val googlePayParams = params?.getMap("googlePay")
|
|
741
|
-
|
|
742
|
-
|
|
728
|
+
unregisterStripeUIManager(googlePayPaymentMethodLauncherManager)
|
|
729
|
+
googlePayPaymentMethodLauncherManager =
|
|
730
|
+
GooglePayPaymentMethodLauncherManager(
|
|
743
731
|
reactApplicationContext,
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
getCurrentActivityOrResolveWithError(promise)?.let {
|
|
750
|
-
try {
|
|
751
|
-
it.supportFragmentManager
|
|
752
|
-
.beginTransaction()
|
|
753
|
-
.add(fragment, GooglePayPaymentMethodLauncherFragment.TAG)
|
|
754
|
-
.commit()
|
|
755
|
-
} catch (error: IllegalStateException) {
|
|
756
|
-
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
732
|
+
googlePayParams?.getBooleanOr("testEnv", false) ?: false,
|
|
733
|
+
googlePayParams?.getBooleanOr("existingPaymentMethodRequired", false) ?: false,
|
|
734
|
+
).also {
|
|
735
|
+
registerStripeUIManager(it)
|
|
736
|
+
it.present(promise)
|
|
757
737
|
}
|
|
758
|
-
}
|
|
759
738
|
}
|
|
760
739
|
|
|
761
740
|
@ReactMethod
|
|
@@ -781,12 +760,12 @@ class StripeSdkModule(
|
|
|
781
760
|
return
|
|
782
761
|
}
|
|
783
762
|
|
|
784
|
-
|
|
785
|
-
|
|
763
|
+
googlePayLauncherManager =
|
|
764
|
+
GooglePayLauncherManager(
|
|
765
|
+
reactApplicationContext,
|
|
786
766
|
clientSecret,
|
|
787
|
-
if (isPaymentIntent)
|
|
767
|
+
if (isPaymentIntent) GooglePayLauncherManager.Mode.ForPayment else GooglePayLauncherManager.Mode.ForSetup,
|
|
788
768
|
googlePayParams,
|
|
789
|
-
reactApplicationContext,
|
|
790
769
|
) { launcherResult, errorMap ->
|
|
791
770
|
if (errorMap != null) {
|
|
792
771
|
promise.resolve(errorMap)
|
|
@@ -851,7 +830,6 @@ class StripeSdkModule(
|
|
|
851
830
|
}
|
|
852
831
|
}
|
|
853
832
|
}
|
|
854
|
-
}
|
|
855
833
|
}
|
|
856
834
|
|
|
857
835
|
@ReactMethod
|
|
@@ -948,7 +926,7 @@ class StripeSdkModule(
|
|
|
948
926
|
params: ReadableMap,
|
|
949
927
|
promise: Promise,
|
|
950
928
|
) {
|
|
951
|
-
val paymentMethodData =
|
|
929
|
+
val paymentMethodData = params.getMap("paymentMethodData")
|
|
952
930
|
val paymentMethodType = mapToPaymentMethodType(getValOr(params, "paymentMethodType", null))
|
|
953
931
|
if (paymentMethodType != PaymentMethod.Type.USBankAccount) {
|
|
954
932
|
promise.resolve(
|
|
@@ -960,7 +938,7 @@ class StripeSdkModule(
|
|
|
960
938
|
return
|
|
961
939
|
}
|
|
962
940
|
|
|
963
|
-
val billingDetails =
|
|
941
|
+
val billingDetails = paymentMethodData?.getMap("billingDetails")
|
|
964
942
|
|
|
965
943
|
val name = billingDetails?.getString("name")
|
|
966
944
|
if (name.isNullOrEmpty()) {
|
|
@@ -979,26 +957,19 @@ class StripeSdkModule(
|
|
|
979
957
|
billingDetails.getString("email"),
|
|
980
958
|
)
|
|
981
959
|
|
|
982
|
-
|
|
983
|
-
|
|
960
|
+
unregisterStripeUIManager(collectBankAccountLauncherManager)
|
|
961
|
+
collectBankAccountLauncherManager =
|
|
962
|
+
CollectBankAccountLauncherManager(
|
|
984
963
|
reactApplicationContext,
|
|
985
964
|
publishableKey,
|
|
986
965
|
stripeAccountId,
|
|
987
966
|
clientSecret,
|
|
988
967
|
isPaymentIntent,
|
|
989
968
|
collectParams,
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
try {
|
|
994
|
-
it.supportFragmentManager
|
|
995
|
-
.beginTransaction()
|
|
996
|
-
.add(collectBankAccountLauncherFragment!!, "collect_bank_account_launcher_fragment")
|
|
997
|
-
.commit()
|
|
998
|
-
} catch (error: IllegalStateException) {
|
|
999
|
-
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
969
|
+
).also {
|
|
970
|
+
registerStripeUIManager(it)
|
|
971
|
+
it.present(promise)
|
|
1000
972
|
}
|
|
1001
|
-
}
|
|
1002
973
|
}
|
|
1003
974
|
|
|
1004
975
|
@ReactMethod
|
|
@@ -1096,16 +1067,18 @@ class StripeSdkModule(
|
|
|
1096
1067
|
promise.resolve(createMissingInitError())
|
|
1097
1068
|
return
|
|
1098
1069
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1070
|
+
unregisterStripeUIManager(financialConnectionsSheetManager)
|
|
1071
|
+
financialConnectionsSheetManager =
|
|
1072
|
+
FinancialConnectionsSheetManager(
|
|
1073
|
+
reactApplicationContext,
|
|
1101
1074
|
clientSecret,
|
|
1102
|
-
|
|
1075
|
+
FinancialConnectionsSheetManager.Mode.ForToken,
|
|
1103
1076
|
publishableKey,
|
|
1104
1077
|
stripeAccountId,
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1078
|
+
).also {
|
|
1079
|
+
registerStripeUIManager(it)
|
|
1080
|
+
it.present(promise)
|
|
1081
|
+
}
|
|
1109
1082
|
}
|
|
1110
1083
|
|
|
1111
1084
|
@ReactMethod
|
|
@@ -1118,16 +1091,19 @@ class StripeSdkModule(
|
|
|
1118
1091
|
promise.resolve(createMissingInitError())
|
|
1119
1092
|
return
|
|
1120
1093
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1094
|
+
|
|
1095
|
+
unregisterStripeUIManager(financialConnectionsSheetManager)
|
|
1096
|
+
financialConnectionsSheetManager =
|
|
1097
|
+
FinancialConnectionsSheetManager(
|
|
1098
|
+
reactApplicationContext,
|
|
1123
1099
|
clientSecret,
|
|
1124
|
-
|
|
1100
|
+
FinancialConnectionsSheetManager.Mode.ForSession,
|
|
1125
1101
|
publishableKey,
|
|
1126
1102
|
stripeAccountId,
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1103
|
+
).also {
|
|
1104
|
+
registerStripeUIManager(it)
|
|
1105
|
+
it.present(promise)
|
|
1106
|
+
}
|
|
1131
1107
|
}
|
|
1132
1108
|
|
|
1133
1109
|
@ReactMethod
|
|
@@ -1141,25 +1117,11 @@ class StripeSdkModule(
|
|
|
1141
1117
|
return
|
|
1142
1118
|
}
|
|
1143
1119
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
it.context = reactApplicationContext
|
|
1149
|
-
it.initPromise = promise
|
|
1150
|
-
val bundle = toBundleObject(params)
|
|
1151
|
-
bundle.putBundle("customerAdapter", toBundleObject(customerAdapterOverrides))
|
|
1152
|
-
it.arguments = bundle
|
|
1153
|
-
}
|
|
1154
|
-
try {
|
|
1155
|
-
activity.supportFragmentManager
|
|
1156
|
-
.beginTransaction()
|
|
1157
|
-
.add(customerSheetFragment!!, CustomerSheetFragment.TAG)
|
|
1158
|
-
.commit()
|
|
1159
|
-
} catch (error: IllegalStateException) {
|
|
1160
|
-
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
1120
|
+
unregisterStripeUIManager(customerSheetManager)
|
|
1121
|
+
customerSheetManager =
|
|
1122
|
+
CustomerSheetManager(reactApplicationContext, params, customerAdapterOverrides, promise).also {
|
|
1123
|
+
registerStripeUIManager(it)
|
|
1161
1124
|
}
|
|
1162
|
-
}
|
|
1163
1125
|
}
|
|
1164
1126
|
|
|
1165
1127
|
@ReactMethod
|
|
@@ -1167,19 +1129,16 @@ class StripeSdkModule(
|
|
|
1167
1129
|
params: ReadableMap,
|
|
1168
1130
|
promise: Promise,
|
|
1169
1131
|
) {
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
}
|
|
1174
|
-
customerSheetFragment?.present(timeout, promise) ?: run {
|
|
1175
|
-
promise.resolve(CustomerSheetFragment.createMissingInitError())
|
|
1132
|
+
val timeout = params.getIntOrNull("timeout")?.toLong()
|
|
1133
|
+
customerSheetManager?.present(promise, timeout) ?: run {
|
|
1134
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1176
1135
|
}
|
|
1177
1136
|
}
|
|
1178
1137
|
|
|
1179
1138
|
@ReactMethod
|
|
1180
1139
|
override fun retrieveCustomerSheetPaymentOptionSelection(promise: Promise) {
|
|
1181
|
-
|
|
1182
|
-
promise.resolve(
|
|
1140
|
+
customerSheetManager?.retrievePaymentOptionSelection(promise) ?: run {
|
|
1141
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1183
1142
|
}
|
|
1184
1143
|
}
|
|
1185
1144
|
|
|
@@ -1188,7 +1147,7 @@ class StripeSdkModule(
|
|
|
1188
1147
|
paymentMethodJsonObjects: ReadableArray,
|
|
1189
1148
|
promise: Promise,
|
|
1190
1149
|
) {
|
|
1191
|
-
|
|
1150
|
+
customerSheetManager?.let { fragment ->
|
|
1192
1151
|
val paymentMethods = mutableListOf<PaymentMethod>()
|
|
1193
1152
|
for (paymentMethodJson in paymentMethodJsonObjects.toArrayList()) {
|
|
1194
1153
|
PaymentMethod.fromJson(JSONObject((paymentMethodJson as HashMap<*, *>)))?.let {
|
|
@@ -1202,7 +1161,7 @@ class StripeSdkModule(
|
|
|
1202
1161
|
}
|
|
1203
1162
|
fragment.customerAdapter?.fetchPaymentMethodsCallback?.complete(paymentMethods)
|
|
1204
1163
|
} ?: run {
|
|
1205
|
-
promise.resolve(
|
|
1164
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1206
1165
|
return
|
|
1207
1166
|
}
|
|
1208
1167
|
}
|
|
@@ -1212,7 +1171,7 @@ class StripeSdkModule(
|
|
|
1212
1171
|
paymentMethodJson: ReadableMap,
|
|
1213
1172
|
promise: Promise,
|
|
1214
1173
|
) {
|
|
1215
|
-
|
|
1174
|
+
customerSheetManager?.let {
|
|
1216
1175
|
val paymentMethod =
|
|
1217
1176
|
PaymentMethod.fromJson(JSONObject(paymentMethodJson.toHashMap() as HashMap<*, *>))
|
|
1218
1177
|
if (paymentMethod == null) {
|
|
@@ -1224,7 +1183,7 @@ class StripeSdkModule(
|
|
|
1224
1183
|
}
|
|
1225
1184
|
it.customerAdapter?.attachPaymentMethodCallback?.complete(paymentMethod)
|
|
1226
1185
|
} ?: run {
|
|
1227
|
-
promise.resolve(
|
|
1186
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1228
1187
|
return
|
|
1229
1188
|
}
|
|
1230
1189
|
}
|
|
@@ -1234,7 +1193,7 @@ class StripeSdkModule(
|
|
|
1234
1193
|
paymentMethodJson: ReadableMap,
|
|
1235
1194
|
promise: Promise,
|
|
1236
1195
|
) {
|
|
1237
|
-
|
|
1196
|
+
customerSheetManager?.let {
|
|
1238
1197
|
val paymentMethod =
|
|
1239
1198
|
PaymentMethod.fromJson(JSONObject(paymentMethodJson.toHashMap() as HashMap<*, *>))
|
|
1240
1199
|
if (paymentMethod == null) {
|
|
@@ -1246,17 +1205,17 @@ class StripeSdkModule(
|
|
|
1246
1205
|
}
|
|
1247
1206
|
it.customerAdapter?.detachPaymentMethodCallback?.complete(paymentMethod)
|
|
1248
1207
|
} ?: run {
|
|
1249
|
-
promise.resolve(
|
|
1208
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1250
1209
|
return
|
|
1251
1210
|
}
|
|
1252
1211
|
}
|
|
1253
1212
|
|
|
1254
1213
|
@ReactMethod
|
|
1255
1214
|
override fun customerAdapterSetSelectedPaymentOptionCallback(promise: Promise) {
|
|
1256
|
-
|
|
1215
|
+
customerSheetManager?.let {
|
|
1257
1216
|
it.customerAdapter?.setSelectedPaymentOptionCallback?.complete(Unit)
|
|
1258
1217
|
} ?: run {
|
|
1259
|
-
promise.resolve(
|
|
1218
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1260
1219
|
return
|
|
1261
1220
|
}
|
|
1262
1221
|
}
|
|
@@ -1266,10 +1225,10 @@ class StripeSdkModule(
|
|
|
1266
1225
|
paymentOption: String?,
|
|
1267
1226
|
promise: Promise,
|
|
1268
1227
|
) {
|
|
1269
|
-
|
|
1228
|
+
customerSheetManager?.let {
|
|
1270
1229
|
it.customerAdapter?.fetchSelectedPaymentOptionCallback?.complete(paymentOption)
|
|
1271
1230
|
} ?: run {
|
|
1272
|
-
promise.resolve(
|
|
1231
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1273
1232
|
return
|
|
1274
1233
|
}
|
|
1275
1234
|
}
|
|
@@ -1279,29 +1238,27 @@ class StripeSdkModule(
|
|
|
1279
1238
|
clientSecret: String,
|
|
1280
1239
|
promise: Promise,
|
|
1281
1240
|
) {
|
|
1282
|
-
|
|
1241
|
+
customerSheetManager?.let {
|
|
1283
1242
|
it.customerAdapter?.setupIntentClientSecretForCustomerAttachCallback?.complete(clientSecret)
|
|
1284
1243
|
} ?: run {
|
|
1285
|
-
promise.resolve(
|
|
1244
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1286
1245
|
return
|
|
1287
1246
|
}
|
|
1288
1247
|
}
|
|
1289
1248
|
|
|
1290
|
-
@OptIn(ExperimentalCustomerSessionApi::class)
|
|
1291
1249
|
@ReactMethod
|
|
1292
1250
|
override fun clientSecretProviderSetupIntentClientSecretCallback(
|
|
1293
1251
|
setupIntentClientSecret: String,
|
|
1294
1252
|
promise: Promise,
|
|
1295
1253
|
) {
|
|
1296
|
-
|
|
1254
|
+
customerSheetManager?.let {
|
|
1297
1255
|
it.customerSessionProvider?.provideSetupIntentClientSecretCallback?.complete(setupIntentClientSecret)
|
|
1298
1256
|
} ?: run {
|
|
1299
|
-
promise.resolve(
|
|
1257
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1300
1258
|
return
|
|
1301
1259
|
}
|
|
1302
1260
|
}
|
|
1303
1261
|
|
|
1304
|
-
@OptIn(ExperimentalCustomerSessionApi::class)
|
|
1305
1262
|
@ReactMethod
|
|
1306
1263
|
override fun clientSecretProviderCustomerSessionClientSecretCallback(
|
|
1307
1264
|
customerSessionClientSecretJson: ReadableMap,
|
|
@@ -1318,15 +1275,15 @@ class StripeSdkModule(
|
|
|
1318
1275
|
return
|
|
1319
1276
|
}
|
|
1320
1277
|
|
|
1321
|
-
|
|
1278
|
+
customerSheetManager?.let {
|
|
1322
1279
|
it.customerSessionProvider?.providesCustomerSessionClientSecretCallback?.complete(
|
|
1323
1280
|
CustomerSheet.CustomerSessionClientSecret.create(
|
|
1324
|
-
customerId = customerId
|
|
1325
|
-
clientSecret = clientSecret
|
|
1281
|
+
customerId = customerId,
|
|
1282
|
+
clientSecret = clientSecret,
|
|
1326
1283
|
),
|
|
1327
1284
|
)
|
|
1328
1285
|
} ?: run {
|
|
1329
|
-
promise.resolve(
|
|
1286
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1330
1287
|
return
|
|
1331
1288
|
}
|
|
1332
1289
|
}
|