@aepstore-dev/contracts 1.12.0 → 1.13.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/payments.ts +266 -57
- package/package.json +1 -1
- package/proto/payments.proto +146 -85
package/gen/payments.ts
CHANGED
|
@@ -16,52 +16,50 @@ export interface Ok {
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* ---------------------------------------------------------------------------
|
|
19
|
-
* Purchase / checkout
|
|
19
|
+
* Purchase / checkout / topup
|
|
20
20
|
* ---------------------------------------------------------------------------
|
|
21
21
|
*/
|
|
22
22
|
export interface Purchase {
|
|
23
23
|
id: string;
|
|
24
24
|
productId: string;
|
|
25
25
|
productName: string;
|
|
26
|
-
/** buyer */
|
|
27
26
|
userId: string;
|
|
28
|
-
/** Decimal as string */
|
|
29
27
|
price: string;
|
|
30
28
|
/** PENDING | COMPLETED | FAILED | REFUNDED */
|
|
31
29
|
status: string;
|
|
32
|
-
/** YooKassa payment id */
|
|
33
30
|
paymentId: string;
|
|
34
|
-
/**
|
|
31
|
+
/** BALANCE | YOOKASSA */
|
|
32
|
+
paymentMethod: string;
|
|
35
33
|
commissionPercent: string;
|
|
36
|
-
/** snapshot, Decimal as string */
|
|
37
34
|
sellerAmount: string;
|
|
38
35
|
createdAt: string;
|
|
39
36
|
completedAt: string;
|
|
40
37
|
}
|
|
41
38
|
|
|
39
|
+
export interface TopupRequest {
|
|
40
|
+
userId: string;
|
|
41
|
+
/** >= 10.00 */
|
|
42
|
+
amount: string;
|
|
43
|
+
returnUrl: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
42
46
|
export interface CreateCheckoutRequest {
|
|
43
|
-
/** buyer */
|
|
44
47
|
userId: string;
|
|
45
48
|
productId: string;
|
|
46
|
-
/**
|
|
49
|
+
/** BALANCE | YOOKASSA (default YOOKASSA) */
|
|
50
|
+
paymentMethod: string;
|
|
47
51
|
returnUrl: string;
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
export interface CheckoutResponse {
|
|
51
55
|
purchaseId: string;
|
|
52
56
|
paymentId: string;
|
|
53
|
-
/**
|
|
57
|
+
/** empty when paid from balance (instant) */
|
|
54
58
|
confirmationUrl: string;
|
|
59
|
+
/** PENDING (redirect) | COMPLETED (balance) */
|
|
55
60
|
status: string;
|
|
56
61
|
}
|
|
57
62
|
|
|
58
|
-
export interface PaymentEventRequest {
|
|
59
|
-
/** payment.succeeded | payment.canceled | refund.succeeded */
|
|
60
|
-
event: string;
|
|
61
|
-
/** YooKassa payment object id (re-fetched & verified by the service) */
|
|
62
|
-
paymentId: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
63
|
export interface GetMyPurchasesRequest {
|
|
66
64
|
userId: string;
|
|
67
65
|
page: number;
|
|
@@ -77,13 +75,11 @@ export interface PurchasesListResponse {
|
|
|
77
75
|
|
|
78
76
|
export interface GetPurchaseRequest {
|
|
79
77
|
id: string;
|
|
80
|
-
/** requester (must be buyer or admin) */
|
|
81
78
|
userId: string;
|
|
82
79
|
}
|
|
83
80
|
|
|
84
81
|
export interface RefundPurchaseRequest {
|
|
85
82
|
purchaseId: string;
|
|
86
|
-
/** buyer (own) or admin */
|
|
87
83
|
actorUserId: string;
|
|
88
84
|
isAdmin: boolean;
|
|
89
85
|
reason: string;
|
|
@@ -91,32 +87,64 @@ export interface RefundPurchaseRequest {
|
|
|
91
87
|
|
|
92
88
|
/**
|
|
93
89
|
* ---------------------------------------------------------------------------
|
|
94
|
-
*
|
|
90
|
+
* Wallet & statement
|
|
95
91
|
* ---------------------------------------------------------------------------
|
|
96
92
|
*/
|
|
97
|
-
export interface
|
|
98
|
-
|
|
93
|
+
export interface GetWalletRequest {
|
|
94
|
+
userId: string;
|
|
99
95
|
}
|
|
100
96
|
|
|
101
|
-
export interface
|
|
102
|
-
|
|
103
|
-
available: string;
|
|
104
|
-
/** still in the hold window */
|
|
97
|
+
export interface WalletResponse {
|
|
98
|
+
spending: string;
|
|
105
99
|
pending: string;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
payout: string;
|
|
101
|
+
/** spending + payout */
|
|
102
|
+
spendable: string;
|
|
103
|
+
/** payout */
|
|
104
|
+
withdrawable: string;
|
|
109
105
|
currency: string;
|
|
110
|
-
/** completed, non-refunded sales count */
|
|
111
106
|
lifetimeSales: number;
|
|
112
|
-
/** tier the NEXT sale would use */
|
|
113
107
|
currentCommissionPercent: string;
|
|
114
108
|
}
|
|
115
109
|
|
|
110
|
+
export interface ListTransactionsRequest {
|
|
111
|
+
userId: string;
|
|
112
|
+
/** optional filter (TOPUP|PURCHASE|SALE_CLEAR|WITHDRAWAL|REFUND|ADJUSTMENT) */
|
|
113
|
+
type: string;
|
|
114
|
+
page: number;
|
|
115
|
+
limit: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface StatementEntry {
|
|
119
|
+
/** ledger entry id */
|
|
120
|
+
id: string;
|
|
121
|
+
txId: string;
|
|
122
|
+
/** tx type */
|
|
123
|
+
type: string;
|
|
124
|
+
/** which of the user's accounts */
|
|
125
|
+
accountKind: string;
|
|
126
|
+
/** DEBIT | CREDIT */
|
|
127
|
+
direction: string;
|
|
128
|
+
amount: string;
|
|
129
|
+
description: string;
|
|
130
|
+
createdAt: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface TransactionsListResponse {
|
|
134
|
+
items: StatementEntry[];
|
|
135
|
+
total: number;
|
|
136
|
+
page: number;
|
|
137
|
+
limit: number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* ---------------------------------------------------------------------------
|
|
142
|
+
* Withdrawals
|
|
143
|
+
* ---------------------------------------------------------------------------
|
|
144
|
+
*/
|
|
116
145
|
export interface Withdrawal {
|
|
117
146
|
id: string;
|
|
118
147
|
sellerId: string;
|
|
119
|
-
/** Decimal as string */
|
|
120
148
|
amount: string;
|
|
121
149
|
/** PENDING | PROCESSING | COMPLETED | REJECTED */
|
|
122
150
|
status: string;
|
|
@@ -130,14 +158,12 @@ export interface Withdrawal {
|
|
|
130
158
|
|
|
131
159
|
export interface RequestWithdrawalRequest {
|
|
132
160
|
sellerId: string;
|
|
133
|
-
/** Decimal as string */
|
|
134
161
|
amount: string;
|
|
135
162
|
method: string;
|
|
136
163
|
details: string;
|
|
137
164
|
}
|
|
138
165
|
|
|
139
166
|
export interface ListWithdrawalsRequest {
|
|
140
|
-
/** empty = all (admin only) */
|
|
141
167
|
sellerId: string;
|
|
142
168
|
status: string;
|
|
143
169
|
page: number;
|
|
@@ -154,27 +180,153 @@ export interface WithdrawalsListResponse {
|
|
|
154
180
|
export interface ProcessWithdrawalRequest {
|
|
155
181
|
withdrawalId: string;
|
|
156
182
|
adminId: string;
|
|
157
|
-
/** approve (→PROCESSING) | complete (→COMPLETED) | reject (→REJECTED) */
|
|
158
183
|
action: string;
|
|
159
184
|
comment: string;
|
|
160
185
|
}
|
|
161
186
|
|
|
187
|
+
/**
|
|
188
|
+
* ---------------------------------------------------------------------------
|
|
189
|
+
* Webhook
|
|
190
|
+
* ---------------------------------------------------------------------------
|
|
191
|
+
*/
|
|
192
|
+
export interface PaymentEventRequest {
|
|
193
|
+
event: string;
|
|
194
|
+
paymentId: string;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* ---------------------------------------------------------------------------
|
|
199
|
+
* Admin
|
|
200
|
+
* ---------------------------------------------------------------------------
|
|
201
|
+
*/
|
|
202
|
+
export interface AdminOverviewRequest {
|
|
203
|
+
from: string;
|
|
204
|
+
to: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface AdminOverviewResponse {
|
|
208
|
+
/** platform commission earned (period) */
|
|
209
|
+
revenue: string;
|
|
210
|
+
/** gross merchandise value (period) */
|
|
211
|
+
gmv: string;
|
|
212
|
+
/** Σ all users' (pending+payout+spending) — what we owe */
|
|
213
|
+
liabilities: string;
|
|
214
|
+
/** money in transit at PSP */
|
|
215
|
+
pspClearing: string;
|
|
216
|
+
/** reserved for approved withdrawals */
|
|
217
|
+
payoutsPayable: string;
|
|
218
|
+
refundsTotal: string;
|
|
219
|
+
topupsTotal: string;
|
|
220
|
+
withdrawalsTotal: string;
|
|
221
|
+
salesCount: number;
|
|
222
|
+
currency: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface AdminListTransactionsRequest {
|
|
226
|
+
type: string;
|
|
227
|
+
userId: string;
|
|
228
|
+
accountKind: string;
|
|
229
|
+
from: string;
|
|
230
|
+
to: string;
|
|
231
|
+
page: number;
|
|
232
|
+
limit: number;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface AdminEntry {
|
|
236
|
+
accountId: string;
|
|
237
|
+
accountKind: string;
|
|
238
|
+
ownerId: string;
|
|
239
|
+
direction: string;
|
|
240
|
+
amount: string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface AdminLedgerTx {
|
|
244
|
+
id: string;
|
|
245
|
+
type: string;
|
|
246
|
+
status: string;
|
|
247
|
+
refType: string;
|
|
248
|
+
refId: string;
|
|
249
|
+
description: string;
|
|
250
|
+
createdBy: string;
|
|
251
|
+
createdAt: string;
|
|
252
|
+
entries: AdminEntry[];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface AdminTransactionsListResponse {
|
|
256
|
+
items: AdminLedgerTx[];
|
|
257
|
+
total: number;
|
|
258
|
+
page: number;
|
|
259
|
+
limit: number;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface GetUserFinanceRequest {
|
|
263
|
+
userId: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface AccountBalance {
|
|
267
|
+
kind: string;
|
|
268
|
+
balance: string;
|
|
269
|
+
currency: string;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface UserFinanceResponse {
|
|
273
|
+
wallet: WalletResponse | undefined;
|
|
274
|
+
accounts: AccountBalance[];
|
|
275
|
+
recent: StatementEntry[];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export interface CreateAdjustmentRequest {
|
|
279
|
+
adminId: string;
|
|
280
|
+
userId: string;
|
|
281
|
+
/** USER_SPENDING | USER_PAYOUT | USER_PENDING */
|
|
282
|
+
accountKind: string;
|
|
283
|
+
/** CREDIT (give) | DEBIT (take) */
|
|
284
|
+
direction: string;
|
|
285
|
+
amount: string;
|
|
286
|
+
reason: string;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export interface SalesAnalyticsRequest {
|
|
290
|
+
from: string;
|
|
291
|
+
to: string;
|
|
292
|
+
granularity: string;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface SalesPoint {
|
|
296
|
+
date: string;
|
|
297
|
+
salesCount: number;
|
|
298
|
+
gmv: string;
|
|
299
|
+
revenue: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface SellerStat {
|
|
303
|
+
sellerId: string;
|
|
304
|
+
username: string;
|
|
305
|
+
sales: number;
|
|
306
|
+
gmv: string;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export interface SalesAnalyticsResponse {
|
|
310
|
+
points: SalesPoint[];
|
|
311
|
+
topSellers: SellerStat[];
|
|
312
|
+
/** % refunded purchases */
|
|
313
|
+
refundRate: string;
|
|
314
|
+
}
|
|
315
|
+
|
|
162
316
|
export const PAYMENTS_V1_PACKAGE_NAME = "payments.v1";
|
|
163
317
|
|
|
164
318
|
/**
|
|
165
|
-
* Commerce
|
|
166
|
-
* Money
|
|
167
|
-
*
|
|
168
|
-
* PENDING/PROCESSING/COMPLETED/REJECTED for withdrawals) — kept as `string`
|
|
169
|
-
* rather than proto enums to avoid value-name clashes inside one proto package.
|
|
319
|
+
* Commerce + double-entry wallet/ledger (D9 / D9.2). See payments-service/docs/FINANCE.md.
|
|
320
|
+
* Money = Decimal-as-string (D7). Statuses/enums as strings (avoid proto enum
|
|
321
|
+
* value-name clashes within one package).
|
|
170
322
|
*/
|
|
171
323
|
|
|
172
324
|
export interface PaymentsServiceClient {
|
|
173
|
-
|
|
325
|
+
/** ----- buyer ----- */
|
|
174
326
|
|
|
175
|
-
|
|
327
|
+
topup(request: TopupRequest): Observable<CheckoutResponse>;
|
|
176
328
|
|
|
177
|
-
|
|
329
|
+
createCheckout(request: CreateCheckoutRequest): Observable<CheckoutResponse>;
|
|
178
330
|
|
|
179
331
|
getMyPurchases(request: GetMyPurchasesRequest): Observable<PurchasesListResponse>;
|
|
180
332
|
|
|
@@ -182,32 +334,52 @@ export interface PaymentsServiceClient {
|
|
|
182
334
|
|
|
183
335
|
refundPurchase(request: RefundPurchaseRequest): Observable<Purchase>;
|
|
184
336
|
|
|
185
|
-
|
|
337
|
+
/** ----- wallet ----- */
|
|
338
|
+
|
|
339
|
+
getWallet(request: GetWalletRequest): Observable<WalletResponse>;
|
|
340
|
+
|
|
341
|
+
listTransactions(request: ListTransactionsRequest): Observable<TransactionsListResponse>;
|
|
342
|
+
|
|
343
|
+
/** ----- withdrawals ----- */
|
|
186
344
|
|
|
187
345
|
requestWithdrawal(request: RequestWithdrawalRequest): Observable<Withdrawal>;
|
|
188
346
|
|
|
189
347
|
listWithdrawals(request: ListWithdrawalsRequest): Observable<WithdrawalsListResponse>;
|
|
190
348
|
|
|
191
349
|
processWithdrawal(request: ProcessWithdrawalRequest): Observable<Withdrawal>;
|
|
350
|
+
|
|
351
|
+
/** ----- provider webhook (gateway forwards a verified event) ----- */
|
|
352
|
+
|
|
353
|
+
handlePaymentEvent(request: PaymentEventRequest): Observable<Ok>;
|
|
354
|
+
|
|
355
|
+
/** ----- admin ----- */
|
|
356
|
+
|
|
357
|
+
getAdminOverview(request: AdminOverviewRequest): Observable<AdminOverviewResponse>;
|
|
358
|
+
|
|
359
|
+
adminListTransactions(request: AdminListTransactionsRequest): Observable<AdminTransactionsListResponse>;
|
|
360
|
+
|
|
361
|
+
getUserFinance(request: GetUserFinanceRequest): Observable<UserFinanceResponse>;
|
|
362
|
+
|
|
363
|
+
createAdjustment(request: CreateAdjustmentRequest): Observable<Ok>;
|
|
364
|
+
|
|
365
|
+
getSalesAnalytics(request: SalesAnalyticsRequest): Observable<SalesAnalyticsResponse>;
|
|
192
366
|
}
|
|
193
367
|
|
|
194
368
|
/**
|
|
195
|
-
* Commerce
|
|
196
|
-
* Money
|
|
197
|
-
*
|
|
198
|
-
* PENDING/PROCESSING/COMPLETED/REJECTED for withdrawals) — kept as `string`
|
|
199
|
-
* rather than proto enums to avoid value-name clashes inside one proto package.
|
|
369
|
+
* Commerce + double-entry wallet/ledger (D9 / D9.2). See payments-service/docs/FINANCE.md.
|
|
370
|
+
* Money = Decimal-as-string (D7). Statuses/enums as strings (avoid proto enum
|
|
371
|
+
* value-name clashes within one package).
|
|
200
372
|
*/
|
|
201
373
|
|
|
202
374
|
export interface PaymentsServiceController {
|
|
375
|
+
/** ----- buyer ----- */
|
|
376
|
+
|
|
377
|
+
topup(request: TopupRequest): Promise<CheckoutResponse> | Observable<CheckoutResponse> | CheckoutResponse;
|
|
378
|
+
|
|
203
379
|
createCheckout(
|
|
204
380
|
request: CreateCheckoutRequest,
|
|
205
381
|
): Promise<CheckoutResponse> | Observable<CheckoutResponse> | CheckoutResponse;
|
|
206
382
|
|
|
207
|
-
/** Gateway forwards a verified YooKassa webhook event here. */
|
|
208
|
-
|
|
209
|
-
handlePaymentEvent(request: PaymentEventRequest): Promise<Ok> | Observable<Ok> | Ok;
|
|
210
|
-
|
|
211
383
|
getMyPurchases(
|
|
212
384
|
request: GetMyPurchasesRequest,
|
|
213
385
|
): Promise<PurchasesListResponse> | Observable<PurchasesListResponse> | PurchasesListResponse;
|
|
@@ -216,9 +388,15 @@ export interface PaymentsServiceController {
|
|
|
216
388
|
|
|
217
389
|
refundPurchase(request: RefundPurchaseRequest): Promise<Purchase> | Observable<Purchase> | Purchase;
|
|
218
390
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
): Promise<
|
|
391
|
+
/** ----- wallet ----- */
|
|
392
|
+
|
|
393
|
+
getWallet(request: GetWalletRequest): Promise<WalletResponse> | Observable<WalletResponse> | WalletResponse;
|
|
394
|
+
|
|
395
|
+
listTransactions(
|
|
396
|
+
request: ListTransactionsRequest,
|
|
397
|
+
): Promise<TransactionsListResponse> | Observable<TransactionsListResponse> | TransactionsListResponse;
|
|
398
|
+
|
|
399
|
+
/** ----- withdrawals ----- */
|
|
222
400
|
|
|
223
401
|
requestWithdrawal(request: RequestWithdrawalRequest): Promise<Withdrawal> | Observable<Withdrawal> | Withdrawal;
|
|
224
402
|
|
|
@@ -227,20 +405,51 @@ export interface PaymentsServiceController {
|
|
|
227
405
|
): Promise<WithdrawalsListResponse> | Observable<WithdrawalsListResponse> | WithdrawalsListResponse;
|
|
228
406
|
|
|
229
407
|
processWithdrawal(request: ProcessWithdrawalRequest): Promise<Withdrawal> | Observable<Withdrawal> | Withdrawal;
|
|
408
|
+
|
|
409
|
+
/** ----- provider webhook (gateway forwards a verified event) ----- */
|
|
410
|
+
|
|
411
|
+
handlePaymentEvent(request: PaymentEventRequest): Promise<Ok> | Observable<Ok> | Ok;
|
|
412
|
+
|
|
413
|
+
/** ----- admin ----- */
|
|
414
|
+
|
|
415
|
+
getAdminOverview(
|
|
416
|
+
request: AdminOverviewRequest,
|
|
417
|
+
): Promise<AdminOverviewResponse> | Observable<AdminOverviewResponse> | AdminOverviewResponse;
|
|
418
|
+
|
|
419
|
+
adminListTransactions(
|
|
420
|
+
request: AdminListTransactionsRequest,
|
|
421
|
+
): Promise<AdminTransactionsListResponse> | Observable<AdminTransactionsListResponse> | AdminTransactionsListResponse;
|
|
422
|
+
|
|
423
|
+
getUserFinance(
|
|
424
|
+
request: GetUserFinanceRequest,
|
|
425
|
+
): Promise<UserFinanceResponse> | Observable<UserFinanceResponse> | UserFinanceResponse;
|
|
426
|
+
|
|
427
|
+
createAdjustment(request: CreateAdjustmentRequest): Promise<Ok> | Observable<Ok> | Ok;
|
|
428
|
+
|
|
429
|
+
getSalesAnalytics(
|
|
430
|
+
request: SalesAnalyticsRequest,
|
|
431
|
+
): Promise<SalesAnalyticsResponse> | Observable<SalesAnalyticsResponse> | SalesAnalyticsResponse;
|
|
230
432
|
}
|
|
231
433
|
|
|
232
434
|
export function PaymentsServiceControllerMethods() {
|
|
233
435
|
return function (constructor: Function) {
|
|
234
436
|
const grpcMethods: string[] = [
|
|
437
|
+
"topup",
|
|
235
438
|
"createCheckout",
|
|
236
|
-
"handlePaymentEvent",
|
|
237
439
|
"getMyPurchases",
|
|
238
440
|
"getPurchase",
|
|
239
441
|
"refundPurchase",
|
|
240
|
-
"
|
|
442
|
+
"getWallet",
|
|
443
|
+
"listTransactions",
|
|
241
444
|
"requestWithdrawal",
|
|
242
445
|
"listWithdrawals",
|
|
243
446
|
"processWithdrawal",
|
|
447
|
+
"handlePaymentEvent",
|
|
448
|
+
"getAdminOverview",
|
|
449
|
+
"adminListTransactions",
|
|
450
|
+
"getUserFinance",
|
|
451
|
+
"createAdjustment",
|
|
452
|
+
"getSalesAnalytics",
|
|
244
453
|
];
|
|
245
454
|
for (const method of grpcMethods) {
|
|
246
455
|
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
package/package.json
CHANGED
package/proto/payments.proto
CHANGED
|
@@ -2,108 +2,122 @@ syntax = "proto3";
|
|
|
2
2
|
|
|
3
3
|
package payments.v1;
|
|
4
4
|
|
|
5
|
-
// Commerce
|
|
6
|
-
// Money
|
|
7
|
-
//
|
|
8
|
-
// PENDING/PROCESSING/COMPLETED/REJECTED for withdrawals) — kept as `string`
|
|
9
|
-
// rather than proto enums to avoid value-name clashes inside one proto package.
|
|
5
|
+
// Commerce + double-entry wallet/ledger (D9 / D9.2). See payments-service/docs/FINANCE.md.
|
|
6
|
+
// Money = Decimal-as-string (D7). Statuses/enums as strings (avoid proto enum
|
|
7
|
+
// value-name clashes within one package).
|
|
10
8
|
service PaymentsService {
|
|
9
|
+
// ----- buyer -----
|
|
10
|
+
rpc Topup(TopupRequest) returns (CheckoutResponse);
|
|
11
11
|
rpc CreateCheckout(CreateCheckoutRequest) returns (CheckoutResponse);
|
|
12
|
-
// Gateway forwards a verified YooKassa webhook event here.
|
|
13
|
-
rpc HandlePaymentEvent(PaymentEventRequest) returns (Ok);
|
|
14
|
-
|
|
15
12
|
rpc GetMyPurchases(GetMyPurchasesRequest) returns (PurchasesListResponse);
|
|
16
13
|
rpc GetPurchase(GetPurchaseRequest) returns (Purchase);
|
|
17
14
|
rpc RefundPurchase(RefundPurchaseRequest) returns (Purchase);
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
// ----- wallet -----
|
|
17
|
+
rpc GetWallet(GetWalletRequest) returns (WalletResponse);
|
|
18
|
+
rpc ListTransactions(ListTransactionsRequest) returns (TransactionsListResponse);
|
|
19
|
+
|
|
20
|
+
// ----- withdrawals -----
|
|
20
21
|
rpc RequestWithdrawal(RequestWithdrawalRequest) returns (Withdrawal);
|
|
21
22
|
rpc ListWithdrawals(ListWithdrawalsRequest) returns (WithdrawalsListResponse);
|
|
22
23
|
rpc ProcessWithdrawal(ProcessWithdrawalRequest) returns (Withdrawal);
|
|
24
|
+
|
|
25
|
+
// ----- provider webhook (gateway forwards a verified event) -----
|
|
26
|
+
rpc HandlePaymentEvent(PaymentEventRequest) returns (Ok);
|
|
27
|
+
|
|
28
|
+
// ----- admin -----
|
|
29
|
+
rpc GetAdminOverview(AdminOverviewRequest) returns (AdminOverviewResponse);
|
|
30
|
+
rpc AdminListTransactions(AdminListTransactionsRequest) returns (AdminTransactionsListResponse);
|
|
31
|
+
rpc GetUserFinance(GetUserFinanceRequest) returns (UserFinanceResponse);
|
|
32
|
+
rpc CreateAdjustment(CreateAdjustmentRequest) returns (Ok);
|
|
33
|
+
rpc GetSalesAnalytics(SalesAnalyticsRequest) returns (SalesAnalyticsResponse);
|
|
23
34
|
}
|
|
24
35
|
|
|
25
36
|
message Ok { bool ok = 1; }
|
|
26
37
|
|
|
27
38
|
// ---------------------------------------------------------------------------
|
|
28
|
-
// Purchase / checkout
|
|
39
|
+
// Purchase / checkout / topup
|
|
29
40
|
// ---------------------------------------------------------------------------
|
|
30
41
|
message Purchase {
|
|
31
42
|
string id = 1;
|
|
32
43
|
string product_id = 2;
|
|
33
44
|
string product_name = 3;
|
|
34
|
-
string user_id = 4;
|
|
35
|
-
string price = 5;
|
|
36
|
-
string status = 6;
|
|
37
|
-
string payment_id = 7;
|
|
38
|
-
string
|
|
39
|
-
string
|
|
40
|
-
string
|
|
41
|
-
string
|
|
45
|
+
string user_id = 4;
|
|
46
|
+
string price = 5;
|
|
47
|
+
string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
|
|
48
|
+
string payment_id = 7;
|
|
49
|
+
string payment_method = 8; // BALANCE | YOOKASSA
|
|
50
|
+
string commission_percent = 9;
|
|
51
|
+
string seller_amount = 10;
|
|
52
|
+
string created_at = 11;
|
|
53
|
+
string completed_at = 12;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
message TopupRequest {
|
|
57
|
+
string user_id = 1;
|
|
58
|
+
string amount = 2; // >= 10.00
|
|
59
|
+
string return_url = 3;
|
|
42
60
|
}
|
|
43
61
|
|
|
44
62
|
message CreateCheckoutRequest {
|
|
45
|
-
string user_id = 1;
|
|
63
|
+
string user_id = 1;
|
|
46
64
|
string product_id = 2;
|
|
47
|
-
string
|
|
65
|
+
string payment_method = 3; // BALANCE | YOOKASSA (default YOOKASSA)
|
|
66
|
+
string return_url = 4;
|
|
48
67
|
}
|
|
49
68
|
|
|
50
69
|
message CheckoutResponse {
|
|
51
70
|
string purchase_id = 1;
|
|
52
71
|
string payment_id = 2;
|
|
53
|
-
string confirmation_url = 3; //
|
|
54
|
-
string status = 4;
|
|
72
|
+
string confirmation_url = 3; // empty when paid from balance (instant)
|
|
73
|
+
string status = 4; // PENDING (redirect) | COMPLETED (balance)
|
|
55
74
|
}
|
|
56
75
|
|
|
57
|
-
message
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
76
|
+
message GetMyPurchasesRequest { string user_id = 1; int32 page = 2; int32 limit = 3; }
|
|
77
|
+
message PurchasesListResponse { repeated Purchase items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
78
|
+
message GetPurchaseRequest { string id = 1; string user_id = 2; }
|
|
79
|
+
message RefundPurchaseRequest { string purchase_id = 1; string actor_user_id = 2; bool is_admin = 3; string reason = 4; }
|
|
61
80
|
|
|
62
|
-
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
// Wallet & statement
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
message GetWalletRequest { string user_id = 1; }
|
|
85
|
+
message WalletResponse {
|
|
86
|
+
string spending = 1;
|
|
87
|
+
string pending = 2;
|
|
88
|
+
string payout = 3;
|
|
89
|
+
string spendable = 4; // spending + payout
|
|
90
|
+
string withdrawable = 5; // payout
|
|
91
|
+
string currency = 6;
|
|
92
|
+
int32 lifetime_sales = 7;
|
|
93
|
+
string current_commission_percent = 8;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
message ListTransactionsRequest {
|
|
63
97
|
string user_id = 1;
|
|
64
|
-
|
|
65
|
-
int32 limit = 3;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
message PurchasesListResponse {
|
|
69
|
-
repeated Purchase items = 1;
|
|
70
|
-
int32 total = 2;
|
|
98
|
+
string type = 2; // optional filter (TOPUP|PURCHASE|SALE_CLEAR|WITHDRAWAL|REFUND|ADJUSTMENT)
|
|
71
99
|
int32 page = 3;
|
|
72
100
|
int32 limit = 4;
|
|
73
101
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
string
|
|
77
|
-
string
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
string
|
|
82
|
-
string
|
|
83
|
-
bool is_admin = 3;
|
|
84
|
-
string reason = 4;
|
|
102
|
+
message StatementEntry {
|
|
103
|
+
string id = 1; // ledger entry id
|
|
104
|
+
string tx_id = 2;
|
|
105
|
+
string type = 3; // tx type
|
|
106
|
+
string account_kind = 4; // which of the user's accounts
|
|
107
|
+
string direction = 5; // DEBIT | CREDIT
|
|
108
|
+
string amount = 6;
|
|
109
|
+
string description = 7;
|
|
110
|
+
string created_at = 8;
|
|
85
111
|
}
|
|
112
|
+
message TransactionsListResponse { repeated StatementEntry items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
86
113
|
|
|
87
114
|
// ---------------------------------------------------------------------------
|
|
88
|
-
//
|
|
115
|
+
// Withdrawals
|
|
89
116
|
// ---------------------------------------------------------------------------
|
|
90
|
-
message GetSellerBalanceRequest {
|
|
91
|
-
string seller_id = 1;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
message SellerBalanceResponse {
|
|
95
|
-
string available = 1; // withdrawable now (cleared past the grace window)
|
|
96
|
-
string pending = 2; // still in the hold window
|
|
97
|
-
string withdrawn = 3; // reserved by non-rejected withdrawals
|
|
98
|
-
string currency = 4; // RUB
|
|
99
|
-
int32 lifetime_sales = 5; // completed, non-refunded sales count
|
|
100
|
-
string current_commission_percent = 6; // tier the NEXT sale would use
|
|
101
|
-
}
|
|
102
|
-
|
|
103
117
|
message Withdrawal {
|
|
104
118
|
string id = 1;
|
|
105
119
|
string seller_id = 2;
|
|
106
|
-
string amount = 3;
|
|
120
|
+
string amount = 3;
|
|
107
121
|
string status = 4; // PENDING | PROCESSING | COMPLETED | REJECTED
|
|
108
122
|
string method = 5;
|
|
109
123
|
string details = 6;
|
|
@@ -112,31 +126,78 @@ message Withdrawal {
|
|
|
112
126
|
string processed_at = 9;
|
|
113
127
|
string created_at = 10;
|
|
114
128
|
}
|
|
129
|
+
message RequestWithdrawalRequest { string seller_id = 1; string amount = 2; string method = 3; string details = 4; }
|
|
130
|
+
message ListWithdrawalsRequest { string seller_id = 1; string status = 2; int32 page = 3; int32 limit = 4; }
|
|
131
|
+
message WithdrawalsListResponse { repeated Withdrawal items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
132
|
+
message ProcessWithdrawalRequest { string withdrawal_id = 1; string admin_id = 2; string action = 3; string comment = 4; }
|
|
115
133
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
string details = 4;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
message ListWithdrawalsRequest {
|
|
124
|
-
string seller_id = 1; // empty = all (admin only)
|
|
125
|
-
string status = 2;
|
|
126
|
-
int32 page = 3;
|
|
127
|
-
int32 limit = 4;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
message WithdrawalsListResponse {
|
|
131
|
-
repeated Withdrawal items = 1;
|
|
132
|
-
int32 total = 2;
|
|
133
|
-
int32 page = 3;
|
|
134
|
-
int32 limit = 4;
|
|
135
|
-
}
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
// Webhook
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
message PaymentEventRequest { string event = 1; string payment_id = 2; }
|
|
136
138
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
// Admin
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
message AdminOverviewRequest { string from = 1; string to = 2; }
|
|
143
|
+
message AdminOverviewResponse {
|
|
144
|
+
string revenue = 1; // platform commission earned (period)
|
|
145
|
+
string gmv = 2; // gross merchandise value (period)
|
|
146
|
+
string liabilities = 3; // Σ all users' (pending+payout+spending) — what we owe
|
|
147
|
+
string psp_clearing = 4; // money in transit at PSP
|
|
148
|
+
string payouts_payable = 5; // reserved for approved withdrawals
|
|
149
|
+
string refunds_total = 6;
|
|
150
|
+
string topups_total = 7;
|
|
151
|
+
string withdrawals_total = 8;
|
|
152
|
+
int32 sales_count = 9;
|
|
153
|
+
string currency = 10;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
message AdminListTransactionsRequest {
|
|
157
|
+
string type = 1;
|
|
158
|
+
string user_id = 2;
|
|
159
|
+
string account_kind = 3;
|
|
160
|
+
string from = 4;
|
|
161
|
+
string to = 5;
|
|
162
|
+
int32 page = 6;
|
|
163
|
+
int32 limit = 7;
|
|
164
|
+
}
|
|
165
|
+
message AdminEntry { string account_id = 1; string account_kind = 2; string owner_id = 3; string direction = 4; string amount = 5; }
|
|
166
|
+
message AdminLedgerTx {
|
|
167
|
+
string id = 1;
|
|
168
|
+
string type = 2;
|
|
169
|
+
string status = 3;
|
|
170
|
+
string ref_type = 4;
|
|
171
|
+
string ref_id = 5;
|
|
172
|
+
string description = 6;
|
|
173
|
+
string created_by = 7;
|
|
174
|
+
string created_at = 8;
|
|
175
|
+
repeated AdminEntry entries = 9;
|
|
176
|
+
}
|
|
177
|
+
message AdminTransactionsListResponse { repeated AdminLedgerTx items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
178
|
+
|
|
179
|
+
message GetUserFinanceRequest { string user_id = 1; }
|
|
180
|
+
message AccountBalance { string kind = 1; string balance = 2; string currency = 3; }
|
|
181
|
+
message UserFinanceResponse {
|
|
182
|
+
WalletResponse wallet = 1;
|
|
183
|
+
repeated AccountBalance accounts = 2;
|
|
184
|
+
repeated StatementEntry recent = 3;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
message CreateAdjustmentRequest {
|
|
188
|
+
string admin_id = 1;
|
|
189
|
+
string user_id = 2;
|
|
190
|
+
string account_kind = 3; // USER_SPENDING | USER_PAYOUT | USER_PENDING
|
|
191
|
+
string direction = 4; // CREDIT (give) | DEBIT (take)
|
|
192
|
+
string amount = 5;
|
|
193
|
+
string reason = 6;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
message SalesAnalyticsRequest { string from = 1; string to = 2; string granularity = 3; } // day|week|month
|
|
197
|
+
message SalesPoint { string date = 1; int32 sales_count = 2; string gmv = 3; string revenue = 4; }
|
|
198
|
+
message SellerStat { string seller_id = 1; string username = 2; int32 sales = 3; string gmv = 4; }
|
|
199
|
+
message SalesAnalyticsResponse {
|
|
200
|
+
repeated SalesPoint points = 1;
|
|
201
|
+
repeated SellerStat top_sellers = 2;
|
|
202
|
+
string refund_rate = 3; // % refunded purchases
|
|
142
203
|
}
|