@moneymq/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,418 @@
1
+ interface Product {
2
+ id: string;
3
+ object: 'product';
4
+ name: string;
5
+ description?: string;
6
+ active: boolean;
7
+ metadata?: Record<string, string>;
8
+ created: number;
9
+ updated: number;
10
+ }
11
+ interface ProductCreateParams {
12
+ name: string;
13
+ description?: string;
14
+ active?: boolean;
15
+ metadata?: Record<string, string>;
16
+ }
17
+ interface ProductListParams {
18
+ active?: boolean;
19
+ limit?: number;
20
+ startingAfter?: string;
21
+ }
22
+ interface Price {
23
+ id: string;
24
+ object: 'price';
25
+ product: string;
26
+ currency: string;
27
+ amount: number;
28
+ type: 'one_time' | 'recurring';
29
+ recurring?: {
30
+ interval: 'day' | 'week' | 'month' | 'year';
31
+ intervalCount: number;
32
+ };
33
+ active: boolean;
34
+ metadata?: Record<string, string>;
35
+ created: number;
36
+ }
37
+ interface PriceCreateParams {
38
+ product: string;
39
+ currency: string;
40
+ amount: number;
41
+ type: 'one_time' | 'recurring';
42
+ recurring?: {
43
+ interval: 'day' | 'week' | 'month' | 'year';
44
+ intervalCount?: number;
45
+ };
46
+ metadata?: Record<string, string>;
47
+ }
48
+ declare class ProductsAPI {
49
+ private config;
50
+ constructor(config: MoneyMQConfig);
51
+ private request;
52
+ /**
53
+ * Create a new product
54
+ */
55
+ create(params: ProductCreateParams): Promise<Product>;
56
+ /**
57
+ * Retrieve a product by ID
58
+ */
59
+ retrieve(id: string): Promise<Product>;
60
+ /**
61
+ * List all products
62
+ */
63
+ list(params?: ProductListParams): Promise<{
64
+ data: Product[];
65
+ hasMore: boolean;
66
+ }>;
67
+ /**
68
+ * Update a product
69
+ */
70
+ update(id: string, params: Partial<ProductCreateParams>): Promise<Product>;
71
+ /**
72
+ * Delete a product
73
+ */
74
+ delete(id: string): Promise<{
75
+ deleted: boolean;
76
+ }>;
77
+ }
78
+ declare class PricesAPI {
79
+ private config;
80
+ constructor(config: MoneyMQConfig);
81
+ private request;
82
+ /**
83
+ * Create a new price
84
+ */
85
+ create(params: PriceCreateParams): Promise<Price>;
86
+ /**
87
+ * Retrieve a price by ID
88
+ */
89
+ retrieve(id: string): Promise<Price>;
90
+ /**
91
+ * List all prices
92
+ */
93
+ list(params?: {
94
+ product?: string;
95
+ active?: boolean;
96
+ limit?: number;
97
+ }): Promise<{
98
+ data: Price[];
99
+ hasMore: boolean;
100
+ }>;
101
+ }
102
+ /**
103
+ * Catalog API for managing products and prices
104
+ */
105
+ declare class CatalogAPI {
106
+ /** Products API */
107
+ readonly products: ProductsAPI;
108
+ /** Prices API */
109
+ readonly prices: PricesAPI;
110
+ constructor(config: MoneyMQConfig);
111
+ }
112
+
113
+ interface LineItem {
114
+ price: string;
115
+ quantity: number;
116
+ }
117
+ interface CheckoutSession {
118
+ id: string;
119
+ object: 'checkout.session';
120
+ url: string;
121
+ status: 'open' | 'complete' | 'expired';
122
+ paymentStatus: 'unpaid' | 'paid';
123
+ customer?: string;
124
+ lineItems: LineItem[];
125
+ successUrl: string;
126
+ cancelUrl: string;
127
+ expiresAt: number;
128
+ created: number;
129
+ }
130
+ interface CheckoutCreateParams {
131
+ lineItems: LineItem[];
132
+ successUrl: string;
133
+ cancelUrl: string;
134
+ customerEmail?: string;
135
+ customer?: string;
136
+ metadata?: Record<string, string>;
137
+ }
138
+ interface PaymentLink {
139
+ id: string;
140
+ object: 'payment_link';
141
+ url: string;
142
+ active: boolean;
143
+ lineItems: LineItem[];
144
+ expiresAt?: number;
145
+ created: number;
146
+ }
147
+ interface PaymentLinkCreateParams {
148
+ lineItems: LineItem[];
149
+ expiresAt?: Date | number;
150
+ metadata?: Record<string, string>;
151
+ }
152
+ interface Payment {
153
+ id: string;
154
+ object: 'payment';
155
+ amount: number;
156
+ currency: string;
157
+ status: 'completed' | 'pending' | 'failed';
158
+ customer?: string;
159
+ checkout?: string;
160
+ signature?: string;
161
+ metadata?: Record<string, string>;
162
+ created: number;
163
+ }
164
+ interface PaymentListParams {
165
+ customerId?: string;
166
+ status?: 'completed' | 'pending' | 'failed';
167
+ limit?: number;
168
+ startingAfter?: string;
169
+ }
170
+ interface Customer {
171
+ id: string;
172
+ object: 'customer';
173
+ email: string;
174
+ name?: string;
175
+ metadata?: Record<string, string>;
176
+ subscriptions?: unknown[];
177
+ payments?: Payment[];
178
+ created: number;
179
+ }
180
+ interface CustomerCreateParams {
181
+ email: string;
182
+ name?: string;
183
+ metadata?: Record<string, string>;
184
+ }
185
+ interface CustomerUpdateParams {
186
+ email?: string;
187
+ name?: string;
188
+ metadata?: Record<string, string>;
189
+ }
190
+ interface Payout {
191
+ id: string;
192
+ object: 'payout';
193
+ amount: number;
194
+ currency: string;
195
+ status: 'pending' | 'completed' | 'failed';
196
+ destination: string;
197
+ created: number;
198
+ }
199
+ interface PayoutCreateParams {
200
+ amount: number;
201
+ currency: string;
202
+ destination: string;
203
+ }
204
+ interface PayoutListParams {
205
+ status?: 'pending' | 'completed' | 'failed';
206
+ limit?: number;
207
+ startingAfter?: string;
208
+ }
209
+ interface PayoutSettings {
210
+ destination: {
211
+ type: 'wallet';
212
+ address: string;
213
+ currency: string;
214
+ };
215
+ schedule: 'instant' | 'daily' | 'weekly' | 'monthly';
216
+ minimumAmount?: number;
217
+ }
218
+ interface PayoutSettingsUpdateParams {
219
+ destination?: PayoutSettings['destination'];
220
+ schedule?: PayoutSettings['schedule'];
221
+ minimumAmount?: number;
222
+ }
223
+ declare class CheckoutAPI {
224
+ private request;
225
+ constructor(config: MoneyMQConfig);
226
+ /**
227
+ * Create a checkout session
228
+ */
229
+ create(params: CheckoutCreateParams): Promise<CheckoutSession>;
230
+ /**
231
+ * Retrieve a checkout session
232
+ */
233
+ retrieve(id: string): Promise<CheckoutSession>;
234
+ }
235
+ declare class LinksAPI {
236
+ private request;
237
+ constructor(config: MoneyMQConfig);
238
+ /**
239
+ * Create a payment link
240
+ */
241
+ create(params: PaymentLinkCreateParams): Promise<PaymentLink>;
242
+ /**
243
+ * Retrieve a payment link
244
+ */
245
+ retrieve(id: string): Promise<PaymentLink>;
246
+ /**
247
+ * Deactivate a payment link
248
+ */
249
+ deactivate(id: string): Promise<PaymentLink>;
250
+ }
251
+ declare class CustomersAPI {
252
+ private request;
253
+ constructor(config: MoneyMQConfig);
254
+ /**
255
+ * Create a customer
256
+ */
257
+ create(params: CustomerCreateParams): Promise<Customer>;
258
+ /**
259
+ * Retrieve a customer
260
+ */
261
+ retrieve(id: string, options?: {
262
+ expand?: string[];
263
+ }): Promise<Customer>;
264
+ /**
265
+ * Update a customer
266
+ */
267
+ update(id: string, params: CustomerUpdateParams): Promise<Customer>;
268
+ /**
269
+ * List customers
270
+ */
271
+ list(params?: {
272
+ email?: string;
273
+ limit?: number;
274
+ }): Promise<{
275
+ data: Customer[];
276
+ hasMore: boolean;
277
+ }>;
278
+ }
279
+ declare class PayoutsAPI {
280
+ private request;
281
+ /** Payout settings */
282
+ readonly settings: PayoutSettingsAPI;
283
+ constructor(config: MoneyMQConfig);
284
+ /**
285
+ * Create a manual payout
286
+ */
287
+ create(params: PayoutCreateParams): Promise<Payout>;
288
+ /**
289
+ * Retrieve a payout
290
+ */
291
+ retrieve(id: string): Promise<Payout>;
292
+ /**
293
+ * List payouts
294
+ */
295
+ list(params?: PayoutListParams): Promise<{
296
+ data: Payout[];
297
+ hasMore: boolean;
298
+ }>;
299
+ }
300
+ declare class PayoutSettingsAPI {
301
+ private request;
302
+ constructor(config: MoneyMQConfig);
303
+ /**
304
+ * Get payout settings
305
+ */
306
+ retrieve(): Promise<PayoutSettings>;
307
+ /**
308
+ * Update payout settings
309
+ */
310
+ update(params: PayoutSettingsUpdateParams): Promise<PayoutSettings>;
311
+ }
312
+ declare class WebhooksAPI {
313
+ private request;
314
+ constructor(config: MoneyMQConfig);
315
+ /**
316
+ * Trigger a test webhook event (for testing)
317
+ */
318
+ trigger(event: string, data: Record<string, unknown>): Promise<{
319
+ success: boolean;
320
+ }>;
321
+ }
322
+ /**
323
+ * Payment API for checkout, links, customers, and payouts
324
+ */
325
+ declare class PaymentAPI {
326
+ private request;
327
+ /** Checkout sessions API */
328
+ readonly checkout: CheckoutAPI;
329
+ /** Payment links API */
330
+ readonly links: LinksAPI;
331
+ /** Customers API */
332
+ readonly customers: CustomersAPI;
333
+ /** Payouts API */
334
+ readonly payouts: PayoutsAPI;
335
+ /** Webhooks API */
336
+ readonly webhooks: WebhooksAPI;
337
+ constructor(config: MoneyMQConfig);
338
+ /**
339
+ * Retrieve a payment by ID
340
+ */
341
+ retrieve(id: string): Promise<Payment>;
342
+ /**
343
+ * List payments
344
+ */
345
+ list(params?: PaymentListParams): Promise<{
346
+ data: Payment[];
347
+ hasMore: boolean;
348
+ }>;
349
+ }
350
+
351
+ /**
352
+ * Configuration options for the MoneyMQ client
353
+ *
354
+ * @example
355
+ * ```typescript
356
+ * const config: MoneyMQConfig = {
357
+ * url: 'https://api.moneymq.com',
358
+ * secret: 'your-api-secret', // Optional
359
+ * timeout: 30000,
360
+ * };
361
+ * ```
362
+ */
363
+ interface MoneyMQConfig {
364
+ /**
365
+ * MoneyMQ API URL
366
+ * @example 'http://localhost:8488' or 'https://api.moneymq.com'
367
+ */
368
+ url: string;
369
+ /**
370
+ * Optional secret key for authenticated requests
371
+ * Used for server-side operations that require authentication
372
+ */
373
+ secret?: string;
374
+ /**
375
+ * Request timeout in milliseconds
376
+ * @default 30000
377
+ */
378
+ timeout?: number;
379
+ }
380
+ /**
381
+ * MoneyMQ SDK client for accepting stablecoin payments
382
+ *
383
+ * @example
384
+ * ```typescript
385
+ * import { MoneyMQ } from '@moneymq/sdk';
386
+ *
387
+ * const moneymq = new MoneyMQ({
388
+ * url: process.env.MONEYMQ_URL ?? 'http://localhost:8488',
389
+ * });
390
+ *
391
+ * // Create a product
392
+ * const product = await moneymq.catalog.products.create({
393
+ * name: 'Pro Plan',
394
+ * description: 'Full access to all features',
395
+ * });
396
+ *
397
+ * // Create a checkout session
398
+ * const session = await moneymq.payment.checkout.create({
399
+ * lineItems: [{ price: 'price_xxx', quantity: 1 }],
400
+ * successUrl: 'https://example.com/success',
401
+ * cancelUrl: 'https://example.com/cancel',
402
+ * });
403
+ * ```
404
+ */
405
+ declare class MoneyMQ {
406
+ private config;
407
+ /** Catalog API for products and prices */
408
+ readonly catalog: CatalogAPI;
409
+ /** Payment API for checkout, links, customers, and payouts */
410
+ readonly payment: PaymentAPI;
411
+ constructor(config: MoneyMQConfig);
412
+ /**
413
+ * Make an authenticated request to the MoneyMQ API
414
+ */
415
+ request<T>(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, body?: unknown): Promise<T>;
416
+ }
417
+
418
+ export { type CheckoutCreateParams, type CheckoutSession, type Customer, type CustomerCreateParams, type CustomerUpdateParams, MoneyMQ, type MoneyMQConfig, type Payment, type PaymentLink, type PaymentLinkCreateParams, type PaymentListParams, type Payout, type PayoutCreateParams, type PayoutListParams, type PayoutSettings, type PayoutSettingsUpdateParams, type Price, type PriceCreateParams, type Product, type ProductCreateParams, type ProductListParams };