@stripe/stripe-react-native 0.59.2 → 0.61.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/README.md +1 -1
- package/android/gradle.properties +2 -2
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +123 -89
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +12 -9
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +6 -5
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +54 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +36 -39
- package/ios/Mappers.swift +66 -37
- package/ios/StripeSdkImpl.swift +14 -5
- package/ios/StripeSwiftInterop.h +1 -1
- package/jest/mock.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/connect/Components.js +1 -1
- package/lib/commonjs/connect/Components.js.map +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/commonjs/connect/EmbeddedComponent.js +1 -1
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -1
- package/lib/commonjs/connect/NavigationBar.js +1 -1
- package/lib/commonjs/connect/NavigationBar.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/hooks/useOnramp.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +1 -1
- package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/Onramp.js +1 -1
- package/lib/commonjs/types/Onramp.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/connect/Components.js +1 -1
- package/lib/module/connect/Components.js.map +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/module/connect/EmbeddedComponent.js +1 -1
- package/lib/module/connect/EmbeddedComponent.js.map +1 -1
- package/lib/module/connect/ModalCloseButton.js +1 -1
- package/lib/module/connect/ModalCloseButton.js.map +1 -1
- package/lib/module/connect/NavigationBar.js +1 -1
- package/lib/module/connect/NavigationBar.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/hooks/useOnramp.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeNavigationBar.js +1 -1
- package/lib/module/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/Onramp.js +1 -1
- package/lib/module/types/Onramp.js.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +41 -10
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +0 -5
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useOnramp.tsx +7 -3
- package/src/types/Onramp.ts +42 -9
- package/src/types/index.ts +0 -6
- package/stripe-react-native.podspec +1 -1
package/README.md
CHANGED
|
@@ -100,7 +100,7 @@ implementation 'com.google.android.material:material:<version>'
|
|
|
100
100
|
|
|
101
101
|
#### iOS
|
|
102
102
|
|
|
103
|
-
The Stripe React Native SDK
|
|
103
|
+
The Stripe React Native SDK supports all [Apple supported Xcode versions](https://developer.apple.com/news/upcoming-requirements/) and is compatible with apps targeting iOS 13 or above. For iOS 12 support, please use [`@stripe/stripe-react-native@0.19.0`](https://github.com/stripe/stripe-react-native/releases/tag/v0.19.0).
|
|
104
104
|
|
|
105
105
|
The SDK uses TypeScript features available in Babel version `7.9.0` and above.
|
|
106
106
|
Alternatively use the `plugin-transform-typescript` plugin in your project.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
StripeSdk_kotlinVersion=
|
|
1
|
+
StripeSdk_kotlinVersion=2.3.10
|
|
2
2
|
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=
|
|
6
|
+
StripeSdk_stripeVersion=23.1.+
|
|
@@ -78,7 +78,7 @@ class FakeOnrampSdkModule(
|
|
|
78
78
|
updatedAddress: ReadableMap?,
|
|
79
79
|
promise: Promise,
|
|
80
80
|
) {
|
|
81
|
-
promise
|
|
81
|
+
promise.resolveNotImplemented()
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
@ReactMethod
|
|
@@ -126,7 +126,7 @@ class FakeOnrampSdkModule(
|
|
|
126
126
|
token: ReadableMap,
|
|
127
127
|
promise: Promise,
|
|
128
128
|
) {
|
|
129
|
-
promise
|
|
129
|
+
promise.resolveNotImplemented()
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
@ReactMethod
|
|
@@ -97,17 +97,6 @@ class PaymentSheetManager(
|
|
|
97
97
|
)
|
|
98
98
|
return
|
|
99
99
|
}
|
|
100
|
-
val primaryButtonLabel = arguments.getString("primaryButtonLabel")
|
|
101
|
-
val googlePayConfig = buildGooglePayConfig(arguments.getMap("googlePay"))
|
|
102
|
-
val linkConfig = buildLinkConfig(arguments.getMap("link"))
|
|
103
|
-
val allowsDelayedPaymentMethods = arguments.getBooleanOr("allowsDelayedPaymentMethods", false)
|
|
104
|
-
val billingDetailsMap = arguments.getMap("defaultBillingDetails")
|
|
105
|
-
val billingConfigParams = arguments.getMap("billingDetailsCollectionConfiguration")
|
|
106
|
-
val paymentMethodOrder = arguments.getStringList("paymentMethodOrder")
|
|
107
|
-
val allowsRemovalOfLastSavedPaymentMethod =
|
|
108
|
-
arguments.getBooleanOr("allowsRemovalOfLastSavedPaymentMethod", true)
|
|
109
|
-
val opensCardScannerAutomatically =
|
|
110
|
-
arguments.getBooleanOr("opensCardScannerAutomatically", false)
|
|
111
100
|
paymentIntentClientSecret = arguments.getString("paymentIntentClientSecret").orEmpty()
|
|
112
101
|
setupIntentClientSecret = arguments.getString("setupIntentClientSecret").orEmpty()
|
|
113
102
|
intentConfiguration =
|
|
@@ -121,26 +110,6 @@ class PaymentSheetManager(
|
|
|
121
110
|
// Determine which callback type to use based on what's provided
|
|
122
111
|
val intentConfigMap = arguments.getMap("intentConfiguration")
|
|
123
112
|
val useConfirmationTokenCallback = intentConfigMap?.hasKey("confirmationTokenConfirmHandler") == true
|
|
124
|
-
val appearance =
|
|
125
|
-
try {
|
|
126
|
-
buildPaymentSheetAppearance(arguments.getMap("appearance"), context)
|
|
127
|
-
} catch (error: PaymentSheetAppearanceException) {
|
|
128
|
-
initPromise.resolve(createError(ErrorType.Failed.toString(), error))
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
val customerConfiguration =
|
|
133
|
-
try {
|
|
134
|
-
buildCustomerConfiguration(arguments)
|
|
135
|
-
} catch (error: PaymentSheetException) {
|
|
136
|
-
initPromise.resolve(createError(ErrorType.Failed.toString(), error))
|
|
137
|
-
return
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
val shippingDetails =
|
|
141
|
-
arguments.getMap("defaultShippingDetails")?.let {
|
|
142
|
-
AddressSheetView.buildAddressDetails(it)
|
|
143
|
-
}
|
|
144
113
|
|
|
145
114
|
val paymentOptionCallback =
|
|
146
115
|
PaymentOptionResultCallback { paymentOptionResult ->
|
|
@@ -208,8 +177,6 @@ class PaymentSheetManager(
|
|
|
208
177
|
|
|
209
178
|
is PaymentSheetResult.Completed -> {
|
|
210
179
|
resolvePaymentResult(Arguments.createMap())
|
|
211
|
-
paymentSheet = null
|
|
212
|
-
flowController = null
|
|
213
180
|
}
|
|
214
181
|
}
|
|
215
182
|
}
|
|
@@ -268,6 +235,117 @@ class PaymentSheetManager(
|
|
|
268
235
|
}
|
|
269
236
|
}
|
|
270
237
|
|
|
238
|
+
if (arguments.getBooleanOr("customFlow", false)) {
|
|
239
|
+
if (flowController == null) {
|
|
240
|
+
flowController =
|
|
241
|
+
if (intentConfiguration != null) {
|
|
242
|
+
val builder =
|
|
243
|
+
PaymentSheet.FlowController
|
|
244
|
+
.Builder(
|
|
245
|
+
resultCallback = paymentResultCallback,
|
|
246
|
+
paymentOptionResultCallback = paymentOptionCallback,
|
|
247
|
+
)
|
|
248
|
+
if (useConfirmationTokenCallback) {
|
|
249
|
+
builder.createIntentCallback(createConfirmationTokenCallback)
|
|
250
|
+
} else {
|
|
251
|
+
builder.createIntentCallback(createIntentCallback)
|
|
252
|
+
}
|
|
253
|
+
builder
|
|
254
|
+
.confirmCustomPaymentMethodCallback(this)
|
|
255
|
+
.build(activity)
|
|
256
|
+
} else {
|
|
257
|
+
PaymentSheet.FlowController
|
|
258
|
+
.Builder(
|
|
259
|
+
resultCallback = paymentResultCallback,
|
|
260
|
+
paymentOptionResultCallback = paymentOptionCallback,
|
|
261
|
+
).confirmCustomPaymentMethodCallback(this)
|
|
262
|
+
.build(activity)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
if (paymentSheet == null) {
|
|
267
|
+
paymentSheet =
|
|
268
|
+
if (intentConfiguration != null) {
|
|
269
|
+
val builder = PaymentSheet.Builder(paymentResultCallback)
|
|
270
|
+
if (useConfirmationTokenCallback) {
|
|
271
|
+
builder.createIntentCallback(createConfirmationTokenCallback)
|
|
272
|
+
} else {
|
|
273
|
+
builder.createIntentCallback(createIntentCallback)
|
|
274
|
+
}
|
|
275
|
+
@SuppressLint("RestrictedApi")
|
|
276
|
+
builder
|
|
277
|
+
.confirmCustomPaymentMethodCallback(this)
|
|
278
|
+
.build(activity, signal)
|
|
279
|
+
} else {
|
|
280
|
+
@SuppressLint("RestrictedApi")
|
|
281
|
+
PaymentSheet
|
|
282
|
+
.Builder(paymentResultCallback)
|
|
283
|
+
.confirmCustomPaymentMethodCallback(this)
|
|
284
|
+
.build(activity, signal)
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
configure(arguments, initPromise)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
override fun onDestroy() {
|
|
292
|
+
flowController = null
|
|
293
|
+
paymentSheet = null
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
fun configure(
|
|
297
|
+
args: ReadableMap,
|
|
298
|
+
promise: Promise,
|
|
299
|
+
) {
|
|
300
|
+
val merchantDisplayName = args.getString("merchantDisplayName").orEmpty()
|
|
301
|
+
if (merchantDisplayName.isEmpty()) {
|
|
302
|
+
promise.resolve(
|
|
303
|
+
createError(ErrorType.Failed.toString(), "merchantDisplayName cannot be empty or null."),
|
|
304
|
+
)
|
|
305
|
+
return
|
|
306
|
+
}
|
|
307
|
+
val primaryButtonLabel = args.getString("primaryButtonLabel")
|
|
308
|
+
val googlePayConfig = buildGooglePayConfig(args.getMap("googlePay"))
|
|
309
|
+
val linkConfig = buildLinkConfig(args.getMap("link"))
|
|
310
|
+
val allowsDelayedPaymentMethods = args.getBooleanOr("allowsDelayedPaymentMethods", false)
|
|
311
|
+
val billingDetailsMap = args.getMap("defaultBillingDetails")
|
|
312
|
+
val billingConfigParams = args.getMap("billingDetailsCollectionConfiguration")
|
|
313
|
+
val paymentMethodOrder = args.getStringList("paymentMethodOrder")
|
|
314
|
+
val allowsRemovalOfLastSavedPaymentMethod =
|
|
315
|
+
args.getBooleanOr("allowsRemovalOfLastSavedPaymentMethod", true)
|
|
316
|
+
val opensCardScannerAutomatically =
|
|
317
|
+
args.getBooleanOr("opensCardScannerAutomatically", false)
|
|
318
|
+
paymentIntentClientSecret = args.getString("paymentIntentClientSecret").orEmpty()
|
|
319
|
+
setupIntentClientSecret = args.getString("setupIntentClientSecret").orEmpty()
|
|
320
|
+
intentConfiguration =
|
|
321
|
+
try {
|
|
322
|
+
buildIntentConfiguration(args.getMap("intentConfiguration"))
|
|
323
|
+
} catch (error: PaymentSheetException) {
|
|
324
|
+
promise.resolve(createError(ErrorType.Failed.toString(), error))
|
|
325
|
+
return
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
val appearance =
|
|
329
|
+
try {
|
|
330
|
+
buildPaymentSheetAppearance(args.getMap("appearance"), context)
|
|
331
|
+
} catch (error: PaymentSheetAppearanceException) {
|
|
332
|
+
promise.resolve(createError(ErrorType.Failed.toString(), error))
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
val customerConfiguration =
|
|
337
|
+
try {
|
|
338
|
+
buildCustomerConfiguration(args)
|
|
339
|
+
} catch (error: PaymentSheetException) {
|
|
340
|
+
promise.resolve(createError(ErrorType.Failed.toString(), error))
|
|
341
|
+
return
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
val shippingDetails =
|
|
345
|
+
args.getMap("defaultShippingDetails")?.let {
|
|
346
|
+
AddressSheetView.buildAddressDetails(it)
|
|
347
|
+
}
|
|
348
|
+
|
|
271
349
|
val billingDetailsConfig = buildBillingDetailsCollectionConfiguration(billingConfigParams)
|
|
272
350
|
|
|
273
351
|
val defaultBillingDetails = buildBillingDetails(billingDetailsMap)
|
|
@@ -283,72 +361,28 @@ class PaymentSheetManager(
|
|
|
283
361
|
.link(linkConfig)
|
|
284
362
|
.billingDetailsCollectionConfiguration(billingDetailsConfig)
|
|
285
363
|
.preferredNetworks(
|
|
286
|
-
mapToPreferredNetworks(
|
|
364
|
+
mapToPreferredNetworks(args.getIntegerList("preferredNetworks")),
|
|
287
365
|
).allowsRemovalOfLastSavedPaymentMethod(allowsRemovalOfLastSavedPaymentMethod)
|
|
288
366
|
.opensCardScannerAutomatically(opensCardScannerAutomatically)
|
|
289
|
-
.cardBrandAcceptance(mapToCardBrandAcceptance(
|
|
367
|
+
.cardBrandAcceptance(mapToCardBrandAcceptance(args))
|
|
290
368
|
.apply {
|
|
291
|
-
mapToAllowedCardFundingTypes(
|
|
292
|
-
}.customPaymentMethods(parseCustomPaymentMethods(
|
|
369
|
+
mapToAllowedCardFundingTypes(args)?.let { allowedCardFundingTypes(it) }
|
|
370
|
+
}.customPaymentMethods(parseCustomPaymentMethods(args.getMap("customPaymentMethodConfiguration")))
|
|
293
371
|
|
|
294
372
|
primaryButtonLabel?.let { configurationBuilder.primaryButtonLabel(it) }
|
|
295
373
|
paymentMethodOrder?.let { configurationBuilder.paymentMethodOrder(it) }
|
|
296
374
|
|
|
297
375
|
configurationBuilder.paymentMethodLayout(
|
|
298
|
-
mapToPaymentMethodLayout(
|
|
376
|
+
mapToPaymentMethodLayout(args.getString("paymentMethodLayout")),
|
|
299
377
|
)
|
|
300
378
|
|
|
301
|
-
mapToTermsDisplay(
|
|
379
|
+
mapToTermsDisplay(args)?.let { configurationBuilder.termsDisplay(it) }
|
|
302
380
|
|
|
303
381
|
paymentSheetConfiguration = configurationBuilder.build()
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
flowController =
|
|
307
|
-
if (intentConfiguration != null) {
|
|
308
|
-
val builder =
|
|
309
|
-
PaymentSheet.FlowController
|
|
310
|
-
.Builder(
|
|
311
|
-
resultCallback = paymentResultCallback,
|
|
312
|
-
paymentOptionResultCallback = paymentOptionCallback,
|
|
313
|
-
)
|
|
314
|
-
if (useConfirmationTokenCallback) {
|
|
315
|
-
builder.createIntentCallback(createConfirmationTokenCallback)
|
|
316
|
-
} else {
|
|
317
|
-
builder.createIntentCallback(createIntentCallback)
|
|
318
|
-
}
|
|
319
|
-
builder
|
|
320
|
-
.confirmCustomPaymentMethodCallback(this)
|
|
321
|
-
.build(activity)
|
|
322
|
-
} else {
|
|
323
|
-
PaymentSheet.FlowController
|
|
324
|
-
.Builder(
|
|
325
|
-
resultCallback = paymentResultCallback,
|
|
326
|
-
paymentOptionResultCallback = paymentOptionCallback,
|
|
327
|
-
).confirmCustomPaymentMethodCallback(this)
|
|
328
|
-
.build(activity)
|
|
329
|
-
}
|
|
330
|
-
configureFlowController()
|
|
382
|
+
if (args.getBooleanOr("customFlow", false)) {
|
|
383
|
+
configureFlowController(promise)
|
|
331
384
|
} else {
|
|
332
|
-
|
|
333
|
-
if (intentConfiguration != null) {
|
|
334
|
-
val builder = PaymentSheet.Builder(paymentResultCallback)
|
|
335
|
-
if (useConfirmationTokenCallback) {
|
|
336
|
-
builder.createIntentCallback(createConfirmationTokenCallback)
|
|
337
|
-
} else {
|
|
338
|
-
builder.createIntentCallback(createIntentCallback)
|
|
339
|
-
}
|
|
340
|
-
@SuppressLint("RestrictedApi")
|
|
341
|
-
builder
|
|
342
|
-
.confirmCustomPaymentMethodCallback(this)
|
|
343
|
-
.build(activity, signal)
|
|
344
|
-
} else {
|
|
345
|
-
@SuppressLint("RestrictedApi")
|
|
346
|
-
PaymentSheet
|
|
347
|
-
.Builder(paymentResultCallback)
|
|
348
|
-
.confirmCustomPaymentMethodCallback(this)
|
|
349
|
-
.build(activity, signal)
|
|
350
|
-
}
|
|
351
|
-
initPromise.resolve(Arguments.createMap())
|
|
385
|
+
promise.resolve(Arguments.createMap())
|
|
352
386
|
}
|
|
353
387
|
}
|
|
354
388
|
|
|
@@ -433,10 +467,10 @@ class PaymentSheetManager(
|
|
|
433
467
|
flowController?.confirm()
|
|
434
468
|
}
|
|
435
469
|
|
|
436
|
-
private fun configureFlowController() {
|
|
470
|
+
private fun configureFlowController(promise: Promise) {
|
|
437
471
|
val onFlowControllerConfigure =
|
|
438
472
|
PaymentSheet.FlowController.ConfigCallback { success, error ->
|
|
439
|
-
handleFlowControllerConfigured(success, error,
|
|
473
|
+
handleFlowControllerConfigured(success, error, promise, flowController)
|
|
440
474
|
}
|
|
441
475
|
|
|
442
476
|
if (!paymentIntentClientSecret.isNullOrEmpty()) {
|
|
@@ -458,7 +492,7 @@ class PaymentSheetManager(
|
|
|
458
492
|
callback = onFlowControllerConfigure,
|
|
459
493
|
)
|
|
460
494
|
} else {
|
|
461
|
-
|
|
495
|
+
promise.resolve(
|
|
462
496
|
createError(
|
|
463
497
|
ErrorType.Failed.toString(),
|
|
464
498
|
"One of `paymentIntentClientSecret`, `setupIntentClientSecret`, or `intentConfiguration` is required",
|
|
@@ -257,11 +257,14 @@ class StripeSdkModule(
|
|
|
257
257
|
params: ReadableMap,
|
|
258
258
|
promise: Promise,
|
|
259
259
|
) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
260
|
+
if (paymentSheetManager != null) {
|
|
261
|
+
paymentSheetManager?.configure(params, promise)
|
|
262
|
+
} else {
|
|
263
|
+
paymentSheetManager =
|
|
264
|
+
PaymentSheetManager(reactApplicationContext, params, promise).also {
|
|
265
|
+
registerStripeUIManager(it)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
@ReactMethod
|
|
@@ -1340,10 +1343,10 @@ class StripeSdkModule(
|
|
|
1340
1343
|
stripeAccountId = stripeAccountId,
|
|
1341
1344
|
callback =
|
|
1342
1345
|
object : com.stripe.android.ApiResultCallback<RadarSession> {
|
|
1343
|
-
override fun onSuccess(
|
|
1344
|
-
val
|
|
1345
|
-
|
|
1346
|
-
promise.resolve(
|
|
1346
|
+
override fun onSuccess(result: RadarSession) {
|
|
1347
|
+
val response = WritableNativeMap()
|
|
1348
|
+
response.putString("id", result.id)
|
|
1349
|
+
promise.resolve(response)
|
|
1347
1350
|
}
|
|
1348
1351
|
|
|
1349
1352
|
override fun onError(e: Exception) {
|
|
@@ -142,7 +142,8 @@ public abstract class NativeStripeSdkModuleSpec extends ReactContextBaseJavaModu
|
|
|
142
142
|
Map<String, Object> constants = getTypedExportedConstants();
|
|
143
143
|
if (ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD) {
|
|
144
144
|
Set<String> obligatoryFlowConstants = new HashSet<>(Arrays.asList(
|
|
145
|
-
"API_VERSIONS"
|
|
145
|
+
"API_VERSIONS",
|
|
146
|
+
"SYSTEM_INFO"
|
|
146
147
|
));
|
|
147
148
|
Set<String> optionalFlowConstants = new HashSet<>();
|
|
148
149
|
Set<String> undeclaredConstants = new HashSet<>(constants.keySet());
|
|
@@ -264,6 +265,10 @@ public abstract class NativeStripeSdkModuleSpec extends ReactContextBaseJavaModu
|
|
|
264
265
|
@DoNotStrip
|
|
265
266
|
public abstract void clearEmbeddedPaymentOption(double viewTag, Promise promise);
|
|
266
267
|
|
|
268
|
+
@ReactMethod
|
|
269
|
+
@DoNotStrip
|
|
270
|
+
public abstract void createRadarSession(Promise promise);
|
|
271
|
+
|
|
267
272
|
@ReactMethod
|
|
268
273
|
@DoNotStrip
|
|
269
274
|
public abstract void setFinancialConnectionsForceNativeFlow(boolean enabled, Promise promise);
|
|
@@ -295,8 +300,4 @@ public abstract class NativeStripeSdkModuleSpec extends ReactContextBaseJavaModu
|
|
|
295
300
|
@ReactMethod
|
|
296
301
|
@DoNotStrip
|
|
297
302
|
public abstract void removeListeners(double count);
|
|
298
|
-
|
|
299
|
-
@ReactMethod
|
|
300
|
-
@DoNotStrip
|
|
301
|
-
public abstract void createRadarSession(Promise promise);
|
|
302
303
|
}
|
|
@@ -4,6 +4,9 @@ import android.annotation.SuppressLint
|
|
|
4
4
|
import androidx.compose.ui.graphics.Color
|
|
5
5
|
import com.facebook.react.bridge.ReadableMap
|
|
6
6
|
import com.stripe.android.crypto.onramp.model.OnrampConfiguration
|
|
7
|
+
import com.stripe.android.crypto.onramp.model.PaymentMethodDisplayData
|
|
8
|
+
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
|
|
9
|
+
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher
|
|
7
10
|
import com.stripe.android.link.LinkAppearance
|
|
8
11
|
import com.stripe.android.link.LinkAppearance.Colors
|
|
9
12
|
import com.stripe.android.link.LinkAppearance.PrimaryButton
|
|
@@ -25,12 +28,55 @@ internal fun mapConfig(
|
|
|
25
28
|
|
|
26
29
|
val displayName = configMap.getString("merchantDisplayName") ?: ""
|
|
27
30
|
val cryptoCustomerId = configMap.getString("cryptoCustomerId")
|
|
31
|
+
val googlePayConfig = mapGooglePayConfig(configMap.getMap("googlePay"))
|
|
28
32
|
|
|
29
33
|
return OnrampConfiguration()
|
|
30
34
|
.merchantDisplayName(displayName)
|
|
31
35
|
.publishableKey(publishableKey)
|
|
32
36
|
.appearance(appearance)
|
|
33
37
|
.cryptoCustomerId(cryptoCustomerId)
|
|
38
|
+
.apply { googlePayConfig?.let { googlePayConfig(it) } }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@SuppressLint("RestrictedApi")
|
|
42
|
+
internal fun mapGooglePayConfig(params: ReadableMap?): GooglePayPaymentMethodLauncher.Config? {
|
|
43
|
+
if (params == null) return null
|
|
44
|
+
|
|
45
|
+
val testEnv = params.hasKey("testEnv") && params.getBoolean("testEnv")
|
|
46
|
+
val merchantCountryCode = params.getString("merchantCountryCode") ?: return null
|
|
47
|
+
val merchantName = params.getString("merchantName") ?: return null
|
|
48
|
+
val existingPaymentMethodRequired =
|
|
49
|
+
params.hasKey("existingPaymentMethodRequired") && params.getBoolean("existingPaymentMethodRequired")
|
|
50
|
+
|
|
51
|
+
val billingAddressConfig =
|
|
52
|
+
mapGooglePayBillingAddressConfig(params.getMap("billingAddressConfig"))
|
|
53
|
+
|
|
54
|
+
return GooglePayPaymentMethodLauncher.Config(
|
|
55
|
+
environment = if (testEnv) GooglePayEnvironment.Test else GooglePayEnvironment.Production,
|
|
56
|
+
merchantCountryCode = merchantCountryCode,
|
|
57
|
+
merchantName = merchantName,
|
|
58
|
+
billingAddressConfig = billingAddressConfig,
|
|
59
|
+
existingPaymentMethodRequired = existingPaymentMethodRequired,
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private fun mapGooglePayBillingAddressConfig(params: ReadableMap?): GooglePayPaymentMethodLauncher.BillingAddressConfig {
|
|
64
|
+
if (params == null) return GooglePayPaymentMethodLauncher.BillingAddressConfig()
|
|
65
|
+
|
|
66
|
+
val isRequired = params.hasKey("isRequired") && params.getBoolean("isRequired")
|
|
67
|
+
val format =
|
|
68
|
+
when (params.getString("format")) {
|
|
69
|
+
"Full" -> GooglePayPaymentMethodLauncher.BillingAddressConfig.Format.Full
|
|
70
|
+
else -> GooglePayPaymentMethodLauncher.BillingAddressConfig.Format.Min
|
|
71
|
+
}
|
|
72
|
+
val isPhoneNumberRequired =
|
|
73
|
+
params.hasKey("isPhoneNumberRequired") && params.getBoolean("isPhoneNumberRequired")
|
|
74
|
+
|
|
75
|
+
return GooglePayPaymentMethodLauncher.BillingAddressConfig(
|
|
76
|
+
isRequired = isRequired,
|
|
77
|
+
format = format,
|
|
78
|
+
isPhoneNumberRequired = isPhoneNumberRequired,
|
|
79
|
+
)
|
|
34
80
|
}
|
|
35
81
|
|
|
36
82
|
@SuppressLint("RestrictedApi")
|
|
@@ -101,3 +147,11 @@ internal fun mapAppearance(appearanceMap: ReadableMap): LinkAppearance {
|
|
|
101
147
|
.style(style)
|
|
102
148
|
.primaryButton(primaryButton)
|
|
103
149
|
}
|
|
150
|
+
|
|
151
|
+
@SuppressLint("RestrictedApi")
|
|
152
|
+
internal fun mapPaymentDetailsType(type: PaymentMethodDisplayData.Type): String =
|
|
153
|
+
when (type) {
|
|
154
|
+
PaymentMethodDisplayData.Type.Card -> "Card"
|
|
155
|
+
PaymentMethodDisplayData.Type.BankAccount -> "BankAccount"
|
|
156
|
+
PaymentMethodDisplayData.Type.GooglePay -> "GooglePay"
|
|
157
|
+
}
|
|
@@ -42,12 +42,11 @@ import com.stripe.android.crypto.onramp.model.OnrampTokenAuthenticationResult
|
|
|
42
42
|
import com.stripe.android.crypto.onramp.model.OnrampUpdatePhoneNumberResult
|
|
43
43
|
import com.stripe.android.crypto.onramp.model.OnrampVerifyIdentityResult
|
|
44
44
|
import com.stripe.android.crypto.onramp.model.OnrampVerifyKycInfoResult
|
|
45
|
-
import com.stripe.android.crypto.onramp.model.
|
|
45
|
+
import com.stripe.android.crypto.onramp.model.PaymentMethodSelection
|
|
46
46
|
import com.stripe.android.link.LinkController.PaymentMethodPreview
|
|
47
47
|
import com.stripe.android.link.PaymentMethodPreviewDetails
|
|
48
48
|
import com.stripe.android.model.CardBrand
|
|
49
49
|
import com.stripe.android.model.DateOfBirth
|
|
50
|
-
import com.stripe.android.paymentsheet.PaymentSheet
|
|
51
50
|
import kotlinx.coroutines.CompletableDeferred
|
|
52
51
|
import kotlinx.coroutines.CoroutineScope
|
|
53
52
|
import kotlinx.coroutines.Dispatchers
|
|
@@ -289,35 +288,8 @@ class OnrampSdkModule(
|
|
|
289
288
|
}
|
|
290
289
|
CoroutineScope(Dispatchers.IO).launch {
|
|
291
290
|
val firstName = kycInfo.getString("firstName")
|
|
292
|
-
if (firstName.isNullOrEmpty()) {
|
|
293
|
-
promise.resolve(
|
|
294
|
-
createError(
|
|
295
|
-
ErrorType.Unknown.toString(),
|
|
296
|
-
"Missing required field: firstName",
|
|
297
|
-
),
|
|
298
|
-
)
|
|
299
|
-
return@launch
|
|
300
|
-
}
|
|
301
291
|
val lastName = kycInfo.getString("lastName")
|
|
302
|
-
if (lastName.isNullOrEmpty()) {
|
|
303
|
-
promise.resolve(
|
|
304
|
-
createError(
|
|
305
|
-
ErrorType.Unknown.toString(),
|
|
306
|
-
"Missing required field: lastName",
|
|
307
|
-
),
|
|
308
|
-
)
|
|
309
|
-
return@launch
|
|
310
|
-
}
|
|
311
292
|
val idNumber = kycInfo.getString("idNumber")
|
|
312
|
-
if (idNumber.isNullOrEmpty()) {
|
|
313
|
-
promise.resolve(
|
|
314
|
-
createError(
|
|
315
|
-
ErrorType.Unknown.toString(),
|
|
316
|
-
"Missing required field: idNumber",
|
|
317
|
-
),
|
|
318
|
-
)
|
|
319
|
-
return@launch
|
|
320
|
-
}
|
|
321
293
|
|
|
322
294
|
val dateOfBirthMap = kycInfo.getMap("dateOfBirth")
|
|
323
295
|
val dob =
|
|
@@ -333,17 +305,11 @@ class OnrampSdkModule(
|
|
|
333
305
|
year = dateOfBirthMap.getInt("year"),
|
|
334
306
|
)
|
|
335
307
|
} else {
|
|
336
|
-
|
|
337
|
-
createError(
|
|
338
|
-
ErrorType.Unknown.toString(),
|
|
339
|
-
"Missing required field: dateOfBirth",
|
|
340
|
-
),
|
|
341
|
-
)
|
|
342
|
-
return@launch
|
|
308
|
+
null
|
|
343
309
|
}
|
|
344
310
|
|
|
345
311
|
val addressMap = kycInfo.getMap("address")
|
|
346
|
-
val addressObj = mapToPaymentSheetAddress(addressMap)
|
|
312
|
+
val addressObj = mapToPaymentSheetAddress(addressMap)
|
|
347
313
|
|
|
348
314
|
val kycInfoObj =
|
|
349
315
|
KycInfo(
|
|
@@ -431,8 +397,32 @@ class OnrampSdkModule(
|
|
|
431
397
|
|
|
432
398
|
val method =
|
|
433
399
|
when (paymentMethod) {
|
|
434
|
-
"Card" ->
|
|
435
|
-
"BankAccount" ->
|
|
400
|
+
"Card" -> PaymentMethodSelection.Card()
|
|
401
|
+
"BankAccount" -> PaymentMethodSelection.BankAccount()
|
|
402
|
+
"CardAndBankAccount" -> PaymentMethodSelection.CardAndBankAccount()
|
|
403
|
+
"PlatformPay" -> {
|
|
404
|
+
val googlePayParams =
|
|
405
|
+
platformPayParams.getMap("googlePay")
|
|
406
|
+
?: run {
|
|
407
|
+
promise.resolve(
|
|
408
|
+
createFailedError(
|
|
409
|
+
IllegalArgumentException("Missing googlePay params in platformPayParams"),
|
|
410
|
+
),
|
|
411
|
+
)
|
|
412
|
+
return
|
|
413
|
+
}
|
|
414
|
+
val currencyCode = googlePayParams.getString("currencyCode") ?: ""
|
|
415
|
+
val amount = googlePayParams.getDouble("amount").toLong()
|
|
416
|
+
val transactionId = googlePayParams.getString("transactionId")
|
|
417
|
+
val label = googlePayParams.getString("label")
|
|
418
|
+
|
|
419
|
+
PaymentMethodSelection.GooglePay(
|
|
420
|
+
currencyCode = currencyCode,
|
|
421
|
+
amount = amount,
|
|
422
|
+
transactionId = transactionId,
|
|
423
|
+
label = label,
|
|
424
|
+
)
|
|
425
|
+
}
|
|
436
426
|
else -> {
|
|
437
427
|
promise.resolve(
|
|
438
428
|
createFailedError(
|
|
@@ -596,6 +586,12 @@ class OnrampSdkModule(
|
|
|
596
586
|
displayData.putString("label", paymentDetails.label)
|
|
597
587
|
displayData.putString("sublabel", paymentDetails.sublabel)
|
|
598
588
|
|
|
589
|
+
if (token.hasKey("card")) {
|
|
590
|
+
displayData.putString("type", "Card")
|
|
591
|
+
} else if (token.hasKey("us_bank_account")) {
|
|
592
|
+
displayData.putString("type", "BankAccount")
|
|
593
|
+
}
|
|
594
|
+
|
|
599
595
|
promise.resolve(createResult("displayData", displayData))
|
|
600
596
|
}
|
|
601
597
|
}
|
|
@@ -709,6 +705,7 @@ class OnrampSdkModule(
|
|
|
709
705
|
displayData.putString("icon", iconDataUri)
|
|
710
706
|
displayData.putString("label", result.displayData.label)
|
|
711
707
|
result.displayData.sublabel?.let { displayData.putString("sublabel", it) }
|
|
708
|
+
displayData.putString("type", mapPaymentDetailsType(result.displayData.type))
|
|
712
709
|
|
|
713
710
|
promise.resolve(createResult("displayData", displayData))
|
|
714
711
|
}
|