@getopenpay/openpay-js 0.2.10 → 0.2.12
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/dist/index.d.ts +105 -44
- package/dist/index.es.js +1991 -1539
- package/dist/index.umd.js +15 -15
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
import { ApplePayOption } from '@stripe/stripe-js/dist/stripe-js/elements/apple-pay';
|
|
2
1
|
import { PaymentRequest as PaymentRequest_2 } from '@stripe/stripe-js';
|
|
3
2
|
import { Subject } from 'rxjs';
|
|
4
3
|
import { z } from 'zod';
|
|
5
4
|
|
|
6
|
-
declare type AirwallexApplePayFlowCustomParams = {
|
|
7
|
-
overridePaymentRequest?: {
|
|
8
|
-
amount: Amount;
|
|
9
|
-
pending?: boolean;
|
|
10
|
-
label?: string;
|
|
11
|
-
applePayPaymentRequest?: ApplePayJS.ApplePayPaymentRequest;
|
|
12
|
-
};
|
|
13
|
-
defaultFieldValues?: DefaultFieldValues;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
declare type AirwallexGooglePayFlowCustomParams = {
|
|
17
|
-
overridePaymentRequest?: {
|
|
18
|
-
amount: Amount;
|
|
19
|
-
pending?: boolean;
|
|
20
|
-
googlePayPaymentRequest?: google.payments.api.PaymentDataRequest;
|
|
21
|
-
};
|
|
22
|
-
defaultFieldValues?: DefaultFieldValues;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
5
|
declare type AllCallbacks = {
|
|
26
6
|
onFocus?: (elementId: string, field: AllFieldNames) => void;
|
|
27
7
|
onBlur?: (elementId: string, field: AllFieldNames) => void;
|
|
@@ -53,6 +33,25 @@ declare const Amount = z.object({
|
|
|
53
33
|
|
|
54
34
|
declare type Amount = z.infer<typeof Amount>;
|
|
55
35
|
|
|
36
|
+
declare type ApplePayFlowCustomParams = {
|
|
37
|
+
/**
|
|
38
|
+
* In case of multiple processors available for ApplePay, the preferredProcessor setting will
|
|
39
|
+
* determine which processor to use.
|
|
40
|
+
* If `preferredProcessor` is not set or is not available, the first available processor will be used
|
|
41
|
+
*
|
|
42
|
+
* **Note**: this processor choice is for the whole process of showing PaymentRequest UI, verification and charging.
|
|
43
|
+
* It won't perform fallback processor charging when payment failed.
|
|
44
|
+
*/
|
|
45
|
+
preferredProcessor?: PaymentProcessor;
|
|
46
|
+
overridePaymentRequest?: {
|
|
47
|
+
amount: Amount;
|
|
48
|
+
pending?: boolean;
|
|
49
|
+
label?: string;
|
|
50
|
+
applePayPaymentRequest?: ApplePayJS.ApplePayPaymentRequest;
|
|
51
|
+
};
|
|
52
|
+
defaultFieldValues?: DefaultFieldValues;
|
|
53
|
+
};
|
|
54
|
+
|
|
56
55
|
declare type CdeConnection = {
|
|
57
56
|
send: (data: CdeMessage) => Promise<unknown>;
|
|
58
57
|
};
|
|
@@ -235,16 +234,37 @@ declare class FormCallbacks {
|
|
|
235
234
|
}
|
|
236
235
|
}
|
|
237
236
|
|
|
238
|
-
declare type
|
|
237
|
+
declare type GooglePayFlowCustomParams = {
|
|
238
|
+
/**
|
|
239
|
+
* In case of multiple processors available for GooglePay, the preferredProcessor setting will
|
|
240
|
+
* determine which processor to use.
|
|
241
|
+
* If `preferredProcessor` is not set or is not available, the first available processor will be used
|
|
242
|
+
*
|
|
243
|
+
* **Note**: this processor choice is for the whole process of showing PaymentRequest UI, verification and charging.
|
|
244
|
+
* It won't perform fallback processor charging when payment failed.
|
|
245
|
+
*/
|
|
246
|
+
preferredProcessor?: PaymentProcessor;
|
|
247
|
+
overridePaymentRequest?: {
|
|
248
|
+
amount: Amount;
|
|
249
|
+
pending?: boolean;
|
|
250
|
+
label?: string;
|
|
251
|
+
googlePayPaymentRequest?: PaymentDataRequest;
|
|
252
|
+
};
|
|
253
|
+
defaultFieldValues?: DefaultFieldValues;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
declare type InitApplePayFlowResult = {
|
|
257
|
+
processor: PaymentProcessor;
|
|
239
258
|
isAvailable: boolean;
|
|
240
259
|
isLoading: boolean;
|
|
241
|
-
startFlow: (customParams?:
|
|
260
|
+
startFlow: (customParams?: ApplePayFlowCustomParams) => Promise<void>;
|
|
242
261
|
};
|
|
243
262
|
|
|
244
|
-
declare type
|
|
263
|
+
declare type InitGooglePayFlowResult = {
|
|
264
|
+
processor: PaymentProcessor;
|
|
245
265
|
isAvailable: boolean;
|
|
246
266
|
isLoading: boolean;
|
|
247
|
-
startFlow: (customParams?:
|
|
267
|
+
startFlow: (customParams?: GooglePayFlowCustomParams) => Promise<void>;
|
|
248
268
|
};
|
|
249
269
|
|
|
250
270
|
declare type InitialStatus = {
|
|
@@ -288,6 +308,7 @@ declare type InitStripePrFlowResult =
|
|
|
288
308
|
};
|
|
289
309
|
|
|
290
310
|
declare type InitStripePrFlowSuccess = {
|
|
311
|
+
processor: 'stripe';
|
|
291
312
|
isAvailable: true;
|
|
292
313
|
// Passed to RunFlow
|
|
293
314
|
pr: PaymentRequest_2;
|
|
@@ -296,6 +317,7 @@ declare type InitStripePrFlowSuccess = {
|
|
|
296
317
|
applePay: boolean;
|
|
297
318
|
googlePay: boolean;
|
|
298
319
|
};
|
|
320
|
+
startFlow: (provider: PaymentRequestProvider, params?: PaymentRequestStartParams) => Promise<void>;
|
|
299
321
|
};
|
|
300
322
|
|
|
301
323
|
declare const LoadedEventPayload = z.object({
|
|
@@ -507,12 +529,21 @@ declare const OjsFlows = {
|
|
|
507
529
|
run: runAirwallexApplePayFlow,
|
|
508
530
|
},
|
|
509
531
|
|
|
532
|
+
authorizeNetApplePay: {
|
|
533
|
+
init: initAuthnetApplePayFlow,
|
|
534
|
+
run: runAuthnetApplePayFlow,
|
|
535
|
+
},
|
|
536
|
+
|
|
537
|
+
authorizeNetGooglePay: {
|
|
538
|
+
init: initAuthnetGooglePayFlow,
|
|
539
|
+
run: runAuthnetGooglePayFlow,
|
|
540
|
+
},
|
|
510
541
|
// 👉 Add more flows here
|
|
511
542
|
|
|
512
543
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
513
544
|
} satisfies Record<string, OjsFlow<any, any>>;
|
|
514
545
|
|
|
515
|
-
declare type OnCheckoutError = (message: string) => void;
|
|
546
|
+
declare type OnCheckoutError = (message: string, errorCode?: string) => void;
|
|
516
547
|
|
|
517
548
|
declare type OnCheckoutStarted = () => void;
|
|
518
549
|
|
|
@@ -551,11 +582,19 @@ export declare class OpenPayForm {
|
|
|
551
582
|
initialize: (initParams: InitOjsFlowParams) => Promise<void>;
|
|
552
583
|
};
|
|
553
584
|
readonly airwallexGooglePay: {
|
|
554
|
-
publisher: LoadedOncePublisher<
|
|
585
|
+
publisher: LoadedOncePublisher<InitGooglePayFlowResult>;
|
|
555
586
|
initialize: (initParams: InitOjsFlowParams) => Promise<void>;
|
|
556
587
|
};
|
|
557
588
|
readonly airwallexApplePay: {
|
|
558
|
-
publisher: LoadedOncePublisher<
|
|
589
|
+
publisher: LoadedOncePublisher<InitApplePayFlowResult>;
|
|
590
|
+
initialize: (initParams: InitOjsFlowParams) => Promise<void>;
|
|
591
|
+
};
|
|
592
|
+
readonly authorizeNetGooglePay: {
|
|
593
|
+
publisher: LoadedOncePublisher<InitGooglePayFlowResult>;
|
|
594
|
+
initialize: (initParams: InitOjsFlowParams) => Promise<void>;
|
|
595
|
+
};
|
|
596
|
+
readonly authorizeNetApplePay: {
|
|
597
|
+
publisher: LoadedOncePublisher<InitApplePayFlowResult>;
|
|
559
598
|
initialize: (initParams: InitOjsFlowParams) => Promise<void>;
|
|
560
599
|
};
|
|
561
600
|
};
|
|
@@ -592,22 +631,26 @@ export declare class OpenPayForm {
|
|
|
592
631
|
getAvailablePaymentMethods: () => ({
|
|
593
632
|
name: string;
|
|
594
633
|
} | {
|
|
595
|
-
|
|
596
|
-
pr: PaymentRequest_2;
|
|
597
|
-
availableProviders: {
|
|
598
|
-
applePay: boolean;
|
|
599
|
-
googlePay: boolean;
|
|
600
|
-
};
|
|
601
|
-
name: string;
|
|
602
|
-
} | {
|
|
634
|
+
processor: PaymentProcessor;
|
|
603
635
|
isAvailable: boolean;
|
|
604
636
|
isLoading: boolean;
|
|
605
|
-
startFlow: (customParams?:
|
|
637
|
+
startFlow: (customParams?: ApplePayFlowCustomParams) => Promise<void>;
|
|
606
638
|
name: string;
|
|
607
639
|
} | {
|
|
640
|
+
processor: PaymentProcessor;
|
|
608
641
|
isAvailable: boolean;
|
|
609
642
|
isLoading: boolean;
|
|
610
|
-
startFlow: (customParams?:
|
|
643
|
+
startFlow: (customParams?: GooglePayFlowCustomParams) => Promise<void>;
|
|
644
|
+
name: string;
|
|
645
|
+
} | {
|
|
646
|
+
processor: "stripe";
|
|
647
|
+
isAvailable: true;
|
|
648
|
+
pr: PaymentRequest_2;
|
|
649
|
+
availableProviders: {
|
|
650
|
+
applePay: boolean;
|
|
651
|
+
googlePay: boolean;
|
|
652
|
+
};
|
|
653
|
+
startFlow: (provider: PaymentRequestProvider, params?: PaymentRequestStartParams) => Promise<void>;
|
|
611
654
|
name: string;
|
|
612
655
|
} | {
|
|
613
656
|
isAvailable: true;
|
|
@@ -617,7 +660,7 @@ export declare class OpenPayForm {
|
|
|
617
660
|
isAvailable: false;
|
|
618
661
|
name: string;
|
|
619
662
|
})[] | undefined;
|
|
620
|
-
generalSubmit: <T extends SubmitMethod>(method: T, settings?: SubmitSettings<T>) => void |
|
|
663
|
+
generalSubmit: <T extends SubmitMethod>(method: T, settings?: SubmitSettings<T>) => Promise<void> | undefined;
|
|
621
664
|
/**
|
|
622
665
|
* Alias for submitCard
|
|
623
666
|
*/
|
|
@@ -629,6 +672,12 @@ export declare class OpenPayForm {
|
|
|
629
672
|
updateCallbacks: (newCallbacks: AllCallbacks) => void;
|
|
630
673
|
}
|
|
631
674
|
|
|
675
|
+
declare type PaymentDataRequest = google.payments.api.PaymentDataRequest;
|
|
676
|
+
|
|
677
|
+
declare const PaymentProcessor = z.enum(['stripe', 'airwallex', 'authorize_net']);
|
|
678
|
+
|
|
679
|
+
declare type PaymentProcessor = z.infer<typeof PaymentProcessor>;
|
|
680
|
+
|
|
632
681
|
declare const PaymentRequestProvider = z.enum(['apple_pay', 'google_pay']);
|
|
633
682
|
|
|
634
683
|
declare type PaymentRequestProvider = z.infer<typeof PaymentRequestProvider>;
|
|
@@ -636,8 +685,8 @@ declare type PaymentRequestProvider = z.infer<typeof PaymentRequestProvider>;
|
|
|
636
685
|
declare type PaymentRequestStartParams = {
|
|
637
686
|
overridePaymentRequest?: {
|
|
638
687
|
amount: Amount;
|
|
639
|
-
pending
|
|
640
|
-
|
|
688
|
+
pending?: boolean;
|
|
689
|
+
applePayPaymentRequest?: ApplePayJS.ApplePayPaymentRequest;
|
|
641
690
|
};
|
|
642
691
|
};
|
|
643
692
|
|
|
@@ -649,8 +698,10 @@ declare type PaymentRequestStatus = {
|
|
|
649
698
|
|
|
650
699
|
declare type ProcessorSpecificSubmitSettings<T extends SubmitMethod = SubmitMethod> = {
|
|
651
700
|
'pockyt-paypal': { useRedirectFlow?: boolean };
|
|
652
|
-
'airwallex-google-pay':
|
|
653
|
-
'airwallex-apple-pay':
|
|
701
|
+
'airwallex-google-pay': GooglePayFlowCustomParams;
|
|
702
|
+
'airwallex-apple-pay': ApplePayFlowCustomParams;
|
|
703
|
+
'authorizenet-google-pay': GooglePayFlowCustomParams;
|
|
704
|
+
'authorizenet-apple-pay': ApplePayFlowCustomParams;
|
|
654
705
|
}[T];
|
|
655
706
|
|
|
656
707
|
declare type PRStatuses = Record<PaymentRequestProvider, PaymentRequestStatus>;
|
|
@@ -671,9 +722,19 @@ declare type StripeLinkController = {
|
|
|
671
722
|
waitForButtonToMount: () => Promise<HTMLElement>;
|
|
672
723
|
};
|
|
673
724
|
|
|
674
|
-
declare
|
|
725
|
+
export declare const SubmitMethod = z.nativeEnum(SubmitMethods);
|
|
726
|
+
|
|
727
|
+
export declare type SubmitMethod = z.infer<typeof SubmitMethod>;
|
|
728
|
+
|
|
729
|
+
export declare enum SubmitMethods {
|
|
730
|
+
pockytPaypal = 'pockyt-paypal',
|
|
731
|
+
airwallexGooglePay = 'airwallex-google-pay',
|
|
732
|
+
airwallexApplePay = 'airwallex-apple-pay',
|
|
733
|
+
authorizenetGooglePay = 'authorizenet-google-pay',
|
|
734
|
+
authorizenetApplePay = 'authorizenet-apple-pay',
|
|
735
|
+
}
|
|
675
736
|
|
|
676
|
-
declare type SubmitSettings<T extends SubmitMethod = SubmitMethod> = ProcessorSpecificSubmitSettings<T> &
|
|
737
|
+
export declare type SubmitSettings<T extends SubmitMethod = SubmitMethod> = ProcessorSpecificSubmitSettings<T> &
|
|
677
738
|
CommonSubmitSettings;
|
|
678
739
|
|
|
679
740
|
declare type SuccessStatus<T> = {
|