@classytic/revenue 1.1.2 → 1.1.3
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/README.md +8 -7
- package/dist/application/services/index.d.mts +4 -0
- package/dist/application/services/index.mjs +3 -0
- package/dist/base-CsTlVQJe.d.mts +136 -0
- package/dist/base-DCoyIUj6.mjs +152 -0
- package/dist/category-resolver-DV83N8ok.mjs +284 -0
- package/dist/commission-split-BzB8cd39.mjs +485 -0
- package/dist/core/events.d.mts +294 -0
- package/dist/core/events.mjs +100 -0
- package/dist/core/index.d.mts +9 -0
- package/dist/core/index.mjs +8 -0
- package/dist/enums/index.d.mts +157 -0
- package/dist/enums/index.mjs +56 -0
- package/dist/errors-CorrWz7A.d.mts +787 -0
- package/dist/escrow.enums-CZGrrdg7.mjs +101 -0
- package/dist/{escrow.enums-CE0VQsfe.d.ts → escrow.enums-DwdLuuve.d.mts} +30 -28
- package/dist/idempotency-DaYcUGY1.mjs +172 -0
- package/dist/index-Dsp7H5Wb.d.mts +471 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +38 -0
- package/dist/infrastructure/plugins/{index.d.ts → index.d.mts} +81 -109
- package/dist/infrastructure/plugins/index.mjs +345 -0
- package/dist/money-CvrDOijQ.mjs +271 -0
- package/dist/money-DPG8AtJ8.d.mts +112 -0
- package/dist/{payment.enums-C1BiGlRa.d.ts → payment.enums-HAuAS9Pp.d.mts} +14 -13
- package/dist/payment.enums-tEFVa-Xp.mjs +69 -0
- package/dist/plugin-BbK0OVHy.d.mts +327 -0
- package/dist/plugin-Cd_V04Em.mjs +210 -0
- package/dist/providers/index.d.mts +3 -0
- package/dist/providers/index.mjs +3 -0
- package/dist/reconciliation/{index.d.ts → index.d.mts} +90 -112
- package/dist/reconciliation/index.mjs +192 -0
- package/dist/retry-HHCOXYdn.d.mts +186 -0
- package/dist/revenue-9scqKSef.mjs +553 -0
- package/dist/schemas/index.d.mts +2665 -0
- package/dist/schemas/index.mjs +717 -0
- package/dist/schemas/validation.d.mts +375 -0
- package/dist/schemas/validation.mjs +325 -0
- package/dist/{settlement.enums-ByC1x0ye.d.ts → settlement.enums-DFhkqZEY.d.mts} +31 -29
- package/dist/settlement.schema-D5uWB5tP.d.mts +344 -0
- package/dist/settlement.service-BxuiHpNC.d.mts +594 -0
- package/dist/settlement.service-CUxbUTzT.mjs +2510 -0
- package/dist/split.enums-BrjabxIX.mjs +86 -0
- package/dist/split.enums-DmskfLOM.d.mts +43 -0
- package/dist/tax-BoCt5cEd.d.mts +61 -0
- package/dist/tax-EQ15DO81.mjs +162 -0
- package/dist/transaction.enums-pCyMFT4Z.mjs +96 -0
- package/dist/utils/{index.d.ts → index.d.mts} +91 -161
- package/dist/utils/index.mjs +346 -0
- package/package.json +38 -36
- package/dist/application/services/index.d.ts +0 -6
- package/dist/application/services/index.js +0 -3288
- package/dist/application/services/index.js.map +0 -1
- package/dist/core/events.d.ts +0 -455
- package/dist/core/events.js +0 -122
- package/dist/core/events.js.map +0 -1
- package/dist/core/index.d.ts +0 -13
- package/dist/core/index.js +0 -4591
- package/dist/core/index.js.map +0 -1
- package/dist/enums/index.d.ts +0 -159
- package/dist/enums/index.js +0 -296
- package/dist/enums/index.js.map +0 -1
- package/dist/index-DxIK0UmZ.d.ts +0 -633
- package/dist/index-EnfKzDbs.d.ts +0 -806
- package/dist/index-cLJBLUvx.d.ts +0 -478
- package/dist/index.d.ts +0 -43
- package/dist/index.js +0 -4864
- package/dist/index.js.map +0 -1
- package/dist/infrastructure/plugins/index.js +0 -292
- package/dist/infrastructure/plugins/index.js.map +0 -1
- package/dist/money-widWVD7r.d.ts +0 -111
- package/dist/plugin-Bb9HOE10.d.ts +0 -336
- package/dist/providers/index.d.ts +0 -145
- package/dist/providers/index.js +0 -141
- package/dist/providers/index.js.map +0 -1
- package/dist/reconciliation/index.js +0 -140
- package/dist/reconciliation/index.js.map +0 -1
- package/dist/retry-D4hFUwVk.d.ts +0 -194
- package/dist/schemas/index.d.ts +0 -2655
- package/dist/schemas/index.js +0 -841
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/validation.d.ts +0 -384
- package/dist/schemas/validation.js +0 -303
- package/dist/schemas/validation.js.map +0 -1
- package/dist/settlement.schema-CpamV7ZY.d.ts +0 -343
- package/dist/split.enums-DG3TxQf9.d.ts +0 -42
- package/dist/tax-CV8A0sxl.d.ts +0 -60
- package/dist/utils/index.js +0 -1202
- package/dist/utils/index.js.map +0 -1
package/dist/index-DxIK0UmZ.d.ts
DELETED
|
@@ -1,633 +0,0 @@
|
|
|
1
|
-
import { o as MonetizationCreateParams, p as MonetizationCreateResult, A as ActivateOptions, S as SubscriptionDocument, q as RenewalParams, r as CancelOptions, s as PauseOptions, t as ResumeOptions, u as ListOptions, v as PaymentVerifyOptions, w as PaymentVerifyResult, x as PaymentStatusResult, y as RefundOptions, z as PaymentRefundResult, B as WebhookResult, T as TransactionDocument, k as PaymentProviderInterface, E as TransactionListResult, H as HoldOptions, G as ReleaseOptions, I as ReleaseResult, J as CancelHoldOptions, c as SplitRule, K as SplitResult, N as EscrowStatusResult } from './index-cLJBLUvx.js';
|
|
2
|
-
import { S as SettlementDocument } from './settlement.schema-CpamV7ZY.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Dependency Injection Container
|
|
6
|
-
* @classytic/revenue
|
|
7
|
-
*
|
|
8
|
-
* Lightweight DI container for managing dependencies
|
|
9
|
-
* Inspired by: Awilix, InversifyJS but much simpler
|
|
10
|
-
*/
|
|
11
|
-
declare class Container {
|
|
12
|
-
private _services;
|
|
13
|
-
private _singletons;
|
|
14
|
-
constructor();
|
|
15
|
-
/**
|
|
16
|
-
* Register a service
|
|
17
|
-
* @param name - Service name
|
|
18
|
-
* @param implementation - Service implementation or factory
|
|
19
|
-
* @param options - Registration options
|
|
20
|
-
*/
|
|
21
|
-
register<T>(name: string, implementation: T | ((container: Container) => T), options?: {
|
|
22
|
-
singleton?: boolean;
|
|
23
|
-
factory?: boolean;
|
|
24
|
-
}): this;
|
|
25
|
-
/**
|
|
26
|
-
* Register a singleton service
|
|
27
|
-
* @param name - Service name
|
|
28
|
-
* @param implementation - Service implementation
|
|
29
|
-
*/
|
|
30
|
-
singleton<T>(name: string, implementation: T): this;
|
|
31
|
-
/**
|
|
32
|
-
* Register a transient service (new instance each time)
|
|
33
|
-
* @param name - Service name
|
|
34
|
-
* @param factory - Factory function
|
|
35
|
-
*/
|
|
36
|
-
transient<T>(name: string, factory: (container: Container) => T): this;
|
|
37
|
-
/**
|
|
38
|
-
* Get a service from the container
|
|
39
|
-
* @param name - Service name
|
|
40
|
-
* @returns Service instance
|
|
41
|
-
*/
|
|
42
|
-
get<T>(name: string): T;
|
|
43
|
-
/**
|
|
44
|
-
* Check if service is registered
|
|
45
|
-
* @param name - Service name
|
|
46
|
-
*/
|
|
47
|
-
has(name: string): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Get all registered service names
|
|
50
|
-
*/
|
|
51
|
-
keys(): string[];
|
|
52
|
-
/**
|
|
53
|
-
* Clear all services (useful for testing)
|
|
54
|
-
*/
|
|
55
|
-
clear(): void;
|
|
56
|
-
/**
|
|
57
|
-
* Create a child container (for scoped dependencies)
|
|
58
|
-
*/
|
|
59
|
-
createScope(): Container;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Monetization Service
|
|
64
|
-
* @classytic/revenue
|
|
65
|
-
*
|
|
66
|
-
* Framework-agnostic monetization management service with DI
|
|
67
|
-
* Handles purchases, subscriptions, and free items using provider system
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Monetization Service
|
|
72
|
-
* Uses DI container for all dependencies
|
|
73
|
-
*
|
|
74
|
-
* Architecture:
|
|
75
|
-
* - PluginManager: Wraps operations with lifecycle hooks (before/after)
|
|
76
|
-
* - EventBus: Fire-and-forget notifications for completed operations
|
|
77
|
-
*/
|
|
78
|
-
declare class MonetizationService {
|
|
79
|
-
private readonly models;
|
|
80
|
-
private readonly providers;
|
|
81
|
-
private readonly config;
|
|
82
|
-
private readonly plugins;
|
|
83
|
-
private readonly logger;
|
|
84
|
-
private readonly events;
|
|
85
|
-
private readonly retryConfig;
|
|
86
|
-
private readonly circuitBreaker;
|
|
87
|
-
constructor(container: Container);
|
|
88
|
-
/**
|
|
89
|
-
* Create plugin context for hook execution
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
private getPluginContext;
|
|
93
|
-
/**
|
|
94
|
-
* Execute provider call with retry and circuit breaker protection
|
|
95
|
-
* @private
|
|
96
|
-
*/
|
|
97
|
-
private executeProviderCall;
|
|
98
|
-
/**
|
|
99
|
-
* Create a new monetization (purchase, subscription, or free item)
|
|
100
|
-
*
|
|
101
|
-
* @param params - Monetization parameters
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* // One-time purchase
|
|
105
|
-
* await revenue.monetization.create({
|
|
106
|
-
* data: {
|
|
107
|
-
* organizationId: '...',
|
|
108
|
-
* customerId: '...',
|
|
109
|
-
* sourceId: order._id,
|
|
110
|
-
* sourceModel: 'Order',
|
|
111
|
-
* },
|
|
112
|
-
* planKey: 'one_time',
|
|
113
|
-
* monetizationType: 'purchase',
|
|
114
|
-
* gateway: 'bkash',
|
|
115
|
-
* amount: 1500,
|
|
116
|
-
* });
|
|
117
|
-
*
|
|
118
|
-
* // Recurring subscription
|
|
119
|
-
* await revenue.monetization.create({
|
|
120
|
-
* data: {
|
|
121
|
-
* organizationId: '...',
|
|
122
|
-
* customerId: '...',
|
|
123
|
-
* sourceId: subscription._id,
|
|
124
|
-
* sourceModel: 'Subscription',
|
|
125
|
-
* },
|
|
126
|
-
* planKey: 'monthly',
|
|
127
|
-
* monetizationType: 'subscription',
|
|
128
|
-
* gateway: 'stripe',
|
|
129
|
-
* amount: 2000,
|
|
130
|
-
* });
|
|
131
|
-
*
|
|
132
|
-
* @returns Result with subscription, transaction, and paymentIntent
|
|
133
|
-
*/
|
|
134
|
-
create(params: MonetizationCreateParams): Promise<MonetizationCreateResult>;
|
|
135
|
-
/**
|
|
136
|
-
* Activate subscription after payment verification
|
|
137
|
-
*
|
|
138
|
-
* @param subscriptionId - Subscription ID or transaction ID
|
|
139
|
-
* @param options - Activation options
|
|
140
|
-
* @returns Updated subscription
|
|
141
|
-
*/
|
|
142
|
-
activate(subscriptionId: string, options?: ActivateOptions): Promise<SubscriptionDocument>;
|
|
143
|
-
/**
|
|
144
|
-
* Renew subscription
|
|
145
|
-
*
|
|
146
|
-
* @param subscriptionId - Subscription ID
|
|
147
|
-
* @param params - Renewal parameters
|
|
148
|
-
* @returns { subscription, transaction, paymentIntent }
|
|
149
|
-
*/
|
|
150
|
-
renew(subscriptionId: string, params?: RenewalParams): Promise<MonetizationCreateResult>;
|
|
151
|
-
/**
|
|
152
|
-
* Cancel subscription
|
|
153
|
-
*
|
|
154
|
-
* @param subscriptionId - Subscription ID
|
|
155
|
-
* @param options - Cancellation options
|
|
156
|
-
* @returns Updated subscription
|
|
157
|
-
*/
|
|
158
|
-
cancel(subscriptionId: string, options?: CancelOptions): Promise<SubscriptionDocument>;
|
|
159
|
-
/**
|
|
160
|
-
* Pause subscription
|
|
161
|
-
*
|
|
162
|
-
* @param subscriptionId - Subscription ID
|
|
163
|
-
* @param options - Pause options
|
|
164
|
-
* @returns Updated subscription
|
|
165
|
-
*/
|
|
166
|
-
pause(subscriptionId: string, options?: PauseOptions): Promise<SubscriptionDocument>;
|
|
167
|
-
/**
|
|
168
|
-
* Resume subscription
|
|
169
|
-
*
|
|
170
|
-
* @param subscriptionId - Subscription ID
|
|
171
|
-
* @param options - Resume options
|
|
172
|
-
* @returns Updated subscription
|
|
173
|
-
*/
|
|
174
|
-
resume(subscriptionId: string, options?: ResumeOptions): Promise<SubscriptionDocument>;
|
|
175
|
-
/**
|
|
176
|
-
* List subscriptions with filters
|
|
177
|
-
*
|
|
178
|
-
* @param filters - Query filters
|
|
179
|
-
* @param options - Query options (limit, skip, sort)
|
|
180
|
-
* @returns Subscriptions
|
|
181
|
-
*/
|
|
182
|
-
list(filters?: Record<string, unknown>, options?: ListOptions): Promise<SubscriptionDocument[]>;
|
|
183
|
-
/**
|
|
184
|
-
* Get subscription by ID
|
|
185
|
-
*
|
|
186
|
-
* @param subscriptionId - Subscription ID
|
|
187
|
-
* @returns Subscription
|
|
188
|
-
*/
|
|
189
|
-
get(subscriptionId: string): Promise<SubscriptionDocument>;
|
|
190
|
-
/**
|
|
191
|
-
* Calculate period end date based on plan key
|
|
192
|
-
* @private
|
|
193
|
-
*/
|
|
194
|
-
private _calculatePeriodEnd;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Payment Service
|
|
199
|
-
* @classytic/revenue
|
|
200
|
-
*
|
|
201
|
-
* Framework-agnostic payment verification and management service with DI
|
|
202
|
-
* Handles payment verification, refunds, and status updates
|
|
203
|
-
*/
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Payment Service
|
|
207
|
-
* Uses DI container for all dependencies
|
|
208
|
-
*
|
|
209
|
-
* Architecture:
|
|
210
|
-
* - PluginManager: Wraps operations with lifecycle hooks (before/after)
|
|
211
|
-
* - EventBus: Fire-and-forget notifications for completed operations
|
|
212
|
-
*/
|
|
213
|
-
declare class PaymentService {
|
|
214
|
-
private readonly models;
|
|
215
|
-
private readonly providers;
|
|
216
|
-
private readonly config;
|
|
217
|
-
private readonly plugins;
|
|
218
|
-
private readonly logger;
|
|
219
|
-
private readonly events;
|
|
220
|
-
private readonly retryConfig;
|
|
221
|
-
private readonly circuitBreaker;
|
|
222
|
-
constructor(container: Container);
|
|
223
|
-
/**
|
|
224
|
-
* Create plugin context for hook execution
|
|
225
|
-
* @private
|
|
226
|
-
*/
|
|
227
|
-
private getPluginContext;
|
|
228
|
-
/**
|
|
229
|
-
* Execute provider call with retry and circuit breaker protection
|
|
230
|
-
* @private
|
|
231
|
-
*/
|
|
232
|
-
private executeProviderCall;
|
|
233
|
-
/**
|
|
234
|
-
* Verify a payment
|
|
235
|
-
*
|
|
236
|
-
* @param paymentIntentId - Payment intent ID, session ID, or transaction ID
|
|
237
|
-
* @param options - Verification options
|
|
238
|
-
* @returns { transaction, status }
|
|
239
|
-
*/
|
|
240
|
-
verify(paymentIntentId: string, options?: PaymentVerifyOptions): Promise<PaymentVerifyResult>;
|
|
241
|
-
/**
|
|
242
|
-
* Get payment status
|
|
243
|
-
*
|
|
244
|
-
* @param paymentIntentId - Payment intent ID, session ID, or transaction ID
|
|
245
|
-
* @returns { transaction, status }
|
|
246
|
-
*/
|
|
247
|
-
getStatus(paymentIntentId: string): Promise<PaymentStatusResult>;
|
|
248
|
-
/**
|
|
249
|
-
* Refund a payment
|
|
250
|
-
*
|
|
251
|
-
* @param paymentId - Payment intent ID, session ID, or transaction ID
|
|
252
|
-
* @param amount - Amount to refund (optional, full refund if not provided)
|
|
253
|
-
* @param options - Refund options
|
|
254
|
-
* @returns { transaction, refundResult }
|
|
255
|
-
*/
|
|
256
|
-
refund(paymentId: string, amount?: number | null, options?: RefundOptions): Promise<PaymentRefundResult>;
|
|
257
|
-
/**
|
|
258
|
-
* Handle webhook from payment provider
|
|
259
|
-
*
|
|
260
|
-
* @param provider - Provider name
|
|
261
|
-
* @param payload - Webhook payload
|
|
262
|
-
* @param headers - Request headers
|
|
263
|
-
* @returns { event, transaction }
|
|
264
|
-
*/
|
|
265
|
-
handleWebhook(providerName: string, payload: unknown, headers?: Record<string, string>): Promise<WebhookResult>;
|
|
266
|
-
/**
|
|
267
|
-
* List payments/transactions with filters
|
|
268
|
-
*
|
|
269
|
-
* @param filters - Query filters
|
|
270
|
-
* @param options - Query options (limit, skip, sort)
|
|
271
|
-
* @returns Transactions
|
|
272
|
-
*/
|
|
273
|
-
list(filters?: Record<string, unknown>, options?: ListOptions): Promise<TransactionDocument[]>;
|
|
274
|
-
/**
|
|
275
|
-
* Get payment/transaction by ID
|
|
276
|
-
*
|
|
277
|
-
* @param transactionId - Transaction ID
|
|
278
|
-
* @returns Transaction
|
|
279
|
-
*/
|
|
280
|
-
get(transactionId: string): Promise<TransactionDocument>;
|
|
281
|
-
/**
|
|
282
|
-
* Get provider instance
|
|
283
|
-
*
|
|
284
|
-
* @param providerName - Provider name
|
|
285
|
-
* @returns Provider instance
|
|
286
|
-
*/
|
|
287
|
-
getProvider(providerName: string): PaymentProviderInterface;
|
|
288
|
-
/**
|
|
289
|
-
* Find transaction by sessionId, paymentIntentId, or transaction ID
|
|
290
|
-
* @private
|
|
291
|
-
*/
|
|
292
|
-
private _findTransaction;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Transaction Service
|
|
297
|
-
* @classytic/revenue
|
|
298
|
-
*
|
|
299
|
-
* Thin, focused transaction service for core operations
|
|
300
|
-
* Users handle their own analytics, exports, and complex queries
|
|
301
|
-
*
|
|
302
|
-
* Works with ANY model implementation:
|
|
303
|
-
* - Plain Mongoose models
|
|
304
|
-
* - @classytic/mongokit Repository instances
|
|
305
|
-
* - Any other abstraction with compatible interface
|
|
306
|
-
*/
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Transaction Service
|
|
310
|
-
* Focused on core transaction lifecycle operations
|
|
311
|
-
*
|
|
312
|
-
* Architecture:
|
|
313
|
-
* - PluginManager: Wraps operations with lifecycle hooks (before/after)
|
|
314
|
-
* - EventBus: Fire-and-forget notifications for completed operations
|
|
315
|
-
*/
|
|
316
|
-
declare class TransactionService {
|
|
317
|
-
private readonly models;
|
|
318
|
-
private readonly plugins;
|
|
319
|
-
private readonly events;
|
|
320
|
-
private readonly logger;
|
|
321
|
-
constructor(container: Container);
|
|
322
|
-
/**
|
|
323
|
-
* Create plugin context for hook execution
|
|
324
|
-
* @private
|
|
325
|
-
*/
|
|
326
|
-
private getPluginContext;
|
|
327
|
-
/**
|
|
328
|
-
* Get transaction by ID
|
|
329
|
-
*
|
|
330
|
-
* @param transactionId - Transaction ID
|
|
331
|
-
* @returns Transaction
|
|
332
|
-
*/
|
|
333
|
-
get(transactionId: string): Promise<TransactionDocument>;
|
|
334
|
-
/**
|
|
335
|
-
* List transactions with filters
|
|
336
|
-
*
|
|
337
|
-
* @param filters - Query filters
|
|
338
|
-
* @param options - Query options (limit, skip, sort, populate)
|
|
339
|
-
* @returns { transactions, total, page, limit }
|
|
340
|
-
*/
|
|
341
|
-
list(filters?: Record<string, unknown>, options?: ListOptions): Promise<TransactionListResult>;
|
|
342
|
-
/**
|
|
343
|
-
* Update transaction
|
|
344
|
-
*
|
|
345
|
-
* @param transactionId - Transaction ID
|
|
346
|
-
* @param updates - Fields to update
|
|
347
|
-
* @returns Updated transaction
|
|
348
|
-
*/
|
|
349
|
-
update(transactionId: string, updates: Partial<TransactionDocument>): Promise<TransactionDocument>;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Escrow Service
|
|
354
|
-
* @classytic/revenue
|
|
355
|
-
*
|
|
356
|
-
* Platform-as-intermediary payment flow
|
|
357
|
-
* Hold funds → Verify → Split/Deduct → Release to organization
|
|
358
|
-
*/
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Escrow Service
|
|
362
|
-
* Uses DI container for all dependencies
|
|
363
|
-
*
|
|
364
|
-
* Architecture:
|
|
365
|
-
* - PluginManager: Wraps operations with lifecycle hooks (before/after)
|
|
366
|
-
* - EventBus: Fire-and-forget notifications for completed operations
|
|
367
|
-
*/
|
|
368
|
-
declare class EscrowService {
|
|
369
|
-
private readonly models;
|
|
370
|
-
private readonly plugins;
|
|
371
|
-
private readonly logger;
|
|
372
|
-
private readonly events;
|
|
373
|
-
constructor(container: Container);
|
|
374
|
-
/**
|
|
375
|
-
* Create plugin context for hook execution
|
|
376
|
-
* @private
|
|
377
|
-
*/
|
|
378
|
-
private getPluginContext;
|
|
379
|
-
/**
|
|
380
|
-
* Hold funds in escrow
|
|
381
|
-
*
|
|
382
|
-
* @param transactionId - Transaction to hold
|
|
383
|
-
* @param options - Hold options
|
|
384
|
-
* @returns Updated transaction
|
|
385
|
-
*/
|
|
386
|
-
hold(transactionId: string, options?: HoldOptions): Promise<TransactionDocument>;
|
|
387
|
-
/**
|
|
388
|
-
* Release funds from escrow to recipient
|
|
389
|
-
*
|
|
390
|
-
* @param transactionId - Transaction to release
|
|
391
|
-
* @param options - Release options
|
|
392
|
-
* @returns { transaction, releaseTransaction }
|
|
393
|
-
*/
|
|
394
|
-
release(transactionId: string, options: ReleaseOptions): Promise<ReleaseResult>;
|
|
395
|
-
/**
|
|
396
|
-
* Cancel hold and release back to customer
|
|
397
|
-
*
|
|
398
|
-
* @param transactionId - Transaction to cancel hold
|
|
399
|
-
* @param options - Cancel options
|
|
400
|
-
* @returns Updated transaction
|
|
401
|
-
*/
|
|
402
|
-
cancel(transactionId: string, options?: CancelHoldOptions): Promise<TransactionDocument>;
|
|
403
|
-
/**
|
|
404
|
-
* Split payment to multiple recipients
|
|
405
|
-
* Deducts splits from held amount and releases remainder to organization
|
|
406
|
-
*
|
|
407
|
-
* @param transactionId - Transaction to split
|
|
408
|
-
* @param splitRules - Split configuration
|
|
409
|
-
* @returns { transaction, splitTransactions, organizationTransaction }
|
|
410
|
-
*/
|
|
411
|
-
split(transactionId: string, splitRules?: SplitRule[]): Promise<SplitResult>;
|
|
412
|
-
/**
|
|
413
|
-
* Get escrow status
|
|
414
|
-
*
|
|
415
|
-
* @param transactionId - Transaction ID
|
|
416
|
-
* @returns Escrow status
|
|
417
|
-
*/
|
|
418
|
-
getStatus(transactionId: string): Promise<EscrowStatusResult>;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Settlement Service
|
|
423
|
-
* @classytic/revenue
|
|
424
|
-
*
|
|
425
|
-
* Tracks payouts from platform to vendors/affiliates/partners
|
|
426
|
-
* Manages the flow: Transaction → Split → Settlement → Bank Transfer
|
|
427
|
-
*/
|
|
428
|
-
|
|
429
|
-
interface CreateFromSplitsOptions {
|
|
430
|
-
scheduledAt?: Date;
|
|
431
|
-
payoutMethod?: 'bank_transfer' | 'mobile_wallet' | 'platform_balance' | 'crypto' | 'manual';
|
|
432
|
-
metadata?: Record<string, unknown>;
|
|
433
|
-
}
|
|
434
|
-
interface ScheduleSettlementParams {
|
|
435
|
-
organizationId: string;
|
|
436
|
-
recipientId: string;
|
|
437
|
-
recipientType: 'platform' | 'organization' | 'user' | 'affiliate' | 'partner';
|
|
438
|
-
type: 'split_payout' | 'platform_withdrawal' | 'manual_payout' | 'escrow_release';
|
|
439
|
-
amount: number;
|
|
440
|
-
currency?: string;
|
|
441
|
-
payoutMethod: 'bank_transfer' | 'mobile_wallet' | 'platform_balance' | 'crypto' | 'manual';
|
|
442
|
-
sourceTransactionIds?: string[];
|
|
443
|
-
sourceSplitIds?: string[];
|
|
444
|
-
scheduledAt?: Date;
|
|
445
|
-
bankTransferDetails?: {
|
|
446
|
-
accountNumber?: string;
|
|
447
|
-
accountName?: string;
|
|
448
|
-
bankName?: string;
|
|
449
|
-
routingNumber?: string;
|
|
450
|
-
swiftCode?: string;
|
|
451
|
-
iban?: string;
|
|
452
|
-
};
|
|
453
|
-
mobileWalletDetails?: {
|
|
454
|
-
provider?: string;
|
|
455
|
-
phoneNumber?: string;
|
|
456
|
-
accountNumber?: string;
|
|
457
|
-
};
|
|
458
|
-
cryptoDetails?: {
|
|
459
|
-
network?: string;
|
|
460
|
-
walletAddress?: string;
|
|
461
|
-
};
|
|
462
|
-
notes?: string;
|
|
463
|
-
metadata?: Record<string, unknown>;
|
|
464
|
-
}
|
|
465
|
-
interface ProcessOptions {
|
|
466
|
-
limit?: number;
|
|
467
|
-
organizationId?: string;
|
|
468
|
-
payoutMethod?: string;
|
|
469
|
-
dryRun?: boolean;
|
|
470
|
-
}
|
|
471
|
-
interface ProcessResult {
|
|
472
|
-
processed: number;
|
|
473
|
-
succeeded: number;
|
|
474
|
-
failed: number;
|
|
475
|
-
settlements: SettlementDocument[];
|
|
476
|
-
errors: Array<{
|
|
477
|
-
settlementId: string;
|
|
478
|
-
error: string;
|
|
479
|
-
}>;
|
|
480
|
-
}
|
|
481
|
-
interface CompletionDetails {
|
|
482
|
-
transferReference?: string;
|
|
483
|
-
transferredAt?: Date;
|
|
484
|
-
transactionHash?: string;
|
|
485
|
-
notes?: string;
|
|
486
|
-
metadata?: Record<string, unknown>;
|
|
487
|
-
}
|
|
488
|
-
interface SettlementFilters {
|
|
489
|
-
organizationId?: string;
|
|
490
|
-
recipientId?: string;
|
|
491
|
-
status?: string | string[];
|
|
492
|
-
type?: string;
|
|
493
|
-
payoutMethod?: string;
|
|
494
|
-
scheduledAfter?: Date;
|
|
495
|
-
scheduledBefore?: Date;
|
|
496
|
-
limit?: number;
|
|
497
|
-
skip?: number;
|
|
498
|
-
sort?: Record<string, 1 | -1>;
|
|
499
|
-
}
|
|
500
|
-
interface SummaryOptions {
|
|
501
|
-
organizationId?: string;
|
|
502
|
-
startDate?: Date;
|
|
503
|
-
endDate?: Date;
|
|
504
|
-
}
|
|
505
|
-
interface SettlementSummary {
|
|
506
|
-
recipientId: string;
|
|
507
|
-
totalPending: number;
|
|
508
|
-
totalProcessing: number;
|
|
509
|
-
totalCompleted: number;
|
|
510
|
-
totalFailed: number;
|
|
511
|
-
amountPending: number;
|
|
512
|
-
amountCompleted: number;
|
|
513
|
-
amountFailed: number;
|
|
514
|
-
currency: string;
|
|
515
|
-
lastSettlementDate?: Date;
|
|
516
|
-
settlements: {
|
|
517
|
-
pending: number;
|
|
518
|
-
processing: number;
|
|
519
|
-
completed: number;
|
|
520
|
-
failed: number;
|
|
521
|
-
cancelled: number;
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Settlement Service
|
|
526
|
-
*
|
|
527
|
-
* Handles payout tracking after splits are released from escrow:
|
|
528
|
-
*
|
|
529
|
-
* Flow:
|
|
530
|
-
* 1. Transaction has splits → 2. Escrow released → 3. Create settlements → 4. Process payouts → 5. Mark complete
|
|
531
|
-
*
|
|
532
|
-
* @example
|
|
533
|
-
* ```typescript
|
|
534
|
-
* // Auto-create settlements from transaction splits
|
|
535
|
-
* await revenue.settlement.createFromSplits(transactionId);
|
|
536
|
-
*
|
|
537
|
-
* // Schedule a manual payout
|
|
538
|
-
* await revenue.settlement.schedule({
|
|
539
|
-
* recipientId: vendorId,
|
|
540
|
-
* amount: 8500,
|
|
541
|
-
* payoutMethod: 'bank_transfer',
|
|
542
|
-
* });
|
|
543
|
-
*
|
|
544
|
-
* // Process pending payouts
|
|
545
|
-
* const result = await revenue.settlement.processPending({ limit: 100 });
|
|
546
|
-
*
|
|
547
|
-
* // Mark as completed after bank confirms
|
|
548
|
-
* await revenue.settlement.complete(settlementId, { transferReference: 'TRF123' });
|
|
549
|
-
* ```
|
|
550
|
-
*/
|
|
551
|
-
/**
|
|
552
|
-
* Settlement Service
|
|
553
|
-
* Uses DI container for all dependencies
|
|
554
|
-
*
|
|
555
|
-
* Architecture:
|
|
556
|
-
* - PluginManager: Wraps operations with lifecycle hooks (before/after)
|
|
557
|
-
* - EventBus: Fire-and-forget notifications for completed operations
|
|
558
|
-
*/
|
|
559
|
-
declare class SettlementService {
|
|
560
|
-
private readonly models;
|
|
561
|
-
private readonly plugins;
|
|
562
|
-
private readonly logger;
|
|
563
|
-
private readonly events;
|
|
564
|
-
constructor(container: Container);
|
|
565
|
-
/**
|
|
566
|
-
* Create settlements from transaction splits
|
|
567
|
-
* Typically called after escrow is released
|
|
568
|
-
*
|
|
569
|
-
* @param transactionId - Transaction ID with splits
|
|
570
|
-
* @param options - Creation options
|
|
571
|
-
* @returns Array of created settlements
|
|
572
|
-
*/
|
|
573
|
-
createFromSplits(transactionId: string, options?: CreateFromSplitsOptions): Promise<SettlementDocument[]>;
|
|
574
|
-
/**
|
|
575
|
-
* Schedule a payout
|
|
576
|
-
*
|
|
577
|
-
* @param params - Settlement parameters
|
|
578
|
-
* @returns Created settlement
|
|
579
|
-
*/
|
|
580
|
-
schedule(params: ScheduleSettlementParams): Promise<SettlementDocument>;
|
|
581
|
-
/**
|
|
582
|
-
* Process pending settlements
|
|
583
|
-
* Batch process settlements that are due
|
|
584
|
-
*
|
|
585
|
-
* @param options - Processing options
|
|
586
|
-
* @returns Processing result
|
|
587
|
-
*/
|
|
588
|
-
processPending(options?: ProcessOptions): Promise<ProcessResult>;
|
|
589
|
-
/**
|
|
590
|
-
* Mark settlement as completed
|
|
591
|
-
* Call this after bank confirms the transfer
|
|
592
|
-
*
|
|
593
|
-
* @param settlementId - Settlement ID
|
|
594
|
-
* @param details - Completion details
|
|
595
|
-
* @returns Updated settlement
|
|
596
|
-
*/
|
|
597
|
-
complete(settlementId: string, details?: CompletionDetails): Promise<SettlementDocument>;
|
|
598
|
-
/**
|
|
599
|
-
* Mark settlement as failed
|
|
600
|
-
*
|
|
601
|
-
* @param settlementId - Settlement ID
|
|
602
|
-
* @param reason - Failure reason
|
|
603
|
-
* @returns Updated settlement
|
|
604
|
-
*/
|
|
605
|
-
fail(settlementId: string, reason: string, options?: {
|
|
606
|
-
code?: string;
|
|
607
|
-
retry?: boolean;
|
|
608
|
-
}): Promise<SettlementDocument>;
|
|
609
|
-
/**
|
|
610
|
-
* List settlements with filters
|
|
611
|
-
*
|
|
612
|
-
* @param filters - Query filters
|
|
613
|
-
* @returns Settlements
|
|
614
|
-
*/
|
|
615
|
-
list(filters?: SettlementFilters): Promise<SettlementDocument[]>;
|
|
616
|
-
/**
|
|
617
|
-
* Get payout summary for recipient
|
|
618
|
-
*
|
|
619
|
-
* @param recipientId - Recipient ID
|
|
620
|
-
* @param options - Summary options
|
|
621
|
-
* @returns Settlement summary
|
|
622
|
-
*/
|
|
623
|
-
getSummary(recipientId: string, options?: SummaryOptions): Promise<SettlementSummary>;
|
|
624
|
-
/**
|
|
625
|
-
* Get settlement by ID
|
|
626
|
-
*
|
|
627
|
-
* @param settlementId - Settlement ID
|
|
628
|
-
* @returns Settlement
|
|
629
|
-
*/
|
|
630
|
-
get(settlementId: string): Promise<SettlementDocument>;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
export { Container as C, EscrowService as E, MonetizationService as M, PaymentService as P, SettlementService as S, TransactionService as T };
|