@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/widget.umd.js
CHANGED
|
@@ -958,7 +958,7 @@
|
|
|
958
958
|
version: 'x-sdk-version',
|
|
959
959
|
type: 'x-sdk-type'
|
|
960
960
|
});
|
|
961
|
-
SDK._version = '
|
|
961
|
+
SDK._version = 'v1.127.1-beta';
|
|
962
962
|
|
|
963
963
|
/******************************************************************************
|
|
964
964
|
Copyright (c) Microsoft Corporation.
|
|
@@ -5518,12 +5518,12 @@
|
|
|
5518
5518
|
* @type {object}
|
|
5519
5519
|
* @param {string} HTML=html
|
|
5520
5520
|
*/
|
|
5521
|
-
var TOKEN_FORMAT;
|
|
5521
|
+
var TOKEN_FORMAT$1;
|
|
5522
5522
|
(function (TOKEN_FORMAT) {
|
|
5523
5523
|
TOKEN_FORMAT["HTML"] = "html";
|
|
5524
5524
|
TOKEN_FORMAT["URL"] = "url";
|
|
5525
5525
|
TOKEN_FORMAT["STANDALONE_3DS"] = "standalone_3ds";
|
|
5526
|
-
})(TOKEN_FORMAT || (TOKEN_FORMAT = {}));
|
|
5526
|
+
})(TOKEN_FORMAT$1 || (TOKEN_FORMAT$1 = {}));
|
|
5527
5527
|
/**
|
|
5528
5528
|
* List of available event's name
|
|
5529
5529
|
* @const EVENT
|
|
@@ -5582,11 +5582,11 @@
|
|
|
5582
5582
|
*
|
|
5583
5583
|
*/
|
|
5584
5584
|
function load() {
|
|
5585
|
-
if (this.token.format === TOKEN_FORMAT.HTML) this.iFrame.loadFromHtml(this.token.content, {
|
|
5585
|
+
if (this.token.format === TOKEN_FORMAT$1.HTML) this.iFrame.loadFromHtml(this.token.content, {
|
|
5586
5586
|
title: '3d secure authentication'
|
|
5587
|
-
}, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT.URL) this.iFrame.load(this.token.content, {
|
|
5587
|
+
}, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT$1.URL) this.iFrame.load(this.token.content, {
|
|
5588
5588
|
title: '3d secure authentication'
|
|
5589
|
-
}, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT.STANDALONE_3DS) this.standalone3dsService.load(this.token.content, {
|
|
5589
|
+
}, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT$1.STANDALONE_3DS) this.standalone3dsService.load(this.token.content, {
|
|
5590
5590
|
title: '3d secure authentication'
|
|
5591
5591
|
});else console.error('Token contain unsupported payload');
|
|
5592
5592
|
}
|
|
@@ -5634,7 +5634,7 @@
|
|
|
5634
5634
|
key: "on",
|
|
5635
5635
|
value: function on(eventName, cb) {
|
|
5636
5636
|
var _this = this;
|
|
5637
|
-
if (this.token.format === TOKEN_FORMAT.STANDALONE_3DS) {
|
|
5637
|
+
if (this.token.format === TOKEN_FORMAT$1.STANDALONE_3DS) {
|
|
5638
5638
|
if (typeof cb === 'function') return this.eventEmitter.subscribe(eventName, cb);
|
|
5639
5639
|
return new Promise(function (resolve) {
|
|
5640
5640
|
return _this.eventEmitter.subscribe(eventName, function (res) {
|
|
@@ -8707,6 +8707,161 @@
|
|
|
8707
8707
|
ENABLE_SRC_POPUP: 'enable_src_popup'
|
|
8708
8708
|
};
|
|
8709
8709
|
|
|
8710
|
+
/**
|
|
8711
|
+
* Interface for classes that represent a trigger data.
|
|
8712
|
+
* @interface ITriggerData
|
|
8713
|
+
*
|
|
8714
|
+
* @param {string} [configuration_token]
|
|
8715
|
+
* @param {string} [tab_number]
|
|
8716
|
+
* @param {string} [elements]
|
|
8717
|
+
* @param {string} [form_values]
|
|
8718
|
+
* */
|
|
8719
|
+
/**
|
|
8720
|
+
* List of available triggers
|
|
8721
|
+
*
|
|
8722
|
+
* @type {object}
|
|
8723
|
+
* @param {string} SUBMIT_FORM=submit_form
|
|
8724
|
+
* @param {string} CHANGE_TAB=tab
|
|
8725
|
+
* @param {string} HIDE_ELEMENTS=hide_elements
|
|
8726
|
+
* @param {string} SHOW_ELEMENTS=show_elements
|
|
8727
|
+
* @param {string} REFRESH_CHECKOUT=refresh_checkout
|
|
8728
|
+
* @param {string} UPDATE_FORM_VALUES=update_form_values
|
|
8729
|
+
* @param {string} INIT_CHECKOUT=init_checkout
|
|
8730
|
+
* @param {string} INJECT_CUSTOMER_DATA=inject_customer_data
|
|
8731
|
+
*/
|
|
8732
|
+
var TRIGGER$1 = {
|
|
8733
|
+
SUBMIT_FORM: 'submit_form',
|
|
8734
|
+
CHANGE_TAB: 'tab',
|
|
8735
|
+
HIDE_ELEMENTS: 'hide_elements',
|
|
8736
|
+
SHOW_ELEMENTS: 'show_elements',
|
|
8737
|
+
REFRESH_CHECKOUT: 'refresh_checkout',
|
|
8738
|
+
UPDATE_FORM_VALUES: 'update_form_values',
|
|
8739
|
+
INIT_CHECKOUT: 'init_checkout',
|
|
8740
|
+
INJECT_CUSTOMER_DATA: 'inject_customer_data'
|
|
8741
|
+
};
|
|
8742
|
+
var Trigger = /*#__PURE__*/function () {
|
|
8743
|
+
function Trigger(iFrame) {
|
|
8744
|
+
_classCallCheck(this, Trigger);
|
|
8745
|
+
this.iFrame = iFrame;
|
|
8746
|
+
}
|
|
8747
|
+
return _createClass(Trigger, [{
|
|
8748
|
+
key: "push",
|
|
8749
|
+
value: function push(triggerName) {
|
|
8750
|
+
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
8751
|
+
if (!this.iFrame.isExist()) return;
|
|
8752
|
+
if (ObjectHelper.values(TRIGGER$1).indexOf(triggerName) === -1) console.warn('unsupported trigger type');
|
|
8753
|
+
var body = {
|
|
8754
|
+
trigger: triggerName,
|
|
8755
|
+
destination: 'widget.paydock',
|
|
8756
|
+
data: data
|
|
8757
|
+
};
|
|
8758
|
+
this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(body), '*');
|
|
8759
|
+
}
|
|
8760
|
+
}]);
|
|
8761
|
+
}();
|
|
8762
|
+
|
|
8763
|
+
var PerformanceService = /*#__PURE__*/function () {
|
|
8764
|
+
function PerformanceService() {
|
|
8765
|
+
_classCallCheck(this, PerformanceService);
|
|
8766
|
+
}
|
|
8767
|
+
return _createClass(PerformanceService, null, [{
|
|
8768
|
+
key: "initialize",
|
|
8769
|
+
value: function initialize(env) {
|
|
8770
|
+
var _this = this;
|
|
8771
|
+
performance.now();
|
|
8772
|
+
// Set environment configuration
|
|
8773
|
+
var envInstance = new Env(API_URL, env);
|
|
8774
|
+
var finalUrl = envInstance.getConf().url;
|
|
8775
|
+
// Add performance optimizations in parallel
|
|
8776
|
+
Promise.all([
|
|
8777
|
+
// Add preconnect
|
|
8778
|
+
new Promise(function (resolve) {
|
|
8779
|
+
_this.addLinkTag('preconnect', finalUrl, true);
|
|
8780
|
+
resolve();
|
|
8781
|
+
}),
|
|
8782
|
+
// Add DNS prefetch
|
|
8783
|
+
new Promise(function (resolve) {
|
|
8784
|
+
_this.addLinkTag('dns-prefetch', finalUrl);
|
|
8785
|
+
resolve();
|
|
8786
|
+
}),
|
|
8787
|
+
// Send warmup request
|
|
8788
|
+
new Promise(function (resolve) {
|
|
8789
|
+
if (window.fetch) {
|
|
8790
|
+
fetch("".concat(finalUrl, "/v1/echo"), {
|
|
8791
|
+
mode: 'no-cors',
|
|
8792
|
+
keepalive: true
|
|
8793
|
+
})["catch"](function () {})["finally"](resolve);
|
|
8794
|
+
} else {
|
|
8795
|
+
resolve();
|
|
8796
|
+
}
|
|
8797
|
+
})]);
|
|
8798
|
+
}
|
|
8799
|
+
/**
|
|
8800
|
+
* Dynamically adds or updates a `<link>` tag in the document's `<head>`.
|
|
8801
|
+
* This utility is designed for performance optimizations like `dns-prefetch` and `preconnect`.
|
|
8802
|
+
*
|
|
8803
|
+
* @param rel - The relationship type of the link (e.g., 'dns-prefetch', 'preconnect').
|
|
8804
|
+
* @param href - The URL for the resource.
|
|
8805
|
+
* @param crossorigin - Specifies if the resource should be fetched with a CORS request. Defaults to false.
|
|
8806
|
+
*/
|
|
8807
|
+
}, {
|
|
8808
|
+
key: "addLinkTag",
|
|
8809
|
+
value: function addLinkTag(rel, href) {
|
|
8810
|
+
var crossorigin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
8811
|
+
try {
|
|
8812
|
+
var existingTag = document.head.querySelector("link[rel=\"".concat(rel, "\"][href*=\"").concat(new URL(href).host, "\"]"));
|
|
8813
|
+
if (existingTag) {
|
|
8814
|
+
return;
|
|
8815
|
+
}
|
|
8816
|
+
var linkElement = this.createLinkElement(rel, href, crossorigin);
|
|
8817
|
+
document.head.prepend(linkElement);
|
|
8818
|
+
} catch (error) {
|
|
8819
|
+
console.error("\u274C [Performance] Failed to add ".concat(rel, " tag for ").concat(href, "."), error);
|
|
8820
|
+
}
|
|
8821
|
+
}
|
|
8822
|
+
/**
|
|
8823
|
+
* Creates and configures a new HTMLLinkElement.
|
|
8824
|
+
*
|
|
8825
|
+
* @param rel - The relationship type.
|
|
8826
|
+
* @param href - The resource URL.
|
|
8827
|
+
* @param crossorigin - The CORS setting.
|
|
8828
|
+
* @returns A configured HTMLLinkElement.
|
|
8829
|
+
* @private
|
|
8830
|
+
*/
|
|
8831
|
+
}, {
|
|
8832
|
+
key: "createLinkElement",
|
|
8833
|
+
value: function createLinkElement(rel, href, crossorigin) {
|
|
8834
|
+
var linkElement = document.createElement('link');
|
|
8835
|
+
linkElement.rel = rel;
|
|
8836
|
+
linkElement.href = this.determineHref(rel, href);
|
|
8837
|
+
if (crossorigin) {
|
|
8838
|
+
linkElement.crossOrigin = 'anonymous';
|
|
8839
|
+
}
|
|
8840
|
+
return linkElement;
|
|
8841
|
+
}
|
|
8842
|
+
/**
|
|
8843
|
+
* Determines the appropriate href value based on the link relationship.
|
|
8844
|
+
*
|
|
8845
|
+
* @param rel - The relationship type.
|
|
8846
|
+
* @param originalHref - The original URL.
|
|
8847
|
+
* @returns The processed href string.
|
|
8848
|
+
* @private
|
|
8849
|
+
*/
|
|
8850
|
+
}, {
|
|
8851
|
+
key: "determineHref",
|
|
8852
|
+
value: function determineHref(rel, originalHref) {
|
|
8853
|
+
if (rel === 'dns-prefetch') {
|
|
8854
|
+
// For dns-prefetch, a protocol-relative URL to the host is sufficient.
|
|
8855
|
+
var _URL = new URL(originalHref),
|
|
8856
|
+
host = _URL.host;
|
|
8857
|
+
return "//".concat(host);
|
|
8858
|
+
}
|
|
8859
|
+
// For others, like preconnect, the full original URL is required.
|
|
8860
|
+
return originalHref;
|
|
8861
|
+
}
|
|
8862
|
+
}]);
|
|
8863
|
+
}();
|
|
8864
|
+
|
|
8710
8865
|
var ClickToPaySRC = /*#__PURE__*/function () {
|
|
8711
8866
|
function ClickToPaySRC(iframe_selector, service_id, public_key, meta, eventEmitter, autoResize, env, alias) {
|
|
8712
8867
|
_classCallCheck(this, ClickToPaySRC);
|
|
@@ -8729,6 +8884,7 @@
|
|
|
8729
8884
|
if (env) this.link.setEnv(env, alias);
|
|
8730
8885
|
this.iFrameContainer = new Container(iframe_selector);
|
|
8731
8886
|
this.iFrame = new IFrame(this.iFrameContainer);
|
|
8887
|
+
this.trigger = new Trigger(this.iFrame);
|
|
8732
8888
|
this.iFrameEvent = new IFrameEvent(window);
|
|
8733
8889
|
this.setupIFrameEvents();
|
|
8734
8890
|
}
|
|
@@ -8764,6 +8920,8 @@
|
|
|
8764
8920
|
key: "load",
|
|
8765
8921
|
value: function load() {
|
|
8766
8922
|
var _this2 = this;
|
|
8923
|
+
// Initialize performance optimizations when environment is guaranteed to be final
|
|
8924
|
+
PerformanceService.initialize(this.link.getEnv());
|
|
8767
8925
|
this.iFrame.load(this.link.getUrl(), {
|
|
8768
8926
|
title: 'Click To Pay checkout'
|
|
8769
8927
|
});
|
|
@@ -8815,6 +8973,18 @@
|
|
|
8815
8973
|
}
|
|
8816
8974
|
});
|
|
8817
8975
|
}
|
|
8976
|
+
/**
|
|
8977
|
+
* Send customer data to iframe using the established trigger pattern
|
|
8978
|
+
*
|
|
8979
|
+
* @param {CustomerData} customerData - Customer data to inject
|
|
8980
|
+
*/
|
|
8981
|
+
}, {
|
|
8982
|
+
key: "injectCustomerData",
|
|
8983
|
+
value: function injectCustomerData(customerData) {
|
|
8984
|
+
this.trigger.push(TRIGGER$1.INJECT_CUSTOMER_DATA, {
|
|
8985
|
+
customer: customerData
|
|
8986
|
+
});
|
|
8987
|
+
}
|
|
8818
8988
|
}]);
|
|
8819
8989
|
}();
|
|
8820
8990
|
|
|
@@ -9003,11 +9173,11 @@
|
|
|
9003
9173
|
_this.service_id = service_id;
|
|
9004
9174
|
_this.public_key_or_access_token = public_key_or_access_token;
|
|
9005
9175
|
_this.meta = meta;
|
|
9176
|
+
_this.holdingForCustomerData = false;
|
|
9006
9177
|
return _this;
|
|
9007
9178
|
}
|
|
9008
9179
|
/**
|
|
9009
9180
|
* The final method after configuring the SRC to start the load process of Click To Pay checkout
|
|
9010
|
-
*
|
|
9011
9181
|
*/
|
|
9012
9182
|
_inherits(ClickToPay, _SRC);
|
|
9013
9183
|
return _createClass(ClickToPay, [{
|
|
@@ -9015,62 +9185,53 @@
|
|
|
9015
9185
|
value: function load() {
|
|
9016
9186
|
if (this.provider) return;
|
|
9017
9187
|
this.meta.customizations = this.style;
|
|
9188
|
+
this.holdingForCustomerData = !!this.meta.hold_for_customer_data;
|
|
9018
9189
|
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);
|
|
9019
9190
|
this.provider.load();
|
|
9020
9191
|
}
|
|
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
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
value: function push(triggerName) {
|
|
9062
|
-
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9063
|
-
if (!this.iFrame.isExist()) return;
|
|
9064
|
-
if (ObjectHelper.values(TRIGGER$1).indexOf(triggerName) === -1) console.warn('unsupported trigger type');
|
|
9065
|
-
var body = {
|
|
9066
|
-
trigger: triggerName,
|
|
9067
|
-
destination: 'widget.paydock',
|
|
9068
|
-
data: data
|
|
9069
|
-
};
|
|
9070
|
-
this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(body), '*');
|
|
9192
|
+
/**
|
|
9193
|
+
* Inject customer data after widget initialization via postMessage
|
|
9194
|
+
*
|
|
9195
|
+
* @param {Customer} customerData - Customer data to inject
|
|
9196
|
+
* @throws {Error} When customer data is invalid or widget is not ready
|
|
9197
|
+
* @example
|
|
9198
|
+
* widget.injectCustomerData({
|
|
9199
|
+
* email: 'user@example.com',
|
|
9200
|
+
* first_name: 'John',
|
|
9201
|
+
* last_name: 'Doe'
|
|
9202
|
+
* });
|
|
9203
|
+
*/
|
|
9204
|
+
}, {
|
|
9205
|
+
key: "injectCustomerData",
|
|
9206
|
+
value: function injectCustomerData(customerData) {
|
|
9207
|
+
if (!this.validateCustomerData(customerData)) {
|
|
9208
|
+
throw new Error('Invalid customer data format. Must include at least email or phone.');
|
|
9209
|
+
}
|
|
9210
|
+
if (!this.provider) {
|
|
9211
|
+
throw new Error('Widget not initialized. Call load() first.');
|
|
9212
|
+
}
|
|
9213
|
+
this.provider.injectCustomerData(customerData);
|
|
9214
|
+
}
|
|
9215
|
+
/**
|
|
9216
|
+
* Validate customer data format
|
|
9217
|
+
*
|
|
9218
|
+
* @private
|
|
9219
|
+
* @param {Customer} customerData - Customer data to validate
|
|
9220
|
+
* @returns {boolean} True if valid
|
|
9221
|
+
*/
|
|
9222
|
+
}, {
|
|
9223
|
+
key: "validateCustomerData",
|
|
9224
|
+
value: function validateCustomerData(customerData) {
|
|
9225
|
+
if (!customerData || _typeof$1(customerData) !== 'object') {
|
|
9226
|
+
return false;
|
|
9227
|
+
}
|
|
9228
|
+
// Check if at least email or phone is provided
|
|
9229
|
+
var hasEmail = customerData.email && typeof customerData.email === 'string';
|
|
9230
|
+
var hasPhone = customerData.phone && _typeof$1(customerData.phone) === 'object' && customerData.phone.phone && typeof customerData.phone.phone === 'string';
|
|
9231
|
+
return hasEmail || hasPhone;
|
|
9071
9232
|
}
|
|
9072
9233
|
}]);
|
|
9073
|
-
}();
|
|
9234
|
+
}(SRC);
|
|
9074
9235
|
|
|
9075
9236
|
var VAULT_DISPLAY_EVENT;
|
|
9076
9237
|
(function (VAULT_DISPLAY_EVENT) {
|
|
@@ -15689,6 +15850,30 @@
|
|
|
15689
15850
|
}]);
|
|
15690
15851
|
}(HtmlMultiWidget);
|
|
15691
15852
|
|
|
15853
|
+
var Spinner = /*#__PURE__*/function () {
|
|
15854
|
+
function Spinner() {
|
|
15855
|
+
_classCallCheck(this, Spinner);
|
|
15856
|
+
}
|
|
15857
|
+
return _createClass(Spinner, null, [{
|
|
15858
|
+
key: "getSpinnerElement",
|
|
15859
|
+
value: function getSpinnerElement() {
|
|
15860
|
+
return document.getElementById('spinner');
|
|
15861
|
+
}
|
|
15862
|
+
}, {
|
|
15863
|
+
key: "show",
|
|
15864
|
+
value: function show() {
|
|
15865
|
+
var spinner = this.getSpinnerElement();
|
|
15866
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.classList.remove('spinner-wrapper--hidden');
|
|
15867
|
+
}
|
|
15868
|
+
}, {
|
|
15869
|
+
key: "hide",
|
|
15870
|
+
value: function hide() {
|
|
15871
|
+
var spinner = this.getSpinnerElement();
|
|
15872
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.classList.add('spinner-wrapper--hidden');
|
|
15873
|
+
}
|
|
15874
|
+
}]);
|
|
15875
|
+
}();
|
|
15876
|
+
|
|
15692
15877
|
var InstructionModule$1 = /*#__PURE__*/function () {
|
|
15693
15878
|
function InstructionModule() {
|
|
15694
15879
|
_classCallCheck(this, InstructionModule);
|
|
@@ -15754,30 +15939,6 @@
|
|
|
15754
15939
|
};
|
|
15755
15940
|
}
|
|
15756
15941
|
|
|
15757
|
-
var Spinner = /*#__PURE__*/function () {
|
|
15758
|
-
function Spinner() {
|
|
15759
|
-
_classCallCheck(this, Spinner);
|
|
15760
|
-
}
|
|
15761
|
-
return _createClass(Spinner, null, [{
|
|
15762
|
-
key: "getSpinnerElement",
|
|
15763
|
-
value: function getSpinnerElement() {
|
|
15764
|
-
return document.getElementById('spinner');
|
|
15765
|
-
}
|
|
15766
|
-
}, {
|
|
15767
|
-
key: "show",
|
|
15768
|
-
value: function show() {
|
|
15769
|
-
var spinner = this.getSpinnerElement();
|
|
15770
|
-
spinner === null || spinner === void 0 ? void 0 : spinner.classList.remove('spinner-wrapper--hidden');
|
|
15771
|
-
}
|
|
15772
|
-
}, {
|
|
15773
|
-
key: "hide",
|
|
15774
|
-
value: function hide() {
|
|
15775
|
-
var spinner = this.getSpinnerElement();
|
|
15776
|
-
spinner === null || spinner === void 0 ? void 0 : spinner.classList.add('spinner-wrapper--hidden');
|
|
15777
|
-
}
|
|
15778
|
-
}]);
|
|
15779
|
-
}();
|
|
15780
|
-
|
|
15781
15942
|
var SessionHelper = /*#__PURE__*/function () {
|
|
15782
15943
|
function SessionHelper() {
|
|
15783
15944
|
_classCallCheck(this, SessionHelper);
|
|
@@ -16081,6 +16242,95 @@
|
|
|
16081
16242
|
}(InstructionHandler);
|
|
16082
16243
|
InstructionBankAccountFormShow = __decorate([Instruction('instruction.bank_account_form.show')], InstructionBankAccountFormShow);
|
|
16083
16244
|
|
|
16245
|
+
var toByteArray_1 = toByteArray;
|
|
16246
|
+
var revLookup = [];
|
|
16247
|
+
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
|
|
16248
|
+
|
|
16249
|
+
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
16250
|
+
for (var i$2 = 0, len = code.length; i$2 < len; ++i$2) {
|
|
16251
|
+
revLookup[code.charCodeAt(i$2)] = i$2;
|
|
16252
|
+
}
|
|
16253
|
+
|
|
16254
|
+
// Support decoding URL-safe base64 strings, as Node.js does.
|
|
16255
|
+
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
|
16256
|
+
revLookup['-'.charCodeAt(0)] = 62;
|
|
16257
|
+
revLookup['_'.charCodeAt(0)] = 63;
|
|
16258
|
+
|
|
16259
|
+
function getLens (b64) {
|
|
16260
|
+
var len = b64.length;
|
|
16261
|
+
|
|
16262
|
+
if (len % 4 > 0) {
|
|
16263
|
+
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
16264
|
+
}
|
|
16265
|
+
|
|
16266
|
+
// Trim off extra bytes after placeholder bytes are found
|
|
16267
|
+
// See: https://github.com/beatgammit/base64-js/issues/42
|
|
16268
|
+
var validLen = b64.indexOf('=');
|
|
16269
|
+
if (validLen === -1) validLen = len;
|
|
16270
|
+
|
|
16271
|
+
var placeHoldersLen = validLen === len
|
|
16272
|
+
? 0
|
|
16273
|
+
: 4 - (validLen % 4);
|
|
16274
|
+
|
|
16275
|
+
return [validLen, placeHoldersLen]
|
|
16276
|
+
}
|
|
16277
|
+
|
|
16278
|
+
function _byteLength (b64, validLen, placeHoldersLen) {
|
|
16279
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
16280
|
+
}
|
|
16281
|
+
|
|
16282
|
+
function toByteArray (b64) {
|
|
16283
|
+
var tmp;
|
|
16284
|
+
var lens = getLens(b64);
|
|
16285
|
+
var validLen = lens[0];
|
|
16286
|
+
var placeHoldersLen = lens[1];
|
|
16287
|
+
|
|
16288
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
16289
|
+
|
|
16290
|
+
var curByte = 0;
|
|
16291
|
+
|
|
16292
|
+
// if there are placeholders, only get up to the last complete 4 chars
|
|
16293
|
+
var len = placeHoldersLen > 0
|
|
16294
|
+
? validLen - 4
|
|
16295
|
+
: validLen;
|
|
16296
|
+
|
|
16297
|
+
var i;
|
|
16298
|
+
for (i = 0; i < len; i += 4) {
|
|
16299
|
+
tmp =
|
|
16300
|
+
(revLookup[b64.charCodeAt(i)] << 18) |
|
|
16301
|
+
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
|
16302
|
+
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
|
16303
|
+
revLookup[b64.charCodeAt(i + 3)];
|
|
16304
|
+
arr[curByte++] = (tmp >> 16) & 0xFF;
|
|
16305
|
+
arr[curByte++] = (tmp >> 8) & 0xFF;
|
|
16306
|
+
arr[curByte++] = tmp & 0xFF;
|
|
16307
|
+
}
|
|
16308
|
+
|
|
16309
|
+
if (placeHoldersLen === 2) {
|
|
16310
|
+
tmp =
|
|
16311
|
+
(revLookup[b64.charCodeAt(i)] << 2) |
|
|
16312
|
+
(revLookup[b64.charCodeAt(i + 1)] >> 4);
|
|
16313
|
+
arr[curByte++] = tmp & 0xFF;
|
|
16314
|
+
}
|
|
16315
|
+
|
|
16316
|
+
if (placeHoldersLen === 1) {
|
|
16317
|
+
tmp =
|
|
16318
|
+
(revLookup[b64.charCodeAt(i)] << 10) |
|
|
16319
|
+
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
|
16320
|
+
(revLookup[b64.charCodeAt(i + 2)] >> 2);
|
|
16321
|
+
arr[curByte++] = (tmp >> 8) & 0xFF;
|
|
16322
|
+
arr[curByte++] = tmp & 0xFF;
|
|
16323
|
+
}
|
|
16324
|
+
|
|
16325
|
+
return arr
|
|
16326
|
+
}
|
|
16327
|
+
|
|
16328
|
+
var TOKEN_FORMAT;
|
|
16329
|
+
(function (TOKEN_FORMAT) {
|
|
16330
|
+
TOKEN_FORMAT["HTML"] = "html";
|
|
16331
|
+
TOKEN_FORMAT["URL"] = "url";
|
|
16332
|
+
TOKEN_FORMAT["STANDALONE_3DS"] = "standalone_3ds";
|
|
16333
|
+
})(TOKEN_FORMAT || (TOKEN_FORMAT = {}));
|
|
16084
16334
|
var InstructionCanvas3dsShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
16085
16335
|
function InstructionCanvas3dsShow() {
|
|
16086
16336
|
_classCallCheck(this, InstructionCanvas3dsShow);
|
|
@@ -16091,12 +16341,25 @@
|
|
|
16091
16341
|
key: "handle",
|
|
16092
16342
|
value: function handle(context) {
|
|
16093
16343
|
var _this = this;
|
|
16344
|
+
var token = this.decodeBase64Token(context.payload._3ds_token);
|
|
16094
16345
|
var canvas = new Canvas3ds(this.formSelector, context.payload._3ds_token);
|
|
16095
16346
|
canvas.setEnv(this.getEnv(context.instruction_token));
|
|
16096
|
-
canvas.on('chargeAuth', function (
|
|
16347
|
+
canvas.on('chargeAuth', function () {
|
|
16097
16348
|
return Spinner.show();
|
|
16098
16349
|
});
|
|
16099
|
-
canvas.on('
|
|
16350
|
+
canvas.on('chargeAuthChallenge', function () {
|
|
16351
|
+
if (token.format === TOKEN_FORMAT.STANDALONE_3DS) {
|
|
16352
|
+
Spinner.hide();
|
|
16353
|
+
_this.observeIframeAndResize();
|
|
16354
|
+
}
|
|
16355
|
+
});
|
|
16356
|
+
canvas.on('chargeAuthDecoupled', function () {
|
|
16357
|
+
if (token.format === TOKEN_FORMAT.STANDALONE_3DS) {
|
|
16358
|
+
Spinner.hide();
|
|
16359
|
+
_this.observeIframeAndResize();
|
|
16360
|
+
}
|
|
16361
|
+
});
|
|
16362
|
+
canvas.on('chargeAuthSuccess', function () {
|
|
16100
16363
|
var _a;
|
|
16101
16364
|
(_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
|
|
16102
16365
|
_this.api.checkout().callback({
|
|
@@ -16110,8 +16373,9 @@
|
|
|
16110
16373
|
})["catch"](function (response) {
|
|
16111
16374
|
return console.error('callback.child_widget.status - chargeAuthSuccess: error', response);
|
|
16112
16375
|
});
|
|
16376
|
+
Spinner.show();
|
|
16113
16377
|
});
|
|
16114
|
-
canvas.on('chargeAuthReject', function (
|
|
16378
|
+
canvas.on('chargeAuthReject', function () {
|
|
16115
16379
|
var _a;
|
|
16116
16380
|
// **TODO add interface for chargeAuthReject event **//
|
|
16117
16381
|
(_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
|
|
@@ -16126,6 +16390,7 @@
|
|
|
16126
16390
|
})["catch"](function (response) {
|
|
16127
16391
|
return console.error('callback.child_widget.status - chargeAuthReject: error', response);
|
|
16128
16392
|
});
|
|
16393
|
+
Spinner.show();
|
|
16129
16394
|
});
|
|
16130
16395
|
canvas.on('error', function (event) {
|
|
16131
16396
|
var _a;
|
|
@@ -16142,15 +16407,60 @@
|
|
|
16142
16407
|
})["catch"](function (response) {
|
|
16143
16408
|
return console.error('callback.child_widget.status - errorEvent: error', response);
|
|
16144
16409
|
});
|
|
16410
|
+
Spinner.show();
|
|
16145
16411
|
});
|
|
16146
16412
|
canvas.load();
|
|
16147
|
-
|
|
16413
|
+
if (token.format !== TOKEN_FORMAT.STANDALONE_3DS) {
|
|
16414
|
+
Spinner.hide();
|
|
16415
|
+
}
|
|
16148
16416
|
}
|
|
16149
16417
|
}, {
|
|
16150
16418
|
key: "destroy",
|
|
16151
16419
|
value: function destroy() {
|
|
16152
16420
|
document.querySelector(this.formSelector).innerHTML = '';
|
|
16153
16421
|
}
|
|
16422
|
+
}, {
|
|
16423
|
+
key: "decodeBase64Token",
|
|
16424
|
+
value: function decodeBase64Token(token) {
|
|
16425
|
+
try {
|
|
16426
|
+
var base64 = token.replace(/-/g, '+').replace(/_/g, '/').padEnd(Math.ceil(token.length / 4) * 4, '=');
|
|
16427
|
+
var bytes = toByteArray_1(base64);
|
|
16428
|
+
var json = new TextDecoder().decode(bytes);
|
|
16429
|
+
return JSON.parse(json);
|
|
16430
|
+
} catch (err) {
|
|
16431
|
+
console.error('Failed to decode _3ds_token:', err);
|
|
16432
|
+
throw err;
|
|
16433
|
+
}
|
|
16434
|
+
}
|
|
16435
|
+
}, {
|
|
16436
|
+
key: "observeIframeAndResize",
|
|
16437
|
+
value: function observeIframeAndResize() {
|
|
16438
|
+
var outer = document.querySelector('#standaloneWidget');
|
|
16439
|
+
if (outer) {
|
|
16440
|
+
outer.style.display = 'flex';
|
|
16441
|
+
outer.style.justifyContent = 'center';
|
|
16442
|
+
}
|
|
16443
|
+
var container = document.querySelector('#paydock_authorization_iframe');
|
|
16444
|
+
if (!container) {
|
|
16445
|
+
console.warn('Container not found');
|
|
16446
|
+
return;
|
|
16447
|
+
}
|
|
16448
|
+
var observer = new MutationObserver(function () {
|
|
16449
|
+
var iframe = container.querySelector('iframe');
|
|
16450
|
+
if (iframe) {
|
|
16451
|
+
iframe.style.width = '100%';
|
|
16452
|
+
iframe.style.height = '500px';
|
|
16453
|
+
iframe.style.border = 'none';
|
|
16454
|
+
iframe.style.display = 'block';
|
|
16455
|
+
console.info('3DS iframe resized', iframe);
|
|
16456
|
+
observer.disconnect();
|
|
16457
|
+
}
|
|
16458
|
+
});
|
|
16459
|
+
observer.observe(container, {
|
|
16460
|
+
childList: true,
|
|
16461
|
+
subtree: true
|
|
16462
|
+
});
|
|
16463
|
+
}
|
|
16154
16464
|
}]);
|
|
16155
16465
|
}(InstructionHandler);
|
|
16156
16466
|
InstructionCanvas3dsShow = __decorate([Instruction('instruction.canvas_3ds_form.show')], InstructionCanvas3dsShow);
|
|
@@ -17164,7 +17474,7 @@
|
|
|
17164
17474
|
key: "isTimeoutInstruction",
|
|
17165
17475
|
value: function isTimeoutInstruction(response) {
|
|
17166
17476
|
var _a, _b;
|
|
17167
|
-
return ((_a = response.payload) === null || _a === void 0 ? void 0 : _a.status) === 'expired' || ((_b = response.
|
|
17477
|
+
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';
|
|
17168
17478
|
}
|
|
17169
17479
|
}, {
|
|
17170
17480
|
key: "handleInstruction",
|