UNPKG

securepay

Version:

https://www.securepay.com.au/

62 lines (61 loc) 2.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WechatPayTransactionService = void 0; var wechat_pay_endpoints_const_1 = require("../../../../constants/wechat-pay-endpoints.const"); var enums_1 = require("../../../../enums"); var request_service_1 = require("../../../common/request/request.service"); var WechatPayTransactionService = /** @class */ (function () { function WechatPayTransactionService(options) { this._http = new request_service_1.RequestService(options); this.sandbox = options.sandbox || false; this.debugLevel = options.debugLevel || enums_1.DebugLevel.NONE; this.clientId = options.clientId; this.clientSecret = options.clientSecret; this.merchantCode = options.merchantCode; } /** * Initiates a Wechat transaction. * * @param {WechatPayTransactionInitial} payload */ WechatPayTransactionService.prototype.initialTransaction = function (payload) { if (!payload.merchantCode) payload.merchantCode = this.merchantCode; return this._http.post({ url: wechat_pay_endpoints_const_1.WechatPayEndpoints.INITIAL(this.sandbox), token_type: enums_1.TokenType.SECUREPAY_JWT, data: payload }); }; /** * Refunds a previously executed Wechat transaction * * @param {string} orderId * @param {WechatPayTransactionRefund} payload */ WechatPayTransactionService.prototype.refundTransaction = function (orderId, payload) { if (!payload.merchantCode) payload.merchantCode = this.merchantCode; return this._http.post({ url: wechat_pay_endpoints_const_1.WechatPayEndpoints.REFUND(this.sandbox, orderId), token_type: enums_1.TokenType.SECUREPAY_JWT, data: payload }); }; /** * Retrieves billing & shipping details for a customer that has previously initiated a Wechat transaction * * @param {string} orderId * @param {string} merchantCode */ WechatPayTransactionService.prototype.retrieveTransaction = function (orderId, merchantCode) { if (!merchantCode) merchantCode = this.merchantCode; return this._http.get({ url: wechat_pay_endpoints_const_1.WechatPayEndpoints.RETRIEVE(this.sandbox, orderId, merchantCode), token_type: enums_1.TokenType.SECUREPAY_JWT }); }; return WechatPayTransactionService; }()); exports.WechatPayTransactionService = WechatPayTransactionService;