@lomray/microservice-payment-stripe
Version:
Stripe payment microservice based on NodeJS & inverted json.
50 lines (46 loc) • 1.55 kB
JavaScript
;
var tslib = require('tslib');
var microserviceHelpers = require('@lomray/microservice-helpers');
var classTransformer = require('class-transformer');
var classValidator = require('class-validator');
var price = require('../../entities/price.js');
var stripe = require('../../services/payment-gateway/stripe.js');
class PriceCreateInput {
}
tslib.__decorate([
classValidator.IsString(),
tslib.__metadata("design:type", String)
], PriceCreateInput.prototype, "productId", void 0);
tslib.__decorate([
classValidator.IsString(),
tslib.__metadata("design:type", String)
], PriceCreateInput.prototype, "currency", void 0);
tslib.__decorate([
classValidator.IsString(),
tslib.__metadata("design:type", String)
], PriceCreateInput.prototype, "userId", void 0);
tslib.__decorate([
classValidator.IsNumber(),
tslib.__metadata("design:type", Number)
], PriceCreateInput.prototype, "unitAmount", void 0);
class PriceCreateOutput {
}
tslib.__decorate([
classValidator.IsObject(),
classTransformer.Type(() => price),
tslib.__metadata("design:type", price)
], PriceCreateOutput.prototype, "entity", void 0);
/**
* Create new price
*/
const create = microserviceHelpers.Endpoint.custom(() => ({
input: PriceCreateInput,
output: PriceCreateOutput,
description: 'Create new price',
}), (params) => tslib.__awaiter(void 0, void 0, void 0, function* () {
const service = yield stripe.init();
return {
entity: yield service.createPrice(params),
};
}));
module.exports = create;