@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.
- package/README.md +141 -1
- package/bundles/index.cjs +398 -88
- package/bundles/index.cjs.d.ts +35 -1
- package/bundles/index.mjs +398 -88
- package/bundles/index.mjs.d.ts +35 -1
- package/bundles/types/checkout/checkout.d.ts +4 -4
- package/bundles/types/checkout/checkout.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.canvas_3ds.show.d.ts +2 -0
- package/bundles/types/checkout/instructions/v1/instruction.canvas_3ds.show.d.ts.map +1 -1
- package/bundles/types/components/trigger.d.ts +2 -0
- package/bundles/types/components/trigger.d.ts.map +1 -1
- package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts +23 -2
- package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts.map +1 -1
- package/bundles/types/secure-remote-commerce/index.d.ts +7 -1
- package/bundles/types/secure-remote-commerce/index.d.ts.map +1 -1
- package/bundles/types/secure-remote-commerce/interfaces.d.ts +10 -2
- package/bundles/types/secure-remote-commerce/interfaces.d.ts.map +1 -1
- package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts +10 -1
- package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts.map +1 -1
- package/bundles/types/secure-remote-commerce/providers/src-provider.d.ts +2 -0
- package/bundles/types/secure-remote-commerce/providers/src-provider.d.ts.map +1 -1
- package/bundles/types/secure-remote-commerce/services/performance.service.d.ts +32 -0
- package/bundles/types/secure-remote-commerce/services/performance.service.d.ts.map +1 -0
- package/bundles/widget.umd.js +398 -88
- package/bundles/widget.umd.js.d.ts +35 -1
- package/bundles/widget.umd.js.min.d.ts +35 -1
- package/bundles/widget.umd.min.js +1 -1
- package/docs/api-widget.md +1 -0
- package/docs/click-to-pay-examples.md +109 -0
- package/docs/click-to-pay.md +31 -1
- package/package.json +1 -1
- 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>"refresh_checkout"</code> |
|
|
2912
2912
|
| UPDATE_FORM_VALUES | <code>string</code> | <code>"update_form_values"</code> |
|
|
2913
2913
|
| INIT_CHECKOUT | <code>string</code> | <code>"init_checkout"</code> |
|
|
2914
|
+
| INJECT_CUSTOMER_DATA | <code>string</code> | <code>"inject_customer_data"</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> | DPA
|
|
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.<string></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.<object></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.<string></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"> </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"> </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"> </a>
|
|
8292
8432
|
|
|
8293
8433
|
### clickToPay.setStyles(fields)
|