@primer-io/checkout-web 2.0.0-alpha.3 → 2.0.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/dist/index.d.ts CHANGED
@@ -23,6 +23,8 @@ export interface PayPalOptions extends PositionalConfig {
23
23
  paymentFlow?: PaymentFlow;
24
24
  }
25
25
  export declare enum PaymentInstrumentType {
26
+ PRIMER_PAYPAL = "PRIMER_PAYPAL",
27
+ NETS = "NETS",
26
28
  STRIPE_GIROPAY = "STRIPE_GIROPAY",
27
29
  MOLLIE_GIROPAY = "MOLLIE_GIROPAY",
28
30
  MOLLIE_EPS = "MOLLIE_EPS",
@@ -49,6 +51,7 @@ export declare enum PaymentInstrumentType {
49
51
  PAY_NL_GIROPAY = "PAY_NL_GIROPAY",
50
52
  PAY_NL_PAYCONIQ = "PAY_NL_PAYCONIQ",
51
53
  HOOLAH = "HOOLAH",
54
+ ADYEN_BLIK = "ADYEN_BLIK",
52
55
  ADYEN_VIPPS = "ADYEN_VIPPS",
53
56
  ADYEN_GIROPAY = "ADYEN_GIROPAY",
54
57
  ADYEN_SOFORT = "ADYEN_SOFORT",
@@ -66,6 +69,8 @@ export declare enum PaymentInstrumentType {
66
69
  ATOME = "ATOME"
67
70
  }
68
71
  export declare enum PaymentMethodType {
72
+ PRIMER_PAYPAL = "PRIMER_PAYPAL",
73
+ NETS = "NETS",
69
74
  STRIPE_GIROPAY = "STRIPE_GIROPAY",
70
75
  MOLLIE_GIROPAY = "MOLLIE_GIROPAY",
71
76
  MOLLIE_EPS = "MOLLIE_EPS",
@@ -92,6 +97,7 @@ export declare enum PaymentMethodType {
92
97
  PAY_NL_GIROPAY = "PAY_NL_GIROPAY",
93
98
  PAY_NL_PAYCONIQ = "PAY_NL_PAYCONIQ",
94
99
  HOOLAH = "HOOLAH",
100
+ ADYEN_BLIK = "ADYEN_BLIK",
95
101
  ADYEN_MOBILEPAY = "ADYEN_MOBILEPAY",
96
102
  ADYEN_VIPPS = "ADYEN_VIPPS",
97
103
  ADYEN_GIROPAY = "ADYEN_GIROPAY",
@@ -113,11 +119,7 @@ export declare enum TokenType {
113
119
  SINGLE_USE = "SINGLE_USE",
114
120
  MULTI_USE = "MULTI_USE"
115
121
  }
116
- export declare type Callable<T extends unknown[] = [
117
- ], U = void> = (...args: T) => U;
118
122
  export declare type Nullable<T> = T | null;
119
- export declare type MaybeThunk<T> = T | Callable<[
120
- ], T>;
121
123
  export declare type GooglePayButtonType = "long" | "short";
122
124
  export declare type GooglePayButtonColor = "default" | "black" | "white";
123
125
  export interface GooglePayOptions extends PositionalConfig {
@@ -160,19 +162,25 @@ export declare enum ErrorCode {
160
162
  PAYMENT_METHOD_NOT_COMPATIBLE = "PAYMENT_METHOD_NOT_COMPATIBLE",
161
163
  RESUME_ERROR = "RESUME_ERROR",
162
164
  TAX_ERROR = "TAX_ERROR",
163
- VALIDATION_ERROR = "VALIDATION_ERROR"
165
+ VALIDATION_ERROR = "VALIDATION_ERROR",
166
+ PAYMENT_FAILED = "PAYMENT_FAILED",
167
+ PAYMENT_CREATION_ABORTED = "PAYMENT_CREATION_ABORTED",
168
+ PAYMENT_CREATION_DISABLED = "PAYMENT_CREATION_DISABLED",
169
+ CLIENT_SESSION_UPDATE_ERROR = "CLIENT_SESSION_UPDATE_ERROR"
164
170
  }
165
171
  export interface ErrorOptions {
166
172
  message: string;
167
173
  diagnosticsId?: string;
168
174
  errorId?: string;
169
175
  data?: any;
176
+ isFromDeveloper?: boolean;
170
177
  }
171
178
  declare class PrimerClientError extends Error {
172
179
  code: ErrorCode;
173
180
  message: string;
174
181
  diagnosticsId: Nullable<string>;
175
182
  data?: any;
183
+ isFromDeveloper: boolean;
176
184
  static fromErrorCode(code: ErrorCode, options: ErrorOptions): PrimerClientError;
177
185
  constructor(code: ErrorCode, options: ErrorOptions);
178
186
  }
@@ -299,32 +307,14 @@ export interface VaultMenuStyle {
299
307
  confirmButton?: BlockStyle & TextStyle;
300
308
  };
301
309
  }
302
- export interface SceneTransition {
303
- opacity?: string | number;
304
- transform?: string;
305
- transition?: string;
306
- }
307
- export interface SceneTransitionEventStyle {
308
- enter?: SceneTransition;
309
- entering?: SceneTransition;
310
- exit?: SceneTransition;
311
- exiting?: SceneTransition;
312
- }
313
- export interface SceneTransitionStyle extends SceneTransitionEventStyle {
314
- content: {
315
- transition?: string;
316
- };
317
- push?: SceneTransitionEventStyle;
318
- pop?: SceneTransitionEventStyle;
319
- }
320
- export interface InternalStyle {
321
- scene?: SceneTransitionStyle;
322
- }
323
310
  export interface NetworkErrorStyles {
324
311
  button?: {
325
312
  base: BlockStyle & TextStyle;
326
313
  };
327
314
  }
315
+ export interface ProcessingIndicatorStyle {
316
+ color?: string;
317
+ }
328
318
  export interface CheckoutStyle {
329
319
  fontFaces?: Array<FontFace>;
330
320
  stylesheets?: Array<Stylesheet>;
@@ -348,17 +338,143 @@ export interface CheckoutStyle {
348
338
  vaultMenu?: VaultMenuStyle;
349
339
  backButton?: BackButtonStyle;
350
340
  separator?: SeparatorStyle;
341
+ processingIndicator?: ProcessingIndicatorStyle;
351
342
  }
352
343
  export declare enum CheckoutUXFlow {
353
344
  CHECKOUT = "CHECKOUT",
354
345
  MANAGE_PAYMENT_METHODS = "MANAGE_PAYMENT_METHODS",
355
346
  SINGLE_PAYMENT_METHOD_CHECKOUT = "SINGLE_PAYMENT_METHOD_CHECKOUT"
356
347
  }
357
- export interface CardMetadata {
358
- type: CardNetwork | null;
359
- possibleTypes: string[];
360
- cvvLength: number;
361
- cardNumberLength: number;
348
+ export interface ClientSessionLineItem {
349
+ itemId: string;
350
+ description: string;
351
+ amount: number;
352
+ quantity: number;
353
+ discountAmount?: number;
354
+ taxCode?: string;
355
+ taxAmount?: number;
356
+ }
357
+ export interface ClientSessionShipping {
358
+ amount: number;
359
+ }
360
+ export interface ClientSessionFeeItem {
361
+ type?: string;
362
+ description?: string;
363
+ amount: number;
364
+ }
365
+ export interface ClientSessionAddress {
366
+ firstName?: string;
367
+ lastName?: string;
368
+ addressLine1?: string;
369
+ addressLine2?: string;
370
+ city?: string;
371
+ state?: string;
372
+ countryCode?: string;
373
+ postalCode?: string;
374
+ }
375
+ export interface ClientSession {
376
+ orderId?: string;
377
+ currencyCode?: string;
378
+ lineItems?: ClientSessionLineItem[];
379
+ totalAmount?: number;
380
+ customerId?: string;
381
+ orderDetails?: {
382
+ countryCode?: string;
383
+ shipping?: ClientSessionShipping;
384
+ fees?: ClientSessionFeeItem[];
385
+ };
386
+ customer?: {
387
+ emailAddress?: string;
388
+ mobileNumber?: string;
389
+ firstName?: string;
390
+ lastName?: string;
391
+ billingAddress?: ClientSessionAddress;
392
+ shippingAddress?: ClientSessionAddress;
393
+ taxId?: string;
394
+ nationalDocumentId?: string;
395
+ };
396
+ paymentMethod?: {
397
+ vaultOnSuccess?: boolean;
398
+ options?: Record<string, any>;
399
+ };
400
+ }
401
+ export interface TransitionDurationOptions {
402
+ enter?: number;
403
+ exit?: number;
404
+ }
405
+ export interface SubmitButtonOptions {
406
+ useBuiltInButton?: boolean;
407
+ onVisible?: (isVisible: boolean, context: {
408
+ currentSceneId: string;
409
+ previousSceneId?: string;
410
+ }) => void;
411
+ onContentChange?: (content: string, context: {
412
+ currentSceneId: string;
413
+ }) => void;
414
+ onDisable?: (isDisabled: boolean, context: {
415
+ currentSceneId: string;
416
+ }) => void;
417
+ onLoading?: (isLoading: boolean, context: {
418
+ currentSceneId: string;
419
+ }) => void;
420
+ }
421
+ export interface ProcessingIndicatorOptions {
422
+ visible?: boolean;
423
+ }
424
+ export interface FormOptions {
425
+ inputLabelsVisible?: boolean;
426
+ }
427
+ export declare type CardPreferredFlow = "DEDICATED_SCENE" | "EMBEDDED_IN_HOME";
428
+ export interface CheckoutCardOptions {
429
+ cardholderName?: {
430
+ /**
431
+ * Only works if the cardholder name is visible
432
+ */
433
+ required?: boolean;
434
+ /**
435
+ * @deprecated Set it on your Dashboard
436
+ */
437
+ visible?: boolean;
438
+ placeholder?: Label;
439
+ };
440
+ cardNumber?: {
441
+ placeholder?: Label;
442
+ };
443
+ expiryDate?: {
444
+ placeholder?: Label;
445
+ };
446
+ cvv?: {
447
+ placeholder?: Label;
448
+ };
449
+ preferredFlow?: CardPreferredFlow;
450
+ }
451
+ export interface ErrorMessageOptions {
452
+ disabled?: boolean;
453
+ onErrorMessageShow?: (message: string) => void;
454
+ onErrorMessageHide?: () => void;
455
+ }
456
+ export declare enum SuccessScreenType {
457
+ PAYMENT_METHOD = "PAYMENT_METHOD",
458
+ CHECK = "CHECK"
459
+ }
460
+ export interface CardDetails {
461
+ last4Digits: string;
462
+ cardNumber: string;
463
+ name: string;
464
+ icon: string;
465
+ network: string;
466
+ userDescription?: string;
467
+ }
468
+ export declare type CardNetwork = "american-express" | "diners-club" | "discover" | "elo" | "hiper" | "hipercard" | "interac" | "jcb" | "maestro" | "mastercard" | "mir" | "unionpay" | "private-label" | "visa";
469
+ export interface PayPalDetails {
470
+ icon: string;
471
+ email?: string;
472
+ }
473
+ export interface CustomizablePaymentMethodButton {
474
+ logoSrc: string;
475
+ background: string;
476
+ logoAlt?: string;
477
+ text?: string;
362
478
  }
363
479
  export declare type KlarnaPaymentCategoryType = "pay_now" | "pay_later" | "pay_over_time";
364
480
  export declare type KlarnaSupportedLocale = "de-AT" | "en-AT" | "da-DK" | "en-DK" | "fi-FI" | "sv-FI" | "en-FI" | "de-DE" | "en-DE" | "nl-NL" | "en-NL" | "nb-NO" | "en-NO" | "sv-SE" | "en-SE" | "de-CH" | "fr-CH" | "it-CH" | "en-CH" | "en-GB" | "en-US" | "en-AU" | "nl-BE" | "fr-BE" | "es-ES" | "it-IT";
@@ -384,21 +500,15 @@ export interface KlarnaOptions {
384
500
  paymentFlow?: PaymentFlow;
385
501
  recurringPaymentDescription?: string;
386
502
  allowedPaymentCategories?: KlarnaPaymentCategoryType[];
387
- shippingAddress: KlarnaAddress;
388
- billingAddress: KlarnaAddress;
389
503
  }
390
504
  export declare type SupportedLocale = "de" | "de-DE" | "en" | "en-GB" | "es" | "es-ES" | "fr" | "fr-FR" | "it" | "it-IT";
391
- export declare type Alpha2CountryCode = "ES" | "FR" | "GB" | "DE" | "PL" | "IT" | "US";
392
- export declare type Alpha3CurrencyCode = "EUR" | "GBP" | "USD";
505
+ export declare type Alpha2CountryCode = string;
506
+ export declare type Alpha3CurrencyCode = string;
393
507
  export declare type ElementOrID = Nullable<string | HTMLElement>;
394
508
  export declare type ValidationErrorType = "required" | "invalid";
395
509
  export declare type Label<T extends Record<string, unknown> = Record<string, unknown>> = string | ((options: {
396
510
  locale: SupportedLocale;
397
511
  } | T) => string);
398
- export interface ClientContextOptions {
399
- credentials: PrimerClientCredentials;
400
- thirdPartyScriptTimeout?: number;
401
- }
402
512
  export declare type ResumeToken = {
403
513
  resumeToken: string;
404
514
  paymentId?: string;
@@ -430,12 +540,6 @@ export interface FormState {
430
540
  submitted: boolean;
431
541
  }
432
542
  export declare type InlineStyleMap = Partial<Record<keyof CSSStyleDeclaration, string>>;
433
- export interface PrimerClientCredentials {
434
- clientToken: string;
435
- }
436
- export interface PrimerClientOptions {
437
- credentials: PrimerClientCredentials;
438
- }
439
543
  export interface ExternalPayerInfo {
440
544
  externalPayerId: string;
441
545
  firstName?: string;
@@ -561,79 +665,6 @@ export interface VaultInformation {
561
665
  export interface VaultDetails {
562
666
  currencyCode: Alpha3CurrencyCode;
563
667
  }
564
- export declare type CardPreferredFlow = "DEDICATED_SCENE" | "EMBEDDED_IN_HOME";
565
- export interface CheckoutCardOptions {
566
- css?: string;
567
- /**
568
- * @deprecated Use `cardholderName.required` instead
569
- */
570
- vault?: MaybeThunk<boolean>;
571
- cardholderName?: {
572
- /**
573
- * Only works if the cardholder name is visible
574
- */
575
- required?: boolean;
576
- /**
577
- * @deprecated Set it on your Dashboard
578
- */
579
- visible?: boolean;
580
- placeholder?: Label;
581
- };
582
- cardNumber?: {
583
- placeholder?: Label;
584
- };
585
- expiryDate?: {
586
- placeholder?: Label;
587
- };
588
- cvv?: {
589
- placeholder?: Label;
590
- };
591
- preferredFlow?: CardPreferredFlow;
592
- }
593
- export interface TransitionDurationOptions {
594
- enter?: number;
595
- exit?: number;
596
- }
597
- export interface SubmitButtonOptions {
598
- /**
599
- * @deprecated Use `useBuiltInButton` instead
600
- */
601
- visible?: boolean;
602
- useBuiltInButton?: boolean;
603
- onVisible?: (isVisible: boolean, context: {
604
- currentSceneId: string;
605
- previousSceneId?: string;
606
- }) => void;
607
- onContentChange?: (content: string, context: {
608
- currentSceneId: string;
609
- }) => void;
610
- onDisable?: (isDisabled: boolean, context: {
611
- currentSceneId: string;
612
- }) => void;
613
- onLoading?: (isLoading: boolean, context: {
614
- currentSceneId: string;
615
- }) => void;
616
- }
617
- export interface ProcessingIndicatorOptions {
618
- visible?: boolean;
619
- }
620
- export interface FormOptions {
621
- inputLabelsVisible?: boolean;
622
- }
623
- export declare type CardNetwork = "american-express" | "diners-club" | "discover" | "elo" | "hiper" | "hipercard" | "interac" | "jcb" | "maestro" | "mastercard" | "mir" | "unionpay" | "private-label" | "visa";
624
- export interface ErrorMessageOptions {
625
- disabled?: boolean;
626
- onErrorMessageShow?: (message: string) => void;
627
- onErrorMessageHide?: () => void;
628
- }
629
- export declare enum SuccessScreenType {
630
- /**
631
- * @deprecated Use `PAYMENT_METHOD` instead
632
- */
633
- PaymentMethod = "PaymentMethod",
634
- PAYMENT_METHOD = "PAYMENT_METHOD",
635
- CHECK = "CHECK"
636
- }
637
668
  export declare type CheckSuccessScreenOptions = {
638
669
  type: SuccessScreenType.CHECK;
639
670
  title: Label;
@@ -658,27 +689,6 @@ export declare type SceneOptions = {
658
689
  onEntering?: (sceneId: string) => void;
659
690
  transition?: SceneTransitionOptions | false;
660
691
  };
661
- export declare type ClientSessionAction = {
662
- type: ActionType;
663
- params?: ActionParameters;
664
- };
665
- export declare type ActionType = "SELECT_PAYMENT_METHOD" | "UNSELECT_PAYMENT_METHOD" | "SET_BILLING_ADDRESS" | "SET_EMAIL_ADDRESS";
666
- export declare type ActionParameters = SelectPaymentMethodParamters | DefaulActionParameters | SetBillingAddressParameters | SetCustomerInformationParameters;
667
- export declare type SelectPaymentMethodParamters = {
668
- paymentMethodType: string;
669
- binData?: BinData;
670
- };
671
- export declare type DefaulActionParameters = {
672
- type: string;
673
- };
674
- export declare type SetBillingAddressParameters = {
675
- billingAddress: {
676
- postalCode: string;
677
- };
678
- };
679
- export declare type SetCustomerInformationParameters = {
680
- emailAddress?: string;
681
- };
682
692
  export interface BinData {
683
693
  network?: string;
684
694
  issuerCountryCode?: string;
@@ -692,12 +702,6 @@ export interface BinData {
692
702
  productCode?: string;
693
703
  productName?: string;
694
704
  }
695
- export declare type ClientSessionActionData = {
696
- actions: ClientSessionAction[];
697
- clientToken?: string;
698
- };
699
- export declare type OnTokenizeShouldStart = () => boolean | Promise<boolean>;
700
- export declare type OnTokenizeDidNotStart = (reason: string) => void;
701
705
  export declare type RedirectOptions = {
702
706
  returnUrl?: string;
703
707
  /**
@@ -708,49 +712,75 @@ export declare type RedirectOptions = {
708
712
  export declare type AdvancedOptions = {
709
713
  platform?: "STANDALONE" | "MAGENTO";
710
714
  };
711
- export declare type PaymentStatus = "PENDING" | "FAILED" | "AUTHORIZED" | "SETTLING" | "PARTIALLY_SETTLED" | "SETTLED" | "DECLINED" | "CANCELLED";
712
715
  export declare type Payment = {
713
716
  id: string;
714
- date: string;
715
- status: string;
716
717
  orderId: string;
717
718
  };
719
+ export declare type PaymentHandling = "AUTO" | "MANUAL";
720
+ export interface onBeforePaymentCreateHandler {
721
+ continuePaymentCreation: () => void;
722
+ abortPaymentCreation: () => void;
723
+ }
724
+ export interface OnCheckoutFailHandler {
725
+ showErrorMessage: (errorMessage?: string) => void;
726
+ }
718
727
  export interface PaymentHandlers {
719
- onPaymentStarted?: () => void;
720
- onPaymentSuccess?: (payment: Payment) => void;
721
- onPaymentError?: (error?: PrimerClientError, payment?: Payment) => void;
728
+ onBeforePaymentCreate?: (data: {
729
+ paymentMethodType?: PaymentMethodType;
730
+ }, handler: onBeforePaymentCreateHandler) => void;
731
+ onCheckoutComplete?: (data: {
732
+ payment: Payment;
733
+ }) => void;
734
+ onCheckoutFail?: (error: PrimerClientError, data: {
735
+ payment?: Payment;
736
+ }, handler: OnCheckoutFailHandler | undefined) => void;
722
737
  }
738
+ export declare type OnTokenizeShouldStart = (data: {
739
+ paymentMethodType?: PaymentMethodType;
740
+ }) => boolean | Promise<boolean>;
741
+ export declare type OnTokenizeDidNotStart = (reason: string) => void;
742
+ export declare type OnTokenizeError = (error: PrimerClientError) => void;
743
+ export interface OnTokenizeSuccessHandler {
744
+ handleSuccess(): any;
745
+ handleFailure(errorMessage?: string): any;
746
+ continueWithNewClientToken(clientToken: string): any;
747
+ }
748
+ export declare type OnTokenizeSuccess = (data: PaymentMethodToken, handler: OnTokenizeSuccessHandler) => void | Promise<void>;
749
+ export interface OnResumeSuccessHandler {
750
+ handleSuccess(): any;
751
+ handleFailure(errorMessage?: string): any;
752
+ continueWithNewClientToken(clientToken: string): any;
753
+ }
754
+ export declare type OnResumeSuccess = (data: ResumeToken, handler: OnResumeSuccessHandler) => void;
755
+ export declare type onResumeError = (error: PrimerClientError) => void;
723
756
  export interface TokenizationHandlers {
724
757
  onTokenizeShouldStart?: OnTokenizeShouldStart;
725
758
  onTokenizeDidNotStart?: OnTokenizeDidNotStart;
726
759
  onTokenizeStart?: () => void;
727
- onTokenizeSuccess: (data: PaymentMethodToken) => Promise<SuccessCallbackReturnType>;
728
- onTokenizeError?: (error: PrimerClientError) => void;
729
- onTokenizeProgress?: (evt: {
730
- type: string;
731
- }) => void;
732
- onResumeSuccess: (data: ResumeToken) => Promise<SuccessCallbackReturnType>;
733
- onResumeError?: (error: PrimerClientError) => void;
760
+ onTokenizeSuccess?: OnTokenizeSuccess;
761
+ onTokenizeError?: OnTokenizeError;
762
+ onResumeSuccess?: OnResumeSuccess;
763
+ onResumeError?: onResumeError;
734
764
  }
735
- export interface SinglePaymentMethodCheckoutOptions extends TokenizationHandlers, PaymentHandlers {
736
- countryCode?: Alpha2CountryCode;
737
- /**
738
- * @deprecated Use `orderDetails` instead
739
- */
740
- purchaseInfo?: PurchaseInformation;
765
+ export interface ClientSessionHandlers {
766
+ onClientSessionUpdate?: (clientSession: ClientSession) => void;
767
+ onBeforeClientSessionUpdate?: () => void;
768
+ }
769
+ export interface SinglePaymentMethodCheckoutOptions extends TokenizationHandlers, PaymentHandlers, ClientSessionHandlers {
741
770
  uxFlow: CheckoutUXFlow.SINGLE_PAYMENT_METHOD_CHECKOUT;
742
- scene?: SceneOptions;
743
771
  container: string | Element;
744
772
  paymentMethod: PaymentMethodType;
745
773
  locale?: SupportedLocale;
774
+ style?: CheckoutStyle;
775
+ submitButton?: SubmitButtonOptions;
776
+ processingIndicator?: ProcessingIndicatorOptions;
777
+ errorMessage?: ErrorMessageOptions;
778
+ successScreen?: SuccessScreenOptions;
779
+ form?: FormOptions;
780
+ scene?: SceneOptions;
781
+ vault?: VaultOptions;
746
782
  allowedCardNetworks?: CardNetwork[];
747
- onAmountChange?: (data: AmountChange) => void;
748
- onAmountChanging?: (isChanging: boolean) => void;
749
- onAmountChangeError?: (error: PrimerClientError) => void;
750
- onClientSessionActions?: (data: ClientSessionActionData) => Promise<{
751
- clientToken: string;
752
- } | false>;
753
- threeDSecure?: ThreeDSVerificationOptions;
783
+ redirect?: RedirectOptions;
754
784
  card?: CheckoutCardOptions;
755
785
  giftCard?: CustomizablePaymentMethodButton;
756
786
  paypal?: Omit<PayPalOptions, "container">;
@@ -758,255 +788,71 @@ export interface SinglePaymentMethodCheckoutOptions extends TokenizationHandlers
758
788
  applePay?: Omit<ApplePayOptions, "container">;
759
789
  klarna?: KlarnaOptions;
760
790
  directDebit?: DirectDebitOptions;
761
- submitButton?: SubmitButtonOptions;
762
- processingIndicator?: ProcessingIndicatorOptions;
763
- style?: CheckoutStyle;
764
- errorMessage?: ErrorMessageOptions;
765
- successScreen?: SuccessScreenOptions;
766
- form?: FormOptions;
767
- redirect?: RedirectOptions;
768
- /**
769
- * @deprecated Use setClientToken with new client token instead
770
- */
771
- customerDetails?: CustomerDetails;
772
- /**
773
- * @deprecated Use setClientToken with new client token instead
774
- */
775
- businessDetails?: BusinessDetails;
776
- /**
777
- * @deprecated Use setClientToken with new client token instead
778
- */
779
- orderDetails?: OrderDetails;
791
+ paymentHandling?: PaymentHandling;
780
792
  }
781
793
  export interface VaultManagerOptions {
782
- uxFlow: CheckoutUXFlow.MANAGE_PAYMENT_METHODS;
783
- scene?: SceneOptions;
784
794
  container: string | Element;
785
795
  locale?: SupportedLocale;
796
+ vaultOnly?: boolean;
797
+ deletionDisabled?: boolean;
798
+ style?: CheckoutStyle;
799
+ scene?: SceneOptions;
800
+ errorMessage?: ErrorMessageOptions;
801
+ form?: FormOptions;
802
+ submitButton?: SubmitButtonOptions;
803
+ processingIndicator?: ProcessingIndicatorOptions;
804
+ allowedCardNetworks?: CardNetwork[];
786
805
  card?: CheckoutCardOptions;
806
+ threeDSecure?: ThreeDSVerificationOptions;
787
807
  giftCard?: CustomizablePaymentMethodButton;
788
- allowedCardNetworks?: CardNetwork[];
808
+ directDebit?: DirectDebitOptions;
809
+ paypal?: Omit<PayPalOptions, "container">;
789
810
  onTokenizeShouldStart?: OnTokenizeShouldStart;
790
811
  onTokenizeDidNotStart?: OnTokenizeDidNotStart;
791
812
  onTokenizeStart?: () => void;
792
- onTokenizeSuccess: (data: PaymentMethodToken) => void;
813
+ onTokenizeSuccess?: (data: PaymentMethodToken) => void;
793
814
  onTokenizeError?: (message: PrimerClientError) => void;
794
- onClientSessionActions?: (data: ClientSessionActionData) => Promise<{
795
- clientToken: string;
796
- } | false>;
797
- style?: CheckoutStyle;
798
- directDebit?: DirectDebitOptions;
799
- errorMessage?: ErrorMessageOptions;
800
- submitButton?: SubmitButtonOptions;
801
- threeDSecure?: ThreeDSVerificationOptions;
802
- countryCode?: Alpha2CountryCode;
803
- processingIndicator?: ProcessingIndicatorOptions;
804
- vaultOnly?: boolean;
805
- /**
806
- * @deprecated Use `orderDetails` instead
807
- */
808
- purchaseInfo?: VaultInformation;
809
- /**
810
- * @deprecated Provide details in call to /client-session instead
811
- */
812
- orderDetails?: VaultDetails;
813
- paypal?: Omit<PayPalOptions, "container">;
814
- deletionDisabled?: boolean;
815
- form?: FormOptions;
816
815
  }
817
- export declare type OnClientSessionActions = (data: ClientSessionActionData) => Promise<{
818
- clientToken: string;
819
- } | false>;
820
- export interface CheckoutOptions extends TokenizationHandlers, PaymentHandlers {
821
- countryCode?: Alpha2CountryCode;
822
- /**
823
- * @deprecated Use `orderDetails` instead
824
- */
825
- purchaseInfo?: PurchaseInformation;
816
+ export interface UniversalCheckoutOptions extends TokenizationHandlers, PaymentHandlers, ClientSessionHandlers {
826
817
  uxFlow?: CheckoutUXFlow.CHECKOUT;
827
- scene?: SceneOptions;
828
818
  container: string | Element;
829
819
  locale?: SupportedLocale;
830
- /**
831
- * @deprecated Pass `customerId` in the creation of the Client Session
832
- */
833
- customerId?: string;
834
- allowedCardNetworks?: CardNetwork[];
835
- allowedPaymentMethods?: PaymentMethodType[];
820
+ style?: CheckoutStyle;
821
+ scene?: SceneOptions;
836
822
  vault?: VaultOptions;
837
- onAmountChange?: (data: AmountChange) => void;
838
- onAmountChanging?: (isChanging: boolean) => void;
839
- onAmountChangeError?: (error: PrimerClientError) => void;
840
- onClientSessionActions?: OnClientSessionActions;
841
- threeDSecure?: ThreeDSVerificationOptions;
842
- card?: CheckoutCardOptions;
843
- giftCard?: CustomizablePaymentMethodButton;
844
- paypal?: Omit<PayPalOptions, "container">;
845
- googlePay?: Omit<GooglePayOptions, "container">;
846
- applePay?: Omit<ApplePayOptions, "container">;
847
- klarna?: KlarnaOptions;
848
- directDebit?: DirectDebitOptions;
849
823
  submitButton?: SubmitButtonOptions;
850
824
  processingIndicator?: ProcessingIndicatorOptions;
851
- style?: CheckoutStyle;
852
825
  errorMessage?: ErrorMessageOptions;
853
826
  successScreen?: SuccessScreenOptions;
854
827
  form?: FormOptions;
828
+ allowedPaymentMethods?: PaymentMethodType[];
829
+ allowedCardNetworks?: CardNetwork[];
830
+ card?: CheckoutCardOptions;
855
831
  redirect?: RedirectOptions;
832
+ paypal?: Omit<PayPalOptions, "container">;
833
+ googlePay?: Omit<GooglePayOptions, "container">;
834
+ applePay?: Omit<ApplePayOptions, "container">;
835
+ klarna?: KlarnaOptions;
836
+ directDebit?: DirectDebitOptions;
837
+ giftCard?: CustomizablePaymentMethodButton;
838
+ paymentHandling?: PaymentHandling;
856
839
  advanced?: AdvancedOptions;
857
- /**
858
- * @deprecated Provide details in call to /client-session instead
859
- */
860
- customerDetails?: CustomerDetails;
861
- /**
862
- * @deprecated Provide details in call to /client-session instead
863
- */
864
- businessDetails?: BusinessDetails;
865
- /**
866
- * @deprecated Provide details in call to /client-session instead
867
- */
868
- orderDetails?: OrderDetails;
869
- }
870
- export declare type FieldMetadata = {
871
- error?: string;
872
- valid: boolean;
873
- active: boolean;
874
- dirty: boolean;
875
- touched: boolean;
876
- submitted: boolean;
877
- };
878
- export declare type CreditCardFieldConfig = {
879
- container: string;
880
- placement?: "append" | "prepend";
881
- placeholder?: string;
882
- onChange: (data: {
883
- meta: FieldMetadata;
884
- }) => void;
885
- };
886
- export interface RenderOptions {
887
- uxFlow: null;
888
- locale?: string;
889
- countryCode?: Alpha2CountryCode;
890
- /**
891
- * @deprecated Use `orderDetails` instead
892
- */
893
- purchaseInfo?: PurchaseInformation;
894
- /**
895
- * @deprecated Use setClientToken with new client token instead
896
- */
897
- customerDetails?: CustomerDetails;
898
- /**
899
- * @deprecated Use setClientToken with new client token instead
900
- */
901
- businessDetails?: BusinessDetails;
902
- /**
903
- * @deprecated Use setClientToken with new client token instead
904
- */
905
- orderDetails?: OrderDetails;
906
- onTokenizeStart?: () => void;
907
- onTokenizeSuccess: (data: PaymentMethodToken) => void;
908
- onTokenizeError?: (error: PrimerClientError) => void;
909
- onTokenizeProgress?: (evt: {
910
- type: string;
911
- }) => void;
912
- onClientSessionActions?: (data: ClientSessionActionData) => Promise<{
913
- clientToken: string;
914
- } | false>;
915
- card?: {
916
- cardholderName?: MaybeThunk<string>;
917
- onChange?: (state: FormState) => void;
918
- onCardMetadata?: (meta: CardMetadata) => void;
919
- disabled?: () => boolean;
920
- css?: string;
921
- submitButton: string;
922
- fields: {
923
- cardNumber: CreditCardFieldConfig;
924
- expiryDate: CreditCardFieldConfig;
925
- cvv: CreditCardFieldConfig;
926
- };
927
- };
928
- applePay?: {
929
- container: string;
930
- };
931
- googlePay?: {
932
- container: string;
933
- };
934
- paypal?: {
935
- container: string;
936
- };
937
840
  }
938
841
  export interface PrimerCheckout {
939
842
  teardown(): void;
940
- /**
941
- * @deprecated Use `submit` instead
942
- */
943
- validate(): Promise<Validation>;
944
- /**
945
- * @deprecated Use `submit` instead
946
- */
947
- tokenize(): void;
948
843
  submit(): void;
844
+ setPaymentCreationEnabled(isEnabled: boolean): void;
949
845
  setTokenizationEnabled(isEnabled: boolean): void;
950
- /**
951
- * @deprecated Use `setOrderDetails` instead
952
- */
953
- setPurchaseInfo(purchaseInfo: PurchaseInformation): Promise<void>;
954
- /**
955
- * @deprecated Use setClientToken with new client token instead
956
- */
957
- setCustomerDetails(customerDetails: CustomerDetails | null): Promise<void>;
958
- /**
959
- * @deprecated Use setClientToken with new client token instead
960
- */
961
- setBusinessDetails(businessDetails: BusinessDetails | null): Promise<void>;
962
- /**
963
- * @deprecated Use setClientToken with new client token instead
964
- */
965
- setOrderDetails(orderDetails: OrderDetails | null, orderDetailsInitiator: string | null): Promise<void>;
966
846
  setClientToken(clientToken: string): Promise<boolean>;
967
847
  }
968
848
  export interface PrimerSinglePaymentMethodCheckout {
969
- /**
970
- * @deprecated Use `submit` instead
971
- */
972
- validate(): Promise<Validation>;
973
- /**
974
- * @deprecated Use `submit` instead
975
- */
976
- tokenize(): void;
977
849
  submit(): void;
978
850
  setClientToken(clientToken: string): Promise<boolean>;
979
851
  }
980
852
  export interface PrimerVaultManager {
981
853
  teardown(): void;
982
- /**
983
- * @deprecated Use `submit` instead
984
- */
985
- validate(): Promise<Validation>;
986
- /**
987
- * @deprecated Use `submit` instead
988
- */
989
- tokenize(): void;
990
854
  submit(): void;
991
855
  }
992
- export interface CardDetails {
993
- last4Digits: string;
994
- cardNumber: string;
995
- name: string;
996
- icon: string;
997
- network: string;
998
- userDescription?: string;
999
- }
1000
- export interface PayPalDetails {
1001
- icon: string;
1002
- email?: string;
1003
- }
1004
- export interface CustomizablePaymentMethodButton {
1005
- logoSrc: string;
1006
- background: string;
1007
- logoAlt?: string;
1008
- text?: string;
1009
- }
1010
856
  export interface VaultListItem {
1011
857
  id: string;
1012
858
  type: PaymentInstrumentType;
@@ -1016,567 +862,10 @@ export interface RemotePaymentMethodConfiguration<T> {
1016
862
  id: string;
1017
863
  options: T;
1018
864
  }
1019
- export interface ErrorMonitoring {
1020
- captureException(error: Error): any;
1021
- }
1022
- declare enum ApiEvent {
1023
- startedCheckout = "STARTED_CHECKOUT",
1024
- loadedCheckoutUi = "LOADED_CHECKOUT_UI",
1025
- loadedVaultManagerUi = "LOADED_VAULT_MANAGER_UI",
1026
- completedCheckout = "COMPLETED_CHECKOUT",
1027
- triggered3ds = "TRIGGERED_3DS",
1028
- validationError = "VALIDATION_ERROR",
1029
- tokenizationError = "TOKENIZATION_ERROR",
1030
- threeDSecureError = "3DS_ERROR",
1031
- threeDSecureFailed = "3DS_FAIL",
1032
- threeDSecureSuccess = "3DS_SUCCESS",
1033
- threeDSecureSkipped = "3DS_SKIPPED",
1034
- tokenizeCalled = "TOKENIZE_CALLED",
1035
- creditCardValidationSuccess = "CREDIT_CARD_VALIDATION_SUCCESS",
1036
- creditCardValidationError = "CREDIT_CARD_VALIDATION_ERROR"
1037
- }
1038
- declare enum ClickEvent {
1039
- clickedSubmitButton = "CLICKED_SUBMIT_BUTTON",
1040
- clickedAPMButton = "CLICKED_APM_BUTTON",
1041
- clickedPayPalButton = "CLICKED_PAYPAL_BUTTON",
1042
- clickedDirectDebitButton = "CLICKED_DIRECT_DEBIT_BUTTON",
1043
- clickedApplePayButton = "CLICKED_APPLE_PAY_BUTTON",
1044
- clickedGooglePayButton = "CLICKED_GOOGLE_PAY_BUTTON",
1045
- clickedKlarnaButton = "CLICKED_KLARNA_BUTTON"
1046
- }
1047
- declare enum MockEvent {
1048
- mock = "MOCK"
1049
- }
1050
- export interface AnalyticsData extends Record<string, any> {
1051
- sdkEnvironment?: string;
1052
- paymentIntent?: string;
1053
- paymentMethod?: PaymentInstrumentType;
1054
- amount?: number;
1055
- currency?: string;
1056
- sdkVersion?: string;
1057
- isVault?: boolean;
1058
- uxFlow?: string;
1059
- sessionId?: string;
1060
- }
1061
- export interface AnalyticsAction {
1062
- event: ApiEvent | ClickEvent | MockEvent | string;
1063
- data?: AnalyticsData;
1064
- }
1065
- export interface IAnalyticsProvider {
1066
- call(action: AnalyticsAction): void | boolean;
1067
- time(action: AnalyticsAction): void | boolean;
1068
- }
1069
- export interface IAnalyticsContext {
1070
- amount?: number | undefined;
1071
- currency?: string | undefined;
1072
- isVault?: boolean | undefined;
1073
- paymentIntent?: string | undefined;
1074
- sdkEnvironment?: string | undefined;
1075
- sessionId?: string | undefined;
1076
- }
1077
- declare class Analytics {
1078
- provider: IAnalyticsProvider;
1079
- private sessionId;
1080
- private context;
1081
- private sdkEnvironment;
1082
- private paymentIntent;
1083
- constructor(provider: IAnalyticsProvider);
1084
- /** track event and send to Primer. */
1085
- call(action: AnalyticsAction): boolean | void;
1086
- /** start timing event that might happen in the future. */
1087
- time(action: AnalyticsAction): boolean | void;
1088
- /** updates analytics about the context the checkout is in. */
1089
- setContext(context: IAnalyticsContext): void;
1090
- setSdkEnvironment(env: string): void;
1091
- setPaymentIntent(intent: string): void;
1092
- setSessionId(id: string): void;
1093
- getAnalyticsAction(action: AnalyticsAction): AnalyticsAction;
1094
- }
1095
- export interface ClientSession {
1096
- clientSessionId: string;
1097
- order: ClientSessionOrder;
1098
- customer: ClientSessionCustomer;
1099
- paymentMethod: ClientSessionPaymentMethodOptions;
1100
- }
1101
- export interface ClientSessionLineItem {
1102
- itemId: string;
1103
- description: string;
1104
- amount: number;
1105
- quantity: number;
1106
- discountAmount?: number;
1107
- taxCode?: string;
1108
- taxAmount?: number;
1109
- }
1110
- export interface ClientSessionOrder {
1111
- orderId?: string;
1112
- currencyCode?: Alpha3CurrencyCode;
1113
- countryCode?: Alpha2CountryCode;
1114
- totalOrderAmount?: number;
1115
- merchantAmount?: number;
1116
- lineItems?: ClientSessionLineItem[];
1117
- shipping?: ClientSessionShipping;
1118
- fees?: ClientSessionFeeItem[];
1119
- }
1120
- export interface ClientSessionShipping {
1121
- amount: number;
1122
- }
1123
- export interface ClientSessionFeeItem {
1124
- type?: string;
1125
- description?: string;
1126
- amount: number;
1127
- }
1128
- export interface ClientSessionCustomer {
1129
- customerId?: string;
1130
- emailAddress?: string;
1131
- mobileNumber?: string;
1132
- firstName?: string;
1133
- lastName?: string;
1134
- billingAddress?: ClientSessionAddress;
1135
- shippingAddress?: ClientSessionAddress;
1136
- taxId?: string;
1137
- nationalDocumentId?: string;
1138
- }
1139
- export interface ClientSessionAddress {
1140
- firstName?: string;
1141
- lastName?: string;
1142
- addressLine1?: string;
1143
- addressLine2?: string;
1144
- city?: string;
1145
- state?: string;
1146
- countryCode?: Alpha2CountryCode;
1147
- postalCode?: string;
1148
- }
1149
- export interface ClientSessionPaymentMethodOptions {
1150
- vaultOnSuccess: boolean;
1151
- options: PaymentMethodOption[];
1152
- }
1153
- export interface PaymentMethodOption {
1154
- type: string;
1155
- surcharge?: number;
1156
- networks?: CardNetworkOption[];
1157
- }
1158
- export interface CardNetworkOption {
1159
- type: string;
1160
- surcharge?: number;
1161
- }
1162
- export interface PackageDeclaration {
1163
- type: string;
1164
- version: string;
1165
- name: string;
1166
- entryPoints: Record<string, string>;
1167
- getScenePath?: (sceneId: string) => string | null;
1168
- }
1169
- export interface BaseModule {
1170
- default: unknown;
1171
- }
1172
- declare enum ModuleStatus {
1173
- UNINITIALIZED = 0,
1174
- LOADING = 1,
1175
- READY = 2,
1176
- ERROR = 3
1177
- }
1178
- export interface ModuleKey {
1179
- entryPoint: string;
1180
- scope: string;
1181
- path: string;
1182
- }
1183
- export interface ModuleKeyDescriptor {
1184
- remotePath: string;
1185
- entryFile?: string;
1186
- scope: string;
1187
- path: string;
1188
- }
1189
- export interface PackageKey {
1190
- remotePath: string;
1191
- entryFile?: string;
1192
- scope: string;
1193
- }
1194
- export interface ModuleLoadCallback {
1195
- (moduleDescriptor: ModuleDescriptor): void;
1196
- }
1197
- export interface ModuleDescriptor {
1198
- key: ModuleKey;
1199
- status: ModuleStatus;
1200
- callbacks: Array<ModuleLoadCallback>;
1201
- module: BaseModule | null;
1202
- }
1203
- export interface IModuleLoader {
1204
- loadModule(key: ModuleKey): Promise<ModuleDescriptor>;
1205
- }
1206
- export interface IModule {
1207
- import(exportName?: string): Promise<unknown>;
1208
- }
1209
- export interface IPackage {
1210
- key: PackageKey;
1211
- getDeclaration(): Promise<PackageDeclaration>;
1212
- getModule(string: any): IModule;
1213
- }
1214
- export interface IModuleFactory {
1215
- getPackage(packageKey: PackageKey): IPackage;
1216
- getModule(keyDescriptor: ModuleKeyDescriptor): IModule;
1217
- }
1218
- export interface ModuleOptions {
1219
- key: ModuleKey;
1220
- moduleLoader: IModuleLoader;
1221
- }
1222
- declare class Module implements IModule {
1223
- readonly key: ModuleKey;
1224
- readonly status: ModuleStatus;
1225
- private moduleLoader;
1226
- constructor({ key, moduleLoader }: ModuleOptions);
1227
- import(exportName?: string): Promise<unknown>;
1228
- }
1229
- export interface ScriptLoaderOptions {
1230
- thirdPartyScriptTimeout?: number;
1231
- }
1232
- declare class ScriptLoader {
1233
- private scripts;
1234
- private timeoutMilliseconds;
1235
- constructor(options?: ScriptLoaderOptions);
1236
- load(src: string, options?: {
1237
- crossorigin?: "anonymous" | "use-credentials";
1238
- }): Promise<boolean>;
1239
- }
1240
- declare class ModuleFactory implements IModuleFactory {
1241
- private moduleLoader;
1242
- private modules;
1243
- private packages;
1244
- constructor(scriptLoader: ScriptLoader);
1245
- getModule(keyDescriptor: ModuleKeyDescriptor): Module;
1246
- getPackage(key: PackageKey): any;
1247
- private findModule;
1248
- private findPackage;
1249
- }
1250
- export declare type Props = {
1251
- moduleFactory: IModuleFactory;
1252
- key: PackageKey;
1253
- };
1254
- declare class Package implements IPackage {
1255
- readonly key: PackageKey;
1256
- private moduleFactory;
1257
- private declarationModule;
1258
- constructor({ moduleFactory, key }: Props);
1259
- getDeclaration(): Promise<PackageDeclaration>;
1260
- getModule(path: string): IModule;
1261
- }
1262
- export interface IFrameMessagePayloadMeta {
1263
- source: string;
1264
- destination: string | null;
1265
- name?: string;
1266
- id?: string;
1267
- replyTo?: string;
1268
- [x: string]: unknown;
1269
- }
1270
- export interface IFrameInputMessagePayload<T = unknown> {
1271
- type: string;
1272
- meta?: Partial<IFrameMessagePayloadMeta>;
1273
- payload?: T;
1274
- }
1275
- export interface IFrameMessagePayload<T = unknown> {
1276
- type: string;
1277
- meta: IFrameMessagePayloadMeta;
1278
- payload: T;
1279
- }
1280
- export interface Observer {
1281
- (event: IFrameMessagePayload): void;
1282
- }
1283
- declare class Observable {
1284
- private observers;
1285
- constructor();
1286
- onEvent(event: IFrameMessagePayload): void;
1287
- on(type: string, observer: Observer): void;
1288
- once(type: string, observer: Observer): void;
1289
- notify(event: IFrameMessagePayload): void;
1290
- }
1291
- declare class IFrameMessageBus extends Observable {
1292
- private frames;
1293
- constructor();
1294
- onEvent(event: IFrameMessagePayload): void;
1295
- add(iframe: HTMLIFrameElement): void;
1296
- publish(name: string, event: IFrameInputMessagePayload): void;
1297
- rpc(name: string, evt: IFrameInputMessagePayload): Promise<IFrameMessagePayload>;
1298
- }
1299
- export declare type IFramePlacement = "append" | "prepend";
1300
- export interface IFrameFactoryOptions {
1301
- messageBus: IFrameMessageBus;
1302
- assetsUrl: string;
1303
- }
1304
- export interface CreateIFrameOptions {
1305
- filename: string;
1306
- container: string | Element;
1307
- placement?: IFramePlacement;
1308
- payload?: unknown;
1309
- meta: {
1310
- name: string;
1311
- id?: string;
1312
- ariaLabel?: string;
1313
- placeholder?: string;
1314
- css?: string;
1315
- stylesheets?: string[];
1316
- allowedCardNetworks?: CardNetwork[];
1317
- };
1318
- style?: Record<string, string>;
1319
- onReady?: () => void;
1320
- }
1321
- declare class IFrameFactory {
1322
- private id;
1323
- private messageBus;
1324
- private assetsUrl;
1325
- constructor({ messageBus, assetsUrl }: IFrameFactoryOptions);
1326
- create({ filename, container, meta, payload, placement, style, onReady, }: CreateIFrameOptions): HTMLIFrameElement | null;
1327
- }
1328
- declare enum HttpMethod {
1329
- GET = "get",
1330
- POST = "post",
1331
- DELETE = "delete"
1332
- }
1333
- export interface APIServices {
1334
- messageBus: IFrameMessageBus;
1335
- iframes: IFrameFactory;
1336
- accessToken: string;
1337
- }
1338
- export interface RequestOptions {
1339
- maxAttempts?: number;
1340
- apiVersion?: string;
1341
- }
1342
- export interface APIRequestOptions {
1343
- method: HttpMethod;
1344
- url: string;
1345
- body?: unknown;
1346
- options: RequestOptions;
1347
- }
1348
- export interface ValidationError {
1349
- description: string;
1350
- path: string;
1351
- }
1352
- export interface ValidationErrorDetail {
1353
- model: string;
1354
- errors: ValidationError[];
1355
- }
1356
- export interface APIErrorShape {
1357
- message: string;
1358
- validationErrors: ValidationErrorDetail[];
1359
- diagnosticsId?: string;
1360
- errorId?: string;
1361
- }
1362
- export interface APIResponse<T = unknown> {
1363
- error: Nullable<APIErrorShape>;
1364
- data: Nullable<T>;
1365
- }
1366
- declare class Api {
1367
- private messageBus;
1368
- private isReady;
1369
- private onReadyCallback;
1370
- constructor(services: APIServices);
1371
- setAccessToken(accessToken: string): void;
1372
- ready(): Promise<void>;
1373
- request<T>(payload: APIRequestOptions): Promise<APIResponse<T>>;
1374
- post<T = unknown, U = unknown>(url: string, body: T, options?: RequestOptions): Promise<APIResponse<U>>;
1375
- get<T>(url: string, options?: RequestOptions): Promise<APIResponse<T>>;
1376
- delete<T>(url: string, options?: RequestOptions): Promise<APIResponse<T>>;
1377
- }
1378
- declare enum ClientTokenIntent {
1379
- CHECKOUT = "CHECKOUT",
1380
- THREEDS_AUTHENTICATION = "3DS_AUTHENTICATION",
1381
- REDIRECTION_END = "REDIRECTION_END"
1382
- }
1383
- export declare type CommonClientToken = {
1384
- configurationUrl: string;
1385
- analyticsUrl?: string;
1386
- accessToken: string;
1387
- paymentFlow: PaymentFlow;
1388
- };
1389
- export declare type IntentClientToken = {
1390
- intent: ClientTokenIntent.CHECKOUT | undefined;
1391
- } | {
1392
- intent: ClientTokenIntent.THREEDS_AUTHENTICATION;
1393
- tokenId: string;
1394
- threeDSProvider: string;
1395
- threeDSToken: string;
1396
- threeDSInitUrl: string;
1397
- } | {
1398
- intent: ClientTokenIntent.REDIRECTION_END;
1399
- paymentId: string;
1400
- resumeToken: string;
1401
- } | ({
1402
- intent: string;
1403
- } & Record<string, unknown>);
1404
- export declare type DecodedClientToken = CommonClientToken & IntentClientToken;
1405
- export declare type NewClientTokenListener = (decodedClientToken: DecodedClientToken) => void;
1406
- export interface IClientTokenHandler {
1407
- setClientToken(clientToken: string): any;
1408
- getCurrentClientToken(): string | undefined;
1409
- getCurrentDecodedClientToken(): DecodedClientToken | undefined;
1410
- addNewClientTokenListener(listener: NewClientTokenListener): any;
1411
- removeNewClientTokenListener(listener: NewClientTokenListener): any;
1412
- }
1413
- declare class ClientTokenHandler implements IClientTokenHandler {
1414
- private newClientTokenListeners;
1415
- private currentClientToken;
1416
- private currentDecodedClientToken;
1417
- constructor();
1418
- getCurrentClientToken(): string | undefined;
1419
- getCurrentDecodedClientToken(): (CommonClientToken & {
1420
- intent: ClientTokenIntent.CHECKOUT | undefined;
1421
- }) | (CommonClientToken & {
1422
- intent: ClientTokenIntent.THREEDS_AUTHENTICATION;
1423
- tokenId: string;
1424
- threeDSProvider: string;
1425
- threeDSToken: string;
1426
- threeDSInitUrl: string;
1427
- }) | (CommonClientToken & {
1428
- intent: ClientTokenIntent.REDIRECTION_END;
1429
- paymentId: string;
1430
- resumeToken: string;
1431
- }) | (CommonClientToken & {
1432
- intent: string;
1433
- } & Record<string, unknown>) | undefined;
1434
- setClientToken(clientToken: string): void;
1435
- addNewClientTokenListener(listener: NewClientTokenListener): void;
1436
- removeNewClientTokenListener(listener: NewClientTokenListener): void;
1437
- }
1438
- declare class ClientConfigurationHandler {
1439
- private api;
1440
- private clientTokenHandler;
1441
- constructor(api: Api, clientTokenHandler: ClientTokenHandler);
1442
- getClientConfiguration(clientToken: string): Promise<ClientConfiguration>;
1443
- }
1444
- export interface LongPollServices {
1445
- api: Api;
1446
- }
1447
- export interface LongPollOptions<T> {
1448
- url: string;
1449
- timeout: number;
1450
- pollInterval: number;
1451
- predicate(response: T): boolean;
1452
- }
1453
- declare class LongPoll {
1454
- private api;
1455
- private isStarted;
1456
- constructor(services: LongPollServices);
1457
- start<T>(options: LongPollOptions<T>): Promise<T | null>;
1458
- stop(): void;
1459
- private request;
1460
- private tick;
1461
- }
1462
- export interface PaymentMethodConfig {
1463
- id: string;
1464
- type: PaymentMethodType;
1465
- options: {
1466
- threeDSecureToken?: string;
1467
- threeDSecureInitUrl?: string;
1468
- threeDSecureProvider?: string;
1469
- threeDSecureEnabled?: boolean;
1470
- } | any;
1471
- }
1472
- export interface CheckoutModuleConfig extends Record<string, any> {
1473
- type: string;
1474
- }
1475
- export interface ClientSessionInfo {
1476
- assetsUrl: string;
1477
- coreUrl: string;
1478
- pciUrl: string;
1479
- modulesUrl: string;
1480
- env: string;
1481
- production: boolean;
1482
- paymentFlow: PaymentFlow;
1483
- paymentMethods: PaymentMethodConfig[];
1484
- checkoutModules: CheckoutModuleConfig[];
1485
- threeDSecureToken: Nullable<string>;
1486
- threeDSecureInitUrl: Nullable<string>;
1487
- threeDSecureProvider: Nullable<string>;
1488
- threeDSecureEnabled: boolean;
1489
- accessToken: string;
1490
- isTeardown: boolean;
1491
- clientSession: ClientSession;
1492
- }
1493
- export interface ClientContext {
1494
- clientTokenHandler: IClientTokenHandler;
1495
- clientConfigurationHandler: ClientConfigurationHandler;
1496
- iframes: IFrameFactory;
1497
- messageBus: IFrameMessageBus;
1498
- api: Api;
1499
- longPoll: LongPoll;
1500
- analytics: Analytics;
1501
- errorMonitoring: ErrorMonitoring;
1502
- scriptLoader: ScriptLoader;
1503
- session: ClientSessionInfo;
1504
- moduleFactory: ModuleFactory;
1505
- packages: Package[];
1506
- clientOptions: CheckoutOptions | VaultManagerOptions | SinglePaymentMethodCheckoutOptions | RenderOptions;
1507
- }
1508
- export interface ClientConfiguration {
1509
- coreUrl: string;
1510
- pciUrl: string;
1511
- env: string;
1512
- paymentMethods: PaymentMethodConfig[];
1513
- checkoutModules: CheckoutModuleConfig[];
1514
- clientSession: ClientSession;
1515
- }
1516
- declare class ThreeDSecure {
1517
- private context;
1518
- private provider;
1519
- constructor({ context }: {
1520
- context: ClientContext;
1521
- });
1522
- getContext(): Promise<ClientContext>;
1523
- getProvider(): Promise<any>;
1524
- setup(options: Record<string, unknown>): Promise<void>;
1525
- verify(options: Record<string, unknown>): Promise<any>;
1526
- }
1527
- export interface IBaseState extends Record<string, any> {
1528
- }
1529
- export interface IBaseStore {
1530
- getState(): IBaseState;
1531
- subscribe(listener: any): any;
1532
- }
1533
- export interface IStyleManager {
1534
- setStyle(style?: CheckoutStyle, internalStyle?: InternalStyle): void;
1535
- getStyle(): CheckoutStyle | undefined;
1536
- getHostedFieldStyle(): string | null;
1537
- getApmButtonStyle(): PaymentMethodButtonStyle | null;
1538
- }
1539
- export declare type PaymentMethodSpecs = {
1540
- key: string;
1541
- buttonManagedByPaymentMethod: boolean;
1542
- canVault: boolean;
1543
- hasExportedButtonOptions: boolean;
1544
- homeScene?: string;
865
+ export declare const preloadPrimer: () => Promise<undefined>;
866
+ export declare const Primer: {
867
+ showUniversalCheckout(clientToken: string, options: UniversalCheckoutOptions | SinglePaymentMethodCheckoutOptions): Promise<import(".").PrimerVaultManager>;
868
+ showVaultManager(clientToken: string, options: VaultManagerOptions): Promise<import(".").PrimerVaultManager>;
1545
869
  };
1546
- declare class BasePaymentMethod {
1547
- static specs: PaymentMethodSpecs;
1548
- readonly type: PaymentMethodType;
1549
- displayName: string;
1550
- container: Element | null;
1551
- remoteConfig: any;
1552
- protected constructor(type: PaymentMethodType, name: string);
1553
- static create: (_context: any, _options: Record<string, any>, _remoteConfig: any, _styleManager?: IStyleManager | undefined) => BasePaymentMethod;
1554
- get specs(): PaymentMethodSpecs;
1555
- setupAndValidate(): Promise<boolean>;
1556
- mount(): Promise<boolean>;
1557
- tokenize(options?: any): Promise<void>;
1558
- validate(): Promise<Validation>;
1559
- setDisabled(disabled: boolean): Promise<void>;
1560
- getStore(): IBaseStore | undefined;
1561
- }
1562
- declare class Client {
1563
- static CheckoutUXFlow: typeof CheckoutUXFlow;
1564
- static ThreeDSecureStatus: typeof ThreeDSecureStatus;
1565
- static PaymentFlow: typeof PaymentFlow;
1566
- static PaymentMethodType: typeof PaymentMethodType;
1567
- static SDK_VERSION: unknown;
1568
- static showUniversalCheckout(clientToken: string, options: CheckoutOptions): Promise<PrimerCheckout>;
1569
- private options;
1570
- private currentContextPromise;
1571
- private currentContext;
1572
- constructor(options: ClientContextOptions);
1573
- private getContext;
1574
- render(options: RenderOptions): Promise<Record<string, BasePaymentMethod>>;
1575
- checkout(options: CheckoutOptions | VaultManagerOptions | SinglePaymentMethodCheckoutOptions): Promise<PrimerVaultManager | PrimerCheckout | PrimerSinglePaymentMethodCheckout>;
1576
- get threeDSecure(): ThreeDSecure | null;
1577
- }
1578
- export declare type PrimerClient = Client;
1579
- export declare type PrimerClientConstructor = typeof Client;
1580
- export declare const loadPrimer: () => Promise<PrimerClientConstructor>;
1581
870
 
1582
871
  export {};