UNPKG

sslcommerz-js

Version:

A well-maintained, unofficial Node.js package for integrating SSLCommerz payments. Provides reliable support for initiating and handling transactions with minimal setup.

47 lines 2.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SslCommerz = void 0; const httpCall_1 = require("./httpCall"); const init_data_1 = require("./init.data"); class SslCommerz { constructor(store_id, store_passwd, 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_passwd = store_passwd; } init(data) { return (0, httpCall_1.httpCall)({ url: this.initURL, method: "POST", data: (0, init_data_1.paymentInitData)(Object.assign(Object.assign({}, data), { store_id: this.store_id, store_passwd: this.store_passwd })), }); } validate(data) { const requestUrl = `${this.validationURL}val_id=${data.val_id}&store_id=${this.store_id}&store_passwd=${this.store_passwd}&v=1&format=json`; return (0, httpCall_1.httpCall)({ url: requestUrl, method: "GET" }); } initiateRefund(data) { const requestUrl = `${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_passwd}&v=1&format=json`; return (0, httpCall_1.httpCall)({ url: requestUrl, method: "GET" }); } refundQuery(data) { const requestUrl = `${this.refundQueryURL}refund_ref_id=${data.refund_ref_id}&store_id=${this.store_id}&store_passwd=${this.store_passwd}&v=1&format=json`; return (0, httpCall_1.httpCall)({ url: requestUrl, method: "GET" }); } transactionQueryBySessionId(data) { const requestUrl = `${this.transactionQueryBySessionIdURL}sessionkey=${data.sessionkey}&store_id=${this.store_id}&store_passwd=${this.store_passwd}&v=1&format=json`; return (0, httpCall_1.httpCall)({ url: requestUrl, method: "GET" }); } transactionQueryByTransactionId(data) { const requestUrl = `${this.transactionQueryByTransactionIdURL}tran_id=${data.tran_id}&store_id=${this.store_id}&store_passwd=${this.store_passwd}&v=1&format=json`; return (0, httpCall_1.httpCall)({ url: requestUrl, method: "GET" }); } } exports.SslCommerz = SslCommerz; //# sourceMappingURL=paymentController.js.map