@aepstore-dev/contracts 1.67.0 → 1.68.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.
- package/gen/activity.js +1 -1
- package/gen/activity.ts +270 -270
- package/gen/auth.js +1 -1
- package/gen/auth.ts +323 -323
- package/gen/mail.js +1 -1
- package/gen/mail.ts +121 -121
- package/gen/payments.js +1 -1
- package/gen/payments.ts +1048 -1048
- package/gen/products.d.ts +2 -4
- package/gen/products.ts +2 -4
- package/gen/taxonomy.js +1 -1
- package/gen/taxonomy.ts +185 -185
- package/gen/upload.js +1 -1
- package/gen/upload.ts +287 -287
- package/gen/users.js +1 -1
- package/gen/users.ts +1026 -1026
- package/package.json +1 -1
- package/proto/products.proto +4 -4
package/gen/payments.ts
CHANGED
|
@@ -1,1048 +1,1048 @@
|
|
|
1
|
-
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
-
// versions:
|
|
3
|
-
// protoc-gen-ts_proto v2.10.1
|
|
4
|
-
// protoc v7.35.
|
|
5
|
-
// source: payments.proto
|
|
6
|
-
|
|
7
|
-
/* eslint-disable */
|
|
8
|
-
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
9
|
-
import { Observable } from "rxjs";
|
|
10
|
-
|
|
11
|
-
export const protobufPackage = "payments.v1";
|
|
12
|
-
|
|
13
|
-
export interface Ok {
|
|
14
|
-
ok: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* ---------------------------------------------------------------------------
|
|
19
|
-
* Purchase / checkout / topup
|
|
20
|
-
* ---------------------------------------------------------------------------
|
|
21
|
-
*/
|
|
22
|
-
export interface Purchase {
|
|
23
|
-
id: string;
|
|
24
|
-
productId: string;
|
|
25
|
-
productName: string;
|
|
26
|
-
userId: string;
|
|
27
|
-
/** settled RUB amount */
|
|
28
|
-
price: string;
|
|
29
|
-
/** PENDING | COMPLETED | FAILED | REFUNDED */
|
|
30
|
-
status: string;
|
|
31
|
-
paymentId: string;
|
|
32
|
-
/** BALANCE | YOOKASSA | CRYPTO */
|
|
33
|
-
paymentMethod: string;
|
|
34
|
-
commissionPercent: string;
|
|
35
|
-
sellerAmount: string;
|
|
36
|
-
createdAt: string;
|
|
37
|
-
completedAt: string;
|
|
38
|
-
/** FX snapshot at checkout (empty for legacy RUB purchases). */
|
|
39
|
-
listingCurrency: string;
|
|
40
|
-
/** Decimal as string, in listing_currency */
|
|
41
|
-
listingPrice: string;
|
|
42
|
-
/** listing→RUB rate used (Decimal as string) */
|
|
43
|
-
fxRate: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface TopupRequest {
|
|
47
|
-
userId: string;
|
|
48
|
-
/** >= 10.00 */
|
|
49
|
-
amount: string;
|
|
50
|
-
returnUrl: string;
|
|
51
|
-
/** YOOKASSA | SAVED_CARD | CRYPTO (default YOOKASSA) */
|
|
52
|
-
paymentMethod: string;
|
|
53
|
-
/** required when payment_method=SAVED_CARD */
|
|
54
|
-
savedCardId: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface CreateCheckoutRequest {
|
|
58
|
-
userId: string;
|
|
59
|
-
productId: string;
|
|
60
|
-
/** BALANCE | YOOKASSA | SAVED_CARD | CRYPTO (default YOOKASSA) */
|
|
61
|
-
paymentMethod: string;
|
|
62
|
-
returnUrl: string;
|
|
63
|
-
/**
|
|
64
|
-
* When payment_method=SAVED_CARD — required. ID of a SavedCard row owned
|
|
65
|
-
* by user_id. Ignored otherwise.
|
|
66
|
-
*/
|
|
67
|
-
savedCardId: string;
|
|
68
|
-
/**
|
|
69
|
-
* When payment_method=YOOKASSA — optional. If true, save the card token
|
|
70
|
-
* after success; the bound card becomes available in /account/cards.
|
|
71
|
-
*/
|
|
72
|
-
savePaymentMethod: boolean;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface BindCardRequest {
|
|
76
|
-
userId: string;
|
|
77
|
-
returnUrl: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface GetPaymentIntentRequest {
|
|
81
|
-
intentId: string;
|
|
82
|
-
/** ownership check */
|
|
83
|
-
userId: string;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface PaymentIntentStatus {
|
|
87
|
-
id: string;
|
|
88
|
-
userId: string;
|
|
89
|
-
/** TOPUP | PREMIUM */
|
|
90
|
-
purpose: string;
|
|
91
|
-
/** PENDING | COMPLETED | FAILED | CANCELED */
|
|
92
|
-
status: string;
|
|
93
|
-
amount: string;
|
|
94
|
-
currency: string;
|
|
95
|
-
/** set when purpose=PREMIUM (else empty) */
|
|
96
|
-
purchaseId: string;
|
|
97
|
-
createdAt: string;
|
|
98
|
-
updatedAt: string;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface CheckoutResponse {
|
|
102
|
-
purchaseId: string;
|
|
103
|
-
paymentId: string;
|
|
104
|
-
/** empty when paid from balance (instant) */
|
|
105
|
-
confirmationUrl: string;
|
|
106
|
-
/** PENDING (redirect) | COMPLETED (balance) */
|
|
107
|
-
status: string;
|
|
108
|
-
/** poll via GetPaymentIntent for TOPUP / bind-card flows */
|
|
109
|
-
intentId: string;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface GetMyPurchasesRequest {
|
|
113
|
-
userId: string;
|
|
114
|
-
page: number;
|
|
115
|
-
limit: number;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface PurchasesListResponse {
|
|
119
|
-
items: Purchase[];
|
|
120
|
-
total: number;
|
|
121
|
-
page: number;
|
|
122
|
-
limit: number;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface GetPurchaseRequest {
|
|
126
|
-
id: string;
|
|
127
|
-
userId: string;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export interface RefundPurchaseRequest {
|
|
131
|
-
purchaseId: string;
|
|
132
|
-
actorUserId: string;
|
|
133
|
-
isAdmin: boolean;
|
|
134
|
-
reason: string;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* ---------------------------------------------------------------------------
|
|
139
|
-
* Wallet & statement
|
|
140
|
-
* ---------------------------------------------------------------------------
|
|
141
|
-
*/
|
|
142
|
-
export interface GetWalletRequest {
|
|
143
|
-
userId: string;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export interface WalletResponse {
|
|
147
|
-
spending: string;
|
|
148
|
-
pending: string;
|
|
149
|
-
payout: string;
|
|
150
|
-
/** spending + payout */
|
|
151
|
-
spendable: string;
|
|
152
|
-
/** payout */
|
|
153
|
-
withdrawable: string;
|
|
154
|
-
currency: string;
|
|
155
|
-
lifetimeSales: number;
|
|
156
|
-
currentCommissionPercent: string;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export interface ListTransactionsRequest {
|
|
160
|
-
userId: string;
|
|
161
|
-
/**
|
|
162
|
-
* Legacy low-level filter (one of LedgerTxType). Kept for backward
|
|
163
|
-
* compatibility — admin tooling still uses it directly.
|
|
164
|
-
*/
|
|
165
|
-
type: string;
|
|
166
|
-
page: number;
|
|
167
|
-
limit: number;
|
|
168
|
-
/**
|
|
169
|
-
* ↓ added for the wallet statement page (Round 3)
|
|
170
|
-
* UI-semantic filter mapped onto displayKind:
|
|
171
|
-
* ALL | SALES | INCOME | OUTCOME | REFUND | WITHDRAWAL | PREMIUM
|
|
172
|
-
* SALES = the seller's earnings on this account (USER_PENDING credits from
|
|
173
|
-
* PURCHASE transactions); these stay separate from INCOME (TOPUP).
|
|
174
|
-
*/
|
|
175
|
-
flow: string;
|
|
176
|
-
/**
|
|
177
|
-
* Period selection. `month` is the convenience form (YYYY-MM) used by the
|
|
178
|
-
* month dropdown; from/to override it for an arbitrary range.
|
|
179
|
-
*/
|
|
180
|
-
month: string;
|
|
181
|
-
from: string;
|
|
182
|
-
to: string;
|
|
183
|
-
/**
|
|
184
|
-
* Filter wallet to purchases/refunds of a specific Product category. Has
|
|
185
|
-
* no effect on TOPUP/WITHDRAWAL/PREMIUM/ADJUSTMENT entries (they have no
|
|
186
|
-
* product).
|
|
187
|
-
*/
|
|
188
|
-
productCategoryId: string;
|
|
189
|
-
/** sort_by ∈ { date | amount | type }. Default: date. */
|
|
190
|
-
sortBy: string;
|
|
191
|
-
/** order ∈ { asc | desc }. Default: desc. */
|
|
192
|
-
order: string;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export interface StatementEntry {
|
|
196
|
-
id: string;
|
|
197
|
-
txId: string;
|
|
198
|
-
/** raw tx type (TOPUP|PURCHASE|...) */
|
|
199
|
-
type: string;
|
|
200
|
-
accountKind: string;
|
|
201
|
-
/** DEBIT | CREDIT */
|
|
202
|
-
direction: string;
|
|
203
|
-
amount: string;
|
|
204
|
-
description: string;
|
|
205
|
-
createdAt: string;
|
|
206
|
-
/**
|
|
207
|
-
* ↓ added for the wallet statement page (Round 3)
|
|
208
|
-
* UI-friendly classification computed server-side:
|
|
209
|
-
* TOPUP | PURCHASE | SALE | REFUND | PREMIUM | WITHDRAWAL | ADJUSTMENT
|
|
210
|
-
* SALE is the seller's view of someone else's PURCHASE (CREDIT to their
|
|
211
|
-
* USER_PENDING) — distinct from PURCHASE which is the buyer's DEBIT.
|
|
212
|
-
* PREMIUM is split out of PURCHASE/REFUND so the UI can show
|
|
213
|
-
* "Продление Premium" / refund-of-premium in their own filter bucket.
|
|
214
|
-
* SALE_CLEAR transactions are excluded from the wallet view — the maturity
|
|
215
|
-
* event is surfaced via sale_status on the original SALE row instead.
|
|
216
|
-
*/
|
|
217
|
-
displayKind: string;
|
|
218
|
-
/** affected-account running balance, Decimal-as-string */
|
|
219
|
-
balanceAfter: string;
|
|
220
|
-
/** empty for non-product entries */
|
|
221
|
-
productId: string;
|
|
222
|
-
productName: string;
|
|
223
|
-
/** "Assets" | "Project File" | "Templates" */
|
|
224
|
-
productCategory: string;
|
|
225
|
-
/** optional thumbnail URL for richer rows */
|
|
226
|
-
productPreview: string;
|
|
227
|
-
/**
|
|
228
|
-
* Sale lifecycle. Populated only when display_kind=SALE.
|
|
229
|
-
* PENDING — held in USER_PENDING, not yet withdrawable.
|
|
230
|
-
* MATURED — SALE_CLEAR has fired; money is in USER_PAYOUT.
|
|
231
|
-
*/
|
|
232
|
-
saleStatus: string;
|
|
233
|
-
/**
|
|
234
|
-
* ISO 8601 when the sale becomes withdrawable (sale_completed_at +
|
|
235
|
-
* GRACE_DAYS). Empty for non-sale rows.
|
|
236
|
-
*/
|
|
237
|
-
maturesAt: string;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export interface TransactionsListResponse {
|
|
241
|
-
items: StatementEntry[];
|
|
242
|
-
total: number;
|
|
243
|
-
page: number;
|
|
244
|
-
limit: number;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export interface GetTransactionMonthsRequest {
|
|
248
|
-
userId: string;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
export interface GetTransactionMonthsResponse {
|
|
252
|
-
/**
|
|
253
|
-
* Newest first. "YYYY-MM" strings; the dropdown renders them
|
|
254
|
-
* localized client-side.
|
|
255
|
-
*/
|
|
256
|
-
months: string[];
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* ---------------------------------------------------------------------------
|
|
261
|
-
* Withdrawals
|
|
262
|
-
* ---------------------------------------------------------------------------
|
|
263
|
-
*/
|
|
264
|
-
export interface Withdrawal {
|
|
265
|
-
id: string;
|
|
266
|
-
sellerId: string;
|
|
267
|
-
amount: string;
|
|
268
|
-
/** PENDING | PROCESSING | COMPLETED | REJECTED */
|
|
269
|
-
status: string;
|
|
270
|
-
method: string;
|
|
271
|
-
details: string;
|
|
272
|
-
comment: string;
|
|
273
|
-
processedBy: string;
|
|
274
|
-
processedAt: string;
|
|
275
|
-
createdAt: string;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export interface RequestWithdrawalRequest {
|
|
279
|
-
sellerId: string;
|
|
280
|
-
amount: string;
|
|
281
|
-
method: string;
|
|
282
|
-
details: string;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
export interface ListWithdrawalsRequest {
|
|
286
|
-
sellerId: string;
|
|
287
|
-
status: string;
|
|
288
|
-
page: number;
|
|
289
|
-
limit: number;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export interface WithdrawalsListResponse {
|
|
293
|
-
items: Withdrawal[];
|
|
294
|
-
total: number;
|
|
295
|
-
page: number;
|
|
296
|
-
limit: number;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
export interface ProcessWithdrawalRequest {
|
|
300
|
-
withdrawalId: string;
|
|
301
|
-
adminId: string;
|
|
302
|
-
action: string;
|
|
303
|
-
comment: string;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* ---------------------------------------------------------------------------
|
|
308
|
-
* Webhook
|
|
309
|
-
* ---------------------------------------------------------------------------
|
|
310
|
-
*/
|
|
311
|
-
export interface PaymentEventRequest {
|
|
312
|
-
event: string;
|
|
313
|
-
paymentId: string;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
export interface ProviderCallbackRequest {
|
|
317
|
-
/** yookassa | heleket | … */
|
|
318
|
-
provider: string;
|
|
319
|
-
/** exact raw JSON body as received (signature input) */
|
|
320
|
-
rawBody: string;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* ---------------------------------------------------------------------------
|
|
325
|
-
* FX rates / payment methods
|
|
326
|
-
* ---------------------------------------------------------------------------
|
|
327
|
-
*/
|
|
328
|
-
export interface GetRatesRequest {
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
export interface FxRate {
|
|
332
|
-
/** USD | EUR */
|
|
333
|
-
currency: string;
|
|
334
|
-
/** RUB per 1 unit, Decimal as string */
|
|
335
|
-
rate: string;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
export interface GetRatesResponse {
|
|
339
|
-
/** always RUB */
|
|
340
|
-
base: string;
|
|
341
|
-
/** YYYY-MM-DD the rates are for */
|
|
342
|
-
asOf: string;
|
|
343
|
-
rates: FxRate[];
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export interface GetPaymentMethodsRequest {
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
export interface PaymentMethodInfo {
|
|
350
|
-
/** YOOKASSA | SAVED_CARD | CRYPTO | BALANCE */
|
|
351
|
-
method: string;
|
|
352
|
-
/** yookassa | heleket | '' (BALANCE) */
|
|
353
|
-
provider: string;
|
|
354
|
-
currencies: string[];
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
export interface GetPaymentMethodsResponse {
|
|
358
|
-
methods: PaymentMethodInfo[];
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* ---------------------------------------------------------------------------
|
|
363
|
-
* Admin
|
|
364
|
-
* ---------------------------------------------------------------------------
|
|
365
|
-
*/
|
|
366
|
-
export interface AdminOverviewRequest {
|
|
367
|
-
from: string;
|
|
368
|
-
to: string;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
export interface AdminOverviewResponse {
|
|
372
|
-
/** platform commission earned (period) */
|
|
373
|
-
revenue: string;
|
|
374
|
-
/** gross merchandise value (period) */
|
|
375
|
-
gmv: string;
|
|
376
|
-
/** Σ all users' (pending+payout+spending) — what we owe */
|
|
377
|
-
liabilities: string;
|
|
378
|
-
/** money in transit at PSP */
|
|
379
|
-
pspClearing: string;
|
|
380
|
-
/** reserved for approved withdrawals */
|
|
381
|
-
payoutsPayable: string;
|
|
382
|
-
refundsTotal: string;
|
|
383
|
-
topupsTotal: string;
|
|
384
|
-
withdrawalsTotal: string;
|
|
385
|
-
salesCount: number;
|
|
386
|
-
currency: string;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
export interface AdminListTransactionsRequest {
|
|
390
|
-
type: string;
|
|
391
|
-
userId: string;
|
|
392
|
-
accountKind: string;
|
|
393
|
-
from: string;
|
|
394
|
-
to: string;
|
|
395
|
-
page: number;
|
|
396
|
-
limit: number;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
export interface AdminEntry {
|
|
400
|
-
accountId: string;
|
|
401
|
-
accountKind: string;
|
|
402
|
-
ownerId: string;
|
|
403
|
-
direction: string;
|
|
404
|
-
amount: string;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
export interface AdminLedgerTx {
|
|
408
|
-
id: string;
|
|
409
|
-
type: string;
|
|
410
|
-
status: string;
|
|
411
|
-
refType: string;
|
|
412
|
-
refId: string;
|
|
413
|
-
description: string;
|
|
414
|
-
createdBy: string;
|
|
415
|
-
createdAt: string;
|
|
416
|
-
entries: AdminEntry[];
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
export interface AdminTransactionsListResponse {
|
|
420
|
-
items: AdminLedgerTx[];
|
|
421
|
-
total: number;
|
|
422
|
-
page: number;
|
|
423
|
-
limit: number;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
export interface GetUserFinanceRequest {
|
|
427
|
-
userId: string;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
export interface AccountBalance {
|
|
431
|
-
kind: string;
|
|
432
|
-
balance: string;
|
|
433
|
-
currency: string;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
export interface UserFinanceResponse {
|
|
437
|
-
wallet: WalletResponse | undefined;
|
|
438
|
-
accounts: AccountBalance[];
|
|
439
|
-
recent: StatementEntry[];
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
export interface CreateAdjustmentRequest {
|
|
443
|
-
adminId: string;
|
|
444
|
-
userId: string;
|
|
445
|
-
/** USER_SPENDING | USER_PAYOUT | USER_PENDING */
|
|
446
|
-
accountKind: string;
|
|
447
|
-
/** CREDIT (give) | DEBIT (take) */
|
|
448
|
-
direction: string;
|
|
449
|
-
amount: string;
|
|
450
|
-
reason: string;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
export interface SalesAnalyticsRequest {
|
|
454
|
-
from: string;
|
|
455
|
-
to: string;
|
|
456
|
-
granularity: string;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
export interface SalesPoint {
|
|
460
|
-
date: string;
|
|
461
|
-
salesCount: number;
|
|
462
|
-
gmv: string;
|
|
463
|
-
revenue: string;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
export interface SellerStat {
|
|
467
|
-
sellerId: string;
|
|
468
|
-
username: string;
|
|
469
|
-
sales: number;
|
|
470
|
-
gmv: string;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
export interface SalesAnalyticsResponse {
|
|
474
|
-
points: SalesPoint[];
|
|
475
|
-
topSellers: SellerStat[];
|
|
476
|
-
/** % refunded purchases */
|
|
477
|
-
refundRate: string;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
* ---------------------------------------------------------------------------
|
|
482
|
-
* Premium
|
|
483
|
-
* ---------------------------------------------------------------------------
|
|
484
|
-
*/
|
|
485
|
-
export interface GetPremiumPlansRequest {
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* One plan per (period). Prices are computed server-side from BASE_PRICE × months
|
|
490
|
-
* × (1 − discount); kept here as canonical strings so the gateway has no math.
|
|
491
|
-
*/
|
|
492
|
-
export interface PremiumPlan {
|
|
493
|
-
/** MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12 */
|
|
494
|
-
period: string;
|
|
495
|
-
months: number;
|
|
496
|
-
/** total to charge, Decimal-as-string */
|
|
497
|
-
price: string;
|
|
498
|
-
/** for UI "≈ X ₽/month" */
|
|
499
|
-
monthlyPrice: string;
|
|
500
|
-
discountPercent: string;
|
|
501
|
-
currency: string;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
export interface PremiumPlansResponse {
|
|
505
|
-
plans: PremiumPlan[];
|
|
506
|
-
baseMonthlyPrice: string;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
export interface PurchasePremiumRequest {
|
|
510
|
-
userId: string;
|
|
511
|
-
/** MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12 */
|
|
512
|
-
period: string;
|
|
513
|
-
/** BALANCE | YOOKASSA | SAVED_CARD (empty = smart default) */
|
|
514
|
-
paymentMethod: string;
|
|
515
|
-
/** YooKassa only */
|
|
516
|
-
returnUrl: string;
|
|
517
|
-
/**
|
|
518
|
-
* Save the YooKassa payment_method for future auto-renewals. Ignored for
|
|
519
|
-
* BALANCE. Kept for backwards compatibility; auto_renew=true implies save.
|
|
520
|
-
*/
|
|
521
|
-
savePaymentMethod: boolean;
|
|
522
|
-
/** default false; requires off-session-capable method */
|
|
523
|
-
autoRenew: boolean;
|
|
524
|
-
/** optional for SAVED_CARD; empty = default card */
|
|
525
|
-
savedCardId: string;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
export interface PurchasePremiumResponse {
|
|
529
|
-
/** PremiumPayment.id */
|
|
530
|
-
paymentId: string;
|
|
531
|
-
/** empty for BALANCE (instant) or YooKassa-issued */
|
|
532
|
-
confirmationUrl: string;
|
|
533
|
-
/** PENDING (redirect) | COMPLETED (balance) */
|
|
534
|
-
status: string;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
export interface RunPremiumRenewalsRequest {
|
|
538
|
-
/** safety cap; default 100 */
|
|
539
|
-
maxBatch: number;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
export interface RunPremiumRenewalsResponse {
|
|
543
|
-
attempted: number;
|
|
544
|
-
succeeded: number;
|
|
545
|
-
failed: number;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
export interface SetPremiumPaymentMethodRequest {
|
|
549
|
-
userId: string;
|
|
550
|
-
/** BALANCE | YOOKASSA | SAVED_CARD */
|
|
551
|
-
method: string;
|
|
552
|
-
/** optional for SAVED_CARD; empty = default card */
|
|
553
|
-
savedCardId: string;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
export interface PremiumPaymentMethodResponse {
|
|
557
|
-
/** BALANCE | YOOKASSA | SAVED_CARD */
|
|
558
|
-
method: string;
|
|
559
|
-
/** empty unless SAVED_CARD */
|
|
560
|
-
savedCardId: string;
|
|
561
|
-
autoRenew: boolean;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
export interface PremiumPaymentRow {
|
|
565
|
-
id: string;
|
|
566
|
-
userId: string;
|
|
567
|
-
amount: string;
|
|
568
|
-
/** MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12 */
|
|
569
|
-
period: string;
|
|
570
|
-
/** BALANCE | YOOKASSA */
|
|
571
|
-
method: string;
|
|
572
|
-
/** PENDING | COMPLETED | FAILED | REFUNDED */
|
|
573
|
-
status: string;
|
|
574
|
-
isRenewal: boolean;
|
|
575
|
-
createdAt: string;
|
|
576
|
-
completedAt: string;
|
|
577
|
-
refundedAt: string;
|
|
578
|
-
refundedAmount: string;
|
|
579
|
-
/**
|
|
580
|
-
* Convenience: true if this payment is currently inside the 7-day refund
|
|
581
|
-
* window AND status == COMPLETED AND not already refunded.
|
|
582
|
-
*/
|
|
583
|
-
refundable: boolean;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
export interface RefundPremiumRequest {
|
|
587
|
-
userId: string;
|
|
588
|
-
paymentId: string;
|
|
589
|
-
/** optional */
|
|
590
|
-
reason: string;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
export interface RefundPremiumResponse {
|
|
594
|
-
payment:
|
|
595
|
-
| PremiumPaymentRow
|
|
596
|
-
| undefined;
|
|
597
|
-
/** ISO 8601 after rollback */
|
|
598
|
-
newExpiresAt: string;
|
|
599
|
-
/** true when rollback put expiresAt <= now */
|
|
600
|
-
subscriptionRevoked: boolean;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
export interface GetMyPremiumPaymentsRequest {
|
|
604
|
-
userId: string;
|
|
605
|
-
page: number;
|
|
606
|
-
limit: number;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
export interface GetPremiumPaymentRequest {
|
|
610
|
-
userId: string;
|
|
611
|
-
paymentId: string;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
export interface PremiumPaymentsListResponse {
|
|
615
|
-
items: PremiumPaymentRow[];
|
|
616
|
-
total: number;
|
|
617
|
-
page: number;
|
|
618
|
-
limit: number;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
/**
|
|
622
|
-
* ---------------------------------------------------------------------------
|
|
623
|
-
* Saved cards (YooKassa payment_method tokens; we never see PAN)
|
|
624
|
-
* ---------------------------------------------------------------------------
|
|
625
|
-
*/
|
|
626
|
-
export interface SavedCard {
|
|
627
|
-
id: string;
|
|
628
|
-
/** "MIR" | "VISA" | "MASTERCARD" | "" */
|
|
629
|
-
brand: string;
|
|
630
|
-
/** "0000" etc, display-only */
|
|
631
|
-
last4: string;
|
|
632
|
-
expMonth: number;
|
|
633
|
-
expYear: number;
|
|
634
|
-
isDefault: boolean;
|
|
635
|
-
/** user-set label */
|
|
636
|
-
nickname: string;
|
|
637
|
-
createdAt: string;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
export interface ListSavedCardsRequest {
|
|
641
|
-
userId: string;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
export interface ListSavedCardsResponse {
|
|
645
|
-
items: SavedCard[];
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
export interface DeleteSavedCardRequest {
|
|
649
|
-
userId: string;
|
|
650
|
-
id: string;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
export interface SetDefaultSavedCardRequest {
|
|
654
|
-
userId: string;
|
|
655
|
-
id: string;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
export interface UpdateSavedCardRequest {
|
|
659
|
-
userId: string;
|
|
660
|
-
id: string;
|
|
661
|
-
/** empty = clear */
|
|
662
|
-
nickname: string;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
/**
|
|
666
|
-
* ---------------------------------------------------------------------------
|
|
667
|
-
* Payout details (persistent default; per-withdrawal override still allowed)
|
|
668
|
-
* ---------------------------------------------------------------------------
|
|
669
|
-
*/
|
|
670
|
-
export interface UpdatePayoutDetailsRequest {
|
|
671
|
-
userId: string;
|
|
672
|
-
/** "card" | "sbp" | "bank" | "" (clear) */
|
|
673
|
-
method: string;
|
|
674
|
-
/** JSON string — payments-service treats opaquely */
|
|
675
|
-
details: string;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
export interface UpdatePayoutDetailsResponse {
|
|
679
|
-
method: string;
|
|
680
|
-
details: string;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
export interface GetPayoutDetailsRequest {
|
|
684
|
-
userId: string;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
export const PAYMENTS_V1_PACKAGE_NAME = "payments.v1";
|
|
688
|
-
|
|
689
|
-
/**
|
|
690
|
-
* Commerce + double-entry wallet/ledger (D9 / D9.2). See payments-service/docs/FINANCE.md.
|
|
691
|
-
* Money = Decimal-as-string (D7). Statuses/enums as strings (avoid proto enum
|
|
692
|
-
* value-name clashes within one package).
|
|
693
|
-
*/
|
|
694
|
-
|
|
695
|
-
export interface PaymentsServiceClient {
|
|
696
|
-
/** ----- buyer ----- */
|
|
697
|
-
|
|
698
|
-
topup(request: TopupRequest): Observable<CheckoutResponse>;
|
|
699
|
-
|
|
700
|
-
createCheckout(request: CreateCheckoutRequest): Observable<CheckoutResponse>;
|
|
701
|
-
|
|
702
|
-
getMyPurchases(request: GetMyPurchasesRequest): Observable<PurchasesListResponse>;
|
|
703
|
-
|
|
704
|
-
getPurchase(request: GetPurchaseRequest): Observable<Purchase>;
|
|
705
|
-
|
|
706
|
-
refundPurchase(request: RefundPurchaseRequest): Observable<Purchase>;
|
|
707
|
-
|
|
708
|
-
/** ----- wallet ----- */
|
|
709
|
-
|
|
710
|
-
getWallet(request: GetWalletRequest): Observable<WalletResponse>;
|
|
711
|
-
|
|
712
|
-
listTransactions(request: ListTransactionsRequest): Observable<TransactionsListResponse>;
|
|
713
|
-
|
|
714
|
-
getTransactionMonths(request: GetTransactionMonthsRequest): Observable<GetTransactionMonthsResponse>;
|
|
715
|
-
|
|
716
|
-
/** ----- withdrawals ----- */
|
|
717
|
-
|
|
718
|
-
requestWithdrawal(request: RequestWithdrawalRequest): Observable<Withdrawal>;
|
|
719
|
-
|
|
720
|
-
listWithdrawals(request: ListWithdrawalsRequest): Observable<WithdrawalsListResponse>;
|
|
721
|
-
|
|
722
|
-
processWithdrawal(request: ProcessWithdrawalRequest): Observable<Withdrawal>;
|
|
723
|
-
|
|
724
|
-
/** ----- provider webhook (gateway forwards a verified event) ----- */
|
|
725
|
-
|
|
726
|
-
handlePaymentEvent(request: PaymentEventRequest): Observable<Ok>;
|
|
727
|
-
|
|
728
|
-
/**
|
|
729
|
-
* Generalized per-provider callback (POST /payments/webhook/:provider).
|
|
730
|
-
* Carries the EXACT raw JSON body: signed providers (Heleket) hash the
|
|
731
|
-
* byte-exact payload, so re-serializing a parsed body would break the sign.
|
|
732
|
-
*/
|
|
733
|
-
|
|
734
|
-
handleProviderCallback(request: ProviderCallbackRequest): Observable<Ok>;
|
|
735
|
-
|
|
736
|
-
/** ----- premium ----- */
|
|
737
|
-
|
|
738
|
-
getPremiumPlans(request: GetPremiumPlansRequest): Observable<PremiumPlansResponse>;
|
|
739
|
-
|
|
740
|
-
purchasePremium(request: PurchasePremiumRequest): Observable<PurchasePremiumResponse>;
|
|
741
|
-
|
|
742
|
-
setPremiumPaymentMethod(request: SetPremiumPaymentMethodRequest): Observable<PremiumPaymentMethodResponse>;
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* 7-day refund window from completedAt. Reverses ledger, calls YooKassa for
|
|
746
|
-
* card purchases, rolls back the subscription's expiresAt by the period.
|
|
747
|
-
*/
|
|
748
|
-
|
|
749
|
-
refundPremium(request: RefundPremiumRequest): Observable<RefundPremiumResponse>;
|
|
750
|
-
|
|
751
|
-
getMyPremiumPayments(request: GetMyPremiumPaymentsRequest): Observable<PremiumPaymentsListResponse>;
|
|
752
|
-
|
|
753
|
-
getPremiumPayment(request: GetPremiumPaymentRequest): Observable<PremiumPaymentRow>;
|
|
754
|
-
|
|
755
|
-
/**
|
|
756
|
-
* Internal — InternalServiceGuard. tasks-service cron triggers due renewals;
|
|
757
|
-
* payments-service iterates ACTIVE subscriptions with autoRenew+savedCard.
|
|
758
|
-
*/
|
|
759
|
-
|
|
760
|
-
runPremiumRenewals(request: RunPremiumRenewalsRequest): Observable<RunPremiumRenewalsResponse>;
|
|
761
|
-
|
|
762
|
-
/** ----- saved cards ----- */
|
|
763
|
-
|
|
764
|
-
listSavedCards(request: ListSavedCardsRequest): Observable<ListSavedCardsResponse>;
|
|
765
|
-
|
|
766
|
-
deleteSavedCard(request: DeleteSavedCardRequest): Observable<Ok>;
|
|
767
|
-
|
|
768
|
-
setDefaultSavedCard(request: SetDefaultSavedCardRequest): Observable<SavedCard>;
|
|
769
|
-
|
|
770
|
-
updateSavedCard(request: UpdateSavedCardRequest): Observable<SavedCard>;
|
|
771
|
-
|
|
772
|
-
/**
|
|
773
|
-
* Standalone "bind card" flow: creates a 1₽ YooKassa charge with
|
|
774
|
-
* save_payment_method=true; after the webhook the SavedCard row is
|
|
775
|
-
* persisted and the 1₽ credits USER_SPENDING so the user keeps it.
|
|
776
|
-
*/
|
|
777
|
-
|
|
778
|
-
bindCard(request: BindCardRequest): Observable<CheckoutResponse>;
|
|
779
|
-
|
|
780
|
-
/**
|
|
781
|
-
* Poll an intent after returnUrl redirect: TOPUP/PREMIUM completion, bind-card
|
|
782
|
-
* completion. Ownership-checked by user_id.
|
|
783
|
-
*/
|
|
784
|
-
|
|
785
|
-
getPaymentIntent(request: GetPaymentIntentRequest): Observable<PaymentIntentStatus>;
|
|
786
|
-
|
|
787
|
-
/**
|
|
788
|
-
* ----- FX / available methods (public, cached) -----
|
|
789
|
-
* Daily CBR rates (RUB base). Frontend uses this for the "≈" display hint;
|
|
790
|
-
* the authoritative charge amount is always computed server-side at checkout.
|
|
791
|
-
*/
|
|
792
|
-
|
|
793
|
-
getRates(request: GetRatesRequest): Observable<GetRatesResponse>;
|
|
794
|
-
|
|
795
|
-
/**
|
|
796
|
-
* Payment methods derived from live provider capabilities — the client
|
|
797
|
-
* renders only what is actually available (e.g. CRYPTO appears once the
|
|
798
|
-
* Heleket merchant is configured).
|
|
799
|
-
*/
|
|
800
|
-
|
|
801
|
-
getPaymentMethods(request: GetPaymentMethodsRequest): Observable<GetPaymentMethodsResponse>;
|
|
802
|
-
|
|
803
|
-
/** ----- payout details ----- */
|
|
804
|
-
|
|
805
|
-
updatePayoutDetails(request: UpdatePayoutDetailsRequest): Observable<UpdatePayoutDetailsResponse>;
|
|
806
|
-
|
|
807
|
-
getPayoutDetails(request: GetPayoutDetailsRequest): Observable<UpdatePayoutDetailsResponse>;
|
|
808
|
-
|
|
809
|
-
/** ----- admin ----- */
|
|
810
|
-
|
|
811
|
-
getAdminOverview(request: AdminOverviewRequest): Observable<AdminOverviewResponse>;
|
|
812
|
-
|
|
813
|
-
adminListTransactions(request: AdminListTransactionsRequest): Observable<AdminTransactionsListResponse>;
|
|
814
|
-
|
|
815
|
-
getUserFinance(request: GetUserFinanceRequest): Observable<UserFinanceResponse>;
|
|
816
|
-
|
|
817
|
-
createAdjustment(request: CreateAdjustmentRequest): Observable<Ok>;
|
|
818
|
-
|
|
819
|
-
getSalesAnalytics(request: SalesAnalyticsRequest): Observable<SalesAnalyticsResponse>;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
/**
|
|
823
|
-
* Commerce + double-entry wallet/ledger (D9 / D9.2). See payments-service/docs/FINANCE.md.
|
|
824
|
-
* Money = Decimal-as-string (D7). Statuses/enums as strings (avoid proto enum
|
|
825
|
-
* value-name clashes within one package).
|
|
826
|
-
*/
|
|
827
|
-
|
|
828
|
-
export interface PaymentsServiceController {
|
|
829
|
-
/** ----- buyer ----- */
|
|
830
|
-
|
|
831
|
-
topup(request: TopupRequest): Promise<CheckoutResponse> | Observable<CheckoutResponse> | CheckoutResponse;
|
|
832
|
-
|
|
833
|
-
createCheckout(
|
|
834
|
-
request: CreateCheckoutRequest,
|
|
835
|
-
): Promise<CheckoutResponse> | Observable<CheckoutResponse> | CheckoutResponse;
|
|
836
|
-
|
|
837
|
-
getMyPurchases(
|
|
838
|
-
request: GetMyPurchasesRequest,
|
|
839
|
-
): Promise<PurchasesListResponse> | Observable<PurchasesListResponse> | PurchasesListResponse;
|
|
840
|
-
|
|
841
|
-
getPurchase(request: GetPurchaseRequest): Promise<Purchase> | Observable<Purchase> | Purchase;
|
|
842
|
-
|
|
843
|
-
refundPurchase(request: RefundPurchaseRequest): Promise<Purchase> | Observable<Purchase> | Purchase;
|
|
844
|
-
|
|
845
|
-
/** ----- wallet ----- */
|
|
846
|
-
|
|
847
|
-
getWallet(request: GetWalletRequest): Promise<WalletResponse> | Observable<WalletResponse> | WalletResponse;
|
|
848
|
-
|
|
849
|
-
listTransactions(
|
|
850
|
-
request: ListTransactionsRequest,
|
|
851
|
-
): Promise<TransactionsListResponse> | Observable<TransactionsListResponse> | TransactionsListResponse;
|
|
852
|
-
|
|
853
|
-
getTransactionMonths(
|
|
854
|
-
request: GetTransactionMonthsRequest,
|
|
855
|
-
): Promise<GetTransactionMonthsResponse> | Observable<GetTransactionMonthsResponse> | GetTransactionMonthsResponse;
|
|
856
|
-
|
|
857
|
-
/** ----- withdrawals ----- */
|
|
858
|
-
|
|
859
|
-
requestWithdrawal(request: RequestWithdrawalRequest): Promise<Withdrawal> | Observable<Withdrawal> | Withdrawal;
|
|
860
|
-
|
|
861
|
-
listWithdrawals(
|
|
862
|
-
request: ListWithdrawalsRequest,
|
|
863
|
-
): Promise<WithdrawalsListResponse> | Observable<WithdrawalsListResponse> | WithdrawalsListResponse;
|
|
864
|
-
|
|
865
|
-
processWithdrawal(request: ProcessWithdrawalRequest): Promise<Withdrawal> | Observable<Withdrawal> | Withdrawal;
|
|
866
|
-
|
|
867
|
-
/** ----- provider webhook (gateway forwards a verified event) ----- */
|
|
868
|
-
|
|
869
|
-
handlePaymentEvent(request: PaymentEventRequest): Promise<Ok> | Observable<Ok> | Ok;
|
|
870
|
-
|
|
871
|
-
/**
|
|
872
|
-
* Generalized per-provider callback (POST /payments/webhook/:provider).
|
|
873
|
-
* Carries the EXACT raw JSON body: signed providers (Heleket) hash the
|
|
874
|
-
* byte-exact payload, so re-serializing a parsed body would break the sign.
|
|
875
|
-
*/
|
|
876
|
-
|
|
877
|
-
handleProviderCallback(request: ProviderCallbackRequest): Promise<Ok> | Observable<Ok> | Ok;
|
|
878
|
-
|
|
879
|
-
/** ----- premium ----- */
|
|
880
|
-
|
|
881
|
-
getPremiumPlans(
|
|
882
|
-
request: GetPremiumPlansRequest,
|
|
883
|
-
): Promise<PremiumPlansResponse> | Observable<PremiumPlansResponse> | PremiumPlansResponse;
|
|
884
|
-
|
|
885
|
-
purchasePremium(
|
|
886
|
-
request: PurchasePremiumRequest,
|
|
887
|
-
): Promise<PurchasePremiumResponse> | Observable<PurchasePremiumResponse> | PurchasePremiumResponse;
|
|
888
|
-
|
|
889
|
-
setPremiumPaymentMethod(
|
|
890
|
-
request: SetPremiumPaymentMethodRequest,
|
|
891
|
-
): Promise<PremiumPaymentMethodResponse> | Observable<PremiumPaymentMethodResponse> | PremiumPaymentMethodResponse;
|
|
892
|
-
|
|
893
|
-
/**
|
|
894
|
-
* 7-day refund window from completedAt. Reverses ledger, calls YooKassa for
|
|
895
|
-
* card purchases, rolls back the subscription's expiresAt by the period.
|
|
896
|
-
*/
|
|
897
|
-
|
|
898
|
-
refundPremium(
|
|
899
|
-
request: RefundPremiumRequest,
|
|
900
|
-
): Promise<RefundPremiumResponse> | Observable<RefundPremiumResponse> | RefundPremiumResponse;
|
|
901
|
-
|
|
902
|
-
getMyPremiumPayments(
|
|
903
|
-
request: GetMyPremiumPaymentsRequest,
|
|
904
|
-
): Promise<PremiumPaymentsListResponse> | Observable<PremiumPaymentsListResponse> | PremiumPaymentsListResponse;
|
|
905
|
-
|
|
906
|
-
getPremiumPayment(
|
|
907
|
-
request: GetPremiumPaymentRequest,
|
|
908
|
-
): Promise<PremiumPaymentRow> | Observable<PremiumPaymentRow> | PremiumPaymentRow;
|
|
909
|
-
|
|
910
|
-
/**
|
|
911
|
-
* Internal — InternalServiceGuard. tasks-service cron triggers due renewals;
|
|
912
|
-
* payments-service iterates ACTIVE subscriptions with autoRenew+savedCard.
|
|
913
|
-
*/
|
|
914
|
-
|
|
915
|
-
runPremiumRenewals(
|
|
916
|
-
request: RunPremiumRenewalsRequest,
|
|
917
|
-
): Promise<RunPremiumRenewalsResponse> | Observable<RunPremiumRenewalsResponse> | RunPremiumRenewalsResponse;
|
|
918
|
-
|
|
919
|
-
/** ----- saved cards ----- */
|
|
920
|
-
|
|
921
|
-
listSavedCards(
|
|
922
|
-
request: ListSavedCardsRequest,
|
|
923
|
-
): Promise<ListSavedCardsResponse> | Observable<ListSavedCardsResponse> | ListSavedCardsResponse;
|
|
924
|
-
|
|
925
|
-
deleteSavedCard(request: DeleteSavedCardRequest): Promise<Ok> | Observable<Ok> | Ok;
|
|
926
|
-
|
|
927
|
-
setDefaultSavedCard(request: SetDefaultSavedCardRequest): Promise<SavedCard> | Observable<SavedCard> | SavedCard;
|
|
928
|
-
|
|
929
|
-
updateSavedCard(request: UpdateSavedCardRequest): Promise<SavedCard> | Observable<SavedCard> | SavedCard;
|
|
930
|
-
|
|
931
|
-
/**
|
|
932
|
-
* Standalone "bind card" flow: creates a 1₽ YooKassa charge with
|
|
933
|
-
* save_payment_method=true; after the webhook the SavedCard row is
|
|
934
|
-
* persisted and the 1₽ credits USER_SPENDING so the user keeps it.
|
|
935
|
-
*/
|
|
936
|
-
|
|
937
|
-
bindCard(request: BindCardRequest): Promise<CheckoutResponse> | Observable<CheckoutResponse> | CheckoutResponse;
|
|
938
|
-
|
|
939
|
-
/**
|
|
940
|
-
* Poll an intent after returnUrl redirect: TOPUP/PREMIUM completion, bind-card
|
|
941
|
-
* completion. Ownership-checked by user_id.
|
|
942
|
-
*/
|
|
943
|
-
|
|
944
|
-
getPaymentIntent(
|
|
945
|
-
request: GetPaymentIntentRequest,
|
|
946
|
-
): Promise<PaymentIntentStatus> | Observable<PaymentIntentStatus> | PaymentIntentStatus;
|
|
947
|
-
|
|
948
|
-
/**
|
|
949
|
-
* ----- FX / available methods (public, cached) -----
|
|
950
|
-
* Daily CBR rates (RUB base). Frontend uses this for the "≈" display hint;
|
|
951
|
-
* the authoritative charge amount is always computed server-side at checkout.
|
|
952
|
-
*/
|
|
953
|
-
|
|
954
|
-
getRates(request: GetRatesRequest): Promise<GetRatesResponse> | Observable<GetRatesResponse> | GetRatesResponse;
|
|
955
|
-
|
|
956
|
-
/**
|
|
957
|
-
* Payment methods derived from live provider capabilities — the client
|
|
958
|
-
* renders only what is actually available (e.g. CRYPTO appears once the
|
|
959
|
-
* Heleket merchant is configured).
|
|
960
|
-
*/
|
|
961
|
-
|
|
962
|
-
getPaymentMethods(
|
|
963
|
-
request: GetPaymentMethodsRequest,
|
|
964
|
-
): Promise<GetPaymentMethodsResponse> | Observable<GetPaymentMethodsResponse> | GetPaymentMethodsResponse;
|
|
965
|
-
|
|
966
|
-
/** ----- payout details ----- */
|
|
967
|
-
|
|
968
|
-
updatePayoutDetails(
|
|
969
|
-
request: UpdatePayoutDetailsRequest,
|
|
970
|
-
): Promise<UpdatePayoutDetailsResponse> | Observable<UpdatePayoutDetailsResponse> | UpdatePayoutDetailsResponse;
|
|
971
|
-
|
|
972
|
-
getPayoutDetails(
|
|
973
|
-
request: GetPayoutDetailsRequest,
|
|
974
|
-
): Promise<UpdatePayoutDetailsResponse> | Observable<UpdatePayoutDetailsResponse> | UpdatePayoutDetailsResponse;
|
|
975
|
-
|
|
976
|
-
/** ----- admin ----- */
|
|
977
|
-
|
|
978
|
-
getAdminOverview(
|
|
979
|
-
request: AdminOverviewRequest,
|
|
980
|
-
): Promise<AdminOverviewResponse> | Observable<AdminOverviewResponse> | AdminOverviewResponse;
|
|
981
|
-
|
|
982
|
-
adminListTransactions(
|
|
983
|
-
request: AdminListTransactionsRequest,
|
|
984
|
-
): Promise<AdminTransactionsListResponse> | Observable<AdminTransactionsListResponse> | AdminTransactionsListResponse;
|
|
985
|
-
|
|
986
|
-
getUserFinance(
|
|
987
|
-
request: GetUserFinanceRequest,
|
|
988
|
-
): Promise<UserFinanceResponse> | Observable<UserFinanceResponse> | UserFinanceResponse;
|
|
989
|
-
|
|
990
|
-
createAdjustment(request: CreateAdjustmentRequest): Promise<Ok> | Observable<Ok> | Ok;
|
|
991
|
-
|
|
992
|
-
getSalesAnalytics(
|
|
993
|
-
request: SalesAnalyticsRequest,
|
|
994
|
-
): Promise<SalesAnalyticsResponse> | Observable<SalesAnalyticsResponse> | SalesAnalyticsResponse;
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
export function PaymentsServiceControllerMethods() {
|
|
998
|
-
return function (constructor: Function) {
|
|
999
|
-
const grpcMethods: string[] = [
|
|
1000
|
-
"topup",
|
|
1001
|
-
"createCheckout",
|
|
1002
|
-
"getMyPurchases",
|
|
1003
|
-
"getPurchase",
|
|
1004
|
-
"refundPurchase",
|
|
1005
|
-
"getWallet",
|
|
1006
|
-
"listTransactions",
|
|
1007
|
-
"getTransactionMonths",
|
|
1008
|
-
"requestWithdrawal",
|
|
1009
|
-
"listWithdrawals",
|
|
1010
|
-
"processWithdrawal",
|
|
1011
|
-
"handlePaymentEvent",
|
|
1012
|
-
"handleProviderCallback",
|
|
1013
|
-
"getPremiumPlans",
|
|
1014
|
-
"purchasePremium",
|
|
1015
|
-
"setPremiumPaymentMethod",
|
|
1016
|
-
"refundPremium",
|
|
1017
|
-
"getMyPremiumPayments",
|
|
1018
|
-
"getPremiumPayment",
|
|
1019
|
-
"runPremiumRenewals",
|
|
1020
|
-
"listSavedCards",
|
|
1021
|
-
"deleteSavedCard",
|
|
1022
|
-
"setDefaultSavedCard",
|
|
1023
|
-
"updateSavedCard",
|
|
1024
|
-
"bindCard",
|
|
1025
|
-
"getPaymentIntent",
|
|
1026
|
-
"getRates",
|
|
1027
|
-
"getPaymentMethods",
|
|
1028
|
-
"updatePayoutDetails",
|
|
1029
|
-
"getPayoutDetails",
|
|
1030
|
-
"getAdminOverview",
|
|
1031
|
-
"adminListTransactions",
|
|
1032
|
-
"getUserFinance",
|
|
1033
|
-
"createAdjustment",
|
|
1034
|
-
"getSalesAnalytics",
|
|
1035
|
-
];
|
|
1036
|
-
for (const method of grpcMethods) {
|
|
1037
|
-
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
1038
|
-
GrpcMethod("PaymentsService", method)(constructor.prototype[method], method, descriptor);
|
|
1039
|
-
}
|
|
1040
|
-
const grpcStreamMethods: string[] = [];
|
|
1041
|
-
for (const method of grpcStreamMethods) {
|
|
1042
|
-
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
1043
|
-
GrpcStreamMethod("PaymentsService", method)(constructor.prototype[method], method, descriptor);
|
|
1044
|
-
}
|
|
1045
|
-
};
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
export const PAYMENTS_SERVICE_NAME = "PaymentsService";
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.10.1
|
|
4
|
+
// protoc v7.35.0
|
|
5
|
+
// source: payments.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
9
|
+
import { Observable } from "rxjs";
|
|
10
|
+
|
|
11
|
+
export const protobufPackage = "payments.v1";
|
|
12
|
+
|
|
13
|
+
export interface Ok {
|
|
14
|
+
ok: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* ---------------------------------------------------------------------------
|
|
19
|
+
* Purchase / checkout / topup
|
|
20
|
+
* ---------------------------------------------------------------------------
|
|
21
|
+
*/
|
|
22
|
+
export interface Purchase {
|
|
23
|
+
id: string;
|
|
24
|
+
productId: string;
|
|
25
|
+
productName: string;
|
|
26
|
+
userId: string;
|
|
27
|
+
/** settled RUB amount */
|
|
28
|
+
price: string;
|
|
29
|
+
/** PENDING | COMPLETED | FAILED | REFUNDED */
|
|
30
|
+
status: string;
|
|
31
|
+
paymentId: string;
|
|
32
|
+
/** BALANCE | YOOKASSA | CRYPTO */
|
|
33
|
+
paymentMethod: string;
|
|
34
|
+
commissionPercent: string;
|
|
35
|
+
sellerAmount: string;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
completedAt: string;
|
|
38
|
+
/** FX snapshot at checkout (empty for legacy RUB purchases). */
|
|
39
|
+
listingCurrency: string;
|
|
40
|
+
/** Decimal as string, in listing_currency */
|
|
41
|
+
listingPrice: string;
|
|
42
|
+
/** listing→RUB rate used (Decimal as string) */
|
|
43
|
+
fxRate: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface TopupRequest {
|
|
47
|
+
userId: string;
|
|
48
|
+
/** >= 10.00 */
|
|
49
|
+
amount: string;
|
|
50
|
+
returnUrl: string;
|
|
51
|
+
/** YOOKASSA | SAVED_CARD | CRYPTO (default YOOKASSA) */
|
|
52
|
+
paymentMethod: string;
|
|
53
|
+
/** required when payment_method=SAVED_CARD */
|
|
54
|
+
savedCardId: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface CreateCheckoutRequest {
|
|
58
|
+
userId: string;
|
|
59
|
+
productId: string;
|
|
60
|
+
/** BALANCE | YOOKASSA | SAVED_CARD | CRYPTO (default YOOKASSA) */
|
|
61
|
+
paymentMethod: string;
|
|
62
|
+
returnUrl: string;
|
|
63
|
+
/**
|
|
64
|
+
* When payment_method=SAVED_CARD — required. ID of a SavedCard row owned
|
|
65
|
+
* by user_id. Ignored otherwise.
|
|
66
|
+
*/
|
|
67
|
+
savedCardId: string;
|
|
68
|
+
/**
|
|
69
|
+
* When payment_method=YOOKASSA — optional. If true, save the card token
|
|
70
|
+
* after success; the bound card becomes available in /account/cards.
|
|
71
|
+
*/
|
|
72
|
+
savePaymentMethod: boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface BindCardRequest {
|
|
76
|
+
userId: string;
|
|
77
|
+
returnUrl: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface GetPaymentIntentRequest {
|
|
81
|
+
intentId: string;
|
|
82
|
+
/** ownership check */
|
|
83
|
+
userId: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface PaymentIntentStatus {
|
|
87
|
+
id: string;
|
|
88
|
+
userId: string;
|
|
89
|
+
/** TOPUP | PREMIUM */
|
|
90
|
+
purpose: string;
|
|
91
|
+
/** PENDING | COMPLETED | FAILED | CANCELED */
|
|
92
|
+
status: string;
|
|
93
|
+
amount: string;
|
|
94
|
+
currency: string;
|
|
95
|
+
/** set when purpose=PREMIUM (else empty) */
|
|
96
|
+
purchaseId: string;
|
|
97
|
+
createdAt: string;
|
|
98
|
+
updatedAt: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface CheckoutResponse {
|
|
102
|
+
purchaseId: string;
|
|
103
|
+
paymentId: string;
|
|
104
|
+
/** empty when paid from balance (instant) */
|
|
105
|
+
confirmationUrl: string;
|
|
106
|
+
/** PENDING (redirect) | COMPLETED (balance) */
|
|
107
|
+
status: string;
|
|
108
|
+
/** poll via GetPaymentIntent for TOPUP / bind-card flows */
|
|
109
|
+
intentId: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface GetMyPurchasesRequest {
|
|
113
|
+
userId: string;
|
|
114
|
+
page: number;
|
|
115
|
+
limit: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface PurchasesListResponse {
|
|
119
|
+
items: Purchase[];
|
|
120
|
+
total: number;
|
|
121
|
+
page: number;
|
|
122
|
+
limit: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface GetPurchaseRequest {
|
|
126
|
+
id: string;
|
|
127
|
+
userId: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface RefundPurchaseRequest {
|
|
131
|
+
purchaseId: string;
|
|
132
|
+
actorUserId: string;
|
|
133
|
+
isAdmin: boolean;
|
|
134
|
+
reason: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* ---------------------------------------------------------------------------
|
|
139
|
+
* Wallet & statement
|
|
140
|
+
* ---------------------------------------------------------------------------
|
|
141
|
+
*/
|
|
142
|
+
export interface GetWalletRequest {
|
|
143
|
+
userId: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface WalletResponse {
|
|
147
|
+
spending: string;
|
|
148
|
+
pending: string;
|
|
149
|
+
payout: string;
|
|
150
|
+
/** spending + payout */
|
|
151
|
+
spendable: string;
|
|
152
|
+
/** payout */
|
|
153
|
+
withdrawable: string;
|
|
154
|
+
currency: string;
|
|
155
|
+
lifetimeSales: number;
|
|
156
|
+
currentCommissionPercent: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface ListTransactionsRequest {
|
|
160
|
+
userId: string;
|
|
161
|
+
/**
|
|
162
|
+
* Legacy low-level filter (one of LedgerTxType). Kept for backward
|
|
163
|
+
* compatibility — admin tooling still uses it directly.
|
|
164
|
+
*/
|
|
165
|
+
type: string;
|
|
166
|
+
page: number;
|
|
167
|
+
limit: number;
|
|
168
|
+
/**
|
|
169
|
+
* ↓ added for the wallet statement page (Round 3)
|
|
170
|
+
* UI-semantic filter mapped onto displayKind:
|
|
171
|
+
* ALL | SALES | INCOME | OUTCOME | REFUND | WITHDRAWAL | PREMIUM
|
|
172
|
+
* SALES = the seller's earnings on this account (USER_PENDING credits from
|
|
173
|
+
* PURCHASE transactions); these stay separate from INCOME (TOPUP).
|
|
174
|
+
*/
|
|
175
|
+
flow: string;
|
|
176
|
+
/**
|
|
177
|
+
* Period selection. `month` is the convenience form (YYYY-MM) used by the
|
|
178
|
+
* month dropdown; from/to override it for an arbitrary range.
|
|
179
|
+
*/
|
|
180
|
+
month: string;
|
|
181
|
+
from: string;
|
|
182
|
+
to: string;
|
|
183
|
+
/**
|
|
184
|
+
* Filter wallet to purchases/refunds of a specific Product category. Has
|
|
185
|
+
* no effect on TOPUP/WITHDRAWAL/PREMIUM/ADJUSTMENT entries (they have no
|
|
186
|
+
* product).
|
|
187
|
+
*/
|
|
188
|
+
productCategoryId: string;
|
|
189
|
+
/** sort_by ∈ { date | amount | type }. Default: date. */
|
|
190
|
+
sortBy: string;
|
|
191
|
+
/** order ∈ { asc | desc }. Default: desc. */
|
|
192
|
+
order: string;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface StatementEntry {
|
|
196
|
+
id: string;
|
|
197
|
+
txId: string;
|
|
198
|
+
/** raw tx type (TOPUP|PURCHASE|...) */
|
|
199
|
+
type: string;
|
|
200
|
+
accountKind: string;
|
|
201
|
+
/** DEBIT | CREDIT */
|
|
202
|
+
direction: string;
|
|
203
|
+
amount: string;
|
|
204
|
+
description: string;
|
|
205
|
+
createdAt: string;
|
|
206
|
+
/**
|
|
207
|
+
* ↓ added for the wallet statement page (Round 3)
|
|
208
|
+
* UI-friendly classification computed server-side:
|
|
209
|
+
* TOPUP | PURCHASE | SALE | REFUND | PREMIUM | WITHDRAWAL | ADJUSTMENT
|
|
210
|
+
* SALE is the seller's view of someone else's PURCHASE (CREDIT to their
|
|
211
|
+
* USER_PENDING) — distinct from PURCHASE which is the buyer's DEBIT.
|
|
212
|
+
* PREMIUM is split out of PURCHASE/REFUND so the UI can show
|
|
213
|
+
* "Продление Premium" / refund-of-premium in their own filter bucket.
|
|
214
|
+
* SALE_CLEAR transactions are excluded from the wallet view — the maturity
|
|
215
|
+
* event is surfaced via sale_status on the original SALE row instead.
|
|
216
|
+
*/
|
|
217
|
+
displayKind: string;
|
|
218
|
+
/** affected-account running balance, Decimal-as-string */
|
|
219
|
+
balanceAfter: string;
|
|
220
|
+
/** empty for non-product entries */
|
|
221
|
+
productId: string;
|
|
222
|
+
productName: string;
|
|
223
|
+
/** "Assets" | "Project File" | "Templates" */
|
|
224
|
+
productCategory: string;
|
|
225
|
+
/** optional thumbnail URL for richer rows */
|
|
226
|
+
productPreview: string;
|
|
227
|
+
/**
|
|
228
|
+
* Sale lifecycle. Populated only when display_kind=SALE.
|
|
229
|
+
* PENDING — held in USER_PENDING, not yet withdrawable.
|
|
230
|
+
* MATURED — SALE_CLEAR has fired; money is in USER_PAYOUT.
|
|
231
|
+
*/
|
|
232
|
+
saleStatus: string;
|
|
233
|
+
/**
|
|
234
|
+
* ISO 8601 when the sale becomes withdrawable (sale_completed_at +
|
|
235
|
+
* GRACE_DAYS). Empty for non-sale rows.
|
|
236
|
+
*/
|
|
237
|
+
maturesAt: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface TransactionsListResponse {
|
|
241
|
+
items: StatementEntry[];
|
|
242
|
+
total: number;
|
|
243
|
+
page: number;
|
|
244
|
+
limit: number;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface GetTransactionMonthsRequest {
|
|
248
|
+
userId: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface GetTransactionMonthsResponse {
|
|
252
|
+
/**
|
|
253
|
+
* Newest first. "YYYY-MM" strings; the dropdown renders them
|
|
254
|
+
* localized client-side.
|
|
255
|
+
*/
|
|
256
|
+
months: string[];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* ---------------------------------------------------------------------------
|
|
261
|
+
* Withdrawals
|
|
262
|
+
* ---------------------------------------------------------------------------
|
|
263
|
+
*/
|
|
264
|
+
export interface Withdrawal {
|
|
265
|
+
id: string;
|
|
266
|
+
sellerId: string;
|
|
267
|
+
amount: string;
|
|
268
|
+
/** PENDING | PROCESSING | COMPLETED | REJECTED */
|
|
269
|
+
status: string;
|
|
270
|
+
method: string;
|
|
271
|
+
details: string;
|
|
272
|
+
comment: string;
|
|
273
|
+
processedBy: string;
|
|
274
|
+
processedAt: string;
|
|
275
|
+
createdAt: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export interface RequestWithdrawalRequest {
|
|
279
|
+
sellerId: string;
|
|
280
|
+
amount: string;
|
|
281
|
+
method: string;
|
|
282
|
+
details: string;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export interface ListWithdrawalsRequest {
|
|
286
|
+
sellerId: string;
|
|
287
|
+
status: string;
|
|
288
|
+
page: number;
|
|
289
|
+
limit: number;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface WithdrawalsListResponse {
|
|
293
|
+
items: Withdrawal[];
|
|
294
|
+
total: number;
|
|
295
|
+
page: number;
|
|
296
|
+
limit: number;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export interface ProcessWithdrawalRequest {
|
|
300
|
+
withdrawalId: string;
|
|
301
|
+
adminId: string;
|
|
302
|
+
action: string;
|
|
303
|
+
comment: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* ---------------------------------------------------------------------------
|
|
308
|
+
* Webhook
|
|
309
|
+
* ---------------------------------------------------------------------------
|
|
310
|
+
*/
|
|
311
|
+
export interface PaymentEventRequest {
|
|
312
|
+
event: string;
|
|
313
|
+
paymentId: string;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface ProviderCallbackRequest {
|
|
317
|
+
/** yookassa | heleket | … */
|
|
318
|
+
provider: string;
|
|
319
|
+
/** exact raw JSON body as received (signature input) */
|
|
320
|
+
rawBody: string;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* ---------------------------------------------------------------------------
|
|
325
|
+
* FX rates / payment methods
|
|
326
|
+
* ---------------------------------------------------------------------------
|
|
327
|
+
*/
|
|
328
|
+
export interface GetRatesRequest {
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export interface FxRate {
|
|
332
|
+
/** USD | EUR */
|
|
333
|
+
currency: string;
|
|
334
|
+
/** RUB per 1 unit, Decimal as string */
|
|
335
|
+
rate: string;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export interface GetRatesResponse {
|
|
339
|
+
/** always RUB */
|
|
340
|
+
base: string;
|
|
341
|
+
/** YYYY-MM-DD the rates are for */
|
|
342
|
+
asOf: string;
|
|
343
|
+
rates: FxRate[];
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export interface GetPaymentMethodsRequest {
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export interface PaymentMethodInfo {
|
|
350
|
+
/** YOOKASSA | SAVED_CARD | CRYPTO | BALANCE */
|
|
351
|
+
method: string;
|
|
352
|
+
/** yookassa | heleket | '' (BALANCE) */
|
|
353
|
+
provider: string;
|
|
354
|
+
currencies: string[];
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export interface GetPaymentMethodsResponse {
|
|
358
|
+
methods: PaymentMethodInfo[];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* ---------------------------------------------------------------------------
|
|
363
|
+
* Admin
|
|
364
|
+
* ---------------------------------------------------------------------------
|
|
365
|
+
*/
|
|
366
|
+
export interface AdminOverviewRequest {
|
|
367
|
+
from: string;
|
|
368
|
+
to: string;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export interface AdminOverviewResponse {
|
|
372
|
+
/** platform commission earned (period) */
|
|
373
|
+
revenue: string;
|
|
374
|
+
/** gross merchandise value (period) */
|
|
375
|
+
gmv: string;
|
|
376
|
+
/** Σ all users' (pending+payout+spending) — what we owe */
|
|
377
|
+
liabilities: string;
|
|
378
|
+
/** money in transit at PSP */
|
|
379
|
+
pspClearing: string;
|
|
380
|
+
/** reserved for approved withdrawals */
|
|
381
|
+
payoutsPayable: string;
|
|
382
|
+
refundsTotal: string;
|
|
383
|
+
topupsTotal: string;
|
|
384
|
+
withdrawalsTotal: string;
|
|
385
|
+
salesCount: number;
|
|
386
|
+
currency: string;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export interface AdminListTransactionsRequest {
|
|
390
|
+
type: string;
|
|
391
|
+
userId: string;
|
|
392
|
+
accountKind: string;
|
|
393
|
+
from: string;
|
|
394
|
+
to: string;
|
|
395
|
+
page: number;
|
|
396
|
+
limit: number;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export interface AdminEntry {
|
|
400
|
+
accountId: string;
|
|
401
|
+
accountKind: string;
|
|
402
|
+
ownerId: string;
|
|
403
|
+
direction: string;
|
|
404
|
+
amount: string;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export interface AdminLedgerTx {
|
|
408
|
+
id: string;
|
|
409
|
+
type: string;
|
|
410
|
+
status: string;
|
|
411
|
+
refType: string;
|
|
412
|
+
refId: string;
|
|
413
|
+
description: string;
|
|
414
|
+
createdBy: string;
|
|
415
|
+
createdAt: string;
|
|
416
|
+
entries: AdminEntry[];
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export interface AdminTransactionsListResponse {
|
|
420
|
+
items: AdminLedgerTx[];
|
|
421
|
+
total: number;
|
|
422
|
+
page: number;
|
|
423
|
+
limit: number;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export interface GetUserFinanceRequest {
|
|
427
|
+
userId: string;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export interface AccountBalance {
|
|
431
|
+
kind: string;
|
|
432
|
+
balance: string;
|
|
433
|
+
currency: string;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export interface UserFinanceResponse {
|
|
437
|
+
wallet: WalletResponse | undefined;
|
|
438
|
+
accounts: AccountBalance[];
|
|
439
|
+
recent: StatementEntry[];
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export interface CreateAdjustmentRequest {
|
|
443
|
+
adminId: string;
|
|
444
|
+
userId: string;
|
|
445
|
+
/** USER_SPENDING | USER_PAYOUT | USER_PENDING */
|
|
446
|
+
accountKind: string;
|
|
447
|
+
/** CREDIT (give) | DEBIT (take) */
|
|
448
|
+
direction: string;
|
|
449
|
+
amount: string;
|
|
450
|
+
reason: string;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export interface SalesAnalyticsRequest {
|
|
454
|
+
from: string;
|
|
455
|
+
to: string;
|
|
456
|
+
granularity: string;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export interface SalesPoint {
|
|
460
|
+
date: string;
|
|
461
|
+
salesCount: number;
|
|
462
|
+
gmv: string;
|
|
463
|
+
revenue: string;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export interface SellerStat {
|
|
467
|
+
sellerId: string;
|
|
468
|
+
username: string;
|
|
469
|
+
sales: number;
|
|
470
|
+
gmv: string;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface SalesAnalyticsResponse {
|
|
474
|
+
points: SalesPoint[];
|
|
475
|
+
topSellers: SellerStat[];
|
|
476
|
+
/** % refunded purchases */
|
|
477
|
+
refundRate: string;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* ---------------------------------------------------------------------------
|
|
482
|
+
* Premium
|
|
483
|
+
* ---------------------------------------------------------------------------
|
|
484
|
+
*/
|
|
485
|
+
export interface GetPremiumPlansRequest {
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* One plan per (period). Prices are computed server-side from BASE_PRICE × months
|
|
490
|
+
* × (1 − discount); kept here as canonical strings so the gateway has no math.
|
|
491
|
+
*/
|
|
492
|
+
export interface PremiumPlan {
|
|
493
|
+
/** MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12 */
|
|
494
|
+
period: string;
|
|
495
|
+
months: number;
|
|
496
|
+
/** total to charge, Decimal-as-string */
|
|
497
|
+
price: string;
|
|
498
|
+
/** for UI "≈ X ₽/month" */
|
|
499
|
+
monthlyPrice: string;
|
|
500
|
+
discountPercent: string;
|
|
501
|
+
currency: string;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export interface PremiumPlansResponse {
|
|
505
|
+
plans: PremiumPlan[];
|
|
506
|
+
baseMonthlyPrice: string;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
export interface PurchasePremiumRequest {
|
|
510
|
+
userId: string;
|
|
511
|
+
/** MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12 */
|
|
512
|
+
period: string;
|
|
513
|
+
/** BALANCE | YOOKASSA | SAVED_CARD (empty = smart default) */
|
|
514
|
+
paymentMethod: string;
|
|
515
|
+
/** YooKassa only */
|
|
516
|
+
returnUrl: string;
|
|
517
|
+
/**
|
|
518
|
+
* Save the YooKassa payment_method for future auto-renewals. Ignored for
|
|
519
|
+
* BALANCE. Kept for backwards compatibility; auto_renew=true implies save.
|
|
520
|
+
*/
|
|
521
|
+
savePaymentMethod: boolean;
|
|
522
|
+
/** default false; requires off-session-capable method */
|
|
523
|
+
autoRenew: boolean;
|
|
524
|
+
/** optional for SAVED_CARD; empty = default card */
|
|
525
|
+
savedCardId: string;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
export interface PurchasePremiumResponse {
|
|
529
|
+
/** PremiumPayment.id */
|
|
530
|
+
paymentId: string;
|
|
531
|
+
/** empty for BALANCE (instant) or YooKassa-issued */
|
|
532
|
+
confirmationUrl: string;
|
|
533
|
+
/** PENDING (redirect) | COMPLETED (balance) */
|
|
534
|
+
status: string;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
export interface RunPremiumRenewalsRequest {
|
|
538
|
+
/** safety cap; default 100 */
|
|
539
|
+
maxBatch: number;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
export interface RunPremiumRenewalsResponse {
|
|
543
|
+
attempted: number;
|
|
544
|
+
succeeded: number;
|
|
545
|
+
failed: number;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
export interface SetPremiumPaymentMethodRequest {
|
|
549
|
+
userId: string;
|
|
550
|
+
/** BALANCE | YOOKASSA | SAVED_CARD */
|
|
551
|
+
method: string;
|
|
552
|
+
/** optional for SAVED_CARD; empty = default card */
|
|
553
|
+
savedCardId: string;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
export interface PremiumPaymentMethodResponse {
|
|
557
|
+
/** BALANCE | YOOKASSA | SAVED_CARD */
|
|
558
|
+
method: string;
|
|
559
|
+
/** empty unless SAVED_CARD */
|
|
560
|
+
savedCardId: string;
|
|
561
|
+
autoRenew: boolean;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
export interface PremiumPaymentRow {
|
|
565
|
+
id: string;
|
|
566
|
+
userId: string;
|
|
567
|
+
amount: string;
|
|
568
|
+
/** MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12 */
|
|
569
|
+
period: string;
|
|
570
|
+
/** BALANCE | YOOKASSA */
|
|
571
|
+
method: string;
|
|
572
|
+
/** PENDING | COMPLETED | FAILED | REFUNDED */
|
|
573
|
+
status: string;
|
|
574
|
+
isRenewal: boolean;
|
|
575
|
+
createdAt: string;
|
|
576
|
+
completedAt: string;
|
|
577
|
+
refundedAt: string;
|
|
578
|
+
refundedAmount: string;
|
|
579
|
+
/**
|
|
580
|
+
* Convenience: true if this payment is currently inside the 7-day refund
|
|
581
|
+
* window AND status == COMPLETED AND not already refunded.
|
|
582
|
+
*/
|
|
583
|
+
refundable: boolean;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
export interface RefundPremiumRequest {
|
|
587
|
+
userId: string;
|
|
588
|
+
paymentId: string;
|
|
589
|
+
/** optional */
|
|
590
|
+
reason: string;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export interface RefundPremiumResponse {
|
|
594
|
+
payment:
|
|
595
|
+
| PremiumPaymentRow
|
|
596
|
+
| undefined;
|
|
597
|
+
/** ISO 8601 after rollback */
|
|
598
|
+
newExpiresAt: string;
|
|
599
|
+
/** true when rollback put expiresAt <= now */
|
|
600
|
+
subscriptionRevoked: boolean;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export interface GetMyPremiumPaymentsRequest {
|
|
604
|
+
userId: string;
|
|
605
|
+
page: number;
|
|
606
|
+
limit: number;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
export interface GetPremiumPaymentRequest {
|
|
610
|
+
userId: string;
|
|
611
|
+
paymentId: string;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export interface PremiumPaymentsListResponse {
|
|
615
|
+
items: PremiumPaymentRow[];
|
|
616
|
+
total: number;
|
|
617
|
+
page: number;
|
|
618
|
+
limit: number;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* ---------------------------------------------------------------------------
|
|
623
|
+
* Saved cards (YooKassa payment_method tokens; we never see PAN)
|
|
624
|
+
* ---------------------------------------------------------------------------
|
|
625
|
+
*/
|
|
626
|
+
export interface SavedCard {
|
|
627
|
+
id: string;
|
|
628
|
+
/** "MIR" | "VISA" | "MASTERCARD" | "" */
|
|
629
|
+
brand: string;
|
|
630
|
+
/** "0000" etc, display-only */
|
|
631
|
+
last4: string;
|
|
632
|
+
expMonth: number;
|
|
633
|
+
expYear: number;
|
|
634
|
+
isDefault: boolean;
|
|
635
|
+
/** user-set label */
|
|
636
|
+
nickname: string;
|
|
637
|
+
createdAt: string;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
export interface ListSavedCardsRequest {
|
|
641
|
+
userId: string;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
export interface ListSavedCardsResponse {
|
|
645
|
+
items: SavedCard[];
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
export interface DeleteSavedCardRequest {
|
|
649
|
+
userId: string;
|
|
650
|
+
id: string;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
export interface SetDefaultSavedCardRequest {
|
|
654
|
+
userId: string;
|
|
655
|
+
id: string;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
export interface UpdateSavedCardRequest {
|
|
659
|
+
userId: string;
|
|
660
|
+
id: string;
|
|
661
|
+
/** empty = clear */
|
|
662
|
+
nickname: string;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* ---------------------------------------------------------------------------
|
|
667
|
+
* Payout details (persistent default; per-withdrawal override still allowed)
|
|
668
|
+
* ---------------------------------------------------------------------------
|
|
669
|
+
*/
|
|
670
|
+
export interface UpdatePayoutDetailsRequest {
|
|
671
|
+
userId: string;
|
|
672
|
+
/** "card" | "sbp" | "bank" | "" (clear) */
|
|
673
|
+
method: string;
|
|
674
|
+
/** JSON string — payments-service treats opaquely */
|
|
675
|
+
details: string;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
export interface UpdatePayoutDetailsResponse {
|
|
679
|
+
method: string;
|
|
680
|
+
details: string;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
export interface GetPayoutDetailsRequest {
|
|
684
|
+
userId: string;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
export const PAYMENTS_V1_PACKAGE_NAME = "payments.v1";
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Commerce + double-entry wallet/ledger (D9 / D9.2). See payments-service/docs/FINANCE.md.
|
|
691
|
+
* Money = Decimal-as-string (D7). Statuses/enums as strings (avoid proto enum
|
|
692
|
+
* value-name clashes within one package).
|
|
693
|
+
*/
|
|
694
|
+
|
|
695
|
+
export interface PaymentsServiceClient {
|
|
696
|
+
/** ----- buyer ----- */
|
|
697
|
+
|
|
698
|
+
topup(request: TopupRequest): Observable<CheckoutResponse>;
|
|
699
|
+
|
|
700
|
+
createCheckout(request: CreateCheckoutRequest): Observable<CheckoutResponse>;
|
|
701
|
+
|
|
702
|
+
getMyPurchases(request: GetMyPurchasesRequest): Observable<PurchasesListResponse>;
|
|
703
|
+
|
|
704
|
+
getPurchase(request: GetPurchaseRequest): Observable<Purchase>;
|
|
705
|
+
|
|
706
|
+
refundPurchase(request: RefundPurchaseRequest): Observable<Purchase>;
|
|
707
|
+
|
|
708
|
+
/** ----- wallet ----- */
|
|
709
|
+
|
|
710
|
+
getWallet(request: GetWalletRequest): Observable<WalletResponse>;
|
|
711
|
+
|
|
712
|
+
listTransactions(request: ListTransactionsRequest): Observable<TransactionsListResponse>;
|
|
713
|
+
|
|
714
|
+
getTransactionMonths(request: GetTransactionMonthsRequest): Observable<GetTransactionMonthsResponse>;
|
|
715
|
+
|
|
716
|
+
/** ----- withdrawals ----- */
|
|
717
|
+
|
|
718
|
+
requestWithdrawal(request: RequestWithdrawalRequest): Observable<Withdrawal>;
|
|
719
|
+
|
|
720
|
+
listWithdrawals(request: ListWithdrawalsRequest): Observable<WithdrawalsListResponse>;
|
|
721
|
+
|
|
722
|
+
processWithdrawal(request: ProcessWithdrawalRequest): Observable<Withdrawal>;
|
|
723
|
+
|
|
724
|
+
/** ----- provider webhook (gateway forwards a verified event) ----- */
|
|
725
|
+
|
|
726
|
+
handlePaymentEvent(request: PaymentEventRequest): Observable<Ok>;
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Generalized per-provider callback (POST /payments/webhook/:provider).
|
|
730
|
+
* Carries the EXACT raw JSON body: signed providers (Heleket) hash the
|
|
731
|
+
* byte-exact payload, so re-serializing a parsed body would break the sign.
|
|
732
|
+
*/
|
|
733
|
+
|
|
734
|
+
handleProviderCallback(request: ProviderCallbackRequest): Observable<Ok>;
|
|
735
|
+
|
|
736
|
+
/** ----- premium ----- */
|
|
737
|
+
|
|
738
|
+
getPremiumPlans(request: GetPremiumPlansRequest): Observable<PremiumPlansResponse>;
|
|
739
|
+
|
|
740
|
+
purchasePremium(request: PurchasePremiumRequest): Observable<PurchasePremiumResponse>;
|
|
741
|
+
|
|
742
|
+
setPremiumPaymentMethod(request: SetPremiumPaymentMethodRequest): Observable<PremiumPaymentMethodResponse>;
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* 7-day refund window from completedAt. Reverses ledger, calls YooKassa for
|
|
746
|
+
* card purchases, rolls back the subscription's expiresAt by the period.
|
|
747
|
+
*/
|
|
748
|
+
|
|
749
|
+
refundPremium(request: RefundPremiumRequest): Observable<RefundPremiumResponse>;
|
|
750
|
+
|
|
751
|
+
getMyPremiumPayments(request: GetMyPremiumPaymentsRequest): Observable<PremiumPaymentsListResponse>;
|
|
752
|
+
|
|
753
|
+
getPremiumPayment(request: GetPremiumPaymentRequest): Observable<PremiumPaymentRow>;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Internal — InternalServiceGuard. tasks-service cron triggers due renewals;
|
|
757
|
+
* payments-service iterates ACTIVE subscriptions with autoRenew+savedCard.
|
|
758
|
+
*/
|
|
759
|
+
|
|
760
|
+
runPremiumRenewals(request: RunPremiumRenewalsRequest): Observable<RunPremiumRenewalsResponse>;
|
|
761
|
+
|
|
762
|
+
/** ----- saved cards ----- */
|
|
763
|
+
|
|
764
|
+
listSavedCards(request: ListSavedCardsRequest): Observable<ListSavedCardsResponse>;
|
|
765
|
+
|
|
766
|
+
deleteSavedCard(request: DeleteSavedCardRequest): Observable<Ok>;
|
|
767
|
+
|
|
768
|
+
setDefaultSavedCard(request: SetDefaultSavedCardRequest): Observable<SavedCard>;
|
|
769
|
+
|
|
770
|
+
updateSavedCard(request: UpdateSavedCardRequest): Observable<SavedCard>;
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Standalone "bind card" flow: creates a 1₽ YooKassa charge with
|
|
774
|
+
* save_payment_method=true; after the webhook the SavedCard row is
|
|
775
|
+
* persisted and the 1₽ credits USER_SPENDING so the user keeps it.
|
|
776
|
+
*/
|
|
777
|
+
|
|
778
|
+
bindCard(request: BindCardRequest): Observable<CheckoutResponse>;
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Poll an intent after returnUrl redirect: TOPUP/PREMIUM completion, bind-card
|
|
782
|
+
* completion. Ownership-checked by user_id.
|
|
783
|
+
*/
|
|
784
|
+
|
|
785
|
+
getPaymentIntent(request: GetPaymentIntentRequest): Observable<PaymentIntentStatus>;
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* ----- FX / available methods (public, cached) -----
|
|
789
|
+
* Daily CBR rates (RUB base). Frontend uses this for the "≈" display hint;
|
|
790
|
+
* the authoritative charge amount is always computed server-side at checkout.
|
|
791
|
+
*/
|
|
792
|
+
|
|
793
|
+
getRates(request: GetRatesRequest): Observable<GetRatesResponse>;
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Payment methods derived from live provider capabilities — the client
|
|
797
|
+
* renders only what is actually available (e.g. CRYPTO appears once the
|
|
798
|
+
* Heleket merchant is configured).
|
|
799
|
+
*/
|
|
800
|
+
|
|
801
|
+
getPaymentMethods(request: GetPaymentMethodsRequest): Observable<GetPaymentMethodsResponse>;
|
|
802
|
+
|
|
803
|
+
/** ----- payout details ----- */
|
|
804
|
+
|
|
805
|
+
updatePayoutDetails(request: UpdatePayoutDetailsRequest): Observable<UpdatePayoutDetailsResponse>;
|
|
806
|
+
|
|
807
|
+
getPayoutDetails(request: GetPayoutDetailsRequest): Observable<UpdatePayoutDetailsResponse>;
|
|
808
|
+
|
|
809
|
+
/** ----- admin ----- */
|
|
810
|
+
|
|
811
|
+
getAdminOverview(request: AdminOverviewRequest): Observable<AdminOverviewResponse>;
|
|
812
|
+
|
|
813
|
+
adminListTransactions(request: AdminListTransactionsRequest): Observable<AdminTransactionsListResponse>;
|
|
814
|
+
|
|
815
|
+
getUserFinance(request: GetUserFinanceRequest): Observable<UserFinanceResponse>;
|
|
816
|
+
|
|
817
|
+
createAdjustment(request: CreateAdjustmentRequest): Observable<Ok>;
|
|
818
|
+
|
|
819
|
+
getSalesAnalytics(request: SalesAnalyticsRequest): Observable<SalesAnalyticsResponse>;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Commerce + double-entry wallet/ledger (D9 / D9.2). See payments-service/docs/FINANCE.md.
|
|
824
|
+
* Money = Decimal-as-string (D7). Statuses/enums as strings (avoid proto enum
|
|
825
|
+
* value-name clashes within one package).
|
|
826
|
+
*/
|
|
827
|
+
|
|
828
|
+
export interface PaymentsServiceController {
|
|
829
|
+
/** ----- buyer ----- */
|
|
830
|
+
|
|
831
|
+
topup(request: TopupRequest): Promise<CheckoutResponse> | Observable<CheckoutResponse> | CheckoutResponse;
|
|
832
|
+
|
|
833
|
+
createCheckout(
|
|
834
|
+
request: CreateCheckoutRequest,
|
|
835
|
+
): Promise<CheckoutResponse> | Observable<CheckoutResponse> | CheckoutResponse;
|
|
836
|
+
|
|
837
|
+
getMyPurchases(
|
|
838
|
+
request: GetMyPurchasesRequest,
|
|
839
|
+
): Promise<PurchasesListResponse> | Observable<PurchasesListResponse> | PurchasesListResponse;
|
|
840
|
+
|
|
841
|
+
getPurchase(request: GetPurchaseRequest): Promise<Purchase> | Observable<Purchase> | Purchase;
|
|
842
|
+
|
|
843
|
+
refundPurchase(request: RefundPurchaseRequest): Promise<Purchase> | Observable<Purchase> | Purchase;
|
|
844
|
+
|
|
845
|
+
/** ----- wallet ----- */
|
|
846
|
+
|
|
847
|
+
getWallet(request: GetWalletRequest): Promise<WalletResponse> | Observable<WalletResponse> | WalletResponse;
|
|
848
|
+
|
|
849
|
+
listTransactions(
|
|
850
|
+
request: ListTransactionsRequest,
|
|
851
|
+
): Promise<TransactionsListResponse> | Observable<TransactionsListResponse> | TransactionsListResponse;
|
|
852
|
+
|
|
853
|
+
getTransactionMonths(
|
|
854
|
+
request: GetTransactionMonthsRequest,
|
|
855
|
+
): Promise<GetTransactionMonthsResponse> | Observable<GetTransactionMonthsResponse> | GetTransactionMonthsResponse;
|
|
856
|
+
|
|
857
|
+
/** ----- withdrawals ----- */
|
|
858
|
+
|
|
859
|
+
requestWithdrawal(request: RequestWithdrawalRequest): Promise<Withdrawal> | Observable<Withdrawal> | Withdrawal;
|
|
860
|
+
|
|
861
|
+
listWithdrawals(
|
|
862
|
+
request: ListWithdrawalsRequest,
|
|
863
|
+
): Promise<WithdrawalsListResponse> | Observable<WithdrawalsListResponse> | WithdrawalsListResponse;
|
|
864
|
+
|
|
865
|
+
processWithdrawal(request: ProcessWithdrawalRequest): Promise<Withdrawal> | Observable<Withdrawal> | Withdrawal;
|
|
866
|
+
|
|
867
|
+
/** ----- provider webhook (gateway forwards a verified event) ----- */
|
|
868
|
+
|
|
869
|
+
handlePaymentEvent(request: PaymentEventRequest): Promise<Ok> | Observable<Ok> | Ok;
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Generalized per-provider callback (POST /payments/webhook/:provider).
|
|
873
|
+
* Carries the EXACT raw JSON body: signed providers (Heleket) hash the
|
|
874
|
+
* byte-exact payload, so re-serializing a parsed body would break the sign.
|
|
875
|
+
*/
|
|
876
|
+
|
|
877
|
+
handleProviderCallback(request: ProviderCallbackRequest): Promise<Ok> | Observable<Ok> | Ok;
|
|
878
|
+
|
|
879
|
+
/** ----- premium ----- */
|
|
880
|
+
|
|
881
|
+
getPremiumPlans(
|
|
882
|
+
request: GetPremiumPlansRequest,
|
|
883
|
+
): Promise<PremiumPlansResponse> | Observable<PremiumPlansResponse> | PremiumPlansResponse;
|
|
884
|
+
|
|
885
|
+
purchasePremium(
|
|
886
|
+
request: PurchasePremiumRequest,
|
|
887
|
+
): Promise<PurchasePremiumResponse> | Observable<PurchasePremiumResponse> | PurchasePremiumResponse;
|
|
888
|
+
|
|
889
|
+
setPremiumPaymentMethod(
|
|
890
|
+
request: SetPremiumPaymentMethodRequest,
|
|
891
|
+
): Promise<PremiumPaymentMethodResponse> | Observable<PremiumPaymentMethodResponse> | PremiumPaymentMethodResponse;
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* 7-day refund window from completedAt. Reverses ledger, calls YooKassa for
|
|
895
|
+
* card purchases, rolls back the subscription's expiresAt by the period.
|
|
896
|
+
*/
|
|
897
|
+
|
|
898
|
+
refundPremium(
|
|
899
|
+
request: RefundPremiumRequest,
|
|
900
|
+
): Promise<RefundPremiumResponse> | Observable<RefundPremiumResponse> | RefundPremiumResponse;
|
|
901
|
+
|
|
902
|
+
getMyPremiumPayments(
|
|
903
|
+
request: GetMyPremiumPaymentsRequest,
|
|
904
|
+
): Promise<PremiumPaymentsListResponse> | Observable<PremiumPaymentsListResponse> | PremiumPaymentsListResponse;
|
|
905
|
+
|
|
906
|
+
getPremiumPayment(
|
|
907
|
+
request: GetPremiumPaymentRequest,
|
|
908
|
+
): Promise<PremiumPaymentRow> | Observable<PremiumPaymentRow> | PremiumPaymentRow;
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Internal — InternalServiceGuard. tasks-service cron triggers due renewals;
|
|
912
|
+
* payments-service iterates ACTIVE subscriptions with autoRenew+savedCard.
|
|
913
|
+
*/
|
|
914
|
+
|
|
915
|
+
runPremiumRenewals(
|
|
916
|
+
request: RunPremiumRenewalsRequest,
|
|
917
|
+
): Promise<RunPremiumRenewalsResponse> | Observable<RunPremiumRenewalsResponse> | RunPremiumRenewalsResponse;
|
|
918
|
+
|
|
919
|
+
/** ----- saved cards ----- */
|
|
920
|
+
|
|
921
|
+
listSavedCards(
|
|
922
|
+
request: ListSavedCardsRequest,
|
|
923
|
+
): Promise<ListSavedCardsResponse> | Observable<ListSavedCardsResponse> | ListSavedCardsResponse;
|
|
924
|
+
|
|
925
|
+
deleteSavedCard(request: DeleteSavedCardRequest): Promise<Ok> | Observable<Ok> | Ok;
|
|
926
|
+
|
|
927
|
+
setDefaultSavedCard(request: SetDefaultSavedCardRequest): Promise<SavedCard> | Observable<SavedCard> | SavedCard;
|
|
928
|
+
|
|
929
|
+
updateSavedCard(request: UpdateSavedCardRequest): Promise<SavedCard> | Observable<SavedCard> | SavedCard;
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Standalone "bind card" flow: creates a 1₽ YooKassa charge with
|
|
933
|
+
* save_payment_method=true; after the webhook the SavedCard row is
|
|
934
|
+
* persisted and the 1₽ credits USER_SPENDING so the user keeps it.
|
|
935
|
+
*/
|
|
936
|
+
|
|
937
|
+
bindCard(request: BindCardRequest): Promise<CheckoutResponse> | Observable<CheckoutResponse> | CheckoutResponse;
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Poll an intent after returnUrl redirect: TOPUP/PREMIUM completion, bind-card
|
|
941
|
+
* completion. Ownership-checked by user_id.
|
|
942
|
+
*/
|
|
943
|
+
|
|
944
|
+
getPaymentIntent(
|
|
945
|
+
request: GetPaymentIntentRequest,
|
|
946
|
+
): Promise<PaymentIntentStatus> | Observable<PaymentIntentStatus> | PaymentIntentStatus;
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* ----- FX / available methods (public, cached) -----
|
|
950
|
+
* Daily CBR rates (RUB base). Frontend uses this for the "≈" display hint;
|
|
951
|
+
* the authoritative charge amount is always computed server-side at checkout.
|
|
952
|
+
*/
|
|
953
|
+
|
|
954
|
+
getRates(request: GetRatesRequest): Promise<GetRatesResponse> | Observable<GetRatesResponse> | GetRatesResponse;
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Payment methods derived from live provider capabilities — the client
|
|
958
|
+
* renders only what is actually available (e.g. CRYPTO appears once the
|
|
959
|
+
* Heleket merchant is configured).
|
|
960
|
+
*/
|
|
961
|
+
|
|
962
|
+
getPaymentMethods(
|
|
963
|
+
request: GetPaymentMethodsRequest,
|
|
964
|
+
): Promise<GetPaymentMethodsResponse> | Observable<GetPaymentMethodsResponse> | GetPaymentMethodsResponse;
|
|
965
|
+
|
|
966
|
+
/** ----- payout details ----- */
|
|
967
|
+
|
|
968
|
+
updatePayoutDetails(
|
|
969
|
+
request: UpdatePayoutDetailsRequest,
|
|
970
|
+
): Promise<UpdatePayoutDetailsResponse> | Observable<UpdatePayoutDetailsResponse> | UpdatePayoutDetailsResponse;
|
|
971
|
+
|
|
972
|
+
getPayoutDetails(
|
|
973
|
+
request: GetPayoutDetailsRequest,
|
|
974
|
+
): Promise<UpdatePayoutDetailsResponse> | Observable<UpdatePayoutDetailsResponse> | UpdatePayoutDetailsResponse;
|
|
975
|
+
|
|
976
|
+
/** ----- admin ----- */
|
|
977
|
+
|
|
978
|
+
getAdminOverview(
|
|
979
|
+
request: AdminOverviewRequest,
|
|
980
|
+
): Promise<AdminOverviewResponse> | Observable<AdminOverviewResponse> | AdminOverviewResponse;
|
|
981
|
+
|
|
982
|
+
adminListTransactions(
|
|
983
|
+
request: AdminListTransactionsRequest,
|
|
984
|
+
): Promise<AdminTransactionsListResponse> | Observable<AdminTransactionsListResponse> | AdminTransactionsListResponse;
|
|
985
|
+
|
|
986
|
+
getUserFinance(
|
|
987
|
+
request: GetUserFinanceRequest,
|
|
988
|
+
): Promise<UserFinanceResponse> | Observable<UserFinanceResponse> | UserFinanceResponse;
|
|
989
|
+
|
|
990
|
+
createAdjustment(request: CreateAdjustmentRequest): Promise<Ok> | Observable<Ok> | Ok;
|
|
991
|
+
|
|
992
|
+
getSalesAnalytics(
|
|
993
|
+
request: SalesAnalyticsRequest,
|
|
994
|
+
): Promise<SalesAnalyticsResponse> | Observable<SalesAnalyticsResponse> | SalesAnalyticsResponse;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
export function PaymentsServiceControllerMethods() {
|
|
998
|
+
return function (constructor: Function) {
|
|
999
|
+
const grpcMethods: string[] = [
|
|
1000
|
+
"topup",
|
|
1001
|
+
"createCheckout",
|
|
1002
|
+
"getMyPurchases",
|
|
1003
|
+
"getPurchase",
|
|
1004
|
+
"refundPurchase",
|
|
1005
|
+
"getWallet",
|
|
1006
|
+
"listTransactions",
|
|
1007
|
+
"getTransactionMonths",
|
|
1008
|
+
"requestWithdrawal",
|
|
1009
|
+
"listWithdrawals",
|
|
1010
|
+
"processWithdrawal",
|
|
1011
|
+
"handlePaymentEvent",
|
|
1012
|
+
"handleProviderCallback",
|
|
1013
|
+
"getPremiumPlans",
|
|
1014
|
+
"purchasePremium",
|
|
1015
|
+
"setPremiumPaymentMethod",
|
|
1016
|
+
"refundPremium",
|
|
1017
|
+
"getMyPremiumPayments",
|
|
1018
|
+
"getPremiumPayment",
|
|
1019
|
+
"runPremiumRenewals",
|
|
1020
|
+
"listSavedCards",
|
|
1021
|
+
"deleteSavedCard",
|
|
1022
|
+
"setDefaultSavedCard",
|
|
1023
|
+
"updateSavedCard",
|
|
1024
|
+
"bindCard",
|
|
1025
|
+
"getPaymentIntent",
|
|
1026
|
+
"getRates",
|
|
1027
|
+
"getPaymentMethods",
|
|
1028
|
+
"updatePayoutDetails",
|
|
1029
|
+
"getPayoutDetails",
|
|
1030
|
+
"getAdminOverview",
|
|
1031
|
+
"adminListTransactions",
|
|
1032
|
+
"getUserFinance",
|
|
1033
|
+
"createAdjustment",
|
|
1034
|
+
"getSalesAnalytics",
|
|
1035
|
+
];
|
|
1036
|
+
for (const method of grpcMethods) {
|
|
1037
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
1038
|
+
GrpcMethod("PaymentsService", method)(constructor.prototype[method], method, descriptor);
|
|
1039
|
+
}
|
|
1040
|
+
const grpcStreamMethods: string[] = [];
|
|
1041
|
+
for (const method of grpcStreamMethods) {
|
|
1042
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
1043
|
+
GrpcStreamMethod("PaymentsService", method)(constructor.prototype[method], method, descriptor);
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
export const PAYMENTS_SERVICE_NAME = "PaymentsService";
|