@paydock/client-sdk 1.113.2 → 1.114.7-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 (107) hide show
  1. package/README.md +757 -80
  2. package/bundles/index.cjs +1344 -190
  3. package/bundles/index.cjs.d.ts +2355 -2058
  4. package/bundles/index.mjs +1340 -187
  5. package/bundles/index.mjs.d.ts +2355 -2058
  6. package/bundles/types/api/api-base.d.ts.map +1 -1
  7. package/bundles/types/api/api-charge-internal.d.ts +1 -0
  8. package/bundles/types/api/api-charge-internal.d.ts.map +1 -1
  9. package/bundles/types/api/api-checkout-internal.d.ts +1 -0
  10. package/bundles/types/api/api-checkout-internal.d.ts.map +1 -1
  11. package/bundles/types/checkout/helpers/resource-helper.d.ts +4 -3
  12. package/bundles/types/checkout/helpers/resource-helper.d.ts.map +1 -1
  13. package/bundles/types/checkout/helpers/session-helper.d.ts +3 -0
  14. package/bundles/types/checkout/helpers/session-helper.d.ts.map +1 -1
  15. package/bundles/types/checkout/instructions/v1/instruction.afterpay_checkout_form.show.d.ts.map +1 -1
  16. package/bundles/types/checkout/instructions/v1/instruction.card_form.show.d.ts.map +1 -1
  17. package/bundles/types/checkout/instructions/v1/instruction.generic.show_message.d.ts.map +1 -1
  18. package/bundles/types/checkout/instructions/v1/instruction.zip_checkout_form.show.d.ts.map +1 -1
  19. package/bundles/types/checkout/layout-widgets/additionals.d.ts +1 -1
  20. package/bundles/types/checkout/layout-widgets/additionals.d.ts.map +1 -1
  21. package/bundles/types/checkout/layout-widgets/payment-methods-template.d.ts.map +1 -1
  22. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts +1 -1
  23. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts.map +1 -1
  24. package/bundles/types/components/iframe-event.d.ts +34 -29
  25. package/bundles/types/components/iframe-event.d.ts.map +1 -1
  26. package/bundles/types/components/iframe.d.ts +2 -2
  27. package/bundles/types/components/iframe.d.ts.map +1 -1
  28. package/bundles/types/components/param.d.ts +3 -0
  29. package/bundles/types/components/param.d.ts.map +1 -1
  30. package/bundles/types/configs/env/environment.paydock.d.ts.map +1 -1
  31. package/bundles/types/helper/event-error.d.ts +55 -0
  32. package/bundles/types/helper/event-error.d.ts.map +1 -0
  33. package/bundles/types/helper/process-event-error.d.ts +9 -0
  34. package/bundles/types/helper/process-event-error.d.ts.map +1 -0
  35. package/bundles/types/index-cba.d.ts +5 -1
  36. package/bundles/types/index-cba.d.ts.map +1 -1
  37. package/bundles/types/index.d.ts +3 -1
  38. package/bundles/types/index.d.ts.map +1 -1
  39. package/bundles/types/paypal-data-collector/index.d.ts +23 -0
  40. package/bundles/types/paypal-data-collector/index.d.ts.map +1 -0
  41. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts +58 -0
  42. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts.map +1 -0
  43. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts +21 -0
  44. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts.map +1 -0
  45. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts +17 -0
  46. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts.map +1 -0
  47. package/bundles/types/paypal-save-payment-source/index.d.ts +61 -0
  48. package/bundles/types/paypal-save-payment-source/index.d.ts.map +1 -0
  49. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts +85 -0
  50. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts.map +1 -0
  51. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts +83 -0
  52. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts.map +1 -0
  53. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts +35 -0
  54. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts.map +1 -0
  55. package/bundles/types/secure-remote-commerce/index.d.ts +2 -1
  56. package/bundles/types/secure-remote-commerce/index.d.ts.map +1 -1
  57. package/bundles/types/secure-remote-commerce/interfaces.d.ts +2 -5
  58. package/bundles/types/secure-remote-commerce/interfaces.d.ts.map +1 -1
  59. package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts.map +1 -1
  60. package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts +12 -0
  61. package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts.map +1 -0
  62. package/bundles/types/shared/services/configuration-validation/types.d.ts +73 -0
  63. package/bundles/types/shared/services/configuration-validation/types.d.ts.map +1 -0
  64. package/bundles/types/wallet-buttons/enums.d.ts +12 -0
  65. package/bundles/types/wallet-buttons/enums.d.ts.map +1 -0
  66. package/bundles/types/wallet-buttons/index.d.ts +5 -1
  67. package/bundles/types/wallet-buttons/index.d.ts.map +1 -1
  68. package/bundles/types/wallet-buttons/wallet-buttons.d.ts +28 -15
  69. package/bundles/types/wallet-buttons/wallet-buttons.d.ts.map +1 -1
  70. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts +1 -1
  71. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts.map +1 -1
  72. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
  73. package/bundles/types/wallet-buttons-express/index.d.ts +1 -0
  74. package/bundles/types/wallet-buttons-express/index.d.ts.map +1 -1
  75. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts +1 -0
  76. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts.map +1 -1
  77. package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
  78. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts +1 -0
  79. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts.map +1 -1
  80. package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts.map +1 -1
  81. package/bundles/types/widget/configuration.d.ts +13 -9
  82. package/bundles/types/widget/configuration.d.ts.map +1 -1
  83. package/bundles/types/widget/html-multi-widget.d.ts +1 -2
  84. package/bundles/types/widget/html-multi-widget.d.ts.map +1 -1
  85. package/bundles/types/widget/html-widget.d.ts +2 -1
  86. package/bundles/types/widget/html-widget.d.ts.map +1 -1
  87. package/bundles/types/widget/multi-widget.d.ts +14 -2
  88. package/bundles/types/widget/multi-widget.d.ts.map +1 -1
  89. package/bundles/widget.umd.js +1344 -190
  90. package/bundles/widget.umd.js.d.ts +2355 -2058
  91. package/bundles/widget.umd.js.min.d.ts +2355 -2058
  92. package/bundles/widget.umd.min.js +1 -61
  93. package/docs/api-widget.md +59 -16
  94. package/docs/click-to-pay-examples.md +0 -36
  95. package/docs/click-to-pay.md +1 -3
  96. package/docs/paypal-data-collector-examples.md +59 -0
  97. package/docs/paypal-data-collector.md +149 -0
  98. package/docs/paypal-save-payment-source-examples.md +63 -0
  99. package/docs/paypal-save-payment-source.md +256 -0
  100. package/docs/wallet-buttons-examples.md +1 -1
  101. package/docs/wallet-buttons-express-examples.md +1 -1
  102. package/docs/wallet-buttons-express.md +1 -0
  103. package/docs/wallet-buttons.md +3 -0
  104. package/docs/widget-examples.md +162 -25
  105. package/examples/multi-html-widget/extend.html +5 -0
  106. package/package.json +2 -2
  107. package/slate.md +161 -60
@@ -58,6 +58,7 @@ declare class Env implements IEnvironment {
58
58
  }
59
59
 
60
60
  type HttpRequestMethod = 'DELETE' | 'GET' | 'OPTIONS' | 'POST' | 'PUT';
61
+ type HttpRequestUrl = string | URL;
61
62
 
62
63
  type AgentPrototype = Pick<(typeof MicroAgent)['prototype'], 'addPageAction' | 'noticeError'>;
63
64
  type AgentMethodNames = keyof AgentPrototype;
@@ -449,6 +450,8 @@ interface IParams extends IStyles$1, ITexts, ICommonParams {
449
450
  phone_mask_only_countries?: string;
450
451
  language?: string;
451
452
  vault_display_token?: string;
453
+ sdk_origin?: boolean;
454
+ hide_ui_errors?: boolean;
452
455
  }
453
456
  interface ICountryPhoneMask {
454
457
  preferred_countries?: string[];
@@ -612,6 +615,7 @@ interface IWalletMeta {
612
615
  amount_label?: string;
613
616
  country?: string;
614
617
  pay_later?: boolean;
618
+ hide_message?: boolean;
615
619
  standalone?: boolean;
616
620
  show_billing_address?: boolean;
617
621
  request_payer_name?: boolean;
@@ -661,10 +665,10 @@ declare class IFrame {
661
665
  constructor(container: Container);
662
666
  load(link: string, options?: {
663
667
  title?: string;
664
- }): void;
668
+ }, iframeClass?: string): void;
665
669
  loadFromHtml(content: string, options?: {
666
670
  title?: string;
667
- }): void;
671
+ }, iframeClass?: string): void;
668
672
  remove(): void;
669
673
  show(): void;
670
674
  hide(saveSize?: boolean): void;
@@ -675,73 +679,6 @@ declare class IFrame {
675
679
  private setStyles;
676
680
  }
677
681
 
678
- /**
679
- * Contains basic information associated with the event.
680
- *
681
- * Including event (name), source of the message, purpose and a unique identifier
682
- * for the event.
683
- *
684
- * @interface IEventData
685
- *
686
- * @param {string} event The name of the event.
687
- * @param {string} message_source A system variable that identifies the event source.
688
- * @param {string} purpose A system variable that states the purpose of the event.
689
- * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
690
- */
691
- interface IEventData$1 {
692
- event: string;
693
- message_source: string;
694
- purpose: string;
695
- widget_id: string;
696
- data?: any;
697
- ref_id?: string;
698
- }
699
- declare const EVENT$1: {
700
- AFTER_LOAD: string;
701
- SUBMIT: string;
702
- FINISH: string;
703
- VALIDATION_ERROR: string;
704
- SYSTEM_ERROR: string;
705
- /** @deprecated */
706
- CHECKOUT_SUCCESS: string;
707
- CHECKOUT_READY: string;
708
- CHECKOUT_ERROR: string;
709
- CHECKOUT_COMPLETED: string;
710
- CHECKOUT_POPUP_OPEN: string;
711
- CHECKOUT_POPUP_CLOSE: string;
712
- RECOGNITION_TOKEN_REQUESTED: string;
713
- RECOGNITION_TOKEN_DROPPED: string;
714
- VALIDATION: string;
715
- SELECT: string;
716
- UNSELECT: string;
717
- NEXT: string;
718
- PREV: string;
719
- META_CHANGE: string;
720
- RESIZE: string;
721
- CHARGE_AUTH_SUCCESS: string;
722
- CHARGE_AUTH_REJECT: string;
723
- CHARGE_AUTH_CANCELLED: string;
724
- ADDITIONAL_DATA_SUCCESS: string;
725
- ADDITIONAL_DATA_REJECT: string;
726
- CHARGE_AUTH: string;
727
- DISPATCH_SUCCESS: string;
728
- DISPATCH_ERROR: string;
729
- };
730
- interface Listener {
731
- event: string;
732
- listener: (event: any) => void;
733
- widget_id: string;
734
- }
735
- declare type Listeners = Listener[];
736
- declare class IFrameEvent {
737
- protected listeners: Listeners;
738
- constructor(subject: Window | null);
739
- emit(data: IEventData$1): void;
740
- on<T>(eventName: string, widgetId: string, cb: (data: T) => void): void;
741
- clear(): void;
742
- private subscribe;
743
- }
744
-
745
682
  /**
746
683
  * List of available payment source types
747
684
  *
@@ -755,6 +692,7 @@ declare const PAYMENT_TYPE: {
755
692
  GIFT_CARD: string;
756
693
  BANK_ACCOUNT: string;
757
694
  CHECKOUT: string;
695
+ BSB: string;
758
696
  };
759
697
  /**
760
698
  * Purposes
@@ -763,13 +701,13 @@ declare const PAYMENT_TYPE: {
763
701
  * @param {string} CARD_PAYMENT_SOURCE_WITH_CVV=card_payment_source_with_cvv
764
702
  * @param {string} CARD_PAYMENT_SOURCE_WITHOUT_CVV=card_payment_source_without_cvv
765
703
  * */
766
- declare const PURPOSE: {
767
- PAYMENT_SOURCE: string;
768
- CARD_PAYMENT_SOURCE_WITH_CVV: string;
769
- CARD_PAYMENT_SOURCE_WITHOUT_CVV: string;
770
- };
704
+ declare enum PURPOSE {
705
+ PAYMENT_SOURCE = "payment_source",
706
+ CARD_PAYMENT_SOURCE_WITH_CVV = "card_payment_source_with_cvv",
707
+ CARD_PAYMENT_SOURCE_WITHOUT_CVV = "card_payment_source_without_cvv"
708
+ }
771
709
  interface IGeneral {
772
- purpose: string;
710
+ purpose: PURPOSE;
773
711
  predefined_fields: IPredefinedFields;
774
712
  defined_form_fields?: string[];
775
713
  webhook_destination?: string;
@@ -803,9 +741,9 @@ interface IPredefinedFields {
803
741
  declare class Configuration {
804
742
  private configs;
805
743
  private env;
806
- static createEachToken(accessToken: string, configs: Configuration[], cb: (tokens: string[]) => void, errorCb?: (errors: string[]) => void): void;
807
- private static finishCreatingEachToken;
808
- /** @constructs */ constructor(gatewayID?: string, paymentType?: string, purpose?: string);
744
+ static createEachToken(accessToken: string, configs: Configuration[]): Promise<string[]>;
745
+ private static addTokenInBase64;
746
+ /** @constructs */ constructor(gatewayID?: string, paymentType?: string, purpose?: PURPOSE);
809
747
  /**
810
748
  * Destination, where customer will receive all successful responses.
811
749
  * Response will contain “data” object with “payment_source” or other parameters, in depending on 'purpose'
@@ -895,1786 +833,1480 @@ declare class Configuration {
895
833
  * @param {createToken~requestCallback} errorCb - The callback that handles the failed response.
896
834
  */
897
835
  createToken(accessToken: string, cb: (token: string) => void, errorCb?: (error: any) => void): void;
836
+ getDefaultGateway<T>(accessToken: string, method: HttpRequestMethod, url: HttpRequestUrl): Promise<T>;
898
837
  private send;
899
838
  getConfigs(): IGeneral;
900
839
  private getUrl;
840
+ private getDefaultGatewayUrl;
901
841
  setGiftCardSchemeData(giftCardScheme: any, processingNetwork: any): void;
902
842
  }
903
843
 
904
- declare class EventEmitter {
905
- private events;
906
- emit<T>(eventName: string, data?: T): void;
907
- emitWithResult<T, R>(eventName: string, data?: T): Promise<R[]>;
908
- subscribe<T>(eventName: string, handler: (data: T) => void): () => void;
909
- }
910
-
911
- declare class Standalone3dsService {
912
- protected container: Container;
913
- protected eventEmitter: EventEmitter;
914
- protected env: string;
915
- protected alias: string;
916
- constructor(container: Container, eventEmitter: any);
917
- load(token: string, options: {
918
- title: string;
919
- }): void;
920
- setEnv(env: string, alias?: string): void;
921
- }
922
-
923
844
  /**
924
- * List of available token's content formats
925
- * @enum TOKEN_FORMAT
926
- *
845
+ * Current constant include available type of element for styling
846
+ * @const STYLABLE_ELEMENT
927
847
  * @type {object}
928
- * @param {string} HTML=html
929
- */
930
- declare enum TOKEN_FORMAT {
931
- HTML = "html",
932
- URL = "url",
933
- STANDALONE_3DS = "standalone_3ds"
934
- }
848
+ * @param {string} INPUT=input.
849
+ * These states are available: [STYLABLE_ELEMENT_STATE.ERROR]{@link STYLABLE_ELEMENT_STATE}, [STYLABLE_ELEMENT_STATE.FOCUS]{@link STYLABLE_ELEMENT_STATE}.
850
+ * These styles are available [IElementStyleInput]{@link IElementStyleInput}
851
+ * @param {string} SUBMIT_BUTTON=submit_button
852
+ * These states are available: [STYLABLE_ELEMENT_STATE.HOVER]{@link STYLABLE_ELEMENT_STATE}.
853
+ * These styles are available [IElementStyleSubmitButton]{@link IElementStyleSubmitButton}
854
+ * @param {string} LABEL=label.
855
+ * These styles are available [IElementStyleLabel]{@link IElementStyleLabel}
856
+ * @param {string} TITLE=title.
857
+ * These styles are available [IElementStyleTitle]{@link IElementStyleTitle}
858
+ * @param {string} TITLE_DESCRIPTION=title_description.
859
+ * These styles are available [IElementStyleTitleDescription]{@link IElementStyleTitleDescription}
860
+ * */
861
+ declare const STYLABLE_ELEMENT: {
862
+ INPUT: string;
863
+ SUBMIT_BUTTON: string;
864
+ LABEL: string;
865
+ TITLE: string;
866
+ TITLE_DESCRIPTION: string;
867
+ };
935
868
  /**
936
- * List of available event's name
937
- * @const EVENT
938
- *
869
+ * Current constant include available states of element for styling
870
+ * @const STYLABLE_ELEMENT_STATE
939
871
  * @type {object}
940
- * @param {string} CHARGE_AUTH_SUCCESS=chargeAuthSuccess
941
- * @param {string} CHARGE_AUTH_REJECT=chargeAuthReject
942
- * @param {string} ADDITIONAL_DATA_SUCCESS=additionalDataCollectSuccess
943
- * @param {string} ADDITIONAL_DATA_REJECT=additionalDataCollectReject
944
- * @param {string} CHARGE_AUTH=chargeAuth
945
- */
872
+ * @param {string} ERROR=error client|server validation. This state applies to: input
873
+ * @param {string} FOCUS=focus focus. This state applies to: input
874
+ * @param {string} HOVER=hover focus. This state applies to: submit_button
875
+ * */
876
+ declare const STYLABLE_ELEMENT_STATE: {
877
+ ERROR: string;
878
+ FOCUS: string;
879
+ HOVER: string;
880
+ };
881
+ interface IElementStyleInput {
882
+ color?: string;
883
+ border?: string;
884
+ border_radius?: string;
885
+ background_color?: string;
886
+ height?: string;
887
+ text_decoration?: string;
888
+ font_size?: string;
889
+ font_family?: string;
890
+ padding?: string;
891
+ margin?: string;
892
+ transition?: string;
893
+ line_height?: string;
894
+ font_weight?: string;
895
+ }
896
+ interface IElementStyleSubmitButton {
897
+ color?: string;
898
+ border?: string;
899
+ border_radius?: string;
900
+ background_color?: string;
901
+ text_decoration?: string;
902
+ font_size?: string;
903
+ font_family?: string;
904
+ padding?: string;
905
+ margin?: string;
906
+ transition?: string;
907
+ line_height?: string;
908
+ font_weight?: string;
909
+ opacity?: string;
910
+ }
911
+ interface IElementStyleLabel {
912
+ color?: string;
913
+ text_decoration?: string;
914
+ font_size?: string;
915
+ font_family?: string;
916
+ line_height?: string;
917
+ font_weight?: string;
918
+ padding?: string;
919
+ margin?: string;
920
+ }
921
+ interface IElementStyleTitle {
922
+ color?: string;
923
+ text_decoration?: string;
924
+ font_size?: string;
925
+ font_family?: string;
926
+ line_height?: string;
927
+ font_weight?: string;
928
+ padding?: string;
929
+ margin?: string;
930
+ }
931
+ interface IElementStyleTitleDescription {
932
+ color?: string;
933
+ text_decoration?: string;
934
+ font_size?: string;
935
+ font_family?: string;
936
+ line_height?: string;
937
+ font_weight?: string;
938
+ padding?: string;
939
+ margin?: string;
940
+ }
941
+
942
+ declare const ERROR_CATEGORY: {
943
+ readonly CONFIGURATION: "configuration";
944
+ readonly IDENTITY: "identity_access_management";
945
+ readonly INTERNAL: "internal";
946
+ readonly PROCESS: "process";
947
+ readonly RESOURCE: "resource";
948
+ readonly VALIDATION: "validation";
949
+ };
950
+ type ErrorCategory = (typeof ERROR_CATEGORY)[keyof typeof ERROR_CATEGORY];
951
+ declare const ERROR_CAUSE: {
952
+ readonly ABORTED: "aborted";
953
+ readonly ACCESS_FORBIDDEN: "access_forbidden";
954
+ readonly ALREADY_EXISTS: "already_exists";
955
+ readonly CANCELED: "canceled";
956
+ readonly INVALID_CONFIGURATION: "invalid_configuration";
957
+ readonly INVALID_INPUT: "invalid_input";
958
+ readonly NOT_FOUND: "not_found";
959
+ readonly NOT_IMPLEMENTED: "not_implemented";
960
+ readonly RATE_LIMITED: "rate_limited";
961
+ readonly SERVER_BUSY: "server_busy";
962
+ readonly SERVICE_UNREACHABLE: "service_unreachable";
963
+ readonly UNAUTHORIZED: "unauthorized";
964
+ readonly UNKNOWN: "unknown_error";
965
+ readonly UNPROCESSABLE_ENTITY: "unprocessable_entity";
966
+ };
967
+ type ErrorCause = (typeof ERROR_CAUSE)[keyof typeof ERROR_CAUSE];
968
+ interface ErrorDetails {
969
+ cause: ErrorCause;
970
+ contextId: string;
971
+ message: string;
972
+ timestamp: string;
973
+ }
974
+ interface IEventError {
975
+ cause: ErrorCause;
976
+ category: ErrorCategory;
977
+ retryable: boolean;
978
+ details: ErrorDetails;
979
+ }
980
+
946
981
  /**
947
- * List of available event's name for Standalone 3ds flow
948
- * @const STANDALONE_3DS_EVENT
949
982
  *
950
- * @type {object}
951
- * @param {string} CHARGE_AUTH_SUCCESS=chargeAuthSuccess
952
- * @param {string} CHARGE_AUTH_REJECT=chargeAuthReject
953
- * @param {string} CHARGE_AUTH_DECOUPLED=chargeAuthDecoupled
954
- * @param {string} CHARGE_AUTH_CHALLENGE=chargeAuthChallenge
955
- * @param {string} CHARGE_AUTH_INFO=chargeAuthInfo
956
- * @param {string} ERROR=error
957
- */
958
- /**
959
- * Class Canvas3ds include method for working on html
983
+ * Class MultiWidget include method for for creating iframe url
960
984
  * @constructor
961
985
  *
962
- * @param {string} selector - Selector of html element. Container for widget
963
- * @param {string} token - Pre authorized token
986
+ * @param {string} accessToken - PayDock users access token or public key
987
+ * @param {(Configuration | string | Configuration[] | string[])} conf - exemplar[s] Configuration class OR configuration token
988
+ *
964
989
  * @example
965
- * var widget = new Canvas3ds('#widget', 'token');
990
+ * var widget = new MultiWidget('accessToken','configurationToken'); // With a pre-created configuration token
991
+ *
992
+ * var widget = new MultiWidget('accessToken',['configurationToken', 'configurationToken2']); // With pre-created configuration tokens
966
993
  *
994
+ * var widget = new MultiWidget('accessToken', new Configuration('gatewayId')); With Configuration
967
995
  *
996
+ * var widget = new MultiWidget('accessToken',[ With Configurations
997
+ * Configuration('gatewayId'),
998
+ * Configuration('gatewayId', 'bank_account')
999
+ * ]);
968
1000
  */
969
- declare class Canvas3ds {
1001
+ declare class MultiWidget {
970
1002
  protected link: Link;
971
1003
  protected configs: Configuration[];
972
- protected publicKey: string;
973
- protected token: {
974
- content: string;
975
- format: TOKEN_FORMAT;
976
- charge_3ds_id: string;
977
- };
978
- protected standalone3dsService: Standalone3dsService;
979
- protected container: Container;
980
- protected iFrame: IFrame;
1004
+ protected configTokens: string[];
1005
+ protected accessToken: string;
981
1006
  protected event: IFrameEvent;
982
- protected eventEmitter: EventEmitter;
983
- /** @constructs */ constructor(selector: string, token: string);
984
- protected static extractToken(token: string): {
985
- content: string;
986
- format: TOKEN_FORMAT;
987
- charge_3ds_id: string;
988
- };
1007
+ constructor(accessToken: string, confTokens: string[]);
1008
+ constructor(accessToken: string, confToken: string);
1009
+ constructor(accessToken: string, configs: Configuration[]);
1010
+ constructor(accessToken: string, conf: Configuration);
989
1011
  /**
990
- * The final method to beginning, the load process of widget to html
1012
+ * Object contain styles for widget
991
1013
  *
1014
+ * @example
1015
+ * widget.setStyles({
1016
+ * background_color: 'rgb(0, 0, 0)',
1017
+ * border_color: 'yellow',
1018
+ * text_color: '#FFFFAA',
1019
+ * button_color: 'rgba(255, 255, 255, 0.9)',
1020
+ * font_size: '20px'
1021
+ * fort_family: 'fantasy'
1022
+ * });
1023
+ * @param {IStyles} fields - name of styles which can be shown in widget [STYLE]{@link STYLE}
992
1024
  */
993
- load(): void;
1025
+ setStyles(styles: IStyles$1): void;
994
1026
  /**
995
- * Current method can change environment. By default environment = sandbox.
996
- * Also we can change domain alias for this environment. By default domain_alias = paydock.com
1027
+ * Method to set a country code mask for the phone input.
997
1028
  *
998
1029
  * @example
999
- * widget.setEnv('production');
1000
- * @param {string} env - sandbox, production
1001
- * @param {string} [alias] - Own domain alias
1002
- */
1003
- setEnv(env: string, alias?: string): void;
1004
- getEnv(): string;
1005
- on(eventName: string): Promise<IEventData$1>;
1006
- on(eventName: string, cb: (data: IEventData$1) => void): any;
1007
- /**
1008
- * Using this method you can hide widget after load
1009
- * @param {boolean} [saveSize=false] - using this param you can save iframe's size
1030
+ * widget.usePhoneCountryMask();
1031
+ *
1032
+ * @example
1033
+ * widget.usePhoneCountryMask({
1034
+ * default_country: 'au',
1035
+ * preferred_countries: ['au', 'gb'],
1036
+ * only_countries: ['au', 'gb', 'us', 'ua']
1037
+ * });
1038
+ *
1039
+ * @param {object} [options] - Options for configure the phone mask.
1040
+ * @param {string} [options.default_country] - Set a default country for the mask.
1041
+ * @param {Array.<string>} [options.preferred_countries] - Set list of preferred countries for the top of the select box .
1042
+ * @param {Array.<string>} [options.only_countries] - Set list of countries to show in the select box.
1010
1043
  */
1011
- hide(saveSize: boolean): void;
1044
+ usePhoneCountryMask(options?: ICountryPhoneMask): void;
1045
+ setStyle(param: string, value: string): void;
1012
1046
  /**
1013
- * Using this method you can show widget after using hide method
1047
+ * Method for set different texts inside the widget
1048
+ *
1049
+ * @example
1050
+ * widget.setTexts({
1051
+ * title: 'Your card',
1052
+ * finish_text: 'Payment resource was successfully accepted',
1053
+ * title_description: '* indicates required field',
1054
+ * submit_button: 'Save',
1055
+ * submit_button_processing: 'Load...',
1056
+ * });
1014
1057
  *
1058
+ * @param {ITexts} fields - name of text items which can be shown in widget [TEXT]{@link TEXT}
1015
1059
  */
1016
- show(): void;
1060
+ setTexts(texts: ITexts): void;
1061
+ setText(param: string, value: string): void;
1062
+ setElementStyle(element: string, state: string, styles: IElementStyleInput | IElementStyleSubmitButton | IElementStyleLabel): any;
1063
+ setElementStyle(element: string, styles: IElementStyleInput | IElementStyleSubmitButton | IElementStyleLabel | IElementStyleTitle | IElementStyleTitleDescription): any;
1017
1064
  /**
1018
- * Using this method you can reload widget
1065
+ * The method to set the predefined values for the form fields inside the widget
1066
+ *
1067
+ * @example
1068
+ * widget.setFormValues({
1069
+ * email: 'predefined@email.com',
1070
+ * card_name: 'Houston'
1071
+ * });
1072
+ *
1073
+ * @param { Object } fieldValues - Key of object is one of [FORM_FIELD]{@link FORM_FIELD}, The object value is what we are expecting
1074
+ */
1075
+ setFormValues(fieldValues: IFormValues): void;
1076
+ setFormValue(key: string, value: string): void;
1077
+ /**
1078
+ * The method to set custom form field labels
1079
+ *
1080
+ * @example
1081
+ * widget.setFormPlaceholders({
1082
+ * card_name: 'Card Holder Name',
1083
+ * email: 'Email For Receipt'
1084
+ * })
1019
1085
  *
1086
+ * @param { Object } fieldLabels - Key of object is one of [FORM_FIELD]{@link FORM_FIELD}, The object value is what we are expecting
1020
1087
  */
1021
- reload(): void;
1088
+ setFormLabels(fieldLabels: IFormLabels): void;
1089
+ setFormLabel(key: string, label: string): void;
1090
+ /**
1091
+ * The method to set custom form fields placeholders
1092
+ *
1093
+ * @example
1094
+ * widget.setFormPlaceholders({
1095
+ * card_name: 'Input your card holder name...',
1096
+ * email: 'Input your email, like test@example.com'
1097
+ * })
1098
+ *
1099
+ * @param { Object } fieldPlaceholders - Key of object is one of [FORM_FIELD]{@link FORM_FIELD}, Value of object is expected placeholder
1100
+ */
1101
+ setFormPlaceholders(fieldPlaceholders: IFormPlaceholders): void;
1102
+ setFormPlaceholder(key: string, placeholder: string): void;
1103
+ /**
1104
+ * The method to set the full configuration for the all specific form elements (label, placeholder, value)
1105
+ * You can also use the other method for the partial configuration like: setFormValues, setFormPlaceholder, setFormLabel
1106
+ *
1107
+ * @example
1108
+ * widget.setFormElements([
1109
+ * {
1110
+ * field: 'card_name',
1111
+ * placeholder: 'Input your card holder name...',
1112
+ * label: 'Card Holder Name',
1113
+ * value: 'Houston',
1114
+ * },
1115
+ * {
1116
+ * field: 'email',
1117
+ * placeholder: 'Input your email, like test@example.com',
1118
+ * label: 'Email For Receipt',
1119
+ * value: 'predefined@email.com',
1120
+ * },
1121
+ * ])
1122
+ *
1123
+ * @param { string } elements - The list of elements
1124
+ * @param { string } elements[].field - Field name of the element [FORM_FIELD]{@link FORM_FIELD}
1125
+ * @param { string } elements[].placeholder - Set custom form field placeholder
1126
+ * @param { string } elements[].label - Set custom labels near form field
1127
+ * @param { string } elements[].value - Set predefined values for the form field
1128
+ */
1129
+ setFormElements(elements: IFormElement[]): void;
1130
+ setFormElement(element: IFormElement): void;
1131
+ /**
1132
+ * The method to change the widget icons
1133
+ *
1134
+ * @deprecated
1135
+ */
1136
+ setIcons(icons: IIcons): void;
1137
+ setIcon(key: string, value: string): void;
1138
+ /**
1139
+ * Using this method you can set hidden elements inside widget
1140
+ *
1141
+ * @example
1142
+ * widget.setHiddenElements(['submit_button', 'email']);
1143
+ *
1144
+ * @param {string[]} elements - list of element which can be hidden [ELEMENT]{@link ELEMENT} || [FORM_FIELD]{@link FORM_FIELD}
1145
+ */
1146
+ setHiddenElements(elements: string[]): void;
1147
+ /**
1148
+ * Current method can set custom ID to identify the data in the future
1149
+ *
1150
+ * @example
1151
+ * widget.setRefId('id');
1152
+ *
1153
+ * @param {string} refId - custom id
1154
+ */
1155
+ setRefId(refId: string): void;
1156
+ /**
1157
+ * Current method can add visual validation from gateway to widget's form fields
1158
+ *
1159
+ * @example
1160
+ * widget.useGatewayFieldValidation();
1161
+ */
1162
+ useGatewayFieldValidation(): void;
1163
+ /**
1164
+ * Current method can set icons of supported card types
1165
+ *
1166
+ * @example
1167
+ *
1168
+ * widget.setSupportedCardIcons(['mastercard', 'visa'], validateCardNumberInput);
1169
+ *
1170
+ * @param {string[]} elements - [SUPPORTED_CARD_TYPES]{@link SUPPORTED_CARD_TYPES}
1171
+ * @param {boolean} validateCardNumberInput - [validateCardNumberInput=false] - using this param you allow validation for card number input on supported card types
1172
+ */
1173
+ setSupportedCardIcons(elements: string[], validateCardNumberInput?: boolean): void;
1174
+ /**
1175
+ * Current method can hide prevent the widget from showing the error messages
1176
+ *
1177
+ * @example
1178
+ * widget.hideUiErrors('id');
1179
+ */
1180
+ hideUiErrors(): void;
1181
+ /**
1182
+ * Current method can change environment. By default environment = sandbox.
1183
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
1184
+ *
1185
+ * @example
1186
+ * widget.setEnv('production', 'paydock.com');
1187
+ * @param {string} env - sandbox, production
1188
+ * @param {string} [alias] - Own domain alias
1189
+ */
1190
+ setEnv(env: string, alias?: string): void;
1191
+ getEnv(): void;
1192
+ /**
1193
+ * Method for creating iframe url
1194
+ *
1195
+ * @example
1196
+ * widget.loadIFrameUrl(function (url) {
1197
+ * console.log(url);
1198
+ * }, function (errors) {
1199
+ * console.log(errors);
1200
+ * });
1201
+ */
1202
+ loadIFrameUrl(cb: (url: string) => void, errorCb?: (error: any) => void): void;
1203
+ /**
1204
+ * Method for setting a custom language code
1205
+ *
1206
+ * @example
1207
+ * config.setLanguage('en');
1208
+ * @param {string} code - ISO 639-1
1209
+ */
1210
+ setLanguage(code: any): void;
1211
+ getLink(): Link;
1212
+ protected handleErrorEvent(event: EventTypes, error: IEventError, purpose: PURPOSE): void;
1022
1213
  }
1023
1214
 
1024
- /**
1025
- * @type {object}
1026
- * @param {string} CLICK=click
1027
- * @param {string} POPUP_REDIRECT=popup_redirect
1028
- * @param {string} ERROR=error
1029
- * @param {string} ACCEPTED=accepted
1030
- * @param {string} FINISH=finish
1031
- * @param {string} CLOSE=close
1032
- */
1033
- declare const CHECKOUT_BUTTON_EVENT: {
1034
- CLICK: string;
1035
- POPUP_REDIRECT: string;
1036
- REDIRECT: string;
1037
- ERROR: string;
1038
- REFERRED: string;
1039
- DECLINED: string;
1040
- CANCELLED: string;
1041
- ACCEPTED: string;
1042
- FINISH: string;
1043
- CLOSE: string;
1044
- };
1045
- /**
1046
- * @type {object}
1047
- * @param {string} CONTEXTUAL=contextual
1048
- * @param {string} REDIRECT=redirect
1049
- */
1050
- declare enum CHECKOUT_MODE {
1051
- CONTEXTUAL = "contextual",
1052
- REDIRECT = "redirect"
1215
+ interface ITriggerData {
1216
+ configuration_token?: string;
1217
+ tab_number?: number;
1218
+ elements?: string;
1219
+ form_values?: string;
1053
1220
  }
1054
1221
  /**
1222
+ * Interface for classes that represent a trigger data.
1223
+ * @interface ITriggerData
1224
+ *
1225
+ * @param {string} [configuration_token]
1226
+ * @param {string} [tab_number]
1227
+ * @param {string} [elements]
1228
+ * @param {string} [form_values]
1229
+ * */
1230
+ /**
1231
+ * List of available triggers
1232
+ *
1055
1233
  * @type {object}
1056
- * @param {string} ZIPMONEY=Zipmoney
1057
- * @param {string} PAYPAL=PaypalClassic
1058
- * @param {string} AFTERPAY=Afterpay
1234
+ * @param {string} SUBMIT_FORM=submit_form
1235
+ * @param {string} CHANGE_TAB=tab
1236
+ * @param {string} HIDE_ELEMENTS=hide_elements
1237
+ * @param {string} SHOW_ELEMENTS=show_elements
1238
+ * @param {string} REFRESH_CHECKOUT=refresh_checkout
1239
+ * @param {string} UPDATE_FORM_VALUES=update_form_values
1240
+ * @param {string} INIT_CHECKOUT=init_checkout
1059
1241
  */
1060
- declare enum GATEWAY_TYPE {
1061
- ZIPMONEY = "Zipmoney",
1062
- PAYPAL = "PaypalClassic",
1063
- AFTERPAY = "Afterpay"
1064
- }
1065
- interface IEventCheckoutFinishData {
1066
- payment_source_token: string;
1067
- checkout_email: string;
1068
- checkout_holder: string;
1069
- gateway_type: string;
1242
+ declare const TRIGGER: {
1243
+ SUBMIT_FORM: string;
1244
+ CHANGE_TAB: string;
1245
+ HIDE_ELEMENTS: string;
1246
+ SHOW_ELEMENTS: string;
1247
+ REFRESH_CHECKOUT: string;
1248
+ UPDATE_FORM_VALUES: string;
1249
+ INIT_CHECKOUT: string;
1250
+ };
1251
+ declare class Trigger {
1252
+ protected iFrame: IFrame;
1253
+ constructor(iFrame: IFrame);
1254
+ push(triggerName: string, data?: ITriggerData): void;
1070
1255
  }
1071
1256
 
1072
- /**
1073
- * Class Background create overlay for checkout
1074
- *
1075
- * @example
1076
- * var overlay = new Background();
1077
- */
1078
- declare class Background {
1079
- protected description: string;
1080
- protected title: string;
1081
- protected overlay: HTMLElement;
1082
- protected style: HTMLStyleElement;
1083
- protected eventEmitter: EventEmitter;
1084
- protected showControl: boolean;
1085
- protected showLoader: boolean;
1086
- constructor();
1087
- initControl(): void;
1088
- initLoader(): void;
1089
- private eventHandler;
1090
- clear(): void;
1091
- private createLoader;
1092
- protected createTemplate(): void;
1093
- private createStyles;
1094
- setBackdropDescription(text: string): void;
1095
- setBackdropTitle(text: string): void;
1096
- onTrigger(triggerName: string, cb: () => void): void;
1097
- isInit(): boolean;
1098
- hideContinueControl(): void;
1099
- turnOffControl(): void;
1100
- turnOffLoader(): void;
1101
- }
1102
-
1103
- declare type SuccessCb = (data: any, status: number) => void;
1104
- declare type ErrorCb = (err: any, status: number) => void;
1105
- declare abstract class HttpCore {
1106
- private env;
1107
- constructor();
1108
- setEnv(env: string, alias?: string): void;
1109
- getEnv(): string;
1110
- protected getUrl(): string;
1111
- protected create(accessToken: string, data: any, cb: SuccessCb, errorCb: ErrorCb): void;
1112
- protected get(accessToken: string, cb: SuccessCb, errorCb: ErrorCb): void;
1113
- protected parser(text: any, status: number, cb: SuccessCb, errorCb: ErrorCb): void;
1114
- protected abstract getLink(): string;
1115
- }
1116
-
1117
- interface IBody$1 {
1118
- gateway_id: string;
1119
- success_redirect_url: string;
1120
- error_redirect_url: string;
1121
- redirect_url: string;
1122
- meta: IPayPalMeta;
1123
- description?: string;
1124
- }
1125
- interface ICheckout {
1126
- gateway_id: string;
1127
- checkout_type: string;
1128
- gateway_type: string;
1129
- link: string;
1130
- reference_id: string;
1131
- token: string;
1132
- mode?: string;
1133
- }
1134
- declare class Builder$1 extends HttpCore {
1135
- private body;
1136
- constructor(gatewayID: string, successRedirectUrl: string, errorRedirectUrl: string);
1137
- protected getLink(): string;
1138
- setDescriptions(text: string): void;
1139
- setMeta(meta: IPayPalMeta): void;
1140
- getConfigs(): IBody$1;
1141
- send(publicKey: string, cb: (checkout: ICheckout) => void, errorCb?: (error: any, code: string) => void): void;
1142
- }
1143
-
1144
- interface IDetails {
1145
- checkout_email: string;
1146
- checkout_holder: string;
1147
- status: string;
1148
- gateway_type: string;
1149
- }
1150
- declare class Checker extends HttpCore {
1151
- token: string;
1152
- constructor(token: string);
1153
- protected getLink(): string;
1154
- send(accessToken: string, cb: (details: IDetails) => void, errorCb?: (error: any) => void): void;
1155
- }
1156
-
1157
- type AdditionalParams = Record<string, string | number | boolean>;
1158
- interface IRunner {
1159
- next(checkoutData: ICheckout, params?: AdditionalParams): void;
1160
- error(error: string, code: string, cb: (close: boolean) => void): void;
1161
- getSuccessRedirectUri(): string;
1162
- getErrorRedirectUri(): string;
1163
- setEnv(env: string, alias?: string): void;
1164
- }
1165
-
1166
- interface IDispatcherData {
1167
- message_source: string;
1168
- event: string;
1169
- }
1170
-
1171
- interface IContextualRunner extends IRunner {
1172
- run(): void;
1173
- isRunning(): boolean;
1174
- continue(): void;
1175
- stop(): void;
1176
- onStop(cb: () => void): void;
1177
- onCheckout<T extends IDispatcherData>(event: string, cb: (checkout: ICheckout, data?: T) => void): void;
1178
- setBackgroundTitle(text: string): void;
1179
- setBackgroundDescription(text: string): void;
1180
- turnOffBackdrop(): void;
1181
- setSuspendedRedirectUri(uri: string): void;
1182
- }
1183
-
1184
- interface IRedirectRunner extends IRunner {
1185
- setRedirectUrl(url: string): void;
1186
- getRedirectUrl(): string;
1187
- getProxyRedirectUrl(): string;
1188
- }
1189
-
1190
- interface CheckoutContextualHandlerParams {
1191
- accessToken: string;
1192
- gatewayId: string;
1257
+ interface IEventMetaData extends IEventData$1 {
1258
+ configuration_token: string;
1259
+ type: string;
1260
+ account_name?: string;
1261
+ account_number?: string;
1262
+ card_number_last4?: string;
1263
+ card_number_length?: number;
1264
+ card_scheme?: string;
1265
+ gateway_type?: string;
1193
1266
  }
1194
- declare class CheckoutContextualHandler {
1195
- protected background: Background;
1196
- protected runner: IContextualRunner;
1197
- protected eventEmitter: EventEmitter;
1198
- protected params: CheckoutContextualHandlerParams;
1199
- protected env: string;
1200
- protected details: IDetails;
1201
- constructor(background: Background, runner: IContextualRunner, eventEmitter: EventEmitter, params: CheckoutContextualHandlerParams);
1202
- init(env: string): void;
1203
- setEnv(env: string): void;
1204
- protected checkToken(token: string, cb: () => void): void;
1205
- protected createOneTimeToken(token: string): void;
1267
+ interface IEventFinishData extends IEventData$1 {
1268
+ payment_source: string;
1269
+ payment_source_token?: string;
1206
1270
  }
1207
-
1208
1271
  /**
1209
- * Class CheckoutButton transform usual button into checkout
1272
+ * Interface of data from validation event.
1273
+ *
1274
+ * @interface IFormValidation
1275
+ *
1276
+ * @param {string} event The name of the event.
1277
+ * @param {string} message_source A system variable that identifies the event source.
1278
+ * @param {string} purpose A system variable that states the purpose of the event.
1279
+ * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
1280
+ * @param {boolean} [form_valid] Indicates wether or not the form is valid.
1281
+ * @param {Array<string>} [invalid_fields] Names of form fields with invalid data.
1282
+ * @param {Array<string>} [invalid_showed_fields] Names of invalid form fields which are already displaying the error.
1283
+ * @param {Partial<Record<CardValidatorValue | GenericValidatorValue, Array<string>>>} [validators] Object containing validator identifiers as keys and the fields subject to that validator as an array of form field names.
1284
+ * See list of available [Generic Vallidators]{@link GENERIC_VALIDATORS} and [Card Validators]{@link CARD_VALIDATORS},
1285
+ */
1286
+ /**
1287
+ * Contains basic information associated with the event and additional meta data
1288
+ * specific to the event. E.g., card info, gateway info, etc.
1289
+ *
1290
+ * @interface IEventMetaData
1291
+ *
1292
+ * @param {string} event The name of the event.
1293
+ * @param {string} purpose A system variable that states the purpose of the event.
1294
+ * @param {string} message_source A system variable that identifies the event source.
1295
+ * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
1296
+ * @param {string} configuration_token Token received from our API with widget data
1297
+ * @param {string} type Payment type 'card', 'bank_account'
1298
+ * @param {string} gateway_type Gateway type
1299
+ * @param {string} [card_number_last4] Last 4 digit of your card
1300
+ * @param {string} [card_scheme] Card scheme, e.g., (Visa, Mastercard and American Express (AmEx))
1301
+ * @param {number} [card_number_length] Card number length
1302
+ * @param {string} [account_name] Bank account account name
1303
+ * @param {string} [account_number] Bank account account number
1304
+ * */
1305
+ /**
1306
+ * Interface of data from event.
1307
+ * @interface IEventAfterLoadData
1308
+ *
1309
+ * @param {string} event The name of the event.
1310
+ * @param {string} purpose A system variable that states the purpose of the event.
1311
+ * @param {string} message_source A system variable that identifies the event source.
1312
+ * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
1313
+ * */
1314
+ /**
1315
+ * Interface of data from event.
1316
+ * @interface IEventFinishData
1317
+ *
1318
+ * @param {string} event The name of the event.
1319
+ * @param {string} purpose A system variable that states the purpose of the event.
1320
+ * @param {string} message_source A system variable that identifies the event source.
1321
+ * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
1322
+ * @param {string} payment_source One time token. Result from this endpoint [API docs](https://docs.paydock.com/#tokens)
1323
+ * */
1324
+ /**
1325
+ * List of available event's name
1326
+ * @const EVENT
1327
+ *
1328
+ * @type {object}
1329
+ * @param {string} AFTER_LOAD=afterLoad
1330
+ * @param {string} SUBMIT=submit
1331
+ * @param {string} FINISH=finish
1332
+ * @param {string} VALIDATION=validation
1333
+ * @param {string} VALIDATION_ERROR=validationError
1334
+ * @param {string} SYSTEM_ERROR=systemError
1335
+ * @param {string} META_CHANGE=metaChange
1336
+ * @param {string} RESIZE=resize
1337
+ */
1338
+ /**
1339
+ * List of available event's name
1340
+ * @const VAULT_DISPLAY_EVENT
1210
1341
  *
1342
+ * @type {object}
1343
+ * @param {string} AFTER_LOAD=afterLoad
1344
+ * @param {string} SYSTEM_ERROR=system_error
1345
+ * @param {string} CVV_SECURE_CODE_REQUESTED=cvv_secure_code_requested
1346
+ * @param {string} CARD_NUMBER_SECURE_CODE_REQUESTED=card_number_secure_code_requested
1347
+ * @param {string} ACCESS_FORBIDDEN=access_forbidden
1348
+ * @param {string} SESSION_EXPIRED=systemError
1349
+ * @param {string} SYSTEM_ERROR=session_expired
1350
+ * @param {string} OPERATION_FORBIDDEN=operation_forbidden
1351
+ */
1352
+ /**
1353
+ * Class HtmlMultiWidget include method for working with html
1211
1354
  * @constructor
1355
+ * @extends MultiWidget
1212
1356
  *
1213
- * @param {string} selector - Selector of html element.
1214
- * @param {string} aceessToken - PayDock access token or users public key
1215
- * @param {string} [gatewayId=default] - PayDock's gatewayId. By default or if put 'default', it will use the selected default gateway
1216
- * @param {string} [type=PaypalClassic] - Type of gateway (PaypalClassic, Zipmoney)
1357
+ * @param {string} selector - Selector of html element. Container for widget
1358
+ * @param {string} publicKey - PayDock users public key
1359
+ * @param {(Configuration | string | Configuration[] | string[])} conf - exemplar[s] Configuration class OR configuration token
1217
1360
  * @example
1218
- * var widget = new CheckoutButton('#button', 'accessToken','gatewayId');
1361
+ * var widget = new MultiWidget('#widget', 'publicKey','configurationToken'); // With a pre-created configuration token
1362
+ *
1363
+ * var widget = new MultiWidget('#widget', 'publicKey',['configurationToken', 'configurationToken2']); // With pre-created configuration tokens
1364
+ *
1365
+ * var widget = new MultiWidget('#widget', 'publicKey', new Configuration('gatewayId')); With Configuration
1366
+ *
1367
+ * var widget = new MultiWidget('#widget', 'publicKey',[ With Configurations
1368
+ * Configuration(), // default gateway_id,
1369
+ * Configuration('not_configured'), // without gateway,
1370
+ * Configuration('gatewayId'),
1371
+ * Configuration('gatewayId', 'bank_account')
1372
+ * ]);
1219
1373
  */
1220
- declare class CheckoutButton {
1221
- protected accessToken: string;
1222
- protected gatewayId: string;
1223
- protected gatewayType: GATEWAY_TYPE;
1224
- protected mode: CHECKOUT_MODE;
1225
- protected window: Window;
1226
- protected eventEmitter: EventEmitter;
1374
+ declare class HtmlMultiWidget extends MultiWidget {
1227
1375
  protected container: Container;
1228
- protected meta: IPayPalMeta;
1229
- protected runner: IContextualRunner | IRedirectRunner;
1230
- protected background?: Background;
1231
- protected checkoutHandler?: CheckoutContextualHandler;
1232
- protected env: string;
1233
- protected alias?: string;
1234
- /** @constructs */ constructor(selector: string, accessToken: string, gatewayId?: string, gatewayType?: GATEWAY_TYPE, mode?: CHECKOUT_MODE);
1235
- protected chooseRunner(gatewayType: GATEWAY_TYPE, mode: CHECKOUT_MODE): void;
1236
- protected buildAdditionalParams(): AdditionalParams;
1237
- protected initCheckout(container: Container): void;
1376
+ protected iFrame: IFrame;
1377
+ protected triggerElement: Trigger;
1378
+ protected validationData: IFormValidation;
1379
+ /** @constructs */ constructor(selector: string, publicKey: string, conf: any);
1238
1380
  /**
1239
- * This callback will be called for each event in payment source widget
1381
+ * Loads the widget.
1240
1382
  *
1241
- * @callback listener
1383
+ * Calling this method results in an iframe element being inserted and rendered in the DOM.
1384
+ */
1385
+ load(): void;
1386
+ /**
1387
+ * Registers a form validation callback for validation events.
1242
1388
  */
1389
+ protected afterLoad(): void;
1243
1390
  /**
1244
1391
  * Listen to events of widget
1245
1392
  *
1246
1393
  * @example
1247
1394
  *
1248
- * widget.on('click', function () {
1395
+ * ```javascript
1396
+ * widget.on('form_submit', function (data) {
1397
+ * console.log(data);
1398
+ * });
1399
+ * ```
1400
+ *
1401
+ * @example
1249
1402
  *
1403
+ * ```javascript
1404
+ * widget.on('form_submit').then(function (data) {
1405
+ * console.log(data);
1250
1406
  * });
1251
- * @param {string} eventName - Available event names [CHECKOUT_BUTTON_EVENT]{@link CHECKOUT_BUTTON_EVENT}
1252
- * @param {listener} cb
1407
+ * ```
1408
+ *
1409
+ * @typedef {(data: IEventData | IEventMetaData | IEventFinishData | IFormValidation) => void} EventListenerCallback
1410
+ *
1411
+ * @param {string} eventName - The name of the event that should be listened. Available event names [EVENT]{@link EVENT}.
1412
+ * @param {EventListenerCallback} [cb] - A function to be invoked whenever the event occurs.
1413
+ *
1414
+ * @return {Promise<IEventData | IEventMetaData | IEventFinishData | IFormValidation> | void}
1253
1415
  */
1254
- on<T = object>(name: string, handler: (data: T) => void): void;
1416
+ on(eventName: string): Promise<IEventData$1 | IEventMetaData | IEventFinishData | IFormValidation>;
1417
+ on(eventName: string, cb: (data: IEventData$1 | IEventMetaData | IEventFinishData | IFormValidation) => void): any;
1255
1418
  /**
1256
- * Close popup window forcibly.
1257
- * Only for 'contextual' mode.
1419
+ * Registers callback that will be invoked for every trigger.
1258
1420
  *
1421
+ * @param {'submit_form' | 'tab'} triggers - The Widget element identifier that caused the trigger.
1422
+ * @param {ITriggerData} data - Data that will be sent to the widget when the trigger occurs.
1259
1423
  */
1260
- close(): void;
1424
+ trigger(triggerName: string, data?: ITriggerData): void;
1261
1425
  /**
1262
- * After finish event of checkout button, data (dataType) will be insert to input (selector)
1426
+ * Gets a reference to the form current validation state.
1263
1427
  *
1264
- * @param {string} selector - css selector . [] #
1265
- * @param {string} dataType - data type of IEventCheckoutFinishData [IEventCheckoutFinishData]{@link #IEventCheckoutFinishData}.
1428
+ * !Warning: do not directly modify the values of the returned object.
1429
+ *
1430
+ * @return {IFormValidation} Form validation object
1266
1431
  */
1267
- onFinishInsert(selector: string, dataType: string): void;
1432
+ getValidationState(): IFormValidation;
1268
1433
  /**
1269
- * Method for setting meta information for checkout page
1434
+ * Checks if a given form is valid.
1270
1435
  *
1271
- * @example
1272
- * button.setMeta({
1273
- brand_name: 'paydock',
1274
- reference: '15',
1275
- email: 'wault@paydock.com'
1276
- });
1436
+ * A form is valid if all form fields are valid.
1277
1437
  *
1278
- * @param {(IPayPalMeta|IAfterpayMeta|IZipmoneyMeta)} meta - Data which can be shown on checkout page [IPayPalMeta]{@link IPayPalMeta} [IZipmoneyMeta]{@link IZipmoneyMeta} [IAfterpayMeta]{@link IAfterpayMeta}
1438
+ * @return {boolean} Indicates wether or not form is valid.
1279
1439
  */
1280
- setMeta(meta: IPayPalMeta | IAfterpayMeta | IZipmoneyMeta): void;
1440
+ isValidForm(): boolean;
1281
1441
  /**
1282
- * Method for setting backdrop description.
1283
- * Only for 'contextual' mode.
1442
+ * Using this method you can check if a specific form field is invalid
1284
1443
  *
1285
- * @example
1286
- * button.setBackdropDescription('Custom description');
1444
+ * @param {string} field - Field name
1445
+ * @return {boolean} Field is invalid
1446
+ */
1447
+ isInvalidField(field?: string): boolean;
1448
+ /**
1449
+ * Checks if a given form field is displaying an error.
1287
1450
  *
1288
- * @param {string} text - description which can be shown in overlay of back side checkout page
1451
+ * @param {string} field - The form field name
1452
+ *
1453
+ * @return {boolean} Indicates wether or not the Error message is being displayed on the associated field.
1289
1454
  */
1290
- setBackdropDescription(text: string): void;
1455
+ isFieldErrorShowed(field?: string): boolean;
1291
1456
  /**
1292
- * Method for setting backdrop title.
1293
- * Only for 'contextual' mode.
1457
+ * Checks if a given form field is valid or invalid by name.
1294
1458
  *
1295
- * @example
1296
- * button.setBackdropTitle('Custom title');
1459
+ * @param {string} field - The form field name
1460
+ * @param validator - The name of the validator.
1297
1461
  *
1298
- * @param {text} string - title which can be shown in overlay of back side checkout page
1462
+ * @return {boolean} Indicates wether or not the field is invalid based on validator intepretation.
1299
1463
  */
1300
- setBackdropTitle(text: string): void;
1464
+ isInvalidFieldByValidator(field: string, validator: ValidatorFieldsMapKey): boolean;
1301
1465
  /**
1302
- * Method for setting suspended redirect uri. Redirect after referred checkout.
1303
- * Only for 'contextual' mode.
1466
+ * Hides the widget.
1304
1467
  *
1305
- * @param {uri} string - uri for redirect (by default)
1468
+ * E.g., use this method to hide the widget after it loads.
1469
+ *
1470
+ * @param {boolean} [saveSize=false] Wether the original iframe element size should be saved before being hidden.
1306
1471
  */
1307
- setSuspendedRedirectUri(uri: string): void;
1472
+ hide(saveSize: boolean): void;
1308
1473
  /**
1309
- * Method for setting the merchant redirect URL.
1310
- * Merchant's customers redirect after successfull checkout.
1311
- * Only for 'redirect' mode.
1474
+ * Shows the widget.
1312
1475
  *
1313
- * @param {url} string - redirect url
1476
+ * E.g., use this method to show the widget after it was explicitly hidden.
1314
1477
  */
1315
- setRedirectUrl(url: string): void;
1316
- getSuccessRedirectUri(): string;
1478
+ show(): void;
1317
1479
  /**
1318
- * Method for disable backdrop on the page.
1319
- * Only for 'contextual' mode.
1480
+ * Reloads the widget.
1481
+ */
1482
+ reload(): void;
1483
+ /**
1484
+ * Hides the specified Widget elements by their identifier.
1320
1485
  *
1321
1486
  * @example
1322
- * button.turnOffBackdrop();
1323
1487
  *
1488
+ * ```javascript
1489
+ * widget.hideElements(['submit_button', 'email']);
1490
+ * ```
1491
+ *
1492
+ * @param {string[]} elements - List of element which can be hidden [ELEMENT]{@link ELEMENT} || [FORM_FIELD]{@link FORM_FIELD}
1324
1493
  */
1325
- turnOffBackdrop(): void;
1326
- protected turnOffControlBackdrop(): void;
1327
- protected turnOffLoaderBackdrop(): void;
1328
- setEnv(env: string, alias?: string): void;
1329
- getEnv(): string;
1330
- private getRunnerByMode;
1331
- private assertMethodSupport;
1332
- }
1333
-
1334
- interface ZipmoneyRunnerParams extends AdditionalParams {
1335
- gateway_id: string;
1336
- public_key: string;
1337
- }
1338
-
1339
- /**
1340
- * Class ZipmoneyCheckoutButton is wrapper of CheckoutButton transform usual button into checkout
1341
- *
1342
- * @extends CheckoutButton
1343
- *
1344
- * @constructor
1345
- *
1346
- * @param {string} selector - Selector of html element.
1347
- * @param {string} publicKey - PayDock users public key
1348
- * @param {string} [gatewayId=default] - PayDock's gatewayId. By default or if put 'default', it will use the selected default gateway
1349
- * @param {string} [gatewayId=default] - Checkout mode, it could be set to 'contextual' or 'redirect'. By default it 'contextual'
1350
- * @example
1351
- * var widget = new ZipmoneyCheckoutButton('#button', 'publicKey','gatewayId');
1352
- */
1353
- declare class ZipmoneyCheckoutButton extends CheckoutButton {
1354
- protected publicKey: string;
1355
- protected gatewayId: string;
1356
- protected mode: CHECKOUT_MODE;
1357
- /** @constructs */ constructor(selector: string, publicKey: string, gatewayId?: string, mode?: CHECKOUT_MODE);
1494
+ hideElements(elements: string[]): void;
1358
1495
  /**
1359
- * Method for setting suspended redirect uri. Redirect after referred checkout
1496
+ * Shows the specified Widget elements by their identifier.
1360
1497
  *
1361
- * The URI is used for a redirect after the checkout is complete.
1362
- * This can be provided, even if using in-context checkout (sdk). By default, the standard styled page will be used.
1363
- * If using in-context (sdk) we will not automatically redirect to this URI.
1498
+ * @example
1364
1499
  *
1365
-
1366
- * @param {uri} string - uri for suspended redirect (by default)
1500
+ * ```javascript
1501
+ * widget.showElements(['submit_button', 'email']);
1502
+ * ```
1503
+ *
1504
+ * @param {string[]} elements - List of elements which can be showed [ELEMENT]{@link ELEMENT} || [FORM_FIELD]{@link FORM_FIELD}
1367
1505
  */
1368
- setSuspendedRedirectUri(uri: string): void;
1506
+ showElements(elements: string[]): void;
1369
1507
  /**
1370
- * Method for setting the merchant redirect URL.
1371
- * The merchant's customers would be redirected to the specified URL
1372
- * at the end of ZipMoney checkout flow.
1508
+ * Updates the form field values inside the widget.
1373
1509
  *
1374
- * Once the redirect URL would be set, the checkout flow would be immediately switched
1375
- * from 'contextual' mode to the 'redirect' mode.
1376
- * The merchant's customer would be automatically redirected to this URL after the checkout is complete.
1510
+ * @example
1377
1511
  *
1378
- * @param {url} string - URL for redirect
1512
+ * ```javascript
1513
+ * widget.updateFormValues({
1514
+ * email: 'predefined@email.com',
1515
+ * card_name: 'Houston'
1516
+ * });
1517
+ *```
1518
+ *
1519
+ * @param {IFormValues} fieldValues - Fields with values
1379
1520
  */
1380
- setRedirectUrl(url: string): void;
1381
- protected buildAdditionalParams(): ZipmoneyRunnerParams;
1382
- }
1383
-
1384
- /**
1385
- * Class AfterpayCheckoutButton is wrapper of CheckoutButton transform usual button into checkout
1386
- *
1387
- * @extends CheckoutButton
1388
- *
1389
- * @constructor
1390
- *
1391
- * @param {string} selector - Selector of html element.
1392
- * @param {string} accessToken - PayDock access-token or users public key
1393
- * @param {string} [gatewayId=default] - PayDock's gatewayId. By default or if put 'default', it will use the selected default gateway
1394
- * @example
1395
- * var widget = new AfterpayCheckoutButton('#button', 'access-token','gatewayId');
1396
- */
1397
- declare class AfterpayCheckoutButton extends CheckoutButton {
1398
- protected accessToken: string;
1399
- protected gatewayId: string;
1400
- protected showETP: boolean;
1401
- /** @constructs */ constructor(selector: string, accessToken: string, gatewayId?: string);
1521
+ updateFormValues(fieldValues: IFormValues): void;
1402
1522
  /**
1403
- * Method which toggles the "Enhanced Tracking Protection" warning popup to 'on' mode.
1523
+ * Updates a single form field values inside the widget by the form field name.
1404
1524
  *
1405
- * This popup with a warning about "Enhanced Tracking Protection" limitations
1406
- * would be shown in the Mozilla Firefox browser version 100+
1525
+ * @example
1407
1526
  *
1408
- * By default, the popup would not be shown, until
1409
- * the flag would be set to `true`
1410
-
1411
- * @param {doShow} boolean - flag which toggle the popup visibility
1527
+ * ```javascript
1528
+ * widget.updateFormValue("card_name", "John Doe");
1529
+ *```
1530
+ *
1531
+ * @param {string} key - The form field name
1532
+ * @param {string} value - The form field value
1412
1533
  */
1413
- showEnhancedTrackingProtectionPopup(doShow: boolean): void;
1414
- protected buildAdditionalParams(): AdditionalParams;
1415
- }
1416
-
1417
- /**
1418
- * Class PaypalCheckoutButton is wrapper of CheckoutButton transform usual button into checkout
1419
- *
1420
- * @extends CheckoutButton
1421
- *
1422
- * @constructor
1423
- *
1424
- * @param {string} selector - Selector of html element.
1425
- * @param {string} publicKey - PayDock users public key
1426
- * @param {string} [gatewayId=default] - PayDock's gatewayId. By default or if put 'default', it will use the selected default gateway
1427
- * @example
1428
- * var widget = new PaypalCheckoutButton('#button', 'publicKey','gatewayId');
1429
- */
1430
- declare class PaypalCheckoutButton extends CheckoutButton {
1431
- protected publicKey: string;
1432
- protected gatewayId: string;
1433
- /** @constructs */ constructor(selector: string, publicKey: string, gatewayId?: string);
1434
- }
1435
-
1436
- /**
1437
- *
1438
- * Class PaymentSourceWidget include method for for creating iframe url
1439
- * @constructor
1440
- *
1441
- * @param {string} publicKey - PayDock users public key
1442
- * @param {string} customer - PayDock's customer_id or customer_reference (In order to use the customer_reference, you must explicitly specify useReference as true)
1443
- * @param {boolean} [useReference=false]
1444
- *
1445
- * @example
1446
- * var widget = new PaymentSourceWidget('publicKey','customerId');
1447
- * // or
1448
- * var widget = new PaymentSourceWidget('publicKey', customerReference, true);
1449
- */
1450
- declare class PaymentSourceWidget {
1451
- protected link: Link;
1452
- protected configs: Configuration[];
1453
- protected configTokens: string[];
1454
- protected publicKey: string;
1455
- /** @constructs */ constructor(accessToken: string, queryToken: string);
1456
- /**
1457
- * Object contain styles for widget
1458
- *
1459
- * @example
1460
- * widget.setStyles({
1461
- * background_color: 'rgb(0, 0, 0)',
1462
- * border_color: 'yellow',
1463
- * text_color: '#FFFFAA',
1464
- * icon_size: 'small',
1465
- * font_size: '20px'
1466
- * });
1467
- * @param {IStyles} fields - name of styles which can be shown in widget [STYLE]{@link STYLE}
1468
- */
1469
- setStyles(styles: IStyles$1): void;
1470
- setStyle(param: string, value: string): void;
1471
- /**
1472
- * Current method can set custom ID to identify the data in the future
1473
- *
1474
- * @example
1475
- * widget.setRefId('id');
1476
- *
1477
- * @param {string} refId - custom id
1478
- */
1479
- setRefId(refId: string): void;
1480
- /**
1481
- * Current method can set limit for payment sources count. In case when limit sets less then general count will be shown pagination buttons prev and next.
1482
- *
1483
- * @param {string} count - payment source count
1484
- */
1485
- setLimit(count: number): void;
1534
+ updateFormValue(key: string, value: string): void;
1486
1535
  /**
1487
- * Current method can change environment. By default environment = sandbox
1488
- * Also we can change domain alias for this environment. By default domain_alias = paydock.com
1536
+ * Inserts the event data (after finish event) onto the input field associated with the provided CSS selector.
1489
1537
  *
1490
- * @example
1491
- * widget.setEnv('production');
1492
- * @param {string} env - sandbox, production
1493
- * @param {string} [alias] - Own domain alias
1494
- */
1495
- setEnv(env: string, alias?: string): void;
1496
- getEnv(): void;
1497
- /**
1498
- * Method for getting iframe's url
1538
+ * @param {string} selector - A CSS selector. E.g., ".my-class", "#my-id", or others
1539
+ * @param {string} dataType - The data type of IEventData object.
1499
1540
  */
1500
- getIFrameUrl(): string;
1541
+ onFinishInsert(selector: string, dataType: string): void;
1501
1542
  /**
1502
- * Show payment source inside widget only with requested gateway ids
1503
- *
1543
+ * Intercepts a form submission and delegates processing to the widget.
1504
1544
  *
1505
- * @param {string[]} ids - List of gateway_id
1506
- */
1507
- filterByGatewayIds(ids: string[]): void;
1508
- /**
1545
+ * An simplified example of the process:
1546
+ * - User clicks submit button in your form
1547
+ * - This implicitly triggers a submission to the widget
1548
+ * - The widget submits your form
1509
1549
  *
1510
- * Show payment source inside widget only with requested payment source types
1550
+ * @note The widget's submit button will be hidden.
1511
1551
  *
1512
- * @param types - List of payment source types. Available parameters [PAYMENT_TYPE]{@link PAYMENT_TYPE}
1513
- */
1514
- filterByTypes(types: string[]): void;
1515
- /**
1516
- * Method for setting a custom language code
1552
+ * @param {string} selector - css selector of your form
1517
1553
  *
1518
1554
  * @example
1519
- * config.setLanguage('en');
1520
- * @param {string} code - ISO 639-1
1521
- */
1522
- setLanguage(code: any): void;
1523
- }
1524
-
1525
- interface IEventSelectData extends IEventData$1 {
1526
- customer_id: string;
1527
- payment_source_id: string;
1528
- gateway_id: string;
1529
- primary: boolean;
1530
- card_number_last4?: string;
1531
- card_scheme?: string;
1532
- checkout_email?: string;
1533
- gateway_type?: string;
1534
- payment_source_type: string;
1535
- account_name?: string;
1536
- account_number?: string;
1537
- }
1538
- interface IEventPaginationData extends IEventData$1 {
1539
- total_item: number;
1540
- skip: number;
1541
- limit: number;
1542
- }
1543
- interface IEventAfterLoadData extends IEventData$1 {
1544
- total_item: number;
1545
- skip: number;
1546
- limit: number;
1547
- }
1548
- interface IEventSizeData extends IEventData$1 {
1549
- height: number;
1550
- width: number;
1551
- }
1552
- /**
1553
- * Interface of data from event.
1554
- *
1555
- * @interface IEventSelectData
1556
- *
1557
- * @param {string} event
1558
- * @param {string} purpose
1559
- * @param {string} message_source
1560
- * @param {string} [ref_id]
1561
- * @param {string} customer_id
1562
- * @param {string} payment_source_id
1563
- * @param {string} gateway_id
1564
- * @param {boolean} primary
1565
- * @param {string} [widget_id]
1566
- * @param {string} [card_number_last4]
1567
- * @param {string} [card_scheme]
1568
- * @param {string} gateway_type
1569
- * @param {string} [checkout_email]
1570
- * @param {string} payment_source_type
1571
- * @param {string} [account_name]
1572
- * @param {string} [account_number]
1573
- * */
1574
- /**
1575
- * Interface of data from event.
1576
- *
1577
- * @interface IEventPaginationData
1578
- *
1579
- * @param {string} event
1580
- * @param {string} purpose
1581
- * @param {string} message_source
1582
- * @param {string} [ref_id]
1583
- * @param {number} total_item
1584
- * @param {number} skip
1585
- * @param {number} limit
1586
- * */
1587
- /**
1588
- * Interface of data from event.
1589
- *
1590
- * @interface IEventAfterLoadData
1591
- *
1592
- * @param {string} event The name of the event.
1593
- * @param {string} purpose A system variable that states the purpose of the event.
1594
- * @param {string} message_source A system variable that identifies the event source.
1595
- * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
1596
- * @param {number} total_item Pagination param. Total item count
1597
- * @param {number} skip Pagination param. Skip items from first item
1598
- * @param {number} limit Pagination param. Query limit
1599
- * */
1600
- /**
1601
- * Interface of data from event.
1602
- * @interface IEventFinishData
1603
- *
1604
- * @param {string} event The name of the event.
1605
- * @param {string} purpose A system variable that states the purpose of the event.
1606
- * @param {string} message_source A system variable that identifies the event source.
1607
- * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
1608
- * */
1609
- /**
1610
- * Interface of data from event.
1611
- * @interface IEventSizeData
1612
- *
1613
- * @param {number} event The name of the event.
1614
- * @param {number} purpose A system variable that states the purpose of the event.
1615
- * @param {string} message_source A system variable that identifies the event source.
1616
- * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
1617
- * @param {number} height Height of iFrame
1618
- * @param {number} width Width of iFrame
1619
- * */
1620
- /**
1621
- * List of available event's name
1622
- *
1623
- * @const EVENT
1624
- *
1625
- * @type {object}
1626
- * @param {string} AFTER_LOAD=afterLoad
1627
- * @param {string} SYSTEM_ERROR=systemError
1628
- * @param {string} SELECT=select
1629
- * @param {string} UNSELECT=unselect
1630
- * @param {string} NEXT=next
1631
- * @param {string} PREV=prev
1632
- * @param {string} META_CHANGE=metaChange
1633
- * @param {string} RESIZE=resize
1634
- */
1635
- /**
1636
- * Class HtmlPaymentSourceWidget include method for working on html
1637
- * @constructor
1638
- * @extends PaymentSourceWidget
1639
- *
1640
- * @param {string} selector - Selector of html element. Container for widget
1641
- * @param {string} publicKey - PayDock users public key
1642
- * @param {string} queryToken - PayDock's query token that represents params to search customer by id or reference
1643
- * @example
1644
- * * var widget = new HtmlPaymentSourceWidget('#widget', 'publicKey','queryToken');
1645
-
1646
- */
1647
- declare class HtmlPaymentSourceWidget extends PaymentSourceWidget {
1648
- protected container: Container;
1649
- protected iFrame: IFrame;
1650
- protected event: IFrameEvent;
1651
- /** @constructs */ constructor(selector: string, publicKey: string, queryToken: string);
1652
- /**
1653
- * The final method to beginning, the load process of widget to html
1654
1555
  *
1556
+ * ```html
1557
+ * <body>
1558
+ * <form id="myForm">
1559
+ * <input name="amount">
1560
+ * <button type="submit">Submit</button>
1561
+ * </form>
1562
+ * <script>
1563
+ * widget.interceptSubmitForm('#myForm');
1564
+ * </script>
1565
+ * </body>
1566
+ * ```
1655
1567
  */
1656
- load(): void;
1568
+ interceptSubmitForm(selector: string): void;
1657
1569
  /**
1658
- * This callback will be called for each event in payment source widget
1659
- *
1660
- * @callback listener--PaymentSourceWidget
1661
- * @param {IEventData | IEventSelectData | IEventPaginationData | IEventAfterLoadData} response
1570
+ * This method hides a submit button and automatically execute form submit
1662
1571
  */
1572
+ useCheckoutAutoSubmit(): void;
1663
1573
  /**
1664
- * Listen to events of widget
1574
+ * Use this method for resize iFrame according content height
1665
1575
  *
1666
1576
  * @example
1667
1577
  *
1668
- * widget.on('select', function (data) {
1669
- * console.log(data);
1670
- * });
1671
- * @param {string} eventName - Available event names [EVENT]{@link EVENT}
1672
- * @param {listener--PaymentSourceWidget} cb
1578
+ * ```javascript
1579
+ * widget.useAutoResize();
1580
+ *```
1673
1581
  */
1674
- on(eventName: string, cb: (data: IEventData$1 | IEventSelectData | IEventPaginationData | IEventAfterLoadData | IEventSizeData) => void): void;
1675
- /**
1676
- * Using this method you can hide widget after load
1677
- * @param {boolean} [saveSize=false] - using this param you can save iframe's size
1678
- */
1679
- hide(saveSize: boolean): void;
1680
- /**
1681
- * Using this method you can show widget after using hide method
1682
- *
1683
- */
1684
- show(): void;
1685
- /**
1686
- * Using this method you can reload widget
1687
- *
1688
- */
1689
- reload(): void;
1690
- /**
1691
- * After select event of widget, data (dataType) will be insert to input (selector)
1692
- *
1693
- * @param {string} selector - css selector . [] #
1694
- * @param {string} dataType - data type of [IEventSelectData]{@link IEventSelectData}.
1695
- */
1696
- onSelectInsert(selector: string, dataType: string): void;
1697
- }
1698
-
1699
- declare const TYPE: {
1700
- EXTERNAL_CHECKOUT_TOKEN: string;
1701
- CHECKOUT_TOKEN: string;
1702
- BANK_ACCOUNT: string;
1703
- CARD: string;
1704
- };
1705
- interface IBody {
1706
- gateway_id: string;
1707
- type: string;
1708
- checkout_token?: string;
1709
- }
1710
- declare class Builder extends HttpCore {
1711
- private body;
1712
- constructor(gatewayID: string, checkoutToken: string, type: string);
1713
- constructor(gatewayID: string, externalCheckoutToken: string, type: string);
1714
- constructor(gatewayID: string, card: any, type: string);
1715
- constructor(gatewayID: string, bankAccount: any, type: string);
1716
- protected getLink(): string;
1717
- send(accessToken: string, cb: (token: string) => void, errorCb?: (error: any) => void): void;
1718
- getConfigs(): IBody;
1719
- }
1720
-
1721
- interface IBaseSRCMeta {
1722
- customizations?: IStyles;
1723
- dpa_data?: {
1724
- dpa_presentation_name?: string;
1725
- dpa_uri?: string;
1726
- };
1727
- dpa_transaction_options?: {
1728
- dpa_locale?: string;
1729
- dpa_accepted_billing_countries?: string[];
1730
- consumer_name_requested?: boolean;
1731
- consumer_email_address_requested?: boolean;
1732
- consumer_phone_number_requested?: boolean;
1733
- transaction_amount?: {
1734
- transaction_amount?: number;
1735
- transaction_currency_code?: string;
1736
- };
1737
- merchant_order_id?: string;
1738
- merchant_category_code?: string;
1739
- merchant_country_code?: string;
1740
- };
1741
- }
1742
- interface PhoneNumber {
1743
- country_code: string;
1744
- phone_number: string;
1745
- }
1746
- interface Customer {
1747
- email?: string;
1748
- phone?: {
1749
- country_code?: string;
1750
- phone?: string;
1751
- };
1752
- first_name?: string;
1753
- last_name?: string;
1754
- }
1755
- interface IClickToPayMeta extends IBaseSRCMeta {
1756
- dpa_data?: IBaseSRCMeta['dpa_data'] & {
1757
- dpa_address?: string;
1758
- dpa_email_address?: string;
1759
- dpa_phone_number?: PhoneNumber;
1760
- dpa_logo_uri?: string;
1761
- dpa_supported_email_address?: string;
1762
- dpa_supported_phone_number?: PhoneNumber;
1763
- dpa_uri?: string;
1764
- dpa_support_uri?: string;
1765
- application_type?: 'WEB_BROWSER' | 'MOBILE_APP';
1766
- };
1767
- disable_summary_screen?: boolean;
1768
- co_brand_names?: string[];
1769
- checkout_experience?: 'WITHIN_CHECKOUT' | 'PAYMENT_SETTINGS';
1770
- services?: 'INLINE_CHECKOUT' | 'INLINE_INSTALLMENTS';
1771
- dpa_transaction_options?: IBaseSRCMeta['dpa_transaction_options'] & {
1772
- dpa_billing_preference?: MASTERCARD_DPA_SHIPPING_BILLING_PREFERENCE;
1773
- payment_options?: Array<{
1774
- dynamic_data_type?: string;
1775
- }>;
1776
- order_type?: MASTERCARD_ORDER_TYPE;
1777
- three_ds_preference?: string;
1778
- confirm_payment?: boolean;
1779
- };
1780
- customer?: Customer;
1781
- unaccepted_card_type?: 'CREDIT' | 'DEBIT';
1782
- recognition_token?: string;
1783
- }
1784
- type MASTERCARD_DPA_SHIPPING_BILLING_PREFERENCE = 'FULL' | 'POSTAL_COUNTRY' | 'NONE';
1785
- type MASTERCARD_ORDER_TYPE = 'SPLIT_SHIPMENT' | 'PREFERRED_CARD';
1786
- interface IStyles {
1787
- primary_button_color?: string;
1788
- secondary_button_color?: string;
1789
- primary_button_text_color?: string;
1790
- secondary_button_text_color?: string;
1791
- font_family?: string;
1792
- enable_src_popup?: boolean;
1793
- }
1794
-
1795
- declare class ApiChargeInternal {
1796
- protected api: ApiInternal;
1797
- constructor(api: ApiInternal);
1798
- walletCapture(payload: WalletCaptureBody): Promise<WalletCaptureResponse>;
1799
- walletCallback(payload: WalletCallbackBody): Promise<WalletCallbackResponse>;
1800
- standalone3dsProcess(payload: Standalone3dsProcessBody): Promise<ProcessAuthenticationResponse>;
1801
- standalone3dsHandle(): Promise<HandleResponseInterface>;
1802
- }
1803
- interface WalletCaptureResponse {
1804
- id: string;
1805
- amount: number;
1806
- currency: string;
1807
- status: string;
1808
- }
1809
- interface WalletCaptureBody {
1810
- payment_method_id?: string;
1811
- customer?: {
1812
- payment_source?: {
1813
- type?: string;
1814
- card_name?: string;
1815
- card_scheme?: string;
1816
- card_number_last4?: string;
1817
- expire_month?: number;
1818
- expire_year?: number;
1819
- address_line1?: string;
1820
- address_line2?: string;
1821
- address_city?: string;
1822
- address_postcode?: string;
1823
- address_state?: string;
1824
- address_country?: string;
1825
- external_payer_id?: string;
1826
- ref_token?: string;
1827
- };
1828
- };
1829
- }
1830
- interface WalletCallbackBody {
1831
- request_type: string;
1832
- }
1833
- interface WalletCallbackResponse {
1834
- id: string;
1835
- status: string;
1836
- callback_method: string;
1837
- callback_rel: string;
1838
- callback_url: string;
1839
- }
1840
- interface Standalone3dsProcessBody {
1841
- charge_3ds_id: string;
1842
- }
1843
- interface HandleResponseInterface {
1844
- status: string;
1845
- error: string;
1846
- result: {
1847
- reference: string;
1848
- reference_2: string;
1849
- identifier: string;
1850
- identifier_2: string;
1851
- identifier_3: string;
1852
- identifier_4: string;
1853
- identifier_5: string;
1854
- type: string;
1855
- status: string;
1856
- status_2: string;
1857
- status_code: string;
1858
- ref_token: string;
1859
- cancellation: string;
1860
- count: string;
1861
- version: string;
1862
- whitelist: {
1863
- status: string;
1864
- source: string;
1865
- };
1866
- result: string;
1867
- };
1868
- }
1869
- interface ProcessAuthenticationResponse {
1870
- status: string;
1871
- error?: string;
1872
- result?: {
1873
- challenge: string;
1874
- challenge_url: string;
1875
- decoupled_challenge: boolean;
1876
- frictionless: boolean;
1877
- identifier: string;
1878
- identifier_3: string;
1879
- identifier_4: string;
1880
- reference: string;
1881
- reference_2: string;
1882
- secondary_url: string;
1883
- skipped: boolean;
1884
- status: string;
1885
- type: string;
1886
- version: string;
1887
- description?: string;
1888
- };
1889
- }
1890
-
1891
- declare class ApiGatewayInternal {
1892
- protected api: ApiInternal;
1893
- constructor(api: ApiInternal);
1894
- getWalletConfig(gateway_id: string): Promise<GetWalletConfigResponse>;
1895
- }
1896
- interface GetWalletConfigResponse {
1897
- type: string;
1898
- mode: string;
1899
- credentials?: object;
1900
- }
1901
-
1902
- declare class ApiServiceInternal {
1903
- protected api: ApiInternal;
1904
- constructor(api: ApiInternal);
1905
- getConfig(service_id: string): Promise<GetConfigResponse>;
1906
- }
1907
- interface GetConfigResponse {
1908
- type: string;
1909
- merchant: string;
1910
- username: string;
1911
- password: string;
1912
- certificate: string;
1913
- certificate_passphrase: string;
1914
- }
1915
-
1916
- declare class ApiCheckoutInternal {
1917
- protected api: ApiInternal;
1918
- constructor(api: ApiInternal);
1919
- instructions(session_id: string): Observable<object>;
1920
- callback(payload: Object): Promise<Object>;
1921
- status(id: string): Promise<Object>;
1922
- }
1923
-
1924
- declare class ApiInternal extends ApiBase {
1925
- charge(): ApiChargeInternal;
1926
- service(): ApiServiceInternal;
1927
- checkout(): ApiCheckoutInternal;
1928
- gateway(): ApiGatewayInternal;
1929
- }
1930
-
1931
- interface SRCProvider {
1932
- load(): void;
1933
- getEnv(): string;
1934
- hideButton?(saveSize: boolean): void;
1935
- showButton?(): void;
1936
- hideCheckout?(saveSize: boolean): void;
1937
- showCheckout?(): void;
1938
- reload(): void;
1939
- useAutoResize?(): void;
1940
- }
1941
-
1942
- declare abstract class SRC {
1943
- protected iframe_selector: string;
1944
- protected service_id: string;
1945
- protected public_key_or_access_token: string;
1946
- protected meta: IClickToPayMeta;
1947
- protected eventEmitter: EventEmitter;
1948
- protected env: string;
1949
- protected alias?: string;
1950
- protected api: ApiInternal;
1951
- protected provider: SRCProvider;
1952
- protected autoResize: boolean;
1953
- protected style: IStyles;
1954
- constructor(iframe_selector: string, service_id: string, public_key_or_access_token: string, meta: IClickToPayMeta);
1955
- /**
1956
- * Object contain styles for widget - call before `.load()`.
1957
- *
1958
- * @example
1959
- * widget.setStyles({
1960
- * enable_src_popup: true
1961
- * primary_button_color: 'red',
1962
- * secondary_button_color: 'blue',
1963
- * primary_button_text_color: 'white',
1964
- * secondary_button_text_color: 'white',
1965
- * font_family: 'Arial',
1966
- * });
1967
- * @param {IStyles} fields - name of styles which can be shown in widget [STYLE]{@link STYLE}
1968
- */
1969
- setStyles(styles: IStyles): void;
1970
- private setStyle;
1971
- load(): void;
1582
+ useAutoResize(): void;
1583
+ }
1584
+
1585
+ /**
1586
+ * Class Widget include method for working on html and include extended by HtmlMultiWidget methods
1587
+ * @constructor
1588
+ * @extends HtmlMultiWidget
1589
+ * @extends MultiWidget
1590
+ *
1591
+ * @example
1592
+ * var widget = new HtmlWidget('#widget', 'publicKey', 'gatewayID'); // short
1593
+ *
1594
+ * var widget = new HtmlWidget('#widget', 'publicKey', 'gatewayID', 'bank_account', 'payment_source'); // extend
1595
+ *
1596
+ * var widget = new HtmlWidget('#widget', 'publicKey', 'not_configured'); // without gateway
1597
+ *
1598
+ * @param {string} selector - Selector of html element. Container for widget
1599
+ * @param {string} publicKey - PayDock users public key
1600
+ * @param {string} [gatewayID=default] - ID of a gateway connected to PayDock. By default or if put 'default', it will use the selected default gateway. If put 'not_configured', it won’t use gateway to create downstream token.
1601
+ * @param {string} [paymentType=card] - Type of payment source which shows in widget form. Available parameters : “card”, “bank_account”.
1602
+ * @param {string} [purpose=payment_source] - Purpose of widget form. Available parameters: ‘payment_source’, ‘card_payment_source_with_cvv’, ‘card_payment_source_without_cvv’
1603
+ */
1604
+ declare class HtmlWidget extends HtmlMultiWidget {
1605
+ /** @constructs */ constructor(selector: string, publicKey: string, gatewayID?: string, paymentType?: string, purpose?: PURPOSE);
1972
1606
  /**
1973
- * Current method can change environment. By default environment = sandbox.
1974
- * Also we can change domain alias for this environment. By default domain_alias = paydock.com
1607
+ * Destination, where customer will receive all successful responses.
1608
+ * Response will contain “data” object with “payment_source” or other parameters, in depending on 'purpose'
1975
1609
  *
1976
1610
  * @example
1977
- * SRC.setEnv('production');
1978
- * @param {string} env - sandbox, production
1979
- * @param {string} [alias] - Own domain alias
1611
+ * widget.setWebHookDestination('http://google.com');
1612
+ *
1613
+ * @param {string} url - Your endpoint for post request.
1980
1614
  */
1981
- setEnv(env: string, alias?: string): void;
1615
+ setWebHookDestination(url: string): void;
1982
1616
  /**
1983
- * Method to read the current environment
1617
+ * URL to which the Customer will be redirected to after the success finish
1984
1618
  *
1985
1619
  * @example
1986
- * SRC.getEnv();
1620
+ * widget.setSuccessRedirectUrl('google.com/search?q=success');
1621
+ *
1622
+ * @param {string} url
1987
1623
  */
1988
- getEnv(): string;
1989
- on(eventName: string): Promise<any>;
1990
- on(eventName: string, cb: (data: any) => void): any;
1624
+ setSuccessRedirectUrl(url: string): void;
1991
1625
  /**
1992
- * Using this method you can hide checkout after load and button click
1993
- * @param {boolean} [saveSize=false] - using this param you can save iframe's size (if applicable)
1626
+ * URL to which the Customer will be redirected to if an error is triggered in the process of operation
1994
1627
  *
1995
1628
  * @example
1996
- * SRC.hideCheckout();
1629
+ * widget.setErrorRedirectUrl('google.com/search?q=error');
1630
+ *
1631
+ * @param {string} url
1997
1632
  */
1998
- hideCheckout(saveSize: boolean): void;
1633
+ setErrorRedirectUrl(url: string): void;
1999
1634
  /**
2000
- * Using this method you can show checkout after using hideCheckout method
1635
+ * Set list with widget form field, which will be shown in form. Also you can set the required validation for these fields
2001
1636
  *
2002
1637
  * @example
2003
- * SRC.showCheckout()
1638
+ * widget.setFormFields(['phone', 'email', 'first_name*']);
1639
+ *
1640
+ * @param {string[]} fields - name of fields which can be shown in a widget.
1641
+ * If after a name of a field, you put “*”, this field will be required on client-side. (For validation, you can specify any fields, even those that are shown by default: card_number, expiration, etc... ) [FORM_FIELD]{@link FORM_FIELD}
2004
1642
  */
2005
- showCheckout(): void;
1643
+ setFormFields(fields: string[]): void;
2006
1644
  /**
2007
- * Using this method you can reload the whole checkout
1645
+ * The method to set the full configuration for the all specific form elements (visibility, required, label, placeholder, value)
1646
+ * You can also use the other method for the partial configuration like: setFormFields, setFormValues, setFormPlaceholder, setFormLabel
2008
1647
  *
2009
1648
  * @example
2010
- * SRC.reload()
1649
+ * widget.setFormElements([
1650
+ * {
1651
+ * field: 'card_name*',
1652
+ * placeholder: 'Input your card holder name...',
1653
+ * label: 'Card Holder Name',
1654
+ * value: 'Houston',
1655
+ * },
1656
+ * {
1657
+ * field: 'email',
1658
+ * placeholder: 'Input your email, like test@example.com',
1659
+ * label: 'Email for the receipt',
1660
+ * value: 'predefined@email.com',
1661
+ * },
1662
+ * ])
1663
+ *
1664
+ * @param { Object[] } elements - List of elements
1665
+ * @param { string } elements[].field - Field name of element. If after a name of a field, you put “*”, this field will be required on client-side. (For validation, you can specify any fields, even those that are shown by default: card_number, expiration, etc... ) [FORM_FIELD]{@link FORM_FIELD}
1666
+ * @param { string } elements[].placeholder - Set custom placeholders in form fields
1667
+ * @param { string } elements[].label - Set a custom labels near the form field
1668
+ * @param { string } elements[].value - Set predefined values for the form field
2011
1669
  */
2012
- reload(): void;
1670
+ setFormElements(elements: IFormElement[]): void;
1671
+ setFormElement(element: IFormElement): void;
2013
1672
  /**
2014
- * Use this method for resize checkout iFrame according to content height, if applicable
1673
+ * The method to set meta information for the checkout page
2015
1674
  *
2016
1675
  * @example
2017
- * SRC.useAutoResize();
1676
+ * config.setMeta({
1677
+ brand_name: 'paydock',
1678
+ reference: '15',
1679
+ email: 'wault@paydock.com'
1680
+ });
2018
1681
  *
1682
+ * @param {IPayPalMeta | IBamboraMeta} object - data which can be shown on checkout page [IPayPalMeta]{@link IPayPalMeta} [IBamboraMeta]{@link IBamboraMeta}
2019
1683
  */
2020
- useAutoResize(): void;
1684
+ setMeta(meta: IPayPalMeta | IBamboraMeta): void;
1685
+ setGiftCardScheme(giftCardScheme: any, processingNetwork: any): void;
2021
1686
  }
2022
1687
 
2023
1688
  /**
2024
- * Class ClickToPay include methods for interacting with the ClickToPay checkout and Manual Card option
2025
- *
2026
- * @extends SRC
1689
+ * Contains basic information associated with the event.
2027
1690
  *
2028
- * @constructor
1691
+ * Including event (name), source of the message, purpose and a unique identifier
1692
+ * for the event.
2029
1693
  *
2030
- * @param {string} iframe_selector - Selector of html element. Container for Click To Pay checkout iFrame.
2031
- * @param {string} service_id - Card Scheme Service ID
2032
- * @param {string} public_key_or_access_token - Paydock public key or Access Token
2033
- * @param {IClickToPayMeta} meta - Data that configures the Click To Pay checkout
2034
- * @example
2035
- * var mastercardSRC = new ClickToPay('#checkoutIframe', 'service_id', 'public_key', {});
1694
+ * @interface IEventData
2036
1695
  *
1696
+ * @param {string} event The name of the event.
1697
+ * @param {string} message_source A system variable that identifies the event source.
1698
+ * @param {string} purpose A system variable that states the purpose of the event.
1699
+ * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
2037
1700
  */
2038
- declare class ClickToPay extends SRC {
2039
- protected iframe_selector: string;
2040
- protected service_id: string;
2041
- protected public_key_or_access_token: string;
2042
- protected meta: IClickToPayMeta;
2043
- /** @constructs */ constructor(iframe_selector: string, service_id: string, public_key_or_access_token: string, meta: IClickToPayMeta);
2044
- /**
2045
- * The final method after configuring the SRC to start the load process of Click To Pay checkout
2046
- *
2047
- */
2048
- load(): void;
1701
+ interface IEventData$1 {
1702
+ event: string;
1703
+ message_source: string;
1704
+ purpose: PURPOSE;
1705
+ widget_id: string;
1706
+ data?: any;
1707
+ ref_id?: string;
1708
+ error?: IEventError;
1709
+ }
1710
+ declare const EVENT$1: {
1711
+ readonly AFTER_LOAD: "afterLoad";
1712
+ readonly SUBMIT: "submit";
1713
+ readonly FINISH: "finish";
1714
+ readonly VALIDATION_ERROR: "validationError";
1715
+ readonly SYSTEM_ERROR: "systemError";
1716
+ readonly ERROR: "error";
1717
+ /** @deprecated */
1718
+ readonly CHECKOUT_SUCCESS: "checkoutSuccess";
1719
+ readonly CHECKOUT_READY: "checkoutReady";
1720
+ readonly CHECKOUT_ERROR: "checkoutError";
1721
+ readonly CHECKOUT_COMPLETED: "checkoutCompleted";
1722
+ readonly CHECKOUT_POPUP_OPEN: "checkoutPopupOpen";
1723
+ readonly CHECKOUT_POPUP_CLOSE: "checkoutPopupClose";
1724
+ readonly RECOGNITION_TOKEN_REQUESTED: "recognitionTokenRequested";
1725
+ readonly RECOGNITION_TOKEN_DROPPED: "recognitionTokenDropped";
1726
+ readonly VALIDATION: "validation";
1727
+ readonly SELECT: "select";
1728
+ readonly UNSELECT: "unselect";
1729
+ readonly NEXT: "next";
1730
+ readonly PREV: "prev";
1731
+ readonly META_CHANGE: "metaChange";
1732
+ readonly RESIZE: "resize";
1733
+ readonly CHARGE_AUTH_SUCCESS: "chargeAuthSuccess";
1734
+ readonly CHARGE_AUTH_REJECT: "chargeAuthReject";
1735
+ readonly CHARGE_AUTH_CANCELLED: "chargeAuthCancelled";
1736
+ readonly ADDITIONAL_DATA_SUCCESS: "additionalDataCollectSuccess";
1737
+ readonly ADDITIONAL_DATA_REJECT: "additionalDataCollectReject";
1738
+ readonly CHARGE_AUTH: "chargeAuth";
1739
+ readonly DISPATCH_SUCCESS: "dispatchSuccess";
1740
+ readonly DISPATCH_ERROR: "dispatchError";
1741
+ };
1742
+ type EventTypes = typeof EVENT$1[keyof typeof EVENT$1];
1743
+ interface Listener {
1744
+ event: string;
1745
+ listener: (event: any) => void;
1746
+ widget_id: string;
1747
+ }
1748
+ declare type Listeners = Listener[];
1749
+ declare class IFrameEvent {
1750
+ protected listeners: Listeners;
1751
+ constructor(subject: Window | null);
1752
+ emit(data: IEventData$1): void;
1753
+ on<T>(eventName: string, widgetId: string, cb: (data: T) => void): void;
1754
+ clear(): void;
1755
+ private subscribe;
2049
1756
  }
2050
1757
 
2051
- interface ITriggerData {
2052
- configuration_token?: string;
2053
- tab_number?: number;
2054
- elements?: string;
2055
- form_values?: string;
1758
+ declare class EventEmitter {
1759
+ private events;
1760
+ emit<T>(eventName: string, data?: T): void;
1761
+ emitWithResult<T, R>(eventName: string, data?: T): Promise<R[]>;
1762
+ subscribe<T>(eventName: string, handler: (data: T) => void): () => void;
1763
+ }
1764
+
1765
+ declare class Standalone3dsService {
1766
+ protected container: Container;
1767
+ protected eventEmitter: EventEmitter;
1768
+ protected env: string;
1769
+ protected alias: string;
1770
+ constructor(container: Container, eventEmitter: any);
1771
+ load(token: string, options: {
1772
+ title: string;
1773
+ }): void;
1774
+ setEnv(env: string, alias?: string): void;
2056
1775
  }
1776
+
2057
1777
  /**
2058
- * Interface for classes that represent a trigger data.
2059
- * @interface ITriggerData
1778
+ * List of available token's content formats
1779
+ * @enum TOKEN_FORMAT
2060
1780
  *
2061
- * @param {string} [configuration_token]
2062
- * @param {string} [tab_number]
2063
- * @param {string} [elements]
2064
- * @param {string} [form_values]
2065
- * */
1781
+ * @type {object}
1782
+ * @param {string} HTML=html
1783
+ */
1784
+ declare enum TOKEN_FORMAT {
1785
+ HTML = "html",
1786
+ URL = "url",
1787
+ STANDALONE_3DS = "standalone_3ds"
1788
+ }
2066
1789
  /**
2067
- * List of available triggers
1790
+ * List of available event's name
1791
+ * @const EVENT
2068
1792
  *
2069
1793
  * @type {object}
2070
- * @param {string} SUBMIT_FORM=submit_form
2071
- * @param {string} CHANGE_TAB=tab
2072
- * @param {string} HIDE_ELEMENTS=hide_elements
2073
- * @param {string} SHOW_ELEMENTS=show_elements
2074
- * @param {string} REFRESH_CHECKOUT=refresh_checkout
2075
- * @param {string} UPDATE_FORM_VALUES=update_form_values
2076
- * @param {string} INIT_CHECKOUT=init_checkout
1794
+ * @param {string} CHARGE_AUTH_SUCCESS=chargeAuthSuccess
1795
+ * @param {string} CHARGE_AUTH_REJECT=chargeAuthReject
1796
+ * @param {string} ADDITIONAL_DATA_SUCCESS=additionalDataCollectSuccess
1797
+ * @param {string} ADDITIONAL_DATA_REJECT=additionalDataCollectReject
1798
+ * @param {string} CHARGE_AUTH=chargeAuth
2077
1799
  */
2078
- declare const TRIGGER: {
2079
- SUBMIT_FORM: string;
2080
- CHANGE_TAB: string;
2081
- HIDE_ELEMENTS: string;
2082
- SHOW_ELEMENTS: string;
2083
- REFRESH_CHECKOUT: string;
2084
- UPDATE_FORM_VALUES: string;
2085
- INIT_CHECKOUT: string;
2086
- };
2087
- declare class Trigger {
2088
- protected iFrame: IFrame;
2089
- constructor(iFrame: IFrame);
2090
- push(triggerName: string, data?: ITriggerData): void;
2091
- }
2092
-
2093
- declare class VaultDisplayIframeEvent extends IFrameEvent {
2094
- on<T>(eventName: string, widgetId: string, cb: (data: T) => void): void;
2095
- }
2096
-
2097
1800
  /**
2098
- * Class VaultDisplayWidget include method for working on html
1801
+ * List of available event's name for Standalone 3ds flow
1802
+ * @const STANDALONE_3DS_EVENT
1803
+ *
1804
+ * @type {object}
1805
+ * @param {string} CHARGE_AUTH_SUCCESS=chargeAuthSuccess
1806
+ * @param {string} CHARGE_AUTH_REJECT=chargeAuthReject
1807
+ * @param {string} CHARGE_AUTH_DECOUPLED=chargeAuthDecoupled
1808
+ * @param {string} CHARGE_AUTH_CHALLENGE=chargeAuthChallenge
1809
+ * @param {string} CHARGE_AUTH_INFO=chargeAuthInfo
1810
+ * @param {string} ERROR=error
1811
+ */
1812
+ /**
1813
+ * Class Canvas3ds include method for working on html
2099
1814
  * @constructor
2100
1815
  *
1816
+ * @param {string} selector - Selector of html element. Container for widget
1817
+ * @param {string} token - Pre authorized token
2101
1818
  * @example
2102
- * var widget = new VaultDisplayWidget('#widget', 'token');
1819
+ * var widget = new Canvas3ds('#widget', 'token');
1820
+ *
2103
1821
  *
2104
- * @param {string} selector - Selector of html element. Container for widget
2105
- * @param {string} token - One time token
2106
1822
  */
2107
- declare class VaultDisplayWidget {
1823
+ declare class Canvas3ds {
1824
+ protected link: Link;
1825
+ protected configs: Configuration[];
1826
+ protected publicKey: string;
1827
+ protected token: {
1828
+ content: string;
1829
+ format: TOKEN_FORMAT;
1830
+ charge_3ds_id: string;
1831
+ };
1832
+ protected standalone3dsService: Standalone3dsService;
2108
1833
  protected container: Container;
2109
1834
  protected iFrame: IFrame;
2110
- protected triggerElement: Trigger;
2111
- protected event: VaultDisplayIframeEvent;
2112
- protected validationData: IFormValidation;
2113
- protected vaultDisplayToken: string;
2114
- protected link: Link;
2115
- protected configs: any[];
1835
+ protected event: IFrameEvent;
1836
+ protected eventEmitter: EventEmitter;
2116
1837
  /** @constructs */ constructor(selector: string, token: string);
1838
+ protected static extractToken(token: string): {
1839
+ content: string;
1840
+ format: TOKEN_FORMAT;
1841
+ charge_3ds_id: string;
1842
+ };
1843
+ /**
1844
+ * The final method to beginning, the load process of widget to html
1845
+ *
1846
+ */
1847
+ load(): void;
2117
1848
  /**
2118
1849
  * Current method can change environment. By default environment = sandbox.
2119
1850
  * Also we can change domain alias for this environment. By default domain_alias = paydock.com
2120
1851
  *
2121
1852
  * @example
2122
- * widget.setEnv('production', 'paydock.com');
1853
+ * widget.setEnv('production');
2123
1854
  * @param {string} env - sandbox, production
2124
1855
  * @param {string} [alias] - Own domain alias
2125
1856
  */
2126
1857
  setEnv(env: string, alias?: string): void;
2127
- /**
2128
- * This callback will be called for each event in widget
2129
- *
2130
- * @callback listener
2131
- * @param {IEventData} response
2132
- */
1858
+ getEnv(): string;
2133
1859
  on(eventName: string): Promise<IEventData$1>;
2134
1860
  on(eventName: string, cb: (data: IEventData$1) => void): any;
2135
1861
  /**
2136
- * Object contain styles for widget
1862
+ * Using this method you can hide widget after load
1863
+ * @param {boolean} [saveSize=false] - using this param you can save iframe's size
1864
+ */
1865
+ hide(saveSize: boolean): void;
1866
+ /**
1867
+ * Using this method you can show widget after using hide method
2137
1868
  *
2138
- * @example
2139
- * widget.setStyles({
2140
- * background_color: '#fff',
2141
- * border_color: 'yellow',
2142
- * text_color: '#FFFFAA',
2143
- * button_color: 'rgba(255, 255, 255, 0.9)',
2144
- * font_size: '20px',
2145
- * fort_family: 'fantasy'
2146
- * });
2147
- * @param {VaultDisplayStyle} fields - name of styles which can be shown in widget [VAULT_DISPLAY_STYLE]{@link VAULT_DISPLAY_STYLE}
2148
1869
  */
2149
- setStyles(styles: IStyles$1): void;
2150
- setStyle(param: string, value: string): void;
1870
+ show(): void;
2151
1871
  /**
2152
- * The final method to beginning, the load process of widget to html
1872
+ * Using this method you can reload widget
2153
1873
  *
2154
1874
  */
2155
- load(): void;
1875
+ reload(): void;
2156
1876
  }
2157
1877
 
2158
- interface IWalletServiceUpdateData {
2159
- amount: number;
2160
- shipping_options?: IShippingOption[];
1878
+ /**
1879
+ * @type {object}
1880
+ * @param {string} CLICK=click
1881
+ * @param {string} POPUP_REDIRECT=popup_redirect
1882
+ * @param {string} ERROR=error
1883
+ * @param {string} ACCEPTED=accepted
1884
+ * @param {string} FINISH=finish
1885
+ * @param {string} CLOSE=close
1886
+ */
1887
+ declare const CHECKOUT_BUTTON_EVENT: {
1888
+ CLICK: string;
1889
+ POPUP_REDIRECT: string;
1890
+ REDIRECT: string;
1891
+ ERROR: string;
1892
+ REFERRED: string;
1893
+ DECLINED: string;
1894
+ CANCELLED: string;
1895
+ ACCEPTED: string;
1896
+ FINISH: string;
1897
+ CLOSE: string;
1898
+ };
1899
+ /**
1900
+ * @type {object}
1901
+ * @param {string} CONTEXTUAL=contextual
1902
+ * @param {string} REDIRECT=redirect
1903
+ */
1904
+ declare enum CHECKOUT_MODE {
1905
+ CONTEXTUAL = "contextual",
1906
+ REDIRECT = "redirect"
2161
1907
  }
2162
- interface IWalletServiceUpdate {
2163
- success: boolean;
2164
- body?: IWalletServiceUpdateData;
1908
+ /**
1909
+ * @type {object}
1910
+ * @param {string} ZIPMONEY=Zipmoney
1911
+ * @param {string} PAYPAL=PaypalClassic
1912
+ * @param {string} AFTERPAY=Afterpay
1913
+ */
1914
+ declare enum GATEWAY_TYPE {
1915
+ ZIPMONEY = "Zipmoney",
1916
+ PAYPAL = "PaypalClassic",
1917
+ AFTERPAY = "Afterpay"
2165
1918
  }
2166
- interface IPaymentMethod {
2167
- payment_method_id?: string;
2168
- device?: string;
2169
- customer: {
2170
- payer_name: string;
2171
- payer_email: string;
2172
- payer_phone: string;
2173
- payment_source: {
2174
- wallet_type: WALLET_TYPE;
2175
- card_name: string;
2176
- type: string;
2177
- card_scheme: string;
2178
- card_number_last4: string;
2179
- expire_month: number;
2180
- expire_year: number;
2181
- address_line1: string;
2182
- address_line2: string;
2183
- address_city: string;
2184
- address_postcode: string;
2185
- address_state: string;
2186
- address_country: string;
2187
- ref_token?: string;
2188
- };
2189
- };
2190
- shipping?: {
2191
- method?: string;
2192
- options?: IShippingOption[];
2193
- address_line1?: string;
2194
- address_line2?: string;
2195
- address_city?: string;
2196
- address_postcode?: string;
2197
- address_state?: string;
2198
- address_country?: string;
2199
- address_company?: string;
2200
- address_origin_postcode?: string;
2201
- contact?: {
2202
- first_name?: string;
2203
- last_name?: string;
2204
- email?: string;
2205
- phone?: string;
2206
- phone2?: string;
2207
- };
2208
- };
1919
+ interface IEventCheckoutFinishData {
1920
+ payment_source_token: string;
1921
+ checkout_email: string;
1922
+ checkout_holder: string;
1923
+ gateway_type: string;
2209
1924
  }
2210
- interface IUnavailableWalletEventBody {
1925
+
1926
+ /**
1927
+ * Class Background create overlay for checkout
1928
+ *
1929
+ * @example
1930
+ * var overlay = new Background();
1931
+ */
1932
+ declare class Background {
1933
+ protected description: string;
1934
+ protected title: string;
1935
+ protected overlay: HTMLElement;
1936
+ protected style: HTMLStyleElement;
1937
+ protected eventEmitter: EventEmitter;
1938
+ protected showControl: boolean;
1939
+ protected showLoader: boolean;
1940
+ constructor();
1941
+ initControl(): void;
1942
+ initLoader(): void;
1943
+ private eventHandler;
1944
+ clear(): void;
1945
+ private createLoader;
1946
+ protected createTemplate(): void;
1947
+ private createStyles;
1948
+ setBackdropDescription(text: string): void;
1949
+ setBackdropTitle(text: string): void;
1950
+ onTrigger(triggerName: string, cb: () => void): void;
1951
+ isInit(): boolean;
1952
+ hideContinueControl(): void;
1953
+ turnOffControl(): void;
1954
+ turnOffLoader(): void;
2211
1955
  }
2212
- interface IPaymentMethodSelectedWalletEventBody {
2213
- data: IPaymentMethod;
2214
- onSuccess: () => void;
2215
- onError: (message?: string) => void;
1956
+
1957
+ declare type SuccessCb = (data: any, status: number) => void;
1958
+ declare type ErrorCb = (err: any, status: number) => void;
1959
+ declare abstract class HttpCore {
1960
+ private env;
1961
+ constructor();
1962
+ setEnv(env: string, alias?: string): void;
1963
+ getEnv(): string;
1964
+ protected getUrl(): string;
1965
+ protected create(accessToken: string, data: any, cb: SuccessCb, errorCb: ErrorCb): void;
1966
+ protected get(accessToken: string, cb: SuccessCb, errorCb: ErrorCb): void;
1967
+ protected parser(text: any, status: number, cb: SuccessCb, errorCb: ErrorCb): void;
1968
+ protected abstract getLink(): string;
2216
1969
  }
2217
- interface IWalletService {
2218
- load(container: Container): Promise<void>;
2219
- close?(): void;
2220
- update(data: IWalletServiceUpdate): void;
2221
- enable(): void;
2222
- disable(): void;
2223
- setEnv(env: string): any;
2224
- on(eventName: string, cb?: (data: IUnavailableWalletEventBody | IPaymentMethodSelectedWalletEventBody | any) => void): any;
1970
+
1971
+ interface IBody$1 {
1972
+ gateway_id: string;
1973
+ success_redirect_url: string;
1974
+ error_redirect_url: string;
1975
+ redirect_url: string;
1976
+ meta: IPayPalMeta;
1977
+ description?: string;
1978
+ }
1979
+ interface ICheckout {
1980
+ gateway_id: string;
1981
+ checkout_type: string;
1982
+ gateway_type: string;
1983
+ link: string;
1984
+ reference_id: string;
1985
+ token: string;
1986
+ mode?: string;
1987
+ }
1988
+ declare class Builder$1 extends HttpCore {
1989
+ private body;
1990
+ constructor(gatewayID: string, successRedirectUrl: string, errorRedirectUrl: string);
1991
+ protected getLink(): string;
1992
+ setDescriptions(text: string): void;
1993
+ setMeta(meta: IPayPalMeta): void;
1994
+ getConfigs(): IBody$1;
1995
+ send(publicKey: string, cb: (checkout: ICheckout) => void, errorCb?: (error: any, code: string) => void): void;
2225
1996
  }
2226
1997
 
2227
- interface IWalletPaymentSuccessful {
2228
- id: string;
2229
- amount: number;
2230
- currency: string;
1998
+ interface IDetails {
1999
+ checkout_email: string;
2000
+ checkout_holder: string;
2231
2001
  status: string;
2232
- payer_name?: string;
2233
- payer_email?: string;
2234
- payer_phone?: string;
2002
+ gateway_type: string;
2235
2003
  }
2236
- interface IWalletUnavailable {
2237
- wallet?: WALLET_TYPE;
2004
+ declare class Checker extends HttpCore {
2005
+ token: string;
2006
+ constructor(token: string);
2007
+ protected getLink(): string;
2008
+ send(accessToken: string, cb: (details: IDetails) => void, errorCb?: (error: any) => void): void;
2009
+ }
2010
+
2011
+ type AdditionalParams = Record<string, string | number | boolean>;
2012
+ interface IRunner {
2013
+ next(checkoutData: ICheckout, params?: AdditionalParams): void;
2014
+ error(error: string, code: string, cb: (close: boolean) => void): void;
2015
+ getSuccessRedirectUri(): string;
2016
+ getErrorRedirectUri(): string;
2017
+ setEnv(env: string, alias?: string): void;
2238
2018
  }
2239
- interface IWalletOnClick {
2240
- attachResult: (result: Promise<void> | boolean) => void;
2019
+
2020
+ interface IDispatcherData {
2021
+ message_source: string;
2022
+ event: string;
2241
2023
  }
2242
- interface IWalletUpdate {
2243
- wallet_response_code?: string;
2244
- wallet_order_id?: string;
2245
- wallet_session_id?: string;
2246
- payment_source?: {
2247
- wallet_payment_method_id?: string;
2248
- card_number_last4?: string;
2249
- card_scheme?: string;
2250
- };
2251
- wallet_loyalty_account?: {
2252
- id?: string;
2253
- barcode?: string;
2254
- };
2255
- shipping?: {
2256
- address_line1?: string;
2257
- address_line2?: string;
2258
- address_postcode?: string;
2259
- address_city?: string;
2260
- address_state?: string;
2261
- address_country?: string;
2262
- address_company?: string;
2263
- post_office_box_number?: string;
2264
- wallet_address_id?: string;
2265
- wallet_address_name?: string;
2266
- wallet_address_created_timestamp?: string;
2267
- wallet_address_updated_timestamp?: string;
2268
- };
2269
- selected_shipping_option?: IShippingOption;
2024
+
2025
+ interface IContextualRunner extends IRunner {
2026
+ run(): void;
2027
+ isRunning(): boolean;
2028
+ continue(): void;
2029
+ stop(): void;
2030
+ onStop(cb: () => void): void;
2031
+ onCheckout<T extends IDispatcherData>(event: string, cb: (checkout: ICheckout, data?: T) => void): void;
2032
+ setBackgroundTitle(text: string): void;
2033
+ setBackgroundDescription(text: string): void;
2034
+ turnOffBackdrop(): void;
2035
+ setSuspendedRedirectUri(uri: string): void;
2270
2036
  }
2271
2037
 
2272
- interface IEventData {
2273
- event: string;
2274
- data: void | IWalletPaymentSuccessful | IWalletUpdate | IWalletUnavailable | IWalletOnClick | any;
2038
+ interface IRedirectRunner extends IRunner {
2039
+ setRedirectUrl(url: string): void;
2040
+ getRedirectUrl(): string;
2041
+ getProxyRedirectUrl(): string;
2275
2042
  }
2276
- interface IWalletUpdateData {
2277
- success: boolean;
2043
+
2044
+ interface CheckoutContextualHandlerParams {
2045
+ accessToken: string;
2046
+ gatewayId: string;
2047
+ }
2048
+ declare class CheckoutContextualHandler {
2049
+ protected background: Background;
2050
+ protected runner: IContextualRunner;
2051
+ protected eventEmitter: EventEmitter;
2052
+ protected params: CheckoutContextualHandlerParams;
2053
+ protected env: string;
2054
+ protected details: IDetails;
2055
+ constructor(background: Background, runner: IContextualRunner, eventEmitter: EventEmitter, params: CheckoutContextualHandlerParams);
2056
+ init(env: string): void;
2057
+ setEnv(env: string): void;
2058
+ protected checkToken(token: string, cb: () => void): void;
2059
+ protected createOneTimeToken(token: string): void;
2278
2060
  }
2061
+
2279
2062
  /**
2280
- * Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Flypay V2, Paypal, Afterpay)
2063
+ * Class CheckoutButton transform usual button into checkout
2064
+ *
2281
2065
  * @constructor
2282
2066
  *
2067
+ * @param {string} selector - Selector of html element.
2068
+ * @param {string} aceessToken - PayDock access token or users public key
2069
+ * @param {string} [gatewayId=default] - PayDock's gatewayId. By default or if put 'default', it will use the selected default gateway
2070
+ * @param {string} [type=PaypalClassic] - Type of gateway (PaypalClassic, Zipmoney)
2283
2071
  * @example
2284
- * var button = new WalletButtons('#wallet-buttons', 'charge-token', { amount_label: 'Total', country: 'us' });
2285
- *
2286
- * @param {string} selector - Selector of html element. Container for the WalletButtons.
2287
- * @param {string} chargeToken - token for the wallet transaction, created with a secure call to `POST charges/wallet`.
2288
- * @param {IWalletMeta} meta - data that configures the E-Wallet, which can be shown on checkout page and configures required customer information.
2072
+ * var widget = new CheckoutButton('#button', 'accessToken','gatewayId');
2289
2073
  */
2290
- declare class WalletButtons {
2291
- protected container: Container;
2292
- protected api: ApiInternal;
2293
- protected service: IWalletService;
2074
+ declare class CheckoutButton {
2075
+ protected accessToken: string;
2076
+ protected gatewayId: string;
2077
+ protected gatewayType: GATEWAY_TYPE;
2078
+ protected mode: CHECKOUT_MODE;
2079
+ protected window: Window;
2294
2080
  protected eventEmitter: EventEmitter;
2295
- protected hasUpdateHandler: boolean;
2296
- /** @constructs */ constructor(selector: string, chargeToken: string, meta: IWalletMeta);
2297
- /**
2298
- * Initializes the availability checks and inserts the button if possible.
2299
- * Otherwise function onUnavailable(handler: VoidFunction) will be called.
2300
- *
2301
- * @example
2302
- * var button = new WalletButtons(
2303
- * '#buttons',
2304
- * token,
2305
- * {
2306
- * amount_label: 'Total',
2307
- * country: 'DE',
2308
- * }
2309
- * );
2310
- * button.load();
2311
- */
2312
- load(): void;
2081
+ protected container: Container;
2082
+ protected meta: IPayPalMeta;
2083
+ protected runner: IContextualRunner | IRedirectRunner;
2084
+ protected background?: Background;
2085
+ protected checkoutHandler?: CheckoutContextualHandler;
2086
+ protected env: string;
2087
+ protected alias?: string;
2088
+ /** @constructs */ constructor(selector: string, accessToken: string, gatewayId?: string, gatewayType?: GATEWAY_TYPE, mode?: CHECKOUT_MODE);
2089
+ protected chooseRunner(gatewayType: GATEWAY_TYPE, mode: CHECKOUT_MODE): void;
2090
+ protected buildAdditionalParams(): AdditionalParams;
2091
+ protected initCheckout(container: Container): void;
2313
2092
  /**
2314
- * Triggers the update process of the wallet, if available.
2315
- * Currently supported by Flypay, Paypal and ApplePay/GooglePay via MPGS Wallets.
2316
- *
2317
- * @example
2318
- * var button = new WalletButtons(
2319
- * '#buttons',
2320
- * token,
2321
- * {
2322
- * amount_label: 'Total',
2323
- * country: 'DE',
2324
- * }
2325
- * );
2326
- * button.on('update', (data) => {
2327
- * updateChargeAmountInBackend(data);
2328
- * button.update({ success: true });
2329
- * });
2093
+ * This callback will be called for each event in payment source widget
2330
2094
  *
2331
- * @example
2332
- * // ApplePay via MPGS example:
2333
- * var button = new WalletButtons(
2334
- * '#buttons',
2335
- * token,
2336
- * {
2337
- * amount_label: 'Total',
2338
- * country: 'AU',
2339
- * ...
2340
- * }
2341
- * );
2342
- * button.on('update', (data) => {
2343
- * updateChargeAmountInBackend(data);
2344
- * button.update({
2345
- * success: true,
2346
- * body: {
2347
- * amount: 15,
2348
- * shipping_options: [
2349
- * {
2350
- * id: "NEW-FreeShip",
2351
- * label: "NEW - Free Shipping",
2352
- * detail: "Arrives in 3 to 5 days",
2353
- * amount: "0.00"
2354
- * },
2355
- * {
2356
- * id: "NEW - FastShip",
2357
- * label: "NEW - Fast Shipping",
2358
- * detail: "Arrives in less than 1 day",
2359
- * amount: "10.00"
2360
- * }
2361
- * ]
2362
- * }
2363
- * });
2364
- * });
2095
+ * @callback listener
2365
2096
  */
2366
- update(data: IWalletUpdateData): void;
2367
2097
  /**
2368
- * Current method can change environment. By default environment = sandbox.
2369
- * Also we can change domain alias for this environment. By default domain_alias = paydock.com
2370
- * Bear in mind that you must set an environment before calling `button.load()`.
2098
+ * Listen to events of widget
2371
2099
  *
2372
2100
  * @example
2373
- * button.setEnv('production', 'paydock.com');
2374
- * @param {string} env - sandbox, production
2375
- * @param {string} [alias] - Own domain alias
2376
- */
2377
- setEnv(env: string, alias?: string): void;
2378
- /**
2379
- * Current method can enable the payment button. This method is only supported for Flypay V2.
2380
2101
  *
2381
- * @example
2382
- * button.enable();
2383
- */
2384
- enable(): void;
2385
- /**
2386
- * Current method can disable the payment button. This method is only supported for Flypay V2.
2102
+ * widget.on('click', function () {
2387
2103
  *
2388
- * @example
2389
- * button.disable('production', 'paydock.com');
2104
+ * });
2105
+ * @param {string} eventName - Available event names [CHECKOUT_BUTTON_EVENT]{@link CHECKOUT_BUTTON_EVENT}
2106
+ * @param {listener} cb
2390
2107
  */
2391
- disable(): void;
2108
+ on<T = object>(name: string, handler: (data: T) => void): void;
2392
2109
  /**
2393
- * Closes the checkout forcibly. Currently supported in Flypay wallet.
2110
+ * Close popup window forcibly.
2111
+ * Only for 'contextual' mode.
2394
2112
  *
2395
- * @example
2396
- * button.close();
2397
2113
  */
2398
2114
  close(): void;
2399
- on(eventName: string): Promise<IEventData>;
2400
- on(eventName: string, cb: (data: IEventData) => void): any;
2401
- /**
2402
- * User to subscribe to the no button available event. This method is used after loading when the button is not available.
2403
- * For MPGS, since can have more than one wallet button configured (ApplePay/GooglePay) you will receive a body (({ wallet: WALLET_TYPE.GOOGLE }) or ({ wallet: WALLET_TYPE.APPLE })) indicating which button is unavailable
2404
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
2405
- *
2406
- * @example
2407
- * button.onUnavailable(() => {
2408
- * console.log('No wallet buttons available');
2409
- * });
2410
- *
2411
- * @example
2412
- * button.onUnavailable().then(() => console.log('No wallet buttons available'));
2413
- *
2414
- * @example
2415
- * button.onUnavailable(function (data) {console.log('data.wallet :: ', data.wallet)});
2416
- *
2417
- * @param {listener} [handler] - Function to be called when no button is available.
2418
- */
2419
- onUnavailable(handler?: (data: IEventData) => void): Promise<void> | (() => void);
2420
2115
  /**
2421
- * If the wallet performs some update in the checkout process, the function passed as parameter will be called.
2422
- *
2423
- * NOTE: make sure to call the `button.update(result)` method on handler completion.
2424
- *
2425
- * @example
2426
- * button.onUpdate((data) => {
2427
- * button.update({ success: true });
2428
- * });
2429
- *
2430
- * @example
2431
- * button.onUpdate().then((data) => throw new Error());
2116
+ * After finish event of checkout button, data (dataType) will be insert to input (selector)
2432
2117
  *
2433
- * @param {listener} [handler] - Function to be called when the payment was successful.
2118
+ * @param {string} selector - css selector . [] #
2119
+ * @param {string} dataType - data type of IEventCheckoutFinishData [IEventCheckoutFinishData]{@link #IEventCheckoutFinishData}.
2434
2120
  */
2435
- onUpdate(handler?: (data: IEventData) => void): Promise<unknown> | (() => void);
2121
+ onFinishInsert(selector: string, dataType: string): void;
2436
2122
  /**
2437
- * If the payment was successful, the function passed as parameter will be called.
2438
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
2439
- *
2440
- * @example
2441
- * button.onPaymentSuccessful((data) => {
2442
- * console.log('Payment successful!');
2443
- * });
2123
+ * Method for setting meta information for checkout page
2444
2124
  *
2445
2125
  * @example
2446
- * button.onPaymentSuccessful().then((data) => console.log('Payment successful!'));
2126
+ * button.setMeta({
2127
+ brand_name: 'paydock',
2128
+ reference: '15',
2129
+ email: 'wault@paydock.com'
2130
+ });
2447
2131
  *
2448
- * @param {listener} [handler] - Function to be called when the payment was successful.
2132
+ * @param {(IPayPalMeta|IAfterpayMeta|IZipmoneyMeta)} meta - Data which can be shown on checkout page [IPayPalMeta]{@link IPayPalMeta} [IZipmoneyMeta]{@link IZipmoneyMeta} [IAfterpayMeta]{@link IAfterpayMeta}
2449
2133
  */
2450
- onPaymentSuccessful(handler?: (data: IEventData) => void): Promise<unknown> | (() => void);
2134
+ setMeta(meta: IPayPalMeta | IAfterpayMeta | IZipmoneyMeta): void;
2451
2135
  /**
2452
- * If the payment was left in fraud review, the function passed as parameter will be called.
2453
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
2454
- *
2455
- * @example
2456
- * button.onPaymentInReview((data) => {
2457
- * console.log('Payment in fraud review');
2458
- * });
2136
+ * Method for setting backdrop description.
2137
+ * Only for 'contextual' mode.
2459
2138
  *
2460
2139
  * @example
2461
- * button.onPaymentInReview().then((data) => console.log('Payment in fraud review'));
2140
+ * button.setBackdropDescription('Custom description');
2462
2141
  *
2463
- * @param {listener} [handler] - Function to be called when the payment was left in fraud review status.
2142
+ * @param {string} text - description which can be shown in overlay of back side checkout page
2464
2143
  */
2465
- onPaymentInReview(handler?: (err: IEventData) => void): Promise<unknown> | (() => void);
2144
+ setBackdropDescription(text: string): void;
2466
2145
  /**
2467
- * If the payment was not successful, the function passed as parameter will be called.
2468
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
2469
- *
2470
- * @example
2471
- * button.onPaymentError((err) => {
2472
- * console.log('Payment not successful');
2473
- * });
2146
+ * Method for setting backdrop title.
2147
+ * Only for 'contextual' mode.
2474
2148
  *
2475
2149
  * @example
2476
- * button.onPaymentError().then((err) => console.log('Payment not successful'));
2150
+ * button.setBackdropTitle('Custom title');
2477
2151
  *
2478
- * @param {listener} [handler] - Function to be called when the payment was not successful.
2152
+ * @param {text} string - title which can be shown in overlay of back side checkout page
2479
2153
  */
2480
- onPaymentError(handler?: (err: IEventData) => void): Promise<unknown> | (() => void);
2154
+ setBackdropTitle(text: string): void;
2481
2155
  /**
2482
- * Registers a callback function to be invoked when authentication tokens are changed.
2483
- * This function allows you to respond to changes in authentication tokens, such as when a user logs in.
2484
- *
2485
- * @example
2486
- * button.onAuthTokensChanged((eventData) => {
2487
- * console.log('Authentication tokens changed:', eventData);
2488
- * });
2156
+ * Method for setting suspended redirect uri. Redirect after referred checkout.
2157
+ * Only for 'contextual' mode.
2489
2158
  *
2490
- * @example
2491
- * button.onAuthTokensChanged().then((eventData) => {
2492
- * console.log('Authentication tokens changed:', eventData);
2493
- * });
2159
+ * @param {uri} string - uri for redirect (by default)
2160
+ */
2161
+ setSuspendedRedirectUri(uri: string): void;
2162
+ /**
2163
+ * Method for setting the merchant redirect URL.
2164
+ * Merchant's customers redirect after successfull checkout.
2165
+ * Only for 'redirect' mode.
2494
2166
  *
2495
- * @param {listener} [handler] - Function to be called when authentication tokens are changed.
2167
+ * @param {url} string - redirect url
2496
2168
  */
2497
- onAuthTokensChanged(handler?: (err: IEventData) => void): Promise<unknown> | (() => void);
2169
+ setRedirectUrl(url: string): void;
2170
+ getSuccessRedirectUri(): string;
2498
2171
  /**
2499
- * Registers a callback function to be invoked when the wallet button gets clicked.
2500
- * There are two operational modes supported, Synchronous and Asynchronous.
2501
- * 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.
2502
- * When synchronous operations occur on the callback handler, attaching a boolean result via `attachResult` is optional to control the execution flow.
2503
- * Note this is supported for Paypal, GooglePay and ApplePay wallet buttons at the moment.
2172
+ * Method for disable backdrop on the page.
2173
+ * Only for 'contextual' mode.
2504
2174
  *
2505
2175
  * @example
2506
- * button.onClick((data) => {
2507
- * performValidationLogic();
2508
- * });
2176
+ * button.turnOffBackdrop();
2509
2177
  *
2510
- * @param {listener} handler - Function to be called when the wallet button is clicked.
2511
2178
  */
2512
- onClick(handler: (data: IEventData) => void): () => void;
2179
+ turnOffBackdrop(): void;
2180
+ protected turnOffControlBackdrop(): void;
2181
+ protected turnOffLoaderBackdrop(): void;
2182
+ setEnv(env: string, alias?: string): void;
2183
+ getEnv(): string;
2184
+ private getRunnerByMode;
2185
+ private assertMethodSupport;
2186
+ }
2187
+
2188
+ interface ZipmoneyRunnerParams extends AdditionalParams {
2189
+ gateway_id: string;
2190
+ public_key: string;
2191
+ }
2192
+
2193
+ /**
2194
+ * Class ZipmoneyCheckoutButton is wrapper of CheckoutButton transform usual button into checkout
2195
+ *
2196
+ * @extends CheckoutButton
2197
+ *
2198
+ * @constructor
2199
+ *
2200
+ * @param {string} selector - Selector of html element.
2201
+ * @param {string} publicKey - PayDock users public key
2202
+ * @param {string} [gatewayId=default] - PayDock's gatewayId. By default or if put 'default', it will use the selected default gateway
2203
+ * @param {string} [gatewayId=default] - Checkout mode, it could be set to 'contextual' or 'redirect'. By default it 'contextual'
2204
+ * @example
2205
+ * var widget = new ZipmoneyCheckoutButton('#button', 'publicKey','gatewayId');
2206
+ */
2207
+ declare class ZipmoneyCheckoutButton extends CheckoutButton {
2208
+ protected publicKey: string;
2209
+ protected gatewayId: string;
2210
+ protected mode: CHECKOUT_MODE;
2211
+ /** @constructs */ constructor(selector: string, publicKey: string, gatewayId?: string, mode?: CHECKOUT_MODE);
2513
2212
  /**
2514
- * Registers a callback function to be invoked when the wallet checkout opens.
2515
- * Note this is supported for FlypayV2 wallet button at the moment.
2213
+ * Method for setting suspended redirect uri. Redirect after referred checkout
2516
2214
  *
2517
- * @example
2518
- * button.onCheckoutOpen((data) => {
2519
- * console.log('Checkout opens');
2520
- * });
2215
+ * The URI is used for a redirect after the checkout is complete.
2216
+ * This can be provided, even if using in-context checkout (sdk). By default, the standard styled page will be used.
2217
+ * If using in-context (sdk) we will not automatically redirect to this URI.
2521
2218
  *
2522
- * @param {listener} handler - Function to be called when the wallet checkout opens.
2219
+
2220
+ * @param {uri} string - uri for suspended redirect (by default)
2523
2221
  */
2524
- onCheckoutOpen(handler?: (err: IEventData) => void): Promise<unknown> | (() => void);
2222
+ setSuspendedRedirectUri(uri: string): void;
2525
2223
  /**
2526
- * Registers a callback function to be invoked when the wallet checkout closes.
2527
- * Note this is supported for FlypayV2 wallet button at the moment.
2224
+ * Method for setting the merchant redirect URL.
2225
+ * The merchant's customers would be redirected to the specified URL
2226
+ * at the end of ZipMoney checkout flow.
2528
2227
  *
2529
- * @example
2530
- * button.onCheckoutClose(() => {
2531
- * console.log('Wallet checkout closes');
2532
- * });
2228
+ * Once the redirect URL would be set, the checkout flow would be immediately switched
2229
+ * from 'contextual' mode to the 'redirect' mode.
2230
+ * The merchant's customer would be automatically redirected to this URL after the checkout is complete.
2533
2231
  *
2534
- * @param {listener} handler - Function to be called when the wallet checkout closes.
2232
+ * @param {url} string - URL for redirect
2535
2233
  */
2536
- onCheckoutClose(handler?: (err: IEventData) => void): Promise<unknown> | (() => void);
2537
- private setupServiceCallbacks;
2538
- private setupUnavailableCallback;
2539
- private setupUpdateCallback;
2540
- private setupOnClickCallback;
2541
- private setupOnCheckoutOpenCallback;
2542
- private setupOnCheckoutCloseCallback;
2543
- private setupWalletCallback;
2544
- private setupPaymentCallback;
2545
- private setupPaymentSuccessCallback;
2546
- private setupPaymentInReviewCallback;
2547
- private setupPaymentErrorCallback;
2548
- private setupAuthTokensChangedCallback;
2234
+ setRedirectUrl(url: string): void;
2235
+ protected buildAdditionalParams(): ZipmoneyRunnerParams;
2549
2236
  }
2550
2237
 
2551
2238
  /**
2552
- * Current constant include available type of element for styling
2553
- * @const STYLABLE_ELEMENT
2554
- * @type {object}
2555
- * @param {string} INPUT=input.
2556
- * These states are available: [STYLABLE_ELEMENT_STATE.ERROR]{@link STYLABLE_ELEMENT_STATE}, [STYLABLE_ELEMENT_STATE.FOCUS]{@link STYLABLE_ELEMENT_STATE}.
2557
- * These styles are available [IElementStyleInput]{@link IElementStyleInput}
2558
- * @param {string} SUBMIT_BUTTON=submit_button
2559
- * These states are available: [STYLABLE_ELEMENT_STATE.HOVER]{@link STYLABLE_ELEMENT_STATE}.
2560
- * These styles are available [IElementStyleSubmitButton]{@link IElementStyleSubmitButton}
2561
- * @param {string} LABEL=label.
2562
- * These styles are available [IElementStyleLabel]{@link IElementStyleLabel}
2563
- * @param {string} TITLE=title.
2564
- * These styles are available [IElementStyleTitle]{@link IElementStyleTitle}
2565
- * @param {string} TITLE_DESCRIPTION=title_description.
2566
- * These styles are available [IElementStyleTitleDescription]{@link IElementStyleTitleDescription}
2567
- * */
2568
- declare const STYLABLE_ELEMENT: {
2569
- INPUT: string;
2570
- SUBMIT_BUTTON: string;
2571
- LABEL: string;
2572
- TITLE: string;
2573
- TITLE_DESCRIPTION: string;
2574
- };
2575
- /**
2576
- * Current constant include available states of element for styling
2577
- * @const STYLABLE_ELEMENT_STATE
2578
- * @type {object}
2579
- * @param {string} ERROR=error client|server validation. This state applies to: input
2580
- * @param {string} FOCUS=focus focus. This state applies to: input
2581
- * @param {string} HOVER=hover focus. This state applies to: submit_button
2582
- * */
2583
- declare const STYLABLE_ELEMENT_STATE: {
2584
- ERROR: string;
2585
- FOCUS: string;
2586
- HOVER: string;
2587
- };
2588
- interface IElementStyleInput {
2589
- color?: string;
2590
- border?: string;
2591
- border_radius?: string;
2592
- background_color?: string;
2593
- height?: string;
2594
- text_decoration?: string;
2595
- font_size?: string;
2596
- font_family?: string;
2597
- padding?: string;
2598
- margin?: string;
2599
- transition?: string;
2600
- line_height?: string;
2601
- font_weight?: string;
2602
- }
2603
- interface IElementStyleSubmitButton {
2604
- color?: string;
2605
- border?: string;
2606
- border_radius?: string;
2607
- background_color?: string;
2608
- text_decoration?: string;
2609
- font_size?: string;
2610
- font_family?: string;
2611
- padding?: string;
2612
- margin?: string;
2613
- transition?: string;
2614
- line_height?: string;
2615
- font_weight?: string;
2616
- opacity?: string;
2617
- }
2618
- interface IElementStyleLabel {
2619
- color?: string;
2620
- text_decoration?: string;
2621
- font_size?: string;
2622
- font_family?: string;
2623
- line_height?: string;
2624
- font_weight?: string;
2625
- padding?: string;
2626
- margin?: string;
2627
- }
2628
- interface IElementStyleTitle {
2629
- color?: string;
2630
- text_decoration?: string;
2631
- font_size?: string;
2632
- font_family?: string;
2633
- line_height?: string;
2634
- font_weight?: string;
2635
- padding?: string;
2636
- margin?: string;
2637
- }
2638
- interface IElementStyleTitleDescription {
2639
- color?: string;
2640
- text_decoration?: string;
2641
- font_size?: string;
2642
- font_family?: string;
2643
- line_height?: string;
2644
- font_weight?: string;
2645
- padding?: string;
2646
- margin?: string;
2239
+ * Class AfterpayCheckoutButton is wrapper of CheckoutButton transform usual button into checkout
2240
+ *
2241
+ * @extends CheckoutButton
2242
+ *
2243
+ * @constructor
2244
+ *
2245
+ * @param {string} selector - Selector of html element.
2246
+ * @param {string} accessToken - PayDock access-token or users public key
2247
+ * @param {string} [gatewayId=default] - PayDock's gatewayId. By default or if put 'default', it will use the selected default gateway
2248
+ * @example
2249
+ * var widget = new AfterpayCheckoutButton('#button', 'access-token','gatewayId');
2250
+ */
2251
+ declare class AfterpayCheckoutButton extends CheckoutButton {
2252
+ protected accessToken: string;
2253
+ protected gatewayId: string;
2254
+ protected showETP: boolean;
2255
+ /** @constructs */ constructor(selector: string, accessToken: string, gatewayId?: string);
2256
+ /**
2257
+ * Method which toggles the "Enhanced Tracking Protection" warning popup to 'on' mode.
2258
+ *
2259
+ * This popup with a warning about "Enhanced Tracking Protection" limitations
2260
+ * would be shown in the Mozilla Firefox browser version 100+
2261
+ *
2262
+ * By default, the popup would not be shown, until
2263
+ * the flag would be set to `true`
2264
+
2265
+ * @param {doShow} boolean - flag which toggle the popup visibility
2266
+ */
2267
+ showEnhancedTrackingProtectionPopup(doShow: boolean): void;
2268
+ protected buildAdditionalParams(): AdditionalParams;
2647
2269
  }
2648
2270
 
2649
2271
  /**
2272
+ * Class PaypalCheckoutButton is wrapper of CheckoutButton transform usual button into checkout
2650
2273
  *
2651
- * Class MultiWidget include method for for creating iframe url
2652
- * @constructor
2274
+ * @extends CheckoutButton
2653
2275
  *
2654
- * @param {string} accessToken - PayDock users access token or public key
2655
- * @param {(Configuration | string | Configuration[] | string[])} conf - exemplar[s] Configuration class OR configuration token
2276
+ * @constructor
2656
2277
  *
2278
+ * @param {string} selector - Selector of html element.
2279
+ * @param {string} publicKey - PayDock users public key
2280
+ * @param {string} [gatewayId=default] - PayDock's gatewayId. By default or if put 'default', it will use the selected default gateway
2657
2281
  * @example
2658
- * var widget = new MultiWidget('accessToken','configurationToken'); // With a pre-created configuration token
2282
+ * var widget = new PaypalCheckoutButton('#button', 'publicKey','gatewayId');
2283
+ */
2284
+ declare class PaypalCheckoutButton extends CheckoutButton {
2285
+ protected publicKey: string;
2286
+ protected gatewayId: string;
2287
+ /** @constructs */ constructor(selector: string, publicKey: string, gatewayId?: string);
2288
+ }
2289
+
2290
+ /**
2659
2291
  *
2660
- * var widget = new MultiWidget('accessToken',['configurationToken', 'configurationToken2']); // With pre-created configuration tokens
2292
+ * Class PaymentSourceWidget include method for for creating iframe url
2293
+ * @constructor
2661
2294
  *
2662
- * var widget = new MultiWidget('accessToken', new Configuration('gatewayId')); With Configuration
2295
+ * @param {string} publicKey - PayDock users public key
2296
+ * @param {string} customer - PayDock's customer_id or customer_reference (In order to use the customer_reference, you must explicitly specify useReference as true)
2297
+ * @param {boolean} [useReference=false]
2663
2298
  *
2664
- * var widget = new MultiWidget('accessToken',[ With Configurations
2665
- * Configuration('gatewayId'),
2666
- * Configuration('gatewayId', 'bank_account')
2667
- * ]);
2299
+ * @example
2300
+ * var widget = new PaymentSourceWidget('publicKey','customerId');
2301
+ * // or
2302
+ * var widget = new PaymentSourceWidget('publicKey', customerReference, true);
2668
2303
  */
2669
- declare class MultiWidget {
2304
+ declare class PaymentSourceWidget {
2670
2305
  protected link: Link;
2671
2306
  protected configs: Configuration[];
2672
2307
  protected configTokens: string[];
2673
- protected accessToken: string;
2674
- constructor(accessToken: string, confTokens: string[]);
2675
- constructor(accessToken: string, confToken: string);
2676
- constructor(accessToken: string, configs: Configuration[]);
2677
- constructor(accessToken: string, conf: Configuration);
2308
+ protected publicKey: string;
2309
+ /** @constructs */ constructor(accessToken: string, queryToken: string);
2678
2310
  /**
2679
2311
  * Object contain styles for widget
2680
2312
  *
@@ -2683,623 +2315,1075 @@ declare class MultiWidget {
2683
2315
  * background_color: 'rgb(0, 0, 0)',
2684
2316
  * border_color: 'yellow',
2685
2317
  * text_color: '#FFFFAA',
2686
- * button_color: 'rgba(255, 255, 255, 0.9)',
2318
+ * icon_size: 'small',
2687
2319
  * font_size: '20px'
2688
- * fort_family: 'fantasy'
2689
2320
  * });
2690
2321
  * @param {IStyles} fields - name of styles which can be shown in widget [STYLE]{@link STYLE}
2691
2322
  */
2692
2323
  setStyles(styles: IStyles$1): void;
2324
+ setStyle(param: string, value: string): void;
2693
2325
  /**
2694
- * Method to set a country code mask for the phone input.
2326
+ * Current method can set custom ID to identify the data in the future
2695
2327
  *
2696
2328
  * @example
2697
- * widget.usePhoneCountryMask();
2329
+ * widget.setRefId('id');
2330
+ *
2331
+ * @param {string} refId - custom id
2332
+ */
2333
+ setRefId(refId: string): void;
2334
+ /**
2335
+ * Current method can set limit for payment sources count. In case when limit sets less then general count will be shown pagination buttons prev and next.
2336
+ *
2337
+ * @param {string} count - payment source count
2338
+ */
2339
+ setLimit(count: number): void;
2340
+ /**
2341
+ * Current method can change environment. By default environment = sandbox
2342
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
2698
2343
  *
2699
2344
  * @example
2700
- * widget.usePhoneCountryMask({
2701
- * default_country: 'au',
2702
- * preferred_countries: ['au', 'gb'],
2703
- * only_countries: ['au', 'gb', 'us', 'ua']
2704
- * });
2345
+ * widget.setEnv('production');
2346
+ * @param {string} env - sandbox, production
2347
+ * @param {string} [alias] - Own domain alias
2348
+ */
2349
+ setEnv(env: string, alias?: string): void;
2350
+ getEnv(): void;
2351
+ /**
2352
+ * Method for getting iframe's url
2353
+ */
2354
+ getIFrameUrl(): string;
2355
+ /**
2356
+ * Show payment source inside widget only with requested gateway ids
2705
2357
  *
2706
- * @param {object} [options] - Options for configure the phone mask.
2707
- * @param {string} [options.default_country] - Set a default country for the mask.
2708
- * @param {Array.<string>} [options.preferred_countries] - Set list of preferred countries for the top of the select box .
2709
- * @param {Array.<string>} [options.only_countries] - Set list of countries to show in the select box.
2358
+ *
2359
+ * @param {string[]} ids - List of gateway_id
2710
2360
  */
2711
- usePhoneCountryMask(options?: ICountryPhoneMask): void;
2712
- setStyle(param: string, value: string): void;
2361
+ filterByGatewayIds(ids: string[]): void;
2713
2362
  /**
2714
- * Method for set different texts inside the widget
2363
+ *
2364
+ * Show payment source inside widget only with requested payment source types
2365
+ *
2366
+ * @param types - List of payment source types. Available parameters [PAYMENT_TYPE]{@link PAYMENT_TYPE}
2367
+ */
2368
+ filterByTypes(types: string[]): void;
2369
+ /**
2370
+ * Method for setting a custom language code
2715
2371
  *
2716
2372
  * @example
2717
- * widget.setTexts({
2718
- * title: 'Your card',
2719
- * finish_text: 'Payment resource was successfully accepted',
2720
- * title_description: '* indicates required field',
2721
- * submit_button: 'Save',
2722
- * submit_button_processing: 'Load...',
2723
- * });
2373
+ * config.setLanguage('en');
2374
+ * @param {string} code - ISO 639-1
2375
+ */
2376
+ setLanguage(code: any): void;
2377
+ }
2378
+
2379
+ interface IEventSelectData extends IEventData$1 {
2380
+ customer_id: string;
2381
+ payment_source_id: string;
2382
+ gateway_id: string;
2383
+ primary: boolean;
2384
+ card_number_last4?: string;
2385
+ card_scheme?: string;
2386
+ checkout_email?: string;
2387
+ gateway_type?: string;
2388
+ payment_source_type: string;
2389
+ account_name?: string;
2390
+ account_number?: string;
2391
+ }
2392
+ interface IEventPaginationData extends IEventData$1 {
2393
+ total_item: number;
2394
+ skip: number;
2395
+ limit: number;
2396
+ }
2397
+ interface IEventAfterLoadData extends IEventData$1 {
2398
+ total_item: number;
2399
+ skip: number;
2400
+ limit: number;
2401
+ }
2402
+ interface IEventSizeData extends IEventData$1 {
2403
+ height: number;
2404
+ width: number;
2405
+ }
2406
+ /**
2407
+ * Interface of data from event.
2408
+ *
2409
+ * @interface IEventSelectData
2410
+ *
2411
+ * @param {string} event
2412
+ * @param {string} purpose
2413
+ * @param {string} message_source
2414
+ * @param {string} [ref_id]
2415
+ * @param {string} customer_id
2416
+ * @param {string} payment_source_id
2417
+ * @param {string} gateway_id
2418
+ * @param {boolean} primary
2419
+ * @param {string} [widget_id]
2420
+ * @param {string} [card_number_last4]
2421
+ * @param {string} [card_scheme]
2422
+ * @param {string} gateway_type
2423
+ * @param {string} [checkout_email]
2424
+ * @param {string} payment_source_type
2425
+ * @param {string} [account_name]
2426
+ * @param {string} [account_number]
2427
+ * */
2428
+ /**
2429
+ * Interface of data from event.
2430
+ *
2431
+ * @interface IEventPaginationData
2432
+ *
2433
+ * @param {string} event
2434
+ * @param {string} purpose
2435
+ * @param {string} message_source
2436
+ * @param {string} [ref_id]
2437
+ * @param {number} total_item
2438
+ * @param {number} skip
2439
+ * @param {number} limit
2440
+ * */
2441
+ /**
2442
+ * Interface of data from event.
2443
+ *
2444
+ * @interface IEventAfterLoadData
2445
+ *
2446
+ * @param {string} event The name of the event.
2447
+ * @param {string} purpose A system variable that states the purpose of the event.
2448
+ * @param {string} message_source A system variable that identifies the event source.
2449
+ * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
2450
+ * @param {number} total_item Pagination param. Total item count
2451
+ * @param {number} skip Pagination param. Skip items from first item
2452
+ * @param {number} limit Pagination param. Query limit
2453
+ * */
2454
+ /**
2455
+ * Interface of data from event.
2456
+ * @interface IEventFinishData
2457
+ *
2458
+ * @param {string} event The name of the event.
2459
+ * @param {string} purpose A system variable that states the purpose of the event.
2460
+ * @param {string} message_source A system variable that identifies the event source.
2461
+ * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
2462
+ * */
2463
+ /**
2464
+ * Interface of data from event.
2465
+ * @interface IEventSizeData
2466
+ *
2467
+ * @param {number} event The name of the event.
2468
+ * @param {number} purpose A system variable that states the purpose of the event.
2469
+ * @param {string} message_source A system variable that identifies the event source.
2470
+ * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
2471
+ * @param {number} height Height of iFrame
2472
+ * @param {number} width Width of iFrame
2473
+ * */
2474
+ /**
2475
+ * List of available event's name
2476
+ *
2477
+ * @const EVENT
2478
+ *
2479
+ * @type {object}
2480
+ * @param {string} AFTER_LOAD=afterLoad
2481
+ * @param {string} SYSTEM_ERROR=systemError
2482
+ * @param {string} SELECT=select
2483
+ * @param {string} UNSELECT=unselect
2484
+ * @param {string} NEXT=next
2485
+ * @param {string} PREV=prev
2486
+ * @param {string} META_CHANGE=metaChange
2487
+ * @param {string} RESIZE=resize
2488
+ */
2489
+ /**
2490
+ * Class HtmlPaymentSourceWidget include method for working on html
2491
+ * @constructor
2492
+ * @extends PaymentSourceWidget
2493
+ *
2494
+ * @param {string} selector - Selector of html element. Container for widget
2495
+ * @param {string} publicKey - PayDock users public key
2496
+ * @param {string} queryToken - PayDock's query token that represents params to search customer by id or reference
2497
+ * @example
2498
+ * * var widget = new HtmlPaymentSourceWidget('#widget', 'publicKey','queryToken');
2499
+
2500
+ */
2501
+ declare class HtmlPaymentSourceWidget extends PaymentSourceWidget {
2502
+ protected container: Container;
2503
+ protected iFrame: IFrame;
2504
+ protected event: IFrameEvent;
2505
+ /** @constructs */ constructor(selector: string, publicKey: string, queryToken: string);
2506
+ /**
2507
+ * The final method to beginning, the load process of widget to html
2724
2508
  *
2725
- * @param {ITexts} fields - name of text items which can be shown in widget [TEXT]{@link TEXT}
2726
2509
  */
2727
- setTexts(texts: ITexts): void;
2728
- setText(param: string, value: string): void;
2729
- setElementStyle(element: string, state: string, styles: IElementStyleInput | IElementStyleSubmitButton | IElementStyleLabel): any;
2730
- setElementStyle(element: string, styles: IElementStyleInput | IElementStyleSubmitButton | IElementStyleLabel | IElementStyleTitle | IElementStyleTitleDescription): any;
2731
- /**
2732
- * The method to set the predefined values for the form fields inside the widget
2733
- *
2734
- * @example
2735
- * widget.setFormValues({
2736
- * email: 'predefined@email.com',
2737
- * card_name: 'Houston'
2738
- * });
2739
- *
2740
- * @param { Object } fieldValues - Key of object is one of [FORM_FIELD]{@link FORM_FIELD}, The object value is what we are expecting
2741
- */
2742
- setFormValues(fieldValues: IFormValues): void;
2743
- setFormValue(key: string, value: string): void;
2510
+ load(): void;
2744
2511
  /**
2745
- * The method to set custom form field labels
2746
- *
2747
- * @example
2748
- * widget.setFormPlaceholders({
2749
- * card_name: 'Card Holder Name',
2750
- * email: 'Email For Receipt'
2751
- * })
2512
+ * This callback will be called for each event in payment source widget
2752
2513
  *
2753
- * @param { Object } fieldLabels - Key of object is one of [FORM_FIELD]{@link FORM_FIELD}, The object value is what we are expecting
2514
+ * @callback listener--PaymentSourceWidget
2515
+ * @param {IEventData | IEventSelectData | IEventPaginationData | IEventAfterLoadData} response
2754
2516
  */
2755
- setFormLabels(fieldLabels: IFormLabels): void;
2756
- setFormLabel(key: string, label: string): void;
2757
2517
  /**
2758
- * The method to set custom form fields placeholders
2518
+ * Listen to events of widget
2759
2519
  *
2760
2520
  * @example
2761
- * widget.setFormPlaceholders({
2762
- * card_name: 'Input your card holder name...',
2763
- * email: 'Input your email, like test@example.com'
2764
- * })
2765
2521
  *
2766
- * @param { Object } fieldPlaceholders - Key of object is one of [FORM_FIELD]{@link FORM_FIELD}, Value of object is expected placeholder
2522
+ * widget.on('select', function (data) {
2523
+ * console.log(data);
2524
+ * });
2525
+ * @param {string} eventName - Available event names [EVENT]{@link EVENT}
2526
+ * @param {listener--PaymentSourceWidget} cb
2767
2527
  */
2768
- setFormPlaceholders(fieldPlaceholders: IFormPlaceholders): void;
2769
- setFormPlaceholder(key: string, placeholder: string): void;
2528
+ on(eventName: string, cb: (data: IEventData$1 | IEventSelectData | IEventPaginationData | IEventAfterLoadData | IEventSizeData) => void): void;
2770
2529
  /**
2771
- * The method to set the full configuration for the all specific form elements (label, placeholder, value)
2772
- * You can also use the other method for the partial configuration like: setFormValues, setFormPlaceholder, setFormLabel
2530
+ * Using this method you can hide widget after load
2531
+ * @param {boolean} [saveSize=false] - using this param you can save iframe's size
2532
+ */
2533
+ hide(saveSize: boolean): void;
2534
+ /**
2535
+ * Using this method you can show widget after using hide method
2773
2536
  *
2774
- * @example
2775
- * widget.setFormElements([
2776
- * {
2777
- * field: 'card_name',
2778
- * placeholder: 'Input your card holder name...',
2779
- * label: 'Card Holder Name',
2780
- * value: 'Houston',
2781
- * },
2782
- * {
2783
- * field: 'email',
2784
- * placeholder: 'Input your email, like test@example.com',
2785
- * label: 'Email For Receipt',
2786
- * value: 'predefined@email.com',
2787
- * },
2788
- * ])
2537
+ */
2538
+ show(): void;
2539
+ /**
2540
+ * Using this method you can reload widget
2789
2541
  *
2790
- * @param { string } elements - The list of elements
2791
- * @param { string } elements[].field - Field name of the element [FORM_FIELD]{@link FORM_FIELD}
2792
- * @param { string } elements[].placeholder - Set custom form field placeholder
2793
- * @param { string } elements[].label - Set custom labels near form field
2794
- * @param { string } elements[].value - Set predefined values for the form field
2795
2542
  */
2796
- setFormElements(elements: IFormElement[]): void;
2797
- setFormElement(element: IFormElement): void;
2543
+ reload(): void;
2798
2544
  /**
2799
- * The method to change the widget icons
2545
+ * After select event of widget, data (dataType) will be insert to input (selector)
2800
2546
  *
2801
- * @deprecated
2547
+ * @param {string} selector - css selector . [] #
2548
+ * @param {string} dataType - data type of [IEventSelectData]{@link IEventSelectData}.
2802
2549
  */
2803
- setIcons(icons: IIcons): void;
2804
- setIcon(key: string, value: string): void;
2550
+ onSelectInsert(selector: string, dataType: string): void;
2551
+ }
2552
+
2553
+ declare const TYPE: {
2554
+ EXTERNAL_CHECKOUT_TOKEN: string;
2555
+ CHECKOUT_TOKEN: string;
2556
+ BANK_ACCOUNT: string;
2557
+ CARD: string;
2558
+ };
2559
+ interface IBody {
2560
+ gateway_id: string;
2561
+ type: string;
2562
+ checkout_token?: string;
2563
+ }
2564
+ declare class Builder extends HttpCore {
2565
+ private body;
2566
+ constructor(gatewayID: string, checkoutToken: string, type: string);
2567
+ constructor(gatewayID: string, externalCheckoutToken: string, type: string);
2568
+ constructor(gatewayID: string, card: any, type: string);
2569
+ constructor(gatewayID: string, bankAccount: any, type: string);
2570
+ protected getLink(): string;
2571
+ send(accessToken: string, cb: (token: string) => void, errorCb?: (error: any) => void): void;
2572
+ getConfigs(): IBody;
2573
+ }
2574
+
2575
+ interface IBaseSRCMeta {
2576
+ customizations?: IStyles;
2577
+ dpa_data?: {
2578
+ dpa_presentation_name?: string;
2579
+ dpa_uri?: string;
2580
+ };
2581
+ dpa_transaction_options?: {
2582
+ dpa_locale?: string;
2583
+ dpa_accepted_billing_countries?: string[];
2584
+ consumer_name_requested?: boolean;
2585
+ consumer_email_address_requested?: boolean;
2586
+ consumer_phone_number_requested?: boolean;
2587
+ transaction_amount?: {
2588
+ transaction_amount?: number;
2589
+ transaction_currency_code?: string;
2590
+ };
2591
+ merchant_order_id?: string;
2592
+ merchant_category_code?: string;
2593
+ merchant_country_code?: string;
2594
+ };
2595
+ }
2596
+ interface PhoneNumber {
2597
+ country_code: string;
2598
+ phone_number: string;
2599
+ }
2600
+ interface Customer {
2601
+ email?: string;
2602
+ phone?: {
2603
+ country_code?: string;
2604
+ phone?: string;
2605
+ };
2606
+ first_name?: string;
2607
+ last_name?: string;
2608
+ }
2609
+ interface IClickToPayMeta extends IBaseSRCMeta {
2610
+ dpa_data?: IBaseSRCMeta['dpa_data'] & {
2611
+ dpa_address?: string;
2612
+ dpa_email_address?: string;
2613
+ dpa_phone_number?: PhoneNumber;
2614
+ dpa_logo_uri?: string;
2615
+ dpa_supported_email_address?: string;
2616
+ dpa_supported_phone_number?: PhoneNumber;
2617
+ dpa_uri?: string;
2618
+ dpa_support_uri?: string;
2619
+ application_type?: 'WEB_BROWSER' | 'MOBILE_APP';
2620
+ };
2621
+ disable_summary_screen?: boolean;
2622
+ co_brand_names?: string[];
2623
+ checkout_experience?: 'WITHIN_CHECKOUT' | 'PAYMENT_SETTINGS';
2624
+ services?: 'INLINE_CHECKOUT' | 'INLINE_INSTALLMENTS';
2625
+ dpa_transaction_options?: IBaseSRCMeta['dpa_transaction_options'] & {
2626
+ dpa_billing_preference?: MASTERCARD_DPA_SHIPPING_BILLING_PREFERENCE;
2627
+ payment_options?: Array<{
2628
+ dynamic_data_type?: string;
2629
+ }>;
2630
+ order_type?: MASTERCARD_ORDER_TYPE;
2631
+ three_ds_preference?: string;
2632
+ confirm_payment?: boolean;
2633
+ };
2634
+ customer?: Customer;
2635
+ unaccepted_card_type?: 'CREDIT' | 'DEBIT';
2636
+ recognition_token?: string;
2637
+ }
2638
+ type MASTERCARD_DPA_SHIPPING_BILLING_PREFERENCE = 'FULL' | 'POSTAL_COUNTRY' | 'NONE';
2639
+ type MASTERCARD_ORDER_TYPE = 'SPLIT_SHIPMENT' | 'PREFERRED_CARD';
2640
+ interface IStyles {
2641
+ primary_button_color?: string;
2642
+ secondary_button_color?: string;
2643
+ primary_button_text_color?: string;
2644
+ secondary_button_text_color?: string;
2645
+ font_family?: string;
2646
+ enable_src_popup?: boolean;
2647
+ }
2648
+
2649
+ declare class ApiChargeInternal {
2650
+ protected api: ApiInternal;
2651
+ constructor(api: ApiInternal);
2652
+ walletCapture(payload: WalletCaptureBody): Promise<WalletCaptureResponse>;
2653
+ walletCallback(payload: WalletCallbackBody): Promise<WalletCallbackResponse>;
2654
+ standalone3dsProcess(payload: Standalone3dsProcessBody): Promise<ProcessAuthenticationResponse>;
2655
+ standalone3dsHandle(): Promise<HandleResponseInterface>;
2656
+ }
2657
+ interface WalletCaptureResponse {
2658
+ id: string;
2659
+ amount: number;
2660
+ currency: string;
2661
+ status: string;
2662
+ }
2663
+ interface WalletCaptureBody {
2664
+ payment_method_id?: string;
2665
+ customer?: {
2666
+ payment_source?: {
2667
+ type?: string;
2668
+ card_name?: string;
2669
+ card_scheme?: string;
2670
+ card_number_last4?: string;
2671
+ expire_month?: number;
2672
+ expire_year?: number;
2673
+ address_line1?: string;
2674
+ address_line2?: string;
2675
+ address_city?: string;
2676
+ address_postcode?: string;
2677
+ address_state?: string;
2678
+ address_country?: string;
2679
+ external_payer_id?: string;
2680
+ ref_token?: string;
2681
+ wallet_express?: boolean;
2682
+ };
2683
+ };
2684
+ }
2685
+ interface WalletCallbackBody {
2686
+ request_type: string;
2687
+ }
2688
+ interface WalletCallbackResponse {
2689
+ id: string;
2690
+ status: string;
2691
+ callback_method: string;
2692
+ callback_rel: string;
2693
+ callback_url: string;
2694
+ }
2695
+ interface Standalone3dsProcessBody {
2696
+ charge_3ds_id: string;
2697
+ }
2698
+ interface HandleResponseInterface {
2699
+ status: string;
2700
+ error: string;
2701
+ result: {
2702
+ reference: string;
2703
+ reference_2: string;
2704
+ identifier: string;
2705
+ identifier_2: string;
2706
+ identifier_3: string;
2707
+ identifier_4: string;
2708
+ identifier_5: string;
2709
+ type: string;
2710
+ status: string;
2711
+ status_2: string;
2712
+ status_code: string;
2713
+ ref_token: string;
2714
+ cancellation: string;
2715
+ count: string;
2716
+ version: string;
2717
+ whitelist: {
2718
+ status: string;
2719
+ source: string;
2720
+ };
2721
+ result: string;
2722
+ };
2723
+ }
2724
+ interface ProcessAuthenticationResponse {
2725
+ status: string;
2726
+ error?: string;
2727
+ result?: {
2728
+ challenge: string;
2729
+ challenge_url: string;
2730
+ decoupled_challenge: boolean;
2731
+ frictionless: boolean;
2732
+ identifier: string;
2733
+ identifier_3: string;
2734
+ identifier_4: string;
2735
+ reference: string;
2736
+ reference_2: string;
2737
+ secondary_url: string;
2738
+ skipped: boolean;
2739
+ status: string;
2740
+ type: string;
2741
+ version: string;
2742
+ description?: string;
2743
+ };
2744
+ }
2745
+
2746
+ declare class ApiGatewayInternal {
2747
+ protected api: ApiInternal;
2748
+ constructor(api: ApiInternal);
2749
+ getWalletConfig(gateway_id: string): Promise<GetWalletConfigResponse>;
2750
+ }
2751
+ interface GetWalletConfigResponse {
2752
+ type: string;
2753
+ mode: string;
2754
+ credentials?: object;
2755
+ }
2756
+
2757
+ declare class ApiServiceInternal {
2758
+ protected api: ApiInternal;
2759
+ constructor(api: ApiInternal);
2760
+ getConfig(service_id: string): Promise<GetConfigResponse>;
2761
+ }
2762
+ interface GetConfigResponse {
2763
+ type: string;
2764
+ merchant: string;
2765
+ username: string;
2766
+ password: string;
2767
+ certificate: string;
2768
+ certificate_passphrase: string;
2769
+ }
2770
+
2771
+ declare class ApiCheckoutInternal {
2772
+ protected api: ApiInternal;
2773
+ constructor(api: ApiInternal);
2774
+ instructions(session_id: string): Observable<object>;
2775
+ private getInstructionLink;
2776
+ callback(payload: Object): Promise<Object>;
2777
+ status(id: string): Promise<Object>;
2778
+ }
2779
+
2780
+ declare class ApiInternal extends ApiBase {
2781
+ charge(): ApiChargeInternal;
2782
+ service(): ApiServiceInternal;
2783
+ checkout(): ApiCheckoutInternal;
2784
+ gateway(): ApiGatewayInternal;
2785
+ }
2786
+
2787
+ interface SRCProvider {
2788
+ load(): void;
2789
+ getEnv(): string;
2790
+ hideButton?(saveSize: boolean): void;
2791
+ showButton?(): void;
2792
+ hideCheckout?(saveSize: boolean): void;
2793
+ showCheckout?(): void;
2794
+ reload(): void;
2795
+ useAutoResize?(): void;
2796
+ }
2797
+
2798
+ declare abstract class SRC {
2799
+ protected iframe_selector: string;
2800
+ protected service_id: string;
2801
+ protected public_key_or_access_token: string;
2802
+ protected meta: IClickToPayMeta;
2803
+ protected eventEmitter: EventEmitter;
2804
+ protected env: string;
2805
+ protected alias?: string;
2806
+ protected api: ApiInternal;
2807
+ protected provider: SRCProvider;
2808
+ protected autoResize: boolean;
2809
+ protected style: IStyles;
2810
+ constructor(iframe_selector: string, service_id: string, public_key_or_access_token: string, meta: IClickToPayMeta);
2805
2811
  /**
2806
- * Using this method you can set hidden elements inside widget
2807
- *
2808
- * @example
2809
- * widget.setHiddenElements(['submit_button', 'email']);
2810
- *
2811
- * @param {string[]} elements - list of element which can be hidden [ELEMENT]{@link ELEMENT} || [FORM_FIELD]{@link FORM_FIELD}
2812
- */
2813
- setHiddenElements(elements: string[]): void;
2812
+ * Object contain styles for widget - call before `.load()`.
2813
+ *
2814
+ * @example
2815
+ * widget.setStyles({
2816
+ * enable_src_popup: true
2817
+ * primary_button_color: 'red',
2818
+ * secondary_button_color: 'blue',
2819
+ * primary_button_text_color: 'white',
2820
+ * secondary_button_text_color: 'white',
2821
+ * font_family: 'Arial',
2822
+ * });
2823
+ * @param {IStyles} fields - name of styles which can be shown in widget [STYLE]{@link STYLE}
2824
+ */
2825
+ setStyles(styles: IStyles): void;
2826
+ private setStyle;
2827
+ load(): void;
2814
2828
  /**
2815
- * Current method can set custom ID to identify the data in the future
2829
+ * Current method can change environment. By default environment = sandbox.
2830
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
2816
2831
  *
2817
2832
  * @example
2818
- * widget.setRefId('id');
2819
- *
2820
- * @param {string} refId - custom id
2833
+ * SRC.setEnv('production');
2834
+ * @param {string} env - sandbox, production
2835
+ * @param {string} [alias] - Own domain alias
2821
2836
  */
2822
- setRefId(refId: string): void;
2837
+ setEnv(env: string, alias?: string): void;
2823
2838
  /**
2824
- * Current method can add visual validation from gateway to widget's form fields
2839
+ * Method to read the current environment
2825
2840
  *
2826
2841
  * @example
2827
- * widget.useGatewayFieldValidation();
2842
+ * SRC.getEnv();
2828
2843
  */
2829
- useGatewayFieldValidation(): void;
2844
+ getEnv(): string;
2845
+ on(eventName: string): Promise<any>;
2846
+ on(eventName: string, cb: (data: any) => void): any;
2830
2847
  /**
2831
- * Current method can set icons of supported card types
2848
+ * Using this method you can hide checkout after load and button click
2849
+ * @param {boolean} [saveSize=false] - using this param you can save iframe's size (if applicable)
2832
2850
  *
2833
2851
  * @example
2834
- *
2835
- * widget.setSupportedCardIcons(['mastercard', 'visa'], validateCardNumberInput);
2836
- *
2837
- * @param {string[]} elements - [SUPPORTED_CARD_TYPES]{@link SUPPORTED_CARD_TYPES}
2838
- * @param {boolean} validateCardNumberInput - [validateCardNumberInput=false] - using this param you allow validation for card number input on supported card types
2852
+ * SRC.hideCheckout();
2839
2853
  */
2840
- setSupportedCardIcons(elements: string[], validateCardNumberInput?: boolean): void;
2854
+ hideCheckout(saveSize: boolean): void;
2841
2855
  /**
2842
- * Current method can change environment. By default environment = sandbox.
2843
- * Also we can change domain alias for this environment. By default domain_alias = paydock.com
2856
+ * Using this method you can show checkout after using hideCheckout method
2844
2857
  *
2845
2858
  * @example
2846
- * widget.setEnv('production', 'paydock.com');
2847
- * @param {string} env - sandbox, production
2848
- * @param {string} [alias] - Own domain alias
2859
+ * SRC.showCheckout()
2849
2860
  */
2850
- setEnv(env: string, alias?: string): void;
2851
- getEnv(): void;
2861
+ showCheckout(): void;
2852
2862
  /**
2853
- * Method for creating iframe url
2863
+ * Using this method you can reload the whole checkout
2854
2864
  *
2855
2865
  * @example
2856
- * widget.loadIFrameUrl(function (url) {
2857
- * console.log(url);
2858
- * }, function (errors) {
2859
- * console.log(errors);
2860
- * });
2866
+ * SRC.reload()
2861
2867
  */
2862
- loadIFrameUrl(cb: (url: string) => void, errorCb?: (errors: string[]) => void): void;
2868
+ reload(): void;
2863
2869
  /**
2864
- * Method for setting a custom language code
2870
+ * Use this method for resize checkout iFrame according to content height, if applicable
2865
2871
  *
2866
2872
  * @example
2867
- * config.setLanguage('en');
2868
- * @param {string} code - ISO 639-1
2869
- */
2870
- setLanguage(code: any): void;
2871
- }
2872
-
2873
- interface IEventMetaData extends IEventData$1 {
2874
- configuration_token: string;
2875
- type: string;
2876
- account_name?: string;
2877
- account_number?: string;
2878
- card_number_last4?: string;
2879
- card_number_length?: number;
2880
- card_scheme?: string;
2881
- gateway_type?: string;
2882
- }
2883
- interface IEventFinishData extends IEventData$1 {
2884
- payment_source: string;
2885
- payment_source_token?: string;
2886
- }
2887
- /**
2888
- * Interface of data from validation event.
2889
- *
2890
- * @interface IFormValidation
2891
- *
2892
- * @param {string} event The name of the event.
2893
- * @param {string} message_source A system variable that identifies the event source.
2894
- * @param {string} purpose A system variable that states the purpose of the event.
2895
- * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
2896
- * @param {boolean} [form_valid] Indicates wether or not the form is valid.
2897
- * @param {Array<string>} [invalid_fields] Names of form fields with invalid data.
2898
- * @param {Array<string>} [invalid_showed_fields] Names of invalid form fields which are already displaying the error.
2899
- * @param {Partial<Record<CardValidatorValue | GenericValidatorValue, Array<string>>>} [validators] Object containing validator identifiers as keys and the fields subject to that validator as an array of form field names.
2900
- * See list of available [Generic Vallidators]{@link GENERIC_VALIDATORS} and [Card Validators]{@link CARD_VALIDATORS},
2901
- */
2902
- /**
2903
- * Contains basic information associated with the event and additional meta data
2904
- * specific to the event. E.g., card info, gateway info, etc.
2905
- *
2906
- * @interface IEventMetaData
2907
- *
2908
- * @param {string} event The name of the event.
2909
- * @param {string} purpose A system variable that states the purpose of the event.
2910
- * @param {string} message_source A system variable that identifies the event source.
2911
- * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
2912
- * @param {string} configuration_token Token received from our API with widget data
2913
- * @param {string} type Payment type 'card', 'bank_account'
2914
- * @param {string} gateway_type Gateway type
2915
- * @param {string} [card_number_last4] Last 4 digit of your card
2916
- * @param {string} [card_scheme] Card scheme, e.g., (Visa, Mastercard and American Express (AmEx))
2917
- * @param {number} [card_number_length] Card number length
2918
- * @param {string} [account_name] Bank account account name
2919
- * @param {string} [account_number] Bank account account number
2920
- * */
2921
- /**
2922
- * Interface of data from event.
2923
- * @interface IEventAfterLoadData
2924
- *
2925
- * @param {string} event The name of the event.
2926
- * @param {string} purpose A system variable that states the purpose of the event.
2927
- * @param {string} message_source A system variable that identifies the event source.
2928
- * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
2929
- * */
2930
- /**
2931
- * Interface of data from event.
2932
- * @interface IEventFinishData
2933
- *
2934
- * @param {string} event The name of the event.
2935
- * @param {string} purpose A system variable that states the purpose of the event.
2936
- * @param {string} message_source A system variable that identifies the event source.
2937
- * @param {string} [ref_id] Custom unique value that identifies result of processed operation.
2938
- * @param {string} payment_source One time token. Result from this endpoint [API docs](https://docs.paydock.com/#tokens)
2939
- * */
2940
- /**
2941
- * List of available event's name
2942
- * @const EVENT
2943
- *
2944
- * @type {object}
2945
- * @param {string} AFTER_LOAD=afterLoad
2946
- * @param {string} SUBMIT=submit
2947
- * @param {string} FINISH=finish
2948
- * @param {string} VALIDATION=validation
2949
- * @param {string} VALIDATION_ERROR=validationError
2950
- * @param {string} SYSTEM_ERROR=systemError
2951
- * @param {string} META_CHANGE=metaChange
2952
- * @param {string} RESIZE=resize
2953
- */
2873
+ * SRC.useAutoResize();
2874
+ *
2875
+ */
2876
+ useAutoResize(): void;
2877
+ }
2878
+
2954
2879
  /**
2955
- * List of available event's name
2956
- * @const VAULT_DISPLAY_EVENT
2880
+ * Class ClickToPay include methods for interacting with the ClickToPay checkout and Manual Card option
2881
+ *
2882
+ * @extends SRC
2957
2883
  *
2958
- * @type {object}
2959
- * @param {string} AFTER_LOAD=afterLoad
2960
- * @param {string} SYSTEM_ERROR=system_error
2961
- * @param {string} CVV_SECURE_CODE_REQUESTED=cvv_secure_code_requested
2962
- * @param {string} CARD_NUMBER_SECURE_CODE_REQUESTED=card_number_secure_code_requested
2963
- * @param {string} ACCESS_FORBIDDEN=access_forbidden
2964
- * @param {string} SESSION_EXPIRED=systemError
2965
- * @param {string} SYSTEM_ERROR=session_expired
2966
- * @param {string} OPERATION_FORBIDDEN=operation_forbidden
2967
- */
2968
- /**
2969
- * Class HtmlMultiWidget include method for working with html
2970
2884
  * @constructor
2971
- * @extends MultiWidget
2972
2885
  *
2973
- * @param {string} selector - Selector of html element. Container for widget
2974
- * @param {string} publicKey - PayDock users public key
2975
- * @param {(Configuration | string | Configuration[] | string[])} conf - exemplar[s] Configuration class OR configuration token
2886
+ * @param {string} iframe_selector - Selector of html element. Container for Click To Pay checkout iFrame.
2887
+ * @param {string} service_id - Card Scheme Service ID
2888
+ * @param {string} public_key_or_access_token - Paydock public key or Access Token
2889
+ * @param {IClickToPayMeta} meta - Data that configures the Click To Pay checkout
2976
2890
  * @example
2977
- * var widget = new MultiWidget('#widget', 'publicKey','configurationToken'); // With a pre-created configuration token
2891
+ * var mastercardSRC = new ClickToPay('#checkoutIframe', 'service_id', 'public_key', {});
2978
2892
  *
2979
- * var widget = new MultiWidget('#widget', 'publicKey',['configurationToken', 'configurationToken2']); // With pre-created configuration tokens
2893
+ */
2894
+ declare class ClickToPay extends SRC {
2895
+ protected iframe_selector: string;
2896
+ protected service_id: string;
2897
+ protected public_key_or_access_token: string;
2898
+ protected meta: IClickToPayMeta;
2899
+ /** @constructs */ constructor(iframe_selector: string, service_id: string, public_key_or_access_token: string, meta: IClickToPayMeta);
2900
+ /**
2901
+ * The final method after configuring the SRC to start the load process of Click To Pay checkout
2902
+ *
2903
+ */
2904
+ load(): void;
2905
+ }
2906
+
2907
+ declare class VaultDisplayIframeEvent extends IFrameEvent {
2908
+ on<T>(eventName: string, widgetId: string, cb: (data: T) => void): void;
2909
+ }
2910
+
2911
+ /**
2912
+ * Class VaultDisplayWidget include method for working on html
2913
+ * @constructor
2980
2914
  *
2981
- * var widget = new MultiWidget('#widget', 'publicKey', new Configuration('gatewayId')); With Configuration
2915
+ * @example
2916
+ * var widget = new VaultDisplayWidget('#widget', 'token');
2982
2917
  *
2983
- * var widget = new MultiWidget('#widget', 'publicKey',[ With Configurations
2984
- * Configuration(), // default gateway_id,
2985
- * Configuration('not_configured'), // without gateway,
2986
- * Configuration('gatewayId'),
2987
- * Configuration('gatewayId', 'bank_account')
2988
- * ]);
2918
+ * @param {string} selector - Selector of html element. Container for widget
2919
+ * @param {string} token - One time token
2989
2920
  */
2990
- declare class HtmlMultiWidget extends MultiWidget {
2921
+ declare class VaultDisplayWidget {
2991
2922
  protected container: Container;
2992
2923
  protected iFrame: IFrame;
2993
2924
  protected triggerElement: Trigger;
2994
- protected event: IFrameEvent;
2925
+ protected event: VaultDisplayIframeEvent;
2995
2926
  protected validationData: IFormValidation;
2996
- /** @constructs */ constructor(selector: string, publicKey: string, conf: any);
2927
+ protected vaultDisplayToken: string;
2928
+ protected link: Link;
2929
+ protected configs: any[];
2930
+ /** @constructs */ constructor(selector: string, token: string);
2931
+ /**
2932
+ * Current method can change environment. By default environment = sandbox.
2933
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
2934
+ *
2935
+ * @example
2936
+ * widget.setEnv('production', 'paydock.com');
2937
+ * @param {string} env - sandbox, production
2938
+ * @param {string} [alias] - Own domain alias
2939
+ */
2940
+ setEnv(env: string, alias?: string): void;
2941
+ /**
2942
+ * This callback will be called for each event in widget
2943
+ *
2944
+ * @callback listener
2945
+ * @param {IEventData} response
2946
+ */
2947
+ on(eventName: string): Promise<IEventData$1>;
2948
+ on(eventName: string, cb: (data: IEventData$1) => void): any;
2949
+ /**
2950
+ * Object contain styles for widget
2951
+ *
2952
+ * @example
2953
+ * widget.setStyles({
2954
+ * background_color: '#fff',
2955
+ * border_color: 'yellow',
2956
+ * text_color: '#FFFFAA',
2957
+ * button_color: 'rgba(255, 255, 255, 0.9)',
2958
+ * font_size: '20px',
2959
+ * fort_family: 'fantasy'
2960
+ * });
2961
+ * @param {VaultDisplayStyle} fields - name of styles which can be shown in widget [VAULT_DISPLAY_STYLE]{@link VAULT_DISPLAY_STYLE}
2962
+ */
2963
+ setStyles(styles: IStyles$1): void;
2964
+ setStyle(param: string, value: string): void;
2965
+ /**
2966
+ * The final method to beginning, the load process of widget to html
2967
+ *
2968
+ */
2969
+ load(): void;
2970
+ }
2971
+
2972
+ interface IWalletServiceUpdateData {
2973
+ amount: number;
2974
+ shipping_options?: IShippingOption[];
2975
+ }
2976
+ interface IWalletServiceUpdate {
2977
+ success: boolean;
2978
+ body?: IWalletServiceUpdateData;
2979
+ }
2980
+ interface IPaymentMethod {
2981
+ payment_method_id?: string;
2982
+ device?: string;
2983
+ customer: {
2984
+ payer_name: string;
2985
+ payer_email: string;
2986
+ payer_phone: string;
2987
+ payment_source: {
2988
+ wallet_type: WALLET_TYPE;
2989
+ card_name: string;
2990
+ type: string;
2991
+ card_scheme: string;
2992
+ card_number_last4: string;
2993
+ expire_month: number;
2994
+ expire_year: number;
2995
+ address_line1: string;
2996
+ address_line2: string;
2997
+ address_city: string;
2998
+ address_postcode: string;
2999
+ address_state: string;
3000
+ address_country: string;
3001
+ ref_token?: string;
3002
+ };
3003
+ };
3004
+ shipping?: {
3005
+ method?: string;
3006
+ options?: IShippingOption[];
3007
+ address_line1?: string;
3008
+ address_line2?: string;
3009
+ address_city?: string;
3010
+ address_postcode?: string;
3011
+ address_state?: string;
3012
+ address_country?: string;
3013
+ address_company?: string;
3014
+ address_origin_postcode?: string;
3015
+ contact?: {
3016
+ first_name?: string;
3017
+ last_name?: string;
3018
+ email?: string;
3019
+ phone?: string;
3020
+ phone2?: string;
3021
+ };
3022
+ };
3023
+ }
3024
+ interface IUnavailableWalletEventBody {
3025
+ }
3026
+ interface IPaymentMethodSelectedWalletEventBody {
3027
+ data: IPaymentMethod;
3028
+ onSuccess: () => void;
3029
+ onError: (message?: string) => void;
3030
+ }
3031
+ interface IWalletService {
3032
+ load(container: Container): Promise<void>;
3033
+ close?(): void;
3034
+ update(data: IWalletServiceUpdate): void;
3035
+ enable(): void;
3036
+ disable(): void;
3037
+ setEnv(env: string): any;
3038
+ on(eventName: string, cb?: (data: IUnavailableWalletEventBody | IPaymentMethodSelectedWalletEventBody | any) => void): any;
3039
+ }
3040
+
3041
+ interface IWalletPaymentSuccessful {
3042
+ id: string;
3043
+ amount: number;
3044
+ currency: string;
3045
+ status: string;
3046
+ payer_name?: string;
3047
+ payer_email?: string;
3048
+ payer_phone?: string;
3049
+ }
3050
+ interface IWalletUnavailable {
3051
+ wallet?: WALLET_TYPE;
3052
+ }
3053
+ interface IWalletOnClick {
3054
+ attachResult: (result: Promise<void> | boolean) => void;
3055
+ }
3056
+ interface IWalletUpdate {
3057
+ wallet_response_code?: string;
3058
+ wallet_order_id?: string;
3059
+ wallet_session_id?: string;
3060
+ payment_source?: {
3061
+ wallet_payment_method_id?: string;
3062
+ card_number_last4?: string;
3063
+ card_scheme?: string;
3064
+ };
3065
+ wallet_loyalty_account?: {
3066
+ id?: string;
3067
+ barcode?: string;
3068
+ };
3069
+ shipping?: {
3070
+ address_line1?: string;
3071
+ address_line2?: string;
3072
+ address_postcode?: string;
3073
+ address_city?: string;
3074
+ address_state?: string;
3075
+ address_country?: string;
3076
+ address_company?: string;
3077
+ post_office_box_number?: string;
3078
+ wallet_address_id?: string;
3079
+ wallet_address_name?: string;
3080
+ wallet_address_created_timestamp?: string;
3081
+ wallet_address_updated_timestamp?: string;
3082
+ };
3083
+ selected_shipping_option?: IShippingOption;
3084
+ }
3085
+
3086
+ declare enum EventEnum {
3087
+ UNAVAILABLE = "unavailable",
3088
+ UPDATE = "update",
3089
+ PAYMENT_SUCCESSFUL = "paymentSuccessful",
3090
+ PAYMENT_ERROR = "paymentError",
3091
+ PAYMENT_IN_REVIEW = "paymentInReview",
3092
+ AUTH_TOKENS_CHANGED = "authTokensChanged",
3093
+ ON_CLICK = "onClick",
3094
+ ON_CHECKOUT_OPEN = "onCheckoutOpen",
3095
+ ON_CHECKOUT_CLOSE = "onCheckoutClose"
3096
+ }
3097
+
3098
+ interface IEventData<T = any> {
3099
+ event: string;
3100
+ data: T;
3101
+ }
3102
+ interface IWalletPaymentSuccessfulEvent extends IEventData<IWalletPaymentSuccessful> {
3103
+ event: EventEnum.PAYMENT_SUCCESSFUL;
3104
+ }
3105
+ interface IWalletUpdateEvent extends IEventData<IWalletUpdate> {
3106
+ event: EventEnum.UPDATE;
3107
+ }
3108
+ interface IWalletUnavailableEvent extends IEventData<IWalletUnavailable> {
3109
+ event: EventEnum.UNAVAILABLE;
3110
+ }
3111
+ interface IWalletOnClickEvent extends IEventData<IWalletOnClick> {
3112
+ event: EventEnum.ON_CLICK;
3113
+ }
3114
+ interface IWalletUpdateData {
3115
+ success: boolean;
3116
+ }
3117
+ /**
3118
+ * Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Flypay V2, Paypal, Afterpay)
3119
+ * @constructor
3120
+ *
3121
+ * @example
3122
+ * var button = new WalletButtons('#wallet-buttons', 'charge-token', { amount_label: 'Total', country: 'us' });
3123
+ *
3124
+ * @param {string} selector - Selector of html element. Container for the WalletButtons.
3125
+ * @param {string} chargeToken - token for the wallet transaction, created with a secure call to `POST charges/wallet`.
3126
+ * @param {IWalletMeta} meta - data that configures the E-Wallet, which can be shown on checkout page and configures required customer information.
3127
+ */
3128
+ declare class WalletButtons {
3129
+ protected container: Container;
3130
+ protected api: ApiInternal;
3131
+ protected service: IWalletService;
3132
+ protected eventEmitter: EventEmitter;
3133
+ protected hasUpdateHandler: boolean;
3134
+ /** @constructs */ constructor(selector: string, chargeToken: string, meta: IWalletMeta);
2997
3135
  /**
2998
- * Loads the widget.
3136
+ * Initializes the availability checks and inserts the button if possible.
3137
+ * Otherwise function onUnavailable(handler: VoidFunction) will be called.
2999
3138
  *
3000
- * Calling this method results in an iframe element being inserted and rendered in the DOM.
3139
+ * @example
3140
+ * var button = new WalletButtons(
3141
+ * '#buttons',
3142
+ * token,
3143
+ * {
3144
+ * amount_label: 'Total',
3145
+ * country: 'DE',
3146
+ * }
3147
+ * );
3148
+ * button.load();
3001
3149
  */
3002
3150
  load(): void;
3003
3151
  /**
3004
- * Registers a form validation callback for validation events.
3005
- */
3006
- protected afterLoad(): void;
3007
- /**
3008
- * Listen to events of widget
3152
+ * Triggers the update process of the wallet, if available.
3153
+ * Currently supported by Flypay, Paypal and ApplePay/GooglePay via MPGS Wallets.
3009
3154
  *
3010
3155
  * @example
3011
- *
3012
- * ```javascript
3013
- * widget.on('form_submit', function (data) {
3014
- * console.log(data);
3015
- * });
3016
- * ```
3156
+ * var button = new WalletButtons(
3157
+ * '#buttons',
3158
+ * token,
3159
+ * {
3160
+ * amount_label: 'Total',
3161
+ * country: 'DE',
3162
+ * }
3163
+ * );
3164
+ * button.on('update', (data) => {
3165
+ * updateChargeAmountInBackend(data);
3166
+ * button.update({ success: true });
3167
+ * });
3017
3168
  *
3018
3169
  * @example
3019
- *
3020
- * ```javascript
3021
- * widget.on('form_submit').then(function (data) {
3022
- * console.log(data);
3023
- * });
3024
- * ```
3025
- *
3026
- * @typedef {(data: IEventData | IEventMetaData | IEventFinishData | IFormValidation) => void} EventListenerCallback
3027
- *
3028
- * @param {string} eventName - The name of the event that should be listened. Available event names [EVENT]{@link EVENT}.
3029
- * @param {EventListenerCallback} [cb] - A function to be invoked whenever the event occurs.
3030
- *
3031
- * @return {Promise<IEventData | IEventMetaData | IEventFinishData | IFormValidation> | void}
3032
- */
3033
- on(eventName: string): Promise<IEventData$1 | IEventMetaData | IEventFinishData | IFormValidation>;
3034
- on(eventName: string, cb: (data: IEventData$1 | IEventMetaData | IEventFinishData | IFormValidation) => void): any;
3035
- /**
3036
- * Registers callback that will be invoked for every trigger.
3037
- *
3038
- * @param {'submit_form' | 'tab'} triggers - The Widget element identifier that caused the trigger.
3039
- * @param {ITriggerData} data - Data that will be sent to the widget when the trigger occurs.
3040
- */
3041
- trigger(triggerName: string, data?: ITriggerData): void;
3042
- /**
3043
- * Gets a reference to the form current validation state.
3044
- *
3045
- * !Warning: do not directly modify the values of the returned object.
3046
- *
3047
- * @return {IFormValidation} Form validation object
3048
- */
3049
- getValidationState(): IFormValidation;
3050
- /**
3051
- * Checks if a given form is valid.
3052
- *
3053
- * A form is valid if all form fields are valid.
3054
- *
3055
- * @return {boolean} Indicates wether or not form is valid.
3056
- */
3057
- isValidForm(): boolean;
3058
- /**
3059
- * Using this method you can check if a specific form field is invalid
3060
- *
3061
- * @param {string} field - Field name
3062
- * @return {boolean} Field is invalid
3063
- */
3064
- isInvalidField(field?: string): boolean;
3065
- /**
3066
- * Checks if a given form field is displaying an error.
3067
- *
3068
- * @param {string} field - The form field name
3069
- *
3070
- * @return {boolean} Indicates wether or not the Error message is being displayed on the associated field.
3071
- */
3072
- isFieldErrorShowed(field?: string): boolean;
3073
- /**
3074
- * Checks if a given form field is valid or invalid by name.
3075
- *
3076
- * @param {string} field - The form field name
3077
- * @param validator - The name of the validator.
3078
- *
3079
- * @return {boolean} Indicates wether or not the field is invalid based on validator intepretation.
3170
+ * // ApplePay via MPGS example:
3171
+ * var button = new WalletButtons(
3172
+ * '#buttons',
3173
+ * token,
3174
+ * {
3175
+ * amount_label: 'Total',
3176
+ * country: 'AU',
3177
+ * ...
3178
+ * }
3179
+ * );
3180
+ * button.on('update', (data) => {
3181
+ * updateChargeAmountInBackend(data);
3182
+ * button.update({
3183
+ * success: true,
3184
+ * body: {
3185
+ * amount: 15,
3186
+ * shipping_options: [
3187
+ * {
3188
+ * id: "NEW-FreeShip",
3189
+ * label: "NEW - Free Shipping",
3190
+ * detail: "Arrives in 3 to 5 days",
3191
+ * amount: "0.00"
3192
+ * },
3193
+ * {
3194
+ * id: "NEW - FastShip",
3195
+ * label: "NEW - Fast Shipping",
3196
+ * detail: "Arrives in less than 1 day",
3197
+ * amount: "10.00"
3198
+ * }
3199
+ * ]
3200
+ * }
3201
+ * });
3202
+ * });
3080
3203
  */
3081
- isInvalidFieldByValidator(field: string, validator: ValidatorFieldsMapKey): boolean;
3204
+ update(data: IWalletUpdateData): void;
3082
3205
  /**
3083
- * Hides the widget.
3084
- *
3085
- * E.g., use this method to hide the widget after it loads.
3206
+ * Current method can change environment. By default environment = sandbox.
3207
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
3208
+ * Bear in mind that you must set an environment before calling `button.load()`.
3086
3209
  *
3087
- * @param {boolean} [saveSize=false] Wether the original iframe element size should be saved before being hidden.
3210
+ * @example
3211
+ * button.setEnv('production', 'paydock.com');
3212
+ * @param {string} env - sandbox, production
3213
+ * @param {string} [alias] - Own domain alias
3088
3214
  */
3089
- hide(saveSize: boolean): void;
3215
+ setEnv(env: string, alias?: string): void;
3090
3216
  /**
3091
- * Shows the widget.
3217
+ * Current method can enable the payment button. This method is only supported for Flypay V2.
3092
3218
  *
3093
- * E.g., use this method to show the widget after it was explicitly hidden.
3094
- */
3095
- show(): void;
3096
- /**
3097
- * Reloads the widget.
3219
+ * @example
3220
+ * button.enable();
3098
3221
  */
3099
- reload(): void;
3222
+ enable(): void;
3100
3223
  /**
3101
- * Hides the specified Widget elements by their identifier.
3224
+ * Current method can disable the payment button. This method is only supported for Flypay V2.
3102
3225
  *
3103
3226
  * @example
3104
- *
3105
- * ```javascript
3106
- * widget.hideElements(['submit_button', 'email']);
3107
- * ```
3108
- *
3109
- * @param {string[]} elements - List of element which can be hidden [ELEMENT]{@link ELEMENT} || [FORM_FIELD]{@link FORM_FIELD}
3227
+ * button.disable('production', 'paydock.com');
3110
3228
  */
3111
- hideElements(elements: string[]): void;
3229
+ disable(): void;
3112
3230
  /**
3113
- * Shows the specified Widget elements by their identifier.
3231
+ * Closes the checkout forcibly. Currently supported in Flypay wallet.
3114
3232
  *
3115
3233
  * @example
3116
- *
3117
- * ```javascript
3118
- * widget.showElements(['submit_button', 'email']);
3119
- * ```
3120
- *
3121
- * @param {string[]} elements - List of elements which can be showed [ELEMENT]{@link ELEMENT} || [FORM_FIELD]{@link FORM_FIELD}
3234
+ * button.close();
3122
3235
  */
3123
- showElements(elements: string[]): void;
3236
+ close(): void;
3237
+ on(eventName: string): Promise<IEventData>;
3238
+ on(eventName: string, cb: (data: IEventData) => void): any;
3124
3239
  /**
3125
- * Updates the form field values inside the widget.
3240
+ * User to subscribe to the no button available event. This method is used after loading when the button is not available.
3241
+ * For MPGS, since can have more than one wallet button configured (ApplePay/GooglePay) you will receive a body (({ wallet: WALLET_TYPE.GOOGLE }) or ({ wallet: WALLET_TYPE.APPLE })) indicating which button is unavailable
3242
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3126
3243
  *
3127
3244
  * @example
3128
- *
3129
- * ```javascript
3130
- * widget.updateFormValues({
3131
- * email: 'predefined@email.com',
3132
- * card_name: 'Houston'
3245
+ * button.onUnavailable(() => {
3246
+ * console.log('No wallet buttons available');
3133
3247
  * });
3134
- *```
3135
- *
3136
- * @param {IFormValues} fieldValues - Fields with values
3137
- */
3138
- updateFormValues(fieldValues: IFormValues): void;
3139
- /**
3140
- * Updates a single form field values inside the widget by the form field name.
3141
3248
  *
3142
3249
  * @example
3250
+ * button.onUnavailable().then(() => console.log('No wallet buttons available'));
3143
3251
  *
3144
- * ```javascript
3145
- * widget.updateFormValue("card_name", "John Doe");
3146
- *```
3147
- *
3148
- * @param {string} key - The form field name
3149
- * @param {string} value - The form field value
3150
- */
3151
- updateFormValue(key: string, value: string): void;
3152
- /**
3153
- * Inserts the event data (after finish event) onto the input field associated with the provided CSS selector.
3252
+ * @example
3253
+ * button.onUnavailable(function (data) {console.log('data.wallet :: ', data.wallet)});
3154
3254
  *
3155
- * @param {string} selector - A CSS selector. E.g., ".my-class", "#my-id", or others
3156
- * @param {string} dataType - The data type of IEventData object.
3255
+ * @param {listener} [handler] - Function to be called when no button is available.
3157
3256
  */
3158
- onFinishInsert(selector: string, dataType: string): void;
3257
+ onUnavailable(handler?: (data: IWalletUnavailableEvent) => void): Promise<void> | (() => void);
3159
3258
  /**
3160
- * Intercepts a form submission and delegates processing to the widget.
3161
- *
3162
- * An simplified example of the process:
3163
- * - User clicks submit button in your form
3164
- * - This implicitly triggers a submission to the widget
3165
- * - The widget submits your form
3166
- *
3167
- * @note The widget's submit button will be hidden.
3259
+ * If the wallet performs some update in the checkout process, the function passed as parameter will be called.
3168
3260
  *
3169
- * @param {string} selector - css selector of your form
3261
+ * NOTE: make sure to call the `button.update(result)` method on handler completion.
3170
3262
  *
3171
3263
  * @example
3172
- *
3173
- * ```html
3174
- * <body>
3175
- * <form id="myForm">
3176
- * <input name="amount">
3177
- * <button type="submit">Submit</button>
3178
- * </form>
3179
- * <script>
3180
- * widget.interceptSubmitForm('#myForm');
3181
- * </script>
3182
- * </body>
3183
- * ```
3184
- */
3185
- interceptSubmitForm(selector: string): void;
3186
- /**
3187
- * This method hides a submit button and automatically execute form submit
3264
+ * button.onUpdate((data) => {
3265
+ * button.update({ success: true });
3266
+ * });
3267
+ *
3268
+ * @example
3269
+ * button.onUpdate().then((data) => throw new Error());
3270
+ *
3271
+ * @param {listener} [handler] - Function to be called when the payment was successful.
3188
3272
  */
3189
- useCheckoutAutoSubmit(): void;
3273
+ onUpdate(handler?: (data: IWalletUpdateEvent) => void): Promise<unknown> | (() => void);
3190
3274
  /**
3191
- * Use this method for resize iFrame according content height
3275
+ * If the payment was successful, the function passed as parameter will be called.
3276
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3192
3277
  *
3193
3278
  * @example
3279
+ * button.onPaymentSuccessful((data) => {
3280
+ * console.log('Payment successful!');
3281
+ * });
3194
3282
  *
3195
- * ```javascript
3196
- * widget.useAutoResize();
3197
- *```
3283
+ * @example
3284
+ * button.onPaymentSuccessful().then((data) => console.log('Payment successful!'));
3285
+ *
3286
+ * @param {listener} [handler] - Function to be called when the payment was successful.
3198
3287
  */
3199
- useAutoResize(): void;
3200
- }
3201
-
3202
- /**
3203
- * Class Widget include method for working on html and include extended by HtmlMultiWidget methods
3204
- * @constructor
3205
- * @extends HtmlMultiWidget
3206
- * @extends MultiWidget
3207
- *
3208
- * @example
3209
- * var widget = new HtmlWidget('#widget', 'publicKey', 'gatewayID'); // short
3210
- *
3211
- * var widget = new HtmlWidget('#widget', 'publicKey', 'gatewayID', 'bank_account', 'payment_source'); // extend
3212
- *
3213
- * var widget = new HtmlWidget('#widget', 'publicKey', 'not_configured'); // without gateway
3214
- *
3215
- * @param {string} selector - Selector of html element. Container for widget
3216
- * @param {string} publicKey - PayDock users public key
3217
- * @param {string} [gatewayID=default] - ID of a gateway connected to PayDock. By default or if put 'default', it will use the selected default gateway. If put 'not_configured', it won’t use gateway to create downstream token.
3218
- * @param {string} [paymentType=card] - Type of payment source which shows in widget form. Available parameters : “card”, “bank_account”.
3219
- * @param {string} [purpose=payment_source] - Purpose of widget form. Available parameters: ‘payment_source’, ‘card_payment_source_with_cvv’, ‘card_payment_source_without_cvv’
3220
- */
3221
- declare class HtmlWidget extends HtmlMultiWidget {
3222
- /** @constructs */ constructor(selector: string, publicKey: string, gatewayID?: string, paymentType?: string, purpose?: string);
3288
+ onPaymentSuccessful(handler?: (data: IWalletPaymentSuccessfulEvent) => void): Promise<unknown> | (() => void);
3223
3289
  /**
3224
- * Destination, where customer will receive all successful responses.
3225
- * Response will contain “data” object with “payment_source” or other parameters, in depending on 'purpose'
3290
+ * If the payment was left in fraud review, the function passed as parameter will be called.
3291
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3226
3292
  *
3227
3293
  * @example
3228
- * widget.setWebHookDestination('http://google.com');
3294
+ * button.onPaymentInReview((data) => {
3295
+ * console.log('Payment in fraud review');
3296
+ * });
3229
3297
  *
3230
- * @param {string} url - Your endpoint for post request.
3298
+ * @example
3299
+ * button.onPaymentInReview().then((data) => console.log('Payment in fraud review'));
3300
+ *
3301
+ * @param {listener} [handler] - Function to be called when the payment was left in fraud review status.
3231
3302
  */
3232
- setWebHookDestination(url: string): void;
3303
+ onPaymentInReview(handler?: (err: IEventData) => void): Promise<unknown> | (() => void);
3233
3304
  /**
3234
- * URL to which the Customer will be redirected to after the success finish
3305
+ * If the payment was not successful, the function passed as parameter will be called.
3306
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3235
3307
  *
3236
3308
  * @example
3237
- * widget.setSuccessRedirectUrl('google.com/search?q=success');
3309
+ * button.onPaymentError((err) => {
3310
+ * console.log('Payment not successful');
3311
+ * });
3238
3312
  *
3239
- * @param {string} url
3313
+ * @example
3314
+ * button.onPaymentError().then((err) => console.log('Payment not successful'));
3315
+ *
3316
+ * @param {listener} [handler] - Function to be called when the payment was not successful.
3240
3317
  */
3241
- setSuccessRedirectUrl(url: string): void;
3318
+ onPaymentError(handler?: (err: IEventData) => void): Promise<unknown> | (() => void);
3242
3319
  /**
3243
- * URL to which the Customer will be redirected to if an error is triggered in the process of operation
3320
+ * Registers a callback function to be invoked when authentication tokens are changed.
3321
+ * This function allows you to respond to changes in authentication tokens, such as when a user logs in.
3244
3322
  *
3245
3323
  * @example
3246
- * widget.setErrorRedirectUrl('google.com/search?q=error');
3324
+ * button.onAuthTokensChanged((eventData) => {
3325
+ * console.log('Authentication tokens changed:', eventData);
3326
+ * });
3247
3327
  *
3248
- * @param {string} url
3328
+ * @example
3329
+ * button.onAuthTokensChanged().then((eventData) => {
3330
+ * console.log('Authentication tokens changed:', eventData);
3331
+ * });
3332
+ *
3333
+ * @param {listener} [handler] - Function to be called when authentication tokens are changed.
3249
3334
  */
3250
- setErrorRedirectUrl(url: string): void;
3335
+ onAuthTokensChanged(handler?: (err: IEventData) => void): Promise<unknown> | (() => void);
3251
3336
  /**
3252
- * Set list with widget form field, which will be shown in form. Also you can set the required validation for these fields
3337
+ * Registers a callback function to be invoked when the wallet button gets clicked.
3338
+ * There are two operational modes supported, Synchronous and Asynchronous.
3339
+ * 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.
3340
+ * When synchronous operations occur on the callback handler, attaching a boolean result via `attachResult` is optional to control the execution flow.
3341
+ * Note this is supported for Paypal, GooglePay and ApplePay wallet buttons at the moment.
3253
3342
  *
3254
3343
  * @example
3255
- * widget.setFormFields(['phone', 'email', 'first_name*']);
3344
+ * button.onClick((data) => {
3345
+ * performValidationLogic();
3346
+ * });
3256
3347
  *
3257
- * @param {string[]} fields - name of fields which can be shown in a widget.
3258
- * If after a name of a field, you put “*”, this field will be required on client-side. (For validation, you can specify any fields, even those that are shown by default: card_number, expiration, etc... ) [FORM_FIELD]{@link FORM_FIELD}
3348
+ * @param {listener} handler - Function to be called when the wallet button is clicked.
3259
3349
  */
3260
- setFormFields(fields: string[]): void;
3350
+ onClick(handler: (data: IWalletOnClickEvent) => void): () => void;
3261
3351
  /**
3262
- * The method to set the full configuration for the all specific form elements (visibility, required, label, placeholder, value)
3263
- * You can also use the other method for the partial configuration like: setFormFields, setFormValues, setFormPlaceholder, setFormLabel
3352
+ * Registers a callback function to be invoked when the wallet checkout opens.
3353
+ * Note this is supported for FlypayV2 wallet button at the moment.
3264
3354
  *
3265
3355
  * @example
3266
- * widget.setFormElements([
3267
- * {
3268
- * field: 'card_name*',
3269
- * placeholder: 'Input your card holder name...',
3270
- * label: 'Card Holder Name',
3271
- * value: 'Houston',
3272
- * },
3273
- * {
3274
- * field: 'email',
3275
- * placeholder: 'Input your email, like test@example.com',
3276
- * label: 'Email for the receipt',
3277
- * value: 'predefined@email.com',
3278
- * },
3279
- * ])
3356
+ * button.onCheckoutOpen((data) => {
3357
+ * console.log('Checkout opens');
3358
+ * });
3280
3359
  *
3281
- * @param { Object[] } elements - List of elements
3282
- * @param { string } elements[].field - Field name of element. If after a name of a field, you put “*”, this field will be required on client-side. (For validation, you can specify any fields, even those that are shown by default: card_number, expiration, etc... ) [FORM_FIELD]{@link FORM_FIELD}
3283
- * @param { string } elements[].placeholder - Set custom placeholders in form fields
3284
- * @param { string } elements[].label - Set a custom labels near the form field
3285
- * @param { string } elements[].value - Set predefined values for the form field
3360
+ * @param {listener} handler - Function to be called when the wallet checkout opens.
3286
3361
  */
3287
- setFormElements(elements: IFormElement[]): void;
3288
- setFormElement(element: IFormElement): void;
3362
+ onCheckoutOpen(handler?: (err: IEventData) => void): Promise<unknown> | (() => void);
3289
3363
  /**
3290
- * The method to set meta information for the checkout page
3364
+ * Registers a callback function to be invoked when the wallet checkout closes.
3365
+ * Note this is supported for FlypayV2 wallet button at the moment.
3291
3366
  *
3292
3367
  * @example
3293
- * config.setMeta({
3294
- brand_name: 'paydock',
3295
- reference: '15',
3296
- email: 'wault@paydock.com'
3297
- });
3368
+ * button.onCheckoutClose(() => {
3369
+ * console.log('Wallet checkout closes');
3370
+ * });
3298
3371
  *
3299
- * @param {IPayPalMeta | IBamboraMeta} object - data which can be shown on checkout page [IPayPalMeta]{@link IPayPalMeta} [IBamboraMeta]{@link IBamboraMeta}
3372
+ * @param {listener} handler - Function to be called when the wallet checkout closes.
3300
3373
  */
3301
- setMeta(meta: IPayPalMeta | IBamboraMeta): void;
3302
- setGiftCardScheme(giftCardScheme: any, processingNetwork: any): void;
3374
+ onCheckoutClose(handler?: (err: IEventData) => void): Promise<unknown> | (() => void);
3375
+ private setupServiceCallbacks;
3376
+ private setupUnavailableCallback;
3377
+ private setupUpdateCallback;
3378
+ private setupOnClickCallback;
3379
+ private setupOnCheckoutOpenCallback;
3380
+ private setupOnCheckoutCloseCallback;
3381
+ private setupWalletCallback;
3382
+ private setupPaymentCallback;
3383
+ private setupPaymentSuccessCallback;
3384
+ private setupPaymentInReviewCallback;
3385
+ private setupPaymentErrorCallback;
3386
+ private setupAuthTokensChangedCallback;
3303
3387
  }
3304
3388
 
3305
3389
  type Instruction = new (selector: string, formSelector: string, api: ApiInternal) => InstructionHandler & InstructionDestroyable & InstructionDecorated;
@@ -3459,6 +3543,7 @@ interface WalletCaptureRequest {
3459
3543
  address_state?: string;
3460
3544
  ref_token?: string;
3461
3545
  external_payer_id?: string;
3546
+ wallet_express?: boolean;
3462
3547
  };
3463
3548
  };
3464
3549
  }
@@ -3731,6 +3816,7 @@ declare class ApplePayWalletButtonExpress extends BaseWalletButton<ApplePayWalle
3731
3816
 
3732
3817
  interface PaypalWalletMeta extends BaseWalletMeta {
3733
3818
  pay_later?: boolean;
3819
+ hide_message?: boolean;
3734
3820
  standalone?: boolean;
3735
3821
  capture?: boolean;
3736
3822
  style?: {
@@ -3803,4 +3889,215 @@ declare class PaypalWalletButtonExpress extends BaseWalletButton<PaypalWalletMet
3803
3889
  private paypalSharedProps;
3804
3890
  }
3805
3891
 
3806
- export { AfterpayCheckoutButton, Api, ApplePayWalletButtonExpress, CHECKOUT_BUTTON_EVENT, Canvas3ds, Checkout, ClickToPay, Configuration, ELEMENT, EVENT$1 as EVENT, Builder$1 as ExternalCheckoutBuilder, Checker as ExternalCheckoutChecker, FORM_FIELD, HtmlMultiWidget, HtmlPaymentSourceWidget, HtmlWidget, type ICheckout, type IDetails, type IElementStyleInput, type IEventCheckoutFinishData, type IPayPalMeta, type IStyles$1 as IStyles, type ITexts, InstructionDebugger, MultiWidget, PAYMENT_TYPE, PURPOSE, Builder as PaymentSourceBuilder, PaymentSourceWidget, PaypalCheckoutButton, PaypalWalletButtonExpress, STYLABLE_ELEMENT, STYLABLE_ELEMENT_STATE, STYLE, SUPPORTED_CARD_TYPES, TEXT, TRIGGER, TYPE, VAULT_DISPLAY_STYLE, type VaultDisplayStyle, VaultDisplayWidget, WalletButtons, ZipmoneyCheckoutButton };
3892
+ declare enum ErrorCodes$1 {
3893
+ PROMISE_NOT_ENABLED = "promise_not_enabled",
3894
+ SCRIPT_ERROR = "script_error"
3895
+ }
3896
+ interface PayPalDataCollectorConfig {
3897
+ mouse_movement?: boolean;
3898
+ }
3899
+ interface IPayPalDataCollector {
3900
+ collectDeviceData(): Promise<CollectedDeviceData>;
3901
+ setEnv(env: string): void;
3902
+ }
3903
+ interface CollectedDeviceData {
3904
+ correlation_id: string;
3905
+ }
3906
+ interface IOnErrorEventData$1 {
3907
+ error_code: ErrorCodes$1;
3908
+ }
3909
+
3910
+ /**
3911
+ * PayPal Data Collector Widget constructor
3912
+ *
3913
+ * @param {string} [flowId] - This string identifies the source website of the FraudNet request.
3914
+ * @param {PayPalDataCollectorConfig} [config] - Extra configuration for the widget.
3915
+ *
3916
+ * @example
3917
+ * var payPalDataCollector = new PayPalDataCollector('FLOW_ID', {});
3918
+ */
3919
+ declare class PayPalDataCollector {
3920
+ protected service: IPayPalDataCollector;
3921
+ protected eventEmitter: EventEmitter;
3922
+ /** @constructs */ constructor(flowId?: string, config?: PayPalDataCollectorConfig);
3923
+ /**
3924
+ * After configuring the PayPalDataCollector Widget, starts the process and returns
3925
+ * the correlation id used among the requests asynchronously.
3926
+ *
3927
+ * @returns {Promise<CollectedDeviceData>} Promise when resolved, returns an object
3928
+ * that contains the `correlation_id` key.
3929
+ *
3930
+ * @example
3931
+ * const collectedDeviceData = await payPalDataCollectorWidget.collectDeviceData();
3932
+ * console.log(collectedDeviceData.correlation_id)
3933
+ */
3934
+ collectDeviceData(): Promise<CollectedDeviceData>;
3935
+ /**
3936
+ * Callback for onError method.
3937
+ *
3938
+ * @callback OnErrorCallback
3939
+ * @param {IOnErrorEventData|null} data
3940
+ */
3941
+ /**
3942
+ * If the process fails, the function passed as parameter will be called.
3943
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3944
+ *
3945
+ * @example
3946
+ * PayPalDataCollector.onError((eventData) => console.log('Some error occur'));
3947
+ *
3948
+ * @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow.
3949
+ */
3950
+ onError(callback?: (data?: IOnErrorEventData$1) => void): () => void;
3951
+ /**
3952
+ * Current method can change environment. By default environment = test.
3953
+ * This method does not affect Paydock's API calls or environments, is only for PayPal Data Collector
3954
+ * script, in order to know if the script is injected on a live server or is a testing
3955
+ * environment. The available values are `test` and `live`. This should match with the used
3956
+ * `gateway.mode` in Paydock to process the transaction.
3957
+ *
3958
+ * @example
3959
+ * PayPalDataCollector.setEnv('live');
3960
+ * @param {string} env - test, live
3961
+ */
3962
+ setEnv(env: string): void;
3963
+ }
3964
+
3965
+ interface PayPalStyleConfig {
3966
+ layout?: 'vertical' | 'horizontal';
3967
+ color?: 'blue' | 'gold' | 'silver' | 'black' | 'white';
3968
+ shape?: 'rect' | 'sharp' | 'pill';
3969
+ label?: 'paypal' | 'checkout' | 'buynow' | 'pay';
3970
+ disableMaxWidth?: boolean;
3971
+ disableMaxHeight?: boolean;
3972
+ height?: number;
3973
+ borderRadius?: number;
3974
+ tagline?: boolean;
3975
+ }
3976
+ interface PayPalMessageConfig {
3977
+ amount?: number;
3978
+ align?: 'center' | 'left' | 'right';
3979
+ color?: 'black' | 'white';
3980
+ position?: 'top' | 'bottom';
3981
+ }
3982
+ interface PayPalSavePaymentSourceWidgetConfig {
3983
+ style?: PayPalStyleConfig;
3984
+ message?: PayPalMessageConfig;
3985
+ }
3986
+ interface IPayPalSavePaymentSourceWidget {
3987
+ load(container: Container): void;
3988
+ setEnv(env: string, alias?: string): void;
3989
+ }
3990
+ declare enum ErrorCodes {
3991
+ UNAVAILABLE = "unavailable",
3992
+ ON_PAYPAL_VAULT_SETUP_TOKEN_ERROR = "onPaypalVaultSetupTokenError",
3993
+ ON_GET_ID_TOKEN_ERROR = "onGetIdTokenError",
3994
+ ON_GET_WALLET_CONFIG_ERROR = "onGetWalletConfigError",
3995
+ ON_GET_SETUP_TOKEN_ERROR = "onGetSetupTokenError",
3996
+ ON_ONE_TIME_TOKEN_ERROR = "onOneTimeTokenError"
3997
+ }
3998
+ declare enum EVENTS {
3999
+ ON_SUCCESS = "ON_SUCCESS",
4000
+ ON_ERROR = "ON_ERROR",
4001
+ ON_CANCEL = "ON_CANCEL"
4002
+ }
4003
+ interface IOnSuccessEventData {
4004
+ event: EVENTS.ON_SUCCESS;
4005
+ data: {
4006
+ token: string;
4007
+ email: string;
4008
+ };
4009
+ }
4010
+ interface IOnErrorEventData {
4011
+ event: EVENTS.ON_ERROR;
4012
+ data: {
4013
+ error_code: ErrorCodes;
4014
+ details?: string;
4015
+ message?: string;
4016
+ };
4017
+ }
4018
+ interface IOnCancelEventData {
4019
+ event: EVENTS.ON_CANCEL;
4020
+ }
4021
+
4022
+ /**
4023
+ * PayPal Save Payment Source Widget constructor
4024
+ *
4025
+ * @param {string} selector - Selector of html element. Container for PayPal Save Payment Source Widget.
4026
+ * @param {string} publicKey - PayDock users public key.
4027
+ * @param {string} gatewayId - PayDock's PayPal gatewayId.
4028
+ * @param {PayPalSavePaymentSourceWidgetConfig} config - Extra configuration for the widget, like styles.
4029
+ *
4030
+ * @example
4031
+ * var payPalSavePaymentSourceWidget = new PayPalSavePaymentSourceWidget('#paypalButton', 'public_key', 'gateway_id');
4032
+ */
4033
+ declare class PayPalSavePaymentSourceWidget {
4034
+ protected container: Container;
4035
+ protected service: IPayPalSavePaymentSourceWidget;
4036
+ protected eventEmitter: EventEmitter;
4037
+ /** @constructs */ constructor(selector: string, publicKey: string, gatewayId: string, config?: PayPalSavePaymentSourceWidgetConfig);
4038
+ /**
4039
+ * The final method after configuring the PayPalSavePaymentSource Widget to
4040
+ * start the load process.
4041
+ */
4042
+ load(): void;
4043
+ /**
4044
+ * Current method can change environment. By default environment = sandbox.
4045
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
4046
+ *
4047
+ * @example
4048
+ * payPalSavePaymentSourceWidget.setEnv('production');
4049
+ * @param {string} env - sandbox, production
4050
+ * @param {string} [alias] - Own domain alias
4051
+ */
4052
+ setEnv(env: string, alias?: string): void;
4053
+ /**
4054
+ * Callback for onSuccess method.
4055
+ *
4056
+ * @callback OnSuccessCallback
4057
+ * @param {IOnSuccessEventData} data
4058
+ */
4059
+ /**
4060
+ * If the setup token was successfully approved and a OTT was generated, the function passed as parameter will be called.
4061
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
4062
+ *
4063
+ * @example
4064
+ * payPalSavePaymentSourceWidget.onSuccess((eventData) => console.log('One time token and email obtained successfully'));
4065
+ *
4066
+ * @param {OnSuccessCallback} [callback] - Function to be called when the result is successful.
4067
+ */
4068
+ onSuccess(callback?: (data: IOnSuccessEventData) => void): () => void;
4069
+ /**
4070
+ * Callback for onError method.
4071
+ *
4072
+ * @callback OnErrorCallback
4073
+ * @param {IOnErrorEventData} data
4074
+ */
4075
+ /**
4076
+ * If in the process for obtaining the setup token fails, the function passed as parameter will be called.
4077
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
4078
+ *
4079
+ * @example
4080
+ * payPalSavePaymentSourceWidget.onError((eventData) => console.log('Some error occurred'));
4081
+ *
4082
+ * @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow.
4083
+ */
4084
+ onError(callback?: (data: IOnErrorEventData) => void): () => void;
4085
+ /**
4086
+ * Callback for onCancel method.
4087
+ *
4088
+ * @callback OnCancelCallback
4089
+ * @param {IOnCancelEventData} data
4090
+ */
4091
+ /**
4092
+ * If in the process for obtaining the setup token was cancelled, the function passed as parameter will be called.
4093
+ * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
4094
+ *
4095
+ * @example
4096
+ * payPalSavePaymentSourceWidget.onCancel(() => console.log('Operation cancelled'));
4097
+ *
4098
+ * @param {OnCancelCallback} [callback] - Function to be called when the operation is cancelled.
4099
+ */
4100
+ onCancel(callback?: (data?: IOnCancelEventData) => void): () => void;
4101
+ }
4102
+
4103
+ export { AfterpayCheckoutButton, Api, ApplePayWalletButtonExpress, CHECKOUT_BUTTON_EVENT, Canvas3ds, Checkout, ClickToPay, Configuration, ELEMENT, EVENT$1 as EVENT, Builder$1 as ExternalCheckoutBuilder, Checker as ExternalCheckoutChecker, FORM_FIELD, 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, 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, WalletButtons, ZipmoneyCheckoutButton };