UNPKG

node-wipay

Version:

This is a node wrapper for the WiPay Caribbean V1 API.

64 lines 2.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * WiPay Gateway Class * This class handles the Credit Card Gateway Endpoint Operations. * @param {WiPayAuth} auth * @param {WiPayGatewayConfig} config * @return {WiPayGateway} */ var WiPayGateway = /** @class */ (function () { /** * WiPay Gateway Constructor * Creates and initialises the WiPay Gateway object. * @param {WiPayAuth} auth * @param {WiPayGatewayConfig} config */ function WiPayGateway(auth, config) { var _this = this; /** * Construct Payment Endpoint * This function returns the Payment Endpoint to be used. Note * that this endpoint is a wrapper around the Gateway endpoint * and requires less parameters to be passed, but changes the * user's experience. * @return {string} */ this.constructPaymentEndpoint = function () { var endpoint = ("" + _this._auth.Gateway + ("?total=" + _this._config.Total) + ("&currency=" + _this._config.Currency) + ("&order_id=" + _this._config.OrderID) + ("&fee_structure=" + _this._config.FeeStructure) + ("&account_number=" + (_this._auth.Config.AccountNumber || _this._auth.Config.DeveloperID)) + ("&return_url=" + _this._config.RedirectUrl)); return endpoint; }; /** * Construct Gateway Endpoint * This function returns the Gateway Endpoint to be used. This is * the base Gateway Endpoint and takes many standard parameters. * @return {string} */ this.constructGatewayEndpoint = function () { var endpoint = ("" + _this._auth.Gateway + ("?name=" + _this._config.Name) + ("&phone=" + _this._config.PhoneNumber) + ("&email=" + _this._config.Email) + ("&total=" + _this._config.Total) + ("&currency=" + _this._config.Currency) + ("&order_id=" + _this._config.OrderID) + ("&developer_id=" + (_this._auth.Config.AccountNumber || _this._auth.Config.DeveloperID)) + ("&return_url=" + _this._config.RedirectUrl)); return endpoint; }; this.generateEndpoint = function () { return _this._auth.Payments ? _this.constructPaymentEndpoint() : _this.constructGatewayEndpoint(); }; this._auth = auth; this._config = config; } return WiPayGateway; }()); exports.default = WiPayGateway; //# sourceMappingURL=index.js.map