UNPKG

@lomray/microservice-payment-stripe

Version:

Stripe payment microservice based on NodeJS & inverted json.

46 lines (42 loc) 1.47 kB
'use strict'; var tslib = require('tslib'); var microserviceHelpers = require('@lomray/microservice-helpers'); var classTransformer = require('class-transformer'); var classValidator = require('class-validator'); var customer = require('../../entities/customer.js'); var stripe = require('../../services/payment-gateway/stripe.js'); class CustomerCreateInput { } tslib.__decorate([ classValidator.IsString(), tslib.__metadata("design:type", String) ], CustomerCreateInput.prototype, "userId", void 0); tslib.__decorate([ classValidator.IsString(), tslib.__metadata("design:type", String) ], CustomerCreateInput.prototype, "email", void 0); tslib.__decorate([ classValidator.IsString(), tslib.__metadata("design:type", String) ], CustomerCreateInput.prototype, "name", void 0); class CustomerCreateOutput { } tslib.__decorate([ classValidator.IsObject(), classTransformer.Type(() => customer), tslib.__metadata("design:type", customer) ], CustomerCreateOutput.prototype, "entity", void 0); /** * Create new customer */ const create = microserviceHelpers.Endpoint.custom(() => ({ input: CustomerCreateInput, output: CustomerCreateOutput, description: 'Create new customer', }), ({ userId, email, name }) => tslib.__awaiter(void 0, void 0, void 0, function* () { const service = yield stripe.init(); return { entity: yield service.createCustomer(userId, email, name), }; })); module.exports = create;