@misterhomer1992/miit-bot-payment 1.0.7 → 1.0.8
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 +1 -359
- package/dist/modules/cancellableAPI/utils.d.ts +1 -2
- package/dist/modules/cancellableAPI/utils.d.ts.map +1 -1
- package/dist/modules/cancellableAPI/utils.js.map +1 -1
- package/dist/modules/invoice/repository.d.ts +0 -25
- package/dist/modules/invoice/repository.d.ts.map +1 -1
- package/dist/modules/invoice/repository.js +0 -25
- package/dist/modules/invoice/repository.js.map +1 -1
- package/dist/modules/invoice/service.d.ts +0 -21
- package/dist/modules/invoice/service.d.ts.map +1 -1
- package/dist/modules/invoice/service.js +0 -21
- package/dist/modules/invoice/service.js.map +1 -1
- package/dist/modules/invoice/types.d.ts +0 -8
- package/dist/modules/invoice/types.d.ts.map +1 -1
- package/dist/modules/payments/api.d.ts +3 -4
- package/dist/modules/payments/api.d.ts.map +1 -1
- package/dist/modules/payments/api.js +3 -3
- package/dist/modules/payments/api.js.map +1 -1
- package/dist/modules/payments/repository.d.ts +1 -59
- package/dist/modules/payments/repository.d.ts.map +1 -1
- package/dist/modules/payments/repository.js +2 -59
- package/dist/modules/payments/repository.js.map +1 -1
- package/dist/modules/payments/service.d.ts +2 -66
- package/dist/modules/payments/service.d.ts.map +1 -1
- package/dist/modules/payments/service.js +5 -68
- package/dist/modules/payments/service.js.map +1 -1
- package/dist/modules/payments/types.d.ts +4 -11
- package/dist/modules/payments/types.d.ts.map +1 -1
- package/dist/modules/payments/utils.d.ts +3 -4
- package/dist/modules/payments/utils.d.ts.map +1 -1
- package/dist/modules/payments/utils.js +6 -6
- package/dist/modules/payments/utils.js.map +1 -1
- package/dist/modules/subscription/repository.d.ts +4 -83
- package/dist/modules/subscription/repository.d.ts.map +1 -1
- package/dist/modules/subscription/repository.js +15 -109
- package/dist/modules/subscription/repository.js.map +1 -1
- package/dist/modules/subscription/service.d.ts +5 -89
- package/dist/modules/subscription/service.d.ts.map +1 -1
- package/dist/modules/subscription/service.js +7 -83
- package/dist/modules/subscription/service.js.map +1 -1
- package/dist/modules/subscription/types.d.ts +12 -27
- package/dist/modules/subscription/types.d.ts.map +1 -1
- package/dist/modules/user/types.d.ts +7 -8
- package/dist/modules/user/types.d.ts.map +1 -1
- package/dist/modules/user/userRepository.d.ts +3 -46
- package/dist/modules/user/userRepository.d.ts.map +1 -1
- package/dist/modules/user/userRepository.js +6 -48
- package/dist/modules/user/userRepository.js.map +1 -1
- package/dist/modules/user/userService.d.ts +3 -37
- package/dist/modules/user/userService.d.ts.map +1 -1
- package/dist/modules/user/userService.js +3 -36
- package/dist/modules/user/userService.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,361 +1,3 @@
|
|
|
1
1
|
# @miit-bot/payment-utils
|
|
2
2
|
|
|
3
|
-
Personal TypeScript library for managing payments and invoices in my bot applications.
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
This is a private utility library I use across my bot projects to handle:
|
|
8
|
-
|
|
9
|
-
- Payment processing with Wayforpay
|
|
10
|
-
- Invoice management and webhook handling
|
|
11
|
-
- Payment lifecycle tracking (pending → completed/failed/expired)
|
|
12
|
-
- Multi-platform support (Telegram, web, etc.)
|
|
13
|
-
- Expired payment cleanup
|
|
14
|
-
|
|
15
|
-
Also includes some legacy payment validation and formatting utilities.
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install @miit-bot/payment-utils
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Setup
|
|
24
|
-
|
|
25
|
-
### Firebase Initialization
|
|
26
|
-
|
|
27
|
-
Initialize Firebase Admin SDK before using payment/invoice services:
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import * as admin from 'firebase-admin';
|
|
31
|
-
|
|
32
|
-
admin.initializeApp({
|
|
33
|
-
credential: admin.credential.cert({
|
|
34
|
-
projectId: 'your-project-id',
|
|
35
|
-
clientEmail: 'your-client-email',
|
|
36
|
-
privateKey: 'your-private-key',
|
|
37
|
-
}),
|
|
38
|
-
});
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Required Firestore Collections
|
|
42
|
-
|
|
43
|
-
- `payments` - Payment records
|
|
44
|
-
- `invoices` - Invoice records from Wayforpay webhooks
|
|
45
|
-
|
|
46
|
-
## Usage
|
|
47
|
-
|
|
48
|
-
### PaymentService
|
|
49
|
-
|
|
50
|
-
Manages payment lifecycle from creation to completion.
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
import { PaymentService } from '@miit-bot/payment-utils';
|
|
54
|
-
|
|
55
|
-
const logger = {
|
|
56
|
-
error: (params) => console.error(params),
|
|
57
|
-
info: (params) => console.info(params),
|
|
58
|
-
warn: (params) => console.warn(params),
|
|
59
|
-
debug: (params) => console.debug(params),
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const paymentService = new PaymentService(logger);
|
|
63
|
-
|
|
64
|
-
// Create payment when user initiates purchase
|
|
65
|
-
const payment = await paymentService.create({
|
|
66
|
-
orderReference: 'ORDER_123456',
|
|
67
|
-
userId: 'user_abc',
|
|
68
|
-
status: 'pending',
|
|
69
|
-
paymentLink: 'https://wayforpay.com/pay/...',
|
|
70
|
-
planId: 'premium_monthly',
|
|
71
|
-
amount: 99.99,
|
|
72
|
-
currency: 'USD',
|
|
73
|
-
createdAt: new Date().toISOString(),
|
|
74
|
-
platform: 'telegram',
|
|
75
|
-
provider: 'wayforpay',
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Retrieve by order reference
|
|
79
|
-
const payment = await paymentService.getByOrderReference('ORDER_123456');
|
|
80
|
-
|
|
81
|
-
// Get user's payment history
|
|
82
|
-
const userPayments = await paymentService.getByUserId({
|
|
83
|
-
userId: 'user_abc',
|
|
84
|
-
appNamespace: 'telegram',
|
|
85
|
-
status: 'completed', // optional filter
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// Update payment status (e.g., after webhook)
|
|
89
|
-
await paymentService.updateFields({
|
|
90
|
-
orderReference: 'ORDER_123456',
|
|
91
|
-
fields: [
|
|
92
|
-
['status', 'completed'],
|
|
93
|
-
['invoiceId', 'invoice_xyz'],
|
|
94
|
-
],
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// Find expired pending payments for cleanup
|
|
98
|
-
const expiredPayments = await paymentService.getExpiredPendingPayments({
|
|
99
|
-
hoursOld: 24, // default: 24
|
|
100
|
-
});
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### InvoiceService
|
|
104
|
-
|
|
105
|
-
Stores invoice data from Wayforpay webhooks.
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
import { InvoiceService } from '@miit-bot/payment-utils';
|
|
109
|
-
|
|
110
|
-
const invoiceService = new InvoiceService(logger);
|
|
111
|
-
|
|
112
|
-
// Create invoice from webhook data
|
|
113
|
-
const invoice = await invoiceService.create({
|
|
114
|
-
merchantAccount: 'merchant_123',
|
|
115
|
-
orderReference: 'ORDER_123456',
|
|
116
|
-
merchantSignature: 'signature_hash',
|
|
117
|
-
reasonCode: 1100,
|
|
118
|
-
reason: 'Payment successful',
|
|
119
|
-
createdDate: Date.now(),
|
|
120
|
-
processingDate: Date.now(),
|
|
121
|
-
currency: 'USD',
|
|
122
|
-
amount: 99.99,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// Retrieve invoice
|
|
126
|
-
const invoice = await invoiceService.getByOrderReference('ORDER_123456');
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Typical Workflow
|
|
130
|
-
|
|
131
|
-
### 1. User Initiates Payment
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
134
|
-
const payment = await paymentService.create({
|
|
135
|
-
orderReference: generateOrderReference(),
|
|
136
|
-
userId: user.id,
|
|
137
|
-
status: 'pending',
|
|
138
|
-
paymentLink: wayforpayUrl,
|
|
139
|
-
planId: 'premium_monthly',
|
|
140
|
-
amount: 99.99,
|
|
141
|
-
currency: 'USD',
|
|
142
|
-
createdAt: new Date().toISOString(),
|
|
143
|
-
platform: 'telegram',
|
|
144
|
-
provider: 'wayforpay',
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
// Send link to user
|
|
148
|
-
sendPaymentLink(payment.paymentLink);
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### 2. Wayforpay Webhook Handler
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
|
-
// Update payment status
|
|
155
|
-
await paymentService.updateFields({
|
|
156
|
-
orderReference: webhookData.orderReference,
|
|
157
|
-
fields: [['status', 'completed']],
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
// Save invoice
|
|
161
|
-
const invoice = await invoiceService.create({
|
|
162
|
-
merchantAccount: webhookData.merchantAccount,
|
|
163
|
-
orderReference: webhookData.orderReference,
|
|
164
|
-
merchantSignature: webhookData.merchantSignature,
|
|
165
|
-
reasonCode: webhookData.reasonCode,
|
|
166
|
-
reason: webhookData.reason,
|
|
167
|
-
createdDate: webhookData.createdDate,
|
|
168
|
-
processingDate: webhookData.processingDate,
|
|
169
|
-
currency: webhookData.currency,
|
|
170
|
-
amount: webhookData.amount,
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
// Link invoice to payment
|
|
174
|
-
await paymentService.updateFields({
|
|
175
|
-
orderReference: webhookData.orderReference,
|
|
176
|
-
fields: [['invoiceId', invoice.id]],
|
|
177
|
-
});
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### 3. Cleanup Expired Payments (Cron Job)
|
|
181
|
-
|
|
182
|
-
```typescript
|
|
183
|
-
async function cleanupExpiredPayments() {
|
|
184
|
-
const expired = await paymentService.getExpiredPendingPayments({ hoursOld: 24 });
|
|
185
|
-
|
|
186
|
-
for (const payment of expired) {
|
|
187
|
-
await paymentService.updateFields({
|
|
188
|
-
orderReference: payment.orderReference,
|
|
189
|
-
fields: [['status', 'expired']],
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## API Reference
|
|
196
|
-
|
|
197
|
-
### PaymentService
|
|
198
|
-
|
|
199
|
-
**Methods:**
|
|
200
|
-
|
|
201
|
-
- `getByOrderReference(orderReference: string): Promise<PaymentEntity | null>`
|
|
202
|
-
- `getByUserId(params: { userId: string; appNamespace: AppNamespace; status?: PaymentStatus }): Promise<PaymentEntity[]>`
|
|
203
|
-
- `create(paymentData: Omit<PaymentEntity, 'id'>): Promise<PaymentEntity>`
|
|
204
|
-
- `updateFields(params: { orderReference: string; fields: UpdateDBPaymentFields }): Promise<void>`
|
|
205
|
-
- `getExpiredPendingPayments(params?: { hoursOld?: number }): Promise<PaymentEntity[]>`
|
|
206
|
-
|
|
207
|
-
### InvoiceService
|
|
208
|
-
|
|
209
|
-
**Methods:**
|
|
210
|
-
|
|
211
|
-
- `create(invoiceData: Omit<InvoiceEntity, 'id'>): Promise<InvoiceEntity>`
|
|
212
|
-
- `getByOrderReference(orderReference: string): Promise<InvoiceEntity | null>`
|
|
213
|
-
|
|
214
|
-
### Types
|
|
215
|
-
|
|
216
|
-
#### PaymentEntity
|
|
217
|
-
|
|
218
|
-
```typescript
|
|
219
|
-
interface PaymentEntity {
|
|
220
|
-
id?: string;
|
|
221
|
-
orderReference: string;
|
|
222
|
-
userId: string;
|
|
223
|
-
status: 'pending' | 'completed' | 'failed' | 'expired';
|
|
224
|
-
paymentLink: string;
|
|
225
|
-
planId: string;
|
|
226
|
-
amount: number;
|
|
227
|
-
currency: 'UAH' | 'USD';
|
|
228
|
-
createdAt: string;
|
|
229
|
-
invoiceId?: string;
|
|
230
|
-
platform: AppNamespace;
|
|
231
|
-
provider: 'wayforpay';
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
#### InvoiceEntity
|
|
236
|
-
|
|
237
|
-
```typescript
|
|
238
|
-
interface InvoiceEntity {
|
|
239
|
-
id: string;
|
|
240
|
-
merchantAccount: string;
|
|
241
|
-
orderReference: string;
|
|
242
|
-
merchantSignature: string;
|
|
243
|
-
reasonCode: number;
|
|
244
|
-
reason: string;
|
|
245
|
-
createdDate: number;
|
|
246
|
-
processingDate: number;
|
|
247
|
-
currency: string;
|
|
248
|
-
amount: number;
|
|
249
|
-
}
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
#### Logger Interface
|
|
253
|
-
|
|
254
|
-
```typescript
|
|
255
|
-
interface Logger {
|
|
256
|
-
error(params: { message: string; payload?: any }): void;
|
|
257
|
-
info(params: { message: string; payload?: any }): void;
|
|
258
|
-
warn(params: { message: string; payload?: any }): void;
|
|
259
|
-
debug(params: { message: string; payload?: any }): void;
|
|
260
|
-
}
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
## Legacy Validation & Formatting
|
|
264
|
-
|
|
265
|
-
### Card Validation
|
|
266
|
-
|
|
267
|
-
```typescript
|
|
268
|
-
import { validateCardNumber, CardType } from '@miit-bot/payment-utils';
|
|
269
|
-
|
|
270
|
-
const result = validateCardNumber('4532015112830366');
|
|
271
|
-
// { isValid: true, cardType: 'VISA', message: 'Valid card number' }
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
### Amount Validation
|
|
275
|
-
|
|
276
|
-
```typescript
|
|
277
|
-
import { validateAmount } from '@miit-bot/payment-utils';
|
|
278
|
-
|
|
279
|
-
const result = validateAmount(99.99);
|
|
280
|
-
// { isValid: true, amount: 99.99, message: 'Valid amount' }
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
### CVV Validation
|
|
284
|
-
|
|
285
|
-
```typescript
|
|
286
|
-
import { validateCVV, CardType } from '@miit-bot/payment-utils';
|
|
287
|
-
|
|
288
|
-
const isValid = validateCVV('123'); // true
|
|
289
|
-
const isValidAmex = validateCVV('1234', CardType.AMEX); // true
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
### Card Formatting
|
|
293
|
-
|
|
294
|
-
```typescript
|
|
295
|
-
import { formatCardNumber, maskCardNumber } from '@miit-bot/payment-utils';
|
|
296
|
-
|
|
297
|
-
formatCardNumber('4532015112830366'); // '4532 0151 1283 0366'
|
|
298
|
-
formatCardNumber('4532015112830366', true); // '**** **** **** 0366'
|
|
299
|
-
maskCardNumber('4532015112830366', 4, 'X'); // 'XXXXXXXXXXXX0366'
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
### Currency Formatting
|
|
303
|
-
|
|
304
|
-
```typescript
|
|
305
|
-
import { formatCurrency } from '@miit-bot/payment-utils';
|
|
306
|
-
|
|
307
|
-
formatCurrency(1234.56); // '$1,234.56'
|
|
308
|
-
formatCurrency(1234.56, { locale: 'de-DE', currency: 'EUR' }); // '1.234,56 €'
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
### Expiry Date Formatting
|
|
312
|
-
|
|
313
|
-
```typescript
|
|
314
|
-
import { formatExpiryDate } from '@miit-bot/payment-utils';
|
|
315
|
-
|
|
316
|
-
formatExpiryDate(12, 2025); // '12/25'
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
## Architecture
|
|
320
|
-
|
|
321
|
-
**Service Layer** - Business logic and error handling
|
|
322
|
-
|
|
323
|
-
- `PaymentService` - Payment operations
|
|
324
|
-
- `InvoiceService` - Invoice operations
|
|
325
|
-
|
|
326
|
-
**Repository Layer** - Database operations
|
|
327
|
-
|
|
328
|
-
- `PaymentRepository` - Firestore queries for payments
|
|
329
|
-
- `InvoiceRepository` - Firestore queries for invoices
|
|
330
|
-
|
|
331
|
-
Benefits: Clean separation, easy testing, type-safe.
|
|
332
|
-
|
|
333
|
-
## Development
|
|
334
|
-
|
|
335
|
-
```bash
|
|
336
|
-
# Install
|
|
337
|
-
npm install
|
|
338
|
-
|
|
339
|
-
# Build
|
|
340
|
-
npm run build
|
|
341
|
-
|
|
342
|
-
# Lint
|
|
343
|
-
npm run lint
|
|
344
|
-
|
|
345
|
-
# Format
|
|
346
|
-
npm run format
|
|
347
|
-
|
|
348
|
-
# Watch
|
|
349
|
-
npm run watch
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
### Dependencies
|
|
353
|
-
|
|
354
|
-
- **firebase-admin** - Peer dependency for Firestore
|
|
355
|
-
- **TypeScript** - Dev dependency
|
|
356
|
-
- **ESLint** - Dev dependency
|
|
357
|
-
- **Prettier** - Dev dependency
|
|
358
|
-
|
|
359
|
-
## License
|
|
360
|
-
|
|
361
|
-
MIT
|
|
3
|
+
Personal TypeScript library for managing payments and invoices in my bot applications.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { SimpleFn } from '../../types/function';
|
|
2
|
-
import { AppNamespace } from '../app/types';
|
|
3
2
|
type DefaultParams = Record<string, unknown> & {
|
|
4
3
|
userId: string;
|
|
5
|
-
|
|
4
|
+
platform: string;
|
|
6
5
|
};
|
|
7
6
|
declare function wrapCancellableAPI<T extends SimpleFn, TParams extends any[] = Parameters<T> extends never[] ? [DefaultParams] : Parameters<T> & [DefaultParams]>(api: T, props?: {
|
|
8
7
|
timeout?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/modules/cancellableAPI/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/modules/cancellableAPI/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,iBAAS,kBAAkB,CACvB,CAAC,SAAS,QAAQ,EAClB,OAAO,SAAS,GAAG,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAC3G,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,IACjB,GAAG,MAAM,OAAO,KAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAW9E;AAED,iBAAS,cAAc,CACnB,CAAC,SAAS,QAAQ,EAClB,OAAO,SAAS,GAAG,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAC3G,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,IACjB,GAAG,MAAM,OAAO,KAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAW9E;AAED,iBAAS,iBAAiB,CAAC,CAAC,SAAS,QAAQ,EAAE,OAAO,SAAS,GAAG,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAChF,GAAG,EAAE,CAAC,EACN,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,IAEX,GAAG,MAAM,OAAO,KAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAW9E;AAED,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/modules/cancellableAPI/utils.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/modules/cancellableAPI/utils.ts"],"names":[],"mappings":";;AA2DS,gDAAkB;AAAE,wCAAc;AAAE,8CAAiB;AA1D9D,4CAAuD;AAOvD,SAAS,kBAAkB,CAGzB,GAAM,EAAE,KAA4B;IAClC,OAAO,UAAU,GAAG,IAAa;QAC7B,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,IAAA,2BAAmB,EAAC;YAC7D,OAAO,EAAE,KAAK,EAAE,OAAO;SAC1B,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC;aAC9C,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,MAAM,CAAC,CAAC;QACZ,CAAC,CAAC;aACD,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC;AACN,CAAC;AAED,SAAS,cAAc,CAGrB,GAAM,EAAE,KAA4B;IAClC,OAAO,UAAU,GAAG,IAAa;QAC7B,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,IAAA,2BAAmB,EAAC;YAC7D,OAAO,EAAE,KAAK,EAAE,OAAO;SAC1B,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC;aAC9C,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,MAAM,CAAC,CAAC;QACZ,CAAC,CAAC;aACD,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC;AACN,CAAC;AAED,SAAS,iBAAiB,CACtB,GAAM,EACN,KAA4B;IAE5B,OAAO,UAAU,GAAG,IAAa;QAC7B,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,IAAA,2BAAmB,EAAC;YAC7D,OAAO,EAAE,KAAK,EAAE,OAAO;SAC1B,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC;aAC9C,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,MAAM,CAAC,CAAC;QACZ,CAAC,CAAC;aACD,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -1,38 +1,13 @@
|
|
|
1
1
|
import { Firestore } from 'firebase-admin/firestore';
|
|
2
2
|
import { InvoiceEntity, IInvoiceRepository } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* InvoiceRepository class handles all database operations related to invoices.
|
|
5
|
-
* Implements repository pattern for invoice data access.
|
|
6
|
-
*/
|
|
7
3
|
declare class InvoiceRepository implements IInvoiceRepository {
|
|
8
4
|
private readonly db;
|
|
9
5
|
private readonly collectionName;
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of InvoiceRepository.
|
|
12
|
-
* @param params - Repository dependencies
|
|
13
|
-
* @param params.db - Optional Firestore instance for dependency injection (defaults to getFirestore())
|
|
14
|
-
*/
|
|
15
6
|
constructor({ db }?: {
|
|
16
7
|
db?: Firestore;
|
|
17
8
|
});
|
|
18
|
-
/**
|
|
19
|
-
* Retrieves an invoice by its order reference.
|
|
20
|
-
* @param orderReference - The unique order reference identifier
|
|
21
|
-
* @returns Promise resolving to InvoiceEntity or null if not found
|
|
22
|
-
*/
|
|
23
9
|
getByOrderReference(orderReference: string): Promise<InvoiceEntity | null>;
|
|
24
|
-
/**
|
|
25
|
-
* Creates a new invoice record in the database.
|
|
26
|
-
* @param invoiceData - Invoice data without ID (ID will be auto-generated)
|
|
27
|
-
* @returns Promise resolving to created InvoiceEntity with ID
|
|
28
|
-
* @throws Error if invoice creation fails
|
|
29
|
-
*/
|
|
30
10
|
create(invoiceData: Omit<InvoiceEntity, 'id'>): Promise<InvoiceEntity>;
|
|
31
|
-
/**
|
|
32
|
-
* Maps a Firestore document to an InvoiceEntity.
|
|
33
|
-
* @param doc - Firestore document snapshot
|
|
34
|
-
* @returns InvoiceEntity with document ID
|
|
35
|
-
*/
|
|
36
11
|
private mapDocumentToEntity;
|
|
37
12
|
}
|
|
38
13
|
export { InvoiceRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/modules/invoice/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuC,MAAM,0BAA0B,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG5D
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/modules/invoice/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuC,MAAM,0BAA0B,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG5D,cAAM,iBAAkB,YAAW,kBAAkB;IACjD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAY;IAC/B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAc;gBAEjC,EAAE,EAAE,EAAE,GAAE;QAAE,EAAE,CAAC,EAAE,SAAS,CAAA;KAAO;IAI9B,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAe1E,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAgBnF,OAAO,CAAC,mBAAmB;CAM9B;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -3,25 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InvoiceRepository = void 0;
|
|
4
4
|
const firestore_1 = require("firebase-admin/firestore");
|
|
5
5
|
const const_1 = require("./const");
|
|
6
|
-
/**
|
|
7
|
-
* InvoiceRepository class handles all database operations related to invoices.
|
|
8
|
-
* Implements repository pattern for invoice data access.
|
|
9
|
-
*/
|
|
10
6
|
class InvoiceRepository {
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of InvoiceRepository.
|
|
13
|
-
* @param params - Repository dependencies
|
|
14
|
-
* @param params.db - Optional Firestore instance for dependency injection (defaults to getFirestore())
|
|
15
|
-
*/
|
|
16
7
|
constructor({ db } = {}) {
|
|
17
8
|
this.collectionName = 'invoices';
|
|
18
9
|
this.db = db || (0, firestore_1.getFirestore)();
|
|
19
10
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Retrieves an invoice by its order reference.
|
|
22
|
-
* @param orderReference - The unique order reference identifier
|
|
23
|
-
* @returns Promise resolving to InvoiceEntity or null if not found
|
|
24
|
-
*/
|
|
25
11
|
async getByOrderReference(orderReference) {
|
|
26
12
|
const querySnapshot = await this.db
|
|
27
13
|
.collection(this.collectionName)
|
|
@@ -34,12 +20,6 @@ class InvoiceRepository {
|
|
|
34
20
|
const doc = querySnapshot.docs[0];
|
|
35
21
|
return this.mapDocumentToEntity(doc);
|
|
36
22
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Creates a new invoice record in the database.
|
|
39
|
-
* @param invoiceData - Invoice data without ID (ID will be auto-generated)
|
|
40
|
-
* @returns Promise resolving to created InvoiceEntity with ID
|
|
41
|
-
* @throws Error if invoice creation fails
|
|
42
|
-
*/
|
|
43
23
|
async create(invoiceData) {
|
|
44
24
|
// Generate a new document reference to get the ID first
|
|
45
25
|
const docRef = this.db.collection(this.collectionName).doc();
|
|
@@ -52,11 +32,6 @@ class InvoiceRepository {
|
|
|
52
32
|
await docRef.set(invoiceEntity);
|
|
53
33
|
return invoiceEntity;
|
|
54
34
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Maps a Firestore document to an InvoiceEntity.
|
|
57
|
-
* @param doc - Firestore document snapshot
|
|
58
|
-
* @returns InvoiceEntity with document ID
|
|
59
|
-
*/
|
|
60
35
|
mapDocumentToEntity(doc) {
|
|
61
36
|
return {
|
|
62
37
|
id: doc.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../src/modules/invoice/repository.ts"],"names":[],"mappings":";;;AAAA,wDAA0F;AAE1F,mCAAiD;AAEjD
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../src/modules/invoice/repository.ts"],"names":[],"mappings":";;;AAAA,wDAA0F;AAE1F,mCAAiD;AAEjD,MAAM,iBAAiB;IAInB,YAAY,EAAE,EAAE,KAAyB,EAAE;QAF1B,mBAAc,GAAG,UAAU,CAAC;QAGzC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,IAAA,wBAAY,GAAE,CAAC;IACnC,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,cAAsB;QACnD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,EAAE;aAC9B,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC;aAC/B,KAAK,CAAC,gBAAgB,EAAE,IAAI,EAAE,cAAc,CAAC;aAC7C,KAAK,CAAC,CAAC,CAAC;aACR,GAAG,EAAE,CAAC;QAEX,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,WAAsC;QACtD,wDAAwD;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,GAAG,EAAE,CAAC;QAE7D,MAAM,aAAa,GAAkB;YACjC,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,GAAG,8BAAsB;YACzB,GAAG,WAAW;SACjB,CAAC;QAEF,oEAAoE;QACpE,MAAM,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAEhC,OAAO,aAAa,CAAC;IACzB,CAAC;IAEO,mBAAmB,CAAC,GAA0B;QAClD,OAAO;YACH,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,GAAG,GAAG,CAAC,IAAI,EAAE;SACC,CAAC;IACvB,CAAC;CACJ;AAEQ,8CAAiB"}
|
|
@@ -1,34 +1,13 @@
|
|
|
1
1
|
import { Logger } from '../logger/types';
|
|
2
2
|
import { InvoiceEntity, IInvoiceRepository, IInvoiceService } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* InvoiceService class handles business logic related to invoices.
|
|
5
|
-
* Acts as an intermediary between controllers/handlers and the repository layer.
|
|
6
|
-
*/
|
|
7
3
|
export declare class InvoiceService implements IInvoiceService {
|
|
8
4
|
private readonly logger;
|
|
9
5
|
private readonly repository;
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of InvoiceService.
|
|
12
|
-
* @param params - Service dependencies
|
|
13
|
-
* @param params.logger - Application logger instance for logging operations
|
|
14
|
-
* @param params.repository - Optional invoice repository instance for dependency injection (defaults to new InvoiceRepository())
|
|
15
|
-
*/
|
|
16
6
|
constructor({ logger, repository }: {
|
|
17
7
|
logger: Logger;
|
|
18
8
|
repository?: IInvoiceRepository;
|
|
19
9
|
});
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new invoice.
|
|
22
|
-
* @param invoiceData - Invoice data without ID
|
|
23
|
-
* @returns Promise resolving to created InvoiceEntity
|
|
24
|
-
* @throws Error if invoice creation fails
|
|
25
|
-
*/
|
|
26
10
|
create(invoiceData: Omit<InvoiceEntity, 'id'>): Promise<InvoiceEntity>;
|
|
27
|
-
/**
|
|
28
|
-
* Retrieves an invoice by order reference.
|
|
29
|
-
* @param orderReference - The unique order reference identifier
|
|
30
|
-
* @returns Promise resolving to InvoiceEntity or null if not found
|
|
31
|
-
*/
|
|
32
11
|
getByOrderReference(orderReference: string): Promise<InvoiceEntity | null>;
|
|
33
12
|
}
|
|
34
13
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/invoice/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE7E
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/invoice/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE7E,qBAAa,cAAe,YAAW,eAAe;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;gBAEpC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,kBAAkB,CAAA;KAAE;IAK1E,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAgBtE,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;CAc1F"}
|
|
@@ -2,27 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InvoiceService = void 0;
|
|
4
4
|
const repository_1 = require("./repository");
|
|
5
|
-
/**
|
|
6
|
-
* InvoiceService class handles business logic related to invoices.
|
|
7
|
-
* Acts as an intermediary between controllers/handlers and the repository layer.
|
|
8
|
-
*/
|
|
9
5
|
class InvoiceService {
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of InvoiceService.
|
|
12
|
-
* @param params - Service dependencies
|
|
13
|
-
* @param params.logger - Application logger instance for logging operations
|
|
14
|
-
* @param params.repository - Optional invoice repository instance for dependency injection (defaults to new InvoiceRepository())
|
|
15
|
-
*/
|
|
16
6
|
constructor({ logger, repository }) {
|
|
17
7
|
this.logger = logger;
|
|
18
8
|
this.repository = repository || new repository_1.InvoiceRepository();
|
|
19
9
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new invoice.
|
|
22
|
-
* @param invoiceData - Invoice data without ID
|
|
23
|
-
* @returns Promise resolving to created InvoiceEntity
|
|
24
|
-
* @throws Error if invoice creation fails
|
|
25
|
-
*/
|
|
26
10
|
async create(invoiceData) {
|
|
27
11
|
try {
|
|
28
12
|
return await this.repository.create(invoiceData);
|
|
@@ -38,11 +22,6 @@ class InvoiceService {
|
|
|
38
22
|
throw error;
|
|
39
23
|
}
|
|
40
24
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Retrieves an invoice by order reference.
|
|
43
|
-
* @param orderReference - The unique order reference identifier
|
|
44
|
-
* @returns Promise resolving to InvoiceEntity or null if not found
|
|
45
|
-
*/
|
|
46
25
|
async getByOrderReference(orderReference) {
|
|
47
26
|
try {
|
|
48
27
|
return await this.repository.getByOrderReference(orderReference);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/modules/invoice/service.ts"],"names":[],"mappings":";;;AACA,6CAAiD;AAGjD
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/modules/invoice/service.ts"],"names":[],"mappings":";;;AACA,6CAAiD;AAGjD,MAAa,cAAc;IAIvB,YAAY,EAAE,MAAM,EAAE,UAAU,EAAuD;QACnF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,IAAI,8BAAiB,EAAE,CAAC;IAC5D,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,WAAsC;QACtD,IAAI,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACrD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBACd,OAAO,EAAE,iCAAiC;gBAC1C,OAAO,EAAE;oBACL,cAAc,EAAE,WAAW,CAAC,cAAc;oBAC1C,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;iBAC/B;aACJ,CAAC,CAAC;YAEH,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,cAAsB;QACnD,IAAI,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;QACrE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBACd,OAAO,EAAE,8CAA8C;gBACvD,OAAO,EAAE;oBACL,cAAc;oBACd,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;iBAC/B;aACJ,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;CACJ;AAvCD,wCAuCC"}
|
|
@@ -18,14 +18,10 @@ type InvoiceEntity = {
|
|
|
18
18
|
interface IInvoiceRepository {
|
|
19
19
|
/**
|
|
20
20
|
* Retrieves an invoice by its order reference.
|
|
21
|
-
* @param orderReference - The unique order reference identifier
|
|
22
|
-
* @returns Promise resolving to InvoiceEntity or null if not found
|
|
23
21
|
*/
|
|
24
22
|
getByOrderReference(orderReference: string): Promise<InvoiceEntity | null>;
|
|
25
23
|
/**
|
|
26
24
|
* Creates a new invoice record in the database.
|
|
27
|
-
* @param invoiceData - Invoice data without ID (ID will be auto-generated)
|
|
28
|
-
* @returns Promise resolving to created InvoiceEntity with ID
|
|
29
25
|
*/
|
|
30
26
|
create(invoiceData: Omit<InvoiceEntity, 'id'>): Promise<InvoiceEntity>;
|
|
31
27
|
}
|
|
@@ -36,14 +32,10 @@ interface IInvoiceRepository {
|
|
|
36
32
|
interface IInvoiceService {
|
|
37
33
|
/**
|
|
38
34
|
* Creates a new invoice.
|
|
39
|
-
* @param invoiceData - Invoice data without ID
|
|
40
|
-
* @returns Promise resolving to created InvoiceEntity
|
|
41
35
|
*/
|
|
42
36
|
create(invoiceData: Omit<InvoiceEntity, 'id'>): Promise<InvoiceEntity>;
|
|
43
37
|
/**
|
|
44
38
|
* Retrieves an invoice by order reference.
|
|
45
|
-
* @param orderReference - The unique order reference identifier
|
|
46
|
-
* @returns Promise resolving to InvoiceEntity or null if not found
|
|
47
39
|
*/
|
|
48
40
|
getByOrderReference(orderReference: string): Promise<InvoiceEntity | null>;
|
|
49
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/invoice/types.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,UAAU,kBAAkB;IACxB
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/invoice/types.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,UAAU,kBAAkB;IACxB;;OAEG;IACH,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IAE3E;;OAEG;IACH,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC1E;AAED;;;GAGG;AACH,UAAU,eAAe;IACrB;;OAEG;IACH,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAEvE;;OAEG;IACH,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;CAC9E;AAED,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AppNamespace } from '../app/types';
|
|
2
1
|
interface WayforpayResponse {
|
|
3
2
|
url?: string;
|
|
4
3
|
[key: string]: unknown;
|
|
@@ -9,7 +8,7 @@ interface WayforpayResponse {
|
|
|
9
8
|
*
|
|
10
9
|
* @param params - Payment creation parameters
|
|
11
10
|
* @param params.userId - The unique identifier of the user making the payment
|
|
12
|
-
* @param params.
|
|
11
|
+
* @param params.platform - The application namespace (e.g., 'app' or 'telegram')
|
|
13
12
|
* @param params.productName - The name of the product being purchased
|
|
14
13
|
* @param params.productPrice - The price of the product
|
|
15
14
|
* @param params.planId - The identifier of the subscription plan
|
|
@@ -19,9 +18,9 @@ interface WayforpayResponse {
|
|
|
19
18
|
* @returns Promise resolving to an object containing the payment URL and order reference, or null
|
|
20
19
|
* @throws Error with code 'CREATE_PAYMENT_API' if the API response is invalid or missing URL
|
|
21
20
|
*/
|
|
22
|
-
declare function createPaymentAPI({ userId,
|
|
21
|
+
declare function createPaymentAPI({ userId, platform, productName, productPrice, planId, dateNext, currency, regularCount, regularMode, language, }: {
|
|
23
22
|
userId: string;
|
|
24
|
-
|
|
23
|
+
platform: string;
|
|
25
24
|
productName: string;
|
|
26
25
|
productPrice: number;
|
|
27
26
|
planId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/api.ts"],"names":[],"mappings":"AAKA,UAAU,iBAAiB;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;GAeG;AACH,iBAAe,gBAAgB,CAAC,EAC5B,MAAM,EACN,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAgB,EAChB,WAAqB,EACrB,QAAe,GAClB,EAAE;IACC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAoC1D;AAED;;;;;;;;;;;;GAYG;AACH,iBAAe,sBAAsB,CAAC,EAClC,cAAc,EACd,MAAM,EACN,SAAS,EACT,OAAO,EACP,WAAW,EACX,QAAQ,GACX,EAAE;IACC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACvD,QAAQ,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAmB7B;AAED,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,CAAC"}
|