@paydock/client-sdk 1.119.0-beta → 1.119.2

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