UNPKG

@lomray/microservice-payment-stripe

Version:

Stripe payment microservice based on NodeJS & inverted json.

82 lines (78 loc) 3.2 kB
'use strict'; var tslib = require('tslib'); var microserviceHelpers = require('@lomray/microservice-helpers'); var classValidator = require('class-validator'); var classValidatorJsonschema = require('class-validator-jsonschema'); var typeorm = require('typeorm'); var refundStatus = require('../constants/refund-status.js'); var transactionStatus = require('../constants/transaction-status.js'); /** * Refund entity * @TODO Refund don't have pure relation to the transaction cause, cause: * 1. Transaction id is not unique (presented as debit and credit transactions) * 2. If relation will be refer to the transaction pk id, refunds will be duplicated for both transaction types */ let Refund = class Refund { }; tslib.__decorate([ typeorm.PrimaryGeneratedColumn('uuid'), classValidator.Length(1, 36), tslib.__metadata("design:type", String) ], Refund.prototype, "id", void 0); tslib.__decorate([ classValidatorJsonschema.JSONSchema({ description: 'Stripe transaction id (e.g. payment intent)', example: 'pi_3Nha3JAmQ4asS8PS0JPXIyEh', }), typeorm.Column({ type: 'varchar', length: 66 }), classValidator.Length(1, 66), tslib.__metadata("design:type", String) ], Refund.prototype, "transactionId", void 0); tslib.__decorate([ classValidatorJsonschema.JSONSchema({ description: 'Handled refund amount, should be less or equal to refund amount', example: 10000, }), classValidatorJsonschema.JSONSchema({ description: 'Unit amount (e.g. 100$ = 10000 in unit' }), typeorm.Column({ type: 'int' }), classValidator.IsNumber(), tslib.__metadata("design:type", Number) ], Refund.prototype, "amount", void 0); tslib.__decorate([ classValidatorJsonschema.JSONSchema({ description: 'Microservice entity. Can be entity from transaction group or other', }), typeorm.Column({ type: 'varchar', length: 36, default: null }), microserviceHelpers.IsUndefinable(), microserviceHelpers.IsNullable(), classValidator.Length(1, 36), tslib.__metadata("design:type", Object) ], Refund.prototype, "entityId", void 0); tslib.__decorate([ typeorm.Column({ type: 'json', default: {} }), classValidator.IsObject(), microserviceHelpers.IsUndefinable(), tslib.__metadata("design:type", Object) ], Refund.prototype, "params", void 0); tslib.__decorate([ typeorm.Column({ type: 'enum', enum: refundStatus, default: refundStatus.INITIAL }), classValidator.IsEnum(transactionStatus), microserviceHelpers.IsUndefinable(), tslib.__metadata("design:type", String) ], Refund.prototype, "status", void 0); tslib.__decorate([ microserviceHelpers.IsTypeormDate(), typeorm.CreateDateColumn(), tslib.__metadata("design:type", Date) ], Refund.prototype, "createdAt", void 0); tslib.__decorate([ microserviceHelpers.IsTypeormDate(), typeorm.UpdateDateColumn(), tslib.__metadata("design:type", Date) ], Refund.prototype, "updatedAt", void 0); Refund = tslib.__decorate([ classValidatorJsonschema.JSONSchema({ description: 'Created refund related to the transaction' }), typeorm.Entity() ], Refund); var RefundEntity = Refund; module.exports = RefundEntity;