@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
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
import EventBus, { RevenueEvents } from './core/events.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Plugin System
|
|
5
|
-
* @classytic/revenue
|
|
6
|
-
*
|
|
7
|
-
* Composable, type-safe plugin architecture
|
|
8
|
-
* Inspired by: Hono middleware, Fastify plugins, Redux middleware
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Plugin context passed to hooks
|
|
13
|
-
*/
|
|
14
|
-
interface PluginContext {
|
|
15
|
-
/** Event bus for emitting events */
|
|
16
|
-
events: EventBus;
|
|
17
|
-
/** Logger instance */
|
|
18
|
-
logger: PluginLogger;
|
|
19
|
-
/** Plugin-specific storage (use this to share data between hook calls) */
|
|
20
|
-
storage: Map<string, unknown>;
|
|
21
|
-
/** Request metadata */
|
|
22
|
-
meta: {
|
|
23
|
-
idempotencyKey?: string;
|
|
24
|
-
requestId: string;
|
|
25
|
-
timestamp: Date;
|
|
26
|
-
[key: string]: unknown;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Plugin logger interface
|
|
31
|
-
*/
|
|
32
|
-
interface PluginLogger {
|
|
33
|
-
debug(message: string, data?: unknown): void;
|
|
34
|
-
info(message: string, data?: unknown): void;
|
|
35
|
-
warn(message: string, data?: unknown): void;
|
|
36
|
-
error(message: string, data?: unknown): void;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Hook function type
|
|
40
|
-
*/
|
|
41
|
-
type HookFn<TInput = unknown, TOutput = unknown> = (ctx: PluginContext, input: TInput, next: () => Promise<TOutput>) => Promise<TOutput>;
|
|
42
|
-
/**
|
|
43
|
-
* Available hook points
|
|
44
|
-
*/
|
|
45
|
-
interface PluginHooks {
|
|
46
|
-
'monetization.create.before': HookFn<MonetizationCreateInput>;
|
|
47
|
-
'monetization.create.after': HookFn<MonetizationCreateInput, MonetizationCreateOutput>;
|
|
48
|
-
'payment.create.before': HookFn<PaymentCreateInput>;
|
|
49
|
-
'payment.create.after': HookFn<PaymentCreateInput, PaymentCreateOutput>;
|
|
50
|
-
'payment.verify.before': HookFn<PaymentVerifyInput>;
|
|
51
|
-
'payment.verify.after': HookFn<PaymentVerifyInput, PaymentVerifyOutput>;
|
|
52
|
-
'payment.refund.before': HookFn<RefundInput>;
|
|
53
|
-
'payment.refund.after': HookFn<RefundInput, RefundOutput>;
|
|
54
|
-
'subscription.create.before': HookFn<SubscriptionCreateInput>;
|
|
55
|
-
'subscription.create.after': HookFn<SubscriptionCreateInput, SubscriptionCreateOutput>;
|
|
56
|
-
'subscription.activate.before': HookFn<SubscriptionActivateInput>;
|
|
57
|
-
'subscription.activate.after': HookFn<SubscriptionActivateInput, SubscriptionActivateOutput>;
|
|
58
|
-
'subscription.cancel.before': HookFn<SubscriptionCancelInput>;
|
|
59
|
-
'subscription.cancel.after': HookFn<SubscriptionCancelInput, SubscriptionCancelOutput>;
|
|
60
|
-
'subscription.pause.before': HookFn<SubscriptionPauseInput>;
|
|
61
|
-
'subscription.pause.after': HookFn<SubscriptionPauseInput, SubscriptionPauseOutput>;
|
|
62
|
-
'subscription.resume.before': HookFn<SubscriptionResumeInput>;
|
|
63
|
-
'subscription.resume.after': HookFn<SubscriptionResumeInput, SubscriptionResumeOutput>;
|
|
64
|
-
'transaction.create.before': HookFn<TransactionCreateInput>;
|
|
65
|
-
'transaction.create.after': HookFn<TransactionCreateInput, TransactionCreateOutput>;
|
|
66
|
-
'transaction.update.before': HookFn<TransactionUpdateInput>;
|
|
67
|
-
'transaction.update.after': HookFn<TransactionUpdateInput, TransactionUpdateOutput>;
|
|
68
|
-
'escrow.hold.before': HookFn<EscrowHoldInput>;
|
|
69
|
-
'escrow.hold.after': HookFn<EscrowHoldInput, EscrowHoldOutput>;
|
|
70
|
-
'escrow.release.before': HookFn<EscrowReleaseInput>;
|
|
71
|
-
'escrow.release.after': HookFn<EscrowReleaseInput, EscrowReleaseOutput>;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Clean, explicit hook input/output types
|
|
75
|
-
* Self-documenting and fully type-safe - no more `as any` needed!
|
|
76
|
-
*/
|
|
77
|
-
/**
|
|
78
|
-
* Data passed to monetization.create hooks
|
|
79
|
-
* Includes all parameters plus tax if injected by tax plugin
|
|
80
|
-
*/
|
|
81
|
-
interface MonetizationCreateInput {
|
|
82
|
-
data: {
|
|
83
|
-
organizationId?: string;
|
|
84
|
-
customerId?: string;
|
|
85
|
-
sourceId?: string;
|
|
86
|
-
sourceModel?: string;
|
|
87
|
-
};
|
|
88
|
-
planKey: string;
|
|
89
|
-
amount: number;
|
|
90
|
-
currency?: string;
|
|
91
|
-
gateway?: string;
|
|
92
|
-
entity?: string | null;
|
|
93
|
-
monetizationType?: 'subscription' | 'purchase' | 'free';
|
|
94
|
-
paymentData?: Record<string, unknown>;
|
|
95
|
-
metadata?: Record<string, unknown>;
|
|
96
|
-
idempotencyKey?: string | null;
|
|
97
|
-
tax?: {
|
|
98
|
-
isApplicable: boolean;
|
|
99
|
-
rate: number;
|
|
100
|
-
baseAmount: number;
|
|
101
|
-
taxAmount: number;
|
|
102
|
-
totalAmount: number;
|
|
103
|
-
pricesIncludeTax: boolean;
|
|
104
|
-
type: 'collected' | 'paid' | 'exempt';
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
interface MonetizationCreateOutput {
|
|
108
|
-
transactionId?: string;
|
|
109
|
-
subscriptionId?: string;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Data passed to payment.create hooks
|
|
113
|
-
*/
|
|
114
|
-
interface PaymentCreateInput {
|
|
115
|
-
transactionId: string;
|
|
116
|
-
amount: number;
|
|
117
|
-
currency: string;
|
|
118
|
-
gateway: string;
|
|
119
|
-
paymentData?: Record<string, unknown>;
|
|
120
|
-
metadata?: Record<string, unknown>;
|
|
121
|
-
}
|
|
122
|
-
interface PaymentCreateOutput {
|
|
123
|
-
paymentIntentId: string;
|
|
124
|
-
clientSecret?: string;
|
|
125
|
-
}
|
|
126
|
-
interface PaymentVerifyInput {
|
|
127
|
-
id: string;
|
|
128
|
-
verifiedBy?: string;
|
|
129
|
-
}
|
|
130
|
-
interface PaymentVerifyOutput {
|
|
131
|
-
verified: boolean;
|
|
132
|
-
}
|
|
133
|
-
interface RefundInput {
|
|
134
|
-
transactionId: string;
|
|
135
|
-
amount?: number;
|
|
136
|
-
reason?: string;
|
|
137
|
-
}
|
|
138
|
-
interface RefundOutput {
|
|
139
|
-
refundId: string;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Data passed to subscription.create hooks
|
|
143
|
-
* Note: subscriptionId is undefined in .before hook (not yet created)
|
|
144
|
-
* and populated in .after hook (already created)
|
|
145
|
-
*/
|
|
146
|
-
interface SubscriptionCreateInput {
|
|
147
|
-
subscriptionId?: string;
|
|
148
|
-
planKey: string;
|
|
149
|
-
customerId?: string;
|
|
150
|
-
organizationId?: string;
|
|
151
|
-
entity?: string | null;
|
|
152
|
-
}
|
|
153
|
-
interface SubscriptionCreateOutput {
|
|
154
|
-
subscription: unknown;
|
|
155
|
-
transaction?: unknown;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Data passed to subscription.activate hooks
|
|
159
|
-
*/
|
|
160
|
-
interface SubscriptionActivateInput {
|
|
161
|
-
subscriptionId: string;
|
|
162
|
-
transactionId?: string;
|
|
163
|
-
activatedAt?: Date;
|
|
164
|
-
}
|
|
165
|
-
interface SubscriptionActivateOutput {
|
|
166
|
-
activated: boolean;
|
|
167
|
-
activatedAt: Date;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Data passed to subscription.cancel hooks
|
|
171
|
-
*/
|
|
172
|
-
interface SubscriptionCancelInput {
|
|
173
|
-
subscriptionId: string;
|
|
174
|
-
immediate?: boolean;
|
|
175
|
-
reason?: string;
|
|
176
|
-
}
|
|
177
|
-
interface SubscriptionCancelOutput {
|
|
178
|
-
cancelled: boolean;
|
|
179
|
-
effectiveDate?: Date;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Data passed to subscription.pause hooks
|
|
183
|
-
*/
|
|
184
|
-
interface SubscriptionPauseInput {
|
|
185
|
-
subscriptionId: string;
|
|
186
|
-
reason?: string;
|
|
187
|
-
}
|
|
188
|
-
interface SubscriptionPauseOutput {
|
|
189
|
-
paused: boolean;
|
|
190
|
-
pausedAt: Date;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Data passed to subscription.resume hooks
|
|
194
|
-
*/
|
|
195
|
-
interface SubscriptionResumeInput {
|
|
196
|
-
subscriptionId: string;
|
|
197
|
-
extendPeriod?: boolean;
|
|
198
|
-
}
|
|
199
|
-
interface SubscriptionResumeOutput {
|
|
200
|
-
resumed: boolean;
|
|
201
|
-
resumedAt: Date;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Data passed to transaction.create hooks
|
|
205
|
-
*/
|
|
206
|
-
interface TransactionCreateInput {
|
|
207
|
-
amount: number;
|
|
208
|
-
currency: string;
|
|
209
|
-
type: string;
|
|
210
|
-
organizationId?: string;
|
|
211
|
-
customerId?: string;
|
|
212
|
-
metadata?: Record<string, unknown>;
|
|
213
|
-
}
|
|
214
|
-
interface TransactionCreateOutput {
|
|
215
|
-
transactionId: string;
|
|
216
|
-
}
|
|
217
|
-
interface TransactionUpdateInput {
|
|
218
|
-
transactionId: string;
|
|
219
|
-
updates: Record<string, unknown>;
|
|
220
|
-
}
|
|
221
|
-
interface TransactionUpdateOutput {
|
|
222
|
-
transaction: unknown;
|
|
223
|
-
}
|
|
224
|
-
interface EscrowHoldInput {
|
|
225
|
-
transactionId: string;
|
|
226
|
-
reason?: string;
|
|
227
|
-
}
|
|
228
|
-
interface EscrowHoldOutput {
|
|
229
|
-
held: boolean;
|
|
230
|
-
}
|
|
231
|
-
interface EscrowReleaseInput {
|
|
232
|
-
transactionId: string;
|
|
233
|
-
recipientId?: string;
|
|
234
|
-
recipientType?: string;
|
|
235
|
-
}
|
|
236
|
-
interface EscrowReleaseOutput {
|
|
237
|
-
released: boolean;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Plugin definition
|
|
241
|
-
*/
|
|
242
|
-
interface RevenuePlugin {
|
|
243
|
-
/** Unique plugin name */
|
|
244
|
-
name: string;
|
|
245
|
-
/** Plugin version */
|
|
246
|
-
version?: string;
|
|
247
|
-
/** Plugin description */
|
|
248
|
-
description?: string;
|
|
249
|
-
/** Dependencies on other plugins */
|
|
250
|
-
dependencies?: string[];
|
|
251
|
-
/** Hook implementations */
|
|
252
|
-
hooks?: Partial<PluginHooks>;
|
|
253
|
-
/** Event listeners */
|
|
254
|
-
events?: Partial<{
|
|
255
|
-
[K in keyof RevenueEvents]: (event: RevenueEvents[K]) => void | Promise<void>;
|
|
256
|
-
}>;
|
|
257
|
-
/** Initialize plugin */
|
|
258
|
-
init?: (ctx: PluginContext) => void | Promise<void>;
|
|
259
|
-
/** Cleanup plugin */
|
|
260
|
-
destroy?: () => void | Promise<void>;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Plugin manager - handles registration and execution
|
|
264
|
-
*/
|
|
265
|
-
declare class PluginManager {
|
|
266
|
-
private plugins;
|
|
267
|
-
private hooks;
|
|
268
|
-
private initialized;
|
|
269
|
-
/**
|
|
270
|
-
* Register a plugin
|
|
271
|
-
*/
|
|
272
|
-
register(plugin: RevenuePlugin): this;
|
|
273
|
-
/**
|
|
274
|
-
* Initialize all plugins
|
|
275
|
-
*/
|
|
276
|
-
init(ctx: PluginContext): Promise<void>;
|
|
277
|
-
/**
|
|
278
|
-
* Execute a hook chain
|
|
279
|
-
*/
|
|
280
|
-
executeHook<TInput, TOutput>(hookName: string, ctx: PluginContext, input: TInput, execute: () => Promise<TOutput>): Promise<TOutput>;
|
|
281
|
-
/**
|
|
282
|
-
* Check if plugin is registered
|
|
283
|
-
*/
|
|
284
|
-
has(name: string): boolean;
|
|
285
|
-
/**
|
|
286
|
-
* Get a plugin by name
|
|
287
|
-
*/
|
|
288
|
-
get(name: string): RevenuePlugin | undefined;
|
|
289
|
-
/**
|
|
290
|
-
* Get all registered plugins
|
|
291
|
-
*/
|
|
292
|
-
list(): RevenuePlugin[];
|
|
293
|
-
/**
|
|
294
|
-
* Destroy all plugins
|
|
295
|
-
*/
|
|
296
|
-
destroy(): Promise<void>;
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Logging plugin - logs all operations
|
|
300
|
-
*/
|
|
301
|
-
declare function loggingPlugin(options?: {
|
|
302
|
-
level?: 'debug' | 'info';
|
|
303
|
-
}): RevenuePlugin;
|
|
304
|
-
/**
|
|
305
|
-
* Audit plugin - records all operations for compliance
|
|
306
|
-
*/
|
|
307
|
-
declare function auditPlugin(options?: {
|
|
308
|
-
store?: (entry: AuditEntry) => Promise<void>;
|
|
309
|
-
}): RevenuePlugin;
|
|
310
|
-
interface AuditEntry {
|
|
311
|
-
action: string;
|
|
312
|
-
requestId: string;
|
|
313
|
-
timestamp: Date;
|
|
314
|
-
input: Record<string, unknown>;
|
|
315
|
-
output: Record<string, unknown>;
|
|
316
|
-
idempotencyKey?: string;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Metrics plugin - collects operation metrics
|
|
320
|
-
*/
|
|
321
|
-
declare function metricsPlugin(options?: {
|
|
322
|
-
onMetric?: (metric: Metric) => void;
|
|
323
|
-
}): RevenuePlugin;
|
|
324
|
-
interface Metric {
|
|
325
|
-
name: string;
|
|
326
|
-
duration: number;
|
|
327
|
-
success: boolean;
|
|
328
|
-
error?: string;
|
|
329
|
-
[key: string]: unknown;
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Create a custom plugin
|
|
333
|
-
*/
|
|
334
|
-
declare function definePlugin(plugin: RevenuePlugin): RevenuePlugin;
|
|
335
|
-
|
|
336
|
-
export { type HookFn as H, type PluginLogger as P, type RevenuePlugin as R, type PluginContext as a, PluginManager as b, auditPlugin as c, definePlugin as d, type PluginHooks as e, loggingPlugin as l, metricsPlugin as m };
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { l as CreateIntentParams, P as PaymentIntentData, b as PaymentResultData, m as RefundResultData, W as WebhookEventData, n as ProviderCapabilities } from '../index-cLJBLUvx.js';
|
|
2
|
-
import 'mongoose';
|
|
3
|
-
import '@classytic/shared-types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Payment Provider Base Class
|
|
7
|
-
* @classytic/revenue
|
|
8
|
-
*
|
|
9
|
-
* Abstract base class for all payment providers
|
|
10
|
-
* Inspired by: Vercel AI SDK, Stripe SDK
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Payment Intent - standardized response from createIntent
|
|
15
|
-
*/
|
|
16
|
-
declare class PaymentIntent implements PaymentIntentData {
|
|
17
|
-
readonly id: string;
|
|
18
|
-
readonly sessionId: string | null;
|
|
19
|
-
readonly paymentIntentId: string | null;
|
|
20
|
-
readonly provider: string;
|
|
21
|
-
readonly status: string;
|
|
22
|
-
readonly amount: number;
|
|
23
|
-
readonly currency?: string;
|
|
24
|
-
readonly metadata: Record<string, unknown>;
|
|
25
|
-
readonly clientSecret?: string;
|
|
26
|
-
readonly paymentUrl?: string;
|
|
27
|
-
readonly instructions?: string;
|
|
28
|
-
readonly raw?: unknown;
|
|
29
|
-
constructor(data: PaymentIntentData);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Payment Result - standardized response from verifyPayment
|
|
33
|
-
*/
|
|
34
|
-
declare class PaymentResult implements PaymentResultData {
|
|
35
|
-
readonly id: string;
|
|
36
|
-
readonly provider: string;
|
|
37
|
-
readonly status: 'succeeded' | 'failed' | 'processing' | 'requires_action';
|
|
38
|
-
readonly amount?: number;
|
|
39
|
-
readonly currency?: string;
|
|
40
|
-
readonly paidAt?: Date;
|
|
41
|
-
readonly metadata: Record<string, unknown>;
|
|
42
|
-
readonly raw?: unknown;
|
|
43
|
-
constructor(data: PaymentResultData);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Refund Result - standardized response from refund
|
|
47
|
-
*/
|
|
48
|
-
declare class RefundResult implements RefundResultData {
|
|
49
|
-
readonly id: string;
|
|
50
|
-
readonly provider: string;
|
|
51
|
-
readonly status: 'succeeded' | 'failed' | 'processing';
|
|
52
|
-
readonly amount?: number;
|
|
53
|
-
readonly currency?: string;
|
|
54
|
-
readonly refundedAt?: Date;
|
|
55
|
-
readonly reason?: string;
|
|
56
|
-
readonly metadata: Record<string, unknown>;
|
|
57
|
-
readonly raw?: unknown;
|
|
58
|
-
constructor(data: RefundResultData);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Webhook Event - standardized webhook event
|
|
62
|
-
*/
|
|
63
|
-
declare class WebhookEvent implements WebhookEventData {
|
|
64
|
-
readonly id: string;
|
|
65
|
-
readonly provider: string;
|
|
66
|
-
readonly type: string;
|
|
67
|
-
readonly data: {
|
|
68
|
-
sessionId?: string;
|
|
69
|
-
paymentIntentId?: string;
|
|
70
|
-
[key: string]: unknown;
|
|
71
|
-
};
|
|
72
|
-
readonly createdAt?: Date;
|
|
73
|
-
readonly raw?: unknown;
|
|
74
|
-
constructor(data: WebhookEventData);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Base Payment Provider
|
|
78
|
-
* All payment providers must extend this class
|
|
79
|
-
*/
|
|
80
|
-
declare abstract class PaymentProvider {
|
|
81
|
-
readonly config: Record<string, unknown>;
|
|
82
|
-
readonly name: string;
|
|
83
|
-
/** Default currency - injected by Revenue when provider is registered */
|
|
84
|
-
private _defaultCurrency;
|
|
85
|
-
constructor(config?: Record<string, unknown>);
|
|
86
|
-
/**
|
|
87
|
-
* Get the default currency for this provider
|
|
88
|
-
* Used when creating PaymentIntent, PaymentResult, RefundResult without explicit currency
|
|
89
|
-
*/
|
|
90
|
-
get defaultCurrency(): string;
|
|
91
|
-
/**
|
|
92
|
-
* Set the default currency (called by Revenue when registering provider)
|
|
93
|
-
* @internal
|
|
94
|
-
*/
|
|
95
|
-
setDefaultCurrency(currency: string): void;
|
|
96
|
-
/**
|
|
97
|
-
* Create a payment intent
|
|
98
|
-
* @param params - Payment parameters
|
|
99
|
-
* @returns Promise<PaymentIntent>
|
|
100
|
-
*/
|
|
101
|
-
abstract createIntent(params: CreateIntentParams): Promise<PaymentIntent>;
|
|
102
|
-
/**
|
|
103
|
-
* Verify a payment
|
|
104
|
-
* @param intentId - Payment intent ID
|
|
105
|
-
* @returns Promise<PaymentResult>
|
|
106
|
-
*/
|
|
107
|
-
abstract verifyPayment(intentId: string): Promise<PaymentResult>;
|
|
108
|
-
/**
|
|
109
|
-
* Get payment status
|
|
110
|
-
* @param intentId - Payment intent ID
|
|
111
|
-
* @returns Promise<PaymentResult>
|
|
112
|
-
*/
|
|
113
|
-
abstract getStatus(intentId: string): Promise<PaymentResult>;
|
|
114
|
-
/**
|
|
115
|
-
* Refund a payment
|
|
116
|
-
* @param paymentId - Payment ID
|
|
117
|
-
* @param amount - Amount to refund (optional, full refund if not provided)
|
|
118
|
-
* @param options - Refund options
|
|
119
|
-
* @returns Promise<RefundResult>
|
|
120
|
-
*/
|
|
121
|
-
abstract refund(paymentId: string, amount?: number | null, options?: {
|
|
122
|
-
reason?: string;
|
|
123
|
-
}): Promise<RefundResult>;
|
|
124
|
-
/**
|
|
125
|
-
* Handle webhook from provider
|
|
126
|
-
* @param payload - Webhook payload
|
|
127
|
-
* @param headers - Request headers (for signature verification)
|
|
128
|
-
* @returns Promise<WebhookEvent>
|
|
129
|
-
*/
|
|
130
|
-
abstract handleWebhook(payload: unknown, headers?: Record<string, string>): Promise<WebhookEvent>;
|
|
131
|
-
/**
|
|
132
|
-
* Verify webhook signature (optional)
|
|
133
|
-
* @param payload - Webhook payload
|
|
134
|
-
* @param signature - Webhook signature
|
|
135
|
-
* @returns boolean
|
|
136
|
-
*/
|
|
137
|
-
verifyWebhookSignature(_payload: unknown, _signature: string): boolean;
|
|
138
|
-
/**
|
|
139
|
-
* Get provider capabilities
|
|
140
|
-
* @returns ProviderCapabilities
|
|
141
|
-
*/
|
|
142
|
-
getCapabilities(): ProviderCapabilities;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export { CreateIntentParams, PaymentIntent, PaymentIntentData, PaymentProvider, PaymentProvider as PaymentProviderDefault, PaymentResult, PaymentResultData, ProviderCapabilities, RefundResult, RefundResultData, WebhookEvent, WebhookEventData };
|
package/dist/providers/index.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
// @classytic/revenue - Enterprise Revenue Management System
|
|
2
|
-
|
|
3
|
-
// src/providers/base.ts
|
|
4
|
-
var PaymentIntent = class {
|
|
5
|
-
id;
|
|
6
|
-
sessionId;
|
|
7
|
-
paymentIntentId;
|
|
8
|
-
provider;
|
|
9
|
-
status;
|
|
10
|
-
amount;
|
|
11
|
-
currency;
|
|
12
|
-
metadata;
|
|
13
|
-
clientSecret;
|
|
14
|
-
paymentUrl;
|
|
15
|
-
instructions;
|
|
16
|
-
raw;
|
|
17
|
-
constructor(data) {
|
|
18
|
-
this.id = data.id;
|
|
19
|
-
this.sessionId = data.sessionId ?? null;
|
|
20
|
-
this.paymentIntentId = data.paymentIntentId ?? null;
|
|
21
|
-
this.provider = data.provider;
|
|
22
|
-
this.status = data.status;
|
|
23
|
-
this.amount = data.amount;
|
|
24
|
-
this.currency = data.currency;
|
|
25
|
-
this.metadata = data.metadata ?? {};
|
|
26
|
-
this.clientSecret = data.clientSecret;
|
|
27
|
-
this.paymentUrl = data.paymentUrl;
|
|
28
|
-
this.instructions = data.instructions;
|
|
29
|
-
this.raw = data.raw;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var PaymentResult = class {
|
|
33
|
-
id;
|
|
34
|
-
provider;
|
|
35
|
-
status;
|
|
36
|
-
amount;
|
|
37
|
-
currency;
|
|
38
|
-
paidAt;
|
|
39
|
-
metadata;
|
|
40
|
-
raw;
|
|
41
|
-
constructor(data) {
|
|
42
|
-
this.id = data.id;
|
|
43
|
-
this.provider = data.provider;
|
|
44
|
-
this.status = data.status;
|
|
45
|
-
this.amount = data.amount;
|
|
46
|
-
this.currency = data.currency;
|
|
47
|
-
this.paidAt = data.paidAt;
|
|
48
|
-
this.metadata = data.metadata ?? {};
|
|
49
|
-
this.raw = data.raw;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var RefundResult = class {
|
|
53
|
-
id;
|
|
54
|
-
provider;
|
|
55
|
-
status;
|
|
56
|
-
amount;
|
|
57
|
-
currency;
|
|
58
|
-
refundedAt;
|
|
59
|
-
reason;
|
|
60
|
-
metadata;
|
|
61
|
-
raw;
|
|
62
|
-
constructor(data) {
|
|
63
|
-
this.id = data.id;
|
|
64
|
-
this.provider = data.provider;
|
|
65
|
-
this.status = data.status;
|
|
66
|
-
this.amount = data.amount;
|
|
67
|
-
this.currency = data.currency;
|
|
68
|
-
this.refundedAt = data.refundedAt;
|
|
69
|
-
this.reason = data.reason;
|
|
70
|
-
this.metadata = data.metadata ?? {};
|
|
71
|
-
this.raw = data.raw;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var WebhookEvent = class {
|
|
75
|
-
id;
|
|
76
|
-
provider;
|
|
77
|
-
type;
|
|
78
|
-
data;
|
|
79
|
-
createdAt;
|
|
80
|
-
raw;
|
|
81
|
-
constructor(data) {
|
|
82
|
-
this.id = data.id;
|
|
83
|
-
this.provider = data.provider;
|
|
84
|
-
this.type = data.type;
|
|
85
|
-
this.data = data.data;
|
|
86
|
-
this.createdAt = data.createdAt;
|
|
87
|
-
this.raw = data.raw;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
var PaymentProvider = class {
|
|
91
|
-
config;
|
|
92
|
-
name;
|
|
93
|
-
/** Default currency - injected by Revenue when provider is registered */
|
|
94
|
-
_defaultCurrency = "USD";
|
|
95
|
-
constructor(config = {}) {
|
|
96
|
-
this.config = config;
|
|
97
|
-
this.name = "base";
|
|
98
|
-
if (config.defaultCurrency && typeof config.defaultCurrency === "string") {
|
|
99
|
-
this._defaultCurrency = config.defaultCurrency;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Get the default currency for this provider
|
|
104
|
-
* Used when creating PaymentIntent, PaymentResult, RefundResult without explicit currency
|
|
105
|
-
*/
|
|
106
|
-
get defaultCurrency() {
|
|
107
|
-
return this._defaultCurrency;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Set the default currency (called by Revenue when registering provider)
|
|
111
|
-
* @internal
|
|
112
|
-
*/
|
|
113
|
-
setDefaultCurrency(currency) {
|
|
114
|
-
this._defaultCurrency = currency;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Verify webhook signature (optional)
|
|
118
|
-
* @param payload - Webhook payload
|
|
119
|
-
* @param signature - Webhook signature
|
|
120
|
-
* @returns boolean
|
|
121
|
-
*/
|
|
122
|
-
verifyWebhookSignature(_payload, _signature) {
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get provider capabilities
|
|
127
|
-
* @returns ProviderCapabilities
|
|
128
|
-
*/
|
|
129
|
-
getCapabilities() {
|
|
130
|
-
return {
|
|
131
|
-
supportsWebhooks: false,
|
|
132
|
-
supportsRefunds: false,
|
|
133
|
-
supportsPartialRefunds: false,
|
|
134
|
-
requiresManualVerification: true
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export { PaymentIntent, PaymentProvider, PaymentResult, RefundResult, WebhookEvent };
|
|
140
|
-
//# sourceMappingURL=index.js.map
|
|
141
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/providers/base.ts"],"names":[],"mappings":"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","file":"index.js","sourcesContent":["/**\n * Payment Provider Base Class\n * @classytic/revenue\n *\n * Abstract base class for all payment providers\n * Inspired by: Vercel AI SDK, Stripe SDK\n */\n\nimport type {\n CreateIntentParams,\n PaymentIntentData,\n PaymentResultData,\n RefundResultData,\n WebhookEventData,\n ProviderCapabilities,\n} from '../shared/types/index.js';\n\n/**\n * Payment Intent - standardized response from createIntent\n */\nexport class PaymentIntent implements PaymentIntentData {\n public readonly id: string;\n public readonly sessionId: string | null;\n public readonly paymentIntentId: string | null;\n public readonly provider: string;\n public readonly status: string;\n public readonly amount: number;\n public readonly currency?: string;\n public readonly metadata: Record<string, unknown>;\n public readonly clientSecret?: string;\n public readonly paymentUrl?: string;\n public readonly instructions?: string;\n public readonly raw?: unknown;\n\n constructor(data: PaymentIntentData) {\n this.id = data.id;\n this.sessionId = data.sessionId ?? null;\n this.paymentIntentId = data.paymentIntentId ?? null;\n this.provider = data.provider;\n this.status = data.status;\n this.amount = data.amount;\n this.currency = data.currency; // Don't default - use app's defaultCurrency config\n this.metadata = data.metadata ?? {};\n this.clientSecret = data.clientSecret;\n this.paymentUrl = data.paymentUrl;\n this.instructions = data.instructions;\n this.raw = data.raw;\n }\n}\n\n/**\n * Payment Result - standardized response from verifyPayment\n */\nexport class PaymentResult implements PaymentResultData {\n public readonly id: string;\n public readonly provider: string;\n public readonly status: 'succeeded' | 'failed' | 'processing' | 'requires_action';\n public readonly amount?: number;\n public readonly currency?: string;\n public readonly paidAt?: Date;\n public readonly metadata: Record<string, unknown>;\n public readonly raw?: unknown;\n\n constructor(data: PaymentResultData) {\n this.id = data.id;\n this.provider = data.provider;\n this.status = data.status;\n this.amount = data.amount;\n this.currency = data.currency; // Don't default - let transaction's currency be used\n this.paidAt = data.paidAt;\n this.metadata = data.metadata ?? {};\n this.raw = data.raw;\n }\n}\n\n/**\n * Refund Result - standardized response from refund\n */\nexport class RefundResult implements RefundResultData {\n public readonly id: string;\n public readonly provider: string;\n public readonly status: 'succeeded' | 'failed' | 'processing';\n public readonly amount?: number;\n public readonly currency?: string;\n public readonly refundedAt?: Date;\n public readonly reason?: string;\n public readonly metadata: Record<string, unknown>;\n public readonly raw?: unknown;\n\n constructor(data: RefundResultData) {\n this.id = data.id;\n this.provider = data.provider;\n this.status = data.status;\n this.amount = data.amount;\n this.currency = data.currency; // Don't default - let transaction's currency be used\n this.refundedAt = data.refundedAt;\n this.reason = data.reason;\n this.metadata = data.metadata ?? {};\n this.raw = data.raw;\n }\n}\n\n/**\n * Webhook Event - standardized webhook event\n */\nexport class WebhookEvent implements WebhookEventData {\n public readonly id: string;\n public readonly provider: string;\n public readonly type: string;\n public readonly data: { sessionId?: string; paymentIntentId?: string; [key: string]: unknown };\n public readonly createdAt?: Date;\n public readonly raw?: unknown;\n\n constructor(data: WebhookEventData) {\n this.id = data.id;\n this.provider = data.provider;\n this.type = data.type;\n this.data = data.data;\n this.createdAt = data.createdAt;\n this.raw = data.raw;\n }\n}\n\n/**\n * Base Payment Provider\n * All payment providers must extend this class\n */\nexport abstract class PaymentProvider {\n public readonly config: Record<string, unknown>;\n public readonly name: string;\n\n /** Default currency - injected by Revenue when provider is registered */\n private _defaultCurrency: string = 'USD';\n\n constructor(config: Record<string, unknown> = {}) {\n this.config = config;\n this.name = 'base'; // Override in subclass\n\n // Allow defaultCurrency to be passed via config\n if (config.defaultCurrency && typeof config.defaultCurrency === 'string') {\n this._defaultCurrency = config.defaultCurrency;\n }\n }\n\n /**\n * Get the default currency for this provider\n * Used when creating PaymentIntent, PaymentResult, RefundResult without explicit currency\n */\n get defaultCurrency(): string {\n return this._defaultCurrency;\n }\n\n /**\n * Set the default currency (called by Revenue when registering provider)\n * @internal\n */\n setDefaultCurrency(currency: string): void {\n this._defaultCurrency = currency;\n }\n\n /**\n * Create a payment intent\n * @param params - Payment parameters\n * @returns Promise<PaymentIntent>\n */\n abstract createIntent(params: CreateIntentParams): Promise<PaymentIntent>;\n\n /**\n * Verify a payment\n * @param intentId - Payment intent ID\n * @returns Promise<PaymentResult>\n */\n abstract verifyPayment(intentId: string): Promise<PaymentResult>;\n\n /**\n * Get payment status\n * @param intentId - Payment intent ID\n * @returns Promise<PaymentResult>\n */\n abstract getStatus(intentId: string): Promise<PaymentResult>;\n\n /**\n * Refund a payment\n * @param paymentId - Payment ID\n * @param amount - Amount to refund (optional, full refund if not provided)\n * @param options - Refund options\n * @returns Promise<RefundResult>\n */\n abstract refund(\n paymentId: string,\n amount?: number | null,\n options?: { reason?: string }\n ): Promise<RefundResult>;\n\n /**\n * Handle webhook from provider\n * @param payload - Webhook payload\n * @param headers - Request headers (for signature verification)\n * @returns Promise<WebhookEvent>\n */\n abstract handleWebhook(\n payload: unknown,\n headers?: Record<string, string>\n ): Promise<WebhookEvent>;\n\n /**\n * Verify webhook signature (optional)\n * @param payload - Webhook payload\n * @param signature - Webhook signature\n * @returns boolean\n */\n verifyWebhookSignature(_payload: unknown, _signature: string): boolean {\n // Override in subclass if provider supports webhook signatures\n return true;\n }\n\n /**\n * Get provider capabilities\n * @returns ProviderCapabilities\n */\n getCapabilities(): ProviderCapabilities {\n return {\n supportsWebhooks: false,\n supportsRefunds: false,\n supportsPartialRefunds: false,\n requiresManualVerification: true,\n };\n }\n}\n\nexport default PaymentProvider;\n\n"]}
|