@paydock/client-sdk 1.10.58-beta → 1.10.72-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 +51 -0
- package/bundles/widget.umd.js +283 -13
- package/bundles/widget.umd.min.js +1 -1
- package/lib/api/api-charge-internal.d.ts +52 -0
- package/lib/api/api-charge-internal.js +12 -1
- package/lib/api/api-charge-internal.js.map +1 -1
- package/lib/canvas-3ds/canvas-3ds.d.ts +17 -1
- package/lib/canvas-3ds/canvas-3ds.js +30 -4
- package/lib/canvas-3ds/canvas-3ds.js.map +1 -1
- package/lib/canvas-3ds/services/gpayments-service.d.ts +42 -0
- package/lib/canvas-3ds/services/gpayments-service.js +162 -0
- package/lib/canvas-3ds/services/gpayments-service.js.map +1 -0
- package/lib/canvas-3ds/services/index.d.ts +1 -0
- package/lib/canvas-3ds/services/index.js +2 -0
- package/lib/canvas-3ds/services/index.js.map +1 -0
- package/lib/canvas-3ds/services/standalone3ds-service.d.ts +21 -0
- package/lib/canvas-3ds/services/standalone3ds-service.js +32 -0
- package/lib/canvas-3ds/services/standalone3ds-service.js.map +1 -0
- package/lib/helper/access-token.d.ts +1 -0
- package/lib/helper/access-token.js +8 -0
- package/lib/helper/access-token.js.map +1 -1
- package/lib/wallet-buttons/paypal.wallet-service.js +4 -6
- package/lib/wallet-buttons/paypal.wallet-service.js.map +1 -1
- package/package.json +1 -1
- package/slate.md +51 -0
package/README.md
CHANGED
|
@@ -4557,6 +4557,57 @@ This example shows how you can use a lot of other methods to settings your form
|
|
|
4557
4557
|
</html>
|
|
4558
4558
|
```
|
|
4559
4559
|
|
|
4560
|
+
## Canvas 3ds for Standalone 3ds charges
|
|
4561
|
+
|
|
4562
|
+
After you initialized the 3ds charge via `v1/charges/standalone-3ds` API endpoint, you get a token used to initialized the Canvas3ds. All above information regarding setup, loading and initialization still apply.
|
|
4563
|
+
|
|
4564
|
+
### Full example
|
|
4565
|
+
|
|
4566
|
+
```html
|
|
4567
|
+
<!DOCTYPE html>
|
|
4568
|
+
<html lang="en">
|
|
4569
|
+
<head>
|
|
4570
|
+
<meta charset="UTF-8" />
|
|
4571
|
+
<title>Title</title>
|
|
4572
|
+
<style>
|
|
4573
|
+
iframe {
|
|
4574
|
+
border: 0;
|
|
4575
|
+
width: 40%;
|
|
4576
|
+
height: 450px;
|
|
4577
|
+
}
|
|
4578
|
+
</style>
|
|
4579
|
+
</head>
|
|
4580
|
+
<body>
|
|
4581
|
+
<div id="widget3ds"></div>
|
|
4582
|
+
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js"></script>
|
|
4583
|
+
<script>
|
|
4584
|
+
var canvas3ds = new paydock.Canvas3ds("#widget3ds", "token");
|
|
4585
|
+
canvas3ds.on("chargeAuthSuccess", function (data) {
|
|
4586
|
+
console.log(data);
|
|
4587
|
+
});
|
|
4588
|
+
canvas3ds.on("chargeAuthReject", function (data) {
|
|
4589
|
+
console.log(data);
|
|
4590
|
+
});
|
|
4591
|
+
canvas3ds.on("chargeAuthChallenge", function (data) {
|
|
4592
|
+
console.log(data);
|
|
4593
|
+
});
|
|
4594
|
+
canvas3ds.on("chargeAuthDecoupled", function (data) {
|
|
4595
|
+
console.log(data.result.description);
|
|
4596
|
+
});
|
|
4597
|
+
canvas3ds.on("error", function ({ charge_3ds_id, error }) {
|
|
4598
|
+
console.log(error);
|
|
4599
|
+
});
|
|
4600
|
+
canvas3ds.load();
|
|
4601
|
+
</script>
|
|
4602
|
+
</body>
|
|
4603
|
+
</html>
|
|
4604
|
+
```
|
|
4605
|
+
|
|
4606
|
+
**The chargeAuthSuccess event is executed both for frictionless flow, or for challenge flow after the customer has correctly authenticated with the bank using whatever challenge imposed.**
|
|
4607
|
+
**The chargeAuthChallenge event is sent before starting a challenge flow (i.e. opening an IFrame for the customer to complete a challenge with ther bank)**
|
|
4608
|
+
**The chargeAuthDecoupled event is sent when the flow is a decoupled challenge, alongside a `data.result.description` field that you must show to the customer, indicating the method the user must use to authenticate. For example this may happen by having the cardholder authenticating directly with their banking app through biometrics. Once the end customer does this, the Canvas3ds will be able to recognize the challenge result is ready and will either produce a chargeAuthSuccess or chargeAuthReject event**
|
|
4609
|
+
**The error event is sent if an unexpected issue with the client library occurs. In such scenarios, you should consider the autentication process as interrupted**
|
|
4610
|
+
|
|
4560
4611
|
## Vault Display Widget
|
|
4561
4612
|
You can find description of all methods and parameters [here](https://www.npmjs.com/package/@paydock/client-sdk#vault-display-widget)
|
|
4562
4613
|
|
package/bundles/widget.umd.js
CHANGED
|
@@ -5154,12 +5154,12 @@
|
|
|
5154
5154
|
});
|
|
5155
5155
|
});
|
|
5156
5156
|
}, onShippingChange: function onShippingChange(data, _actions) {
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
_this2.
|
|
5162
|
-
_this2.
|
|
5157
|
+
return new Promise(function (resolve, reject) {
|
|
5158
|
+
var parsedCallbackData = _this2.parseUpdateData(data);
|
|
5159
|
+
_this2.latestShippingData = parsedCallbackData.shipping;
|
|
5160
|
+
_this2.latestShippingChangePromiseResolve = resolve;
|
|
5161
|
+
_this2.latestShippingChangePromiseReject = reject;
|
|
5162
|
+
_this2.eventEmitter.emit(WALLET_EVENT.UPDATE, parsedCallbackData);
|
|
5163
5163
|
});
|
|
5164
5164
|
}, onApprove: function onApprove(data) {
|
|
5165
5165
|
return new Promise(function (resolve, reject) {
|
|
@@ -5814,6 +5814,15 @@
|
|
|
5814
5814
|
return null;
|
|
5815
5815
|
}
|
|
5816
5816
|
}
|
|
5817
|
+
}, {
|
|
5818
|
+
key: "extractData",
|
|
5819
|
+
value: function extractData(body) {
|
|
5820
|
+
try {
|
|
5821
|
+
return JSON.parse(atob(body.meta));
|
|
5822
|
+
} catch (_a) {
|
|
5823
|
+
return null;
|
|
5824
|
+
}
|
|
5825
|
+
}
|
|
5817
5826
|
}, {
|
|
5818
5827
|
key: "extractMeta",
|
|
5819
5828
|
value: function extractMeta(body) {
|
|
@@ -5948,6 +5957,8 @@
|
|
|
5948
5957
|
|
|
5949
5958
|
var WALLET_CAPTURE_LINK = '/v1/charges/wallet/capture';
|
|
5950
5959
|
var WALLET_CALLBACK_LINK = '/v1/charges/wallet/callback';
|
|
5960
|
+
var STANDALONE_3DS_PROCESS_LINK = '/v1/charges/standalone-3ds/process';
|
|
5961
|
+
var STANDALONE_3DS_HANDLE_LINK = '/v1/charges/standalone-3ds/handle';
|
|
5951
5962
|
var ApiChargeInternal = function () {
|
|
5952
5963
|
function ApiChargeInternal(api) {
|
|
5953
5964
|
classCallCheck(this, ApiChargeInternal);
|
|
@@ -5965,6 +5976,16 @@
|
|
|
5965
5976
|
value: function walletCallback(payload) {
|
|
5966
5977
|
return this.api.getClientPromise('POST', WALLET_CALLBACK_LINK).send(payload);
|
|
5967
5978
|
}
|
|
5979
|
+
}, {
|
|
5980
|
+
key: 'standalone3dsProcess',
|
|
5981
|
+
value: function standalone3dsProcess(payload) {
|
|
5982
|
+
return this.api.getClientPromise('POST', STANDALONE_3DS_PROCESS_LINK).send(payload);
|
|
5983
|
+
}
|
|
5984
|
+
}, {
|
|
5985
|
+
key: 'standalone3dsHandle',
|
|
5986
|
+
value: function standalone3dsHandle() {
|
|
5987
|
+
return this.api.getClientPromise('GET', STANDALONE_3DS_HANDLE_LINK).send(undefined);
|
|
5988
|
+
}
|
|
5968
5989
|
}]);
|
|
5969
5990
|
return ApiChargeInternal;
|
|
5970
5991
|
}();
|
|
@@ -6826,6 +6847,231 @@
|
|
|
6826
6847
|
return HtmlPaymentSourceWidget;
|
|
6827
6848
|
}(PaymentSourceWidget);
|
|
6828
6849
|
|
|
6850
|
+
var hiddenStyle = {
|
|
6851
|
+
visibility: "hidden",
|
|
6852
|
+
border: "0",
|
|
6853
|
+
width: "0",
|
|
6854
|
+
height: "0"
|
|
6855
|
+
};
|
|
6856
|
+
var PROCESS_STANDALONE_3DS_STATUS;
|
|
6857
|
+
(function (PROCESS_STANDALONE_3DS_STATUS) {
|
|
6858
|
+
PROCESS_STANDALONE_3DS_STATUS["SUCCESS"] = "success";
|
|
6859
|
+
PROCESS_STANDALONE_3DS_STATUS["ERROR"] = "error";
|
|
6860
|
+
PROCESS_STANDALONE_3DS_STATUS["PENDING"] = "pending";
|
|
6861
|
+
})(PROCESS_STANDALONE_3DS_STATUS || (PROCESS_STANDALONE_3DS_STATUS = {}));
|
|
6862
|
+
var GPAYMENTS_EVENT = {
|
|
6863
|
+
AUTH_SUCCESS: 'chargeAuthSuccess',
|
|
6864
|
+
AUTH_ERROR: 'chargeAuthReject',
|
|
6865
|
+
DECOUPLED: 'chargeAuthDecoupled',
|
|
6866
|
+
CHALLENGE: 'chargeAuthChallenge',
|
|
6867
|
+
ERROR: 'error'
|
|
6868
|
+
};
|
|
6869
|
+
var GPaymentsService = function () {
|
|
6870
|
+
function GPaymentsService(container, api, eventEmitter) {
|
|
6871
|
+
classCallCheck(this, GPaymentsService);
|
|
6872
|
+
|
|
6873
|
+
this.container = container;
|
|
6874
|
+
this.api = api;
|
|
6875
|
+
this.eventEmitter = eventEmitter;
|
|
6876
|
+
this.resultRead = false;
|
|
6877
|
+
this.iFrameEvent = new IFrameEvent(window);
|
|
6878
|
+
}
|
|
6879
|
+
|
|
6880
|
+
createClass(GPaymentsService, [{
|
|
6881
|
+
key: "load",
|
|
6882
|
+
value: function load(_ref, title) {
|
|
6883
|
+
var initialization_url = _ref.initialization_url,
|
|
6884
|
+
secondary_url = _ref.secondary_url,
|
|
6885
|
+
charge_3ds_id = _ref.charge_3ds_id;
|
|
6886
|
+
|
|
6887
|
+
try {
|
|
6888
|
+
this.setupIFrameEvents(charge_3ds_id);
|
|
6889
|
+
this.initializeIFrames(initialization_url, secondary_url, title);
|
|
6890
|
+
} catch (err) {
|
|
6891
|
+
this.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, this.parseError(err, charge_3ds_id));
|
|
6892
|
+
}
|
|
6893
|
+
}
|
|
6894
|
+
}, {
|
|
6895
|
+
key: "initializeIFrames",
|
|
6896
|
+
value: function initializeIFrames(initializationUrl, secondaryUrl, title) {
|
|
6897
|
+
var hideAuthorization = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
6898
|
+
|
|
6899
|
+
var divAuthorization = document.createElement("div");
|
|
6900
|
+
divAuthorization.setAttribute("id", "paydock_authorization_iframe");
|
|
6901
|
+
this.container.getElement().appendChild(divAuthorization);
|
|
6902
|
+
this.browserAndChallengeContainer = new Container("#paydock_authorization_iframe");
|
|
6903
|
+
this.iFrameAuthorization = new IFrame(this.browserAndChallengeContainer);
|
|
6904
|
+
this.iFrameAuthorization.load(initializationUrl, { title: title });
|
|
6905
|
+
var divSecondaryURL = document.createElement("div");
|
|
6906
|
+
divSecondaryURL.setAttribute("id", "paydock_secondary_iframe");
|
|
6907
|
+
this.container.getElement().appendChild(divSecondaryURL);
|
|
6908
|
+
this.monitoringContainer = new Container("#paydock_secondary_iframe");
|
|
6909
|
+
this.iFrameSecondaryUrl = new IFrame(this.monitoringContainer);
|
|
6910
|
+
this.iFrameSecondaryUrl.load(secondaryUrl, { title: title });
|
|
6911
|
+
this.hideIframes(hideAuthorization);
|
|
6912
|
+
}
|
|
6913
|
+
}, {
|
|
6914
|
+
key: "hideIframes",
|
|
6915
|
+
value: function hideIframes() {
|
|
6916
|
+
var hideAuthorization = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
6917
|
+
|
|
6918
|
+
for (var prop in hiddenStyle) {
|
|
6919
|
+
if (!hiddenStyle.hasOwnProperty(prop)) continue;
|
|
6920
|
+
if (hideAuthorization) this.iFrameAuthorization.setStyle(prop, hiddenStyle[prop]);
|
|
6921
|
+
this.iFrameSecondaryUrl.setStyle(prop, hiddenStyle[prop]);
|
|
6922
|
+
}
|
|
6923
|
+
}
|
|
6924
|
+
}, {
|
|
6925
|
+
key: "setupIFrameEvents",
|
|
6926
|
+
value: function setupIFrameEvents(widgetId) {
|
|
6927
|
+
var _this = this;
|
|
6928
|
+
|
|
6929
|
+
this.iFrameEvent.on(EVENT.CHARGE_AUTH, widgetId, function (data) {
|
|
6930
|
+
if (data.status === "MethodSkipped" /* SKIPPED */) _this.performAuthentication(data);
|
|
6931
|
+
});
|
|
6932
|
+
this.iFrameEvent.on(EVENT.CHARGE_AUTH_SUCCESS, widgetId, function (data) {
|
|
6933
|
+
_this.processResult(data.charge_3ds_id);
|
|
6934
|
+
});
|
|
6935
|
+
}
|
|
6936
|
+
}, {
|
|
6937
|
+
key: "parseResultData",
|
|
6938
|
+
value: function parseResultData(_ref2, charge3dsId) {
|
|
6939
|
+
var status = _ref2.status;
|
|
6940
|
+
|
|
6941
|
+
return {
|
|
6942
|
+
status: status,
|
|
6943
|
+
charge_3ds_id: charge3dsId
|
|
6944
|
+
};
|
|
6945
|
+
}
|
|
6946
|
+
}, {
|
|
6947
|
+
key: "parseHandleResponse",
|
|
6948
|
+
value: function parseHandleResponse(_ref3, charge3dsId) {
|
|
6949
|
+
var status = _ref3.status,
|
|
6950
|
+
result = _ref3.result;
|
|
6951
|
+
|
|
6952
|
+
return {
|
|
6953
|
+
status: status,
|
|
6954
|
+
charge_3ds_id: charge3dsId,
|
|
6955
|
+
result: {
|
|
6956
|
+
description: result === null || result === void 0 ? void 0 : result.description
|
|
6957
|
+
}
|
|
6958
|
+
};
|
|
6959
|
+
}
|
|
6960
|
+
}, {
|
|
6961
|
+
key: "parseError",
|
|
6962
|
+
value: function parseError(data, charge3dsId) {
|
|
6963
|
+
return { charge_3ds_id: charge3dsId, error: data };
|
|
6964
|
+
}
|
|
6965
|
+
}, {
|
|
6966
|
+
key: "processResult",
|
|
6967
|
+
value: function processResult(charge3dsId) {
|
|
6968
|
+
var _this2 = this;
|
|
6969
|
+
|
|
6970
|
+
if (this.resultRead) return;
|
|
6971
|
+
this.resultRead = true;
|
|
6972
|
+
this.api.charge().standalone3dsHandle().then(function (result) {
|
|
6973
|
+
_this2.iFrameAuthorization.remove();
|
|
6974
|
+
_this2.iFrameSecondaryUrl.remove();
|
|
6975
|
+
if (result.status === PROCESS_STANDALONE_3DS_STATUS.SUCCESS) _this2.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this2.parseResultData(result, charge3dsId));else _this2.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this2.parseResultData(result, charge3dsId));
|
|
6976
|
+
}, function (err) {
|
|
6977
|
+
_this2.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this2.parseError(err, charge3dsId));
|
|
6978
|
+
});
|
|
6979
|
+
}
|
|
6980
|
+
}, {
|
|
6981
|
+
key: "externalAPI",
|
|
6982
|
+
value: function externalAPI(method, url) {
|
|
6983
|
+
var request = new XMLHttpRequest();
|
|
6984
|
+
request.open(method, url, true);
|
|
6985
|
+
return new Promise(function (resolve, reject) {
|
|
6986
|
+
request.onload = function () {
|
|
6987
|
+
try {
|
|
6988
|
+
var body = JSON.parse(request.responseText);
|
|
6989
|
+
resolve(body);
|
|
6990
|
+
} catch (error) {
|
|
6991
|
+
reject(error);
|
|
6992
|
+
}
|
|
6993
|
+
};
|
|
6994
|
+
request.send();
|
|
6995
|
+
});
|
|
6996
|
+
}
|
|
6997
|
+
}, {
|
|
6998
|
+
key: "doPolling",
|
|
6999
|
+
value: function doPolling(url, charge3dsId) {
|
|
7000
|
+
var _this3 = this;
|
|
7001
|
+
|
|
7002
|
+
this.externalAPI("GET", url).then(function (data) {
|
|
7003
|
+
if (!data.event || data.event === "AuthResultNotReady") setTimeout(function () {
|
|
7004
|
+
_this3.doPolling(url, charge3dsId);
|
|
7005
|
+
}, 2000);else if (data.event === 'AuthResultReady') _this3.processResult(charge3dsId);else throw new Error("Event not supported");
|
|
7006
|
+
}).catch(function (err) {
|
|
7007
|
+
return _this3.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this3.parseError(err, charge3dsId));
|
|
7008
|
+
});
|
|
7009
|
+
}
|
|
7010
|
+
}, {
|
|
7011
|
+
key: "performAuthentication",
|
|
7012
|
+
value: function performAuthentication(_ref4) {
|
|
7013
|
+
var _this4 = this;
|
|
7014
|
+
|
|
7015
|
+
var charge_3ds_id = _ref4.charge_3ds_id;
|
|
7016
|
+
|
|
7017
|
+
this.iFrameAuthorization.remove();
|
|
7018
|
+
this.iFrameSecondaryUrl.remove();
|
|
7019
|
+
this.api.charge().standalone3dsProcess({ charge_3ds_id: charge_3ds_id }).then(function (authenticationResult) {
|
|
7020
|
+
var _a, _b;
|
|
7021
|
+
if (authenticationResult.status === "success" /* SUCCESS */) _this4.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));else if (authenticationResult.status === "pending" /* PENDING */) {
|
|
7022
|
+
if ((_a = authenticationResult === null || authenticationResult === void 0 ? void 0 : authenticationResult.result) === null || _a === void 0 ? void 0 : _a.challenge) {
|
|
7023
|
+
_this4.eventEmitter.emit(GPAYMENTS_EVENT.CHALLENGE, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
|
|
7024
|
+
_this4.initializeIFrames(authenticationResult.result.challenge_url, 'authenticationResult.result.secondary_url', 'Authentication Challenge', false);
|
|
7025
|
+
_this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
|
|
7026
|
+
} else if ((_b = authenticationResult === null || authenticationResult === void 0 ? void 0 : authenticationResult.result) === null || _b === void 0 ? void 0 : _b.decoupled_challenge) {
|
|
7027
|
+
_this4.eventEmitter.emit(GPAYMENTS_EVENT.DECOUPLED, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
|
|
7028
|
+
_this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
|
|
7029
|
+
}
|
|
7030
|
+
} else return _this4.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
|
|
7031
|
+
}, function (err) {
|
|
7032
|
+
_this4.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this4.parseError(err, charge_3ds_id));
|
|
7033
|
+
});
|
|
7034
|
+
}
|
|
7035
|
+
}]);
|
|
7036
|
+
return GPaymentsService;
|
|
7037
|
+
}();
|
|
7038
|
+
|
|
7039
|
+
var STANDALONE_3DS_GATEWAYS = {
|
|
7040
|
+
GPAYMENTS: "GPayments"
|
|
7041
|
+
};
|
|
7042
|
+
var Standalone3dsService = function () {
|
|
7043
|
+
function Standalone3dsService(container, eventEmitter) {
|
|
7044
|
+
classCallCheck(this, Standalone3dsService);
|
|
7045
|
+
|
|
7046
|
+
this.env = ENV.SANDBOX;
|
|
7047
|
+
this.container = container;
|
|
7048
|
+
this.eventEmitter = eventEmitter;
|
|
7049
|
+
}
|
|
7050
|
+
|
|
7051
|
+
createClass(Standalone3dsService, [{
|
|
7052
|
+
key: "load",
|
|
7053
|
+
value: function load(token, options) {
|
|
7054
|
+
var parsedToken = AccessToken.validateJWT(token);
|
|
7055
|
+
if (!parsedToken) throw new Error("Invalid charge token");
|
|
7056
|
+
var tokenData = AccessToken.extractData(parsedToken.body);
|
|
7057
|
+
var api = new ApiInternal(token, API_AUTH_TYPE.TOKEN);
|
|
7058
|
+
api.setEnv(this.env, this.alias);
|
|
7059
|
+
switch (tokenData.service_type) {
|
|
7060
|
+
case STANDALONE_3DS_GATEWAYS.GPAYMENTS:
|
|
7061
|
+
new GPaymentsService(this.container, api, this.eventEmitter).load(tokenData, options.title);
|
|
7062
|
+
break;
|
|
7063
|
+
}
|
|
7064
|
+
}
|
|
7065
|
+
}, {
|
|
7066
|
+
key: "setEnv",
|
|
7067
|
+
value: function setEnv(env, alias) {
|
|
7068
|
+
this.env = env;
|
|
7069
|
+
this.alias = alias;
|
|
7070
|
+
}
|
|
7071
|
+
}]);
|
|
7072
|
+
return Standalone3dsService;
|
|
7073
|
+
}();
|
|
7074
|
+
|
|
6829
7075
|
/**
|
|
6830
7076
|
* List of available token's content formats
|
|
6831
7077
|
* @enum TOKEN_FORMAT
|
|
@@ -6837,6 +7083,7 @@
|
|
|
6837
7083
|
(function (TOKEN_FORMAT) {
|
|
6838
7084
|
TOKEN_FORMAT["HTML"] = "html";
|
|
6839
7085
|
TOKEN_FORMAT["URL"] = "url";
|
|
7086
|
+
TOKEN_FORMAT["STANDALONE_3DS"] = "standalone_3ds";
|
|
6840
7087
|
})(TOKEN_FORMAT || (TOKEN_FORMAT = {}));
|
|
6841
7088
|
/**
|
|
6842
7089
|
* List of available event's name
|
|
@@ -6849,6 +7096,17 @@
|
|
|
6849
7096
|
* @param {string} ADDITIONAL_DATA_REJECT=additionalDataCollectReject
|
|
6850
7097
|
* @param {string} CHARGE_AUTH=chargeAuth
|
|
6851
7098
|
*/
|
|
7099
|
+
/**
|
|
7100
|
+
* List of available event's name for Standalone 3ds flow
|
|
7101
|
+
* @const STANDALONE_3DS_EVENT
|
|
7102
|
+
*
|
|
7103
|
+
* @type {object}
|
|
7104
|
+
* @param {string} CHARGE_AUTH_SUCCESS=chargeAuthSuccess
|
|
7105
|
+
* @param {string} CHARGE_AUTH_REJECT=chargeAuthReject
|
|
7106
|
+
* @param {string} CHARGE_AUTH_DECOUPLED=chargeAuthDecoupled
|
|
7107
|
+
* @param {string} CHARGE_AUTH_CHALLENGE=chargeAuthChallenge
|
|
7108
|
+
* @param {string} ERROR=error
|
|
7109
|
+
*/
|
|
6852
7110
|
/**
|
|
6853
7111
|
* Class Canvas3ds include method for working on html
|
|
6854
7112
|
* @constructor
|
|
@@ -6870,6 +7128,8 @@
|
|
|
6870
7128
|
this.link.setParams({ ref_id: this.token.charge_3ds_id });
|
|
6871
7129
|
this.container = new Container(selector);
|
|
6872
7130
|
this.iFrame = new IFrame(this.container);
|
|
7131
|
+
this.eventEmitter = new EventEmitter();
|
|
7132
|
+
this.standalone3dsService = new Standalone3dsService(this.container, this.eventEmitter);
|
|
6873
7133
|
this.event = new IFrameEvent(window);
|
|
6874
7134
|
}
|
|
6875
7135
|
|
|
@@ -6881,7 +7141,7 @@
|
|
|
6881
7141
|
*
|
|
6882
7142
|
*/
|
|
6883
7143
|
value: function load() {
|
|
6884
|
-
if (this.token.format === TOKEN_FORMAT.HTML) this.iFrame.loadFromHtml(this.token.content, { title: '3d secure authentication' });else if (this.token.format === TOKEN_FORMAT.URL) this.iFrame.load(this.token.content, { title: '3d secure authentication' });else console.error('Token contain unsupported payload');
|
|
7144
|
+
if (this.token.format === TOKEN_FORMAT.HTML) this.iFrame.loadFromHtml(this.token.content, { title: '3d secure authentication' });else if (this.token.format === TOKEN_FORMAT.URL) this.iFrame.load(this.token.content, { title: '3d secure authentication' });else if (this.token.format === TOKEN_FORMAT.STANDALONE_3DS) this.standalone3dsService.load(this.token.content, { title: '3d secure authentication' });else console.error('Token contain unsupported payload');
|
|
6885
7145
|
}
|
|
6886
7146
|
/**
|
|
6887
7147
|
* Current method can change environment. By default environment = sandbox.
|
|
@@ -6897,6 +7157,7 @@
|
|
|
6897
7157
|
key: 'setEnv',
|
|
6898
7158
|
value: function setEnv(env, alias) {
|
|
6899
7159
|
this.link.setEnv(env, alias);
|
|
7160
|
+
this.standalone3dsService.setEnv(env, alias);
|
|
6900
7161
|
for (var index in this.configs) {
|
|
6901
7162
|
if (!this.configs.hasOwnProperty(index)) continue;
|
|
6902
7163
|
this.configs[index].setEnv(env, alias);
|
|
@@ -6919,7 +7180,7 @@
|
|
|
6919
7180
|
* widget.on('chargeAuthReject').then(function (data) {
|
|
6920
7181
|
* console.log(data);
|
|
6921
7182
|
* });
|
|
6922
|
-
* @param {string} eventName - Available event names [EVENT]{@link EVENT}
|
|
7183
|
+
* @param {string} eventName - Available event names [EVENT]{@link EVENT} [STANDALONE_3DS_EVENT]{@link STANDALONE_3DS_EVENT}
|
|
6923
7184
|
* @param {listener} [cb]
|
|
6924
7185
|
* @return {Promise<IEventData> | void}
|
|
6925
7186
|
*/
|
|
@@ -6929,12 +7190,21 @@
|
|
|
6929
7190
|
value: function on(eventName, cb) {
|
|
6930
7191
|
var _this = this;
|
|
6931
7192
|
|
|
6932
|
-
if (
|
|
6933
|
-
|
|
6934
|
-
return
|
|
6935
|
-
return
|
|
7193
|
+
if (this.token.format === TOKEN_FORMAT.STANDALONE_3DS) {
|
|
7194
|
+
if (typeof cb === 'function') return this.eventEmitter.subscribe(eventName, cb);
|
|
7195
|
+
return new Promise(function (resolve) {
|
|
7196
|
+
return _this.eventEmitter.subscribe(eventName, function (res) {
|
|
7197
|
+
return resolve(res);
|
|
7198
|
+
});
|
|
6936
7199
|
});
|
|
6937
|
-
}
|
|
7200
|
+
} else {
|
|
7201
|
+
if (typeof cb === 'function') return this.event.on(eventName, this.link.getParams().ref_id, cb);
|
|
7202
|
+
return new Promise(function (resolve) {
|
|
7203
|
+
return _this.event.on(eventName, _this.link.getParams().ref_id, function (res) {
|
|
7204
|
+
return resolve(res);
|
|
7205
|
+
});
|
|
7206
|
+
});
|
|
7207
|
+
}
|
|
6938
7208
|
}
|
|
6939
7209
|
/**
|
|
6940
7210
|
* Using this method you can hide widget after load
|