securepay
Version:
https://www.securepay.com.au/
46 lines (45 loc) • 1.72 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.CardPaymentClient = void 0;
var js_sdk_url_enum_1 = require("../enums/js-sdk-url.enum");
var CardPaymentClient = /** @class */ (function () {
function CardPaymentClient(options) {
var _this = this;
this.securePayUiLoaded = false;
options.callback && (this.callback = options.callback);
this.sandbox = options.sandbox;
this.clientId = options.clientId;
this.merchantCode = options.merchantCode;
this.containerId = options.containerId;
var scriptEl = document.createElement('script');
scriptEl.id = "securepay-ui-js";
scriptEl.onload = function () {
_this.init();
};
scriptEl.src = this.sandbox ? js_sdk_url_enum_1.JsSdkUrl.SANDBOX_UI : js_sdk_url_enum_1.JsSdkUrl.UI;
document.head.appendChild(scriptEl);
}
/**
* Initial
*/
CardPaymentClient.prototype.init = function () {
var _this = this;
this.securePayUI = new securePayUI.init({
containerId: this.containerId,
scriptId: 'securepay-ui-js',
clientId: this.clientId,
merchantCode: this.merchantCode,
card: {
onTokeniseSuccess: function (tokenisedCard) {
_this.callback && _this.callback('onTokeniseSuccess', tokenisedCard);
}
},
onLoadComplete: function () {
_this.securePayUiLoaded = true;
_this.callback && _this.callback('onLoadComplete');
}
});
};
return CardPaymentClient;
}());
exports.CardPaymentClient = CardPaymentClient;
;