@paydock/client-sdk 1.119.0-beta → 1.119.2
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 +69 -19
- package/bundles/index.cjs +112 -60
- package/bundles/index.cjs.d.ts +2060 -2050
- package/bundles/index.mjs +106 -53
- package/bundles/index.mjs.d.ts +2060 -2050
- package/bundles/types/checkout/instructions/v1/instruction.card_form.show.d.ts.map +1 -1
- package/bundles/types/components/iframe-event.d.ts +39 -29
- package/bundles/types/components/iframe-event.d.ts.map +1 -1
- package/bundles/types/helper/custom-error.d.ts +8 -0
- package/bundles/types/helper/custom-error.d.ts.map +1 -0
- package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts +1 -1
- package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts.map +1 -1
- package/bundles/types/widget/configuration.d.ts +7 -7
- package/bundles/types/widget/configuration.d.ts.map +1 -1
- package/bundles/types/widget/html-multi-widget.d.ts +1 -2
- package/bundles/types/widget/html-multi-widget.d.ts.map +1 -1
- package/bundles/types/widget/html-widget.d.ts +2 -1
- package/bundles/types/widget/html-widget.d.ts.map +1 -1
- package/bundles/types/widget/multi-widget.d.ts +4 -1
- package/bundles/types/widget/multi-widget.d.ts.map +1 -1
- package/bundles/widget.umd.js +112 -60
- package/bundles/widget.umd.js.d.ts +2060 -2050
- package/bundles/widget.umd.js.min.d.ts +2060 -2050
- package/bundles/widget.umd.min.js +1 -1
- package/docs/api-widget.md +21 -16
- package/docs/widget-examples.md +48 -3
- package/examples/multi-html-widget/extend.html +5 -0
- package/package.json +1 -1
- package/slate.md +48 -3
package/bundles/index.mjs
CHANGED
|
@@ -21,6 +21,13 @@ function _callSuper(t, o, e) {
|
|
|
21
21
|
function _classCallCheck(a, n) {
|
|
22
22
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
23
23
|
}
|
|
24
|
+
function _construct(t, e, r) {
|
|
25
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
26
|
+
var o = [null];
|
|
27
|
+
o.push.apply(o, e);
|
|
28
|
+
var p = new (t.bind.apply(t, o))();
|
|
29
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
30
|
+
}
|
|
24
31
|
function _defineProperties(e, r) {
|
|
25
32
|
for (var t = 0; t < r.length; t++) {
|
|
26
33
|
var o = r[t];
|
|
@@ -123,6 +130,13 @@ function _inherits(t, e) {
|
|
|
123
130
|
writable: !1
|
|
124
131
|
}), e && _setPrototypeOf(t, e);
|
|
125
132
|
}
|
|
133
|
+
function _isNativeFunction(t) {
|
|
134
|
+
try {
|
|
135
|
+
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
136
|
+
} catch (n) {
|
|
137
|
+
return "function" == typeof t;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
126
140
|
function _isNativeReflectConstruct() {
|
|
127
141
|
try {
|
|
128
142
|
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
@@ -524,6 +538,28 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
524
538
|
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
525
539
|
}
|
|
526
540
|
}
|
|
541
|
+
function _wrapNativeSuper(t) {
|
|
542
|
+
var r = "function" == typeof Map ? new Map() : void 0;
|
|
543
|
+
return _wrapNativeSuper = function (t) {
|
|
544
|
+
if (null === t || !_isNativeFunction(t)) return t;
|
|
545
|
+
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
546
|
+
if (void 0 !== r) {
|
|
547
|
+
if (r.has(t)) return r.get(t);
|
|
548
|
+
r.set(t, Wrapper);
|
|
549
|
+
}
|
|
550
|
+
function Wrapper() {
|
|
551
|
+
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|
552
|
+
}
|
|
553
|
+
return Wrapper.prototype = Object.create(t.prototype, {
|
|
554
|
+
constructor: {
|
|
555
|
+
value: Wrapper,
|
|
556
|
+
enumerable: !1,
|
|
557
|
+
writable: !0,
|
|
558
|
+
configurable: !0
|
|
559
|
+
}
|
|
560
|
+
}), _setPrototypeOf(Wrapper, t);
|
|
561
|
+
}, _wrapNativeSuper(t);
|
|
562
|
+
}
|
|
527
563
|
|
|
528
564
|
var Browser = /*#__PURE__*/function () {
|
|
529
565
|
function Browser() {
|
|
@@ -889,7 +925,7 @@ SDK.headerKeys = Object.freeze({
|
|
|
889
925
|
version: 'x-sdk-version',
|
|
890
926
|
type: 'x-sdk-type'
|
|
891
927
|
});
|
|
892
|
-
SDK._version = 'v1.119.
|
|
928
|
+
SDK._version = 'v1.119.2';
|
|
893
929
|
|
|
894
930
|
/******************************************************************************
|
|
895
931
|
Copyright (c) Microsoft Corporation.
|
|
@@ -4151,8 +4187,8 @@ function createNewrelicConfig() {
|
|
|
4151
4187
|
var params = {
|
|
4152
4188
|
enabled: 'true',
|
|
4153
4189
|
accountId: '974691',
|
|
4154
|
-
agentId: '
|
|
4155
|
-
applicationId: '
|
|
4190
|
+
agentId: '1386157152',
|
|
4191
|
+
applicationId: '1386157152',
|
|
4156
4192
|
licenseKey: '4848a32285',
|
|
4157
4193
|
trustKey: '974691'
|
|
4158
4194
|
};
|
|
@@ -4957,6 +4993,7 @@ var EVENT$4 = {
|
|
|
4957
4993
|
FINISH: 'finish',
|
|
4958
4994
|
VALIDATION_ERROR: 'validationError',
|
|
4959
4995
|
SYSTEM_ERROR: 'systemError',
|
|
4996
|
+
ERROR: 'error',
|
|
4960
4997
|
/** @deprecated */
|
|
4961
4998
|
CHECKOUT_SUCCESS: 'checkoutSuccess',
|
|
4962
4999
|
CHECKOUT_READY: 'checkoutReady',
|
|
@@ -13011,6 +13048,22 @@ function getHandleCvv(configuration) {
|
|
|
13011
13048
|
}
|
|
13012
13049
|
}
|
|
13013
13050
|
|
|
13051
|
+
var CustomError = /*#__PURE__*/function (_Error) {
|
|
13052
|
+
function CustomError(message, status, data) {
|
|
13053
|
+
var _this;
|
|
13054
|
+
_classCallCheck(this, CustomError);
|
|
13055
|
+
_this = _callSuper(this, CustomError, [message]);
|
|
13056
|
+
_this.status = status;
|
|
13057
|
+
_this.data = _extends({
|
|
13058
|
+
_message: message
|
|
13059
|
+
}, data);
|
|
13060
|
+
Object.setPrototypeOf(_this, CustomError.prototype);
|
|
13061
|
+
return _this;
|
|
13062
|
+
}
|
|
13063
|
+
_inherits(CustomError, _Error);
|
|
13064
|
+
return _createClass(CustomError);
|
|
13065
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
13066
|
+
|
|
13014
13067
|
/**
|
|
13015
13068
|
* List of available payment source types
|
|
13016
13069
|
*
|
|
@@ -13033,11 +13086,12 @@ var PAYMENT_TYPE = {
|
|
|
13033
13086
|
* @param {string} CARD_PAYMENT_SOURCE_WITH_CVV=card_payment_source_with_cvv
|
|
13034
13087
|
* @param {string} CARD_PAYMENT_SOURCE_WITHOUT_CVV=card_payment_source_without_cvv
|
|
13035
13088
|
* */
|
|
13036
|
-
var PURPOSE
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
|
|
13040
|
-
|
|
13089
|
+
var PURPOSE;
|
|
13090
|
+
(function (PURPOSE) {
|
|
13091
|
+
PURPOSE["PAYMENT_SOURCE"] = "payment_source";
|
|
13092
|
+
PURPOSE["CARD_PAYMENT_SOURCE_WITH_CVV"] = "card_payment_source_with_cvv";
|
|
13093
|
+
PURPOSE["CARD_PAYMENT_SOURCE_WITHOUT_CVV"] = "card_payment_source_without_cvv";
|
|
13094
|
+
})(PURPOSE || (PURPOSE = {}));
|
|
13041
13095
|
var CONFIGURATION_LINK = '/v1/remote-action/configs';
|
|
13042
13096
|
var DEFAULT_GATEWAY_LINK = '/v1/gateways/default';
|
|
13043
13097
|
/**
|
|
@@ -13271,7 +13325,7 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
13271
13325
|
key: "createEachToken",
|
|
13272
13326
|
value: function createEachToken(accessToken, configs) {
|
|
13273
13327
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13274
|
-
var tokens, index, data, validatedConfig
|
|
13328
|
+
var tokens, index, data, validatedConfig;
|
|
13275
13329
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13276
13330
|
while (1) switch (_context.prev = _context.next) {
|
|
13277
13331
|
case 0:
|
|
@@ -13279,16 +13333,16 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
13279
13333
|
_context.t0 = _regeneratorRuntime().keys(configs);
|
|
13280
13334
|
case 2:
|
|
13281
13335
|
if ((_context.t1 = _context.t0()).done) {
|
|
13282
|
-
_context.next =
|
|
13336
|
+
_context.next = 18;
|
|
13283
13337
|
break;
|
|
13284
13338
|
}
|
|
13285
13339
|
index = _context.t1.value;
|
|
13286
13340
|
if (!configs.hasOwnProperty(index)) {
|
|
13287
|
-
_context.next =
|
|
13341
|
+
_context.next = 16;
|
|
13288
13342
|
break;
|
|
13289
13343
|
}
|
|
13290
13344
|
if (!(configs[index].configs.predefined_fields.gateway_id === "default")) {
|
|
13291
|
-
_context.next =
|
|
13345
|
+
_context.next = 14;
|
|
13292
13346
|
break;
|
|
13293
13347
|
}
|
|
13294
13348
|
_context.next = 8;
|
|
@@ -13296,39 +13350,23 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
13296
13350
|
case 8:
|
|
13297
13351
|
data = _context.sent;
|
|
13298
13352
|
if (!(data['status'] !== 200)) {
|
|
13299
|
-
_context.next =
|
|
13353
|
+
_context.next = 13;
|
|
13300
13354
|
break;
|
|
13301
13355
|
}
|
|
13302
13356
|
console.error("--- | gateway: default | ".concat(data['error']['message']));
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
_context.next = 16;
|
|
13307
|
-
break;
|
|
13308
|
-
}
|
|
13357
|
+
data['error']['purpose'] = configs[index].configs.purpose;
|
|
13358
|
+
throw new CustomError('gateway: unexpected error with extract default gateway id', data['status'], data['error']);
|
|
13359
|
+
case 13:
|
|
13309
13360
|
configs[index].configs.predefined_fields.gateway_id = data['resource']['data']['_id'];
|
|
13310
|
-
|
|
13311
|
-
break;
|
|
13312
|
-
case 16:
|
|
13313
|
-
throw new Error('gateway: unexpected error with extract default gateway id');
|
|
13314
|
-
case 17:
|
|
13361
|
+
case 14:
|
|
13315
13362
|
validatedConfig = validateConfiguration(configs[index].configs);
|
|
13316
|
-
if (validatedConfig)
|
|
13317
|
-
|
|
13318
|
-
}
|
|
13319
|
-
_context.next = 23;
|
|
13320
|
-
break;
|
|
13321
|
-
case 21:
|
|
13322
|
-
_validatedConfig = validateConfiguration(configs[index].configs);
|
|
13323
|
-
if (_validatedConfig) {
|
|
13324
|
-
Configuration.addTokenInBase64(tokens, JSON.stringify(_validatedConfig), index);
|
|
13325
|
-
}
|
|
13326
|
-
case 23:
|
|
13363
|
+
if (validatedConfig) Configuration.addTokenInBase64(tokens, JSON.stringify(validatedConfig), index);
|
|
13364
|
+
case 16:
|
|
13327
13365
|
_context.next = 2;
|
|
13328
13366
|
break;
|
|
13329
|
-
case
|
|
13367
|
+
case 18:
|
|
13330
13368
|
return _context.abrupt("return", tokens);
|
|
13331
|
-
case
|
|
13369
|
+
case 19:
|
|
13332
13370
|
case "end":
|
|
13333
13371
|
return _context.stop();
|
|
13334
13372
|
}
|
|
@@ -13574,6 +13612,7 @@ var MultiWidget = /*#__PURE__*/function () {
|
|
|
13574
13612
|
this.accessToken = accessToken;
|
|
13575
13613
|
if (!conf || Array.isArray(conf) && !conf.length) throw Error('configuration token is required');
|
|
13576
13614
|
if (typeof conf === 'string') this.configTokens.push(conf);else if (conf instanceof Configuration) this.configs.push(conf);else if (Array.isArray(conf) && typeof conf[0] === 'string') this.configTokens = conf;else if (Array.isArray(conf) && conf[0] instanceof Configuration) this.configs = conf;else throw Error('Unsupported type of configuration token');
|
|
13615
|
+
this.event = new IFrameEvent(window);
|
|
13577
13616
|
}
|
|
13578
13617
|
/**
|
|
13579
13618
|
* Object contain styles for widget
|
|
@@ -13964,16 +14003,15 @@ var MultiWidget = /*#__PURE__*/function () {
|
|
|
13964
14003
|
this.link.setParams({
|
|
13965
14004
|
configuration_tokens: this.configTokens.join(',')
|
|
13966
14005
|
});
|
|
13967
|
-
|
|
14006
|
+
cb(this.link.getUrl());
|
|
14007
|
+
} else {
|
|
14008
|
+
Configuration.createEachToken(this.accessToken, this.configs).then(function (tokens) {
|
|
14009
|
+
_this2.link.concatParams({
|
|
14010
|
+
configuration_tokens: tokens.join(',')
|
|
14011
|
+
});
|
|
14012
|
+
cb(_this2.link.getUrl());
|
|
14013
|
+
})["catch"](errorCb);
|
|
13968
14014
|
}
|
|
13969
|
-
Configuration.createEachToken(this.accessToken, this.configs).then(function (tokens) {
|
|
13970
|
-
_this2.link.concatParams({
|
|
13971
|
-
configuration_tokens: tokens.join(',')
|
|
13972
|
-
});
|
|
13973
|
-
return cb(_this2.link.getUrl());
|
|
13974
|
-
}, function (errors) {
|
|
13975
|
-
errorCb(errors);
|
|
13976
|
-
});
|
|
13977
14015
|
}
|
|
13978
14016
|
/**
|
|
13979
14017
|
* Method for setting a custom language code
|
|
@@ -13994,6 +14032,21 @@ var MultiWidget = /*#__PURE__*/function () {
|
|
|
13994
14032
|
value: function getLink() {
|
|
13995
14033
|
return this.link;
|
|
13996
14034
|
}
|
|
14035
|
+
}, {
|
|
14036
|
+
key: "handleErrorEvent",
|
|
14037
|
+
value: function handleErrorEvent(err) {
|
|
14038
|
+
if (Object.values(EVENT$4).includes(err.event)) {
|
|
14039
|
+
this.event.emit({
|
|
14040
|
+
event: err.event,
|
|
14041
|
+
message_source: 'widget',
|
|
14042
|
+
purpose: err.data.purpose || '',
|
|
14043
|
+
widget_id: this.link.getParams().widget_id,
|
|
14044
|
+
data: err.data
|
|
14045
|
+
});
|
|
14046
|
+
return;
|
|
14047
|
+
}
|
|
14048
|
+
console.error("Unknown event: ", err);
|
|
14049
|
+
}
|
|
13997
14050
|
}]);
|
|
13998
14051
|
}();
|
|
13999
14052
|
|
|
@@ -14159,7 +14212,6 @@ var HtmlMultiWidget = /*#__PURE__*/function (_MultiWidget) {
|
|
|
14159
14212
|
_this.container = new Container(selector);
|
|
14160
14213
|
_this.iFrame = new IFrame(_this.container);
|
|
14161
14214
|
_this.triggerElement = new Trigger(_this.iFrame);
|
|
14162
|
-
_this.event = new IFrameEvent(window);
|
|
14163
14215
|
return _this;
|
|
14164
14216
|
}
|
|
14165
14217
|
/**
|
|
@@ -14179,11 +14231,12 @@ var HtmlMultiWidget = /*#__PURE__*/function (_MultiWidget) {
|
|
|
14179
14231
|
title: 'Card details'
|
|
14180
14232
|
});
|
|
14181
14233
|
_this2.afterLoad();
|
|
14182
|
-
}, function (
|
|
14183
|
-
|
|
14184
|
-
|
|
14185
|
-
|
|
14186
|
-
}
|
|
14234
|
+
}, function (error) {
|
|
14235
|
+
if (error instanceof CustomError) _this2.handleErrorEvent({
|
|
14236
|
+
event: EVENT$4.ERROR,
|
|
14237
|
+
data: error.data
|
|
14238
|
+
});
|
|
14239
|
+
console.error('Error when creating a token, widget will not be loaded');
|
|
14187
14240
|
});
|
|
14188
14241
|
}
|
|
14189
14242
|
/**
|
|
@@ -15082,7 +15135,7 @@ var InstructionCardFormShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
|
15082
15135
|
value: function handle(context) {
|
|
15083
15136
|
var _this = this;
|
|
15084
15137
|
var _a;
|
|
15085
|
-
this.widget = new HtmlWidget(this.formSelector, context === null || context === void 0 ? void 0 : context.instruction_token, 'not_configured', 'card',
|
|
15138
|
+
this.widget = new HtmlWidget(this.formSelector, context === null || context === void 0 ? void 0 : context.instruction_token, 'not_configured', 'card', PURPOSE.CARD_PAYMENT_SOURCE_WITH_CVV);
|
|
15086
15139
|
this.widget.setStyles(_extends({
|
|
15087
15140
|
button_color: DEFAULT_VARIABLES.BTN_COLOR,
|
|
15088
15141
|
background_color: DEFAULT_VARIABLES.BG_COLOR,
|