@paydock/client-sdk 1.127.0-beta → 1.127.1-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +141 -1
  2. package/bundles/index.cjs +239 -78
  3. package/bundles/index.cjs.d.ts +35 -1
  4. package/bundles/index.mjs +239 -78
  5. package/bundles/index.mjs.d.ts +35 -1
  6. package/bundles/types/checkout/checkout.d.ts +4 -4
  7. package/bundles/types/checkout/checkout.d.ts.map +1 -1
  8. package/bundles/types/components/trigger.d.ts +2 -0
  9. package/bundles/types/components/trigger.d.ts.map +1 -1
  10. package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts +23 -2
  11. package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts.map +1 -1
  12. package/bundles/types/secure-remote-commerce/index.d.ts +7 -1
  13. package/bundles/types/secure-remote-commerce/index.d.ts.map +1 -1
  14. package/bundles/types/secure-remote-commerce/interfaces.d.ts +10 -2
  15. package/bundles/types/secure-remote-commerce/interfaces.d.ts.map +1 -1
  16. package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts +10 -1
  17. package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts.map +1 -1
  18. package/bundles/types/secure-remote-commerce/providers/src-provider.d.ts +2 -0
  19. package/bundles/types/secure-remote-commerce/providers/src-provider.d.ts.map +1 -1
  20. package/bundles/types/secure-remote-commerce/services/performance.service.d.ts +32 -0
  21. package/bundles/types/secure-remote-commerce/services/performance.service.d.ts.map +1 -0
  22. package/bundles/widget.umd.js +239 -78
  23. package/bundles/widget.umd.js.d.ts +35 -1
  24. package/bundles/widget.umd.js.min.d.ts +35 -1
  25. package/bundles/widget.umd.min.js +1 -1
  26. package/docs/api-widget.md +1 -0
  27. package/docs/click-to-pay-examples.md +109 -0
  28. package/docs/click-to-pay.md +31 -1
  29. package/package.json +1 -1
  30. package/slate.md +109 -0
package/README.md CHANGED
@@ -2911,6 +2911,7 @@ List of available triggers
2911
2911
  | REFRESH_CHECKOUT | <code>string</code> | <code>&quot;refresh_checkout&quot;</code> |
2912
2912
  | UPDATE_FORM_VALUES | <code>string</code> | <code>&quot;update_form_values&quot;</code> |
2913
2913
  | INIT_CHECKOUT | <code>string</code> | <code>&quot;init_checkout&quot;</code> |
2914
+ | INJECT_CUSTOMER_DATA | <code>string</code> | <code>&quot;inject_customer_data&quot;</code> |
2914
2915
 
2915
2916
 
2916
2917
  ## Payment sources widget
@@ -8104,6 +8105,115 @@ src.setStyles({
8104
8105
  });
8105
8106
  ```
8106
8107
 
8108
+ ## Configurations for background loading and improved User Load times
8109
+
8110
+ ### hold_for_customer_data
8111
+ When set to `true`, this flag allows you to load the Click to Pay iframe in the background while collecting customer information. This improves the perceived performance by starting the iframe load process early.
8112
+
8113
+ ```javascript
8114
+ const clickToPay = new cba.ClickToPay("#checkoutIframe", SERVICE_ID, PUBLIC_KEY, {
8115
+ hold_for_customer_data: true,
8116
+ dpa_config: {
8117
+ dpa_id: DPA_ID,
8118
+ // ... other config
8119
+ }
8120
+ });
8121
+ ```
8122
+
8123
+ ### injectCustomerData(customer)
8124
+ Once you have collected the customer information, use this method to provide it to the Click to Pay iframe. This will trigger the checkout to continue.
8125
+
8126
+ ```javascript
8127
+ clickToPay.injectCustomerData({
8128
+ email: "customer@example.com",
8129
+ first_name: "John",
8130
+ last_name: "Doe",
8131
+ phone: "+61400123456" // Include country code
8132
+ });
8133
+ ```
8134
+
8135
+ ### Background Loading Example
8136
+ Here's a complete example showing how to implement background loading while collecting customer information:
8137
+
8138
+ ```javascript
8139
+ // 1. Initialize with hold_for_customer_data
8140
+ const clickToPay = new cba.ClickToPay("#checkoutIframe", SERVICE_ID, PUBLIC_KEY, {
8141
+ hold_for_customer_data: true,
8142
+ dpa_config: {
8143
+ dpa_id: DPA_ID,
8144
+ // ... other config
8145
+ }
8146
+ });
8147
+
8148
+ // Hide checkout and show form initially
8149
+ document.getElementById("checkoutIframe").style.display = 'none';
8150
+ document.getElementById("customerForm").style.display = 'block';
8151
+ document.getElementById("loader").style.display = 'none';
8152
+
8153
+ // 2. Setup event handlers
8154
+ clickToPay.on('iframeLoaded', () => {
8155
+ // Iframe is now loaded
8156
+ });
8157
+
8158
+ clickToPay.on('checkoutReady', () => {
8159
+ // Hide loader, show checkout
8160
+ document.getElementById("loader").style.display = 'none';
8161
+ document.getElementById("checkoutIframe").style.display = 'block';
8162
+ clickToPay.showCheckout();
8163
+ });
8164
+
8165
+ // 3. Start loading in background
8166
+ clickToPay.load();
8167
+
8168
+ // 4. Handle form submission
8169
+ document.getElementById("submitButton").addEventListener("click", (e) => {
8170
+ e.preventDefault();
8171
+
8172
+ const customer = {
8173
+ email: document.getElementById("email").value.trim(),
8174
+ first_name: document.getElementById("firstName").value.trim(),
8175
+ last_name: document.getElementById("lastName").value.trim(),
8176
+ phone: document.getElementById("phone").value.trim()
8177
+ };
8178
+
8179
+ // Hide form, show loader
8180
+ document.getElementById("customerForm").style.display = "none";
8181
+ document.getElementById("loader").style.display = "flex";
8182
+
8183
+ try {
8184
+ // Inject customer data to continue checkout
8185
+ clickToPay.injectCustomerData(customer);
8186
+ } catch (error) {
8187
+ // Show form again on error
8188
+ document.getElementById("customerForm").style.display = "block";
8189
+ document.getElementById("loader").style.display = "none";
8190
+ alert("An error occurred. Please try again.");
8191
+ }
8192
+ });
8193
+ ```
8194
+
8195
+ #### HTML Structure
8196
+ Here's the required HTML structure for the background loading example:
8197
+
8198
+ ```html
8199
+ <!-- Click to Pay iframe container -->
8200
+ <div id="checkoutIframe"></div>
8201
+
8202
+ <!-- Customer information form -->
8203
+ <form id="customerForm">
8204
+ <input type="email" id="email" placeholder="Email" required>
8205
+ <input type="text" id="firstName" placeholder="First Name" required>
8206
+ <input type="text" id="lastName" placeholder="Last Name" required>
8207
+ <input type="tel" id="phone" placeholder="Phone (with country code)" required>
8208
+ <button type="submit" id="submitButton">Continue to Checkout</button>
8209
+ </form>
8210
+
8211
+ <!-- Loading indicator -->
8212
+ <div id="loader" style="display: none;">
8213
+ Loading...
8214
+ </div>
8215
+ ```
8216
+
8107
8217
  ## Classes
8108
8218
 
8109
8219
  <dl>
@@ -8159,7 +8269,7 @@ Interface of data used for the Mastercard Checkout. For further information refe
8159
8269
  | [checkout_experience] | <code>string</code> | Checkout experience type, either 'WITHIN_CHECKOUT' or 'PAYMENT_SETTINGS'. |
8160
8270
  | [services] | <code>string</code> | Services offered, such as 'INLINE_CHECKOUT' or 'INLINE_INSTALLMENTS'. |
8161
8271
  | [dpa_transaction_options] | <code>object</code> | Object that stores options for creating a transaction with DPA. |
8162
- | [dpa_transaction_options.dpa_locale] | <code>string</code> | DPAs preferred locale, example en_US. |
8272
+ | [dpa_transaction_options.dpa_locale] | <code>string</code> | DPA's preferred locale, example en_US. |
8163
8273
  | [dpa_transaction_options.dpa_accepted_billing_countries] | <code>Array.&lt;string&gt;</code> | List of accepted billing countries for DPA in ISO 3166-1 alpha-2 format. |
8164
8274
  | [dpa_transaction_options.dpa_billing_preference] | <code>string</code> | Billing preferences for DPA, options are 'FULL', 'POSTAL_COUNTRY', 'NONE'. |
8165
8275
  | [dpa_transaction_options.payment_options] | <code>Array.&lt;object&gt;</code> | Payment options included in the transaction. |
@@ -8184,6 +8294,12 @@ Interface of data used for the Mastercard Checkout. For further information refe
8184
8294
  | [customer.phone.country_code] | <code>string</code> | Customer phone country code (example "1" for US). |
8185
8295
  | [customer.phone.phone] | <code>string</code> | Customer phone number. |
8186
8296
  | [unaccepted_card_type] | <code>string</code> | Used to block a specific card type. Options are 'CREDIT', 'DEBIT'. |
8297
+ | [dpa_config] | <code>object</code> | Raw DPA configuration object for performance optimization. Skips API call when provided. |
8298
+ | [dpa_config.dpa_id] | <code>string</code> | DPA identifier. |
8299
+ | [dpa_config.dpa_name] | <code>string</code> | DPA name. |
8300
+ | [dpa_config.dpa_supported_card_schemes] | <code>Array.&lt;string&gt;</code> | List of supported card schemes: 'MASTERCARD', 'VISA', 'AMEX', 'DISCOVER'. |
8301
+ | [dpa_config.mode] | <code>string</code> | DPA mode, either 'sandbox' or 'live'. |
8302
+ | [hold_for_customer_data] | <code>boolean</code> | Flag to hold initialization for customer data injection. Enables background initialization. |
8187
8303
 
8188
8304
  <a name="EventData" id="EventData" href="#EventData">&nbsp;</a>
8189
8305
 
@@ -8258,6 +8374,7 @@ Class ClickToPay include methods for interacting with the ClickToPay checkout an
8258
8374
  * [ClickToPay](#ClickToPay) ⇐ <code>SRC</code>
8259
8375
  * [new ClickToPay(iframe_selector, service_id, public_key_or_access_token, meta)](#new_ClickToPay_new)
8260
8376
  * [.load()](#ClickToPay+load)
8377
+ * [.injectCustomerData(customerData)](#ClickToPay+injectCustomerData)
8261
8378
  * [.setStyles(fields)](#SRC+setStyles)
8262
8379
  * [.setEnv(env, [alias])](#SRC+setEnv)
8263
8380
  * [.getEnv()](#SRC+getEnv)
@@ -8288,6 +8405,29 @@ var mastercardSRC = new ClickToPay('#checkoutIframe', 'service_id', 'public_key'
8288
8405
  The final method after configuring the SRC to start the load process of Click To Pay checkout
8289
8406
 
8290
8407
  **Kind**: instance method of [<code>ClickToPay</code>](#ClickToPay)
8408
+ <a name="ClickToPay+injectCustomerData" id="ClickToPay+injectCustomerData" href="#ClickToPay+injectCustomerData">&nbsp;</a>
8409
+
8410
+ ### clickToPay.injectCustomerData(customerData)
8411
+ Inject customer data after widget initialization via postMessage
8412
+
8413
+ **Kind**: instance method of [<code>ClickToPay</code>](#ClickToPay)
8414
+ **Throws**:
8415
+
8416
+ - <code>Error</code> When customer data is invalid or widget is not ready
8417
+
8418
+
8419
+ | Param | Type | Description |
8420
+ | --- | --- | --- |
8421
+ | customerData | <code>Customer</code> | Customer data to inject |
8422
+
8423
+ **Example**
8424
+ ```js
8425
+ widget.injectCustomerData({
8426
+ email: 'user@example.com',
8427
+ first_name: 'John',
8428
+ last_name: 'Doe'
8429
+ });
8430
+ ```
8291
8431
  <a name="SRC+setStyles" id="SRC+setStyles" href="#SRC+setStyles">&nbsp;</a>
8292
8432
 
8293
8433
  ### clickToPay.setStyles(fields)
package/bundles/index.cjs CHANGED
@@ -954,7 +954,7 @@ SDK.headerKeys = Object.freeze({
954
954
  version: 'x-sdk-version',
955
955
  type: 'x-sdk-type'
956
956
  });
957
- SDK._version = 'v1.127.0-beta';
957
+ SDK._version = 'v1.127.1-beta';
958
958
 
959
959
  /******************************************************************************
960
960
  Copyright (c) Microsoft Corporation.
@@ -8703,6 +8703,161 @@ var STYLE = {
8703
8703
  ENABLE_SRC_POPUP: 'enable_src_popup'
8704
8704
  };
8705
8705
 
8706
+ /**
8707
+ * Interface for classes that represent a trigger data.
8708
+ * @interface ITriggerData
8709
+ *
8710
+ * @param {string} [configuration_token]
8711
+ * @param {string} [tab_number]
8712
+ * @param {string} [elements]
8713
+ * @param {string} [form_values]
8714
+ * */
8715
+ /**
8716
+ * List of available triggers
8717
+ *
8718
+ * @type {object}
8719
+ * @param {string} SUBMIT_FORM=submit_form
8720
+ * @param {string} CHANGE_TAB=tab
8721
+ * @param {string} HIDE_ELEMENTS=hide_elements
8722
+ * @param {string} SHOW_ELEMENTS=show_elements
8723
+ * @param {string} REFRESH_CHECKOUT=refresh_checkout
8724
+ * @param {string} UPDATE_FORM_VALUES=update_form_values
8725
+ * @param {string} INIT_CHECKOUT=init_checkout
8726
+ * @param {string} INJECT_CUSTOMER_DATA=inject_customer_data
8727
+ */
8728
+ var TRIGGER$1 = {
8729
+ SUBMIT_FORM: 'submit_form',
8730
+ CHANGE_TAB: 'tab',
8731
+ HIDE_ELEMENTS: 'hide_elements',
8732
+ SHOW_ELEMENTS: 'show_elements',
8733
+ REFRESH_CHECKOUT: 'refresh_checkout',
8734
+ UPDATE_FORM_VALUES: 'update_form_values',
8735
+ INIT_CHECKOUT: 'init_checkout',
8736
+ INJECT_CUSTOMER_DATA: 'inject_customer_data'
8737
+ };
8738
+ var Trigger = /*#__PURE__*/function () {
8739
+ function Trigger(iFrame) {
8740
+ _classCallCheck(this, Trigger);
8741
+ this.iFrame = iFrame;
8742
+ }
8743
+ return _createClass(Trigger, [{
8744
+ key: "push",
8745
+ value: function push(triggerName) {
8746
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8747
+ if (!this.iFrame.isExist()) return;
8748
+ if (ObjectHelper.values(TRIGGER$1).indexOf(triggerName) === -1) console.warn('unsupported trigger type');
8749
+ var body = {
8750
+ trigger: triggerName,
8751
+ destination: 'widget.paydock',
8752
+ data: data
8753
+ };
8754
+ this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(body), '*');
8755
+ }
8756
+ }]);
8757
+ }();
8758
+
8759
+ var PerformanceService = /*#__PURE__*/function () {
8760
+ function PerformanceService() {
8761
+ _classCallCheck(this, PerformanceService);
8762
+ }
8763
+ return _createClass(PerformanceService, null, [{
8764
+ key: "initialize",
8765
+ value: function initialize(env) {
8766
+ var _this = this;
8767
+ performance.now();
8768
+ // Set environment configuration
8769
+ var envInstance = new Env(API_URL, env);
8770
+ var finalUrl = envInstance.getConf().url;
8771
+ // Add performance optimizations in parallel
8772
+ Promise.all([
8773
+ // Add preconnect
8774
+ new Promise(function (resolve) {
8775
+ _this.addLinkTag('preconnect', finalUrl, true);
8776
+ resolve();
8777
+ }),
8778
+ // Add DNS prefetch
8779
+ new Promise(function (resolve) {
8780
+ _this.addLinkTag('dns-prefetch', finalUrl);
8781
+ resolve();
8782
+ }),
8783
+ // Send warmup request
8784
+ new Promise(function (resolve) {
8785
+ if (window.fetch) {
8786
+ fetch("".concat(finalUrl, "/v1/echo"), {
8787
+ mode: 'no-cors',
8788
+ keepalive: true
8789
+ })["catch"](function () {})["finally"](resolve);
8790
+ } else {
8791
+ resolve();
8792
+ }
8793
+ })]);
8794
+ }
8795
+ /**
8796
+ * Dynamically adds or updates a `<link>` tag in the document's `<head>`.
8797
+ * This utility is designed for performance optimizations like `dns-prefetch` and `preconnect`.
8798
+ *
8799
+ * @param rel - The relationship type of the link (e.g., 'dns-prefetch', 'preconnect').
8800
+ * @param href - The URL for the resource.
8801
+ * @param crossorigin - Specifies if the resource should be fetched with a CORS request. Defaults to false.
8802
+ */
8803
+ }, {
8804
+ key: "addLinkTag",
8805
+ value: function addLinkTag(rel, href) {
8806
+ var crossorigin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
8807
+ try {
8808
+ var existingTag = document.head.querySelector("link[rel=\"".concat(rel, "\"][href*=\"").concat(new URL(href).host, "\"]"));
8809
+ if (existingTag) {
8810
+ return;
8811
+ }
8812
+ var linkElement = this.createLinkElement(rel, href, crossorigin);
8813
+ document.head.prepend(linkElement);
8814
+ } catch (error) {
8815
+ console.error("\u274C [Performance] Failed to add ".concat(rel, " tag for ").concat(href, "."), error);
8816
+ }
8817
+ }
8818
+ /**
8819
+ * Creates and configures a new HTMLLinkElement.
8820
+ *
8821
+ * @param rel - The relationship type.
8822
+ * @param href - The resource URL.
8823
+ * @param crossorigin - The CORS setting.
8824
+ * @returns A configured HTMLLinkElement.
8825
+ * @private
8826
+ */
8827
+ }, {
8828
+ key: "createLinkElement",
8829
+ value: function createLinkElement(rel, href, crossorigin) {
8830
+ var linkElement = document.createElement('link');
8831
+ linkElement.rel = rel;
8832
+ linkElement.href = this.determineHref(rel, href);
8833
+ if (crossorigin) {
8834
+ linkElement.crossOrigin = 'anonymous';
8835
+ }
8836
+ return linkElement;
8837
+ }
8838
+ /**
8839
+ * Determines the appropriate href value based on the link relationship.
8840
+ *
8841
+ * @param rel - The relationship type.
8842
+ * @param originalHref - The original URL.
8843
+ * @returns The processed href string.
8844
+ * @private
8845
+ */
8846
+ }, {
8847
+ key: "determineHref",
8848
+ value: function determineHref(rel, originalHref) {
8849
+ if (rel === 'dns-prefetch') {
8850
+ // For dns-prefetch, a protocol-relative URL to the host is sufficient.
8851
+ var _URL = new URL(originalHref),
8852
+ host = _URL.host;
8853
+ return "//".concat(host);
8854
+ }
8855
+ // For others, like preconnect, the full original URL is required.
8856
+ return originalHref;
8857
+ }
8858
+ }]);
8859
+ }();
8860
+
8706
8861
  var ClickToPaySRC = /*#__PURE__*/function () {
8707
8862
  function ClickToPaySRC(iframe_selector, service_id, public_key, meta, eventEmitter, autoResize, env, alias) {
8708
8863
  _classCallCheck(this, ClickToPaySRC);
@@ -8725,6 +8880,7 @@ var ClickToPaySRC = /*#__PURE__*/function () {
8725
8880
  if (env) this.link.setEnv(env, alias);
8726
8881
  this.iFrameContainer = new Container(iframe_selector);
8727
8882
  this.iFrame = new IFrame(this.iFrameContainer);
8883
+ this.trigger = new Trigger(this.iFrame);
8728
8884
  this.iFrameEvent = new IFrameEvent(window);
8729
8885
  this.setupIFrameEvents();
8730
8886
  }
@@ -8760,6 +8916,8 @@ var ClickToPaySRC = /*#__PURE__*/function () {
8760
8916
  key: "load",
8761
8917
  value: function load() {
8762
8918
  var _this2 = this;
8919
+ // Initialize performance optimizations when environment is guaranteed to be final
8920
+ PerformanceService.initialize(this.link.getEnv());
8763
8921
  this.iFrame.load(this.link.getUrl(), {
8764
8922
  title: 'Click To Pay checkout'
8765
8923
  });
@@ -8811,6 +8969,18 @@ var ClickToPaySRC = /*#__PURE__*/function () {
8811
8969
  }
8812
8970
  });
8813
8971
  }
8972
+ /**
8973
+ * Send customer data to iframe using the established trigger pattern
8974
+ *
8975
+ * @param {CustomerData} customerData - Customer data to inject
8976
+ */
8977
+ }, {
8978
+ key: "injectCustomerData",
8979
+ value: function injectCustomerData(customerData) {
8980
+ this.trigger.push(TRIGGER$1.INJECT_CUSTOMER_DATA, {
8981
+ customer: customerData
8982
+ });
8983
+ }
8814
8984
  }]);
8815
8985
  }();
8816
8986
 
@@ -8999,11 +9169,11 @@ var ClickToPay = /*#__PURE__*/function (_SRC) {
8999
9169
  _this.service_id = service_id;
9000
9170
  _this.public_key_or_access_token = public_key_or_access_token;
9001
9171
  _this.meta = meta;
9172
+ _this.holdingForCustomerData = false;
9002
9173
  return _this;
9003
9174
  }
9004
9175
  /**
9005
9176
  * The final method after configuring the SRC to start the load process of Click To Pay checkout
9006
- *
9007
9177
  */
9008
9178
  _inherits(ClickToPay, _SRC);
9009
9179
  return _createClass(ClickToPay, [{
@@ -9011,62 +9181,53 @@ var ClickToPay = /*#__PURE__*/function (_SRC) {
9011
9181
  value: function load() {
9012
9182
  if (this.provider) return;
9013
9183
  this.meta.customizations = this.style;
9184
+ this.holdingForCustomerData = !!this.meta.hold_for_customer_data;
9014
9185
  this.provider = new ClickToPaySRC(this.iframe_selector, this.service_id, this.public_key_or_access_token, this.meta, this.eventEmitter, this.autoResize, this.env, this.alias);
9015
9186
  this.provider.load();
9016
9187
  }
9017
- }]);
9018
- }(SRC);
9019
-
9020
- /**
9021
- * Interface for classes that represent a trigger data.
9022
- * @interface ITriggerData
9023
- *
9024
- * @param {string} [configuration_token]
9025
- * @param {string} [tab_number]
9026
- * @param {string} [elements]
9027
- * @param {string} [form_values]
9028
- * */
9029
- /**
9030
- * List of available triggers
9031
- *
9032
- * @type {object}
9033
- * @param {string} SUBMIT_FORM=submit_form
9034
- * @param {string} CHANGE_TAB=tab
9035
- * @param {string} HIDE_ELEMENTS=hide_elements
9036
- * @param {string} SHOW_ELEMENTS=show_elements
9037
- * @param {string} REFRESH_CHECKOUT=refresh_checkout
9038
- * @param {string} UPDATE_FORM_VALUES=update_form_values
9039
- * @param {string} INIT_CHECKOUT=init_checkout
9040
- */
9041
- var TRIGGER$1 = {
9042
- SUBMIT_FORM: 'submit_form',
9043
- CHANGE_TAB: 'tab',
9044
- HIDE_ELEMENTS: 'hide_elements',
9045
- SHOW_ELEMENTS: 'show_elements',
9046
- REFRESH_CHECKOUT: 'refresh_checkout',
9047
- UPDATE_FORM_VALUES: 'update_form_values',
9048
- INIT_CHECKOUT: 'init_checkout'
9049
- };
9050
- var Trigger = /*#__PURE__*/function () {
9051
- function Trigger(iFrame) {
9052
- _classCallCheck(this, Trigger);
9053
- this.iFrame = iFrame;
9054
- }
9055
- return _createClass(Trigger, [{
9056
- key: "push",
9057
- value: function push(triggerName) {
9058
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9059
- if (!this.iFrame.isExist()) return;
9060
- if (ObjectHelper.values(TRIGGER$1).indexOf(triggerName) === -1) console.warn('unsupported trigger type');
9061
- var body = {
9062
- trigger: triggerName,
9063
- destination: 'widget.paydock',
9064
- data: data
9065
- };
9066
- this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(body), '*');
9188
+ /**
9189
+ * Inject customer data after widget initialization via postMessage
9190
+ *
9191
+ * @param {Customer} customerData - Customer data to inject
9192
+ * @throws {Error} When customer data is invalid or widget is not ready
9193
+ * @example
9194
+ * widget.injectCustomerData({
9195
+ * email: 'user@example.com',
9196
+ * first_name: 'John',
9197
+ * last_name: 'Doe'
9198
+ * });
9199
+ */
9200
+ }, {
9201
+ key: "injectCustomerData",
9202
+ value: function injectCustomerData(customerData) {
9203
+ if (!this.validateCustomerData(customerData)) {
9204
+ throw new Error('Invalid customer data format. Must include at least email or phone.');
9205
+ }
9206
+ if (!this.provider) {
9207
+ throw new Error('Widget not initialized. Call load() first.');
9208
+ }
9209
+ this.provider.injectCustomerData(customerData);
9210
+ }
9211
+ /**
9212
+ * Validate customer data format
9213
+ *
9214
+ * @private
9215
+ * @param {Customer} customerData - Customer data to validate
9216
+ * @returns {boolean} True if valid
9217
+ */
9218
+ }, {
9219
+ key: "validateCustomerData",
9220
+ value: function validateCustomerData(customerData) {
9221
+ if (!customerData || _typeof$1(customerData) !== 'object') {
9222
+ return false;
9223
+ }
9224
+ // Check if at least email or phone is provided
9225
+ var hasEmail = customerData.email && typeof customerData.email === 'string';
9226
+ var hasPhone = customerData.phone && _typeof$1(customerData.phone) === 'object' && customerData.phone.phone && typeof customerData.phone.phone === 'string';
9227
+ return hasEmail || hasPhone;
9067
9228
  }
9068
9229
  }]);
9069
- }();
9230
+ }(SRC);
9070
9231
 
9071
9232
  var VAULT_DISPLAY_EVENT;
9072
9233
  (function (VAULT_DISPLAY_EVENT) {
@@ -15685,6 +15846,30 @@ var HtmlWidget = /*#__PURE__*/function (_HtmlMultiWidget) {
15685
15846
  }]);
15686
15847
  }(HtmlMultiWidget);
15687
15848
 
15849
+ var Spinner = /*#__PURE__*/function () {
15850
+ function Spinner() {
15851
+ _classCallCheck(this, Spinner);
15852
+ }
15853
+ return _createClass(Spinner, null, [{
15854
+ key: "getSpinnerElement",
15855
+ value: function getSpinnerElement() {
15856
+ return document.getElementById('spinner');
15857
+ }
15858
+ }, {
15859
+ key: "show",
15860
+ value: function show() {
15861
+ var spinner = this.getSpinnerElement();
15862
+ spinner === null || spinner === void 0 ? void 0 : spinner.classList.remove('spinner-wrapper--hidden');
15863
+ }
15864
+ }, {
15865
+ key: "hide",
15866
+ value: function hide() {
15867
+ var spinner = this.getSpinnerElement();
15868
+ spinner === null || spinner === void 0 ? void 0 : spinner.classList.add('spinner-wrapper--hidden');
15869
+ }
15870
+ }]);
15871
+ }();
15872
+
15688
15873
  var InstructionModule$1 = /*#__PURE__*/function () {
15689
15874
  function InstructionModule() {
15690
15875
  _classCallCheck(this, InstructionModule);
@@ -15750,30 +15935,6 @@ function Instruction(instruction) {
15750
15935
  };
15751
15936
  }
15752
15937
 
15753
- var Spinner = /*#__PURE__*/function () {
15754
- function Spinner() {
15755
- _classCallCheck(this, Spinner);
15756
- }
15757
- return _createClass(Spinner, null, [{
15758
- key: "getSpinnerElement",
15759
- value: function getSpinnerElement() {
15760
- return document.getElementById('spinner');
15761
- }
15762
- }, {
15763
- key: "show",
15764
- value: function show() {
15765
- var spinner = this.getSpinnerElement();
15766
- spinner === null || spinner === void 0 ? void 0 : spinner.classList.remove('spinner-wrapper--hidden');
15767
- }
15768
- }, {
15769
- key: "hide",
15770
- value: function hide() {
15771
- var spinner = this.getSpinnerElement();
15772
- spinner === null || spinner === void 0 ? void 0 : spinner.classList.add('spinner-wrapper--hidden');
15773
- }
15774
- }]);
15775
- }();
15776
-
15777
15938
  var SessionHelper = /*#__PURE__*/function () {
15778
15939
  function SessionHelper() {
15779
15940
  _classCallCheck(this, SessionHelper);
@@ -17309,7 +17470,7 @@ var Checkout = /*#__PURE__*/function () {
17309
17470
  key: "isTimeoutInstruction",
17310
17471
  value: function isTimeoutInstruction(response) {
17311
17472
  var _a, _b;
17312
- return ((_a = response.payload) === null || _a === void 0 ? void 0 : _a.status) === 'expired' || ((_b = response.paload) === null || _b === void 0 ? void 0 : _b.title) === 'Session expired';
17473
+ return ((_a = response.payload) === null || _a === void 0 ? void 0 : _a.status) === 'expired' || ((_b = response.payload) === null || _b === void 0 ? void 0 : _b.title) === 'Session expired';
17313
17474
  }
17314
17475
  }, {
17315
17476
  key: "handleInstruction",
@@ -1243,6 +1243,7 @@ interface ITriggerData {
1243
1243
  * @param {string} REFRESH_CHECKOUT=refresh_checkout
1244
1244
  * @param {string} UPDATE_FORM_VALUES=update_form_values
1245
1245
  * @param {string} INIT_CHECKOUT=init_checkout
1246
+ * @param {string} INJECT_CUSTOMER_DATA=inject_customer_data
1246
1247
  */
1247
1248
  declare const TRIGGER: {
1248
1249
  SUBMIT_FORM: string;
@@ -1252,6 +1253,7 @@ declare const TRIGGER: {
1252
1253
  REFRESH_CHECKOUT: string;
1253
1254
  UPDATE_FORM_VALUES: string;
1254
1255
  INIT_CHECKOUT: string;
1256
+ INJECT_CUSTOMER_DATA: string;
1255
1257
  };
1256
1258
  declare class Trigger {
1257
1259
  protected iFrame: IFrame;
@@ -2899,6 +2901,12 @@ interface Customer {
2899
2901
  first_name?: string;
2900
2902
  last_name?: string;
2901
2903
  }
2904
+ interface DpaConfig {
2905
+ dpa_id: string;
2906
+ dpa_name: string;
2907
+ dpa_supported_card_schemes: ('MASTERCARD' | 'VISA' | 'AMEX' | 'DISCOVER')[];
2908
+ mode: 'sandbox' | 'live';
2909
+ }
2902
2910
  interface IClickToPayMeta extends IBaseSRCMeta {
2903
2911
  dpa_data?: IBaseSRCMeta['dpa_data'] & {
2904
2912
  dpa_address?: string;
@@ -2927,6 +2935,8 @@ interface IClickToPayMeta extends IBaseSRCMeta {
2927
2935
  customer?: Customer;
2928
2936
  unaccepted_card_type?: 'CREDIT' | 'DEBIT';
2929
2937
  recognition_token?: string;
2938
+ dpa_config?: DpaConfig;
2939
+ hold_for_customer_data?: boolean;
2930
2940
  }
2931
2941
  type MASTERCARD_DPA_SHIPPING_BILLING_PREFERENCE = 'FULL' | 'POSTAL_COUNTRY' | 'NONE';
2932
2942
  type MASTERCARD_ORDER_TYPE = 'SPLIT_SHIPMENT' | 'PREFERRED_CARD';
@@ -3077,6 +3087,8 @@ declare class ApiInternal extends ApiBase {
3077
3087
  gateway(): ApiGatewayInternal;
3078
3088
  }
3079
3089
 
3090
+ type CustomerData = Customer;
3091
+
3080
3092
  interface SRCProvider {
3081
3093
  load(): void;
3082
3094
  getEnv(): string;
@@ -3086,6 +3098,7 @@ interface SRCProvider {
3086
3098
  showCheckout?(): void;
3087
3099
  reload(): void;
3088
3100
  useAutoResize?(): void;
3101
+ injectCustomerData(customerData: CustomerData): void;
3089
3102
  }
3090
3103
 
3091
3104
  declare abstract class SRC {
@@ -3189,12 +3202,33 @@ declare class ClickToPay extends SRC {
3189
3202
  protected service_id: string;
3190
3203
  protected public_key_or_access_token: string;
3191
3204
  protected meta: IClickToPayMeta;
3205
+ protected holdingForCustomerData: boolean;
3192
3206
  /** @constructs */ constructor(iframe_selector: string, service_id: string, public_key_or_access_token: string, meta: IClickToPayMeta);
3193
3207
  /**
3194
3208
  * The final method after configuring the SRC to start the load process of Click To Pay checkout
3195
- *
3196
3209
  */
3197
3210
  load(): void;
3211
+ /**
3212
+ * Inject customer data after widget initialization via postMessage
3213
+ *
3214
+ * @param {Customer} customerData - Customer data to inject
3215
+ * @throws {Error} When customer data is invalid or widget is not ready
3216
+ * @example
3217
+ * widget.injectCustomerData({
3218
+ * email: 'user@example.com',
3219
+ * first_name: 'John',
3220
+ * last_name: 'Doe'
3221
+ * });
3222
+ */
3223
+ injectCustomerData(customerData: Customer): void;
3224
+ /**
3225
+ * Validate customer data format
3226
+ *
3227
+ * @private
3228
+ * @param {Customer} customerData - Customer data to validate
3229
+ * @returns {boolean} True if valid
3230
+ */
3231
+ private validateCustomerData;
3198
3232
  }
3199
3233
 
3200
3234
  declare class VaultDisplayIframeEvent extends IFrameEvent {