@payunit/nodejs-sdk
Version:
PayUnit Payment Processor SDK
39 lines • 2 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Invoice = void 0;
const invoice_1 = require("./types/invoice");
const invoice_2 = require("./validators/invoice");
class Invoice {
constructor(client) {
this.client = client;
}
createInvoice(request) {
return __awaiter(this, void 0, void 0, function* () {
const schema = request.type === invoice_1.InvoiceType.NORMAL
? invoice_2.normalInvoiceRequestSchema
: invoice_2.installmentInvoiceRequestSchema;
return yield this.client.makeRequest('POST', '/gateway/invoice/create', schema, request, 'Failed to create invoice');
});
}
getInvoice(invoice_id) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.client.makeRequest('GET', `/gateway/invoice/get/${invoice_id}`, invoice_2.invoiceIdSchema, { invoice_id }, 'Failed to get invoice');
});
}
payInvoice(paymentRequest) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.client.makeRequest('POST', '/gateway/invoice/payment', invoice_2.invoicePaymentRequestSchema, paymentRequest, 'Failed to pay invoice');
});
}
}
exports.Invoice = Invoice;
//# sourceMappingURL=Invoice.js.map