UNPKG

@wepublish/api

Version:
37 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TransactionClient = void 0; const tslib_1 = require("tslib"); class TransactionClient { constructor(client) { this.client = client; } chargePreAuthorizedTransaction(preAuthorizedTransactionId, requestData) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const response = yield this.client.post('Transaction/' + preAuthorizedTransactionId, requestData); if (response.status === 'error') { throw new Error(`Payrexx request has error status with message: ${response.message}`); } if (!response.data[0]) { throw new Error('Cannot find created gateway'); } return response.data[0]; }); } retrieveTransaction(transactionId) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const response = yield this.client.get('Transaction/' + encodeURIComponent(transactionId)); if (response.status === 'error') { if (response.message === 'An error occurred: No Transaction found with id ' + transactionId) { return null; } else { throw new Error(`Payrexx request has error status with message: ${response.message}`); } } return response.data[0]; }); } } exports.TransactionClient = TransactionClient; //# sourceMappingURL=transaction-client.js.map