@stripe/stripe-react-native 0.52.0-crypto-onramp-2-private-beta.2 → 0.53.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/.idea/caches/deviceStreaming.xml +0 -13
- package/android/.idea/gradle.xml +1 -0
- package/android/.idea/misc.xml +1 -1
- package/android/build.gradle +0 -14
- package/android/gradle.properties +1 -1
- package/android/local.properties +2 -2
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +48 -25
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +14 -13
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +1 -19
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +0 -10
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +3 -12
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerDelegate.java +0 -12
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerInterface.java +0 -4
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -4
- package/ios/Mappers.swift +1 -134
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +0 -1
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +1 -7
- package/ios/StripeSdk.mm +7 -0
- package/ios/StripeSdkEmitter.swift +0 -4
- package/ios/StripeSdkImpl.swift +13 -584
- 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/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/events.js +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.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/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/PlatformPay.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.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/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/events.js +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.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/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/PlatformPay.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
- package/lib/typescript/src/events.d.ts +0 -3
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts +1 -0
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugin/withStripe.d.ts +0 -15
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +1 -0
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/types/Errors.d.ts +0 -5
- package/lib/typescript/src/types/Errors.d.ts.map +1 -1
- package/lib/typescript/src/types/PlatformPay.d.ts +7 -1
- package/lib/typescript/src/types/PlatformPay.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +1 -7
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +21 -2
- package/src/components/StripeProvider.tsx +0 -9
- package/src/events.ts +0 -22
- package/src/functions.ts +11 -0
- package/src/index.tsx +0 -1
- package/src/plugin/withStripe.ts +7 -104
- package/src/specs/NativeStripeSdkModule.ts +2 -0
- package/src/types/EmbeddedPaymentElement.tsx +7 -0
- package/src/types/Errors.ts +0 -6
- package/src/types/PlatformPay.ts +7 -1
- package/src/types/index.ts +0 -8
- package/stripe-react-native.podspec +8 -21
- package/.clang-format +0 -90
- package/.claude/settings.local.json +0 -11
- package/.editorconfig +0 -18
- package/.husky/pre-commit +0 -1
- package/.idea/GitLink.xml +0 -6
- package/.idea/codeStyles/Project.xml +0 -162
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/misc.xml +0 -851
- package/.idea/modules.xml +0 -8
- package/.idea/stripe-react-native.iml +0 -9
- package/.idea/vcs.xml +0 -6
- package/.vscode/settings.json +0 -3
- package/CHANGELOG.md +0 -931
- package/CLAUDE.md +0 -148
- package/android/.gradle/8.11.1/checksums/checksums.lock +0 -0
- package/android/.gradle/8.11.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.11.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.11.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.11.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.11.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/GitLink.xml +0 -6
- package/android/.idea/appInsightsSettings.xml +0 -23
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +0 -138
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +0 -110
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +0 -844
- package/ios/StripeOnrampSdk.h +0 -17
- package/ios/StripeOnrampSdk.mm +0 -144
- package/lib/commonjs/hooks/useOnramp.js +0 -2
- package/lib/commonjs/hooks/useOnramp.js.map +0 -1
- package/lib/commonjs/specs/NativeOnrampSdkModule.js +0 -2
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +0 -1
- package/lib/commonjs/types/Onramp.js +0 -2
- package/lib/commonjs/types/Onramp.js.map +0 -1
- package/lib/module/hooks/useOnramp.js +0 -2
- package/lib/module/hooks/useOnramp.js.map +0 -1
- package/lib/module/specs/NativeOnrampSdkModule.js +0 -2
- package/lib/module/specs/NativeOnrampSdkModule.js.map +0 -1
- package/lib/module/types/Onramp.js +0 -2
- package/lib/module/types/Onramp.js.map +0 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +0 -139
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +0 -1
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +0 -26
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +0 -1
- package/lib/typescript/src/types/Onramp.d.ts +0 -259
- package/lib/typescript/src/types/Onramp.d.ts.map +0 -1
- package/package-lock.json +0 -14114
- package/patches/README.md +0 -55
- package/patches/old-arch-codegen-fix.patch +0 -91
- package/src/hooks/useOnramp.tsx +0 -297
- package/src/specs/NativeOnrampSdkModule.ts +0 -41
- package/src/types/Onramp.ts +0 -297
package/ios/StripeSdkImpl.swift
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import PassKit
|
|
2
2
|
@_spi(DashboardOnly) @_spi(STP) import Stripe
|
|
3
3
|
@_spi(EmbeddedPaymentElementPrivateBeta) import StripePaymentSheet
|
|
4
|
-
@_spi(
|
|
5
|
-
@_spi(STP) import StripePaymentSheet
|
|
6
|
-
#if canImport(StripeCryptoOnramp)
|
|
7
|
-
@_spi(STP) import StripeCryptoOnramp
|
|
8
|
-
#endif
|
|
4
|
+
@_spi(STP) import StripePayments
|
|
9
5
|
import StripeFinancialConnections
|
|
10
6
|
import Foundation
|
|
11
7
|
|
|
@@ -14,7 +10,6 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
14
10
|
@objc public static let shared = StripeSdkImpl()
|
|
15
11
|
|
|
16
12
|
@objc public weak var emitter: StripeSdkEmitter? = nil
|
|
17
|
-
@objc public weak var onrampEmitter: StripeOnrampSdkEmitter? = nil
|
|
18
13
|
weak var cardFieldView: CardFieldView? = nil
|
|
19
14
|
weak var cardFormView: CardFormView? = nil
|
|
20
15
|
|
|
@@ -70,11 +65,6 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
70
65
|
var setupIntentClientSecretForCustomerAttachCallback: ((String) -> Void)? = nil
|
|
71
66
|
var customPaymentMethodResultCallback: ((PaymentSheetResult) -> Void)?
|
|
72
67
|
|
|
73
|
-
#if canImport(StripeCryptoOnramp)
|
|
74
|
-
var cryptoOnrampCoordinator: CryptoOnrampCoordinator?
|
|
75
|
-
var cryptoOnrampCheckoutClientSecretContinuation: CheckedContinuation<String, Error>?
|
|
76
|
-
#endif
|
|
77
|
-
|
|
78
68
|
var embeddedInstance: EmbeddedPaymentElement? = nil
|
|
79
69
|
lazy var embeddedInstanceDelegate = StripeSdkEmbeddedPaymentElementDelegate(sdkImpl: self)
|
|
80
70
|
|
|
@@ -180,7 +170,7 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
180
170
|
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
181
171
|
DispatchQueue.main.async {
|
|
182
172
|
if (self.paymentSheetFlowController != nil) {
|
|
183
|
-
self.paymentSheetFlowController?.confirm(from: UIApplication.shared.
|
|
173
|
+
self.paymentSheetFlowController?.confirm(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController()) { paymentResult in
|
|
184
174
|
switch paymentResult {
|
|
185
175
|
case .completed:
|
|
186
176
|
resolve([])
|
|
@@ -219,7 +209,7 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
219
209
|
}
|
|
220
210
|
}
|
|
221
211
|
DispatchQueue.main.async {
|
|
222
|
-
paymentSheetViewController = UIApplication.shared.
|
|
212
|
+
paymentSheetViewController = UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController()
|
|
223
213
|
if let paymentSheetFlowController = self.paymentSheetFlowController {
|
|
224
214
|
paymentSheetFlowController.presentPaymentOptions(from: findViewControllerPresenter(from: paymentSheetViewController!)
|
|
225
215
|
) { didCancel in
|
|
@@ -442,7 +432,7 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
442
432
|
if let applePaymentAuthorizationController = self.applePaymentAuthorizationController {
|
|
443
433
|
applePaymentAuthorizationController.delegate = self
|
|
444
434
|
DispatchQueue.main.async {
|
|
445
|
-
let vc = findViewControllerPresenter(from: UIApplication.shared.
|
|
435
|
+
let vc = findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController())
|
|
446
436
|
vc.present(
|
|
447
437
|
applePaymentAuthorizationController,
|
|
448
438
|
animated: true,
|
|
@@ -775,7 +765,7 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
775
765
|
clientSecret: clientSecret as String,
|
|
776
766
|
returnURL: connectionsReturnURL,
|
|
777
767
|
params: collectParams,
|
|
778
|
-
from: findViewControllerPresenter(from: UIApplication.shared.
|
|
768
|
+
from: findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController()),
|
|
779
769
|
onEvent: onEvent
|
|
780
770
|
) { intent, error in
|
|
781
771
|
if let error = error {
|
|
@@ -802,7 +792,7 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
802
792
|
clientSecret: clientSecret as String,
|
|
803
793
|
returnURL: connectionsReturnURL,
|
|
804
794
|
params: collectParams,
|
|
805
|
-
from: findViewControllerPresenter(from: UIApplication.shared.
|
|
795
|
+
from: findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController()),
|
|
806
796
|
onEvent: onEvent
|
|
807
797
|
) { intent, error in
|
|
808
798
|
if let error = error {
|
|
@@ -1160,550 +1150,15 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
1160
1150
|
#endif
|
|
1161
1151
|
}
|
|
1162
1152
|
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
config: NSDictionary,
|
|
1153
|
+
@objc(setFinancialConnectionsForceNativeFlow:resolver:rejecter:)
|
|
1154
|
+
public func setFinancialConnectionsForceNativeFlow(
|
|
1155
|
+
enabled: Bool,
|
|
1167
1156
|
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1168
1157
|
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1169
|
-
)
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
let appearance: LinkAppearance = if let appearanceParams = config["appearance"] as? [String: Any?] {
|
|
1175
|
-
Mappers.mapToLinkAppearance(appearanceParams)
|
|
1176
|
-
} else {
|
|
1177
|
-
LinkAppearance()
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
let cryptoCustomerId = config["cryptoCustomerId"] as? String
|
|
1181
|
-
|
|
1182
|
-
Task {
|
|
1183
|
-
do {
|
|
1184
|
-
cryptoOnrampCoordinator = try await CryptoOnrampCoordinator.create(appearance: appearance, cryptoCustomerID: cryptoCustomerId)
|
|
1185
|
-
resolve([:]) // Return empty object on success
|
|
1186
|
-
} catch {
|
|
1187
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1188
|
-
resolve(["error": errorResult["error"]!])
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
@objc(hasLinkAccount:resolver:rejecter:)
|
|
1194
|
-
public func hasLinkAccount(
|
|
1195
|
-
email: String,
|
|
1196
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1197
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1198
|
-
) -> Void {
|
|
1199
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1200
|
-
return
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
Task {
|
|
1204
|
-
do {
|
|
1205
|
-
let hasLinkAccount = try await coordinator.hasLinkAccount(with: email)
|
|
1206
|
-
resolve(["hasLinkAccount": hasLinkAccount])
|
|
1207
|
-
} catch {
|
|
1208
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1209
|
-
resolve(["error": errorResult["error"]!])
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
@objc(registerLinkUser:resolver:rejecter:)
|
|
1215
|
-
public func registerLinkUser(
|
|
1216
|
-
info: NSDictionary,
|
|
1217
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1218
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1219
|
-
) -> Void {
|
|
1220
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1221
|
-
return
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
let email = info["email"] as? String ?? ""
|
|
1225
|
-
let phone = info["phone"] as? String ?? ""
|
|
1226
|
-
let country = info["country"] as? String ?? ""
|
|
1227
|
-
let fullName = info["fullName"] as? String
|
|
1228
|
-
|
|
1229
|
-
Task {
|
|
1230
|
-
do {
|
|
1231
|
-
let customerId = try await coordinator.registerLinkUser(email: email, fullName: fullName, phone: phone, country: country)
|
|
1232
|
-
resolve(["customerId": customerId])
|
|
1233
|
-
} catch {
|
|
1234
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1235
|
-
resolve(["error": errorResult["error"]!])
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
@objc(authenticateUser:rejecter:)
|
|
1241
|
-
public func authenticateUser(
|
|
1242
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1243
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1244
|
-
) -> Void {
|
|
1245
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1246
|
-
return
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
Task {
|
|
1250
|
-
do {
|
|
1251
|
-
let presentingViewController = await MainActor.run {
|
|
1252
|
-
findViewControllerPresenter(from: UIApplication.shared.rootViewControllerWithFallback())
|
|
1253
|
-
}
|
|
1254
|
-
let result = try await coordinator.authenticateUser(from: presentingViewController)
|
|
1255
|
-
switch result {
|
|
1256
|
-
case let .completed(customerId):
|
|
1257
|
-
resolve(["customerId": customerId])
|
|
1258
|
-
case .canceled:
|
|
1259
|
-
let errorResult = Errors.createError(ErrorType.Canceled, "Authentication was cancelled")
|
|
1260
|
-
resolve(["error": errorResult["error"]!])
|
|
1261
|
-
}
|
|
1262
|
-
} catch {
|
|
1263
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1264
|
-
resolve(["error": errorResult["error"]!])
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
@objc(registerWalletAddress:network:resolver:rejecter:)
|
|
1270
|
-
public func registerWalletAddress(
|
|
1271
|
-
address: String,
|
|
1272
|
-
network: String,
|
|
1273
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1274
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1275
|
-
) -> Void {
|
|
1276
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1277
|
-
return
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
guard let cryptoNetwork = CryptoNetwork(rawValue: network as String) else {
|
|
1281
|
-
let errorResult = Errors.createError(ErrorType.Unknown, "Invalid network: \(network)")
|
|
1282
|
-
resolve(["error": errorResult["error"]!])
|
|
1283
|
-
return
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
Task {
|
|
1287
|
-
do {
|
|
1288
|
-
try await coordinator.registerWalletAddress(walletAddress: address, network: cryptoNetwork)
|
|
1289
|
-
resolve([:]) // Return empty object on success
|
|
1290
|
-
} catch {
|
|
1291
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1292
|
-
resolve(["error": errorResult["error"]!])
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
@objc(attachKycInfo:resolver:rejecter:)
|
|
1298
|
-
public func attachKycInfo(
|
|
1299
|
-
info: NSDictionary,
|
|
1300
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1301
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1302
|
-
) -> Void {
|
|
1303
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1304
|
-
return
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
guard let kycInfoDictionary = info as? [String: Any?] else {
|
|
1308
|
-
let errorResult = Errors.createError(ErrorType.Failed, "Unexpected format of KYC info dictionary. Expected String keys.")
|
|
1309
|
-
resolve(["error": errorResult["error"]!])
|
|
1310
|
-
return
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
Task {
|
|
1314
|
-
do {
|
|
1315
|
-
let kycInfo = try Mappers.mapToKycInfo(kycInfoDictionary)
|
|
1316
|
-
try await coordinator.attachKYCInfo(info: kycInfo)
|
|
1317
|
-
resolve([:]) // Return empty object on success
|
|
1318
|
-
} catch {
|
|
1319
|
-
if let missingFieldError = error as? Mappers.KycInfoError, case let .missingRequiredField(field) = missingFieldError {
|
|
1320
|
-
let errorResult = Errors.createError(ErrorType.Unknown, "Missing required field: \(field)")
|
|
1321
|
-
resolve(["error": errorResult["error"]!])
|
|
1322
|
-
} else {
|
|
1323
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1324
|
-
resolve(["error": errorResult["error"]!])
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
@objc(updatePhoneNumber:resolver:rejecter:)
|
|
1331
|
-
public func updatePhoneNumber(
|
|
1332
|
-
phone: String,
|
|
1333
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1334
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1335
|
-
) -> Void {
|
|
1336
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1337
|
-
return
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
Task {
|
|
1341
|
-
do {
|
|
1342
|
-
try await coordinator.updatePhoneNumber(to: phone)
|
|
1343
|
-
resolve([:]) // Return empty object on success
|
|
1344
|
-
} catch {
|
|
1345
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1346
|
-
resolve(["error": errorResult["error"]!])
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
@objc(logout:rejecter:)
|
|
1352
|
-
public func logout(
|
|
1353
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1354
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1355
|
-
) -> Void {
|
|
1356
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1357
|
-
return
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
Task {
|
|
1361
|
-
do {
|
|
1362
|
-
try await coordinator.logOut()
|
|
1363
|
-
resolve([:]) // Return empty object on success
|
|
1364
|
-
} catch {
|
|
1365
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1366
|
-
resolve(["error": errorResult["error"]!])
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
@objc(verifyIdentity:rejecter:)
|
|
1372
|
-
public func verifyIdentity(
|
|
1373
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1374
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1375
|
-
) -> Void {
|
|
1376
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1377
|
-
return
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
Task {
|
|
1381
|
-
do {
|
|
1382
|
-
let presentingViewController = await MainActor.run {
|
|
1383
|
-
findViewControllerPresenter(from: UIApplication.shared.rootViewControllerWithFallback())
|
|
1384
|
-
}
|
|
1385
|
-
let result = try await coordinator.verifyIdentity(from: presentingViewController)
|
|
1386
|
-
switch result {
|
|
1387
|
-
case .completed:
|
|
1388
|
-
resolve([:]) // Return empty object on success
|
|
1389
|
-
case .canceled:
|
|
1390
|
-
resolve(["error": Errors.createError(ErrorType.Canceled, "Identity verification was cancelled")["error"]!])
|
|
1391
|
-
}
|
|
1392
|
-
} catch {
|
|
1393
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1394
|
-
resolve(["error": errorResult["error"]!])
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
@objc(collectPaymentMethod:platformPayParams:resolver:rejecter:)
|
|
1400
|
-
public func collectPaymentMethod(
|
|
1401
|
-
paymentMethod: String,
|
|
1402
|
-
platformPayParams: NSDictionary,
|
|
1403
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1404
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1405
|
-
) -> Void {
|
|
1406
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1407
|
-
return
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
var paymentMethodType: PaymentMethodType?
|
|
1411
|
-
switch paymentMethod {
|
|
1412
|
-
case "Card":
|
|
1413
|
-
paymentMethodType = .card
|
|
1414
|
-
case "BankAccount":
|
|
1415
|
-
paymentMethodType = .bankAccount
|
|
1416
|
-
case "PlatformPay":
|
|
1417
|
-
guard let applePayParams = platformPayParams["applePay"] as? NSDictionary else {
|
|
1418
|
-
resolve(Errors.createError(ErrorType.Failed, "You must provide the `applePay` parameter."))
|
|
1419
|
-
return
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
let (error, paymentRequest) = ApplePayUtils.createPaymentRequest(merchantIdentifier: merchantIdentifier, params: applePayParams)
|
|
1423
|
-
if let paymentRequest {
|
|
1424
|
-
paymentMethodType = .applePay(paymentRequest: paymentRequest)
|
|
1425
|
-
} else {
|
|
1426
|
-
resolve(Errors.createError(ErrorType.Failed, "Unable to create Apple Pay payment request: \(String(describing: error))"))
|
|
1427
|
-
return
|
|
1428
|
-
}
|
|
1429
|
-
default:
|
|
1430
|
-
resolve(Errors.createError(ErrorType.Failed, "Unsupported payment method: \(paymentMethod)"))
|
|
1431
|
-
return
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
guard let paymentMethodType else {
|
|
1435
|
-
// In all non-assignment branches above, we've already called `resolve` with error, so simply return.
|
|
1436
|
-
return
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
Task {
|
|
1440
|
-
do {
|
|
1441
|
-
let presentingViewController = await MainActor.run {
|
|
1442
|
-
findViewControllerPresenter(from: UIApplication.shared.rootViewControllerWithFallback())
|
|
1443
|
-
}
|
|
1444
|
-
if let result = try await coordinator.collectPaymentMethod(type: paymentMethodType, from: presentingViewController) {
|
|
1445
|
-
let displayData = Mappers.paymentMethodDisplayDataToMap(result)
|
|
1446
|
-
resolve(["displayData": displayData])
|
|
1447
|
-
} else {
|
|
1448
|
-
let errorResult = Errors.createError(ErrorType.Canceled, "Payment collection was cancelled")
|
|
1449
|
-
resolve(["error": errorResult["error"]!])
|
|
1450
|
-
}
|
|
1451
|
-
} catch {
|
|
1452
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1453
|
-
resolve(["error": errorResult["error"]!])
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
@objc(createCryptoPaymentToken:rejecter:)
|
|
1459
|
-
public func createCryptoPaymentToken(
|
|
1460
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1461
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1462
|
-
) -> Void {
|
|
1463
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1464
|
-
return
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1467
|
-
Task {
|
|
1468
|
-
do {
|
|
1469
|
-
let token = try await coordinator.createCryptoPaymentToken()
|
|
1470
|
-
resolve(["cryptoPaymentToken": token])
|
|
1471
|
-
} catch {
|
|
1472
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1473
|
-
resolve(["error": errorResult["error"]!])
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
@objc(performCheckout:resolver:rejecter:)
|
|
1479
|
-
public func performCheckout(
|
|
1480
|
-
onrampSessionId: String,
|
|
1481
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1482
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1483
|
-
) -> Void {
|
|
1484
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1485
|
-
return
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
Task {
|
|
1489
|
-
do {
|
|
1490
|
-
let result = try await coordinator.performCheckout(onrampSessionId: onrampSessionId, authenticationContext: self) { [weak self] onrampSessionId in
|
|
1491
|
-
self?.onrampEmitter?.emitOnCheckoutClientSecretRequested(["onrampSessionId": onrampSessionId])
|
|
1492
|
-
|
|
1493
|
-
let clientSecret = try await withCheckedThrowingContinuation { [weak self] continuation in
|
|
1494
|
-
self?.cryptoOnrampCheckoutClientSecretContinuation = continuation
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
return clientSecret
|
|
1498
|
-
}
|
|
1499
|
-
switch result {
|
|
1500
|
-
case .completed:
|
|
1501
|
-
resolve([:]) // Return empty object on success
|
|
1502
|
-
case .canceled:
|
|
1503
|
-
let errorResult = Errors.createError(ErrorType.Canceled, "Checkout was cancelled")
|
|
1504
|
-
resolve(["error": errorResult["error"]!])
|
|
1505
|
-
}
|
|
1506
|
-
} catch {
|
|
1507
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1508
|
-
resolve(["error": errorResult["error"]!])
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
@objc(provideCheckoutClientSecret:)
|
|
1514
|
-
public func provideCheckoutClientSecret(clientSecret: String?) {
|
|
1515
|
-
if let clientSecret {
|
|
1516
|
-
cryptoOnrampCheckoutClientSecretContinuation?.resume(returning: clientSecret)
|
|
1517
|
-
} else {
|
|
1518
|
-
let error = NSError(
|
|
1519
|
-
domain: ErrorType.Failed,
|
|
1520
|
-
code: -1,
|
|
1521
|
-
userInfo: [NSLocalizedDescriptionKey: "Failed to provide checkout client secret"]
|
|
1522
|
-
)
|
|
1523
|
-
cryptoOnrampCheckoutClientSecretContinuation?.resume(throwing: error)
|
|
1524
|
-
}
|
|
1525
|
-
cryptoOnrampCheckoutClientSecretContinuation = nil
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
@objc(onrampAuthorize:resolver:rejecter:)
|
|
1529
|
-
public func onrampAuthorize(
|
|
1530
|
-
linkAuthIntentId: String,
|
|
1531
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1532
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1533
|
-
) -> Void {
|
|
1534
|
-
guard isPublishableKeyAvailable(resolve), let coordinator = requireOnrampCoordinator(resolve) else {
|
|
1535
|
-
return
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
Task {
|
|
1539
|
-
do {
|
|
1540
|
-
let presentingViewController = await MainActor.run {
|
|
1541
|
-
findViewControllerPresenter(from: UIApplication.shared.rootViewControllerWithFallback())
|
|
1542
|
-
}
|
|
1543
|
-
let authorizationResult = try await coordinator.authorize(linkAuthIntentId: linkAuthIntentId, from: presentingViewController)
|
|
1544
|
-
switch authorizationResult {
|
|
1545
|
-
case let .consented(customerId):
|
|
1546
|
-
resolve(["status": "Consented", "customerId": customerId])
|
|
1547
|
-
case .denied:
|
|
1548
|
-
resolve(["status": "Denied"])
|
|
1549
|
-
case.canceled:
|
|
1550
|
-
let errorResult = Errors.createError(ErrorType.Canceled, "Authorization was cancelled")
|
|
1551
|
-
resolve(["error": errorResult["error"]!])
|
|
1552
|
-
}
|
|
1553
|
-
} catch {
|
|
1554
|
-
let errorResult = Errors.createError(ErrorType.Failed, error)
|
|
1555
|
-
resolve(["error": errorResult["error"]!])
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
@objc(getCryptoTokenDisplayData:resolver:rejecter:)
|
|
1561
|
-
public func getCryptoTokenDisplayData(
|
|
1562
|
-
token: NSDictionary,
|
|
1563
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
1564
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1565
|
-
) -> Void {
|
|
1566
|
-
let label = STPPaymentMethodType.link.displayName
|
|
1567
|
-
|
|
1568
|
-
if let cardDetails = token["card"] as? [String: Any] {
|
|
1569
|
-
let brand = cardDetails["brand"] as? String ?? ""
|
|
1570
|
-
let funding = cardDetails["funding"] as? String ?? ""
|
|
1571
|
-
let last4 = cardDetails["last4"] as? String ?? ""
|
|
1572
|
-
|
|
1573
|
-
let cardBrand = STPCard.brand(from: brand)
|
|
1574
|
-
let icon = STPImageLibrary.cardBrandImage(for: cardBrand)
|
|
1575
|
-
let brandName = STPCardBrandUtilities.stringFrom(cardBrand)
|
|
1576
|
-
|
|
1577
|
-
let mappedFunding = STPCardFundingType(funding)
|
|
1578
|
-
let formattedBrandName = String(format: mappedFunding.displayNameWithBrand, brandName ?? "")
|
|
1579
|
-
let sublabel = "\(formattedBrandName) •••• \(last4)"
|
|
1580
|
-
|
|
1581
|
-
let result = PaymentMethodDisplayData(icon: icon, label: label, sublabel: sublabel)
|
|
1582
|
-
let displayData = Mappers.paymentMethodDisplayDataToMap(result)
|
|
1583
|
-
|
|
1584
|
-
resolve(["displayData": displayData])
|
|
1585
|
-
} else if let bankDetails = token["us_bank_account"] as? [String: Any] {
|
|
1586
|
-
let bankName = bankDetails["bank_name"] as? String ?? ""
|
|
1587
|
-
let last4 = bankDetails["last4"] as? String ?? ""
|
|
1588
|
-
|
|
1589
|
-
let iconCode = PaymentSheetImageLibrary.bankIconCode(for: bankName)
|
|
1590
|
-
let icon = PaymentSheetImageLibrary.bankIcon(for: iconCode, iconStyle: .filled)
|
|
1591
|
-
let sublabel = "\(bankName) •••• \(last4)"
|
|
1592
|
-
|
|
1593
|
-
let result = PaymentMethodDisplayData(icon: icon, label: label, sublabel: sublabel)
|
|
1594
|
-
let displayData = Mappers.paymentMethodDisplayDataToMap(result)
|
|
1595
|
-
|
|
1596
|
-
resolve(["displayData": displayData])
|
|
1597
|
-
} else {
|
|
1598
|
-
let errorResult = Errors.createError(ErrorType.Unknown, "'type' parameter not unknown.")
|
|
1599
|
-
resolve(["error": errorResult["error"]!])
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
|
|
1603
|
-
/// Checks for a `publishableKey`. Calls the resolve block with an error when one doesn’t exist.
|
|
1604
|
-
/// - Parameter resolve: The resolve block that is called with an error if no `publishableKey` is found.
|
|
1605
|
-
/// - Returns: `true` if a `publishableKey` was found. `false` otherwise.
|
|
1606
|
-
private func isPublishableKeyAvailable(_ resolve: @escaping RCTPromiseResolveBlock) -> Bool {
|
|
1607
|
-
if STPAPIClient.shared.publishableKey == nil {
|
|
1608
|
-
resolve(["error": Errors.MISSING_INIT_ERROR["error"]!])
|
|
1609
|
-
return false
|
|
1610
|
-
} else {
|
|
1611
|
-
return true
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
/// Returns the shared `CryptoOnrampCoordinator`, calling the resolve block with an error if CryptoOnramp has not yet been configured.
|
|
1616
|
-
/// - Parameter resolve: The resolve block that is called with an error if CryptoOnramp has not yet been configured.
|
|
1617
|
-
/// - Returns: The shared `CryptoOnrampCoordinator`, nor `nil` if CryptoOnramp has not yet been configured.
|
|
1618
|
-
private func requireOnrampCoordinator(_ resolve: @escaping RCTPromiseResolveBlock) -> CryptoOnrampCoordinator? {
|
|
1619
|
-
guard let coordinator = cryptoOnrampCoordinator else {
|
|
1620
|
-
let errorResult = Errors.createError(ErrorType.Failed, "CryptoOnramp not configured. Call -configureOnramp:resolver:rejecter: successfully first")
|
|
1621
|
-
resolve(["error": errorResult["error"]!])
|
|
1622
|
-
return nil
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
return coordinator
|
|
1626
|
-
}
|
|
1627
|
-
#else
|
|
1628
|
-
@objc(configureOnramp:resolver:rejecter:)
|
|
1629
|
-
public func configureOnramp(config: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1630
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1631
|
-
}
|
|
1632
|
-
|
|
1633
|
-
@objc(hasLinkAccount:resolver:rejecter:)
|
|
1634
|
-
public func hasLinkAccount(email: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1635
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
@objc(registerLinkUser:resolver:rejecter:)
|
|
1639
|
-
public func registerLinkUser(info: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1640
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
@objc(authenticateUser:rejecter:)
|
|
1644
|
-
public func authenticateUser(resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1645
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
@objc(registerWalletAddress:network:resolver:rejecter:)
|
|
1649
|
-
public func registerWalletAddress(address: String, network: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1650
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
@objc(attachKycInfo:resolver:rejecter:)
|
|
1654
|
-
public func attachKycInfo(info: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1655
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1656
|
-
}
|
|
1657
|
-
|
|
1658
|
-
@objc(updatePhoneNumber:resolver:rejecter:)
|
|
1659
|
-
public func updatePhoneNumber(phone: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1660
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
@objc(logout:rejecter:)
|
|
1664
|
-
public func logout(resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1665
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
@objc(verifyIdentity:rejecter:)
|
|
1669
|
-
public func verifyIdentity(resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1670
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
@objc(collectPaymentMethod:platformPayParams:resolver:rejecter:)
|
|
1674
|
-
public func collectPaymentMethod(paymentMethod: String, platformPayParams: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1675
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
@objc(createCryptoPaymentToken:rejecter:)
|
|
1679
|
-
public func createCryptoPaymentToken(resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1680
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
@objc(performCheckout:resolver:rejecter:)
|
|
1684
|
-
public func performCheckout(onrampSessionId: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1685
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
@objc(provideCheckoutClientSecret:)
|
|
1689
|
-
public func provideCheckoutClientSecret(clientSecret: String?) {
|
|
1690
|
-
// no-op when Onramp is unavailable
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
@objc(onrampAuthorize:resolver:rejecter:)
|
|
1694
|
-
public func onrampAuthorize(linkAuthIntentId: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1695
|
-
resolveWithCryptoOnrampNotAvailableError(resolve)
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
|
-
@objc(getCryptoTokenDisplayData:)
|
|
1699
|
-
public func getCryptoTokenDisplayData(token: NSDictionary) -> [String: Any]? {
|
|
1700
|
-
return nil
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
private func resolveWithCryptoOnrampNotAvailableError(_ resolver: @escaping RCTPromiseResolveBlock) {
|
|
1704
|
-
resolver(Errors.createError(ErrorType.Failed, "StripeCryptoOnramp is not available. To enable, add the 'stripe-react-native/Onramp' subspec to your Podfile."))
|
|
1158
|
+
) {
|
|
1159
|
+
UserDefaults.standard.set(enabled, forKey: "FINANCIAL_CONNECTIONS_EXAMPLE_APP_ENABLE_NATIVE")
|
|
1160
|
+
resolve(nil)
|
|
1705
1161
|
}
|
|
1706
|
-
#endif
|
|
1707
1162
|
|
|
1708
1163
|
public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
|
|
1709
1164
|
confirmPaymentResolver?(Errors.createError(ErrorType.Canceled, "FPX Payment has been canceled"))
|
|
@@ -1766,15 +1221,9 @@ func findViewControllerPresenter(from uiViewController: UIViewController) -> UIV
|
|
|
1766
1221
|
return presentingViewController
|
|
1767
1222
|
}
|
|
1768
1223
|
|
|
1769
|
-
extension UIApplication {
|
|
1770
|
-
func rootViewControllerWithFallback() -> UIViewController {
|
|
1771
|
-
return delegate?.window??.rootViewController ?? UIViewController()
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
1224
|
extension StripeSdkImpl: STPAuthenticationContext {
|
|
1776
1225
|
public func authenticationPresentingViewController() -> UIViewController {
|
|
1777
|
-
return findViewControllerPresenter(from: UIApplication.shared.
|
|
1226
|
+
return findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController())
|
|
1778
1227
|
}
|
|
1779
1228
|
}
|
|
1780
1229
|
|
|
@@ -1819,23 +1268,3 @@ extension FinancialConnectionsSheet.Configuration {
|
|
|
1819
1268
|
self.init(style: style)
|
|
1820
1269
|
}
|
|
1821
1270
|
}
|
|
1822
|
-
|
|
1823
|
-
private extension STPCardFundingType {
|
|
1824
|
-
var displayNameWithBrand: String {
|
|
1825
|
-
switch self {
|
|
1826
|
-
case .credit: String.Localized.Funding.credit
|
|
1827
|
-
case .debit: String.Localized.Funding.debit
|
|
1828
|
-
case .prepaid: String.Localized.Funding.prepaid
|
|
1829
|
-
case .other: String.Localized.Funding.default
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
init(_ typeString: String) {
|
|
1834
|
-
self = switch typeString {
|
|
1835
|
-
case "debit": .debit
|
|
1836
|
-
case "credit": .credit
|
|
1837
|
-
case "prepaid": .prepaid
|
|
1838
|
-
default: .other
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.AddToWalletButton=AddToWalletButton;var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _NativeAddToWalletButton=_interopRequireDefault(require("../specs/NativeAddToWalletButton"));var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="/Users/
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.AddToWalletButton=AddToWalletButton;var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _NativeAddToWalletButton=_interopRequireDefault(require("../specs/NativeAddToWalletButton"));var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="/Users/tianzhao/stripe/stripe-react-native/src/components/AddToWalletButton.tsx";var _excluded=["onComplete"];function AddToWalletButton(_ref){var onComplete=_ref.onComplete,props=(0,_objectWithoutProperties2.default)(_ref,_excluded);return(0,_jsxRuntime.jsx)(_NativeAddToWalletButton.default,Object.assign({},props,{onCompleteAction:function onCompleteAction(value){return onComplete(value.nativeEvent);}}));}
|
|
2
2
|
//# sourceMappingURL=AddToWalletButton.js.map
|