@lomray/microservice-payment-stripe
Version:
Stripe payment microservice based on NodeJS & inverted json.
151 lines (147 loc) • 6.05 kB
JavaScript
;
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 payoutMethod = require('../constants/payout-method.js');
var payoutStatus = require('../constants/payout-status.js');
var payoutType = require('../constants/payout-type.js');
/**
* Payout entity
*/
let Payout = class Payout {
};
tslib.__decorate([
typeorm.PrimaryGeneratedColumn('uuid'),
classValidator.Allow(),
tslib.__metadata("design:type", String)
], Payout.prototype, "id", void 0);
tslib.__decorate([
classValidatorJsonschema.JSONSchema({
description: 'Stripe payout id',
}),
typeorm.Unique('payout(uq):payoutId', ['payoutId']),
typeorm.Column({ type: 'varchar', length: 66 }),
classValidator.Length(1, 66),
tslib.__metadata("design:type", String)
], Payout.prototype, "payoutId", void 0);
tslib.__decorate([
classValidatorJsonschema.JSONSchema({
description: 'Min ±10 cents',
}),
typeorm.Column({ type: 'int' }),
classValidator.IsNumber(),
classValidator.Min(10),
tslib.__metadata("design:type", Number)
], Payout.prototype, "amount", void 0);
tslib.__decorate([
classValidatorJsonschema.JSONSchema({
description: 'Microservice entity. Your internal microservice payout (withdraw) or any else entity, that implements custom functionality',
}),
typeorm.Column({ type: 'varchar', length: 36, default: null }),
classValidator.Length(1, 36),
microserviceHelpers.IsUndefinable(),
microserviceHelpers.IsNullable(),
tslib.__metadata("design:type", Object)
], Payout.prototype, "entityId", void 0);
tslib.__decorate([
classValidatorJsonschema.JSONSchema({
description: 'Id of the bank account or card the payout is sent to. Stripe destination is nullable',
}),
typeorm.Column({ type: 'varchar', length: 66, default: null }),
classValidator.Length(1, 66),
tslib.__metadata("design:type", Object)
], Payout.prototype, "destination", void 0);
tslib.__decorate([
classValidatorJsonschema.JSONSchema({
description: 'The method used to send this payout',
}),
typeorm.Column({ type: 'enum', enum: payoutMethod }),
classValidator.IsEnum(payoutMethod),
tslib.__metadata("design:type", String)
], Payout.prototype, "method", void 0);
tslib.__decorate([
typeorm.Column({ type: 'enum', enum: payoutType }),
classValidator.IsEnum(payoutType),
tslib.__metadata("design:type", String)
], Payout.prototype, "type", void 0);
tslib.__decorate([
classValidatorJsonschema.JSONSchema({
description: `A payout is pending until it’s submitted to the bank, when it becomes in_transit.
The status changes to paid if the transaction succeeds, or to failed or canceled (within 5 business days).
Some payouts that fail might initially show as paid, then change to failed.`,
}),
typeorm.Column({ type: 'enum', enum: payoutStatus }),
classValidator.IsEnum(payoutStatus),
tslib.__metadata("design:type", String)
], Payout.prototype, "status", void 0);
tslib.__decorate([
typeorm.Column({ type: 'varchar', length: 10 }),
classValidator.Length(1, 10),
tslib.__metadata("design:type", String)
], Payout.prototype, "currency", void 0);
tslib.__decorate([
typeorm.Column({ type: 'varchar', length: 20, default: null }),
classValidator.Length(1, 20),
microserviceHelpers.IsUndefinable(),
microserviceHelpers.IsNullable(),
tslib.__metadata("design:type", Object)
], Payout.prototype, "failureCode", void 0);
tslib.__decorate([
typeorm.Column({ type: 'text', default: null }),
classValidator.IsString(),
microserviceHelpers.IsUndefinable(),
microserviceHelpers.IsNullable(),
tslib.__metadata("design:type", Object)
], Payout.prototype, "failureMessage", void 0);
tslib.__decorate([
classValidatorJsonschema.JSONSchema({
description: 'An arbitrary meta information attached to stripe payout instance',
}),
typeorm.Column({ type: 'text', default: null }),
classValidator.IsString(),
microserviceHelpers.IsUndefinable(),
microserviceHelpers.IsNullable(),
tslib.__metadata("design:type", Object)
], Payout.prototype, "description", void 0);
tslib.__decorate([
classValidatorJsonschema.JSONSchema({
description: 'Date that you can expect the payout to arrive in the bank. This factors in delays to account for weekends or bank holidays',
}),
typeorm.Column({ type: 'timestamptz' }),
classValidator.IsDate(),
tslib.__metadata("design:type", Date)
], Payout.prototype, "arrivalDate", void 0);
tslib.__decorate([
typeorm.Column({ type: 'timestamptz' }),
classValidator.IsDate(),
tslib.__metadata("design:type", Date)
], Payout.prototype, "registeredAt", void 0);
tslib.__decorate([
typeorm.Column({ type: 'json', default: {} }),
classValidator.IsObject(),
microserviceHelpers.IsUndefinable(),
tslib.__metadata("design:type", Object)
], Payout.prototype, "params", void 0);
tslib.__decorate([
microserviceHelpers.IsTypeormDate(),
typeorm.CreateDateColumn(),
tslib.__metadata("design:type", Date)
], Payout.prototype, "createdAt", void 0);
tslib.__decorate([
microserviceHelpers.IsTypeormDate(),
typeorm.UpdateDateColumn(),
tslib.__metadata("design:type", Date)
], Payout.prototype, "updatedAt", void 0);
Payout = tslib.__decorate([
classValidatorJsonschema.JSONSchema({
title: 'Payout',
description: `A Payout object is created when you receive funds from Stripe, or when you initiate a payout
to either a bank account or debit card of a connected Stripe account. You can retrieve individual payouts,
and list all payouts. Payouts are made on varying schedules, depending on your country and industry.`,
}),
typeorm.Entity()
], Payout);
var PayoutEntity = Payout;
module.exports = PayoutEntity;