@paydock/client-sdk 1.131.0 → 1.133.1-beta

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.
Files changed (135) hide show
  1. package/README.md +166 -0
  2. package/bundles/index.cjs +12754 -11064
  3. package/bundles/index.cjs.d.ts +1231 -905
  4. package/bundles/index.mjs +12753 -11064
  5. package/bundles/index.mjs.d.ts +1231 -905
  6. package/bundles/types/afterpay-on-site-messaging/afterpay-on-site-messaging.d.ts +40 -0
  7. package/bundles/types/afterpay-on-site-messaging/afterpay-on-site-messaging.d.ts.map +1 -0
  8. package/bundles/types/afterpay-on-site-messaging/afterpay-on-site-messaging.interfaces.d.ts +29 -0
  9. package/bundles/types/afterpay-on-site-messaging/afterpay-on-site-messaging.interfaces.d.ts.map +1 -0
  10. package/bundles/types/afterpay-on-site-messaging/afterpay-on-site-messaging.service.d.ts +14 -0
  11. package/bundles/types/afterpay-on-site-messaging/afterpay-on-site-messaging.service.d.ts.map +1 -0
  12. package/bundles/types/afterpay-on-site-messaging/index.d.ts +18 -0
  13. package/bundles/types/afterpay-on-site-messaging/index.d.ts.map +1 -0
  14. package/bundles/types/api/api-payment-source-internal.d.ts +2 -1
  15. package/bundles/types/api/api-payment-source-internal.d.ts.map +1 -1
  16. package/bundles/types/api/api-service-internal.d.ts +13 -6
  17. package/bundles/types/api/api-service-internal.d.ts.map +1 -1
  18. package/bundles/types/checkout/v1/layout-widgets/payment-methods-template.d.ts.map +1 -1
  19. package/bundles/types/checkout/v3/instructions/instruction.card_form.show.d.ts +1 -0
  20. package/bundles/types/checkout/v3/instructions/instruction.card_form.show.d.ts.map +1 -1
  21. package/bundles/types/checkout/v3/instructions/instruction.payment_methods.show.d.ts.map +1 -1
  22. package/bundles/types/components/param.d.ts +3 -1
  23. package/bundles/types/components/param.d.ts.map +1 -1
  24. package/bundles/types/index-cba.d.ts +9 -6
  25. package/bundles/types/index-cba.d.ts.map +1 -1
  26. package/bundles/types/index.d.ts +9 -6
  27. package/bundles/types/index.d.ts.map +1 -1
  28. package/bundles/types/open-wallets/base/open-wallet-buttons.d.ts +198 -0
  29. package/bundles/types/open-wallets/base/open-wallet-buttons.d.ts.map +1 -0
  30. package/bundles/types/open-wallets/base/open-wallet.service.d.ts +27 -0
  31. package/bundles/types/open-wallets/base/open-wallet.service.d.ts.map +1 -0
  32. package/bundles/types/open-wallets/enum/event.enum.d.ts +8 -1
  33. package/bundles/types/open-wallets/enum/event.enum.d.ts.map +1 -1
  34. package/bundles/types/open-wallets/enum/payload-format.enum.d.ts +4 -0
  35. package/bundles/types/open-wallets/enum/payload-format.enum.d.ts.map +1 -0
  36. package/bundles/types/open-wallets/enum/service-group.enum.d.ts +5 -0
  37. package/bundles/types/open-wallets/enum/service-group.enum.d.ts.map +1 -0
  38. package/bundles/types/open-wallets/index.d.ts +2 -2
  39. package/bundles/types/open-wallets/index.d.ts.map +1 -1
  40. package/bundles/types/open-wallets/interfaces/apple-pay/apple-pay-payment-request.interface.d.ts +495 -0
  41. package/bundles/types/open-wallets/interfaces/apple-pay/apple-pay-payment-request.interface.d.ts.map +1 -0
  42. package/bundles/types/open-wallets/interfaces/apple-pay/index.d.ts +2 -0
  43. package/bundles/types/open-wallets/interfaces/apple-pay/index.d.ts.map +1 -0
  44. package/bundles/types/open-wallets/interfaces/events.interface.d.ts +5 -6
  45. package/bundles/types/open-wallets/interfaces/events.interface.d.ts.map +1 -1
  46. package/bundles/types/open-wallets/interfaces/google-pay/google-pay-meta.interface.d.ts +54 -0
  47. package/bundles/types/open-wallets/interfaces/google-pay/google-pay-meta.interface.d.ts.map +1 -0
  48. package/bundles/types/open-wallets/interfaces/google-pay/index.d.ts +2 -0
  49. package/bundles/types/open-wallets/interfaces/google-pay/index.d.ts.map +1 -0
  50. package/bundles/types/open-wallets/interfaces/index.d.ts +1 -3
  51. package/bundles/types/open-wallets/interfaces/index.d.ts.map +1 -1
  52. package/bundles/types/open-wallets/interfaces/open-wallet-meta.interface.d.ts +11 -0
  53. package/bundles/types/open-wallets/interfaces/open-wallet-meta.interface.d.ts.map +1 -0
  54. package/bundles/types/open-wallets/interfaces/payment-source.interface.d.ts +0 -1
  55. package/bundles/types/open-wallets/interfaces/payment-source.interface.d.ts.map +1 -1
  56. package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts +64 -0
  57. package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts.map +1 -0
  58. package/bundles/types/open-wallets/services/apple-pay/index.d.ts +2 -0
  59. package/bundles/types/open-wallets/services/apple-pay/index.d.ts.map +1 -0
  60. package/bundles/types/open-wallets/services/google-pay/constants/google-pay.constants.d.ts +11 -0
  61. package/bundles/types/open-wallets/services/google-pay/constants/google-pay.constants.d.ts.map +1 -0
  62. package/bundles/types/open-wallets/services/google-pay/constants/index.d.ts +2 -0
  63. package/bundles/types/open-wallets/services/google-pay/constants/index.d.ts.map +1 -0
  64. package/bundles/types/open-wallets/services/google-pay/google-pay.open-wallet.service.d.ts +55 -0
  65. package/bundles/types/open-wallets/services/google-pay/google-pay.open-wallet.service.d.ts.map +1 -0
  66. package/bundles/types/open-wallets/services/google-pay/index.d.ts +2 -0
  67. package/bundles/types/open-wallets/services/google-pay/index.d.ts.map +1 -0
  68. package/bundles/types/open-wallets/services/google-pay/utils/google-pay.utils.d.ts +20 -0
  69. package/bundles/types/open-wallets/services/google-pay/utils/google-pay.utils.d.ts.map +1 -0
  70. package/bundles/types/open-wallets/services/google-pay/utils/index.d.ts +2 -0
  71. package/bundles/types/open-wallets/services/google-pay/utils/index.d.ts.map +1 -0
  72. package/bundles/types/open-wallets/services/google-pay/validation/google-pay.validation.d.ts +3 -0
  73. package/bundles/types/open-wallets/services/google-pay/validation/google-pay.validation.d.ts.map +1 -0
  74. package/bundles/types/open-wallets/services/google-pay/validation/index.d.ts +2 -0
  75. package/bundles/types/open-wallets/services/google-pay/validation/index.d.ts.map +1 -0
  76. package/bundles/types/open-wallets/types/apple-pay/apple-pay-button-style.type.d.ts +2 -0
  77. package/bundles/types/open-wallets/types/apple-pay/apple-pay-button-style.type.d.ts.map +1 -0
  78. package/bundles/types/open-wallets/types/apple-pay/apple-pay-button-type.type.d.ts +2 -0
  79. package/bundles/types/open-wallets/types/apple-pay/apple-pay-button-type.type.d.ts.map +1 -0
  80. package/bundles/types/open-wallets/types/apple-pay/index.d.ts +3 -0
  81. package/bundles/types/open-wallets/types/apple-pay/index.d.ts.map +1 -0
  82. package/bundles/types/open-wallets/types/base-event-data.interface.d.ts +5 -0
  83. package/bundles/types/open-wallets/types/base-event-data.interface.d.ts.map +1 -0
  84. package/bundles/types/open-wallets/types/google-pay/google-pay-button-color.type.d.ts +2 -0
  85. package/bundles/types/open-wallets/types/google-pay/google-pay-button-color.type.d.ts.map +1 -0
  86. package/bundles/types/open-wallets/types/google-pay/google-pay-button-size-mode.type.d.ts +2 -0
  87. package/bundles/types/open-wallets/types/google-pay/google-pay-button-size-mode.type.d.ts.map +1 -0
  88. package/bundles/types/open-wallets/types/google-pay/google-pay-button-type.type.d.ts +2 -0
  89. package/bundles/types/open-wallets/types/google-pay/google-pay-button-type.type.d.ts.map +1 -0
  90. package/bundles/types/open-wallets/types/google-pay/index.d.ts +4 -0
  91. package/bundles/types/open-wallets/types/google-pay/index.d.ts.map +1 -0
  92. package/bundles/types/open-wallets/types/index.d.ts +1 -2
  93. package/bundles/types/open-wallets/types/index.d.ts.map +1 -1
  94. package/bundles/types/open-wallets/types/on-shipping-address-change-event-data.interface.d.ts +21 -0
  95. package/bundles/types/open-wallets/types/on-shipping-address-change-event-data.interface.d.ts.map +1 -0
  96. package/bundles/types/open-wallets/types/on-shipping-address-change-event-response.interface.d.ts +6 -0
  97. package/bundles/types/open-wallets/types/on-shipping-address-change-event-response.interface.d.ts.map +1 -0
  98. package/bundles/types/open-wallets/types/on-shipping-option-change-event-data.interface.d.ts +13 -0
  99. package/bundles/types/open-wallets/types/on-shipping-option-change-event-data.interface.d.ts.map +1 -0
  100. package/bundles/types/open-wallets/types/on-shipping-option-change-event-response.interface.d.ts +4 -0
  101. package/bundles/types/open-wallets/types/on-shipping-option-change-event-response.interface.d.ts.map +1 -0
  102. package/bundles/types/open-wallets/types/payment-source.type.d.ts +85 -0
  103. package/bundles/types/open-wallets/types/payment-source.type.d.ts.map +1 -0
  104. package/bundles/types/open-wallets/types/shipping-event-to-response.type.d.ts +6 -0
  105. package/bundles/types/open-wallets/types/shipping-event-to-response.type.d.ts.map +1 -0
  106. package/bundles/types/open-wallets/types/wallet-type.type.d.ts +2 -2
  107. package/bundles/types/open-wallets/types/wallet-type.type.d.ts.map +1 -1
  108. package/bundles/types/secure-remote-commerce/secure-remote-commerce.d.ts +16 -16
  109. package/bundles/types/secure-remote-commerce/secure-remote-commerce.d.ts.map +1 -1
  110. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts +9 -9
  111. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
  112. package/bundles/types/widget/html-multi-widget.d.ts +13 -1
  113. package/bundles/types/widget/html-multi-widget.d.ts.map +1 -1
  114. package/bundles/types/widget/multi-widget.d.ts +7 -4
  115. package/bundles/types/widget/multi-widget.d.ts.map +1 -1
  116. package/bundles/widget.umd.js +12754 -11064
  117. package/bundles/widget.umd.js.d.ts +1231 -905
  118. package/bundles/widget.umd.js.min.d.ts +1231 -905
  119. package/bundles/widget.umd.min.js +1 -1
  120. package/docs/afterpay-on-site-messaging-examples.md +60 -0
  121. package/docs/afterpay-on-site-messaging.md +104 -0
  122. package/docs/open-wallet-buttons-examples.md +1188 -0
  123. package/package.json +4 -1
  124. package/bundles/types/open-wallets/base/base-open-wallet.d.ts +0 -33
  125. package/bundles/types/open-wallets/base/base-open-wallet.d.ts.map +0 -1
  126. package/bundles/types/open-wallets/interfaces/base-service-config.interface.d.ts +0 -30
  127. package/bundles/types/open-wallets/interfaces/base-service-config.interface.d.ts.map +0 -1
  128. package/bundles/types/open-wallets/interfaces/base-wallet-meta.interface.d.ts +0 -5
  129. package/bundles/types/open-wallets/interfaces/base-wallet-meta.interface.d.ts.map +0 -1
  130. package/bundles/types/open-wallets/services/index.d.ts +0 -9
  131. package/bundles/types/open-wallets/services/index.d.ts.map +0 -1
  132. package/bundles/types/open-wallets/types/ott-backend.type.d.ts +0 -26
  133. package/bundles/types/open-wallets/types/ott-backend.type.d.ts.map +0 -1
  134. package/bundles/types/open-wallets/types/ott-response.type.d.ts +0 -8
  135. package/bundles/types/open-wallets/types/ott-response.type.d.ts.map +0 -1
@@ -1,6 +1,81 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { MicroAgent } from '@newrelic/browser-agent/loaders/micro-agent';
3
3
 
4
+ declare class Container {
5
+ protected selector: string;
6
+ constructor(selector: string);
7
+ isExist(): boolean;
8
+ getStyles<T>(allowValue: string[]): T | {};
9
+ on(name: any, cb: (event: MouseEvent) => void): void;
10
+ getAttr<T>(allowValue: string[]): T | {};
11
+ getElement(): Element;
12
+ getSelector(): string;
13
+ private convertConfigs;
14
+ }
15
+
16
+ declare class EventEmitter {
17
+ private events;
18
+ emit<T>(eventName: string, data?: T): void;
19
+ emitWithResult<T, R>(eventName: string, data?: T): Promise<R[]>;
20
+ subscribe<T>(eventName: string, handler: (data: T) => void): () => void;
21
+ }
22
+
23
+ declare enum PageType {
24
+ CART = "cart",
25
+ PRODUCT = "product"
26
+ }
27
+ interface IAfterpayOnSiteMessagingConfig {
28
+ mpid: string;
29
+ placement_id: string;
30
+ page_type: PageType;
31
+ amount?: string;
32
+ currency: string;
33
+ consumer_locale?: string;
34
+ item_skus?: string;
35
+ item_categories?: string;
36
+ is_eligible?: boolean;
37
+ }
38
+ interface IAfterpayOnSiteMessagingService {
39
+ load(container: Container): void;
40
+ }
41
+
42
+ /**
43
+ * Afterpay On Site Messaging constructor
44
+ *
45
+ * @param {string} selector - Selector of html element. Container for Afterpay On Site Messaging.
46
+ * @param {IAfterpayOnSiteMessagingConfig} config - Required configuration for the Afterpay On Site Messaging.
47
+ *
48
+ * @example
49
+ * var afterpayOnSiteMessaging = new AfterpayOnSiteMessaging('#afterpayButton', config);
50
+ */
51
+ declare class AfterpayOnSiteMessaging {
52
+ protected container: Container;
53
+ protected eventEmitter: EventEmitter;
54
+ protected service: IAfterpayOnSiteMessagingService;
55
+ /** @constructs */ constructor(selector: string, config?: IAfterpayOnSiteMessagingConfig);
56
+ /**
57
+ * The final method after configuring the AfterpayOnSiteMessaging to
58
+ * start the load process.
59
+ */
60
+ load(): void;
61
+ /**
62
+ * Callback for onError method.
63
+ *
64
+ * @callback OnErrorCallback
65
+ * @param {unknown|null} data
66
+ */
67
+ /**
68
+ * If the process fails, the function passed as parameter will be called.
69
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
70
+ *
71
+ * @example
72
+ * AfterpayOnSiteMessaging.onError((eventData) => console.log('Some error occur'));
73
+ *
74
+ * @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow.
75
+ */
76
+ onError(callback?: (data?: unknown) => void): () => void;
77
+ }
78
+
4
79
  declare class ApiCharge {
5
80
  protected api: Api;
6
81
  constructor(api: Api);
@@ -284,6 +359,7 @@ declare const FORM_FIELD: {
284
359
  SAVE_CARD_CONSENT_ACCEPTED: string;
285
360
  ENABLE_CVV_TOKENIZATION_MODE: string;
286
361
  CARD_NUMBER_LAST4: string;
362
+ ENABLE_CVV_VALIDATION: string;
287
363
  };
288
364
  declare const STYLE: {
289
365
  BACKGROUND_COLOR: string;
@@ -367,6 +443,7 @@ interface IFormPropertyOption {
367
443
  address_postcode?: string;
368
444
  address_company?: string;
369
445
  card_number_last4?: string;
446
+ enable_cvv_validation?: string;
370
447
  }
371
448
  interface IFormValues extends IFormPropertyOption {
372
449
  }
@@ -660,18 +737,6 @@ declare class Link {
660
737
  getBaseUrl(): string;
661
738
  }
662
739
 
663
- declare class Container {
664
- protected selector: string;
665
- constructor(selector: string);
666
- isExist(): boolean;
667
- getStyles<T>(allowValue: string[]): T | {};
668
- on(name: any, cb: (event: MouseEvent) => void): void;
669
- getAttr<T>(allowValue: string[]): T | {};
670
- getElement(): Element;
671
- getSelector(): string;
672
- private convertConfigs;
673
- }
674
-
675
740
  declare class IFrame {
676
741
  protected container: Container;
677
742
  constructor(container: Container);
@@ -1233,13 +1298,16 @@ declare class MultiWidget {
1233
1298
  */
1234
1299
  enableSaveCardConsentCheckbox(): void;
1235
1300
  /**
1236
- * The Current method enable the cvv mode for card form
1301
+ * This method enables the CVV mode for card forms.
1302
+ * CVV validation can be enabled using the `enable_cvv_validation` option.
1237
1303
  *
1238
1304
  * @example
1239
- * widget.enableCvvTokenizationMode();
1305
+ * widget.enableCvvTokenizationMode({ enable_cvv_validation : true });
1240
1306
  *
1241
- */
1242
- enableCvvTokenizationMode(): void;
1307
+ */
1308
+ enableCvvTokenizationMode(options?: {
1309
+ enable_cvv_validation?: boolean;
1310
+ }): void;
1243
1311
  }
1244
1312
 
1245
1313
  interface ITriggerData {
@@ -1297,9 +1365,21 @@ interface IEventMetaData extends IEventData$1 {
1297
1365
  gateway_type?: string;
1298
1366
  }
1299
1367
  interface IEventFinishData extends IEventData$1 {
1368
+ address_city?: string;
1369
+ address_country?: string;
1370
+ address_line1?: string;
1371
+ address_line2?: string;
1372
+ address_postcode?: string;
1373
+ address_state?: string;
1374
+ card_scheme?: string;
1375
+ email?: string;
1376
+ expire_month?: string;
1377
+ expire_year?: string;
1378
+ first_name?: string;
1379
+ last_name?: string;
1300
1380
  payment_source: string;
1301
1381
  payment_source_token?: string;
1302
- card_scheme?: string;
1382
+ phone?: string;
1303
1383
  save_card_consent_accepted?: boolean;
1304
1384
  }
1305
1385
  /**
@@ -1790,13 +1870,6 @@ declare class IFrameEvent {
1790
1870
  private subscribe;
1791
1871
  }
1792
1872
 
1793
- declare class EventEmitter {
1794
- private events;
1795
- emit<T>(eventName: string, data?: T): void;
1796
- emitWithResult<T, R>(eventName: string, data?: T): Promise<R[]>;
1797
- subscribe<T>(eventName: string, handler: (data: T) => void): () => void;
1798
- }
1799
-
1800
1873
  declare class Standalone3dsService {
1801
1874
  protected container: Container;
1802
1875
  protected eventEmitter: EventEmitter;
@@ -1910,140 +1983,503 @@ declare class Canvas3ds {
1910
1983
  reload(): void;
1911
1984
  }
1912
1985
 
1913
- /**
1914
- * @type {object}
1915
- * @param {string} CLICK=click
1916
- * @param {string} POPUP_REDIRECT=popup_redirect
1917
- * @param {string} ERROR=error
1918
- * @param {string} ACCEPTED=accepted
1919
- * @param {string} FINISH=finish
1920
- * @param {string} CLOSE=close
1921
- */
1922
- declare const CHECKOUT_BUTTON_EVENT: {
1923
- CLICK: string;
1924
- POPUP_REDIRECT: string;
1925
- REDIRECT: string;
1926
- ERROR: string;
1927
- REFERRED: string;
1928
- DECLINED: string;
1929
- CANCELLED: string;
1930
- ACCEPTED: string;
1931
- FINISH: string;
1932
- CLOSE: string;
1933
- };
1934
- /**
1935
- * @type {object}
1936
- * @param {string} CONTEXTUAL=contextual
1937
- * @param {string} REDIRECT=redirect
1938
- */
1939
- declare enum CHECKOUT_MODE {
1940
- CONTEXTUAL = "contextual",
1941
- REDIRECT = "redirect"
1942
- }
1943
- /**
1944
- * @type {object}
1945
- * @param {string} ZIPMONEY=Zipmoney
1946
- * @param {string} PAYPAL=PaypalClassic
1947
- * @param {string} AFTERPAY=Afterpay
1948
- */
1949
- declare enum GATEWAY_TYPE {
1950
- ZIPMONEY = "Zipmoney",
1951
- PAYPAL = "PaypalClassic",
1952
- AFTERPAY = "Afterpay"
1953
- }
1954
- interface IEventCheckoutFinishData {
1955
- payment_source_token: string;
1956
- checkout_email: string;
1957
- checkout_holder: string;
1958
- gateway_type: string;
1959
- }
1960
-
1961
- /**
1962
- * Class Background create overlay for checkout
1963
- *
1964
- * @example
1965
- * var overlay = new Background();
1966
- */
1967
- declare class Background {
1968
- protected description: string;
1969
- protected title: string;
1970
- protected overlay: HTMLElement;
1971
- protected style: HTMLStyleElement;
1972
- protected eventEmitter: EventEmitter;
1973
- protected showControl: boolean;
1974
- protected showLoader: boolean;
1975
- constructor();
1976
- initControl(): void;
1977
- initLoader(): void;
1978
- private eventHandler;
1979
- clear(): void;
1980
- private createLoader;
1981
- protected createTemplate(): void;
1982
- private createStyles;
1983
- setBackdropDescription(text: string): void;
1984
- setBackdropTitle(text: string): void;
1985
- onTrigger(triggerName: string, cb: () => void): void;
1986
- isInit(): boolean;
1987
- hideContinueControl(): void;
1988
- turnOffControl(): void;
1989
- turnOffLoader(): void;
1990
- }
1991
-
1992
- declare type SuccessCb = (data: any, status: number) => void;
1993
- declare type ErrorCb = (err: any, status: number) => void;
1994
- declare abstract class HttpCore {
1995
- private env;
1996
- constructor();
1997
- setEnv(env: string, alias?: string): void;
1998
- getEnv(): string;
1999
- protected getUrl(): string;
2000
- protected create(accessToken: string, data: any, cb: SuccessCb, errorCb: ErrorCb): void;
2001
- protected get(accessToken: string, cb: SuccessCb, errorCb: ErrorCb): void;
2002
- protected parser(text: any, status: number, cb: SuccessCb, errorCb: ErrorCb): void;
2003
- protected abstract getLink(): string;
1986
+ declare class ApiChargeInternal {
1987
+ protected api: ApiInternal;
1988
+ constructor(api: ApiInternal);
1989
+ walletCapture(payload: WalletCaptureBody): Promise<WalletCaptureResponse>;
1990
+ walletCallback(payload: WalletCallbackBody): Promise<WalletCallbackResponse>;
1991
+ standalone3dsProcess(payload: Standalone3dsProcessBody): Promise<ProcessAuthenticationResponse>;
1992
+ standalone3dsHandle(): Promise<HandleResponseInterface>;
2004
1993
  }
2005
-
2006
- interface IBody$1 {
2007
- gateway_id: string;
2008
- success_redirect_url: string;
2009
- error_redirect_url: string;
2010
- redirect_url: string;
2011
- meta: IPayPalMeta;
2012
- description?: string;
1994
+ interface WalletCaptureResponse {
1995
+ id: string;
1996
+ amount: number;
1997
+ currency: string;
1998
+ status: string;
2013
1999
  }
2014
- interface ICheckout {
2015
- gateway_id: string;
2016
- checkout_type: string;
2017
- gateway_type: string;
2018
- link: string;
2019
- reference_id: string;
2020
- token: string;
2021
- mode?: string;
2000
+ interface WalletCaptureBody {
2001
+ payment_method_id?: string;
2002
+ customer?: {
2003
+ payment_source?: {
2004
+ type?: string;
2005
+ card_name?: string;
2006
+ card_scheme?: string;
2007
+ card_number_last4?: string;
2008
+ expire_month?: number;
2009
+ expire_year?: number;
2010
+ address_line1?: string;
2011
+ address_line2?: string;
2012
+ address_city?: string;
2013
+ address_postcode?: string;
2014
+ address_state?: string;
2015
+ address_country?: string;
2016
+ external_payer_id?: string;
2017
+ ref_token?: string;
2018
+ wallet_express?: boolean;
2019
+ };
2020
+ };
2022
2021
  }
2023
- declare class Builder$1 extends HttpCore {
2024
- private body;
2025
- constructor(gatewayID: string, successRedirectUrl: string, errorRedirectUrl: string);
2026
- protected getLink(): string;
2027
- setDescriptions(text: string): void;
2028
- setMeta(meta: IPayPalMeta): void;
2029
- getConfigs(): IBody$1;
2030
- send(publicKey: string, cb: (checkout: ICheckout) => void, errorCb?: (error: any, code: string) => void): void;
2022
+ interface WalletCallbackBody {
2023
+ request_type: string;
2031
2024
  }
2032
-
2033
- interface IDetails {
2034
- checkout_email: string;
2035
- checkout_holder: string;
2025
+ interface WalletCallbackResponse {
2026
+ id: string;
2036
2027
  status: string;
2037
- gateway_type: string;
2028
+ callback_method: string;
2029
+ callback_rel: string;
2030
+ callback_url: string;
2038
2031
  }
2039
- declare class Checker extends HttpCore {
2040
- token: string;
2041
- constructor(token: string);
2042
- protected getLink(): string;
2043
- send(accessToken: string, cb: (details: IDetails) => void, errorCb?: (error: any) => void): void;
2032
+ interface Standalone3dsProcessBody {
2033
+ charge_3ds_id: string;
2044
2034
  }
2045
-
2046
- type AdditionalParams = Record<string, string | number | boolean>;
2035
+ interface HandleResponseInterface {
2036
+ status: string;
2037
+ error: string;
2038
+ result: {
2039
+ reference: string;
2040
+ reference_2: string;
2041
+ identifier: string;
2042
+ identifier_2: string;
2043
+ identifier_3: string;
2044
+ identifier_4: string;
2045
+ identifier_5: string;
2046
+ type: string;
2047
+ status: string;
2048
+ status_2: string;
2049
+ status_code: string;
2050
+ ref_token: string;
2051
+ cancellation: string;
2052
+ count: string;
2053
+ version: string;
2054
+ whitelist: {
2055
+ status: string;
2056
+ source: string;
2057
+ };
2058
+ result: string;
2059
+ };
2060
+ }
2061
+ interface ProcessAuthenticationResponse {
2062
+ status: string;
2063
+ error?: string;
2064
+ result?: {
2065
+ challenge: string;
2066
+ challenge_url: string;
2067
+ decoupled_challenge: boolean;
2068
+ frictionless: boolean;
2069
+ identifier: string;
2070
+ identifier_3: string;
2071
+ identifier_4: string;
2072
+ reference: string;
2073
+ reference_2: string;
2074
+ secondary_url: string;
2075
+ skipped: boolean;
2076
+ status: string;
2077
+ type: string;
2078
+ version: string;
2079
+ description?: string;
2080
+ };
2081
+ }
2082
+
2083
+ declare class ApiGatewayInternal {
2084
+ protected api: ApiInternal;
2085
+ constructor(api: ApiInternal);
2086
+ getWalletConfig(gateway_id: string): Promise<GetWalletConfigResponse>;
2087
+ }
2088
+ interface GetWalletConfigResponse {
2089
+ type: string;
2090
+ mode: string;
2091
+ credentials?: object;
2092
+ }
2093
+
2094
+ declare class ApiServiceInternal {
2095
+ protected api: ApiInternal;
2096
+ constructor(api: ApiInternal);
2097
+ getConfig(service_id: string): Promise<GetConfigResponse>;
2098
+ }
2099
+ interface GetConfigResponse {
2100
+ type: SERVICE_TYPES;
2101
+ merchant: string;
2102
+ username: string;
2103
+ password: string;
2104
+ certificate: string;
2105
+ certificate_passphrase: string;
2106
+ }
2107
+ declare enum SERVICE_TYPES {
2108
+ ACCERTIFY = "Accertify",
2109
+ BOOKING = "Booking",
2110
+ GPAYMENTS = "GPayments",
2111
+ CLICK_TO_PAY = "ClickToPay",
2112
+ MASTERCARD_NT = "MastercardSCOF",
2113
+ VISA_NT = "VisaVTS",
2114
+ FORTER = "Forter",
2115
+ APPLE_PAY = "ApplePay",
2116
+ GOOGLE_PAY = "GooglePay"
2117
+ }
2118
+
2119
+ declare enum PAYLOAD_FORMAT {
2120
+ ENCRYPTED_STRING = "encrypted_string"
2121
+ }
2122
+
2123
+ declare enum SERVICE_GROUP {
2124
+ CLICK_TO_PAY = "click_to_pay",
2125
+ WALLET = "wallet"
2126
+ }
2127
+
2128
+ type WalletType = WALLET_TYPES;
2129
+ declare enum WALLET_TYPES {
2130
+ APPLE_PAY = "apple",
2131
+ GOOGLE_PAY = "google"
2132
+ }
2133
+
2134
+ interface CreateOTTResponse {
2135
+ temp_token: string;
2136
+ token_type: string;
2137
+ }
2138
+ interface Billing {
2139
+ address_line1: string;
2140
+ address_line2: string;
2141
+ address_country: string;
2142
+ address_city: string;
2143
+ address_postcode: string;
2144
+ address_state: string;
2145
+ }
2146
+ interface CardInfo {
2147
+ card_scheme: string;
2148
+ card_number_last4?: string;
2149
+ }
2150
+ interface CreateOTTData {
2151
+ amount: number;
2152
+ shipping: Shipping;
2153
+ billing: Billing;
2154
+ card_info: CardInfo;
2155
+ ref_token: string;
2156
+ }
2157
+ interface CreateOTTRequest {
2158
+ service_id: string;
2159
+ service_type: SERVICE_TYPES;
2160
+ service_group: SERVICE_GROUP;
2161
+ payload: string;
2162
+ payload_format: PAYLOAD_FORMAT;
2163
+ }
2164
+ interface CreateSessionRequest {
2165
+ service_id: string;
2166
+ session_id: string;
2167
+ request_shipping?: boolean;
2168
+ store_name?: string;
2169
+ }
2170
+ interface CreateSessionResponse {
2171
+ id: string;
2172
+ status: string;
2173
+ callback_method: string;
2174
+ callback_rel: string;
2175
+ callback_url: string;
2176
+ }
2177
+ type CheckoutResponse = ApplePayJS.ApplePayPaymentAuthorizedEvent | google.payments.api.PaymentAuthorizationResult | google.payments.api.PaymentData;
2178
+ declare enum CheckoutActionCode {
2179
+ COMPLETE = "COMPLETE",
2180
+ CANCEL = "CANCEL",
2181
+ ERROR = "ERROR",
2182
+ CHANGE_CARD = "CHANGE_CARD",
2183
+ ADD_CARD = "ADD_CARD",
2184
+ SWITCH_CONSUMER = "SWITCH_CONSUMER"
2185
+ }
2186
+ interface OTTResponse {
2187
+ token: string;
2188
+ token_type: string;
2189
+ three_ds_required?: boolean;
2190
+ wallet_type: WalletType;
2191
+ }
2192
+ interface Shipping {
2193
+ method?: string;
2194
+ options?: IShippingOption[];
2195
+ address_line1?: string;
2196
+ address_line2?: string;
2197
+ address_city?: string;
2198
+ address_postcode?: string;
2199
+ address_state?: string;
2200
+ address_country?: string;
2201
+ address_company?: string;
2202
+ address_origin_postcode?: string;
2203
+ contact?: {
2204
+ first_name?: string;
2205
+ last_name?: string;
2206
+ email?: string;
2207
+ phone?: string;
2208
+ phone2?: string;
2209
+ };
2210
+ }
2211
+
2212
+ declare class ApiPaymentSourceInternal {
2213
+ protected api: ApiInternal;
2214
+ constructor(api: ApiInternal);
2215
+ createOTT(payload: CreateOTTRequest): Promise<CreateOTTResponse>;
2216
+ createSession(payload: CreateSessionRequest): Promise<CreateSessionResponse>;
2217
+ }
2218
+
2219
+ declare class ApiInternal extends ApiBase {
2220
+ charge(): ApiChargeInternal;
2221
+ service(): ApiServiceInternal;
2222
+ checkout(): ApiCheckoutInternal;
2223
+ gateway(): ApiGatewayInternal;
2224
+ paymentSource(): ApiPaymentSourceInternal;
2225
+ }
2226
+
2227
+ declare class ApiCheckoutInternal {
2228
+ protected api: ApiInternal;
2229
+ constructor(api: ApiInternal);
2230
+ instructions(): Observable<object>;
2231
+ private getInstructionLink;
2232
+ callback(payload: Object): Promise<Object>;
2233
+ status(id: string): Promise<Object>;
2234
+ }
2235
+
2236
+ type Instruction = new (selector: string, api: ApiInternal, checkoutWidget: Checkout, formSelector?: string) => InstructionHandler & InstructionDestroyable & InstructionDecorated;
2237
+ interface InstructionHandleable {
2238
+ handle(payload: object, eventEmitter: EventEmitter): void;
2239
+ }
2240
+ interface InstructionDecorated {
2241
+ instruction: string;
2242
+ }
2243
+ interface InstructionDestroyable {
2244
+ destroy(): void;
2245
+ }
2246
+ declare abstract class InstructionHandler implements InstructionHandleable, InstructionDestroyable, InstructionDecorated {
2247
+ selector: string;
2248
+ api: ApiInternal;
2249
+ protected checkoutWidget?: Checkout;
2250
+ formSelector?: string;
2251
+ constructor(selector: string, api: ApiInternal, checkoutWidget?: Checkout, formSelector?: string);
2252
+ instruction: string;
2253
+ abstract handle(context: object, eventEmitter?: any): void;
2254
+ destroy(): void;
2255
+ getEnv(instruction_token: string): string;
2256
+ }
2257
+
2258
+ declare class InstructionModule {
2259
+ instructions: any[];
2260
+ getInstruction(id: string): Instruction | null;
2261
+ }
2262
+
2263
+ interface IntentTokenPayload {
2264
+ env: string;
2265
+ intent_id: string;
2266
+ version: number;
2267
+ env_alias: string;
2268
+ whitelist_domains: string[];
2269
+ }
2270
+ /**
2271
+ * Class CheckoutButton transform usual button into checkout
2272
+ *
2273
+ * @constructor
2274
+ *
2275
+ * @param {string} selector - Selector of html element.
2276
+ * @param {string} intentToken - PayDock intent token
2277
+ * @example
2278
+ * var widget = new Checkout('#widget', 'intent_token');
2279
+ **/
2280
+ declare class Checkout {
2281
+ protected selector: string;
2282
+ protected intentToken: string;
2283
+ protected debug: boolean;
2284
+ protected window: Window;
2285
+ protected eventEmitter: EventEmitter;
2286
+ protected container: Container;
2287
+ protected intentTokenPayload: IntentTokenPayload;
2288
+ protected api: ApiInternal;
2289
+ protected checkoutApi: ApiCheckoutInternal;
2290
+ protected instructions: InstructionModule;
2291
+ protected currentInstruction: InstructionDestroyable & InstructionHandleable;
2292
+ private checkoutVersionHandler;
2293
+ private timeoutTimer;
2294
+ private requestInFlight;
2295
+ private inTimeoutRange;
2296
+ private checkoutFinished;
2297
+ constructor(selector: string, intentToken: string, debug?: boolean);
2298
+ fetchInstruction(): void;
2299
+ finaliseCheckout(): void;
2300
+ private setupTimeoutTimer;
2301
+ private extractIntentTokenPayload;
2302
+ validateJWTWhitelistedDomains(whitelist_domains: string[]): boolean;
2303
+ private ready;
2304
+ private initContractVersion;
2305
+ private isTimeoutInstruction;
2306
+ private handleInstruction;
2307
+ private handleTimeoutInstructions;
2308
+ private getInstructionFromResponse;
2309
+ private extractInstructionPayloadFromResponse;
2310
+ private setEnv;
2311
+ /**
2312
+ * If the payment was successful, the function passed as parameter will be called.
2313
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
2314
+ *
2315
+ * @example
2316
+ * widget.onPaymentSuccessful((data) => {
2317
+ * console.log('Payment successful!');
2318
+ * });
2319
+ */
2320
+ onPaymentSuccessful(handler: (data: IEventData$1) => void): () => void;
2321
+ /**
2322
+ * If the payment was not successful, the function passed as parameter will be called.
2323
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
2324
+ *
2325
+ * @example
2326
+ * widget.onPaymentError((err) => {
2327
+ * console.log('Payment not successful');
2328
+ * });
2329
+ */
2330
+ onPaymentFailure(handler: (data: IEventData$1) => void): () => void;
2331
+ /**
2332
+ * If the payment was expired, the function passed as parameter will be called.
2333
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
2334
+ *
2335
+ * @example
2336
+ * widget.onPaymentInReview((data) => {
2337
+ * console.log('Payment in fraud review');
2338
+ * });
2339
+ */
2340
+ onPaymentExpired(handler: (data: IEventData$1) => void): () => void;
2341
+ createWidgetStructure(): void;
2342
+ private changeLoadingSpinnerVisibility;
2343
+ }
2344
+
2345
+ declare class InstructionDebugger {
2346
+ constructor(selector: string, version: number, instructionName: string, context: object, token?: string);
2347
+ }
2348
+
2349
+ /**
2350
+ * @type {object}
2351
+ * @param {string} CLICK=click
2352
+ * @param {string} POPUP_REDIRECT=popup_redirect
2353
+ * @param {string} ERROR=error
2354
+ * @param {string} ACCEPTED=accepted
2355
+ * @param {string} FINISH=finish
2356
+ * @param {string} CLOSE=close
2357
+ */
2358
+ declare const CHECKOUT_BUTTON_EVENT: {
2359
+ CLICK: string;
2360
+ POPUP_REDIRECT: string;
2361
+ REDIRECT: string;
2362
+ ERROR: string;
2363
+ REFERRED: string;
2364
+ DECLINED: string;
2365
+ CANCELLED: string;
2366
+ ACCEPTED: string;
2367
+ FINISH: string;
2368
+ CLOSE: string;
2369
+ };
2370
+ /**
2371
+ * @type {object}
2372
+ * @param {string} CONTEXTUAL=contextual
2373
+ * @param {string} REDIRECT=redirect
2374
+ */
2375
+ declare enum CHECKOUT_MODE {
2376
+ CONTEXTUAL = "contextual",
2377
+ REDIRECT = "redirect"
2378
+ }
2379
+ /**
2380
+ * @type {object}
2381
+ * @param {string} ZIPMONEY=Zipmoney
2382
+ * @param {string} PAYPAL=PaypalClassic
2383
+ * @param {string} AFTERPAY=Afterpay
2384
+ */
2385
+ declare enum GATEWAY_TYPE {
2386
+ ZIPMONEY = "Zipmoney",
2387
+ PAYPAL = "PaypalClassic",
2388
+ AFTERPAY = "Afterpay"
2389
+ }
2390
+ interface IEventCheckoutFinishData {
2391
+ payment_source_token: string;
2392
+ checkout_email: string;
2393
+ checkout_holder: string;
2394
+ gateway_type: string;
2395
+ }
2396
+
2397
+ /**
2398
+ * Class Background create overlay for checkout
2399
+ *
2400
+ * @example
2401
+ * var overlay = new Background();
2402
+ */
2403
+ declare class Background {
2404
+ protected description: string;
2405
+ protected title: string;
2406
+ protected overlay: HTMLElement;
2407
+ protected style: HTMLStyleElement;
2408
+ protected eventEmitter: EventEmitter;
2409
+ protected showControl: boolean;
2410
+ protected showLoader: boolean;
2411
+ constructor();
2412
+ initControl(): void;
2413
+ initLoader(): void;
2414
+ private eventHandler;
2415
+ clear(): void;
2416
+ private createLoader;
2417
+ protected createTemplate(): void;
2418
+ private createStyles;
2419
+ setBackdropDescription(text: string): void;
2420
+ setBackdropTitle(text: string): void;
2421
+ onTrigger(triggerName: string, cb: () => void): void;
2422
+ isInit(): boolean;
2423
+ hideContinueControl(): void;
2424
+ turnOffControl(): void;
2425
+ turnOffLoader(): void;
2426
+ }
2427
+
2428
+ declare type SuccessCb = (data: any, status: number) => void;
2429
+ declare type ErrorCb = (err: any, status: number) => void;
2430
+ declare abstract class HttpCore {
2431
+ private env;
2432
+ constructor();
2433
+ setEnv(env: string, alias?: string): void;
2434
+ getEnv(): string;
2435
+ protected getUrl(): string;
2436
+ protected create(accessToken: string, data: any, cb: SuccessCb, errorCb: ErrorCb): void;
2437
+ protected get(accessToken: string, cb: SuccessCb, errorCb: ErrorCb): void;
2438
+ protected parser(text: any, status: number, cb: SuccessCb, errorCb: ErrorCb): void;
2439
+ protected abstract getLink(): string;
2440
+ }
2441
+
2442
+ interface IBody$1 {
2443
+ gateway_id: string;
2444
+ success_redirect_url: string;
2445
+ error_redirect_url: string;
2446
+ redirect_url: string;
2447
+ meta: IPayPalMeta;
2448
+ description?: string;
2449
+ }
2450
+ interface ICheckout {
2451
+ gateway_id: string;
2452
+ checkout_type: string;
2453
+ gateway_type: string;
2454
+ link: string;
2455
+ reference_id: string;
2456
+ token: string;
2457
+ mode?: string;
2458
+ }
2459
+ declare class Builder$1 extends HttpCore {
2460
+ private body;
2461
+ constructor(gatewayID: string, successRedirectUrl: string, errorRedirectUrl: string);
2462
+ protected getLink(): string;
2463
+ setDescriptions(text: string): void;
2464
+ setMeta(meta: IPayPalMeta): void;
2465
+ getConfigs(): IBody$1;
2466
+ send(publicKey: string, cb: (checkout: ICheckout) => void, errorCb?: (error: any, code: string) => void): void;
2467
+ }
2468
+
2469
+ interface IDetails {
2470
+ checkout_email: string;
2471
+ checkout_holder: string;
2472
+ status: string;
2473
+ gateway_type: string;
2474
+ }
2475
+ declare class Checker extends HttpCore {
2476
+ token: string;
2477
+ constructor(token: string);
2478
+ protected getLink(): string;
2479
+ send(accessToken: string, cb: (details: IDetails) => void, errorCb?: (error: any) => void): void;
2480
+ }
2481
+
2482
+ type AdditionalParams = Record<string, string | number | boolean>;
2047
2483
  interface IRunner {
2048
2484
  next(checkoutData: ICheckout, params?: AdditionalParams): void;
2049
2485
  error(error: string, code: string, cb: (close: boolean) => void): void;
@@ -2574,40 +3010,359 @@ declare class FraudPreventionService {
2574
3010
  *
2575
3011
  * Make sure to call withForter() before accessing this getter.
2576
3012
  *
2577
- * @returns {ForterDeviceAgent | null} The Forter device agent instance or null if not initialized
3013
+ * @returns {ForterDeviceAgent | null} The Forter device agent instance or null if not initialized
3014
+ *
3015
+ * @example
3016
+ *
3017
+ * ```js
3018
+ * const fps = new FraudPreventionService();
3019
+ *
3020
+ * fps.withForter({
3021
+ * siteId: 'your-site-id',
3022
+ * mode: 'test'
3023
+ * });
3024
+ *
3025
+ * const token = fps.forter?.token;
3026
+ * ```
3027
+ */
3028
+ get forter(): ForterDeviceAgent | null;
3029
+ /**
3030
+ * Gets the credentials for a specific fraud prevention provider.
3031
+ *
3032
+ * Returns different credential types based on the selected provider.
3033
+ *
3034
+ * @param provider - The fraud prevention provider
3035
+ * @param providerId - The ID of the provider instance
3036
+ *
3037
+ * @returns a tuple with shape [providerSpecificCredentials, error]
3038
+ */
3039
+ getProviderCredentials<P extends FraudPreventionProvider>(provider: P, providerId: string): Promise<Result<P extends "forter" ? {
3040
+ provider: "forter";
3041
+ siteId: string;
3042
+ subsiteId: string;
3043
+ } : never, unknown>>;
3044
+ private validateEnvironmentId;
3045
+ private validateEnvironmentAlias;
3046
+ private validateMode;
3047
+ }
3048
+
3049
+ interface BaseEventData$1<T> {
3050
+ event: string;
3051
+ chargeId?: string;
3052
+ data?: T | undefined;
3053
+ }
3054
+
3055
+ declare enum EVENT$1 {
3056
+ ON_UPDATE = "onUpdate",
3057
+ ON_CLICK = "onClick",
3058
+ ON_CHECKOUT_CLOSE = "onCheckoutClose",
3059
+ SUCCESS = "success",
3060
+ UNAVAILABLE = "unavailable",
3061
+ ERROR = "error",
3062
+ UPDATE = "update",
3063
+ LOADED = "loaded",
3064
+ CHECKOUT_CLOSE = "checkoutClose",
3065
+ ON_SHIPPING_ADDRESS_CHANGE = "onShippingAddressChange",
3066
+ ON_SHIPPING_OPTIONS_CHANGE = "onShippingOptionsChange"
3067
+ }
3068
+ type OpenWalletEventType = EVENT$1;
3069
+
3070
+ interface OnClickEventData$1 {
3071
+ request_type: string;
3072
+ wallet_type?: string;
3073
+ meta?: Record<string, unknown>;
3074
+ }
3075
+ interface OnCrateOTTSuccessfulEventData {
3076
+ token: CreateOTTResponse;
3077
+ amount: number;
3078
+ shipping?: Shipping;
3079
+ billing?: Billing;
3080
+ }
3081
+ interface OnCreateOTTErrorEventData extends BaseEventData$1<{
3082
+ message?: string;
3083
+ code?: string;
3084
+ }> {
3085
+ event: EVENT$1.ERROR;
3086
+ }
3087
+ interface OnUnavailableEventData$1 {
3088
+ wallet_type: string;
3089
+ reason: string;
3090
+ details?: Record<string, unknown>;
3091
+ }
3092
+ interface OnErrorEventData$1 {
3093
+ error: Error;
3094
+ context?: {
3095
+ operation?: string;
3096
+ wallet_type?: string;
3097
+ };
3098
+ }
3099
+
3100
+ interface OpenWalletMeta {
3101
+ amount: number;
3102
+ currency: string;
3103
+ country: string;
3104
+ style?: OpenWalletMetaStyles;
3105
+ }
3106
+ interface OpenWalletMetaStyles {
3107
+ button_type?: string;
3108
+ button_style?: string;
3109
+ }
3110
+
3111
+ interface WalletPaymentSource {
3112
+ load(): void;
3113
+ }
3114
+
3115
+ interface BaseEventData<T> {
3116
+ event: string;
3117
+ data?: T | undefined;
3118
+ }
3119
+
3120
+ interface OnShippingAddressChangeEventData$1 extends BaseEventData<AddressChangeEventData$1> {
3121
+ event: EVENT$1.ON_SHIPPING_ADDRESS_CHANGE;
3122
+ }
3123
+ interface AddressChangeEventData$1 {
3124
+ address_postcode?: string;
3125
+ address_city?: string;
3126
+ address_state?: string;
3127
+ address_country?: string;
3128
+ address_line1?: string;
3129
+ address_line2?: string;
3130
+ contact?: {
3131
+ phone?: string;
3132
+ email?: string;
3133
+ first_name?: string;
3134
+ last_name?: string;
3135
+ };
3136
+ }
3137
+
3138
+ interface OnShippingAddressChangeEventResponse$1 {
3139
+ amount?: number;
3140
+ shipping_options?: IApplePayShippingOption$1[];
3141
+ }
3142
+
3143
+ interface OnShippingOptionChangeEventData$1 extends BaseEventData<ShippingOptionChangeEventData$1> {
3144
+ event: EVENT$1.ON_SHIPPING_OPTIONS_CHANGE;
3145
+ }
3146
+ interface ShippingOptionChangeEventData$1 {
3147
+ shipping_option_id?: string;
3148
+ amount?: string;
3149
+ label?: string;
3150
+ detail?: string;
3151
+ }
3152
+
3153
+ interface OnShippingOptionChangeEventResponse$1 {
3154
+ amount?: number;
3155
+ }
3156
+
3157
+ declare class OpenWalletButtons implements WalletPaymentSource {
3158
+ protected container: Container;
3159
+ protected api: ApiInternal;
3160
+ protected env: string;
3161
+ protected serviceId: string;
3162
+ protected meta: OpenWalletMeta;
3163
+ protected eventEmitter: EventEmitter;
3164
+ readonly walletType: WalletType;
3165
+ constructor(selector: string, publicKeyOrAccessToken: string, serviceId: string, meta: OpenWalletMeta, requiredMetaFields: string[]);
3166
+ private getApiAuthType;
3167
+ private validateRequiredMetaFields;
3168
+ private getOpenWalletServiceConfig;
3169
+ private handleOnError;
3170
+ /**
3171
+ * Loads and initializes the wallet button based on the service configuration.
3172
+ * This method fetches the wallet service configuration and creates the appropriate wallet service instance.
3173
+ * Bear in mind that you must call this method after setting up all event handlers.
3174
+ *
3175
+ * @example
3176
+ * button.load();
3177
+ */
3178
+ load(): void;
3179
+ /**
3180
+ * Current method can change environment. By default environment = sandbox.
3181
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
3182
+ * Bear in mind that you must set an environment before calling `button.load()`.
3183
+ *
3184
+ * @example
3185
+ * button.setEnv('production', 'paydock.com');
3186
+ * @param {string} env - sandbox, production
3187
+ * @param {string} [alias] - Own domain alias
3188
+ */
3189
+ setEnv(env: string, alias?: string): void;
3190
+ /**
3191
+ * Callback for onClick method.
3192
+ *
3193
+ * @callback OnClickCallback
3194
+ * @param {OnClickEventData} data
3195
+ */
3196
+ /**
3197
+ /**
3198
+ * Registers a callback function to be invoked when the wallet button gets clicked.
3199
+ * There are two operational modes supported, Synchronous and Asynchronous.
3200
+ * When asynchronous operations need to occur on the callback handler, attaching the Promise via `attachResult` is required to have the wallet wait for a result.
3201
+ * When synchronous operations occur on the callback handler, attaching a boolean result via `attachResult` is optional to control the execution flow.
3202
+ * Note this is supported for Paypal, GooglePay and ApplePay wallet buttons at the moment.
3203
+ *
3204
+ * @example
3205
+ * button.onClick((data) => {
3206
+ * performValidationLogic();
3207
+ * });
3208
+ *
3209
+ * @param {listener} handler - Function to be called when the wallet button is clicked.
3210
+ */
3211
+ onClick(handler: (data: OnClickEventData$1) => void): () => void;
3212
+ /**
3213
+ * Callback for onSuccess method.
3214
+ *
3215
+ * @callback OnSuccessCallback
3216
+ * @param {OnCrateOTTSuccessfulEventData} data
3217
+ * @return {Promise<string>} OTT (One Time Token) string result
3218
+ */
3219
+ /**
3220
+ * If the OTT creation was successful, the function passed as parameter will be called.
3221
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3222
+ *
3223
+ * @example
3224
+ * button.onSuccess((data) => {
3225
+ * console.log('OTT creation successful!', data);
3226
+ * });
3227
+ *
3228
+ * @example
3229
+ * button.onSuccess().then((data) => console.log('OTT creation successful!', data));
3230
+ *
3231
+ * @param {OnSuccessCallback} [handler] - Function to be called when the OTT creation was successful.
3232
+ */
3233
+ onSuccess(handler?: (data: OnCrateOTTSuccessfulEventData) => void): () => void;
3234
+ /**
3235
+ * Callback for onUnavailable method.
3236
+ *
3237
+ * @callback OnUnavailableCallback
3238
+ * @param {OnUnavailableEventData} data
3239
+ */
3240
+ /**
3241
+ * Registers a callback function to be invoked when the wallet is not available in the current context.
3242
+ * This can happen when the wallet service is not supported on the current device or browser.
3243
+ *
3244
+ * @example
3245
+ * button.onUnavailable((data) => {
3246
+ * console.log('Wallet not available', data);
3247
+ * });
3248
+ *
3249
+ * @example
3250
+ * button.onUnavailable().then((data) => console.log('Wallet not available', data));
3251
+ *
3252
+ * @param {OnUnavailableCallback} [handler] - Function to be called when the wallet is not available in the current context.
3253
+ */
3254
+ onUnavailable(handler?: (data: OnUnavailableEventData$1) => void): Promise<unknown> | (() => void);
3255
+ /**
3256
+ * Callback for onError method.
3257
+ *
3258
+ * @callback OnErrorCallback
3259
+ * @param {OnErrorEventData} data
3260
+ */
3261
+ /**
3262
+ * Registers a callback function to be invoked when an error that is not related to payment execution occurs.
3263
+ * For example, if there are configuration issues or validation errors during wallet initialization.
3264
+ *
3265
+ * @example
3266
+ * button.onError((error) => {
3267
+ * console.log('OpenWallet error', error);
3268
+ * });
3269
+ *
3270
+ * @example
3271
+ * button.onError().then((error) => console.log('OpenWallet error', error));
3272
+ *
3273
+ * @param {OnErrorCallback} [handler] - Function to be called when the OpenWallet has an error.
3274
+ */
3275
+ onError(handler?: (data: OnErrorEventData$1) => void): Promise<unknown> | (() => void);
3276
+ /**
3277
+ * Callback for onCancel method.
3278
+ *
3279
+ * @callback OnCancelCallback
3280
+ * @param {any} data
3281
+ */
3282
+ /**
3283
+ * Registers a callback function to be invoked when the wallet checkout is cancelled or closed by the user.
3284
+ * This event is triggered when the user dismisses the wallet payment interface without completing the transaction.
3285
+ *
3286
+ * @example
3287
+ * button.onCancel((data) => {
3288
+ * console.log('Wallet checkout cancelled', data);
3289
+ * });
2578
3290
  *
2579
3291
  * @example
3292
+ * button.onCancel().then((data) => console.log('Wallet checkout cancelled', data));
2580
3293
  *
2581
- * ```js
2582
- * const fps = new FraudPreventionService();
3294
+ * @param {OnCancelCallback} [handler] - Function to be called when the wallet checkout is cancelled.
3295
+ */
3296
+ onCancel(handler?: (data: any) => void): Promise<unknown> | (() => void);
3297
+ /**
3298
+ * Callback for onShippingAddressChange method.
2583
3299
  *
2584
- * fps.withForter({
2585
- * siteId: 'your-site-id',
2586
- * mode: 'test'
3300
+ * @callback OnShippingAddressChangeCallback
3301
+ * @param {OnShippingAddressChangeEventData} data
3302
+ * @return {Promise<OnShippingAddressChangeEventResponse>} Address update result containing updated amount and/or shipping options
3303
+ */
3304
+ /**
3305
+ * If shipping address data is updated, the function passed as parameter will be called.
3306
+ * Use this method to listen for shipping address selection or input from customer when shipping is enabled.
3307
+ * The event handler should return updated payment information including the new amount and available shipping options based on the selected address.
3308
+ *
3309
+ * @example
3310
+ * button.onShippingAddressChange(async (data) => {
3311
+ * const responseData = await fetch('https://your-server.com/update-shipping-address');
3312
+ * return {
3313
+ * amount: responseData.newAmount,
3314
+ * shipping_options: responseData.availableShippingOptions
3315
+ * };
2587
3316
  * });
2588
3317
  *
2589
- * const token = fps.forter?.token;
2590
- * ```
3318
+ * @param {OnShippingAddressChangeCallback} [handler] - Function to be called when the shipping address data is updated.
2591
3319
  */
2592
- get forter(): ForterDeviceAgent | null;
3320
+ onShippingAddressChange(handler?: (data: OnShippingAddressChangeEventData$1) => Promise<OnShippingAddressChangeEventResponse$1>): () => void;
2593
3321
  /**
2594
- * Gets the credentials for a specific fraud prevention provider.
3322
+ * Callback for onShippingOptionsChange method.
2595
3323
  *
2596
- * Returns different credential types based on the selected provider.
3324
+ * @callback OnShippingOptionsChangeCallback
3325
+ * @param {OnShippingOptionChangeEventData} data
3326
+ * @return {Promise<OnShippingOptionChangeEventResponse>} Shipping options update result containing updated amount
3327
+ */
3328
+ /**
3329
+ * If shipping options data is updated, the function passed as parameter will be called.
3330
+ * Use this method to listen for shipping option selection from customer when shipping is enabled.
3331
+ * The event handler should return the updated payment amount based on the selected shipping option.
2597
3332
  *
2598
- * @param provider - The fraud prevention provider
2599
- * @param providerId - The ID of the provider instance
3333
+ * @example
3334
+ * button.onShippingOptionsChange(async (data) => {
3335
+ * const responseData = await fetch('https://your-server.com/update-shipping-option');
3336
+ * return {
3337
+ * amount: responseData.newTotalAmount
3338
+ * };
3339
+ * });
2600
3340
  *
2601
- * @returns a tuple with shape [providerSpecificCredentials, error]
3341
+ * @param {OnShippingOptionsChangeCallback} [handler] - Function to be called when the shipping options data is updated.
2602
3342
  */
2603
- getProviderCredentials<P extends FraudPreventionProvider>(provider: P, providerId: string): Promise<Result<P extends "forter" ? {
2604
- provider: "forter";
2605
- siteId: string;
2606
- subsiteId: string;
2607
- } : never, unknown>>;
2608
- private validateEnvironmentId;
2609
- private validateEnvironmentAlias;
2610
- private validateMode;
3343
+ onShippingOptionsChange(handler?: (data: OnShippingOptionChangeEventData$1) => Promise<OnShippingOptionChangeEventResponse$1>): () => void;
3344
+ }
3345
+
3346
+ declare const TYPE: {
3347
+ EXTERNAL_CHECKOUT_TOKEN: string;
3348
+ CHECKOUT_TOKEN: string;
3349
+ BANK_ACCOUNT: string;
3350
+ CARD: string;
3351
+ };
3352
+ interface IBody {
3353
+ gateway_id: string;
3354
+ type: string;
3355
+ checkout_token?: string;
3356
+ }
3357
+ declare class Builder extends HttpCore {
3358
+ private body;
3359
+ constructor(gatewayID: string, checkoutToken: string, type: string);
3360
+ constructor(gatewayID: string, externalCheckoutToken: string, type: string);
3361
+ constructor(gatewayID: string, card: any, type: string);
3362
+ constructor(gatewayID: string, bankAccount: any, type: string);
3363
+ protected getLink(): string;
3364
+ send(accessToken: string, cb: (token: string) => void, errorCb?: (error: any) => void): void;
3365
+ getConfigs(): IBody;
2611
3366
  }
2612
3367
 
2613
3368
  /**
@@ -2873,321 +3628,215 @@ declare class HtmlPaymentSourceWidget extends PaymentSourceWidget {
2873
3628
  onSelectInsert(selector: string, dataType: string): void;
2874
3629
  }
2875
3630
 
2876
- declare class ApiChargeInternal {
2877
- protected api: ApiInternal;
2878
- constructor(api: ApiInternal);
2879
- walletCapture(payload: WalletCaptureBody): Promise<WalletCaptureResponse>;
2880
- walletCallback(payload: WalletCallbackBody): Promise<WalletCallbackResponse>;
2881
- standalone3dsProcess(payload: Standalone3dsProcessBody): Promise<ProcessAuthenticationResponse>;
2882
- standalone3dsHandle(): Promise<HandleResponseInterface>;
2883
- }
2884
- interface WalletCaptureResponse {
2885
- id: string;
2886
- amount: number;
2887
- currency: string;
2888
- status: string;
2889
- }
2890
- interface WalletCaptureBody {
2891
- payment_method_id?: string;
2892
- customer?: {
2893
- payment_source?: {
2894
- type?: string;
2895
- card_name?: string;
2896
- card_scheme?: string;
2897
- card_number_last4?: string;
2898
- expire_month?: number;
2899
- expire_year?: number;
2900
- address_line1?: string;
2901
- address_line2?: string;
2902
- address_city?: string;
2903
- address_postcode?: string;
2904
- address_state?: string;
2905
- address_country?: string;
2906
- external_payer_id?: string;
2907
- ref_token?: string;
2908
- wallet_express?: boolean;
2909
- };
2910
- };
2911
- }
2912
- interface WalletCallbackBody {
2913
- request_type: string;
2914
- }
2915
- interface WalletCallbackResponse {
2916
- id: string;
2917
- status: string;
2918
- callback_method: string;
2919
- callback_rel: string;
2920
- callback_url: string;
2921
- }
2922
- interface Standalone3dsProcessBody {
2923
- charge_3ds_id: string;
2924
- }
2925
- interface HandleResponseInterface {
2926
- status: string;
2927
- error: string;
2928
- result: {
2929
- reference: string;
2930
- reference_2: string;
2931
- identifier: string;
2932
- identifier_2: string;
2933
- identifier_3: string;
2934
- identifier_4: string;
2935
- identifier_5: string;
2936
- type: string;
2937
- status: string;
2938
- status_2: string;
2939
- status_code: string;
2940
- ref_token: string;
2941
- cancellation: string;
2942
- count: string;
2943
- version: string;
2944
- whitelist: {
2945
- status: string;
2946
- source: string;
2947
- };
2948
- result: string;
2949
- };
2950
- }
2951
- interface ProcessAuthenticationResponse {
2952
- status: string;
2953
- error?: string;
2954
- result?: {
2955
- challenge: string;
2956
- challenge_url: string;
2957
- decoupled_challenge: boolean;
2958
- frictionless: boolean;
2959
- identifier: string;
2960
- identifier_3: string;
2961
- identifier_4: string;
2962
- reference: string;
2963
- reference_2: string;
2964
- secondary_url: string;
2965
- skipped: boolean;
2966
- status: string;
2967
- type: string;
2968
- version: string;
2969
- description?: string;
2970
- };
2971
- }
2972
-
2973
- declare class ApiCheckoutInternal {
2974
- protected api: ApiInternal;
2975
- constructor(api: ApiInternal);
2976
- instructions(): Observable<object>;
2977
- private getInstructionLink;
2978
- callback(payload: Object): Promise<Object>;
2979
- status(id: string): Promise<Object>;
2980
- }
2981
-
2982
- declare class ApiGatewayInternal {
2983
- protected api: ApiInternal;
2984
- constructor(api: ApiInternal);
2985
- getWalletConfig(gateway_id: string): Promise<GetWalletConfigResponse>;
2986
- }
2987
- interface GetWalletConfigResponse {
2988
- type: string;
2989
- mode: string;
2990
- credentials?: object;
2991
- }
2992
-
2993
- interface CreateOTTResponse {
2994
- status: number;
2995
- error: string | null;
2996
- resource: {
2997
- type: string;
2998
- data: {
2999
- token: string;
3000
- '3ds_required': boolean;
3001
- };
3002
- };
3003
- }
3004
- interface CreateOTTRequest {
3005
- checkoutData: CheckoutResponse;
3006
- }
3007
- type CheckoutResponse = ApplePayJS.ApplePayPaymentAuthorizedEvent | google.payments.api.PaymentAuthorizationResult;
3008
- declare enum CheckoutActionCode {
3009
- COMPLETE = "COMPLETE",
3010
- CANCEL = "CANCEL",
3011
- ERROR = "ERROR",
3012
- CHANGE_CARD = "CHANGE_CARD",
3013
- ADD_CARD = "ADD_CARD",
3014
- SWITCH_CONSUMER = "SWITCH_CONSUMER"
3015
- }
3016
-
3017
- declare class ApiPaymentSourceInternal {
3018
- protected api: ApiInternal;
3019
- constructor(api: ApiInternal);
3020
- createOTT(payload: CreateOTTRequest): Promise<CreateOTTResponse>;
3021
- }
3022
-
3023
- declare class ApiServiceInternal {
3024
- protected api: ApiInternal;
3025
- constructor(api: ApiInternal);
3026
- getConfig(service_id: string): Promise<GetConfigResponse>;
3027
- }
3028
- interface GetConfigResponse {
3029
- type: string;
3030
- merchant: string;
3031
- username: string;
3032
- password: string;
3033
- certificate: string;
3034
- certificate_passphrase: string;
3035
- }
3036
-
3037
- declare class ApiInternal extends ApiBase {
3038
- charge(): ApiChargeInternal;
3039
- service(): ApiServiceInternal;
3040
- checkout(): ApiCheckoutInternal;
3041
- gateway(): ApiGatewayInternal;
3042
- paymentSource(): ApiPaymentSourceInternal;
3043
- }
3044
-
3045
- type WalletType = WALLET_TYPES;
3046
- declare enum WALLET_TYPES {
3047
- APPLE_PAY = "ApplePay",
3048
- GOOGLE_PAY = "GooglePay"
3049
- }
3050
-
3051
- interface OTTResponse {
3052
- token: string;
3053
- token_type: string;
3054
- three_ds_required?: boolean;
3055
- wallet_type: WalletType;
3631
+ declare enum ErrorCodes$1 {
3632
+ PROMISE_NOT_ENABLED = "promise_not_enabled",
3633
+ SCRIPT_ERROR = "script_error"
3056
3634
  }
3057
-
3058
- interface BaseServiceConfig<T = Record<string, unknown>> {
3059
- type: string;
3060
- credentials?: T;
3061
- meta?: Record<string, unknown>;
3635
+ interface PayPalDataCollectorConfig {
3636
+ mouse_movement?: boolean;
3062
3637
  }
3063
- interface ApplePayServiceConfig {
3064
- apple: {
3065
- merchant: {
3066
- merchant_id: string;
3067
- domain_name: string;
3068
- display_name: string;
3069
- };
3070
- certificate: {
3071
- certificate_id: string;
3072
- private_key: string;
3073
- };
3074
- };
3638
+ interface IPayPalDataCollector {
3639
+ collectDeviceData(): Promise<CollectedDeviceData>;
3640
+ setEnv(env: string): void;
3075
3641
  }
3076
- interface GooglePayServiceConfig {
3077
- google_pay: {
3078
- merchant: {
3079
- merchant_id: string;
3080
- merchant_name: string;
3081
- };
3082
- gateway_merchant_id: string;
3083
- allowed_auth_methods: string[];
3084
- allowed_card_networks: string[];
3085
- };
3642
+ interface CollectedDeviceData {
3643
+ correlation_id: string;
3086
3644
  }
3087
-
3088
- interface BaseWalletMeta$1 {
3089
- amount: number;
3090
- currency: string;
3645
+ interface IOnErrorEventData$1 {
3646
+ error_code: ErrorCodes$1;
3091
3647
  }
3092
3648
 
3093
- interface BaseEventData<T> {
3094
- event: string;
3095
- chargeId?: string;
3096
- data?: T | undefined;
3649
+ /**
3650
+ * PayPal Data Collector Widget constructor
3651
+ *
3652
+ * @param {string} [flowId] - This string identifies the source website of the FraudNet request.
3653
+ * @param {PayPalDataCollectorConfig} [config] - Extra configuration for the widget.
3654
+ *
3655
+ * @example
3656
+ * var payPalDataCollector = new PayPalDataCollector('FLOW_ID', {});
3657
+ */
3658
+ declare class PayPalDataCollector {
3659
+ protected service: IPayPalDataCollector;
3660
+ protected eventEmitter: EventEmitter;
3661
+ /** @constructs */ constructor(flowId?: string, config?: PayPalDataCollectorConfig);
3662
+ /**
3663
+ * After configuring the PayPalDataCollector Widget, starts the process and returns
3664
+ * the correlation id used among the requests asynchronously.
3665
+ *
3666
+ * @returns {Promise<CollectedDeviceData>} Promise when resolved, returns an object
3667
+ * that contains the `correlation_id` key.
3668
+ *
3669
+ * @example
3670
+ * const collectedDeviceData = await payPalDataCollectorWidget.collectDeviceData();
3671
+ * console.log(collectedDeviceData.correlation_id)
3672
+ */
3673
+ collectDeviceData(): Promise<CollectedDeviceData>;
3674
+ /**
3675
+ * Callback for onError method.
3676
+ *
3677
+ * @callback OnErrorCallback
3678
+ * @param {IOnErrorEventData|null} data
3679
+ */
3680
+ /**
3681
+ * If the process fails, the function passed as parameter will be called.
3682
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3683
+ *
3684
+ * @example
3685
+ * PayPalDataCollector.onError((eventData) => console.log('Some error occur'));
3686
+ *
3687
+ * @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow.
3688
+ */
3689
+ onError(callback?: (data?: IOnErrorEventData$1) => void): () => void;
3690
+ /**
3691
+ * Current method can change environment. By default environment = test.
3692
+ * This method does not affect Paydock's API calls or environments, is only for PayPal Data Collector
3693
+ * script, in order to know if the script is injected on a live server or is a testing
3694
+ * environment. The available values are `test` and `live`. This should match with the used
3695
+ * `gateway.mode` in Paydock to process the transaction.
3696
+ *
3697
+ * @example
3698
+ * PayPalDataCollector.setEnv('live');
3699
+ * @param {string} env - test, live
3700
+ */
3701
+ setEnv(env: string): void;
3097
3702
  }
3098
3703
 
3099
- declare enum EVENT$1 {
3100
- ON_CLICK = "onClick",
3101
- SUCCESS = "success",
3102
- UNAVAILABLE = "unavailable",
3103
- ERROR = "error"
3704
+ interface PayPalStyleConfig {
3705
+ layout?: 'vertical' | 'horizontal';
3706
+ color?: 'blue' | 'gold' | 'silver' | 'black' | 'white';
3707
+ shape?: 'rect' | 'sharp' | 'pill';
3708
+ label?: 'paypal' | 'checkout' | 'buynow' | 'pay';
3709
+ disableMaxWidth?: boolean;
3710
+ disableMaxHeight?: boolean;
3711
+ height?: number;
3712
+ borderRadius?: number;
3713
+ tagline?: boolean;
3104
3714
  }
3105
- type OpenWalletEventType = EVENT$1;
3106
-
3107
- interface OnClickEventData$1 {
3108
- request_type: string;
3109
- wallet_type?: string;
3110
- meta?: Record<string, unknown>;
3715
+ interface PayPalMessageConfig {
3716
+ amount?: number;
3717
+ align?: 'center' | 'left' | 'right';
3718
+ color?: 'black' | 'white';
3719
+ position?: 'top' | 'bottom';
3111
3720
  }
3112
- interface OnCrateOTTSuccessfulEventData {
3113
- token: string;
3114
- token_type: string;
3115
- checkoutData?: CheckoutResponse | unknown;
3116
- three_ds_required?: boolean;
3117
- wallet_type: string;
3721
+ interface PayPalSavePaymentSourceWidgetConfig {
3722
+ style?: PayPalStyleConfig;
3723
+ message?: PayPalMessageConfig;
3118
3724
  }
3119
- interface OnCreateOTTErrorEventData extends BaseEventData<{
3120
- message?: string;
3121
- code?: string;
3122
- }> {
3123
- event: EVENT$1.ERROR;
3725
+ interface IPayPalSavePaymentSourceWidget {
3726
+ load(container: Container): void;
3727
+ setEnv(env: string, alias?: string): void;
3124
3728
  }
3125
- interface OnUnavailableEventData$1 {
3126
- wallet_type: string;
3127
- reason: string;
3128
- details?: Record<string, unknown>;
3729
+ declare enum ErrorCodes {
3730
+ UNAVAILABLE = "unavailable",
3731
+ ON_PAYPAL_VAULT_SETUP_TOKEN_ERROR = "onPaypalVaultSetupTokenError",
3732
+ ON_GET_ID_TOKEN_ERROR = "onGetIdTokenError",
3733
+ ON_GET_WALLET_CONFIG_ERROR = "onGetWalletConfigError",
3734
+ ON_GET_SETUP_TOKEN_ERROR = "onGetSetupTokenError",
3735
+ ON_ONE_TIME_TOKEN_ERROR = "onOneTimeTokenError"
3129
3736
  }
3130
- interface OnErrorEventData$1 {
3131
- error: Error;
3132
- context?: {
3133
- operation?: string;
3134
- wallet_type?: string;
3737
+ declare enum EVENTS {
3738
+ ON_SUCCESS = "ON_SUCCESS",
3739
+ ON_ERROR = "ON_ERROR",
3740
+ ON_CANCEL = "ON_CANCEL"
3741
+ }
3742
+ interface IOnSuccessEventData {
3743
+ event: EVENTS.ON_SUCCESS;
3744
+ data: {
3745
+ token: string;
3746
+ email: string;
3135
3747
  };
3136
3748
  }
3137
-
3138
- interface WalletPaymentSource {
3139
- load(): void;
3140
- setMeta(meta: object): void;
3749
+ interface IOnErrorEventData {
3750
+ event: EVENTS.ON_ERROR;
3751
+ data: {
3752
+ error_code: ErrorCodes;
3753
+ details?: string;
3754
+ message?: string;
3755
+ };
3756
+ }
3757
+ interface IOnCancelEventData {
3758
+ event: EVENTS.ON_CANCEL;
3141
3759
  }
3142
3760
 
3143
- declare abstract class BaseOpenWallet<T extends BaseWalletMeta$1> implements WalletPaymentSource {
3761
+ /**
3762
+ * PayPal Save Payment Source Widget constructor
3763
+ *
3764
+ * @param {string} selector - Selector of html element. Container for PayPal Save Payment Source Widget.
3765
+ * @param {string} publicKey - PayDock users public key.
3766
+ * @param {string} gatewayId - PayDock's PayPal gatewayId.
3767
+ * @param {PayPalSavePaymentSourceWidgetConfig} config - Extra configuration for the widget, like styles.
3768
+ *
3769
+ * @example
3770
+ * var payPalSavePaymentSourceWidget = new PayPalSavePaymentSourceWidget('#paypalButton', 'public_key', 'gateway_id');
3771
+ */
3772
+ declare class PayPalSavePaymentSourceWidget {
3144
3773
  protected container: Container;
3145
- protected api: ApiInternal;
3146
- protected env: string;
3147
- protected serviceId: string;
3148
- protected meta: T;
3774
+ protected service: IPayPalSavePaymentSourceWidget;
3149
3775
  protected eventEmitter: EventEmitter;
3150
- abstract readonly walletType: WalletType;
3151
- constructor(selector: string, publicKeyOrAccessToken: string, serviceId: string, meta: T, requiredMetaFields: string[]);
3152
- private getApiAuthType;
3776
+ /** @constructs */ constructor(selector: string, publicKey: string, gatewayId: string, config?: PayPalSavePaymentSourceWidgetConfig);
3777
+ /**
3778
+ * The final method after configuring the PayPalSavePaymentSource Widget to
3779
+ * start the load process.
3780
+ */
3781
+ load(): void;
3782
+ /**
3783
+ * Current method can change environment. By default environment = sandbox.
3784
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
3785
+ *
3786
+ * @example
3787
+ * payPalSavePaymentSourceWidget.setEnv('production');
3788
+ * @param {string} env - sandbox, production
3789
+ * @param {string} [alias] - Own domain alias
3790
+ */
3153
3791
  setEnv(env: string, alias?: string): void;
3154
- private validateRequiredMetaFields;
3155
- abstract load(): void;
3156
- abstract setMeta(meta: object): void;
3157
- onClick(handler: (data: OnClickEventData$1) => Promise<string>): () => void;
3158
- onSuccess(handler?: (data: OnCrateOTTSuccessfulEventData) => void): Promise<unknown> | (() => void);
3159
- onUnavailable(handler?: (data: OnUnavailableEventData$1) => void): Promise<unknown> | (() => void);
3160
- onError(handler?: (data: OnErrorEventData$1) => void): Promise<unknown> | (() => void);
3161
- protected getServiceWalletConfig<K>(): Promise<BaseServiceConfig<K>>;
3162
- protected executeOpenWalletCallback<K, U extends {
3163
- request_type: string;
3164
- }>(data: U): Promise<K>;
3165
- protected createOTT(data: CreateOTTRequest): Promise<CreateOTTResponse>;
3166
- protected handleOnError(error: Error): void;
3167
- protected handleOnUnavailable(reason?: string): void;
3168
- destroy(): void;
3169
- }
3170
-
3171
- declare const TYPE: {
3172
- EXTERNAL_CHECKOUT_TOKEN: string;
3173
- CHECKOUT_TOKEN: string;
3174
- BANK_ACCOUNT: string;
3175
- CARD: string;
3176
- };
3177
- interface IBody {
3178
- gateway_id: string;
3179
- type: string;
3180
- checkout_token?: string;
3181
- }
3182
- declare class Builder extends HttpCore {
3183
- private body;
3184
- constructor(gatewayID: string, checkoutToken: string, type: string);
3185
- constructor(gatewayID: string, externalCheckoutToken: string, type: string);
3186
- constructor(gatewayID: string, card: any, type: string);
3187
- constructor(gatewayID: string, bankAccount: any, type: string);
3188
- protected getLink(): string;
3189
- send(accessToken: string, cb: (token: string) => void, errorCb?: (error: any) => void): void;
3190
- getConfigs(): IBody;
3792
+ /**
3793
+ * Callback for onSuccess method.
3794
+ *
3795
+ * @callback OnSuccessCallback
3796
+ * @param {IOnSuccessEventData} data
3797
+ */
3798
+ /**
3799
+ * If the setup token was successfully approved and a OTT was generated, the function passed as parameter will be called.
3800
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3801
+ *
3802
+ * @example
3803
+ * payPalSavePaymentSourceWidget.onSuccess((eventData) => console.log('One time token and email obtained successfully'));
3804
+ *
3805
+ * @param {OnSuccessCallback} [callback] - Function to be called when the result is successful.
3806
+ */
3807
+ onSuccess(callback?: (data: IOnSuccessEventData) => void): () => void;
3808
+ /**
3809
+ * Callback for onError method.
3810
+ *
3811
+ * @callback OnErrorCallback
3812
+ * @param {IOnErrorEventData} data
3813
+ */
3814
+ /**
3815
+ * If in the process for obtaining the setup token fails, the function passed as parameter will be called.
3816
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3817
+ *
3818
+ * @example
3819
+ * payPalSavePaymentSourceWidget.onError((eventData) => console.log('Some error occurred'));
3820
+ *
3821
+ * @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow.
3822
+ */
3823
+ onError(callback?: (data: IOnErrorEventData) => void): () => void;
3824
+ /**
3825
+ * Callback for onCancel method.
3826
+ *
3827
+ * @callback OnCancelCallback
3828
+ * @param {IOnCancelEventData} data
3829
+ */
3830
+ /**
3831
+ * If in the process for obtaining the setup token was cancelled, the function passed as parameter will be called.
3832
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3833
+ *
3834
+ * @example
3835
+ * payPalSavePaymentSourceWidget.onCancel(() => console.log('Operation cancelled'));
3836
+ *
3837
+ * @param {OnCancelCallback} [callback] - Function to be called when the operation is cancelled.
3838
+ */
3839
+ onCancel(callback?: (data?: IOnCancelEventData) => void): () => void;
3191
3840
  }
3192
3841
 
3193
3842
  interface IBaseSRCMeta {
@@ -3300,19 +3949,19 @@ declare abstract class SRC {
3300
3949
  protected style: IStyles;
3301
3950
  constructor(iframe_selector: string, service_id: string, public_key_or_access_token: string, meta: IClickToPayMeta);
3302
3951
  /**
3303
- * Object contain styles for widget - call before `.load()`.
3304
- *
3305
- * @example
3306
- * widget.setStyles({
3307
- * enable_src_popup: true
3308
- * primary_button_color: 'red',
3309
- * secondary_button_color: 'blue',
3310
- * primary_button_text_color: 'white',
3311
- * secondary_button_text_color: 'white',
3312
- * font_family: 'Arial',
3313
- * });
3314
- * @param {IStyles} fields - name of styles which can be shown in widget [STYLE]{@link STYLE}
3315
- */
3952
+ * Object contain styles for widget - call before `.load()`.
3953
+ *
3954
+ * @example
3955
+ * widget.setStyles({
3956
+ * enable_src_popup: true
3957
+ * primary_button_color: 'red',
3958
+ * secondary_button_color: 'blue',
3959
+ * primary_button_text_color: 'white',
3960
+ * secondary_button_text_color: 'white',
3961
+ * font_family: 'Arial',
3962
+ * });
3963
+ * @param {IStyles} fields - name of styles which can be shown in widget [STYLE]{@link STYLE}
3964
+ */
3316
3965
  setStyles(styles: IStyles): void;
3317
3966
  private setStyle;
3318
3967
  load(): void;
@@ -3900,210 +4549,17 @@ declare class WalletButtons {
3900
4549
  private setupAuthTokensChangedCallback;
3901
4550
  }
3902
4551
 
3903
- type Instruction = new (selector: string, api: ApiInternal, checkoutWidget: Checkout, formSelector?: string) => InstructionHandler & InstructionDestroyable & InstructionDecorated;
3904
- interface InstructionHandleable {
3905
- handle(payload: object, eventEmitter: EventEmitter): void;
3906
- }
3907
- interface InstructionDecorated {
3908
- instruction: string;
3909
- }
3910
- interface InstructionDestroyable {
3911
- destroy(): void;
3912
- }
3913
- declare abstract class InstructionHandler implements InstructionHandleable, InstructionDestroyable, InstructionDecorated {
3914
- selector: string;
3915
- api: ApiInternal;
3916
- protected checkoutWidget?: Checkout;
3917
- formSelector?: string;
3918
- constructor(selector: string, api: ApiInternal, checkoutWidget?: Checkout, formSelector?: string);
3919
- instruction: string;
3920
- abstract handle(context: object, eventEmitter?: any): void;
3921
- destroy(): void;
3922
- getEnv(instruction_token: string): string;
3923
- }
3924
-
3925
- declare class InstructionModule {
3926
- instructions: any[];
3927
- getInstruction(id: string): Instruction | null;
3928
- }
3929
-
3930
- interface IntentTokenPayload {
3931
- env: string;
3932
- intent_id: string;
3933
- version: number;
3934
- env_alias: string;
3935
- whitelist_domains: string[];
3936
- }
3937
- /**
3938
- * Class CheckoutButton transform usual button into checkout
3939
- *
3940
- * @constructor
3941
- *
3942
- * @param {string} selector - Selector of html element.
3943
- * @param {string} intentToken - PayDock intent token
3944
- * @example
3945
- * var widget = new Checkout('#widget', 'intent_token');
3946
- **/
3947
- declare class Checkout {
3948
- protected selector: string;
3949
- protected intentToken: string;
3950
- protected debug: boolean;
3951
- protected window: Window;
3952
- protected eventEmitter: EventEmitter;
3953
- protected container: Container;
3954
- protected intentTokenPayload: IntentTokenPayload;
3955
- protected api: ApiInternal;
3956
- protected checkoutApi: ApiCheckoutInternal;
3957
- protected instructions: InstructionModule;
3958
- protected currentInstruction: InstructionDestroyable & InstructionHandleable;
3959
- private checkoutVersionHandler;
3960
- private timeoutTimer;
3961
- private requestInFlight;
3962
- private inTimeoutRange;
3963
- private checkoutFinished;
3964
- constructor(selector: string, intentToken: string, debug?: boolean);
3965
- fetchInstruction(): void;
3966
- finaliseCheckout(): void;
3967
- private setupTimeoutTimer;
3968
- private extractIntentTokenPayload;
3969
- validateJWTWhitelistedDomains(whitelist_domains: string[]): boolean;
3970
- private ready;
3971
- private initContractVersion;
3972
- private isTimeoutInstruction;
3973
- private handleInstruction;
3974
- private handleTimeoutInstructions;
3975
- private getInstructionFromResponse;
3976
- private extractInstructionPayloadFromResponse;
3977
- private setEnv;
3978
- /**
3979
- * If the payment was successful, the function passed as parameter will be called.
3980
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3981
- *
3982
- * @example
3983
- * widget.onPaymentSuccessful((data) => {
3984
- * console.log('Payment successful!');
3985
- * });
3986
- */
3987
- onPaymentSuccessful(handler: (data: IEventData$1) => void): () => void;
3988
- /**
3989
- * If the payment was not successful, the function passed as parameter will be called.
3990
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3991
- *
3992
- * @example
3993
- * widget.onPaymentError((err) => {
3994
- * console.log('Payment not successful');
3995
- * });
3996
- */
3997
- onPaymentFailure(handler: (data: IEventData$1) => void): () => void;
3998
- /**
3999
- * If the payment was expired, the function passed as parameter will be called.
4000
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
4001
- *
4002
- * @example
4003
- * widget.onPaymentInReview((data) => {
4004
- * console.log('Payment in fraud review');
4005
- * });
4006
- */
4007
- onPaymentExpired(handler: (data: IEventData$1) => void): () => void;
4008
- createWidgetStructure(): void;
4009
- private changeLoadingSpinnerVisibility;
4010
- }
4011
-
4012
- declare class InstructionDebugger {
4013
- constructor(selector: string, version: number, instructionName: string, context: object, token?: string);
4014
- }
4015
-
4016
- declare enum EVENT {
4017
- UNAVAILABLE = "unavailable",
4018
- ERROR = "error",
4019
- PAYMENT_SUCCESSFUL = "paymentSuccessful",
4020
- PAYMENT_ERROR = "paymentError",
4021
- PAYMENT_IN_REVIEW = "paymentInReview",
4022
- ON_CLICK = "onClick",
4023
- ON_CHECKOUT_CLOSE = "onCheckoutClose",
4024
- ON_SHIPPING_ADDRESS_CHANGE = "onShippingAddressChange",
4025
- ON_SHIPPING_OPTIONS_CHANGE = "onShippingOptionsChange"
4026
- }
4027
-
4028
- interface OnClickEventData extends BaseEventData<undefined> {
4029
- event: EVENT.ON_CLICK;
4030
- }
4031
-
4032
- interface OnPaymentSuccessfulEventData extends BaseEventData<{
4033
- id: string;
4034
- amount: number;
4035
- currency: string;
4036
- status: string;
4037
- }> {
4038
- event: EVENT.PAYMENT_SUCCESSFUL;
4039
- }
4040
-
4041
- interface OnCloseEventData extends BaseEventData<undefined> {
4042
- event: EVENT.ON_CHECKOUT_CLOSE;
4043
- }
4044
-
4045
- interface OnPaymentInReviewEventData extends Omit<OnPaymentSuccessfulEventData, 'event'> {
4046
- event: EVENT.PAYMENT_IN_REVIEW;
4047
- }
4048
-
4049
- interface OnPaymentErrorEventData extends BaseEventData<{
4050
- message?: string;
4051
- code?: string;
4052
- }> {
4053
- event: EVENT.PAYMENT_ERROR;
4054
- }
4055
-
4056
- interface Contact {
4057
- first_name?: string;
4058
- last_name?: string;
4059
- email?: string;
4060
- phone?: string;
4061
- phone2?: string;
4062
- }
4063
- interface WalletCaptureRequest {
4064
- payment_method_id?: string;
4065
- customer: {
4066
- email?: string;
4067
- phone?: string;
4068
- first_name?: string;
4069
- last_name?: string;
4070
- payment_source?: {
4071
- wallet_type?: string;
4072
- address_line1?: string;
4073
- address_line2?: string;
4074
- address_country?: string;
4075
- address_city?: string;
4076
- address_postcode?: string;
4077
- address_state?: string;
4078
- ref_token?: string;
4079
- external_payer_id?: string;
4080
- wallet_express?: boolean;
4081
- };
4082
- };
4083
- shipping?: {
4084
- address_line1?: string;
4085
- address_line2?: string;
4086
- address_line3?: string;
4087
- address_country?: string;
4088
- address_city?: string;
4089
- address_postcode?: string;
4090
- address_state?: string;
4091
- options?: IShippingOption[];
4092
- method?: string;
4093
- contact?: Contact;
4094
- };
4095
- }
4096
-
4097
- interface OnUnavailableEventData extends BaseEventData<undefined> {
4098
- event: EVENT.UNAVAILABLE;
4099
- }
4100
-
4101
4552
  interface BaseGatewayConfig<T> {
4102
4553
  type: string;
4103
4554
  mode: string;
4104
4555
  credentials?: T;
4105
4556
  }
4106
4557
 
4558
+ interface BaseWalletMeta {
4559
+ amount: number;
4560
+ currency: string;
4561
+ }
4562
+
4107
4563
  interface ChargeWalletTokenMeta {
4108
4564
  charge: {
4109
4565
  id: string;
@@ -4149,16 +4605,51 @@ interface ChargeWalletTokenMeta {
4149
4605
  };
4150
4606
  }
4151
4607
 
4152
- interface BaseWalletMeta {
4608
+ declare enum EVENT {
4609
+ UNAVAILABLE = "unavailable",
4610
+ ERROR = "error",
4611
+ PAYMENT_SUCCESSFUL = "paymentSuccessful",
4612
+ PAYMENT_ERROR = "paymentError",
4613
+ PAYMENT_IN_REVIEW = "paymentInReview",
4614
+ ON_CLICK = "onClick",
4615
+ ON_CHECKOUT_CLOSE = "onCheckoutClose",
4616
+ ON_SHIPPING_ADDRESS_CHANGE = "onShippingAddressChange",
4617
+ ON_SHIPPING_OPTIONS_CHANGE = "onShippingOptionsChange"
4618
+ }
4619
+
4620
+ interface OnClickEventData extends BaseEventData$1<undefined> {
4621
+ event: EVENT.ON_CLICK;
4622
+ }
4623
+
4624
+ interface OnCloseEventData extends BaseEventData$1<undefined> {
4625
+ event: EVENT.ON_CHECKOUT_CLOSE;
4626
+ }
4627
+
4628
+ interface OnErrorEventData extends BaseEventData$1<Error> {
4629
+ event: EVENT.ERROR;
4630
+ }
4631
+
4632
+ interface OnPaymentErrorEventData extends BaseEventData$1<{
4633
+ message?: string;
4634
+ code?: string;
4635
+ }> {
4636
+ event: EVENT.PAYMENT_ERROR;
4637
+ }
4638
+
4639
+ interface OnPaymentSuccessfulEventData extends BaseEventData$1<{
4640
+ id: string;
4153
4641
  amount: number;
4154
4642
  currency: string;
4643
+ status: string;
4644
+ }> {
4645
+ event: EVENT.PAYMENT_SUCCESSFUL;
4155
4646
  }
4156
4647
 
4157
- interface OnErrorEventData extends BaseEventData<Error> {
4158
- event: EVENT.ERROR;
4648
+ interface OnPaymentInReviewEventData extends Omit<OnPaymentSuccessfulEventData, 'event'> {
4649
+ event: EVENT.PAYMENT_IN_REVIEW;
4159
4650
  }
4160
4651
 
4161
- interface OnShippingAddressChangeEventData extends BaseEventData<AddressChangeEventData> {
4652
+ interface OnShippingAddressChangeEventData extends BaseEventData$1<AddressChangeEventData> {
4162
4653
  event: EVENT.ON_SHIPPING_ADDRESS_CHANGE;
4163
4654
  }
4164
4655
  interface AddressChangeEventData {
@@ -4176,16 +4667,6 @@ interface AddressChangeEventData {
4176
4667
  };
4177
4668
  }
4178
4669
 
4179
- interface OnShippingOptionChangeEventData extends BaseEventData<ShippingOptionChangeEventData> {
4180
- event: EVENT.ON_SHIPPING_OPTIONS_CHANGE;
4181
- }
4182
- interface ShippingOptionChangeEventData {
4183
- shipping_option_id?: string;
4184
- amount?: string;
4185
- label?: string;
4186
- detail?: string;
4187
- }
4188
-
4189
4670
  interface OnShippingAddressChangeEventResponse {
4190
4671
  token?: string;
4191
4672
  error?: {
@@ -4195,6 +4676,16 @@ interface OnShippingAddressChangeEventResponse {
4195
4676
  };
4196
4677
  }
4197
4678
 
4679
+ interface OnShippingOptionChangeEventData extends BaseEventData$1<ShippingOptionChangeEventData> {
4680
+ event: EVENT.ON_SHIPPING_OPTIONS_CHANGE;
4681
+ }
4682
+ interface ShippingOptionChangeEventData {
4683
+ shipping_option_id?: string;
4684
+ amount?: string;
4685
+ label?: string;
4686
+ detail?: string;
4687
+ }
4688
+
4198
4689
  interface OnShippingOptionChangeEventResponse {
4199
4690
  token?: string;
4200
4691
  label?: string;
@@ -4204,6 +4695,51 @@ interface OnShippingOptionChangeEventResponse {
4204
4695
  };
4205
4696
  }
4206
4697
 
4698
+ interface OnUnavailableEventData extends BaseEventData$1<undefined> {
4699
+ event: EVENT.UNAVAILABLE;
4700
+ }
4701
+
4702
+ interface Contact {
4703
+ first_name?: string;
4704
+ last_name?: string;
4705
+ email?: string;
4706
+ phone?: string;
4707
+ phone2?: string;
4708
+ }
4709
+ interface WalletCaptureRequest {
4710
+ payment_method_id?: string;
4711
+ customer: {
4712
+ email?: string;
4713
+ phone?: string;
4714
+ first_name?: string;
4715
+ last_name?: string;
4716
+ payment_source?: {
4717
+ wallet_type?: string;
4718
+ address_line1?: string;
4719
+ address_line2?: string;
4720
+ address_country?: string;
4721
+ address_city?: string;
4722
+ address_postcode?: string;
4723
+ address_state?: string;
4724
+ ref_token?: string;
4725
+ external_payer_id?: string;
4726
+ wallet_express?: boolean;
4727
+ };
4728
+ };
4729
+ shipping?: {
4730
+ address_line1?: string;
4731
+ address_line2?: string;
4732
+ address_line3?: string;
4733
+ address_country?: string;
4734
+ address_city?: string;
4735
+ address_postcode?: string;
4736
+ address_state?: string;
4737
+ options?: IShippingOption[];
4738
+ method?: string;
4739
+ contact?: Contact;
4740
+ };
4741
+ }
4742
+
4207
4743
  type ShippingEventToResponse<T> = T extends OnShippingAddressChangeEventData ? OnShippingAddressChangeEventResponse : T extends OnShippingOptionChangeEventData ? OnShippingOptionChangeEventResponse : never;
4208
4744
 
4209
4745
  declare abstract class BaseWalletButton<T extends BaseWalletMeta> {
@@ -4787,217 +5323,6 @@ declare class PaypalWalletButtonExpress extends BaseWalletButton<PaypalWalletMet
4787
5323
  private handleShippingOptionsUpdate;
4788
5324
  }
4789
5325
 
4790
- declare enum ErrorCodes$1 {
4791
- PROMISE_NOT_ENABLED = "promise_not_enabled",
4792
- SCRIPT_ERROR = "script_error"
4793
- }
4794
- interface PayPalDataCollectorConfig {
4795
- mouse_movement?: boolean;
4796
- }
4797
- interface IPayPalDataCollector {
4798
- collectDeviceData(): Promise<CollectedDeviceData>;
4799
- setEnv(env: string): void;
4800
- }
4801
- interface CollectedDeviceData {
4802
- correlation_id: string;
4803
- }
4804
- interface IOnErrorEventData$1 {
4805
- error_code: ErrorCodes$1;
4806
- }
4807
-
4808
- /**
4809
- * PayPal Data Collector Widget constructor
4810
- *
4811
- * @param {string} [flowId] - This string identifies the source website of the FraudNet request.
4812
- * @param {PayPalDataCollectorConfig} [config] - Extra configuration for the widget.
4813
- *
4814
- * @example
4815
- * var payPalDataCollector = new PayPalDataCollector('FLOW_ID', {});
4816
- */
4817
- declare class PayPalDataCollector {
4818
- protected service: IPayPalDataCollector;
4819
- protected eventEmitter: EventEmitter;
4820
- /** @constructs */ constructor(flowId?: string, config?: PayPalDataCollectorConfig);
4821
- /**
4822
- * After configuring the PayPalDataCollector Widget, starts the process and returns
4823
- * the correlation id used among the requests asynchronously.
4824
- *
4825
- * @returns {Promise<CollectedDeviceData>} Promise when resolved, returns an object
4826
- * that contains the `correlation_id` key.
4827
- *
4828
- * @example
4829
- * const collectedDeviceData = await payPalDataCollectorWidget.collectDeviceData();
4830
- * console.log(collectedDeviceData.correlation_id)
4831
- */
4832
- collectDeviceData(): Promise<CollectedDeviceData>;
4833
- /**
4834
- * Callback for onError method.
4835
- *
4836
- * @callback OnErrorCallback
4837
- * @param {IOnErrorEventData|null} data
4838
- */
4839
- /**
4840
- * If the process fails, the function passed as parameter will be called.
4841
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
4842
- *
4843
- * @example
4844
- * PayPalDataCollector.onError((eventData) => console.log('Some error occur'));
4845
- *
4846
- * @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow.
4847
- */
4848
- onError(callback?: (data?: IOnErrorEventData$1) => void): () => void;
4849
- /**
4850
- * Current method can change environment. By default environment = test.
4851
- * This method does not affect Paydock's API calls or environments, is only for PayPal Data Collector
4852
- * script, in order to know if the script is injected on a live server or is a testing
4853
- * environment. The available values are `test` and `live`. This should match with the used
4854
- * `gateway.mode` in Paydock to process the transaction.
4855
- *
4856
- * @example
4857
- * PayPalDataCollector.setEnv('live');
4858
- * @param {string} env - test, live
4859
- */
4860
- setEnv(env: string): void;
4861
- }
4862
-
4863
- interface PayPalStyleConfig {
4864
- layout?: 'vertical' | 'horizontal';
4865
- color?: 'blue' | 'gold' | 'silver' | 'black' | 'white';
4866
- shape?: 'rect' | 'sharp' | 'pill';
4867
- label?: 'paypal' | 'checkout' | 'buynow' | 'pay';
4868
- disableMaxWidth?: boolean;
4869
- disableMaxHeight?: boolean;
4870
- height?: number;
4871
- borderRadius?: number;
4872
- tagline?: boolean;
4873
- }
4874
- interface PayPalMessageConfig {
4875
- amount?: number;
4876
- align?: 'center' | 'left' | 'right';
4877
- color?: 'black' | 'white';
4878
- position?: 'top' | 'bottom';
4879
- }
4880
- interface PayPalSavePaymentSourceWidgetConfig {
4881
- style?: PayPalStyleConfig;
4882
- message?: PayPalMessageConfig;
4883
- }
4884
- interface IPayPalSavePaymentSourceWidget {
4885
- load(container: Container): void;
4886
- setEnv(env: string, alias?: string): void;
4887
- }
4888
- declare enum ErrorCodes {
4889
- UNAVAILABLE = "unavailable",
4890
- ON_PAYPAL_VAULT_SETUP_TOKEN_ERROR = "onPaypalVaultSetupTokenError",
4891
- ON_GET_ID_TOKEN_ERROR = "onGetIdTokenError",
4892
- ON_GET_WALLET_CONFIG_ERROR = "onGetWalletConfigError",
4893
- ON_GET_SETUP_TOKEN_ERROR = "onGetSetupTokenError",
4894
- ON_ONE_TIME_TOKEN_ERROR = "onOneTimeTokenError"
4895
- }
4896
- declare enum EVENTS {
4897
- ON_SUCCESS = "ON_SUCCESS",
4898
- ON_ERROR = "ON_ERROR",
4899
- ON_CANCEL = "ON_CANCEL"
4900
- }
4901
- interface IOnSuccessEventData {
4902
- event: EVENTS.ON_SUCCESS;
4903
- data: {
4904
- token: string;
4905
- email: string;
4906
- };
4907
- }
4908
- interface IOnErrorEventData {
4909
- event: EVENTS.ON_ERROR;
4910
- data: {
4911
- error_code: ErrorCodes;
4912
- details?: string;
4913
- message?: string;
4914
- };
4915
- }
4916
- interface IOnCancelEventData {
4917
- event: EVENTS.ON_CANCEL;
4918
- }
4919
-
4920
- /**
4921
- * PayPal Save Payment Source Widget constructor
4922
- *
4923
- * @param {string} selector - Selector of html element. Container for PayPal Save Payment Source Widget.
4924
- * @param {string} publicKey - PayDock users public key.
4925
- * @param {string} gatewayId - PayDock's PayPal gatewayId.
4926
- * @param {PayPalSavePaymentSourceWidgetConfig} config - Extra configuration for the widget, like styles.
4927
- *
4928
- * @example
4929
- * var payPalSavePaymentSourceWidget = new PayPalSavePaymentSourceWidget('#paypalButton', 'public_key', 'gateway_id');
4930
- */
4931
- declare class PayPalSavePaymentSourceWidget {
4932
- protected container: Container;
4933
- protected service: IPayPalSavePaymentSourceWidget;
4934
- protected eventEmitter: EventEmitter;
4935
- /** @constructs */ constructor(selector: string, publicKey: string, gatewayId: string, config?: PayPalSavePaymentSourceWidgetConfig);
4936
- /**
4937
- * The final method after configuring the PayPalSavePaymentSource Widget to
4938
- * start the load process.
4939
- */
4940
- load(): void;
4941
- /**
4942
- * Current method can change environment. By default environment = sandbox.
4943
- * Also we can change domain alias for this environment. By default domain_alias = paydock.com
4944
- *
4945
- * @example
4946
- * payPalSavePaymentSourceWidget.setEnv('production');
4947
- * @param {string} env - sandbox, production
4948
- * @param {string} [alias] - Own domain alias
4949
- */
4950
- setEnv(env: string, alias?: string): void;
4951
- /**
4952
- * Callback for onSuccess method.
4953
- *
4954
- * @callback OnSuccessCallback
4955
- * @param {IOnSuccessEventData} data
4956
- */
4957
- /**
4958
- * If the setup token was successfully approved and a OTT was generated, the function passed as parameter will be called.
4959
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
4960
- *
4961
- * @example
4962
- * payPalSavePaymentSourceWidget.onSuccess((eventData) => console.log('One time token and email obtained successfully'));
4963
- *
4964
- * @param {OnSuccessCallback} [callback] - Function to be called when the result is successful.
4965
- */
4966
- onSuccess(callback?: (data: IOnSuccessEventData) => void): () => void;
4967
- /**
4968
- * Callback for onError method.
4969
- *
4970
- * @callback OnErrorCallback
4971
- * @param {IOnErrorEventData} data
4972
- */
4973
- /**
4974
- * If in the process for obtaining the setup token fails, the function passed as parameter will be called.
4975
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
4976
- *
4977
- * @example
4978
- * payPalSavePaymentSourceWidget.onError((eventData) => console.log('Some error occurred'));
4979
- *
4980
- * @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow.
4981
- */
4982
- onError(callback?: (data: IOnErrorEventData) => void): () => void;
4983
- /**
4984
- * Callback for onCancel method.
4985
- *
4986
- * @callback OnCancelCallback
4987
- * @param {IOnCancelEventData} data
4988
- */
4989
- /**
4990
- * If in the process for obtaining the setup token was cancelled, the function passed as parameter will be called.
4991
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
4992
- *
4993
- * @example
4994
- * payPalSavePaymentSourceWidget.onCancel(() => console.log('Operation cancelled'));
4995
- *
4996
- * @param {OnCancelCallback} [callback] - Function to be called when the operation is cancelled.
4997
- */
4998
- onCancel(callback?: (data?: IOnCancelEventData) => void): () => void;
4999
- }
5000
-
5001
5326
  declare global {
5002
5327
  interface Window {
5003
5328
  paydock: {
@@ -5017,8 +5342,9 @@ declare global {
5017
5342
  HtmlWidget: typeof HtmlWidget;
5018
5343
  PayPalDataCollector: typeof PayPalDataCollector;
5019
5344
  PayPalSavePaymentSource: typeof PayPalSavePaymentSourceWidget;
5345
+ AfterpayOnSiteMessaging: typeof AfterpayOnSiteMessaging;
5020
5346
  };
5021
5347
  }
5022
5348
  }
5023
5349
 
5024
- export { AfterpayCheckoutButton, Api, type ApplePayServiceConfig, ApplePayWalletButtonExpress, BaseOpenWallet, type BaseServiceConfig, type BaseWalletMeta$1 as BaseWalletMeta, CHECKOUT_BUTTON_EVENT, Canvas3ds, Checkout, CheckoutActionCode, type CheckoutResponse, ClickToPay, Configuration, type CreateOTTRequest, type CreateOTTResponse, ELEMENT, EVENT$2 as EVENT, Builder$1 as ExternalCheckoutBuilder, Checker as ExternalCheckoutChecker, FORM_FIELD, FRAUD_PREVENTION_EVENTS, type FraudPreventionEvent, type FraudPreventionEventType, type FraudPreventionProvider, FraudPreventionService, type GooglePayServiceConfig, HtmlMultiWidget, HtmlPaymentSourceWidget, HtmlWidget, type ICheckout, type IClickToPayMeta, type IDetails, type IElementStyleInput, type IEventCheckoutFinishData, type IEventData, type IPayPalMeta, type IStyles$1 as IStyles, type ITexts, type IWalletMeta, type IWalletOnClickEvent, type IWalletPaymentSuccessfulEvent, type IWalletUnavailableEvent, type IWalletUpdateData, type IWalletUpdateEvent, InstructionDebugger, MultiWidget, type OTTResponse, type OnClickEventData$1 as OnClickEventData, type OnCrateOTTSuccessfulEventData, type OnCreateOTTErrorEventData, type OnErrorEventData$1 as OnErrorEventData, type OnUnavailableEventData$1 as OnUnavailableEventData, type OpenWalletEventType, PAYMENT_TYPE, PURPOSE, PayPalDataCollector, PayPalSavePaymentSourceWidget, Builder as PaymentSourceBuilder, PaymentSourceWidget, PaypalCheckoutButton, PaypalWalletButtonExpress, STYLABLE_ELEMENT, STYLABLE_ELEMENT_STATE, STYLE, SUPPORTED_CARD_TYPES, TEXT, TRIGGER, TYPE, VAULT_DISPLAY_STYLE, type VaultDisplayStyle, VaultDisplayWidget, WALLET_TYPES, WalletButtons, type WalletPaymentSource, type WalletType, ZipmoneyCheckoutButton };
5350
+ export { AfterpayCheckoutButton, AfterpayOnSiteMessaging, Api, ApplePayWalletButtonExpress, CHECKOUT_BUTTON_EVENT, Canvas3ds, Checkout, CheckoutActionCode, type CheckoutResponse, ClickToPay, Configuration, type CreateOTTData, type CreateOTTRequest, type CreateOTTResponse, type CreateSessionRequest, type CreateSessionResponse, ELEMENT, EVENT$2 as EVENT, Builder$1 as ExternalCheckoutBuilder, Checker as ExternalCheckoutChecker, FORM_FIELD, FRAUD_PREVENTION_EVENTS, type FraudPreventionEvent, type FraudPreventionEventType, type FraudPreventionProvider, FraudPreventionService, HtmlMultiWidget, HtmlPaymentSourceWidget, HtmlWidget, type ICheckout, type IClickToPayMeta, type IDetails, type IElementStyleInput, type IEventCheckoutFinishData, type IEventData, type IPayPalMeta, type IStyles$1 as IStyles, type ITexts, type IWalletMeta, type IWalletOnClickEvent, type IWalletPaymentSuccessfulEvent, type IWalletUnavailableEvent, type IWalletUpdateData, type IWalletUpdateEvent, InstructionDebugger, MultiWidget, type OTTResponse, type OnClickEventData$1 as OnClickEventData, type OnCrateOTTSuccessfulEventData, type OnCreateOTTErrorEventData, type OnErrorEventData$1 as OnErrorEventData, type OnUnavailableEventData$1 as OnUnavailableEventData, OpenWalletButtons, type OpenWalletEventType, type OpenWalletMeta, PAYMENT_TYPE, PURPOSE, PayPalDataCollector, PayPalSavePaymentSourceWidget, Builder as PaymentSourceBuilder, PaymentSourceWidget, PaypalCheckoutButton, PaypalWalletButtonExpress, STYLABLE_ELEMENT, STYLABLE_ELEMENT_STATE, STYLE, SUPPORTED_CARD_TYPES, TEXT, TRIGGER, TYPE, VAULT_DISPLAY_STYLE, type VaultDisplayStyle, VaultDisplayWidget, WALLET_TYPES, WalletButtons, type WalletPaymentSource, type WalletType, ZipmoneyCheckoutButton };