@merkaly/api 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.schemas.d.ts +1 -0
- package/dist/finance/payment/index.d.ts +1 -0
- package/dist/finance/payment/payment.entity.d.ts +2 -0
- package/dist/finance/payment/payment.enum.d.ts +1 -0
- package/dist/finance/payment/payment.enum.js +1 -0
- package/dist/finance/payment/payment.gateway.entity.d.ts +38 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/integration/payment/charge.d.ts +22 -0
- package/dist/integration/payment/charge.enum.d.ts +9 -0
- package/dist/integration/payment/charge.enum.js +10 -0
- package/dist/integration/payment/connection.d.ts +14 -0
- package/dist/integration/payment/index.d.ts +7 -0
- package/dist/integration/payment/index.js +3 -0
- package/dist/integration/payment/payment.connection.entity.d.ts +21 -0
- package/dist/integration/payment/payment.entity.d.ts +7 -0
- package/dist/integration/payment/provider.enum.d.ts +3 -0
- package/dist/integration/payment/provider.enum.js +4 -0
- package/dist/integration/payment/request.validator.d.ts +12 -0
- package/dist/integration/payment/request.validator.js +75 -0
- package/package.json +1 -1
package/dist/app.schemas.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { AbstractEntity } from '../../abstract.entity.js';
|
|
|
4
4
|
import { StatusEntity } from '../../status.plugin.js';
|
|
5
5
|
import { ITransitionable } from '../../transitionable.interface.js';
|
|
6
6
|
import { FinancePaymentMethodEnum, FinancePaymentStatusEnum, FinancePaymentTypeEnum } from './payment.enum.js';
|
|
7
|
+
import { FinancePaymentGatewayEntity } from './payment.gateway.entity.js';
|
|
7
8
|
export type OrderEntity = OrderSaleEntity | OrderPurchaseEntity;
|
|
8
9
|
export declare class FinancePaymentEntity extends AbstractEntity implements ITransitionable<FinancePaymentStatusEnum> {
|
|
9
10
|
type: FinancePaymentTypeEnum;
|
|
@@ -12,6 +13,7 @@ export declare class FinancePaymentEntity extends AbstractEntity implements ITra
|
|
|
12
13
|
amount: number;
|
|
13
14
|
fee: number;
|
|
14
15
|
method?: FinancePaymentMethodEnum | null;
|
|
16
|
+
gateway?: FinancePaymentGatewayEntity | null;
|
|
15
17
|
status: FinancePaymentStatusEnum;
|
|
16
18
|
history: StatusEntity<FinancePaymentStatusEnum>[];
|
|
17
19
|
readonly number: string;
|
|
@@ -8,6 +8,7 @@ export var FinancePaymentStatusEnum;
|
|
|
8
8
|
export var FinancePaymentMethodEnum;
|
|
9
9
|
(function (FinancePaymentMethodEnum) {
|
|
10
10
|
FinancePaymentMethodEnum["CARD"] = "CARD";
|
|
11
|
+
FinancePaymentMethodEnum["PIX"] = "PIX";
|
|
11
12
|
FinancePaymentMethodEnum["TRANSFER"] = "TRANSFER";
|
|
12
13
|
FinancePaymentMethodEnum["CASH"] = "CASH";
|
|
13
14
|
FinancePaymentMethodEnum["CRYPTO"] = "CRYPTO";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Schema as MongoSchema } from 'mongoose';
|
|
2
|
+
import { FinancePaymentMethodEnum } from './payment.enum.js';
|
|
3
|
+
export declare class FinancePaymentGatewayPixEntity {
|
|
4
|
+
qrCode?: string;
|
|
5
|
+
qrCodeBase64?: string;
|
|
6
|
+
ticketUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const FinancePaymentGatewayPixSchema: MongoSchema<FinancePaymentGatewayPixEntity, import("mongoose").Model<FinancePaymentGatewayPixEntity, any, any, any, import("mongoose").Document<unknown, any, FinancePaymentGatewayPixEntity, any, {}> & FinancePaymentGatewayPixEntity & {
|
|
9
|
+
_id: import("mongoose").Types.ObjectId;
|
|
10
|
+
} & {
|
|
11
|
+
__v: number;
|
|
12
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayPixEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayPixEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<FinancePaymentGatewayPixEntity> & {
|
|
13
|
+
_id: import("mongoose").Types.ObjectId;
|
|
14
|
+
} & {
|
|
15
|
+
__v: number;
|
|
16
|
+
}>;
|
|
17
|
+
export declare class FinancePaymentGatewayEntity {
|
|
18
|
+
provider: string;
|
|
19
|
+
reference: string;
|
|
20
|
+
paymentId?: string;
|
|
21
|
+
method: FinancePaymentMethodEnum;
|
|
22
|
+
status: string;
|
|
23
|
+
statusDetail?: string;
|
|
24
|
+
attempt: number;
|
|
25
|
+
amount: number;
|
|
26
|
+
pix?: FinancePaymentGatewayPixEntity;
|
|
27
|
+
expiresAt?: Date;
|
|
28
|
+
syncedAt: Date;
|
|
29
|
+
}
|
|
30
|
+
export declare const FinancePaymentGatewaySchema: MongoSchema<FinancePaymentGatewayEntity, import("mongoose").Model<FinancePaymentGatewayEntity, any, any, any, import("mongoose").Document<unknown, any, FinancePaymentGatewayEntity, any, {}> & FinancePaymentGatewayEntity & {
|
|
31
|
+
_id: import("mongoose").Types.ObjectId;
|
|
32
|
+
} & {
|
|
33
|
+
__v: number;
|
|
34
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<FinancePaymentGatewayEntity> & {
|
|
35
|
+
_id: import("mongoose").Types.ObjectId;
|
|
36
|
+
} & {
|
|
37
|
+
__v: number;
|
|
38
|
+
}>;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from './contact/customer';
|
|
|
17
17
|
export * from './contact/vendor';
|
|
18
18
|
export * from './finance/payment';
|
|
19
19
|
export * from './integration/supplier';
|
|
20
|
+
export * from './integration/payment';
|
|
20
21
|
export * from './inventory/catalog/brand';
|
|
21
22
|
export * from './inventory/catalog/category';
|
|
22
23
|
export * from './inventory/catalog/product';
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from './contact/customer/index.js';
|
|
|
9
9
|
export * from './contact/vendor/index.js';
|
|
10
10
|
export * from './finance/payment/index.js';
|
|
11
11
|
export * from './integration/supplier/index.js';
|
|
12
|
+
export * from './integration/payment/index.js';
|
|
12
13
|
export * from './inventory/catalog/brand/index.js';
|
|
13
14
|
export * from './inventory/catalog/category/index.js';
|
|
14
15
|
export * from './inventory/catalog/product/index.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PaymentChargeStatusEnum } from './charge.enum.js';
|
|
2
|
+
import type { PaymentProviderEnum } from './provider.enum.js';
|
|
3
|
+
import type { FinancePaymentMethodEnum } from '../../finance/payment';
|
|
4
|
+
export type StorePaymentMethod = FinancePaymentMethodEnum.PIX | FinancePaymentMethodEnum.CARD;
|
|
5
|
+
export interface StorePaymentConfig {
|
|
6
|
+
methods: StorePaymentMethod[];
|
|
7
|
+
provider: keyof typeof PaymentProviderEnum | null;
|
|
8
|
+
publicKey: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface PaymentCharge {
|
|
11
|
+
amount: number;
|
|
12
|
+
attempt: number;
|
|
13
|
+
expiresAt: Date | null;
|
|
14
|
+
method: StorePaymentMethod;
|
|
15
|
+
message: string | null;
|
|
16
|
+
paid: boolean;
|
|
17
|
+
qrCode: string | null;
|
|
18
|
+
qrCodeBase64: string | null;
|
|
19
|
+
status: PaymentChargeStatusEnum;
|
|
20
|
+
statusDetail: string | null;
|
|
21
|
+
ticketUrl: string | null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var PaymentChargeStatusEnum;
|
|
2
|
+
(function (PaymentChargeStatusEnum) {
|
|
3
|
+
PaymentChargeStatusEnum["PENDING"] = "PENDING";
|
|
4
|
+
PaymentChargeStatusEnum["IN_PROCESS"] = "IN_PROCESS";
|
|
5
|
+
PaymentChargeStatusEnum["APPROVED"] = "APPROVED";
|
|
6
|
+
PaymentChargeStatusEnum["REJECTED"] = "REJECTED";
|
|
7
|
+
PaymentChargeStatusEnum["CANCELLED"] = "CANCELLED";
|
|
8
|
+
PaymentChargeStatusEnum["EXPIRED"] = "EXPIRED";
|
|
9
|
+
PaymentChargeStatusEnum["REFUNDED"] = "REFUNDED";
|
|
10
|
+
})(PaymentChargeStatusEnum || (PaymentChargeStatusEnum = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PaymentConnectionStatus {
|
|
2
|
+
account: string | null;
|
|
3
|
+
configured: boolean;
|
|
4
|
+
connected: boolean;
|
|
5
|
+
connectedAt: Date | null;
|
|
6
|
+
expired: boolean;
|
|
7
|
+
expiresAt: Date | null;
|
|
8
|
+
liveMode: boolean | null;
|
|
9
|
+
userId: string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface PaymentConnectionAuthorization {
|
|
12
|
+
authorizationUrl: string;
|
|
13
|
+
state: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Schema as MongoSchema } from 'mongoose';
|
|
2
|
+
export declare class IntegrationPaymentConnectionEntity {
|
|
3
|
+
account?: string;
|
|
4
|
+
userId: string;
|
|
5
|
+
publicKey?: string;
|
|
6
|
+
liveMode: boolean;
|
|
7
|
+
scope?: string;
|
|
8
|
+
accessToken: string;
|
|
9
|
+
refreshToken?: string;
|
|
10
|
+
expiresAt: Date;
|
|
11
|
+
connectedAt: Date;
|
|
12
|
+
}
|
|
13
|
+
export declare const IntegrationPaymentConnectionSchema: MongoSchema<IntegrationPaymentConnectionEntity, import("mongoose").Model<IntegrationPaymentConnectionEntity, any, any, any, import("mongoose").Document<unknown, any, IntegrationPaymentConnectionEntity, any, {}> & IntegrationPaymentConnectionEntity & {
|
|
14
|
+
_id: import("mongoose").Types.ObjectId;
|
|
15
|
+
} & {
|
|
16
|
+
__v: number;
|
|
17
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentConnectionEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentConnectionEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<IntegrationPaymentConnectionEntity> & {
|
|
18
|
+
_id: import("mongoose").Types.ObjectId;
|
|
19
|
+
} & {
|
|
20
|
+
__v: number;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractEntity } from '../../abstract.entity.js';
|
|
2
|
+
import { PaymentProviderEnum } from './provider.enum.js';
|
|
3
|
+
import { IntegrationPaymentConnectionEntity } from './payment.connection.entity.js';
|
|
4
|
+
export declare class IntegrationPaymentEntity extends AbstractEntity {
|
|
5
|
+
provider: PaymentProviderEnum;
|
|
6
|
+
connection?: IntegrationPaymentConnectionEntity;
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AbstractRequestValidator } from '../../abstract.validator.js';
|
|
2
|
+
import type { StorePaymentMethod } from './charge.js';
|
|
3
|
+
export declare class CreatePaymentChargeRequestValidator extends AbstractRequestValidator {
|
|
4
|
+
method: StorePaymentMethod;
|
|
5
|
+
token?: string;
|
|
6
|
+
paymentMethodId?: string;
|
|
7
|
+
paymentTypeId?: 'credit_card';
|
|
8
|
+
issuerId?: string;
|
|
9
|
+
identificationType?: string;
|
|
10
|
+
identificationNumber?: string;
|
|
11
|
+
deviceId?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
import * as class_transformer_1 from "class-transformer";
|
|
12
|
+
import * as class_validator_1 from "class-validator";
|
|
13
|
+
import * as payment_enum_1 from '../../finance/payment/index.js';
|
|
14
|
+
import * as abstract_validator_1 from '../../abstract.validator.js';
|
|
15
|
+
const isCard = (body) => body.method === payment_enum_1.FinancePaymentMethodEnum.CARD;
|
|
16
|
+
const asString = ({ value }) => typeof value === 'number' ? String(value) : value;
|
|
17
|
+
export class CreatePaymentChargeRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
18
|
+
method;
|
|
19
|
+
token;
|
|
20
|
+
paymentMethodId;
|
|
21
|
+
paymentTypeId;
|
|
22
|
+
issuerId;
|
|
23
|
+
identificationType;
|
|
24
|
+
identificationNumber;
|
|
25
|
+
deviceId;
|
|
26
|
+
}
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, class_validator_1.IsIn)([payment_enum_1.FinancePaymentMethodEnum.PIX, payment_enum_1.FinancePaymentMethodEnum.CARD]),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], CreatePaymentChargeRequestValidator.prototype, "method", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, class_validator_1.ValidateIf)(isCard),
|
|
33
|
+
(0, class_validator_1.IsString)(),
|
|
34
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
35
|
+
(0, class_validator_1.Length)(1, 256),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], CreatePaymentChargeRequestValidator.prototype, "token", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, class_validator_1.ValidateIf)(isCard),
|
|
40
|
+
(0, class_validator_1.IsString)(),
|
|
41
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
42
|
+
(0, class_validator_1.Length)(1, 64),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], CreatePaymentChargeRequestValidator.prototype, "paymentMethodId", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, class_validator_1.IsOptional)(),
|
|
47
|
+
(0, class_validator_1.IsIn)(['credit_card']),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], CreatePaymentChargeRequestValidator.prototype, "paymentTypeId", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, class_validator_1.IsOptional)(),
|
|
52
|
+
(0, class_transformer_1.Transform)(asString),
|
|
53
|
+
(0, class_validator_1.IsString)(),
|
|
54
|
+
(0, class_validator_1.Length)(1, 64),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], CreatePaymentChargeRequestValidator.prototype, "issuerId", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, class_validator_1.IsOptional)(),
|
|
59
|
+
(0, class_validator_1.IsString)(),
|
|
60
|
+
(0, class_validator_1.Length)(1, 16),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], CreatePaymentChargeRequestValidator.prototype, "identificationType", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, class_validator_1.IsOptional)(),
|
|
65
|
+
(0, class_transformer_1.Transform)(asString),
|
|
66
|
+
(0, class_validator_1.IsString)(),
|
|
67
|
+
(0, class_validator_1.Length)(1, 32),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], CreatePaymentChargeRequestValidator.prototype, "identificationNumber", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, class_validator_1.IsOptional)(),
|
|
72
|
+
(0, class_validator_1.IsString)(),
|
|
73
|
+
(0, class_validator_1.Length)(1, 512),
|
|
74
|
+
__metadata("design:type", String)
|
|
75
|
+
], CreatePaymentChargeRequestValidator.prototype, "deviceId", void 0);
|