forked from stripe/stripe-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.ts
826 lines (779 loc) · 22.9 KB
/
functions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
import { createError } from './helpers';
import { MissingRoutingNumber } from './types/Errors';
import NativeStripeSdk from './NativeStripeSdk';
import type {
PlatformPayError,
ConfirmPaymentResult,
ConfirmPaymentSheetPaymentResult,
SetupIntent,
PaymentIntent,
ConfirmSetupIntentResult,
CreatePaymentMethodResult,
CreateTokenForCVCUpdateResult,
CreateTokenResult,
HandleNextActionResult,
HandleNextActionForSetupResult,
InitPaymentSheetResult,
PaymentMethod,
PaymentSheet,
PresentPaymentSheetResult,
RetrievePaymentIntentResult,
RetrieveSetupIntentResult,
StripeError,
Token,
VerifyMicrodepositsParams,
VerifyMicrodepositsForPaymentResult,
VerifyMicrodepositsForSetupResult,
CollectBankAccountForPaymentResult,
CollectBankAccountForSetupResult,
IsCardInWalletResult,
CanAddCardToWalletParams,
CanAddCardToWalletResult,
FinancialConnections,
PlatformPay,
} from './types';
import {
Platform,
NativeEventEmitter,
NativeModules,
EmitterSubscription,
} from 'react-native';
export const createPaymentMethod = async (
params: PaymentMethod.CreateParams,
options: PaymentMethod.CreateOptions = {}
): Promise<CreatePaymentMethodResult> => {
try {
const { paymentMethod, error } = await NativeStripeSdk.createPaymentMethod(
params,
options
);
if (error) {
return {
error,
};
}
return {
paymentMethod: paymentMethod!,
};
} catch (error: any) {
return {
error,
};
}
};
export const createToken = async (
params: Token.CreateParams
): Promise<CreateTokenResult> => {
if (
params.type === 'BankAccount' &&
params.country?.toLowerCase() === 'us' &&
!params.routingNumber
) {
return {
error: MissingRoutingNumber,
};
}
try {
const { token, error } = await NativeStripeSdk.createToken(params);
if (error) {
return {
error,
};
}
return {
token: token!,
};
} catch (error: any) {
return {
error,
};
}
};
export const retrievePaymentIntent = async (
clientSecret: string
): Promise<RetrievePaymentIntentResult> => {
try {
const { paymentIntent, error } =
await NativeStripeSdk.retrievePaymentIntent(clientSecret);
if (error) {
return {
error,
};
}
return {
paymentIntent: paymentIntent!,
};
} catch (error: any) {
return {
error,
};
}
};
export const retrieveSetupIntent = async (
clientSecret: string
): Promise<RetrieveSetupIntentResult> => {
try {
const { setupIntent, error } = await NativeStripeSdk.retrieveSetupIntent(
clientSecret
);
if (error) {
return {
error,
};
}
return {
setupIntent: setupIntent!,
};
} catch (error: any) {
return {
error,
};
}
};
/**
* Confirm and, if necessary, authenticate a PaymentIntent.
*
* @param {string} paymentIntentClientSecret The client_secret of the associated [PaymentIntent](https://stripe.com/docs/api/payment_intents).
* @param {object=} params An optional object that contains data related to the payment method used to confirm this payment. If no object is provided (undefined), then it is assumed that the payment method has already been [attached to the Payment Intent](https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method).
* @param {object=} options An optional object that contains options for this payment method.
* @returns A promise that resolves to an object containing either a `paymentIntent` field, or an `error` field.
*/
export const confirmPayment = async (
paymentIntentClientSecret: string,
params?: PaymentIntent.ConfirmParams,
options: PaymentIntent.ConfirmOptions = {}
): Promise<ConfirmPaymentResult> => {
try {
const { paymentIntent, error } = await NativeStripeSdk.confirmPayment(
paymentIntentClientSecret,
params,
options
);
if (error) {
return {
error,
};
}
return {
paymentIntent: paymentIntent!,
};
} catch (error: any) {
return {
error,
};
}
};
/** Handles any nextAction required to authenticate the PaymentIntent.
* Call this method if you are using manual confirmation. See https://stripe.com/docs/payments/accept-a-payment?platform=react-native&ui=custom
*
* @param {string} paymentIntentClientSecret The client secret associated with the PaymentIntent.
* @param {string=} returnURL An optional return URL so the Stripe SDK can redirect back to your app after authentication. This should match the `return_url` you specified during PaymentIntent confirmation.
* */
export const handleNextAction = async (
paymentIntentClientSecret: string,
returnURL?: string
): Promise<HandleNextActionResult> => {
try {
const { paymentIntent, error } =
Platform.OS === 'ios'
? await NativeStripeSdk.handleNextAction(
paymentIntentClientSecret,
returnURL ?? null
)
: await NativeStripeSdk.handleNextAction(paymentIntentClientSecret);
if (error) {
return {
error,
};
}
return {
paymentIntent: paymentIntent!,
};
} catch (error: any) {
return {
error: createError(error),
};
}
};
/** Handles any nextAction required to authenticate the SetupIntent.
* Call this method if you are confirming the SetupIntent on your backend and get a status of requires_action.
*
* @param {string} setupIntentClientSecret The client secret associated with the SetupIntent.
* @param {string=} returnURL An optional return URL so the Stripe SDK can redirect back to your app after authentication. This should match the `return_url` you specified during PaymentIntent confirmation.
* */
export const handleNextActionForSetup = async (
setupIntentClientSecret: string,
returnURL?: string
): Promise<HandleNextActionForSetupResult> => {
try {
const { setupIntent, error } =
Platform.OS === 'ios'
? await NativeStripeSdk.handleNextActionForSetup(
setupIntentClientSecret,
returnURL ?? null
)
: await NativeStripeSdk.handleNextActionForSetup(
setupIntentClientSecret
);
if (error) {
return {
error,
};
}
return {
setupIntent: setupIntent!,
};
} catch (error: any) {
return {
error: createError(error),
};
}
};
export const confirmSetupIntent = async (
paymentIntentClientSecret: string,
params: SetupIntent.ConfirmParams,
options: SetupIntent.ConfirmOptions = {}
): Promise<ConfirmSetupIntentResult> => {
try {
const { setupIntent, error } = await NativeStripeSdk.confirmSetupIntent(
paymentIntentClientSecret,
params,
options
);
if (error) {
return {
error,
};
}
return {
setupIntent: setupIntent!,
};
} catch (error: any) {
return {
error,
};
}
};
export const createTokenForCVCUpdate = async (
cvc: string
): Promise<CreateTokenForCVCUpdateResult> => {
try {
const { tokenId, error } = await NativeStripeSdk.createTokenForCVCUpdate(
cvc
);
if (error) {
return {
error,
};
}
return {
tokenId: tokenId!,
};
} catch (error: any) {
return {
error,
};
}
};
/**
* Call this method in your app whenever you receive a URL for a Stripe callback.
* For convenience, you can pass all URLs you receive to this method first, and
* check the return value to easily determine whether it is a callback URL that Stripe will handle
* or if your app should process it normally. This is iOS-only, and will always return false on Android.
*/
export const handleURLCallback = async (url: string): Promise<boolean> => {
const stripeHandled =
Platform.OS === 'ios'
? await NativeStripeSdk.handleURLCallback(url)
: false;
return stripeHandled;
};
export const verifyMicrodepositsForPayment = async (
clientSecret: string,
params: VerifyMicrodepositsParams
): Promise<VerifyMicrodepositsForPaymentResult> => {
try {
const { paymentIntent, error } = (await NativeStripeSdk.verifyMicrodeposits(
true,
clientSecret,
params
)) as VerifyMicrodepositsForPaymentResult;
if (error) {
return {
error,
};
}
return {
paymentIntent: paymentIntent!,
};
} catch (error: any) {
return {
error: createError(error),
};
}
};
export const verifyMicrodepositsForSetup = async (
clientSecret: string,
params: VerifyMicrodepositsParams
): Promise<VerifyMicrodepositsForSetupResult> => {
try {
const { setupIntent, error } = (await NativeStripeSdk.verifyMicrodeposits(
false,
clientSecret,
params
)) as VerifyMicrodepositsForSetupResult;
if (error) {
return {
error,
};
}
return {
setupIntent: setupIntent!,
};
} catch (error: any) {
return {
error: createError(error),
};
}
};
const eventEmitter = new NativeEventEmitter(NativeModules.StripeSdk);
let confirmHandlerCallback: EmitterSubscription | null = null;
let orderTrackingCallbackListener: EmitterSubscription | null = null;
export const initPaymentSheet = async (
params: PaymentSheet.SetupParams
): Promise<InitPaymentSheetResult> => {
let result;
const confirmHandler = params?.intentConfiguration?.confirmHandler;
if (confirmHandler) {
confirmHandlerCallback?.remove();
confirmHandlerCallback = eventEmitter.addListener(
'onConfirmHandlerCallback',
({
paymentMethod,
shouldSavePaymentMethod,
}: {
paymentMethod: PaymentMethod.Result;
shouldSavePaymentMethod: boolean;
}) => {
confirmHandler(
paymentMethod,
shouldSavePaymentMethod,
NativeStripeSdk.intentCreationCallback
);
}
);
}
const orderTrackingCallback = params?.applePay?.setOrderTracking;
if (orderTrackingCallback) {
orderTrackingCallbackListener?.remove();
orderTrackingCallbackListener = eventEmitter.addListener(
'onOrderTrackingCallback',
() => {
orderTrackingCallback(NativeStripeSdk.configureOrderTracking);
}
);
}
try {
if (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 = await NativeStripeSdk.initPaymentSheet(params);
if (result.error) {
return {
error: result.error,
};
}
return {
paymentOption: result.paymentOption,
};
} catch (error: any) {
return {
error,
};
}
};
export const presentPaymentSheet = async (
options: PaymentSheet.PresentOptions = {}
): Promise<PresentPaymentSheetResult> => {
try {
const { paymentOption, error } = await NativeStripeSdk.presentPaymentSheet(
options
);
if (error) {
return {
error,
};
}
return {
paymentOption: paymentOption!,
};
} catch (error: any) {
return {
error,
};
}
};
export const confirmPaymentSheetPayment =
async (): Promise<ConfirmPaymentSheetPaymentResult> => {
try {
const { error } = await NativeStripeSdk.confirmPaymentSheetPayment();
if (error) {
return {
error,
};
}
return {};
} catch (error: any) {
return {
error,
};
}
};
/**
* You must call this method when the user logs out from your app. This will ensure that
* any persisted authentication state in the PaymentSheet, such as authentication cookies,
* is also cleared during logout.
*/
export const resetPaymentSheetCustomer = async (): Promise<null> => {
return await NativeStripeSdk.resetPaymentSheetCustomer();
};
export const collectBankAccountForPayment = async (
clientSecret: string,
params: PaymentMethod.CollectBankAccountParams
): Promise<CollectBankAccountForPaymentResult> => {
try {
const { paymentIntent, error } = (await NativeStripeSdk.collectBankAccount(
true,
clientSecret,
params
)) as CollectBankAccountForPaymentResult;
if (error) {
return {
error,
};
}
return {
paymentIntent: paymentIntent!,
};
} catch (error: any) {
return {
error: createError(error),
};
}
};
export const collectBankAccountForSetup = async (
clientSecret: string,
params: PaymentMethod.CollectBankAccountParams
): Promise<CollectBankAccountForSetupResult> => {
try {
const { setupIntent, error } = (await NativeStripeSdk.collectBankAccount(
false,
clientSecret,
params
)) as CollectBankAccountForSetupResult;
if (error) {
return {
error,
};
}
return {
setupIntent: setupIntent!,
};
} catch (error: any) {
return {
error: createError(error),
};
}
};
/**
* Use collectBankAccountToken in the [Add a Financial Connections Account to a US Custom Connect](https://stripe.com/docs/financial-connections/connect-payouts) account flow.
* When called, it will load the Authentication Flow, an on-page modal UI which allows your user to securely link their external financial account for payouts.
* @param {string} clientSecret The client_secret of the [Financial Connections Session](https://stripe.com/docs/api/financial_connections/session).
* @returns A promise that resolves to an object containing either `session` and `token` fields, or an error field.
*/
export const collectBankAccountToken = async (
clientSecret: string
): Promise<FinancialConnections.TokenResult> => {
try {
const { session, token, error } =
await NativeStripeSdk.collectBankAccountToken(clientSecret);
if (error) {
return {
error,
};
}
return {
session: session!,
token: token!,
};
} catch (error: any) {
return {
error: createError(error),
};
}
};
/**
* Use collectFinancialConnectionsAccounts in the [Collect an account to build data-powered products](https://stripe.com/docs/financial-connections/other-data-powered-products) flow.
* When called, it will load the Authentication Flow, an on-page modal UI which allows your user to securely link their external financial account.
* @param {string} clientSecret The client_secret of the [Financial Connections Session](https://stripe.com/docs/api/financial_connections/session).
* @returns A promise that resolves to an object containing either a `session` field, or an error field.
*/
export const collectFinancialConnectionsAccounts = async (
clientSecret: string
): Promise<FinancialConnections.SessionResult> => {
try {
const { session, error } =
await NativeStripeSdk.collectFinancialConnectionsAccounts(clientSecret);
if (error) {
return {
error,
};
}
return {
session: session!,
};
} catch (error: any) {
return {
error: createError(error),
};
}
};
/**
* Check if the app & device support adding this card to the native wallet.
* @param params An object containing fields for `primaryAccountIdentifier`, `cardLastFour`, and `testEnv`.
*
* @returns A promise resolving to an object of type CanAddCardToWalletResult. Check the `canAddCard` field, if it's true, you should show the `<AddToWalletButton />`
*/
export const canAddCardToWallet = async (
params: CanAddCardToWalletParams
): Promise<CanAddCardToWalletResult> => {
try {
const { canAddCard, details, error } =
await NativeStripeSdk.canAddCardToWallet(params);
if (error) {
return {
error,
};
}
return {
canAddCard: canAddCard as boolean,
details: details,
};
} catch (error: any) {
return {
error: createError(error),
};
}
};
/** @deprecated Please use `canAddCardToWallet` instead. */
export const isCardInWallet = async (params: {
cardLastFour: string;
}): Promise<IsCardInWalletResult> => {
try {
const { isInWallet, token, error } = await NativeStripeSdk.isCardInWallet(
params
);
if (error) {
return {
error,
};
}
return {
isInWallet: isInWallet as boolean,
token: token,
};
} catch (error: any) {
return {
error: createError(error),
};
}
};
export const Constants = NativeStripeSdk.getConstants();
/**
* Check if the relevant native wallet (Apple Pay on iOS, Google Pay on Android) is supported.
* @returns A boolean indicating whether or not the native wallet is supported.
*/
export const isPlatformPaySupported = async (params?: {
googlePay?: PlatformPay.IsGooglePaySupportedParams;
}): Promise<boolean> => {
return await NativeStripeSdk.isPlatformPaySupported(params ?? {});
};
/**
* Launches the relevant native wallet sheet (Apple Pay on iOS, Google Pay on Android) in order to confirm a Stripe [SetupIntent](https://stripe.com/docs/api/setup_intents).
* @param clientSecret The client secret of the SetupIntent.
* @param params an object describing the Apple Pay and Google Pay configurations.
* @returns An object with an error field if something went wrong or the flow was cancelled, otherwise an object with both `setupIntent` and `paymentMethod` fields.
*/
export const confirmPlatformPaySetupIntent = async (
clientSecret: string,
params: PlatformPay.ConfirmParams
): Promise<PlatformPay.ConfirmSetupIntentResult> => {
try {
const { error, setupIntent } = (await NativeStripeSdk.confirmPlatformPay(
clientSecret,
params,
false
)) as PlatformPay.ConfirmSetupIntentResult;
if (error) {
return {
error,
};
}
return {
setupIntent: setupIntent!,
};
} catch (error: any) {
return {
error,
};
}
};
/**
* Launches the relevant native wallet sheet (Apple Pay on iOS, Google Pay on Android) in order to confirm a Stripe [PaymentIntent](https://stripe.com/docs/api/payment_intents).
* @param clientSecret The client secret of the PaymentIntent.
* @param params an object describing the Apple Pay and Google Pay configurations.
* @returns An object with an error field if something went wrong or the flow was cancelled, otherwise an object with both `paymentIntent` and `paymentMethod` fields.
*/
export const confirmPlatformPayPayment = async (
clientSecret: string,
params: PlatformPay.ConfirmParams
): Promise<PlatformPay.ConfirmPaymentResult> => {
try {
const { error, paymentIntent } = (await NativeStripeSdk.confirmPlatformPay(
clientSecret,
params,
true
)) as PlatformPay.ConfirmPaymentResult;
if (error) {
return {
error,
};
}
return {
paymentIntent: paymentIntent!,
};
} catch (error: any) {
return {
error,
};
}
};
/**
* iOS only, this will always return false on Android. Dismisses the Apple Pay sheet if it is open.
* @returns A boolean indicating whether or not the sheet was successfully closed. Will return false if the Apple Pay sheet was not open.
*/
export const dismissPlatformPay = async (): Promise<boolean> => {
if (Platform.OS !== 'ios') {
return false;
}
try {
const didDismiss = await NativeStripeSdk.dismissPlatformPay();
return didDismiss;
} catch (error: any) {
return false;
}
};
/**
* Launches the relevant native wallet sheet (Apple Pay on iOS, Google Pay on Android) in order to create a Stripe [PaymentMethod](https://stripe.com/docs/api/payment_methods).
* @param params an object describing the Apple Pay and Google Pay configurations.
* @returns An object with an error field if something went wrong or the flow was cancelled, otherwise an object with a `paymentMethod` field.
*/
export const createPlatformPayPaymentMethod = async (
params: PlatformPay.PaymentMethodParams
): Promise<PlatformPay.PaymentMethodResult> => {
try {
const { error, paymentMethod, shippingContact } =
(await NativeStripeSdk.createPlatformPayPaymentMethod(
params,
false
)) as PlatformPay.PaymentMethodResult;
if (error) {
return {
error,
};
}
return {
paymentMethod: paymentMethod!,
shippingContact,
};
} catch (error: any) {
return {
error,
};
}
};
/**
* @deprecated The Tokens API is deprecated, you should use Payment Methods and `createPlatformPayPaymentMethod` instead. Launches the relevant native wallet sheet (Apple Pay on iOS, Google Pay on Android) in order to create a Stripe [token](https://stripe.com/docs/api/tokens).
* @param params an object describing the Apple Pay and Google Pay configurations.
* @returns An object with an error field if something went wrong or the flow was cancelled, otherwise an object with a `token` field.
*/
export const createPlatformPayToken = async (
params: PlatformPay.PaymentMethodParams
): Promise<PlatformPay.TokenResult> => {
try {
const { error, token, shippingContact } =
(await NativeStripeSdk.createPlatformPayPaymentMethod(
params,
true
)) as PlatformPay.TokenResult;
if (error) {
return {
error,
};
}
return {
token: token!,
shippingContact,
};
} catch (error: any) {
return {
error,
};
}
};
/**
* iOS only. Update different items on the Apple Pay sheet, including the summary items, the shipping methods, and any errors shown. iOS only, this is a no-op on Android.
* @param params an object describing the Apple Pay configuration, with the following fields:
* - cartItems An array of payment summary items to display in the Apple Pay sheet.
* - shippingMethods An array of shipping methods to display in the Apple Pay sheet.
* - errors An array of errors associated with the user's input that must be corrected to proceed with payment. These errors will be shown in the Apple Pay sheet.
*
* @returns An object with an optional 'error' field, which is only populated if something went wrong.
*/
export const updatePlatformPaySheet = async (params: {
applePay: {
cartItems: Array<PlatformPay.CartSummaryItem>;
shippingMethods: Array<PlatformPay.ShippingMethod>;
errors: Array<PlatformPay.ApplePaySheetError>;
};
}): Promise<{
error?: StripeError<PlatformPayError>;
}> => {
if (Platform.OS !== 'ios') {
return {};
}
try {
await NativeStripeSdk.updatePlatformPaySheet(
params.applePay.cartItems,
params.applePay.shippingMethods,
params.applePay.errors
);
return {};
} catch (error: any) {
return {
error,
};
}
};
/**
* iOS only, this is a no-op on Android. Use this method to move users to the interface for adding credit cards.
* This method transfers control to the Wallet app on iPhone or to the Settings
* app on iPad. For devices that don’t support Apple Pay, this method does nothing.
*/
export const openPlatformPaySetup = async (): Promise<void> => {
if (Platform.OS === 'ios') {
await NativeStripeSdk.openApplePaySetup();
}
};