sslcommerz
Version:
### Installation
68 lines (67 loc) • 3.9 kB
JavaScript
"use strict";
exports.__esModule = true;
var fetch_1 = require("./fetch");
var payment_init_data_process_1 = require("./payment-init-data-process");
var SslCommerzPayment = /** @class */ (function () {
function SslCommerzPayment(store_id, store_passwd, live) {
if (live === void 0) { live = false; }
this.baseURL = "https://" + (live ? 'securepay' : 'sandbox') + ".sslcommerz.com";
this.initURL = this.baseURL + '/gwprocess/v4/api.php';
this.validationURL = this.baseURL + '/validator/api/validationserverAPI.php?';
this.refundURL = this.baseURL + '/validator/api/merchantTransIDvalidationAPI.php?';
this.refundQueryURL = this.baseURL + '/validator/api/merchantTransIDvalidationAPI.php?';
this.transactionQueryBySessionIdURL = this.baseURL + '/validator/api/merchantTransIDvalidationAPI.php?';
this.transactionQueryByTransactionIdURL = this.baseURL + '/validator/api/merchantTransIDvalidationAPI.php?';
this.store_id = store_id;
this.store_password = store_passwd;
}
SslCommerzPayment.prototype.init = function (data, url, method) {
if (url === void 0) { url = false; }
if (method === void 0) { method = "POST"; }
data.store_id = this.store_id;
data.store_passwd = this.store_password;
return fetch_1.httpCall({ url: url || this.initURL, method: method || "POST", data: payment_init_data_process_1.paymentInitDataProcess(data) });
};
SslCommerzPayment.prototype.validate = function (data, url, method) {
if (url === void 0) { url = false; }
if (method === void 0) { method = "GET"; }
return fetch_1.httpCall({
url: url || this.validationURL + ("val_id=" + data.val_id + "&store_id=" + this.store_id + "&store_passwd=" + this.store_password + "&v=1&format=json"),
method: method || "GET"
});
};
SslCommerzPayment.prototype.initiateRefund = function (data, url, method) {
if (url === void 0) { url = false; }
if (method === void 0) { method = "GET"; }
return fetch_1.httpCall({
url: url || this.refundURL + ("refund_amount=" + data.refund_amount + "&refund_remarks=" + data.refund_remarks + "&bank_tran_id=" + data.bank_tran_id + "&refe_id=" + data.refe_id + "&store_id=" + this.store_id + "&store_passwd=" + this.store_password + "&v=1&format=json"),
method: method || "GET"
});
};
SslCommerzPayment.prototype.refundQuery = function (data, url, method) {
if (url === void 0) { url = false; }
if (method === void 0) { method = "GET"; }
return fetch_1.httpCall({
url: url || this.refundQueryURL + ("refund_ref_id=" + data.refund_ref_id + "&store_id=" + this.store_id + "&store_passwd=" + this.store_password + "&v=1&format=json"),
method: method || "GET"
});
};
SslCommerzPayment.prototype.transactionQueryBySessionId = function (data, url, method) {
if (url === void 0) { url = false; }
if (method === void 0) { method = "GET"; }
return fetch_1.httpCall({
url: url || this.transactionQueryBySessionIdURL + ("sessionkey=" + data.sessionkey + "&store_id=" + this.store_id + "&store_passwd=" + this.store_password + "&v=1&format=json"),
method: method || "GET"
});
};
SslCommerzPayment.prototype.transactionQueryByTransactionId = function (data, url, method) {
if (url === void 0) { url = false; }
if (method === void 0) { method = "GET"; }
return fetch_1.httpCall({
url: url || this.transactionQueryByTransactionIdURL + ("tran_id=" + data.tran_id + "&store_id=" + this.store_id + "&store_passwd=" + this.store_password + "&v=1&format=json"),
method: method || "GET"
});
};
return SslCommerzPayment;
}());
exports["default"] = SslCommerzPayment;