evo360-types 1.3.639 → 1.3.647
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/apps/evo-finops/zod-schemas.d.ts +1153 -0
- package/dist/apps/evo-finops/zod-schemas.js +85 -2
- package/dist/apps/evo-finops/zod-schemas.ts +91 -0
- package/dist/types/evo-finops/common/billing.d.ts +82 -2
- package/dist/types/evo-finops/common/billing.ts +97 -2
- package/dist/types/evo-finops/common/contract.d.ts +8 -0
- package/dist/types/evo-finops/common/contract.ts +11 -0
- package/dist/types/evo-finops/common/payment-method.d.ts +79 -0
- package/dist/types/evo-finops/common/payment-method.js +10 -0
- package/dist/types/evo-finops/common/payment-method.ts +108 -0
- package/dist/types/evo-finops/fb_collections.d.ts +2 -0
- package/dist/types/evo-finops/fb_collections.js +3 -1
- package/dist/types/evo-finops/fb_collections.ts +2 -0
- package/dist/types/evo-finops/index.d.ts +1 -0
- package/dist/types/evo-finops/index.js +1 -0
- package/dist/types/evo-finops/index.ts +1 -0
- package/dist/types/evo-finops/providers/asaas/asaas_provider.d.ts +23 -0
- package/dist/types/evo-finops/providers/asaas/asaas_provider.ts +25 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.zNexFinopsContractAllowancesWriteSchema = exports.zNexFinopsUsageAlertDefaultsSchema = exports.zNexFinopsAlertThresholdSchema = exports.zNexFinopsContractAllowancesSchema = exports.zNexFinopsContractAllowanceSchema = exports.zNexVendasJourneyPaymentSchema = exports.zNexVendasJourneyPaymentSupersededSchema = exports.zNexVendasJourneyPaymentWebhookEventSchema = exports.zNexVendasJourneyBoletoSchema = exports.zNexVendasJourneyPaymentChooseSchema = exports.zNexVendasJourneyPaymentStateSchema = exports.zNexVendasJourneyPaymentKindSchema = exports.zNexVendasJourneyPaymentMethodSchema = exports.zNexFinopsContractAsaasInfoSchema = exports.zNexFinopsAsaasSubscriptionStatusSchema = exports.zNexFinopsPaymentMethodSchema = exports.zNexFinopsProposalSchema = exports.zNexFinopsProposalWriteSchema = exports.zNexFinopsProposalPrefillSchema = exports.zNexFinopsProposalLoyaltyPeriodSchema = exports.zNexFinopsProposalPaymentMethodSchema = exports.zNexFinopsProposalStatusSchema = exports.zServiceInvoiceSchema = exports.zPaymentLinkSchema = exports.zPaymentLinkDocumentStateSchema = exports.zAsaasPaymentLinkSubscriptionCycleSchema = exports.zAsaasPaymentLinkChargeTypeSchema = exports.zAsaasPaymentLinkBillingTypeSchema = exports.zProviderPayloadSnapshotSchema = exports.zProviderTraceSchema = exports.zProviderInvoiceErrorSchema = exports.zProviderInvoiceIdentifiersSchema = void 0;
|
|
3
|
+
exports.zServiceTaxInfoSchema = exports.zServiceLineItemSchema = exports.zServiceInvoiceStateSchema = exports.zProviderServiceInvoiceStatusSchema = exports.zExternalLinkSchema = exports.zExternalObjectTypeSchema = exports.zInvoiceSourceRefSchema = exports.zInvoiceSourceTypeSchema = exports.zInvoiceTakerRefSchema = exports.zInvoiceTakerSnapshotSchema = exports.zInvoiceTakerSnapshotAddressSchema = exports.zTakerDocumentSchema = exports.zTakerTaxProfileSchema = exports.zTakerProviderRefsSchema = exports.zTakerAddressSchema = exports.zInvoiceTakerTypeSchema = exports.zServiceSchema = exports.zCustomerServiceTaxInfoSchema = exports.zIssuerTaxProfileSchema = exports.zIssuerNfseConfigSchema = exports.zIssuerMunicipalCredentialsRefSchema = exports.zIssuerTaxRegimeSchema = exports.zIssuerCompanyIdentitySchema = exports.zIssuerCompanyAddressSchema = exports.zTaxProfileSyncStateSchema = exports.zAsaasProviderSchema = exports.zAsaasProviderAsaasBlockSchema = exports.zAsaasProviderCapabilitiesSchema = exports.zAsaasPaymentsCapabilitiesSchema = exports.zAsaasEnvFlagSchema = exports.zAsaasNfseCapabilitiesSchema = exports.zAsaasEnvAuthConfigSchema = exports.zAsaasSubaccountInputSchema = exports.zAsaasAccountScopeSchema = exports.zAsaasWebhookConfigSchema = exports.zRetryPolicySchema = exports.zAsaasWebhookEventSchema = exports.zAsaasAccountScopeModeSchema = exports.zProviderRemoteRefsSchema = exports.zProviderFiscalInfoPayloadSchema = exports.zProviderCredentialsInputSchema = exports.zProviderCredentialsSecretRefsSchema = exports.zProviderMunicipalOptionsSnapshotSchema = exports.zProviderOptionItemSchema = exports.zProviderMunicipalAuthTypeSchema = exports.zFinopsProviderBaseSchema = exports.zProviderStatusSchema = exports.zFinopsActionSchema = exports.zFinopsProviderTypeSchema = exports.zProviderEnvSchema = void 0;
|
|
4
|
+
exports.zNexFinopsPaymentMethodsDiscoverSchema = exports.zNexFinopsBillingCardChargeSchema = exports.zNexFinopsContractPaymentMethodsWriteSchema = exports.zNexFinopsPaymentMethodPatchSchema = exports.zNexFinopsPaymentMethodStatusSchema = exports.zNexFinopsPaymentMethodKindSchema = exports.zNexFinopsContractAllowancesWriteSchema = exports.zNexFinopsUsageAlertDefaultsSchema = exports.zNexFinopsAlertThresholdSchema = exports.zNexFinopsContractAllowancesSchema = exports.zNexFinopsContractAllowanceSchema = exports.zNexVendasJourneyPaymentSchema = exports.zNexVendasJourneyPaymentSupersededSchema = exports.zNexVendasJourneyPaymentWebhookEventSchema = exports.zNexVendasJourneyBoletoSchema = exports.zNexVendasJourneyPaymentChooseSchema = exports.zNexVendasJourneyPaymentStateSchema = exports.zNexVendasJourneyPaymentKindSchema = exports.zNexVendasJourneyPaymentMethodSchema = exports.zNexFinopsContractAsaasInfoSchema = exports.zNexFinopsAsaasSubscriptionStatusSchema = exports.zNexFinopsPaymentMethodSchema = exports.zNexFinopsProposalSchema = exports.zNexFinopsProposalWriteSchema = exports.zNexFinopsProposalPrefillSchema = exports.zNexFinopsProposalLoyaltyPeriodSchema = exports.zNexFinopsProposalPaymentMethodSchema = exports.zNexFinopsProposalStatusSchema = exports.zServiceInvoiceSchema = exports.zPaymentLinkSchema = exports.zPaymentLinkDocumentStateSchema = exports.zAsaasPaymentLinkSubscriptionCycleSchema = exports.zAsaasPaymentLinkChargeTypeSchema = exports.zAsaasPaymentLinkBillingTypeSchema = exports.zProviderPayloadSnapshotSchema = exports.zProviderTraceSchema = exports.zProviderInvoiceErrorSchema = exports.zProviderInvoiceIdentifiersSchema = exports.zProviderInvoiceLinksSchema = void 0;
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const zod_schemas_1 = require("../shared/zod-schemas");
|
|
7
7
|
// ---- Provider enums and base ----
|
|
@@ -225,6 +225,13 @@ exports.zAsaasEnvAuthConfigSchema = zod_1.z
|
|
|
225
225
|
rate_limit_max_per_minute: zod_1.z.number().optional(),
|
|
226
226
|
})
|
|
227
227
|
.optional(),
|
|
228
|
+
/** feat-253 — IP enviado na cobrança com token quando a credencial não tem o do pagador. */
|
|
229
|
+
card_token: zod_1.z
|
|
230
|
+
.object({
|
|
231
|
+
remote_ip: zod_1.z.string().max(64).optional().nullable(),
|
|
232
|
+
})
|
|
233
|
+
.strip()
|
|
234
|
+
.optional(),
|
|
228
235
|
})
|
|
229
236
|
.passthrough();
|
|
230
237
|
exports.zAsaasNfseCapabilitiesSchema = zod_1.z.object({
|
|
@@ -233,8 +240,22 @@ exports.zAsaasNfseCapabilitiesSchema = zod_1.z.object({
|
|
|
233
240
|
allow_avulsa: zod_1.z.boolean(),
|
|
234
241
|
allow_linked_to_payment: zod_1.z.boolean(),
|
|
235
242
|
});
|
|
243
|
+
exports.zAsaasEnvFlagSchema = zod_1.z
|
|
244
|
+
.object({
|
|
245
|
+
sandbox: zod_1.z.boolean().optional(),
|
|
246
|
+
production: zod_1.z.boolean().optional(),
|
|
247
|
+
})
|
|
248
|
+
.strip();
|
|
236
249
|
exports.zAsaasPaymentsCapabilitiesSchema = zod_1.z.object({
|
|
237
250
|
enabled: zod_1.z.boolean(),
|
|
251
|
+
/** feat-253 — kill-switch do caminho A. @deprecated (caminho A saiu do modelo). */
|
|
252
|
+
card_subscription_adjust: exports.zAsaasEnvFlagSchema.optional(),
|
|
253
|
+
/** feat-253 — flag do caminho B (captura + cobrança com token). */
|
|
254
|
+
card_token: exports.zAsaasEnvFlagSchema.optional(),
|
|
255
|
+
/** feat-253 — fatura hospedada (contingência C + entrada da captura). */
|
|
256
|
+
hosted_invoice: exports.zAsaasEnvFlagSchema.optional(),
|
|
257
|
+
/** feat-253 — job de cobrança automática no vencimento (fatia 8). */
|
|
258
|
+
card_token_auto: exports.zAsaasEnvFlagSchema.optional(),
|
|
238
259
|
});
|
|
239
260
|
exports.zAsaasProviderCapabilitiesSchema = zod_1.z.object({
|
|
240
261
|
nfse: exports.zAsaasNfseCapabilitiesSchema,
|
|
@@ -913,3 +934,65 @@ exports.zNexFinopsContractAllowancesWriteSchema = zod_1.z
|
|
|
913
934
|
alert_thresholds: zod_1.z.array(exports.zNexFinopsAlertThresholdSchema).optional().nullable(),
|
|
914
935
|
})
|
|
915
936
|
.strip();
|
|
937
|
+
// ---- Nexus FinOps — métodos de pagamento do cliente (feat-253) ----
|
|
938
|
+
//
|
|
939
|
+
// PCI: todos `.strip()`. Nenhum schema aceita número de cartão, CCV, dados do
|
|
940
|
+
// portador ou token — chave desconhecida é descartada antes de chegar ao use case.
|
|
941
|
+
exports.zNexFinopsPaymentMethodKindSchema = zod_1.z.enum([
|
|
942
|
+
"asaas_subscription",
|
|
943
|
+
"asaas_card_token",
|
|
944
|
+
]);
|
|
945
|
+
exports.zNexFinopsPaymentMethodStatusSchema = zod_1.z.enum([
|
|
946
|
+
"active",
|
|
947
|
+
"failing",
|
|
948
|
+
"inactive",
|
|
949
|
+
"revoked",
|
|
950
|
+
]);
|
|
951
|
+
/** `PATCH /payment-methods/:id` — o operador só renomeia ou liga/desliga. */
|
|
952
|
+
exports.zNexFinopsPaymentMethodPatchSchema = zod_1.z
|
|
953
|
+
.object({
|
|
954
|
+
label: zod_1.z.string().max(120).optional().nullable(),
|
|
955
|
+
status: zod_1.z.enum(["active", "inactive"]).optional(),
|
|
956
|
+
})
|
|
957
|
+
.strip();
|
|
958
|
+
/** `PUT /contracts/:id/payment-methods` — rota dedicada (o PUT genérico ignora estes campos). */
|
|
959
|
+
exports.zNexFinopsContractPaymentMethodsWriteSchema = zod_1.z
|
|
960
|
+
.object({
|
|
961
|
+
payment_method_ids: zod_1.z.array(zod_1.z.string().min(1).max(128)).max(10),
|
|
962
|
+
default_payment_method_id: zod_1.z.string().min(1).max(128).optional().nullable(),
|
|
963
|
+
})
|
|
964
|
+
.strip();
|
|
965
|
+
/**
|
|
966
|
+
* `POST /billings/:id/card-charge` (feat-253 F2b).
|
|
967
|
+
* - `preview`: prévia da cobrança no cartão salvo (não escreve).
|
|
968
|
+
* - `charge_now`: cobra no cartão salvo (`confirm` + `expected_value`).
|
|
969
|
+
* - `send_invoice`: fatura hospedada do Asaas (`billing_type` CREDIT_CARD captura o cartão; UNDEFINED = cliente escolhe).
|
|
970
|
+
* - `cancel_invoice`: cancela a fatura aberta (`asaas_payment_id`).
|
|
971
|
+
* `.strip()`: dados de cartão/token nunca entram por aqui.
|
|
972
|
+
*/
|
|
973
|
+
exports.zNexFinopsBillingCardChargeSchema = zod_1.z
|
|
974
|
+
.object({
|
|
975
|
+
action: zod_1.z.enum(["preview", "charge_now", "send_invoice", "cancel_invoice"]),
|
|
976
|
+
expected_value: zod_1.z.number().optional(),
|
|
977
|
+
asaas_payment_id: zod_1.z.string().min(1).max(128).optional(),
|
|
978
|
+
confirm: zod_1.z.boolean().optional(),
|
|
979
|
+
capture_card: zod_1.z.boolean().optional(),
|
|
980
|
+
billing_type: zod_1.z.enum(["CREDIT_CARD", "UNDEFINED"]).optional(),
|
|
981
|
+
provider_id: zod_1.z.string().min(1).max(128).optional(),
|
|
982
|
+
env: zod_1.z.enum(["sandbox", "production"]).optional(),
|
|
983
|
+
taker_id: zod_1.z.string().min(1).max(128).optional(),
|
|
984
|
+
allow_early: zod_1.z.boolean().optional(),
|
|
985
|
+
})
|
|
986
|
+
.strip();
|
|
987
|
+
/** `POST /payment-methods/discover` — sem `confirm` é dry-run. */
|
|
988
|
+
exports.zNexFinopsPaymentMethodsDiscoverSchema = zod_1.z
|
|
989
|
+
.object({
|
|
990
|
+
customer_id: zod_1.z.string().min(1).max(128).optional(),
|
|
991
|
+
confirm: zod_1.z
|
|
992
|
+
.object({
|
|
993
|
+
payment_method_ids: zod_1.z.array(zod_1.z.string().min(1).max(128)).max(500),
|
|
994
|
+
})
|
|
995
|
+
.strip()
|
|
996
|
+
.optional(),
|
|
997
|
+
})
|
|
998
|
+
.strip();
|
|
@@ -237,6 +237,13 @@ export const zAsaasEnvAuthConfigSchema = z
|
|
|
237
237
|
rate_limit_max_per_minute: z.number().optional(),
|
|
238
238
|
})
|
|
239
239
|
.optional(),
|
|
240
|
+
/** feat-253 — IP enviado na cobrança com token quando a credencial não tem o do pagador. */
|
|
241
|
+
card_token: z
|
|
242
|
+
.object({
|
|
243
|
+
remote_ip: z.string().max(64).optional().nullable(),
|
|
244
|
+
})
|
|
245
|
+
.strip()
|
|
246
|
+
.optional(),
|
|
240
247
|
})
|
|
241
248
|
.passthrough();
|
|
242
249
|
|
|
@@ -247,8 +254,23 @@ export const zAsaasNfseCapabilitiesSchema = z.object({
|
|
|
247
254
|
allow_linked_to_payment: z.boolean(),
|
|
248
255
|
});
|
|
249
256
|
|
|
257
|
+
export const zAsaasEnvFlagSchema = z
|
|
258
|
+
.object({
|
|
259
|
+
sandbox: z.boolean().optional(),
|
|
260
|
+
production: z.boolean().optional(),
|
|
261
|
+
})
|
|
262
|
+
.strip();
|
|
263
|
+
|
|
250
264
|
export const zAsaasPaymentsCapabilitiesSchema = z.object({
|
|
251
265
|
enabled: z.boolean(),
|
|
266
|
+
/** feat-253 — kill-switch do caminho A. @deprecated (caminho A saiu do modelo). */
|
|
267
|
+
card_subscription_adjust: zAsaasEnvFlagSchema.optional(),
|
|
268
|
+
/** feat-253 — flag do caminho B (captura + cobrança com token). */
|
|
269
|
+
card_token: zAsaasEnvFlagSchema.optional(),
|
|
270
|
+
/** feat-253 — fatura hospedada (contingência C + entrada da captura). */
|
|
271
|
+
hosted_invoice: zAsaasEnvFlagSchema.optional(),
|
|
272
|
+
/** feat-253 — job de cobrança automática no vencimento (fatia 8). */
|
|
273
|
+
card_token_auto: zAsaasEnvFlagSchema.optional(),
|
|
252
274
|
});
|
|
253
275
|
|
|
254
276
|
export const zAsaasProviderCapabilitiesSchema = z.object({
|
|
@@ -1001,3 +1023,72 @@ export const zNexFinopsContractAllowancesWriteSchema = z
|
|
|
1001
1023
|
alert_thresholds: z.array(zNexFinopsAlertThresholdSchema).optional().nullable(),
|
|
1002
1024
|
})
|
|
1003
1025
|
.strip();
|
|
1026
|
+
|
|
1027
|
+
// ---- Nexus FinOps — métodos de pagamento do cliente (feat-253) ----
|
|
1028
|
+
//
|
|
1029
|
+
// PCI: todos `.strip()`. Nenhum schema aceita número de cartão, CCV, dados do
|
|
1030
|
+
// portador ou token — chave desconhecida é descartada antes de chegar ao use case.
|
|
1031
|
+
|
|
1032
|
+
export const zNexFinopsPaymentMethodKindSchema = z.enum([
|
|
1033
|
+
"asaas_subscription",
|
|
1034
|
+
"asaas_card_token",
|
|
1035
|
+
]);
|
|
1036
|
+
|
|
1037
|
+
export const zNexFinopsPaymentMethodStatusSchema = z.enum([
|
|
1038
|
+
"active",
|
|
1039
|
+
"failing",
|
|
1040
|
+
"inactive",
|
|
1041
|
+
"revoked",
|
|
1042
|
+
]);
|
|
1043
|
+
|
|
1044
|
+
/** `PATCH /payment-methods/:id` — o operador só renomeia ou liga/desliga. */
|
|
1045
|
+
export const zNexFinopsPaymentMethodPatchSchema = z
|
|
1046
|
+
.object({
|
|
1047
|
+
label: z.string().max(120).optional().nullable(),
|
|
1048
|
+
status: z.enum(["active", "inactive"]).optional(),
|
|
1049
|
+
})
|
|
1050
|
+
.strip();
|
|
1051
|
+
|
|
1052
|
+
/** `PUT /contracts/:id/payment-methods` — rota dedicada (o PUT genérico ignora estes campos). */
|
|
1053
|
+
export const zNexFinopsContractPaymentMethodsWriteSchema = z
|
|
1054
|
+
.object({
|
|
1055
|
+
payment_method_ids: z.array(z.string().min(1).max(128)).max(10),
|
|
1056
|
+
default_payment_method_id: z.string().min(1).max(128).optional().nullable(),
|
|
1057
|
+
})
|
|
1058
|
+
.strip();
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* `POST /billings/:id/card-charge` (feat-253 F2b).
|
|
1062
|
+
* - `preview`: prévia da cobrança no cartão salvo (não escreve).
|
|
1063
|
+
* - `charge_now`: cobra no cartão salvo (`confirm` + `expected_value`).
|
|
1064
|
+
* - `send_invoice`: fatura hospedada do Asaas (`billing_type` CREDIT_CARD captura o cartão; UNDEFINED = cliente escolhe).
|
|
1065
|
+
* - `cancel_invoice`: cancela a fatura aberta (`asaas_payment_id`).
|
|
1066
|
+
* `.strip()`: dados de cartão/token nunca entram por aqui.
|
|
1067
|
+
*/
|
|
1068
|
+
export const zNexFinopsBillingCardChargeSchema = z
|
|
1069
|
+
.object({
|
|
1070
|
+
action: z.enum(["preview", "charge_now", "send_invoice", "cancel_invoice"]),
|
|
1071
|
+
expected_value: z.number().optional(),
|
|
1072
|
+
asaas_payment_id: z.string().min(1).max(128).optional(),
|
|
1073
|
+
confirm: z.boolean().optional(),
|
|
1074
|
+
capture_card: z.boolean().optional(),
|
|
1075
|
+
billing_type: z.enum(["CREDIT_CARD", "UNDEFINED"]).optional(),
|
|
1076
|
+
provider_id: z.string().min(1).max(128).optional(),
|
|
1077
|
+
env: z.enum(["sandbox", "production"]).optional(),
|
|
1078
|
+
taker_id: z.string().min(1).max(128).optional(),
|
|
1079
|
+
allow_early: z.boolean().optional(),
|
|
1080
|
+
})
|
|
1081
|
+
.strip();
|
|
1082
|
+
|
|
1083
|
+
/** `POST /payment-methods/discover` — sem `confirm` é dry-run. */
|
|
1084
|
+
export const zNexFinopsPaymentMethodsDiscoverSchema = z
|
|
1085
|
+
.object({
|
|
1086
|
+
customer_id: z.string().min(1).max(128).optional(),
|
|
1087
|
+
confirm: z
|
|
1088
|
+
.object({
|
|
1089
|
+
payment_method_ids: z.array(z.string().min(1).max(128)).max(500),
|
|
1090
|
+
})
|
|
1091
|
+
.strip()
|
|
1092
|
+
.optional(),
|
|
1093
|
+
})
|
|
1094
|
+
.strip();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IFireGlobalDoc } from '../../shared';
|
|
2
|
+
import type { NexFinopsPaymentMethodKind } from './payment-method';
|
|
2
3
|
export type NexFinopsBillingStatus = 'draft' | 'issued' | 'paid' | 'overdue' | 'canceled';
|
|
3
4
|
export type NexFinopsBillingAttachmentCategory = 'boleto' | 'invoice' | 'other';
|
|
4
5
|
export interface INexFinopsBillingServiceItem {
|
|
@@ -28,7 +29,7 @@ export interface INexFinopsBillingBoletoTerms {
|
|
|
28
29
|
mora_taxa: number;
|
|
29
30
|
}
|
|
30
31
|
export interface INexFinopsBillingPaymentOption {
|
|
31
|
-
type: 'pix' | 'boleto' | 'payment_link';
|
|
32
|
+
type: 'pix' | 'boleto' | 'payment_link' | 'credit_card';
|
|
32
33
|
provider_id?: string | null;
|
|
33
34
|
external_id?: string | null;
|
|
34
35
|
url?: string | null;
|
|
@@ -63,13 +64,81 @@ export interface INexFinopsBillingAttachment {
|
|
|
63
64
|
category?: NexFinopsBillingAttachmentCategory;
|
|
64
65
|
}
|
|
65
66
|
export interface INexFinopsBillingPaidVia {
|
|
66
|
-
kind: 'payment_link' | 'manual' | 'pix' | 'boleto';
|
|
67
|
+
kind: 'payment_link' | 'manual' | 'pix' | 'boleto' | 'credit_card';
|
|
67
68
|
payment_link_id?: string | null;
|
|
68
69
|
asaas_payment_id?: string | null;
|
|
69
70
|
event?: string | null;
|
|
70
71
|
received_at?: string | null;
|
|
71
72
|
raw_status?: string | null;
|
|
73
|
+
/** feat-253: método de pagamento (cartão) que liquidou a cobrança. */
|
|
74
|
+
payment_method_id?: string | null;
|
|
75
|
+
/** feat-253: degrau do roteamento do webhook de cartão que casou o pagamento. Interno (não vai ao portal). */
|
|
76
|
+
matched_by?: 'card_payment_id' | 'external_reference' | 'subscription_competency' | null;
|
|
72
77
|
}
|
|
78
|
+
/** Resumo do método herdado — só bandeira e últimos 4 (PCI). */
|
|
79
|
+
export interface INexFinopsBillingPaymentMethodSnapshot {
|
|
80
|
+
kind: NexFinopsPaymentMethodKind;
|
|
81
|
+
brand: string | null;
|
|
82
|
+
last4: string | null;
|
|
83
|
+
subscription_id?: string | null;
|
|
84
|
+
}
|
|
85
|
+
export type NexFinopsBillingCardChargeMode = 'subscription_adjust'
|
|
86
|
+
/** Contingência A′. */
|
|
87
|
+
| 'subscription_value_update' | 'token_charge'
|
|
88
|
+
/** feat-253 F2b: fatura avulsa hospedada no Asaas (cartão com captura, ou cliente escolhe). */
|
|
89
|
+
| 'hosted_invoice';
|
|
90
|
+
export type NexFinopsBillingCardChargeStatus = 'scheduled'
|
|
91
|
+
/** Fatura enviada aguardando pagamento, ou cobrança com token em análise. */
|
|
92
|
+
| 'pending' | 'stale' | 'confirmed' | 'refused' | 'refunded' | 'chargeback' | 'canceled' | 'reverted';
|
|
93
|
+
export interface INexFinopsBillingCardChargeHistoryEntry {
|
|
94
|
+
at: string;
|
|
95
|
+
by: string | null;
|
|
96
|
+
action: 'adjust' | 'readjust' | 'revert' | 'charge' | 'event' | 'send_invoice' | 'cancel_invoice' | 'capture';
|
|
97
|
+
value?: number | null;
|
|
98
|
+
event?: string | null;
|
|
99
|
+
}
|
|
100
|
+
export interface INexFinopsBillingCardCharge {
|
|
101
|
+
mode: NexFinopsBillingCardChargeMode;
|
|
102
|
+
payment_method_id: string;
|
|
103
|
+
asaas_payment_id: string;
|
|
104
|
+
subscription_id?: string | null;
|
|
105
|
+
/** `dueDate` do `pay_` no Asaas (YYYY-MM-DD). */
|
|
106
|
+
due_date: string;
|
|
107
|
+
/** Caminho A: valor antes do ajuste. */
|
|
108
|
+
value_before?: number | null;
|
|
109
|
+
/** = `billing.total` no momento do ajuste. */
|
|
110
|
+
value_after: number;
|
|
111
|
+
status: NexFinopsBillingCardChargeStatus;
|
|
112
|
+
raw_status?: string | null;
|
|
113
|
+
/** Mantido por compatibilidade: na F2b é o momento/autor da criação do `pay_`. */
|
|
114
|
+
adjusted_at: string;
|
|
115
|
+
adjusted_by: {
|
|
116
|
+
kind: 'user' | 'system';
|
|
117
|
+
id: string | null;
|
|
118
|
+
};
|
|
119
|
+
last_event?: string | null;
|
|
120
|
+
last_event_at?: string | null;
|
|
121
|
+
failure?: {
|
|
122
|
+
event: string;
|
|
123
|
+
description?: string | null;
|
|
124
|
+
} | null;
|
|
125
|
+
/** Capado em 30 entradas. */
|
|
126
|
+
history: INexFinopsBillingCardChargeHistoryEntry[];
|
|
127
|
+
/** Fatura hospedada que, paga no cartão, captura o token (`billing_type: 'CREDIT_CARD'`). */
|
|
128
|
+
capture_card?: boolean | null;
|
|
129
|
+
/** `invoiceUrl` da fatura hospedada (pagável pelo cliente). */
|
|
130
|
+
invoice_url?: string | null;
|
|
131
|
+
/** `billingType` pedido ao Asaas. */
|
|
132
|
+
billing_type?: 'CREDIT_CARD' | 'UNDEFINED' | null;
|
|
133
|
+
/** Resultado da captura do token após o pagamento. */
|
|
134
|
+
capture_status?: NexFinopsBillingCardCaptureStatus | null;
|
|
135
|
+
/** Método `atok_` capturado por esta cobrança (a tela oferece usar como padrão). Interno (fora do portal). */
|
|
136
|
+
captured_payment_method_id?: string | null;
|
|
137
|
+
/** Provider/ambiente onde o `pay_` foi criado. */
|
|
138
|
+
provider_id?: string | null;
|
|
139
|
+
env?: 'sandbox' | 'production' | null;
|
|
140
|
+
}
|
|
141
|
+
export type NexFinopsBillingCardCaptureStatus = 'captured' | 'no_token' | 'skipped';
|
|
73
142
|
export interface INexFinopsBilling extends IFireGlobalDoc {
|
|
74
143
|
customer_id: string;
|
|
75
144
|
customer_ref?: string | null;
|
|
@@ -95,6 +164,17 @@ export interface INexFinopsBilling extends IFireGlobalDoc {
|
|
|
95
164
|
contract_snapshot?: Record<string, unknown> | null;
|
|
96
165
|
customer_snapshot?: Record<string, unknown> | null;
|
|
97
166
|
notes?: string | null;
|
|
167
|
+
/** Método herdado do `default_payment_method_id` do contrato na geração (ou escolhido depois). */
|
|
168
|
+
payment_method_id?: string | null;
|
|
169
|
+
payment_method_snapshot?: INexFinopsBillingPaymentMethodSnapshot | null;
|
|
170
|
+
/** Todos os `pay_` do Asaas já associados (A e B) — chave do roteamento do webhook. Interno. */
|
|
171
|
+
card_payment_ids?: string[];
|
|
172
|
+
card_charge?: INexFinopsBillingCardCharge | null;
|
|
173
|
+
/** Trava curta da cobrança no cartão (`charge_now`). Interno (fora das projeções). */
|
|
174
|
+
card_charge_lock?: {
|
|
175
|
+
by: string | null;
|
|
176
|
+
until: string;
|
|
177
|
+
} | null;
|
|
98
178
|
}
|
|
99
179
|
/**
|
|
100
180
|
* Transições permitidas de status de cobrança.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IFireGlobalDoc } from '../../shared';
|
|
2
|
+
import type { NexFinopsPaymentMethodKind } from './payment-method';
|
|
2
3
|
|
|
3
4
|
// ── Status ──
|
|
4
5
|
|
|
@@ -42,7 +43,7 @@ export interface INexFinopsBillingBoletoTerms {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export interface INexFinopsBillingPaymentOption {
|
|
45
|
-
type: 'pix' | 'boleto' | 'payment_link';
|
|
46
|
+
type: 'pix' | 'boleto' | 'payment_link' | 'credit_card';
|
|
46
47
|
provider_id?: string | null;
|
|
47
48
|
external_id?: string | null;
|
|
48
49
|
url?: string | null;
|
|
@@ -80,14 +81,97 @@ export interface INexFinopsBillingAttachment {
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
export interface INexFinopsBillingPaidVia {
|
|
83
|
-
kind: 'payment_link' | 'manual' | 'pix' | 'boleto';
|
|
84
|
+
kind: 'payment_link' | 'manual' | 'pix' | 'boleto' | 'credit_card';
|
|
84
85
|
payment_link_id?: string | null;
|
|
85
86
|
asaas_payment_id?: string | null;
|
|
86
87
|
event?: string | null;
|
|
87
88
|
received_at?: string | null;
|
|
88
89
|
raw_status?: string | null;
|
|
90
|
+
/** feat-253: método de pagamento (cartão) que liquidou a cobrança. */
|
|
91
|
+
payment_method_id?: string | null;
|
|
92
|
+
/** feat-253: degrau do roteamento do webhook de cartão que casou o pagamento. Interno (não vai ao portal). */
|
|
93
|
+
matched_by?: 'card_payment_id' | 'external_reference' | 'subscription_competency' | null;
|
|
89
94
|
}
|
|
90
95
|
|
|
96
|
+
// ── Cobrança no cartão (feat-253) ──
|
|
97
|
+
|
|
98
|
+
/** Resumo do método herdado — só bandeira e últimos 4 (PCI). */
|
|
99
|
+
export interface INexFinopsBillingPaymentMethodSnapshot {
|
|
100
|
+
kind: NexFinopsPaymentMethodKind;
|
|
101
|
+
brand: string | null;
|
|
102
|
+
last4: string | null;
|
|
103
|
+
subscription_id?: string | null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type NexFinopsBillingCardChargeMode =
|
|
107
|
+
| 'subscription_adjust'
|
|
108
|
+
/** Contingência A′. */
|
|
109
|
+
| 'subscription_value_update'
|
|
110
|
+
| 'token_charge'
|
|
111
|
+
/** feat-253 F2b: fatura avulsa hospedada no Asaas (cartão com captura, ou cliente escolhe). */
|
|
112
|
+
| 'hosted_invoice';
|
|
113
|
+
|
|
114
|
+
export type NexFinopsBillingCardChargeStatus =
|
|
115
|
+
| 'scheduled'
|
|
116
|
+
/** Fatura enviada aguardando pagamento, ou cobrança com token em análise. */
|
|
117
|
+
| 'pending'
|
|
118
|
+
| 'stale'
|
|
119
|
+
| 'confirmed'
|
|
120
|
+
| 'refused'
|
|
121
|
+
| 'refunded'
|
|
122
|
+
| 'chargeback'
|
|
123
|
+
| 'canceled'
|
|
124
|
+
| 'reverted';
|
|
125
|
+
|
|
126
|
+
export interface INexFinopsBillingCardChargeHistoryEntry {
|
|
127
|
+
at: string;
|
|
128
|
+
by: string | null;
|
|
129
|
+
action: 'adjust' | 'readjust' | 'revert' | 'charge' | 'event' | 'send_invoice' | 'cancel_invoice' | 'capture';
|
|
130
|
+
value?: number | null;
|
|
131
|
+
event?: string | null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface INexFinopsBillingCardCharge {
|
|
135
|
+
mode: NexFinopsBillingCardChargeMode;
|
|
136
|
+
payment_method_id: string;
|
|
137
|
+
asaas_payment_id: string;
|
|
138
|
+
subscription_id?: string | null;
|
|
139
|
+
/** `dueDate` do `pay_` no Asaas (YYYY-MM-DD). */
|
|
140
|
+
due_date: string;
|
|
141
|
+
/** Caminho A: valor antes do ajuste. */
|
|
142
|
+
value_before?: number | null;
|
|
143
|
+
/** = `billing.total` no momento do ajuste. */
|
|
144
|
+
value_after: number;
|
|
145
|
+
status: NexFinopsBillingCardChargeStatus;
|
|
146
|
+
raw_status?: string | null;
|
|
147
|
+
/** Mantido por compatibilidade: na F2b é o momento/autor da criação do `pay_`. */
|
|
148
|
+
adjusted_at: string;
|
|
149
|
+
adjusted_by: { kind: 'user' | 'system'; id: string | null };
|
|
150
|
+
last_event?: string | null;
|
|
151
|
+
last_event_at?: string | null;
|
|
152
|
+
failure?: { event: string; description?: string | null } | null;
|
|
153
|
+
/** Capado em 30 entradas. */
|
|
154
|
+
history: INexFinopsBillingCardChargeHistoryEntry[];
|
|
155
|
+
|
|
156
|
+
// ── F2b (fatura hospedada / token) ──
|
|
157
|
+
|
|
158
|
+
/** Fatura hospedada que, paga no cartão, captura o token (`billing_type: 'CREDIT_CARD'`). */
|
|
159
|
+
capture_card?: boolean | null;
|
|
160
|
+
/** `invoiceUrl` da fatura hospedada (pagável pelo cliente). */
|
|
161
|
+
invoice_url?: string | null;
|
|
162
|
+
/** `billingType` pedido ao Asaas. */
|
|
163
|
+
billing_type?: 'CREDIT_CARD' | 'UNDEFINED' | null;
|
|
164
|
+
/** Resultado da captura do token após o pagamento. */
|
|
165
|
+
capture_status?: NexFinopsBillingCardCaptureStatus | null;
|
|
166
|
+
/** Método `atok_` capturado por esta cobrança (a tela oferece usar como padrão). Interno (fora do portal). */
|
|
167
|
+
captured_payment_method_id?: string | null;
|
|
168
|
+
/** Provider/ambiente onde o `pay_` foi criado. */
|
|
169
|
+
provider_id?: string | null;
|
|
170
|
+
env?: 'sandbox' | 'production' | null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export type NexFinopsBillingCardCaptureStatus = 'captured' | 'no_token' | 'skipped';
|
|
174
|
+
|
|
91
175
|
// ── Main Document ──
|
|
92
176
|
|
|
93
177
|
export interface INexFinopsBilling extends IFireGlobalDoc {
|
|
@@ -144,6 +228,17 @@ export interface INexFinopsBilling extends IFireGlobalDoc {
|
|
|
144
228
|
|
|
145
229
|
// Observações
|
|
146
230
|
notes?: string | null;
|
|
231
|
+
|
|
232
|
+
// ── Cartão (feat-253) ──
|
|
233
|
+
|
|
234
|
+
/** Método herdado do `default_payment_method_id` do contrato na geração (ou escolhido depois). */
|
|
235
|
+
payment_method_id?: string | null;
|
|
236
|
+
payment_method_snapshot?: INexFinopsBillingPaymentMethodSnapshot | null;
|
|
237
|
+
/** Todos os `pay_` do Asaas já associados (A e B) — chave do roteamento do webhook. Interno. */
|
|
238
|
+
card_payment_ids?: string[];
|
|
239
|
+
card_charge?: INexFinopsBillingCardCharge | null;
|
|
240
|
+
/** Trava curta da cobrança no cartão (`charge_now`). Interno (fora das projeções). */
|
|
241
|
+
card_charge_lock?: { by: string | null; until: string } | null;
|
|
147
242
|
}
|
|
148
243
|
|
|
149
244
|
// ── Status transitions ──
|
|
@@ -139,6 +139,14 @@ export interface INexFinopsContract extends IFireGlobalDoc {
|
|
|
139
139
|
/** Método com que o primeiro pagamento foi feito. `accepted_payment_methods` é a oferta; este é o fato. */
|
|
140
140
|
payment_method?: NexFinopsPaymentMethod | null;
|
|
141
141
|
asaas?: INexFinopsContractAsaasInfo | null;
|
|
142
|
+
/**
|
|
143
|
+
* Ids de `payment_methods` do MESMO customer habilitados neste contrato.
|
|
144
|
+
* Escrito só pela rota dedicada `PUT /contracts/:id/payment-methods`; o
|
|
145
|
+
* `PUT /contracts/:id` genérico ignora este campo.
|
|
146
|
+
*/
|
|
147
|
+
payment_method_ids?: string[] | null;
|
|
148
|
+
/** Precisa estar em `payment_method_ids`. É o que a cobrança herda no `billingGenerate`. */
|
|
149
|
+
default_payment_method_id?: string | null;
|
|
142
150
|
/**
|
|
143
151
|
* Franquia incluída no ciclo, por métrica. A CHAVE é o id da métrica (ver
|
|
144
152
|
* `NexFinopsMetricCatalog`) e é deliberadamente `string`: métrica nova é um
|
|
@@ -172,6 +172,17 @@ export interface INexFinopsContract extends IFireGlobalDoc {
|
|
|
172
172
|
payment_method?: NexFinopsPaymentMethod | null;
|
|
173
173
|
asaas?: INexFinopsContractAsaasInfo | null;
|
|
174
174
|
|
|
175
|
+
// ── Métodos de pagamento habilitados (feat-253) ──
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Ids de `payment_methods` do MESMO customer habilitados neste contrato.
|
|
179
|
+
* Escrito só pela rota dedicada `PUT /contracts/:id/payment-methods`; o
|
|
180
|
+
* `PUT /contracts/:id` genérico ignora este campo.
|
|
181
|
+
*/
|
|
182
|
+
payment_method_ids?: string[] | null;
|
|
183
|
+
/** Precisa estar em `payment_method_ids`. É o que a cobrança herda no `billingGenerate`. */
|
|
184
|
+
default_payment_method_id?: string | null;
|
|
185
|
+
|
|
175
186
|
// ── Franquias e alertas de consumo (feat-150 F0) ──
|
|
176
187
|
|
|
177
188
|
/**
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { IFireGlobalDoc } from '../../shared';
|
|
2
|
+
import type { NexFinopsAsaasSubscriptionStatus } from './contract';
|
|
3
|
+
/**
|
|
4
|
+
* - `asaas_subscription` (caminho A): cartão capturado na página do Asaas, dentro
|
|
5
|
+
* de uma assinatura. Id do doc: `asub_<subscription_id>`.
|
|
6
|
+
* - `asaas_card_token` (caminho B): token de cartão do Asaas. Id do doc: `atok_<shortid>`.
|
|
7
|
+
*/
|
|
8
|
+
export type NexFinopsPaymentMethodKind = 'asaas_subscription' | 'asaas_card_token';
|
|
9
|
+
/**
|
|
10
|
+
* - `active`: assinatura `ACTIVE` sem `deleted`, ou token válido.
|
|
11
|
+
* - `failing`: última captura recusada/reprovada; volta a `active` no próximo `PAYMENT_CONFIRMED`.
|
|
12
|
+
* - `inactive`: assinatura `INACTIVE`/`EXPIRED`/`deleted`, ou desativado pelo operador.
|
|
13
|
+
* - `revoked`: token invalidado pelo Asaas. Terminal — o cliente cadastra o cartão de novo.
|
|
14
|
+
*/
|
|
15
|
+
export type NexFinopsPaymentMethodStatus = 'active' | 'failing' | 'inactive' | 'revoked';
|
|
16
|
+
export type NexFinopsPaymentMethodSource = 'discovery_contract_asaas' | 'discovery_payment_link' | 'manual_link' | 'asaas_capture';
|
|
17
|
+
export interface INexFinopsPaymentMethodProviderRef {
|
|
18
|
+
provider_id: string;
|
|
19
|
+
provider_type: 'asaas';
|
|
20
|
+
env: 'sandbox' | 'production';
|
|
21
|
+
/** `cus_` dono do cartão/assinatura (Q5) — pode ser ≠ `taker.provider_refs.remote_customer_id`. */
|
|
22
|
+
remote_customer_id: string;
|
|
23
|
+
}
|
|
24
|
+
export interface INexFinopsPaymentMethodSubscriptionInfo {
|
|
25
|
+
subscription_id: string;
|
|
26
|
+
/** Doc id do nosso payment_link (origem). */
|
|
27
|
+
payment_link_id?: string | null;
|
|
28
|
+
/** Checkout de vendas (`contract.asaas.checkout_id`). */
|
|
29
|
+
checkout_id?: string | null;
|
|
30
|
+
subscription_status?: NexFinopsAsaasSubscriptionStatus | null;
|
|
31
|
+
deleted?: boolean | null;
|
|
32
|
+
cycle?: string | null;
|
|
33
|
+
/** Valor BASE da assinatura. */
|
|
34
|
+
value?: number | null;
|
|
35
|
+
/** Data civil `YYYY-MM-DD`. */
|
|
36
|
+
next_due_date?: string | null;
|
|
37
|
+
}
|
|
38
|
+
/** PCI: só bandeira e últimos 4. */
|
|
39
|
+
export interface INexFinopsPaymentMethodCard {
|
|
40
|
+
brand: string | null;
|
|
41
|
+
last4: string | null;
|
|
42
|
+
}
|
|
43
|
+
export interface INexFinopsPaymentMethodSourceInfo {
|
|
44
|
+
kind: NexFinopsPaymentMethodSource;
|
|
45
|
+
contract_id?: string | null;
|
|
46
|
+
payment_link_id?: string | null;
|
|
47
|
+
journey_ref?: string | null;
|
|
48
|
+
/** Pagamento que originou o método (caminho B). */
|
|
49
|
+
asaas_payment_id?: string | null;
|
|
50
|
+
}
|
|
51
|
+
export interface INexFinopsPaymentMethodLastCharge {
|
|
52
|
+
asaas_payment_id: string;
|
|
53
|
+
status: string;
|
|
54
|
+
at: string;
|
|
55
|
+
error?: string | null;
|
|
56
|
+
}
|
|
57
|
+
export interface INexFinopsCustomerPaymentMethod extends IFireGlobalDoc {
|
|
58
|
+
customer_id: string;
|
|
59
|
+
kind: NexFinopsPaymentMethodKind;
|
|
60
|
+
status: NexFinopsPaymentMethodStatus;
|
|
61
|
+
label?: string | null;
|
|
62
|
+
/** PCI: só isto. Nunca número completo, CCV ou token. */
|
|
63
|
+
card: INexFinopsPaymentMethodCard;
|
|
64
|
+
provider: INexFinopsPaymentMethodProviderRef;
|
|
65
|
+
/** Só no kind `asaas_subscription`. */
|
|
66
|
+
asaas_subscription?: INexFinopsPaymentMethodSubscriptionInfo | null;
|
|
67
|
+
/** Kind `asaas_card_token`: existe `private/credential`. Único reflexo do token. */
|
|
68
|
+
has_credential?: boolean | null;
|
|
69
|
+
source: INexFinopsPaymentMethodSourceInfo;
|
|
70
|
+
last_synced_at?: string | null;
|
|
71
|
+
last_used_at?: string | null;
|
|
72
|
+
last_charge?: INexFinopsPaymentMethodLastCharge | null;
|
|
73
|
+
/** feat-253 F2b: `asub_` migrado aponta para o `atok_` que o substituiu. */
|
|
74
|
+
replaced_by_payment_method_id?: string | null;
|
|
75
|
+
}
|
|
76
|
+
/** Prefixos determinísticos dos ids (idempotência da descoberta). */
|
|
77
|
+
export declare const NEX_FINOPS_PAYMENT_METHOD_ID_PREFIX: Record<NexFinopsPaymentMethodKind, string>;
|
|
78
|
+
/** Status em que o método pode ser herdado por uma cobrança. */
|
|
79
|
+
export declare const NEX_FINOPS_PAYMENT_METHOD_USABLE_STATUSES: readonly NexFinopsPaymentMethodStatus[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NEX_FINOPS_PAYMENT_METHOD_USABLE_STATUSES = exports.NEX_FINOPS_PAYMENT_METHOD_ID_PREFIX = void 0;
|
|
4
|
+
/** Prefixos determinísticos dos ids (idempotência da descoberta). */
|
|
5
|
+
exports.NEX_FINOPS_PAYMENT_METHOD_ID_PREFIX = {
|
|
6
|
+
asaas_subscription: 'asub_',
|
|
7
|
+
asaas_card_token: 'atok_',
|
|
8
|
+
};
|
|
9
|
+
/** Status em que o método pode ser herdado por uma cobrança. */
|
|
10
|
+
exports.NEX_FINOPS_PAYMENT_METHOD_USABLE_STATUSES = ['active', 'failing'];
|