@deepintel-ltd/farmpro-contracts 1.5.14 → 1.5.16
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/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/routes/agents.routes.d.ts +3 -3
- package/dist/routes/agents.routes.js +1 -1
- package/dist/routes/auth.routes.d.ts +516 -0
- package/dist/routes/auth.routes.d.ts.map +1 -1
- package/dist/routes/auth.routes.js +26 -2
- package/dist/routes/index.d.ts +6 -0
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +4 -0
- package/dist/routes/payments.routes.d.ts +1851 -0
- package/dist/routes/payments.routes.d.ts.map +1 -0
- package/dist/routes/payments.routes.js +91 -0
- package/dist/routes/subscriptions.routes.d.ts +3151 -0
- package/dist/routes/subscriptions.routes.d.ts.map +1 -0
- package/dist/routes/subscriptions.routes.js +155 -0
- package/dist/schemas/auth.schemas.d.ts +314 -0
- package/dist/schemas/auth.schemas.d.ts.map +1 -1
- package/dist/schemas/auth.schemas.js +27 -0
- package/dist/schemas/payments.schemas.d.ts +822 -0
- package/dist/schemas/payments.schemas.d.ts.map +1 -0
- package/dist/schemas/payments.schemas.js +105 -0
- package/dist/schemas/subscriptions.schemas.d.ts +1344 -0
- package/dist/schemas/subscriptions.schemas.d.ts.map +1 -0
- package/dist/schemas/subscriptions.schemas.js +150 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/payments.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB;;GAEG;AAGH,eAAO,MAAM,mBAAmB,0EAAwE,CAAC;AAGzG,eAAO,MAAM,qBAAqB,2BAAyB,CAAC;AAG5D,eAAO,MAAM,mBAAmB,yEAAuE,CAAC;AAGxG,eAAO,MAAM,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCnC,CAAC;AAGH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAC/E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAC/E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AACzF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAC;AAClG,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { timestampsSchema, createJsonApiResourceSchema, jsonApiSingleResponseSchema, jsonApiCollectionResponseSchema } from './common.schemas';
|
|
3
|
+
/**
|
|
4
|
+
* Payment schemas - JSON:API compliant
|
|
5
|
+
*/
|
|
6
|
+
// Payment status enum
|
|
7
|
+
export const paymentStatusSchema = z.enum(['pending', 'processing', 'completed', 'failed', 'cancelled']);
|
|
8
|
+
// Payment currency enum
|
|
9
|
+
export const paymentCurrencySchema = z.enum(['NGN', 'USD']);
|
|
10
|
+
// Payment method enum
|
|
11
|
+
export const paymentMethodSchema = z.enum(['card', 'bank_transfer', 'mobile_money', 'ussd', 'account']);
|
|
12
|
+
// Payment gateway enum
|
|
13
|
+
export const paymentGatewaySchema = z.enum(['flutterwave', 'paystack', 'stripe', 'paypal', 'other']);
|
|
14
|
+
// Payment attributes schema (for JSON:API attributes object)
|
|
15
|
+
export const paymentAttributesSchema = z.object({
|
|
16
|
+
amount: z.number().positive(),
|
|
17
|
+
currency: paymentCurrencySchema,
|
|
18
|
+
status: paymentStatusSchema,
|
|
19
|
+
paymentMethod: paymentMethodSchema.nullable().optional(),
|
|
20
|
+
gateway: paymentGatewaySchema,
|
|
21
|
+
gatewayTxRef: z.string().nullable().optional(),
|
|
22
|
+
gatewayTxId: z.string().nullable().optional(),
|
|
23
|
+
description: z.string().nullable().optional(),
|
|
24
|
+
metadata: z.record(z.unknown()).nullable().optional(),
|
|
25
|
+
failureReason: z.string().nullable().optional(),
|
|
26
|
+
paidAt: z.string().datetime().nullable().optional(),
|
|
27
|
+
}).merge(timestampsSchema);
|
|
28
|
+
// Payment attributes for creation (input)
|
|
29
|
+
export const createPaymentAttributesSchema = z.object({
|
|
30
|
+
amount: z.number().positive(),
|
|
31
|
+
currency: paymentCurrencySchema.default('NGN'),
|
|
32
|
+
paymentMethod: paymentMethodSchema.optional(),
|
|
33
|
+
gateway: paymentGatewaySchema.default('flutterwave'), // Default to flutterwave for backward compatibility
|
|
34
|
+
description: z.string().max(500).optional(),
|
|
35
|
+
metadata: z.record(z.unknown()).optional(),
|
|
36
|
+
});
|
|
37
|
+
// Payment attributes for update (input) - typically only for admin operations
|
|
38
|
+
export const updatePaymentAttributesSchema = z.object({
|
|
39
|
+
status: paymentStatusSchema.optional(),
|
|
40
|
+
failureReason: z.string().max(1000).optional(),
|
|
41
|
+
metadata: z.record(z.unknown()).optional(),
|
|
42
|
+
});
|
|
43
|
+
// Payment resource schema
|
|
44
|
+
export const paymentResourceSchema = createJsonApiResourceSchema('payments', paymentAttributesSchema);
|
|
45
|
+
// Payment response schemas
|
|
46
|
+
export const paymentResponseSchema = jsonApiSingleResponseSchema(paymentResourceSchema);
|
|
47
|
+
export const paymentListResponseSchema = jsonApiCollectionResponseSchema(paymentResourceSchema);
|
|
48
|
+
// Flutterwave payment initialization request
|
|
49
|
+
export const flutterwaveInitPaymentSchema = z.object({
|
|
50
|
+
amount: z.number().positive(),
|
|
51
|
+
currency: paymentCurrencySchema,
|
|
52
|
+
email: z.string().email(),
|
|
53
|
+
phone: z.string().optional(),
|
|
54
|
+
name: z.string().optional(),
|
|
55
|
+
paymentMethod: paymentMethodSchema.optional(),
|
|
56
|
+
description: z.string().max(500).optional(),
|
|
57
|
+
metadata: z.record(z.unknown()).optional(),
|
|
58
|
+
});
|
|
59
|
+
// Flutterwave payment initialization response
|
|
60
|
+
export const flutterwaveInitPaymentResponseSchema = z.object({
|
|
61
|
+
status: z.literal('success'),
|
|
62
|
+
message: z.string(),
|
|
63
|
+
data: z.object({
|
|
64
|
+
link: z.string().url(), // Payment link for redirect
|
|
65
|
+
tx_ref: z.string(), // Transaction reference
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
68
|
+
// Flutterwave webhook payload schema
|
|
69
|
+
export const flutterwaveWebhookSchema = z.object({
|
|
70
|
+
event: z.string(),
|
|
71
|
+
data: z.object({
|
|
72
|
+
id: z.number(),
|
|
73
|
+
tx_ref: z.string(),
|
|
74
|
+
flw_ref: z.string(),
|
|
75
|
+
device_fingerprint: z.string().optional(),
|
|
76
|
+
amount: z.number(),
|
|
77
|
+
currency: z.string(),
|
|
78
|
+
charged_amount: z.number(),
|
|
79
|
+
app_fee: z.number(),
|
|
80
|
+
merchant_fee: z.number(),
|
|
81
|
+
processor_response: z.string().optional(),
|
|
82
|
+
auth_model: z.string().optional(),
|
|
83
|
+
card: z.object({
|
|
84
|
+
first_6digits: z.string().optional(),
|
|
85
|
+
last_4digits: z.string().optional(),
|
|
86
|
+
issuer: z.string().optional(),
|
|
87
|
+
country: z.string().optional(),
|
|
88
|
+
type: z.string().optional(),
|
|
89
|
+
token: z.string().optional(),
|
|
90
|
+
expiry: z.string().optional(),
|
|
91
|
+
}).optional(),
|
|
92
|
+
account_id: z.number(),
|
|
93
|
+
customer: z.object({
|
|
94
|
+
id: z.number(),
|
|
95
|
+
name: z.string(),
|
|
96
|
+
phone_number: z.string().optional(),
|
|
97
|
+
email: z.string(),
|
|
98
|
+
created_at: z.string(),
|
|
99
|
+
}),
|
|
100
|
+
status: z.string(),
|
|
101
|
+
payment_type: z.string(),
|
|
102
|
+
created_at: z.string(),
|
|
103
|
+
amount_settled: z.number().optional(),
|
|
104
|
+
}),
|
|
105
|
+
});
|