UNPKG

securepay

Version:

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

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