@stripe/stripe-react-native 0.31.1 → 0.33.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/CHANGELOG.md +39 -1
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +6 -2
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +10 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +5 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +33 -5
- package/ios/ApplePayViewController.swift +24 -5
- package/ios/Mappers.swift +10 -8
- package/ios/StripeSdk+PaymentSheet.swift +4 -0
- package/ios/StripeSdk.swift +15 -11
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/types/NextAction.js.map +1 -1
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/PlatformPay.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/types/NextAction.js.map +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/PlatformPay.js.map +1 -1
- package/lib/typescript/src/types/NextAction.d.ts +4 -2
- package/lib/typescript/src/types/PaymentSheet.d.ts +6 -0
- package/lib/typescript/src/types/PlatformPay.d.ts +8 -3
- package/package.json +1 -1
- package/src/functions.ts +4 -2
- package/src/types/NextAction.ts +5 -2
- package/src/types/PaymentSheet.ts +6 -0
- package/src/types/PlatformPay.ts +8 -3
- package/stripe-react-native.podspec +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
## 0.
|
|
5
|
+
## 0.33.0 - 2023-09-22
|
|
6
|
+
|
|
7
|
+
**Features**
|
|
8
|
+
|
|
9
|
+
- Added the `amount` and `label` params to `initPaymentSheet`'s `googlePay` field configuration. Use this to diplay the amount for setup intents.
|
|
10
|
+
- Added the `amount` and `label` params `createPlatformPayPaymentMethod`, `confirmPlatformPayPayment`, and `confirmPlatformPaySetupIntent`.
|
|
11
|
+
- PaymentSheet now supports the following payment methods on both iOS and Android (previously some of the following were iOS only) for SetupIntents and PaymentIntents with setup for future usage:
|
|
12
|
+
- Alipay
|
|
13
|
+
- BECS Direct Debit
|
|
14
|
+
- Cash App Pay
|
|
15
|
+
- iDEAL
|
|
16
|
+
- SEPA
|
|
17
|
+
- Sofort
|
|
18
|
+
- Bancontact
|
|
19
|
+
- BLIK
|
|
20
|
+
- Boleto
|
|
21
|
+
- Revolut Pay
|
|
22
|
+
- OXXO (PaymentIntents only)
|
|
23
|
+
- Konbini (PaymentIntents only)
|
|
24
|
+
- PaymentSheet now supports the following payment methods on iOS only for SetupIntents and PaymentIntents with setup for future usage:
|
|
25
|
+
- PayNow
|
|
26
|
+
- PromptPay
|
|
27
|
+
|
|
28
|
+
**Fixes**
|
|
29
|
+
|
|
30
|
+
- Fixed an issue on iOS where the value for the `paymentMethod` field on the returned `paymentIntent` object from `confirmPlatformPayPayment` and the returned `setupIntent` object from `confirmPlatformPaySetupIntent` would be null.
|
|
31
|
+
|
|
32
|
+
## 0.32.0 - 2023-09-15
|
|
33
|
+
|
|
34
|
+
**Features**
|
|
35
|
+
|
|
36
|
+
- `createPlatformPayPaymentMethod` and `createPlatformPayToken` now also include an optional `shippingContact` field in their results. [#1500](https://github.com/stripe/stripe-react-native/pull/1500)
|
|
37
|
+
- Added the `removeSavedPaymentMethodMessage` field to `initPaymentSheet` to display a custom message when a saved payment method is removed. iOS Only. [#1498](https://github.com/stripe/stripe-react-native/pull/1498)
|
|
38
|
+
|
|
39
|
+
**Fixes**
|
|
40
|
+
|
|
41
|
+
- Fixed an issue on iOS where recollecting the CVC wouldn't work correctly. [#1501](https://github.com/stripe/stripe-react-native/pull/1501)
|
|
42
|
+
|
|
43
|
+
## 0.31.1 - 2023-09-08
|
|
6
44
|
|
|
7
45
|
**Features**
|
|
8
46
|
|
|
@@ -24,6 +24,8 @@ class GooglePayLauncherFragment : Fragment() {
|
|
|
24
24
|
private lateinit var mode: Mode
|
|
25
25
|
private lateinit var configuration: GooglePayLauncher.Config
|
|
26
26
|
private lateinit var currencyCode: String
|
|
27
|
+
private var amount: Int? = null
|
|
28
|
+
private var label: String? = null
|
|
27
29
|
private lateinit var callback: (result: GooglePayLauncher.Result?, error: WritableMap?) -> Unit
|
|
28
30
|
|
|
29
31
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
|
@@ -47,6 +49,8 @@ class GooglePayLauncherFragment : Fragment() {
|
|
|
47
49
|
this.mode = mode
|
|
48
50
|
this.callback = callback
|
|
49
51
|
this.currencyCode = googlePayParams.getString("currencyCode") ?: "USD"
|
|
52
|
+
this.amount = googlePayParams.getInt("amount")
|
|
53
|
+
this.label = googlePayParams.getString("label")
|
|
50
54
|
this.configuration = GooglePayLauncher.Config(
|
|
51
55
|
environment = if (googlePayParams.getBoolean("testEnv")) GooglePayEnvironment.Test else GooglePayEnvironment.Production,
|
|
52
56
|
merchantCountryCode = googlePayParams.getString("merchantCountryCode").orEmpty(),
|
|
@@ -89,10 +93,10 @@ class GooglePayLauncherFragment : Fragment() {
|
|
|
89
93
|
if (isReady) {
|
|
90
94
|
when (mode) {
|
|
91
95
|
Mode.ForSetup -> {
|
|
92
|
-
launcher.presentForSetupIntent(clientSecret, currencyCode)
|
|
96
|
+
launcher.presentForSetupIntent(clientSecret, currencyCode, amount?.toLong(), label)
|
|
93
97
|
}
|
|
94
98
|
Mode.ForPayment -> {
|
|
95
|
-
launcher.presentForPaymentIntent(clientSecret)
|
|
99
|
+
launcher.presentForPaymentIntent(clientSecret, label)
|
|
96
100
|
}
|
|
97
101
|
}
|
|
98
102
|
} else {
|
|
@@ -80,12 +80,14 @@ class GooglePayRequestHelper {
|
|
|
80
80
|
val countryCode = params.getString("merchantCountryCode").orEmpty()
|
|
81
81
|
val currencyCode = params.getString("currencyCode") ?: "USD"
|
|
82
82
|
val amount = params.getInt("amount")
|
|
83
|
+
val label = params.getString("label")
|
|
83
84
|
|
|
84
85
|
return GooglePayJsonFactory.TransactionInfo(
|
|
85
86
|
currencyCode = currencyCode,
|
|
86
87
|
totalPriceStatus = GooglePayJsonFactory.TransactionInfo.TotalPriceStatus.Estimated,
|
|
87
88
|
countryCode = countryCode,
|
|
88
89
|
totalPrice = amount,
|
|
90
|
+
totalPriceLabel = label,
|
|
89
91
|
checkoutOption = GooglePayJsonFactory.TransactionInfo.CheckoutOption.Default
|
|
90
92
|
)
|
|
91
93
|
}
|
|
@@ -134,6 +136,11 @@ class GooglePayRequestHelper {
|
|
|
134
136
|
|
|
135
137
|
override fun onSuccess(result: PaymentMethod) {
|
|
136
138
|
promiseResult.putMap("paymentMethod", mapFromPaymentMethod(result))
|
|
139
|
+
GooglePayResult.fromJson(paymentInformation).let {
|
|
140
|
+
if (it.shippingInformation != null) {
|
|
141
|
+
promiseResult.putMap("shippingContact", mapFromShippingContact(it))
|
|
142
|
+
}
|
|
143
|
+
}
|
|
137
144
|
promise.resolve(promiseResult)
|
|
138
145
|
}
|
|
139
146
|
}
|
|
@@ -146,6 +153,9 @@ class GooglePayRequestHelper {
|
|
|
146
153
|
val promiseResult = WritableNativeMap()
|
|
147
154
|
googlePayResult.token?.let {
|
|
148
155
|
promiseResult.putMap("token", mapFromToken(it))
|
|
156
|
+
if (googlePayResult.shippingInformation != null) {
|
|
157
|
+
promiseResult.putMap("shippingContact", mapFromShippingContact(googlePayResult))
|
|
158
|
+
}
|
|
149
159
|
promise.resolve(promiseResult)
|
|
150
160
|
} ?: run {
|
|
151
161
|
promise.resolve(createError("Failed", "Unexpected response from Google Pay. No token was found."))
|
|
@@ -282,6 +282,8 @@ class PaymentLauncherFragment(
|
|
|
282
282
|
private fun isNextActionSuccessState(nextAction: StripeIntent.NextActionType?): Boolean {
|
|
283
283
|
return when (nextAction) {
|
|
284
284
|
StripeIntent.NextActionType.DisplayOxxoDetails,
|
|
285
|
+
StripeIntent.NextActionType.DisplayBoletoDetails,
|
|
286
|
+
StripeIntent.NextActionType.DisplayKonbiniDetails,
|
|
285
287
|
StripeIntent.NextActionType.VerifyWithMicrodeposits -> true
|
|
286
288
|
StripeIntent.NextActionType.RedirectToUrl,
|
|
287
289
|
StripeIntent.NextActionType.UseStripeSdk,
|
|
@@ -354,11 +354,15 @@ class PaymentSheetFragment(
|
|
|
354
354
|
val countryCode = params.getString("merchantCountryCode").orEmpty()
|
|
355
355
|
val currencyCode = params.getString("currencyCode").orEmpty()
|
|
356
356
|
val testEnv = params.getBoolean("testEnv")
|
|
357
|
+
val amount = params.getString("amount")?.toLongOrNull()
|
|
358
|
+
val label = params.getString("label")
|
|
357
359
|
|
|
358
360
|
return PaymentSheet.GooglePayConfiguration(
|
|
359
361
|
environment = if (testEnv) PaymentSheet.GooglePayConfiguration.Environment.Test else PaymentSheet.GooglePayConfiguration.Environment.Production,
|
|
360
362
|
countryCode = countryCode,
|
|
361
|
-
currencyCode = currencyCode
|
|
363
|
+
currencyCode = currencyCode,
|
|
364
|
+
amount = amount,
|
|
365
|
+
label = label
|
|
362
366
|
)
|
|
363
367
|
}
|
|
364
368
|
|
|
@@ -490,6 +490,18 @@ internal fun mapNextAction(type: NextActionType?, data: NextActionData?): Writab
|
|
|
490
490
|
NextActionType.CashAppRedirect, NextActionType.BlikAuthorize, NextActionType.UseStripeSdk, NextActionType.UpiAwaitNotification, null -> {
|
|
491
491
|
return null
|
|
492
492
|
}
|
|
493
|
+
NextActionType.DisplayBoletoDetails -> {
|
|
494
|
+
(data as? NextActionData.DisplayBoletoDetails)?.let {
|
|
495
|
+
nextActionMap.putString("type", "boletoVoucher")
|
|
496
|
+
nextActionMap.putString("voucherURL", it.hostedVoucherUrl)
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
NextActionType.DisplayKonbiniDetails -> {
|
|
500
|
+
(data as? NextActionData.DisplayKonbiniDetails)?.let {
|
|
501
|
+
nextActionMap.putString("type", "konbiniVoucher")
|
|
502
|
+
nextActionMap.putString("voucherURL", it.hostedVoucherUrl)
|
|
503
|
+
}
|
|
504
|
+
}
|
|
493
505
|
}
|
|
494
506
|
return nextActionMap
|
|
495
507
|
}
|
|
@@ -807,11 +819,8 @@ internal fun mapFromSetupIntentResult(setupIntent: SetupIntent): WritableMap {
|
|
|
807
819
|
map.putMap("lastSetupError", setupError)
|
|
808
820
|
}
|
|
809
821
|
|
|
810
|
-
setupIntent.paymentMethodTypes
|
|
811
|
-
|
|
812
|
-
code == it.code
|
|
813
|
-
}
|
|
814
|
-
type?.let {
|
|
822
|
+
for (code in setupIntent.paymentMethodTypes) {
|
|
823
|
+
PaymentMethod.Type.fromCode(code)?.let {
|
|
815
824
|
paymentMethodTypes.pushString(mapPaymentMethodType(it))
|
|
816
825
|
}
|
|
817
826
|
}
|
|
@@ -881,3 +890,22 @@ fun toBundleObject(readableMap: ReadableMap?): Bundle {
|
|
|
881
890
|
}
|
|
882
891
|
return result
|
|
883
892
|
}
|
|
893
|
+
|
|
894
|
+
internal fun mapFromShippingContact(googlePayResult: GooglePayResult): WritableMap {
|
|
895
|
+
val map = WritableNativeMap()
|
|
896
|
+
map.putString("emailAddress", googlePayResult.email)
|
|
897
|
+
val name = WritableNativeMap()
|
|
898
|
+
googlePayResult.name
|
|
899
|
+
name.putString("givenName", googlePayResult.shippingInformation?.name)
|
|
900
|
+
map.putMap("name", name)
|
|
901
|
+
map.putString("phoneNumber", googlePayResult.phoneNumber)
|
|
902
|
+
val postalAddress = WritableNativeMap()
|
|
903
|
+
postalAddress.putString("city", googlePayResult.shippingInformation?.address?.city)
|
|
904
|
+
postalAddress.putString("country", googlePayResult.shippingInformation?.address?.country)
|
|
905
|
+
postalAddress.putString("postalCode", googlePayResult.shippingInformation?.address?.postalCode)
|
|
906
|
+
postalAddress.putString("state", googlePayResult.shippingInformation?.address?.state)
|
|
907
|
+
postalAddress.putString("street", googlePayResult.shippingInformation?.address?.line1 + "\n" + googlePayResult.shippingInformation?.address?.line2)
|
|
908
|
+
postalAddress.putString("isoCountryCode", googlePayResult.shippingInformation?.address?.country)
|
|
909
|
+
map.putMap("postalAddress", postalAddress)
|
|
910
|
+
return map
|
|
911
|
+
}
|
|
@@ -21,9 +21,13 @@ extension StripeSdk : PKPaymentAuthorizationViewControllerDelegate, STPApplePayC
|
|
|
21
21
|
if let error = error {
|
|
22
22
|
self.createPlatformPayPaymentMethodResolver?(Errors.createError(ErrorType.Failed, error))
|
|
23
23
|
} else {
|
|
24
|
-
|
|
25
|
-
"token": token != nil ? Mappers.mapFromToken(token: token!.splitApplePayAddressByNewline()) : [:]
|
|
24
|
+
var promiseResult = [
|
|
25
|
+
"token": token != nil ? Mappers.mapFromToken(token: token!.splitApplePayAddressByNewline()) : [:],
|
|
26
26
|
]
|
|
27
|
+
if let shippingContact = payment.shippingContact {
|
|
28
|
+
promiseResult["shippingContact"] = Mappers.mapFromShippingContact(shippingContact: shippingContact)
|
|
29
|
+
}
|
|
30
|
+
|
|
27
31
|
self.createPlatformPayPaymentMethodResolver?(promiseResult)
|
|
28
32
|
}
|
|
29
33
|
completion(PKPaymentAuthorizationResult.init(status: .success, errors: nil))
|
|
@@ -33,9 +37,13 @@ extension StripeSdk : PKPaymentAuthorizationViewControllerDelegate, STPApplePayC
|
|
|
33
37
|
if let error = error {
|
|
34
38
|
self.createPlatformPayPaymentMethodResolver?(Errors.createError(ErrorType.Failed, error))
|
|
35
39
|
} else {
|
|
36
|
-
|
|
40
|
+
var promiseResult = [
|
|
37
41
|
"paymentMethod": Mappers.mapFromPaymentMethod(paymentMethod?.splitApplePayAddressByNewline()) ?? [:]
|
|
38
42
|
]
|
|
43
|
+
if let shippingContact = payment.shippingContact {
|
|
44
|
+
promiseResult["shippingContact"] = Mappers.mapFromShippingContact(shippingContact: shippingContact)
|
|
45
|
+
}
|
|
46
|
+
|
|
39
47
|
self.createPlatformPayPaymentMethodResolver?(promiseResult)
|
|
40
48
|
}
|
|
41
49
|
completion(PKPaymentAuthorizationResult.init(status: .success, errors: nil))
|
|
@@ -157,6 +165,7 @@ extension StripeSdk : PKPaymentAuthorizationViewControllerDelegate, STPApplePayC
|
|
|
157
165
|
paymentInformation: PKPayment,
|
|
158
166
|
completion: @escaping STPIntentClientSecretCompletionBlock
|
|
159
167
|
) {
|
|
168
|
+
self.confirmApplePayPaymentMethod = paymentMethod
|
|
160
169
|
if let clientSecret = self.confirmApplePayPaymentClientSecret {
|
|
161
170
|
completion(clientSecret, nil)
|
|
162
171
|
} else if let clientSecret = self.confirmApplePaySetupClientSecret {
|
|
@@ -199,10 +208,15 @@ extension StripeSdk : PKPaymentAuthorizationViewControllerDelegate, STPApplePayC
|
|
|
199
208
|
}
|
|
200
209
|
|
|
201
210
|
if let paymentIntent = paymentIntent {
|
|
202
|
-
|
|
211
|
+
let result = Mappers.mapFromPaymentIntent(paymentIntent: paymentIntent)
|
|
212
|
+
if (paymentIntent.paymentMethod == nil) {
|
|
213
|
+
result.setValue(Mappers.mapFromPaymentMethod(self.confirmApplePayPaymentMethod), forKey: "paymentMethod")
|
|
214
|
+
}
|
|
215
|
+
resolve(Mappers.createResult("paymentIntent", result))
|
|
203
216
|
} else {
|
|
204
217
|
resolve(Mappers.createResult("paymentIntent", nil))
|
|
205
218
|
}
|
|
219
|
+
self.confirmApplePayPaymentMethod = nil
|
|
206
220
|
}
|
|
207
221
|
} else if let clientSecret = self.confirmApplePaySetupClientSecret {
|
|
208
222
|
STPAPIClient.shared.retrieveSetupIntent(withClientSecret: clientSecret) { (setupIntent, error) in
|
|
@@ -216,10 +230,15 @@ extension StripeSdk : PKPaymentAuthorizationViewControllerDelegate, STPApplePayC
|
|
|
216
230
|
}
|
|
217
231
|
|
|
218
232
|
if let setupIntent = setupIntent {
|
|
219
|
-
|
|
233
|
+
let result = Mappers.mapFromSetupIntent(setupIntent: setupIntent)
|
|
234
|
+
if (setupIntent.paymentMethod == nil) {
|
|
235
|
+
result.setValue(Mappers.mapFromPaymentMethod(self.confirmApplePayPaymentMethod), forKey: "paymentMethod")
|
|
236
|
+
}
|
|
237
|
+
resolve(Mappers.createResult("setupIntent", result))
|
|
220
238
|
} else {
|
|
221
239
|
resolve(Mappers.createResult("setupIntent", nil))
|
|
222
240
|
}
|
|
241
|
+
self.confirmApplePayPaymentMethod = nil
|
|
223
242
|
}
|
|
224
243
|
}
|
|
225
244
|
}
|
package/ios/Mappers.swift
CHANGED
|
@@ -451,14 +451,16 @@ class Mappers {
|
|
|
451
451
|
"voucherURL": it.oxxoDisplayDetails?.hostedVoucherURL.absoluteString ?? NSNull(),
|
|
452
452
|
"voucherNumber": it.oxxoDisplayDetails?.number ?? NSNull(),
|
|
453
453
|
]
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
454
|
+
case .boletoDisplayDetails:
|
|
455
|
+
return [
|
|
456
|
+
"type": "boletoVoucher",
|
|
457
|
+
"voucherURL": it.boletoDisplayDetails?.hostedVoucherURL.absoluteString ?? NSNull(),
|
|
458
|
+
]
|
|
459
|
+
case .konbiniDisplayDetails:
|
|
460
|
+
return [
|
|
461
|
+
"type": "konbiniVoucher",
|
|
462
|
+
"voucherURL": it.konbiniDisplayDetails?.hostedVoucherURL.absoluteString ?? NSNull(),
|
|
463
|
+
]
|
|
462
464
|
default: // .useStripeSDK, .BLIKAuthorize, .unknown
|
|
463
465
|
return nil
|
|
464
466
|
}
|
|
@@ -50,6 +50,10 @@ extension StripeSdk {
|
|
|
50
50
|
configuration.allowsDelayedPaymentMethods = allowsDelayedPaymentMethods
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
if let removeSavedPaymentMethodMessage = params["removeSavedPaymentMethodMessage"] as? String {
|
|
54
|
+
configuration.removeSavedPaymentMethodMessage = removeSavedPaymentMethodMessage
|
|
55
|
+
}
|
|
56
|
+
|
|
53
57
|
if let billingConfigParams = params["billingDetailsCollectionConfiguration"] as? [String: Any?] {
|
|
54
58
|
configuration.billingDetailsCollectionConfiguration.name = StripeSdk.mapToCollectionMode(str: billingConfigParams["name"] as? String)
|
|
55
59
|
configuration.billingDetailsCollectionConfiguration.phone = StripeSdk.mapToCollectionMode(str: billingConfigParams["phone"] as? String)
|
package/ios/StripeSdk.swift
CHANGED
|
@@ -22,6 +22,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
22
22
|
var confirmApplePayResolver: RCTPromiseResolveBlock? = nil
|
|
23
23
|
var confirmApplePayPaymentClientSecret: String? = nil
|
|
24
24
|
var confirmApplePaySetupClientSecret: String? = nil
|
|
25
|
+
var confirmApplePayPaymentMethod: STPPaymentMethod? = nil
|
|
25
26
|
|
|
26
27
|
var applePaymentAuthorizationController: PKPaymentAuthorizationViewController? = nil
|
|
27
28
|
var createPlatformPayPaymentMethodResolver: RCTPromiseResolveBlock? = nil
|
|
@@ -265,20 +266,20 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
265
266
|
if (paymentMethodType == .USBankAccount && paymentMethodData == nil) {
|
|
266
267
|
return STPSetupIntentConfirmParams(clientSecret: setupIntentClientSecret, paymentMethodType: .USBankAccount)
|
|
267
268
|
} else {
|
|
269
|
+
let factory = PaymentMethodFactory.init(paymentMethodData: paymentMethodData, options: options, cardFieldView: cardFieldView, cardFormView: cardFormView)
|
|
268
270
|
let parameters = STPSetupIntentConfirmParams(clientSecret: setupIntentClientSecret)
|
|
269
271
|
|
|
270
272
|
if let paymentMethodId = paymentMethodData?["paymentMethodId"] as? String {
|
|
271
273
|
parameters.paymentMethodID = paymentMethodId
|
|
272
274
|
} else {
|
|
273
|
-
let factory = PaymentMethodFactory.init(paymentMethodData: paymentMethodData, options: options, cardFieldView: cardFieldView, cardFormView: cardFormView)
|
|
274
275
|
do {
|
|
275
|
-
|
|
276
|
-
parameters.paymentMethodParams = paymentMethodParams
|
|
277
|
-
parameters.mandateData = factory.createMandateData()
|
|
276
|
+
parameters.paymentMethodParams = try factory.createParams(paymentMethodType: paymentMethodType)
|
|
278
277
|
} catch {
|
|
279
278
|
err = Errors.createError(ErrorType.Failed, error as NSError?)
|
|
280
279
|
}
|
|
281
280
|
}
|
|
281
|
+
|
|
282
|
+
parameters.mandateData = factory.createMandateData()
|
|
282
283
|
|
|
283
284
|
return parameters
|
|
284
285
|
}
|
|
@@ -842,7 +843,6 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
842
843
|
paymentMethodData: NSDictionary?,
|
|
843
844
|
options: NSDictionary
|
|
844
845
|
) -> (NSDictionary?, STPPaymentIntentParams) {
|
|
845
|
-
let factory = PaymentMethodFactory.init(paymentMethodData: paymentMethodData, options: options, cardFieldView: cardFieldView, cardFormView: cardFormView)
|
|
846
846
|
var err: NSDictionary? = nil
|
|
847
847
|
|
|
848
848
|
let paymentIntentParams: STPPaymentIntentParams = {
|
|
@@ -851,7 +851,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
851
851
|
return STPPaymentIntentParams(clientSecret: paymentIntentClientSecret, paymentMethodType: .USBankAccount)
|
|
852
852
|
} else {
|
|
853
853
|
guard let paymentMethodType = paymentMethodType else { return STPPaymentIntentParams(clientSecret: paymentIntentClientSecret) }
|
|
854
|
-
|
|
854
|
+
let factory = PaymentMethodFactory.init(paymentMethodData: paymentMethodData, options: options, cardFieldView: cardFieldView, cardFormView: cardFormView)
|
|
855
855
|
let paymentMethodId = paymentMethodData?["paymentMethodId"] as? String
|
|
856
856
|
let parameters = STPPaymentIntentParams(clientSecret: paymentIntentClientSecret)
|
|
857
857
|
|
|
@@ -859,15 +859,19 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
859
859
|
parameters.paymentMethodId = paymentMethodId
|
|
860
860
|
} else {
|
|
861
861
|
do {
|
|
862
|
-
|
|
863
|
-
let paymentMethodOptions = try factory.createOptions(paymentMethodType: paymentMethodType)
|
|
864
|
-
parameters.paymentMethodParams = paymentMethodParams
|
|
865
|
-
parameters.paymentMethodOptions = paymentMethodOptions
|
|
866
|
-
parameters.mandateData = factory.createMandateData()
|
|
862
|
+
parameters.paymentMethodParams = try factory.createParams(paymentMethodType: paymentMethodType)
|
|
867
863
|
} catch {
|
|
868
864
|
err = Errors.createError(ErrorType.Failed, error as NSError?)
|
|
869
865
|
}
|
|
870
866
|
}
|
|
867
|
+
|
|
868
|
+
do {
|
|
869
|
+
parameters.paymentMethodOptions = try factory.createOptions(paymentMethodType: paymentMethodType)
|
|
870
|
+
parameters.mandateData = factory.createMandateData()
|
|
871
|
+
} catch {
|
|
872
|
+
err = Errors.createError(ErrorType.Failed, error as NSError?)
|
|
873
|
+
}
|
|
874
|
+
|
|
871
875
|
return parameters
|
|
872
876
|
}
|
|
873
877
|
}()
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.verifyMicrodepositsForSetup=exports.verifyMicrodepositsForPayment=exports.updatePlatformPaySheet=exports.retrieveSetupIntent=exports.retrievePaymentIntent=exports.resetPaymentSheetCustomer=exports.presentPaymentSheet=exports.openPlatformPaySetup=exports.isPlatformPaySupported=exports.isCardInWallet=exports.initPaymentSheet=exports.handleURLCallback=exports.handleNextActionForSetup=exports.handleNextAction=exports.dismissPlatformPay=exports.createTokenForCVCUpdate=exports.createToken=exports.createPlatformPayToken=exports.createPlatformPayPaymentMethod=exports.createPaymentMethod=exports.confirmSetupIntent=exports.confirmPlatformPaySetupIntent=exports.confirmPlatformPayPayment=exports.confirmPaymentSheetPayment=exports.confirmPayment=exports.collectFinancialConnectionsAccounts=exports.collectBankAccountToken=exports.collectBankAccountForSetup=exports.collectBankAccountForPayment=exports.canAddCardToWallet=exports.Constants=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _helpers=require("./helpers");var _Errors=require("./types/Errors");var _NativeStripeSdk=_interopRequireDefault(require("./NativeStripeSdk"));var _reactNative=require("react-native");var createPaymentMethod=function(){var _ref=(0,_asyncToGenerator2.default)(function*(params){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};try{var _yield$NativeStripeSd=yield _NativeStripeSdk.default.createPaymentMethod(params,options),paymentMethod=_yield$NativeStripeSd.paymentMethod,error=_yield$NativeStripeSd.error;if(error){return{error:error};}return{paymentMethod:paymentMethod};}catch(error){return{error:error};}});return function createPaymentMethod(_x){return _ref.apply(this,arguments);};}();exports.createPaymentMethod=createPaymentMethod;var createToken=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(params){var _params$country;if(params.type==='BankAccount'&&((_params$country=params.country)==null?void 0:_params$country.toLowerCase())==='us'&&!params.routingNumber){return{error:_Errors.MissingRoutingNumber};}try{var _yield$NativeStripeSd2=yield _NativeStripeSdk.default.createToken(params),token=_yield$NativeStripeSd2.token,error=_yield$NativeStripeSd2.error;if(error){return{error:error};}return{token:token};}catch(error){return{error:error};}});return function createToken(_x2){return _ref2.apply(this,arguments);};}();exports.createToken=createToken;var retrievePaymentIntent=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd3=yield _NativeStripeSdk.default.retrievePaymentIntent(clientSecret),paymentIntent=_yield$NativeStripeSd3.paymentIntent,error=_yield$NativeStripeSd3.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function retrievePaymentIntent(_x3){return _ref3.apply(this,arguments);};}();exports.retrievePaymentIntent=retrievePaymentIntent;var retrieveSetupIntent=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd4=yield _NativeStripeSdk.default.retrieveSetupIntent(clientSecret),setupIntent=_yield$NativeStripeSd4.setupIntent,error=_yield$NativeStripeSd4.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function retrieveSetupIntent(_x4){return _ref4.apply(this,arguments);};}();exports.retrieveSetupIntent=retrieveSetupIntent;var confirmPayment=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,params){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{var _yield$NativeStripeSd5=yield _NativeStripeSdk.default.confirmPayment(paymentIntentClientSecret,params,options),paymentIntent=_yield$NativeStripeSd5.paymentIntent,error=_yield$NativeStripeSd5.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function confirmPayment(_x5,_x6){return _ref5.apply(this,arguments);};}();exports.confirmPayment=confirmPayment;var handleNextAction=function(){var _ref6=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,returnURL){try{var _ref7=_reactNative.Platform.OS==='ios'?yield _NativeStripeSdk.default.handleNextAction(paymentIntentClientSecret,returnURL!=null?returnURL:null):yield _NativeStripeSdk.default.handleNextAction(paymentIntentClientSecret),paymentIntent=_ref7.paymentIntent,error=_ref7.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function handleNextAction(_x7,_x8){return _ref6.apply(this,arguments);};}();exports.handleNextAction=handleNextAction;var handleNextActionForSetup=function(){var _ref8=(0,_asyncToGenerator2.default)(function*(setupIntentClientSecret,returnURL){try{var _ref9=_reactNative.Platform.OS==='ios'?yield _NativeStripeSdk.default.handleNextActionForSetup(setupIntentClientSecret,returnURL!=null?returnURL:null):yield _NativeStripeSdk.default.handleNextActionForSetup(setupIntentClientSecret),setupIntent=_ref9.setupIntent,error=_ref9.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function handleNextActionForSetup(_x9,_x10){return _ref8.apply(this,arguments);};}();exports.handleNextActionForSetup=handleNextActionForSetup;var confirmSetupIntent=function(){var _ref10=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,params){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{var _yield$NativeStripeSd6=yield _NativeStripeSdk.default.confirmSetupIntent(paymentIntentClientSecret,params,options),setupIntent=_yield$NativeStripeSd6.setupIntent,error=_yield$NativeStripeSd6.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function confirmSetupIntent(_x11,_x12){return _ref10.apply(this,arguments);};}();exports.confirmSetupIntent=confirmSetupIntent;var createTokenForCVCUpdate=function(){var _ref11=(0,_asyncToGenerator2.default)(function*(cvc){try{var _yield$NativeStripeSd7=yield _NativeStripeSdk.default.createTokenForCVCUpdate(cvc),tokenId=_yield$NativeStripeSd7.tokenId,error=_yield$NativeStripeSd7.error;if(error){return{error:error};}return{tokenId:tokenId};}catch(error){return{error:error};}});return function createTokenForCVCUpdate(_x13){return _ref11.apply(this,arguments);};}();exports.createTokenForCVCUpdate=createTokenForCVCUpdate;var handleURLCallback=function(){var _ref12=(0,_asyncToGenerator2.default)(function*(url){var stripeHandled=_reactNative.Platform.OS==='ios'?yield _NativeStripeSdk.default.handleURLCallback(url):false;return stripeHandled;});return function handleURLCallback(_x14){return _ref12.apply(this,arguments);};}();exports.handleURLCallback=handleURLCallback;var verifyMicrodepositsForPayment=function(){var _ref13=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref14=yield _NativeStripeSdk.default.verifyMicrodeposits(true,clientSecret,params),paymentIntent=_ref14.paymentIntent,error=_ref14.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function verifyMicrodepositsForPayment(_x15,_x16){return _ref13.apply(this,arguments);};}();exports.verifyMicrodepositsForPayment=verifyMicrodepositsForPayment;var verifyMicrodepositsForSetup=function(){var _ref15=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref16=yield _NativeStripeSdk.default.verifyMicrodeposits(false,clientSecret,params),setupIntent=_ref16.setupIntent,error=_ref16.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function verifyMicrodepositsForSetup(_x17,_x18){return _ref15.apply(this,arguments);};}();exports.verifyMicrodepositsForSetup=verifyMicrodepositsForSetup;var eventEmitter=new _reactNative.NativeEventEmitter(_reactNative.NativeModules.StripeSdk);var confirmHandlerCallback=null;var orderTrackingCallbackListener=null;var initPaymentSheet=function(){var _ref17=(0,_asyncToGenerator2.default)(function*(params){var _params$intentConfigu,_params$applePay;var result;var confirmHandler=params==null?void 0:(_params$intentConfigu=params.intentConfiguration)==null?void 0:_params$intentConfigu.confirmHandler;if(confirmHandler){var _confirmHandlerCallba;(_confirmHandlerCallba=confirmHandlerCallback)==null?void 0:_confirmHandlerCallba.remove();confirmHandlerCallback=eventEmitter.addListener('onConfirmHandlerCallback',function(_ref18){var paymentMethod=_ref18.paymentMethod,shouldSavePaymentMethod=_ref18.shouldSavePaymentMethod;confirmHandler(paymentMethod,shouldSavePaymentMethod,_NativeStripeSdk.default.intentCreationCallback);});}var orderTrackingCallback=params==null?void 0:(_params$applePay=params.applePay)==null?void 0:_params$applePay.setOrderTracking;if(orderTrackingCallback){var _orderTrackingCallbac;(_orderTrackingCallbac=orderTrackingCallbackListener)==null?void 0:_orderTrackingCallbac.remove();orderTrackingCallbackListener=eventEmitter.addListener('onOrderTrackingCallback',function(){orderTrackingCallback(_NativeStripeSdk.default.configureOrderTracking);});}try{if(_reactNative.Platform.OS==='ios'&&!params.returnURL){console.warn("[@stripe/stripe-react-native] You have not provided the 'returnURL' field to 'initPaymentSheet', so payment methods that require redirects will not be shown in your iOS Payment Sheet. Visit https://stripe.com/docs/payments/accept-a-payment?platform=react-native&ui=payment-sheet#react-native-set-up-return-url to learn more.");}result=yield _NativeStripeSdk.default.initPaymentSheet(params);if(result.error){return{error:result.error};}return{paymentOption:result.paymentOption};}catch(error){return{error:error};}});return function initPaymentSheet(_x19){return _ref17.apply(this,arguments);};}();exports.initPaymentSheet=initPaymentSheet;var presentPaymentSheet=function(){var _ref19=(0,_asyncToGenerator2.default)(function*(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};try{var _yield$NativeStripeSd8=yield _NativeStripeSdk.default.presentPaymentSheet(options),paymentOption=_yield$NativeStripeSd8.paymentOption,error=_yield$NativeStripeSd8.error;if(error){return{error:error};}return{paymentOption:paymentOption};}catch(error){return{error:error};}});return function presentPaymentSheet(){return _ref19.apply(this,arguments);};}();exports.presentPaymentSheet=presentPaymentSheet;var confirmPaymentSheetPayment=function(){var _ref20=(0,_asyncToGenerator2.default)(function*(){try{var _yield$NativeStripeSd9=yield _NativeStripeSdk.default.confirmPaymentSheetPayment(),error=_yield$NativeStripeSd9.error;if(error){return{error:error};}return{};}catch(error){return{error:error};}});return function confirmPaymentSheetPayment(){return _ref20.apply(this,arguments);};}();exports.confirmPaymentSheetPayment=confirmPaymentSheetPayment;var resetPaymentSheetCustomer=function(){var _ref21=(0,_asyncToGenerator2.default)(function*(){return yield _NativeStripeSdk.default.resetPaymentSheetCustomer();});return function resetPaymentSheetCustomer(){return _ref21.apply(this,arguments);};}();exports.resetPaymentSheetCustomer=resetPaymentSheetCustomer;var collectBankAccountForPayment=function(){var _ref22=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref23=yield _NativeStripeSdk.default.collectBankAccount(true,clientSecret,params),paymentIntent=_ref23.paymentIntent,error=_ref23.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountForPayment(_x20,_x21){return _ref22.apply(this,arguments);};}();exports.collectBankAccountForPayment=collectBankAccountForPayment;var collectBankAccountForSetup=function(){var _ref24=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref25=yield _NativeStripeSdk.default.collectBankAccount(false,clientSecret,params),setupIntent=_ref25.setupIntent,error=_ref25.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountForSetup(_x22,_x23){return _ref24.apply(this,arguments);};}();exports.collectBankAccountForSetup=collectBankAccountForSetup;var collectBankAccountToken=function(){var _ref26=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd10=yield _NativeStripeSdk.default.collectBankAccountToken(clientSecret),session=_yield$NativeStripeSd10.session,token=_yield$NativeStripeSd10.token,error=_yield$NativeStripeSd10.error;if(error){return{error:error};}return{session:session,token:token};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountToken(_x24){return _ref26.apply(this,arguments);};}();exports.collectBankAccountToken=collectBankAccountToken;var collectFinancialConnectionsAccounts=function(){var _ref27=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd11=yield _NativeStripeSdk.default.collectFinancialConnectionsAccounts(clientSecret),session=_yield$NativeStripeSd11.session,error=_yield$NativeStripeSd11.error;if(error){return{error:error};}return{session:session};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectFinancialConnectionsAccounts(_x25){return _ref27.apply(this,arguments);};}();exports.collectFinancialConnectionsAccounts=collectFinancialConnectionsAccounts;var canAddCardToWallet=function(){var _ref28=(0,_asyncToGenerator2.default)(function*(params){try{var _yield$NativeStripeSd12=yield _NativeStripeSdk.default.canAddCardToWallet(params),canAddCard=_yield$NativeStripeSd12.canAddCard,details=_yield$NativeStripeSd12.details,error=_yield$NativeStripeSd12.error;if(error){return{error:error};}return{canAddCard:canAddCard,details:details};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function canAddCardToWallet(_x26){return _ref28.apply(this,arguments);};}();exports.canAddCardToWallet=canAddCardToWallet;var isCardInWallet=function(){var _ref29=(0,_asyncToGenerator2.default)(function*(params){try{var _yield$NativeStripeSd13=yield _NativeStripeSdk.default.isCardInWallet(params),isInWallet=_yield$NativeStripeSd13.isInWallet,token=_yield$NativeStripeSd13.token,error=_yield$NativeStripeSd13.error;if(error){return{error:error};}return{isInWallet:isInWallet,token:token};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function isCardInWallet(_x27){return _ref29.apply(this,arguments);};}();exports.isCardInWallet=isCardInWallet;var Constants=_NativeStripeSdk.default.getConstants();exports.Constants=Constants;var isPlatformPaySupported=function(){var _ref30=(0,_asyncToGenerator2.default)(function*(params){return yield _NativeStripeSdk.default.isPlatformPaySupported(params!=null?params:{});});return function isPlatformPaySupported(_x28){return _ref30.apply(this,arguments);};}();exports.isPlatformPaySupported=isPlatformPaySupported;var confirmPlatformPaySetupIntent=function(){var _ref31=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref32=yield _NativeStripeSdk.default.confirmPlatformPay(clientSecret,params,false),error=_ref32.error,setupIntent=_ref32.setupIntent;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function confirmPlatformPaySetupIntent(_x29,_x30){return _ref31.apply(this,arguments);};}();exports.confirmPlatformPaySetupIntent=confirmPlatformPaySetupIntent;var confirmPlatformPayPayment=function(){var _ref33=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref34=yield _NativeStripeSdk.default.confirmPlatformPay(clientSecret,params,true),error=_ref34.error,paymentIntent=_ref34.paymentIntent;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function confirmPlatformPayPayment(_x31,_x32){return _ref33.apply(this,arguments);};}();exports.confirmPlatformPayPayment=confirmPlatformPayPayment;var dismissPlatformPay=function(){var _ref35=(0,_asyncToGenerator2.default)(function*(){if(_reactNative.Platform.OS!=='ios'){return false;}try{var didDismiss=yield _NativeStripeSdk.default.dismissPlatformPay();return didDismiss;}catch(error){return false;}});return function dismissPlatformPay(){return _ref35.apply(this,arguments);};}();exports.dismissPlatformPay=dismissPlatformPay;var createPlatformPayPaymentMethod=function(){var _ref36=(0,_asyncToGenerator2.default)(function*(params){try{var _ref37=yield _NativeStripeSdk.default.createPlatformPayPaymentMethod(params,false),error=_ref37.error,paymentMethod=_ref37.paymentMethod;if(error){return{error:error};}return{paymentMethod:paymentMethod};}catch(error){return{error:error};}});return function createPlatformPayPaymentMethod(_x33){return _ref36.apply(this,arguments);};}();exports.createPlatformPayPaymentMethod=createPlatformPayPaymentMethod;var createPlatformPayToken=function(){var _ref38=(0,_asyncToGenerator2.default)(function*(params){try{var _ref39=yield _NativeStripeSdk.default.createPlatformPayPaymentMethod(params,true),error=_ref39.error,token=_ref39.token;if(error){return{error:error};}return{token:token};}catch(error){return{error:error};}});return function createPlatformPayToken(_x34){return _ref38.apply(this,arguments);};}();exports.createPlatformPayToken=createPlatformPayToken;var updatePlatformPaySheet=function(){var _ref40=(0,_asyncToGenerator2.default)(function*(params){if(_reactNative.Platform.OS!=='ios'){return{};}try{yield _NativeStripeSdk.default.updatePlatformPaySheet(params.applePay.cartItems,params.applePay.shippingMethods,params.applePay.errors);return{};}catch(error){return{error:error};}});return function updatePlatformPaySheet(_x35){return _ref40.apply(this,arguments);};}();exports.updatePlatformPaySheet=updatePlatformPaySheet;var openPlatformPaySetup=function(){var _ref41=(0,_asyncToGenerator2.default)(function*(){if(_reactNative.Platform.OS==='ios'){yield _NativeStripeSdk.default.openApplePaySetup();}});return function openPlatformPaySetup(){return _ref41.apply(this,arguments);};}();exports.openPlatformPaySetup=openPlatformPaySetup;
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.verifyMicrodepositsForSetup=exports.verifyMicrodepositsForPayment=exports.updatePlatformPaySheet=exports.retrieveSetupIntent=exports.retrievePaymentIntent=exports.resetPaymentSheetCustomer=exports.presentPaymentSheet=exports.openPlatformPaySetup=exports.isPlatformPaySupported=exports.isCardInWallet=exports.initPaymentSheet=exports.handleURLCallback=exports.handleNextActionForSetup=exports.handleNextAction=exports.dismissPlatformPay=exports.createTokenForCVCUpdate=exports.createToken=exports.createPlatformPayToken=exports.createPlatformPayPaymentMethod=exports.createPaymentMethod=exports.confirmSetupIntent=exports.confirmPlatformPaySetupIntent=exports.confirmPlatformPayPayment=exports.confirmPaymentSheetPayment=exports.confirmPayment=exports.collectFinancialConnectionsAccounts=exports.collectBankAccountToken=exports.collectBankAccountForSetup=exports.collectBankAccountForPayment=exports.canAddCardToWallet=exports.Constants=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _helpers=require("./helpers");var _Errors=require("./types/Errors");var _NativeStripeSdk=_interopRequireDefault(require("./NativeStripeSdk"));var _reactNative=require("react-native");var createPaymentMethod=function(){var _ref=(0,_asyncToGenerator2.default)(function*(params){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};try{var _yield$NativeStripeSd=yield _NativeStripeSdk.default.createPaymentMethod(params,options),paymentMethod=_yield$NativeStripeSd.paymentMethod,error=_yield$NativeStripeSd.error;if(error){return{error:error};}return{paymentMethod:paymentMethod};}catch(error){return{error:error};}});return function createPaymentMethod(_x){return _ref.apply(this,arguments);};}();exports.createPaymentMethod=createPaymentMethod;var createToken=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(params){var _params$country;if(params.type==='BankAccount'&&((_params$country=params.country)==null?void 0:_params$country.toLowerCase())==='us'&&!params.routingNumber){return{error:_Errors.MissingRoutingNumber};}try{var _yield$NativeStripeSd2=yield _NativeStripeSdk.default.createToken(params),token=_yield$NativeStripeSd2.token,error=_yield$NativeStripeSd2.error;if(error){return{error:error};}return{token:token};}catch(error){return{error:error};}});return function createToken(_x2){return _ref2.apply(this,arguments);};}();exports.createToken=createToken;var retrievePaymentIntent=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd3=yield _NativeStripeSdk.default.retrievePaymentIntent(clientSecret),paymentIntent=_yield$NativeStripeSd3.paymentIntent,error=_yield$NativeStripeSd3.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function retrievePaymentIntent(_x3){return _ref3.apply(this,arguments);};}();exports.retrievePaymentIntent=retrievePaymentIntent;var retrieveSetupIntent=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd4=yield _NativeStripeSdk.default.retrieveSetupIntent(clientSecret),setupIntent=_yield$NativeStripeSd4.setupIntent,error=_yield$NativeStripeSd4.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function retrieveSetupIntent(_x4){return _ref4.apply(this,arguments);};}();exports.retrieveSetupIntent=retrieveSetupIntent;var confirmPayment=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,params){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{var _yield$NativeStripeSd5=yield _NativeStripeSdk.default.confirmPayment(paymentIntentClientSecret,params,options),paymentIntent=_yield$NativeStripeSd5.paymentIntent,error=_yield$NativeStripeSd5.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function confirmPayment(_x5,_x6){return _ref5.apply(this,arguments);};}();exports.confirmPayment=confirmPayment;var handleNextAction=function(){var _ref6=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,returnURL){try{var _ref7=_reactNative.Platform.OS==='ios'?yield _NativeStripeSdk.default.handleNextAction(paymentIntentClientSecret,returnURL!=null?returnURL:null):yield _NativeStripeSdk.default.handleNextAction(paymentIntentClientSecret),paymentIntent=_ref7.paymentIntent,error=_ref7.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function handleNextAction(_x7,_x8){return _ref6.apply(this,arguments);};}();exports.handleNextAction=handleNextAction;var handleNextActionForSetup=function(){var _ref8=(0,_asyncToGenerator2.default)(function*(setupIntentClientSecret,returnURL){try{var _ref9=_reactNative.Platform.OS==='ios'?yield _NativeStripeSdk.default.handleNextActionForSetup(setupIntentClientSecret,returnURL!=null?returnURL:null):yield _NativeStripeSdk.default.handleNextActionForSetup(setupIntentClientSecret),setupIntent=_ref9.setupIntent,error=_ref9.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function handleNextActionForSetup(_x9,_x10){return _ref8.apply(this,arguments);};}();exports.handleNextActionForSetup=handleNextActionForSetup;var confirmSetupIntent=function(){var _ref10=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,params){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{var _yield$NativeStripeSd6=yield _NativeStripeSdk.default.confirmSetupIntent(paymentIntentClientSecret,params,options),setupIntent=_yield$NativeStripeSd6.setupIntent,error=_yield$NativeStripeSd6.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function confirmSetupIntent(_x11,_x12){return _ref10.apply(this,arguments);};}();exports.confirmSetupIntent=confirmSetupIntent;var createTokenForCVCUpdate=function(){var _ref11=(0,_asyncToGenerator2.default)(function*(cvc){try{var _yield$NativeStripeSd7=yield _NativeStripeSdk.default.createTokenForCVCUpdate(cvc),tokenId=_yield$NativeStripeSd7.tokenId,error=_yield$NativeStripeSd7.error;if(error){return{error:error};}return{tokenId:tokenId};}catch(error){return{error:error};}});return function createTokenForCVCUpdate(_x13){return _ref11.apply(this,arguments);};}();exports.createTokenForCVCUpdate=createTokenForCVCUpdate;var handleURLCallback=function(){var _ref12=(0,_asyncToGenerator2.default)(function*(url){var stripeHandled=_reactNative.Platform.OS==='ios'?yield _NativeStripeSdk.default.handleURLCallback(url):false;return stripeHandled;});return function handleURLCallback(_x14){return _ref12.apply(this,arguments);};}();exports.handleURLCallback=handleURLCallback;var verifyMicrodepositsForPayment=function(){var _ref13=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref14=yield _NativeStripeSdk.default.verifyMicrodeposits(true,clientSecret,params),paymentIntent=_ref14.paymentIntent,error=_ref14.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function verifyMicrodepositsForPayment(_x15,_x16){return _ref13.apply(this,arguments);};}();exports.verifyMicrodepositsForPayment=verifyMicrodepositsForPayment;var verifyMicrodepositsForSetup=function(){var _ref15=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref16=yield _NativeStripeSdk.default.verifyMicrodeposits(false,clientSecret,params),setupIntent=_ref16.setupIntent,error=_ref16.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function verifyMicrodepositsForSetup(_x17,_x18){return _ref15.apply(this,arguments);};}();exports.verifyMicrodepositsForSetup=verifyMicrodepositsForSetup;var eventEmitter=new _reactNative.NativeEventEmitter(_reactNative.NativeModules.StripeSdk);var confirmHandlerCallback=null;var orderTrackingCallbackListener=null;var initPaymentSheet=function(){var _ref17=(0,_asyncToGenerator2.default)(function*(params){var _params$intentConfigu,_params$applePay;var result;var confirmHandler=params==null?void 0:(_params$intentConfigu=params.intentConfiguration)==null?void 0:_params$intentConfigu.confirmHandler;if(confirmHandler){var _confirmHandlerCallba;(_confirmHandlerCallba=confirmHandlerCallback)==null?void 0:_confirmHandlerCallba.remove();confirmHandlerCallback=eventEmitter.addListener('onConfirmHandlerCallback',function(_ref18){var paymentMethod=_ref18.paymentMethod,shouldSavePaymentMethod=_ref18.shouldSavePaymentMethod;confirmHandler(paymentMethod,shouldSavePaymentMethod,_NativeStripeSdk.default.intentCreationCallback);});}var orderTrackingCallback=params==null?void 0:(_params$applePay=params.applePay)==null?void 0:_params$applePay.setOrderTracking;if(orderTrackingCallback){var _orderTrackingCallbac;(_orderTrackingCallbac=orderTrackingCallbackListener)==null?void 0:_orderTrackingCallbac.remove();orderTrackingCallbackListener=eventEmitter.addListener('onOrderTrackingCallback',function(){orderTrackingCallback(_NativeStripeSdk.default.configureOrderTracking);});}try{if(_reactNative.Platform.OS==='ios'&&!params.returnURL){console.warn("[@stripe/stripe-react-native] You have not provided the 'returnURL' field to 'initPaymentSheet', so payment methods that require redirects will not be shown in your iOS Payment Sheet. Visit https://stripe.com/docs/payments/accept-a-payment?platform=react-native&ui=payment-sheet#react-native-set-up-return-url to learn more.");}result=yield _NativeStripeSdk.default.initPaymentSheet(params);if(result.error){return{error:result.error};}return{paymentOption:result.paymentOption};}catch(error){return{error:error};}});return function initPaymentSheet(_x19){return _ref17.apply(this,arguments);};}();exports.initPaymentSheet=initPaymentSheet;var presentPaymentSheet=function(){var _ref19=(0,_asyncToGenerator2.default)(function*(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};try{var _yield$NativeStripeSd8=yield _NativeStripeSdk.default.presentPaymentSheet(options),paymentOption=_yield$NativeStripeSd8.paymentOption,error=_yield$NativeStripeSd8.error;if(error){return{error:error};}return{paymentOption:paymentOption};}catch(error){return{error:error};}});return function presentPaymentSheet(){return _ref19.apply(this,arguments);};}();exports.presentPaymentSheet=presentPaymentSheet;var confirmPaymentSheetPayment=function(){var _ref20=(0,_asyncToGenerator2.default)(function*(){try{var _yield$NativeStripeSd9=yield _NativeStripeSdk.default.confirmPaymentSheetPayment(),error=_yield$NativeStripeSd9.error;if(error){return{error:error};}return{};}catch(error){return{error:error};}});return function confirmPaymentSheetPayment(){return _ref20.apply(this,arguments);};}();exports.confirmPaymentSheetPayment=confirmPaymentSheetPayment;var resetPaymentSheetCustomer=function(){var _ref21=(0,_asyncToGenerator2.default)(function*(){return yield _NativeStripeSdk.default.resetPaymentSheetCustomer();});return function resetPaymentSheetCustomer(){return _ref21.apply(this,arguments);};}();exports.resetPaymentSheetCustomer=resetPaymentSheetCustomer;var collectBankAccountForPayment=function(){var _ref22=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref23=yield _NativeStripeSdk.default.collectBankAccount(true,clientSecret,params),paymentIntent=_ref23.paymentIntent,error=_ref23.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountForPayment(_x20,_x21){return _ref22.apply(this,arguments);};}();exports.collectBankAccountForPayment=collectBankAccountForPayment;var collectBankAccountForSetup=function(){var _ref24=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref25=yield _NativeStripeSdk.default.collectBankAccount(false,clientSecret,params),setupIntent=_ref25.setupIntent,error=_ref25.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountForSetup(_x22,_x23){return _ref24.apply(this,arguments);};}();exports.collectBankAccountForSetup=collectBankAccountForSetup;var collectBankAccountToken=function(){var _ref26=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd10=yield _NativeStripeSdk.default.collectBankAccountToken(clientSecret),session=_yield$NativeStripeSd10.session,token=_yield$NativeStripeSd10.token,error=_yield$NativeStripeSd10.error;if(error){return{error:error};}return{session:session,token:token};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountToken(_x24){return _ref26.apply(this,arguments);};}();exports.collectBankAccountToken=collectBankAccountToken;var collectFinancialConnectionsAccounts=function(){var _ref27=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd11=yield _NativeStripeSdk.default.collectFinancialConnectionsAccounts(clientSecret),session=_yield$NativeStripeSd11.session,error=_yield$NativeStripeSd11.error;if(error){return{error:error};}return{session:session};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectFinancialConnectionsAccounts(_x25){return _ref27.apply(this,arguments);};}();exports.collectFinancialConnectionsAccounts=collectFinancialConnectionsAccounts;var canAddCardToWallet=function(){var _ref28=(0,_asyncToGenerator2.default)(function*(params){try{var _yield$NativeStripeSd12=yield _NativeStripeSdk.default.canAddCardToWallet(params),canAddCard=_yield$NativeStripeSd12.canAddCard,details=_yield$NativeStripeSd12.details,error=_yield$NativeStripeSd12.error;if(error){return{error:error};}return{canAddCard:canAddCard,details:details};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function canAddCardToWallet(_x26){return _ref28.apply(this,arguments);};}();exports.canAddCardToWallet=canAddCardToWallet;var isCardInWallet=function(){var _ref29=(0,_asyncToGenerator2.default)(function*(params){try{var _yield$NativeStripeSd13=yield _NativeStripeSdk.default.isCardInWallet(params),isInWallet=_yield$NativeStripeSd13.isInWallet,token=_yield$NativeStripeSd13.token,error=_yield$NativeStripeSd13.error;if(error){return{error:error};}return{isInWallet:isInWallet,token:token};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function isCardInWallet(_x27){return _ref29.apply(this,arguments);};}();exports.isCardInWallet=isCardInWallet;var Constants=_NativeStripeSdk.default.getConstants();exports.Constants=Constants;var isPlatformPaySupported=function(){var _ref30=(0,_asyncToGenerator2.default)(function*(params){return yield _NativeStripeSdk.default.isPlatformPaySupported(params!=null?params:{});});return function isPlatformPaySupported(_x28){return _ref30.apply(this,arguments);};}();exports.isPlatformPaySupported=isPlatformPaySupported;var confirmPlatformPaySetupIntent=function(){var _ref31=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref32=yield _NativeStripeSdk.default.confirmPlatformPay(clientSecret,params,false),error=_ref32.error,setupIntent=_ref32.setupIntent;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function confirmPlatformPaySetupIntent(_x29,_x30){return _ref31.apply(this,arguments);};}();exports.confirmPlatformPaySetupIntent=confirmPlatformPaySetupIntent;var confirmPlatformPayPayment=function(){var _ref33=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref34=yield _NativeStripeSdk.default.confirmPlatformPay(clientSecret,params,true),error=_ref34.error,paymentIntent=_ref34.paymentIntent;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function confirmPlatformPayPayment(_x31,_x32){return _ref33.apply(this,arguments);};}();exports.confirmPlatformPayPayment=confirmPlatformPayPayment;var dismissPlatformPay=function(){var _ref35=(0,_asyncToGenerator2.default)(function*(){if(_reactNative.Platform.OS!=='ios'){return false;}try{var didDismiss=yield _NativeStripeSdk.default.dismissPlatformPay();return didDismiss;}catch(error){return false;}});return function dismissPlatformPay(){return _ref35.apply(this,arguments);};}();exports.dismissPlatformPay=dismissPlatformPay;var createPlatformPayPaymentMethod=function(){var _ref36=(0,_asyncToGenerator2.default)(function*(params){try{var _ref37=yield _NativeStripeSdk.default.createPlatformPayPaymentMethod(params,false),error=_ref37.error,paymentMethod=_ref37.paymentMethod,shippingContact=_ref37.shippingContact;if(error){return{error:error};}return{paymentMethod:paymentMethod,shippingContact:shippingContact};}catch(error){return{error:error};}});return function createPlatformPayPaymentMethod(_x33){return _ref36.apply(this,arguments);};}();exports.createPlatformPayPaymentMethod=createPlatformPayPaymentMethod;var createPlatformPayToken=function(){var _ref38=(0,_asyncToGenerator2.default)(function*(params){try{var _ref39=yield _NativeStripeSdk.default.createPlatformPayPaymentMethod(params,true),error=_ref39.error,token=_ref39.token,shippingContact=_ref39.shippingContact;if(error){return{error:error};}return{token:token,shippingContact:shippingContact};}catch(error){return{error:error};}});return function createPlatformPayToken(_x34){return _ref38.apply(this,arguments);};}();exports.createPlatformPayToken=createPlatformPayToken;var updatePlatformPaySheet=function(){var _ref40=(0,_asyncToGenerator2.default)(function*(params){if(_reactNative.Platform.OS!=='ios'){return{};}try{yield _NativeStripeSdk.default.updatePlatformPaySheet(params.applePay.cartItems,params.applePay.shippingMethods,params.applePay.errors);return{};}catch(error){return{error:error};}});return function updatePlatformPaySheet(_x35){return _ref40.apply(this,arguments);};}();exports.updatePlatformPaySheet=updatePlatformPaySheet;var openPlatformPaySetup=function(){var _ref41=(0,_asyncToGenerator2.default)(function*(){if(_reactNative.Platform.OS==='ios'){yield _NativeStripeSdk.default.openApplePaySetup();}});return function openPlatformPaySetup(){return _ref41.apply(this,arguments);};}();exports.openPlatformPaySetup=openPlatformPaySetup;
|
|
2
2
|
//# sourceMappingURL=functions.js.map
|