@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/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 = '
|
|
957
|
+
SDK._version = 'v1.127.1-beta';
|
|
958
958
|
|
|
959
959
|
/******************************************************************************
|
|
960
960
|
Copyright (c) Microsoft Corporation.
|
|
@@ -5514,12 +5514,12 @@ var EventEmitter = /*#__PURE__*/function () {
|
|
|
5514
5514
|
* @type {object}
|
|
5515
5515
|
* @param {string} HTML=html
|
|
5516
5516
|
*/
|
|
5517
|
-
var TOKEN_FORMAT;
|
|
5517
|
+
var TOKEN_FORMAT$1;
|
|
5518
5518
|
(function (TOKEN_FORMAT) {
|
|
5519
5519
|
TOKEN_FORMAT["HTML"] = "html";
|
|
5520
5520
|
TOKEN_FORMAT["URL"] = "url";
|
|
5521
5521
|
TOKEN_FORMAT["STANDALONE_3DS"] = "standalone_3ds";
|
|
5522
|
-
})(TOKEN_FORMAT || (TOKEN_FORMAT = {}));
|
|
5522
|
+
})(TOKEN_FORMAT$1 || (TOKEN_FORMAT$1 = {}));
|
|
5523
5523
|
/**
|
|
5524
5524
|
* List of available event's name
|
|
5525
5525
|
* @const EVENT
|
|
@@ -5578,11 +5578,11 @@ var Canvas3ds = /*#__PURE__*/function () {
|
|
|
5578
5578
|
*
|
|
5579
5579
|
*/
|
|
5580
5580
|
function load() {
|
|
5581
|
-
if (this.token.format === TOKEN_FORMAT.HTML) this.iFrame.loadFromHtml(this.token.content, {
|
|
5581
|
+
if (this.token.format === TOKEN_FORMAT$1.HTML) this.iFrame.loadFromHtml(this.token.content, {
|
|
5582
5582
|
title: '3d secure authentication'
|
|
5583
|
-
}, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT.URL) this.iFrame.load(this.token.content, {
|
|
5583
|
+
}, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT$1.URL) this.iFrame.load(this.token.content, {
|
|
5584
5584
|
title: '3d secure authentication'
|
|
5585
|
-
}, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT.STANDALONE_3DS) this.standalone3dsService.load(this.token.content, {
|
|
5585
|
+
}, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT$1.STANDALONE_3DS) this.standalone3dsService.load(this.token.content, {
|
|
5586
5586
|
title: '3d secure authentication'
|
|
5587
5587
|
});else console.error('Token contain unsupported payload');
|
|
5588
5588
|
}
|
|
@@ -5630,7 +5630,7 @@ var Canvas3ds = /*#__PURE__*/function () {
|
|
|
5630
5630
|
key: "on",
|
|
5631
5631
|
value: function on(eventName, cb) {
|
|
5632
5632
|
var _this = this;
|
|
5633
|
-
if (this.token.format === TOKEN_FORMAT.STANDALONE_3DS) {
|
|
5633
|
+
if (this.token.format === TOKEN_FORMAT$1.STANDALONE_3DS) {
|
|
5634
5634
|
if (typeof cb === 'function') return this.eventEmitter.subscribe(eventName, cb);
|
|
5635
5635
|
return new Promise(function (resolve) {
|
|
5636
5636
|
return _this.eventEmitter.subscribe(eventName, function (res) {
|
|
@@ -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
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
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);
|
|
@@ -16077,6 +16238,95 @@ var InstructionBankAccountFormShow = /*#__PURE__*/function (_InstructionHandler)
|
|
|
16077
16238
|
}(InstructionHandler);
|
|
16078
16239
|
InstructionBankAccountFormShow = __decorate([Instruction('instruction.bank_account_form.show')], InstructionBankAccountFormShow);
|
|
16079
16240
|
|
|
16241
|
+
var toByteArray_1 = toByteArray;
|
|
16242
|
+
var revLookup = [];
|
|
16243
|
+
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
|
|
16244
|
+
|
|
16245
|
+
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
16246
|
+
for (var i$2 = 0, len = code.length; i$2 < len; ++i$2) {
|
|
16247
|
+
revLookup[code.charCodeAt(i$2)] = i$2;
|
|
16248
|
+
}
|
|
16249
|
+
|
|
16250
|
+
// Support decoding URL-safe base64 strings, as Node.js does.
|
|
16251
|
+
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
|
16252
|
+
revLookup['-'.charCodeAt(0)] = 62;
|
|
16253
|
+
revLookup['_'.charCodeAt(0)] = 63;
|
|
16254
|
+
|
|
16255
|
+
function getLens (b64) {
|
|
16256
|
+
var len = b64.length;
|
|
16257
|
+
|
|
16258
|
+
if (len % 4 > 0) {
|
|
16259
|
+
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
16260
|
+
}
|
|
16261
|
+
|
|
16262
|
+
// Trim off extra bytes after placeholder bytes are found
|
|
16263
|
+
// See: https://github.com/beatgammit/base64-js/issues/42
|
|
16264
|
+
var validLen = b64.indexOf('=');
|
|
16265
|
+
if (validLen === -1) validLen = len;
|
|
16266
|
+
|
|
16267
|
+
var placeHoldersLen = validLen === len
|
|
16268
|
+
? 0
|
|
16269
|
+
: 4 - (validLen % 4);
|
|
16270
|
+
|
|
16271
|
+
return [validLen, placeHoldersLen]
|
|
16272
|
+
}
|
|
16273
|
+
|
|
16274
|
+
function _byteLength (b64, validLen, placeHoldersLen) {
|
|
16275
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
16276
|
+
}
|
|
16277
|
+
|
|
16278
|
+
function toByteArray (b64) {
|
|
16279
|
+
var tmp;
|
|
16280
|
+
var lens = getLens(b64);
|
|
16281
|
+
var validLen = lens[0];
|
|
16282
|
+
var placeHoldersLen = lens[1];
|
|
16283
|
+
|
|
16284
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
16285
|
+
|
|
16286
|
+
var curByte = 0;
|
|
16287
|
+
|
|
16288
|
+
// if there are placeholders, only get up to the last complete 4 chars
|
|
16289
|
+
var len = placeHoldersLen > 0
|
|
16290
|
+
? validLen - 4
|
|
16291
|
+
: validLen;
|
|
16292
|
+
|
|
16293
|
+
var i;
|
|
16294
|
+
for (i = 0; i < len; i += 4) {
|
|
16295
|
+
tmp =
|
|
16296
|
+
(revLookup[b64.charCodeAt(i)] << 18) |
|
|
16297
|
+
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
|
16298
|
+
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
|
16299
|
+
revLookup[b64.charCodeAt(i + 3)];
|
|
16300
|
+
arr[curByte++] = (tmp >> 16) & 0xFF;
|
|
16301
|
+
arr[curByte++] = (tmp >> 8) & 0xFF;
|
|
16302
|
+
arr[curByte++] = tmp & 0xFF;
|
|
16303
|
+
}
|
|
16304
|
+
|
|
16305
|
+
if (placeHoldersLen === 2) {
|
|
16306
|
+
tmp =
|
|
16307
|
+
(revLookup[b64.charCodeAt(i)] << 2) |
|
|
16308
|
+
(revLookup[b64.charCodeAt(i + 1)] >> 4);
|
|
16309
|
+
arr[curByte++] = tmp & 0xFF;
|
|
16310
|
+
}
|
|
16311
|
+
|
|
16312
|
+
if (placeHoldersLen === 1) {
|
|
16313
|
+
tmp =
|
|
16314
|
+
(revLookup[b64.charCodeAt(i)] << 10) |
|
|
16315
|
+
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
|
16316
|
+
(revLookup[b64.charCodeAt(i + 2)] >> 2);
|
|
16317
|
+
arr[curByte++] = (tmp >> 8) & 0xFF;
|
|
16318
|
+
arr[curByte++] = tmp & 0xFF;
|
|
16319
|
+
}
|
|
16320
|
+
|
|
16321
|
+
return arr
|
|
16322
|
+
}
|
|
16323
|
+
|
|
16324
|
+
var TOKEN_FORMAT;
|
|
16325
|
+
(function (TOKEN_FORMAT) {
|
|
16326
|
+
TOKEN_FORMAT["HTML"] = "html";
|
|
16327
|
+
TOKEN_FORMAT["URL"] = "url";
|
|
16328
|
+
TOKEN_FORMAT["STANDALONE_3DS"] = "standalone_3ds";
|
|
16329
|
+
})(TOKEN_FORMAT || (TOKEN_FORMAT = {}));
|
|
16080
16330
|
var InstructionCanvas3dsShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
16081
16331
|
function InstructionCanvas3dsShow() {
|
|
16082
16332
|
_classCallCheck(this, InstructionCanvas3dsShow);
|
|
@@ -16087,12 +16337,25 @@ var InstructionCanvas3dsShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
|
16087
16337
|
key: "handle",
|
|
16088
16338
|
value: function handle(context) {
|
|
16089
16339
|
var _this = this;
|
|
16340
|
+
var token = this.decodeBase64Token(context.payload._3ds_token);
|
|
16090
16341
|
var canvas = new Canvas3ds(this.formSelector, context.payload._3ds_token);
|
|
16091
16342
|
canvas.setEnv(this.getEnv(context.instruction_token));
|
|
16092
|
-
canvas.on('chargeAuth', function (
|
|
16343
|
+
canvas.on('chargeAuth', function () {
|
|
16093
16344
|
return Spinner.show();
|
|
16094
16345
|
});
|
|
16095
|
-
canvas.on('
|
|
16346
|
+
canvas.on('chargeAuthChallenge', function () {
|
|
16347
|
+
if (token.format === TOKEN_FORMAT.STANDALONE_3DS) {
|
|
16348
|
+
Spinner.hide();
|
|
16349
|
+
_this.observeIframeAndResize();
|
|
16350
|
+
}
|
|
16351
|
+
});
|
|
16352
|
+
canvas.on('chargeAuthDecoupled', function () {
|
|
16353
|
+
if (token.format === TOKEN_FORMAT.STANDALONE_3DS) {
|
|
16354
|
+
Spinner.hide();
|
|
16355
|
+
_this.observeIframeAndResize();
|
|
16356
|
+
}
|
|
16357
|
+
});
|
|
16358
|
+
canvas.on('chargeAuthSuccess', function () {
|
|
16096
16359
|
var _a;
|
|
16097
16360
|
(_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
|
|
16098
16361
|
_this.api.checkout().callback({
|
|
@@ -16106,8 +16369,9 @@ var InstructionCanvas3dsShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
|
16106
16369
|
})["catch"](function (response) {
|
|
16107
16370
|
return console.error('callback.child_widget.status - chargeAuthSuccess: error', response);
|
|
16108
16371
|
});
|
|
16372
|
+
Spinner.show();
|
|
16109
16373
|
});
|
|
16110
|
-
canvas.on('chargeAuthReject', function (
|
|
16374
|
+
canvas.on('chargeAuthReject', function () {
|
|
16111
16375
|
var _a;
|
|
16112
16376
|
// **TODO add interface for chargeAuthReject event **//
|
|
16113
16377
|
(_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
|
|
@@ -16122,6 +16386,7 @@ var InstructionCanvas3dsShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
|
16122
16386
|
})["catch"](function (response) {
|
|
16123
16387
|
return console.error('callback.child_widget.status - chargeAuthReject: error', response);
|
|
16124
16388
|
});
|
|
16389
|
+
Spinner.show();
|
|
16125
16390
|
});
|
|
16126
16391
|
canvas.on('error', function (event) {
|
|
16127
16392
|
var _a;
|
|
@@ -16138,15 +16403,60 @@ var InstructionCanvas3dsShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
|
16138
16403
|
})["catch"](function (response) {
|
|
16139
16404
|
return console.error('callback.child_widget.status - errorEvent: error', response);
|
|
16140
16405
|
});
|
|
16406
|
+
Spinner.show();
|
|
16141
16407
|
});
|
|
16142
16408
|
canvas.load();
|
|
16143
|
-
|
|
16409
|
+
if (token.format !== TOKEN_FORMAT.STANDALONE_3DS) {
|
|
16410
|
+
Spinner.hide();
|
|
16411
|
+
}
|
|
16144
16412
|
}
|
|
16145
16413
|
}, {
|
|
16146
16414
|
key: "destroy",
|
|
16147
16415
|
value: function destroy() {
|
|
16148
16416
|
document.querySelector(this.formSelector).innerHTML = '';
|
|
16149
16417
|
}
|
|
16418
|
+
}, {
|
|
16419
|
+
key: "decodeBase64Token",
|
|
16420
|
+
value: function decodeBase64Token(token) {
|
|
16421
|
+
try {
|
|
16422
|
+
var base64 = token.replace(/-/g, '+').replace(/_/g, '/').padEnd(Math.ceil(token.length / 4) * 4, '=');
|
|
16423
|
+
var bytes = toByteArray_1(base64);
|
|
16424
|
+
var json = new TextDecoder().decode(bytes);
|
|
16425
|
+
return JSON.parse(json);
|
|
16426
|
+
} catch (err) {
|
|
16427
|
+
console.error('Failed to decode _3ds_token:', err);
|
|
16428
|
+
throw err;
|
|
16429
|
+
}
|
|
16430
|
+
}
|
|
16431
|
+
}, {
|
|
16432
|
+
key: "observeIframeAndResize",
|
|
16433
|
+
value: function observeIframeAndResize() {
|
|
16434
|
+
var outer = document.querySelector('#standaloneWidget');
|
|
16435
|
+
if (outer) {
|
|
16436
|
+
outer.style.display = 'flex';
|
|
16437
|
+
outer.style.justifyContent = 'center';
|
|
16438
|
+
}
|
|
16439
|
+
var container = document.querySelector('#paydock_authorization_iframe');
|
|
16440
|
+
if (!container) {
|
|
16441
|
+
console.warn('Container not found');
|
|
16442
|
+
return;
|
|
16443
|
+
}
|
|
16444
|
+
var observer = new MutationObserver(function () {
|
|
16445
|
+
var iframe = container.querySelector('iframe');
|
|
16446
|
+
if (iframe) {
|
|
16447
|
+
iframe.style.width = '100%';
|
|
16448
|
+
iframe.style.height = '500px';
|
|
16449
|
+
iframe.style.border = 'none';
|
|
16450
|
+
iframe.style.display = 'block';
|
|
16451
|
+
console.info('3DS iframe resized', iframe);
|
|
16452
|
+
observer.disconnect();
|
|
16453
|
+
}
|
|
16454
|
+
});
|
|
16455
|
+
observer.observe(container, {
|
|
16456
|
+
childList: true,
|
|
16457
|
+
subtree: true
|
|
16458
|
+
});
|
|
16459
|
+
}
|
|
16150
16460
|
}]);
|
|
16151
16461
|
}(InstructionHandler);
|
|
16152
16462
|
InstructionCanvas3dsShow = __decorate([Instruction('instruction.canvas_3ds_form.show')], InstructionCanvas3dsShow);
|
|
@@ -17160,7 +17470,7 @@ var Checkout = /*#__PURE__*/function () {
|
|
|
17160
17470
|
key: "isTimeoutInstruction",
|
|
17161
17471
|
value: function isTimeoutInstruction(response) {
|
|
17162
17472
|
var _a, _b;
|
|
17163
|
-
return ((_a = response.payload) === null || _a === void 0 ? void 0 : _a.status) === 'expired' || ((_b = response.
|
|
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';
|
|
17164
17474
|
}
|
|
17165
17475
|
}, {
|
|
17166
17476
|
key: "handleInstruction",
|