UNPKG

@lomray/microservice-payment-stripe

Version:

Stripe payment microservice based on NodeJS & inverted json.

54 lines (50 loc) 1.84 kB
'use strict'; var tslib = require('tslib'); var microserviceHelpers = require('@lomray/microservice-helpers'); var classTransformer = require('class-transformer'); var classValidator = require('class-validator'); var card = require('../../entities/card.js'); var stripe = require('../../services/payment-gateway/stripe.js'); class CardAddInput { } tslib.__decorate([ classValidator.IsString(), tslib.__metadata("design:type", String) ], CardAddInput.prototype, "userId", void 0); tslib.__decorate([ classValidator.IsString(), microserviceHelpers.IsUndefinable(), tslib.__metadata("design:type", String) ], CardAddInput.prototype, "token", void 0); tslib.__decorate([ classValidator.IsString(), microserviceHelpers.IsUndefinable(), tslib.__metadata("design:type", String) ], CardAddInput.prototype, "expired", void 0); tslib.__decorate([ classValidator.IsString(), microserviceHelpers.IsUndefinable(), tslib.__metadata("design:type", String) ], CardAddInput.prototype, "digits", void 0); tslib.__decorate([ classValidator.IsString(), microserviceHelpers.IsUndefinable(), tslib.__metadata("design:type", String) ], CardAddInput.prototype, "cvc", void 0); class CardAddOutput { } tslib.__decorate([ classValidator.IsObject(), classTransformer.Type(() => card), tslib.__metadata("design:type", card) ], CardAddOutput.prototype, "entity", void 0); /** * Add new card */ const add = microserviceHelpers.Endpoint.custom(() => ({ input: CardAddInput, output: CardAddOutput, description: 'Add new card' }), ({ userId, digits, cvc, token, expired }) => tslib.__awaiter(void 0, void 0, void 0, function* () { const service = yield stripe.init(); return { entity: yield service.addCard({ userId, token, expired, digits, cvc }), }; })); module.exports = add;