@paydock/client-sdk 1.126.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 (32) hide show
  1. package/README.md +141 -1
  2. package/bundles/index.cjs +398 -88
  3. package/bundles/index.cjs.d.ts +35 -1
  4. package/bundles/index.mjs +398 -88
  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/checkout/instructions/v1/instruction.canvas_3ds.show.d.ts +2 -0
  9. package/bundles/types/checkout/instructions/v1/instruction.canvas_3ds.show.d.ts.map +1 -1
  10. package/bundles/types/components/trigger.d.ts +2 -0
  11. package/bundles/types/components/trigger.d.ts.map +1 -1
  12. package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts +23 -2
  13. package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts.map +1 -1
  14. package/bundles/types/secure-remote-commerce/index.d.ts +7 -1
  15. package/bundles/types/secure-remote-commerce/index.d.ts.map +1 -1
  16. package/bundles/types/secure-remote-commerce/interfaces.d.ts +10 -2
  17. package/bundles/types/secure-remote-commerce/interfaces.d.ts.map +1 -1
  18. package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts +10 -1
  19. package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts.map +1 -1
  20. package/bundles/types/secure-remote-commerce/providers/src-provider.d.ts +2 -0
  21. package/bundles/types/secure-remote-commerce/providers/src-provider.d.ts.map +1 -1
  22. package/bundles/types/secure-remote-commerce/services/performance.service.d.ts +32 -0
  23. package/bundles/types/secure-remote-commerce/services/performance.service.d.ts.map +1 -0
  24. package/bundles/widget.umd.js +398 -88
  25. package/bundles/widget.umd.js.d.ts +35 -1
  26. package/bundles/widget.umd.js.min.d.ts +35 -1
  27. package/bundles/widget.umd.min.js +1 -1
  28. package/docs/api-widget.md +1 -0
  29. package/docs/click-to-pay-examples.md +109 -0
  30. package/docs/click-to-pay.md +31 -1
  31. package/package.json +1 -1
  32. package/slate.md +109 -0
@@ -2539,4 +2539,5 @@ List of available triggers
2539
2539
  | REFRESH_CHECKOUT | <code>string</code> | <code>&quot;refresh_checkout&quot;</code> |
2540
2540
  | UPDATE_FORM_VALUES | <code>string</code> | <code>&quot;update_form_values&quot;</code> |
2541
2541
  | INIT_CHECKOUT | <code>string</code> | <code>&quot;init_checkout&quot;</code> |
2542
+ | INJECT_CUSTOMER_DATA | <code>string</code> | <code>&quot;inject_customer_data&quot;</code> |
2542
2543
 
@@ -229,3 +229,112 @@ src.setStyles({
229
229
  font_family: 'Arial',
230
230
  });
231
231
  ```
232
+
233
+ ## Configurations for background loading and improved User Load times
234
+
235
+ ### hold_for_customer_data
236
+ 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.
237
+
238
+ ```javascript
239
+ const clickToPay = new cba.ClickToPay("#checkoutIframe", SERVICE_ID, PUBLIC_KEY, {
240
+ hold_for_customer_data: true,
241
+ dpa_config: {
242
+ dpa_id: DPA_ID,
243
+ // ... other config
244
+ }
245
+ });
246
+ ```
247
+
248
+ ### injectCustomerData(customer)
249
+ 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.
250
+
251
+ ```javascript
252
+ clickToPay.injectCustomerData({
253
+ email: "customer@example.com",
254
+ first_name: "John",
255
+ last_name: "Doe",
256
+ phone: "+61400123456" // Include country code
257
+ });
258
+ ```
259
+
260
+ ### Background Loading Example
261
+ Here's a complete example showing how to implement background loading while collecting customer information:
262
+
263
+ ```javascript
264
+ // 1. Initialize with hold_for_customer_data
265
+ const clickToPay = new cba.ClickToPay("#checkoutIframe", SERVICE_ID, PUBLIC_KEY, {
266
+ hold_for_customer_data: true,
267
+ dpa_config: {
268
+ dpa_id: DPA_ID,
269
+ // ... other config
270
+ }
271
+ });
272
+
273
+ // Hide checkout and show form initially
274
+ document.getElementById("checkoutIframe").style.display = 'none';
275
+ document.getElementById("customerForm").style.display = 'block';
276
+ document.getElementById("loader").style.display = 'none';
277
+
278
+ // 2. Setup event handlers
279
+ clickToPay.on('iframeLoaded', () => {
280
+ // Iframe is now loaded
281
+ });
282
+
283
+ clickToPay.on('checkoutReady', () => {
284
+ // Hide loader, show checkout
285
+ document.getElementById("loader").style.display = 'none';
286
+ document.getElementById("checkoutIframe").style.display = 'block';
287
+ clickToPay.showCheckout();
288
+ });
289
+
290
+ // 3. Start loading in background
291
+ clickToPay.load();
292
+
293
+ // 4. Handle form submission
294
+ document.getElementById("submitButton").addEventListener("click", (e) => {
295
+ e.preventDefault();
296
+
297
+ const customer = {
298
+ email: document.getElementById("email").value.trim(),
299
+ first_name: document.getElementById("firstName").value.trim(),
300
+ last_name: document.getElementById("lastName").value.trim(),
301
+ phone: document.getElementById("phone").value.trim()
302
+ };
303
+
304
+ // Hide form, show loader
305
+ document.getElementById("customerForm").style.display = "none";
306
+ document.getElementById("loader").style.display = "flex";
307
+
308
+ try {
309
+ // Inject customer data to continue checkout
310
+ clickToPay.injectCustomerData(customer);
311
+ } catch (error) {
312
+ // Show form again on error
313
+ document.getElementById("customerForm").style.display = "block";
314
+ document.getElementById("loader").style.display = "none";
315
+ alert("An error occurred. Please try again.");
316
+ }
317
+ });
318
+ ```
319
+
320
+ #### HTML Structure
321
+ Here's the required HTML structure for the background loading example:
322
+
323
+ ```html
324
+ <!-- Click to Pay iframe container -->
325
+ <div id="checkoutIframe"></div>
326
+
327
+ <!-- Customer information form -->
328
+ <form id="customerForm">
329
+ <input type="email" id="email" placeholder="Email" required>
330
+ <input type="text" id="firstName" placeholder="First Name" required>
331
+ <input type="text" id="lastName" placeholder="Last Name" required>
332
+ <input type="tel" id="phone" placeholder="Phone (with country code)" required>
333
+ <button type="submit" id="submitButton">Continue to Checkout</button>
334
+ </form>
335
+
336
+ <!-- Loading indicator -->
337
+ <div id="loader" style="display: none;">
338
+ Loading...
339
+ </div>
340
+ ```
@@ -53,7 +53,7 @@ Interface of data used for the Mastercard Checkout. For further information refe
53
53
  | [checkout_experience] | <code>string</code> | Checkout experience type, either 'WITHIN_CHECKOUT' or 'PAYMENT_SETTINGS'. |
54
54
  | [services] | <code>string</code> | Services offered, such as 'INLINE_CHECKOUT' or 'INLINE_INSTALLMENTS'. |
55
55
  | [dpa_transaction_options] | <code>object</code> | Object that stores options for creating a transaction with DPA. |
56
- | [dpa_transaction_options.dpa_locale] | <code>string</code> | DPAs preferred locale, example en_US. |
56
+ | [dpa_transaction_options.dpa_locale] | <code>string</code> | DPA's preferred locale, example en_US. |
57
57
  | [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. |
58
58
  | [dpa_transaction_options.dpa_billing_preference] | <code>string</code> | Billing preferences for DPA, options are 'FULL', 'POSTAL_COUNTRY', 'NONE'. |
59
59
  | [dpa_transaction_options.payment_options] | <code>Array.&lt;object&gt;</code> | Payment options included in the transaction. |
@@ -78,6 +78,12 @@ Interface of data used for the Mastercard Checkout. For further information refe
78
78
  | [customer.phone.country_code] | <code>string</code> | Customer phone country code (example "1" for US). |
79
79
  | [customer.phone.phone] | <code>string</code> | Customer phone number. |
80
80
  | [unaccepted_card_type] | <code>string</code> | Used to block a specific card type. Options are 'CREDIT', 'DEBIT'. |
81
+ | [dpa_config] | <code>object</code> | Raw DPA configuration object for performance optimization. Skips API call when provided. |
82
+ | [dpa_config.dpa_id] | <code>string</code> | DPA identifier. |
83
+ | [dpa_config.dpa_name] | <code>string</code> | DPA name. |
84
+ | [dpa_config.dpa_supported_card_schemes] | <code>Array.&lt;string&gt;</code> | List of supported card schemes: 'MASTERCARD', 'VISA', 'AMEX', 'DISCOVER'. |
85
+ | [dpa_config.mode] | <code>string</code> | DPA mode, either 'sandbox' or 'live'. |
86
+ | [hold_for_customer_data] | <code>boolean</code> | Flag to hold initialization for customer data injection. Enables background initialization. |
81
87
 
82
88
  <a name="EventData" id="EventData" href="#EventData">&nbsp;</a>
83
89
 
@@ -152,6 +158,7 @@ Class ClickToPay include methods for interacting with the ClickToPay checkout an
152
158
  * [ClickToPay](#ClickToPay) ⇐ <code>SRC</code>
153
159
  * [new ClickToPay(iframe_selector, service_id, public_key_or_access_token, meta)](#new_ClickToPay_new)
154
160
  * [.load()](#ClickToPay+load)
161
+ * [.injectCustomerData(customerData)](#ClickToPay+injectCustomerData)
155
162
  * [.setStyles(fields)](#SRC+setStyles)
156
163
  * [.setEnv(env, [alias])](#SRC+setEnv)
157
164
  * [.getEnv()](#SRC+getEnv)
@@ -182,6 +189,29 @@ var mastercardSRC = new ClickToPay('#checkoutIframe', 'service_id', 'public_key'
182
189
  The final method after configuring the SRC to start the load process of Click To Pay checkout
183
190
 
184
191
  **Kind**: instance method of [<code>ClickToPay</code>](#ClickToPay)
192
+ <a name="ClickToPay+injectCustomerData" id="ClickToPay+injectCustomerData" href="#ClickToPay+injectCustomerData">&nbsp;</a>
193
+
194
+ ### clickToPay.injectCustomerData(customerData)
195
+ Inject customer data after widget initialization via postMessage
196
+
197
+ **Kind**: instance method of [<code>ClickToPay</code>](#ClickToPay)
198
+ **Throws**:
199
+
200
+ - <code>Error</code> When customer data is invalid or widget is not ready
201
+
202
+
203
+ | Param | Type | Description |
204
+ | --- | --- | --- |
205
+ | customerData | <code>Customer</code> | Customer data to inject |
206
+
207
+ **Example**
208
+ ```js
209
+ widget.injectCustomerData({
210
+ email: 'user@example.com',
211
+ first_name: 'John',
212
+ last_name: 'Doe'
213
+ });
214
+ ```
185
215
  <a name="SRC+setStyles" id="SRC+setStyles" href="#SRC+setStyles">&nbsp;</a>
186
216
 
187
217
  ### clickToPay.setStyles(fields)
package/package.json CHANGED
@@ -104,7 +104,7 @@
104
104
  }
105
105
  },
106
106
  "name": "@paydock/client-sdk",
107
- "version": "1.126.0-beta",
107
+ "version": "1.127.1-beta",
108
108
  "scripts": {
109
109
  "build:doc": "node docs/html/marked.js",
110
110
  "build:js": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
package/slate.md CHANGED
@@ -2062,6 +2062,115 @@ src.setStyles({
2062
2062
  });
2063
2063
  ```
2064
2064
 
2065
+ ## Configurations for background loading and improved User Load times
2066
+
2067
+ ### hold_for_customer_data
2068
+ 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.
2069
+
2070
+ ```javascript
2071
+ const clickToPay = new cba.ClickToPay("#checkoutIframe", SERVICE_ID, PUBLIC_KEY, {
2072
+ hold_for_customer_data: true,
2073
+ dpa_config: {
2074
+ dpa_id: DPA_ID,
2075
+ // ... other config
2076
+ }
2077
+ });
2078
+ ```
2079
+
2080
+ ### injectCustomerData(customer)
2081
+ 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.
2082
+
2083
+ ```javascript
2084
+ clickToPay.injectCustomerData({
2085
+ email: "customer@example.com",
2086
+ first_name: "John",
2087
+ last_name: "Doe",
2088
+ phone: "+61400123456" // Include country code
2089
+ });
2090
+ ```
2091
+
2092
+ ### Background Loading Example
2093
+ Here's a complete example showing how to implement background loading while collecting customer information:
2094
+
2095
+ ```javascript
2096
+ // 1. Initialize with hold_for_customer_data
2097
+ const clickToPay = new cba.ClickToPay("#checkoutIframe", SERVICE_ID, PUBLIC_KEY, {
2098
+ hold_for_customer_data: true,
2099
+ dpa_config: {
2100
+ dpa_id: DPA_ID,
2101
+ // ... other config
2102
+ }
2103
+ });
2104
+
2105
+ // Hide checkout and show form initially
2106
+ document.getElementById("checkoutIframe").style.display = 'none';
2107
+ document.getElementById("customerForm").style.display = 'block';
2108
+ document.getElementById("loader").style.display = 'none';
2109
+
2110
+ // 2. Setup event handlers
2111
+ clickToPay.on('iframeLoaded', () => {
2112
+ // Iframe is now loaded
2113
+ });
2114
+
2115
+ clickToPay.on('checkoutReady', () => {
2116
+ // Hide loader, show checkout
2117
+ document.getElementById("loader").style.display = 'none';
2118
+ document.getElementById("checkoutIframe").style.display = 'block';
2119
+ clickToPay.showCheckout();
2120
+ });
2121
+
2122
+ // 3. Start loading in background
2123
+ clickToPay.load();
2124
+
2125
+ // 4. Handle form submission
2126
+ document.getElementById("submitButton").addEventListener("click", (e) => {
2127
+ e.preventDefault();
2128
+
2129
+ const customer = {
2130
+ email: document.getElementById("email").value.trim(),
2131
+ first_name: document.getElementById("firstName").value.trim(),
2132
+ last_name: document.getElementById("lastName").value.trim(),
2133
+ phone: document.getElementById("phone").value.trim()
2134
+ };
2135
+
2136
+ // Hide form, show loader
2137
+ document.getElementById("customerForm").style.display = "none";
2138
+ document.getElementById("loader").style.display = "flex";
2139
+
2140
+ try {
2141
+ // Inject customer data to continue checkout
2142
+ clickToPay.injectCustomerData(customer);
2143
+ } catch (error) {
2144
+ // Show form again on error
2145
+ document.getElementById("customerForm").style.display = "block";
2146
+ document.getElementById("loader").style.display = "none";
2147
+ alert("An error occurred. Please try again.");
2148
+ }
2149
+ });
2150
+ ```
2151
+
2152
+ #### HTML Structure
2153
+ Here's the required HTML structure for the background loading example:
2154
+
2155
+ ```html
2156
+ <!-- Click to Pay iframe container -->
2157
+ <div id="checkoutIframe"></div>
2158
+
2159
+ <!-- Customer information form -->
2160
+ <form id="customerForm">
2161
+ <input type="email" id="email" placeholder="Email" required>
2162
+ <input type="text" id="firstName" placeholder="First Name" required>
2163
+ <input type="text" id="lastName" placeholder="Last Name" required>
2164
+ <input type="tel" id="phone" placeholder="Phone (with country code)" required>
2165
+ <button type="submit" id="submitButton">Continue to Checkout</button>
2166
+ </form>
2167
+
2168
+ <!-- Loading indicator -->
2169
+ <div id="loader" style="display: none;">
2170
+ Loading...
2171
+ </div>
2172
+ ```
2173
+
2065
2174
  # Fraud prevention
2066
2175
 
2067
2176
  The Fraud Prevention module allows you to add security layers to your payment workflows