@aepstore-dev/contracts 1.11.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/dist/proto/paths.d.ts +2 -0
- package/dist/proto/paths.js +2 -0
- package/gen/payments.ts +466 -0
- package/package.json +1 -1
- package/proto/payments.proto +203 -0
package/dist/proto/paths.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare const PROTO_PATHS: {
|
|
|
2
2
|
readonly ACTIVITY: string;
|
|
3
3
|
readonly AUTH: string;
|
|
4
4
|
readonly MAIL: string;
|
|
5
|
+
readonly PAYMENTS: string;
|
|
5
6
|
readonly PRODUCTS: string;
|
|
6
7
|
readonly SUPPORT: string;
|
|
7
8
|
readonly TAXONOMY: string;
|
|
@@ -12,6 +13,7 @@ export declare const PROTO_PACKAGES: {
|
|
|
12
13
|
readonly ACTIVITY: "activity.v1";
|
|
13
14
|
readonly AUTH: "auth.v1";
|
|
14
15
|
readonly MAIL: "mail.v1";
|
|
16
|
+
readonly PAYMENTS: "payments.v1";
|
|
15
17
|
readonly PRODUCTS: "products.v1";
|
|
16
18
|
readonly SUPPORT: "support.v1";
|
|
17
19
|
readonly TAXONOMY: "taxonomy.v1";
|
package/dist/proto/paths.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.PROTO_PATHS = {
|
|
|
7
7
|
ACTIVITY: (0, path_1.join)(PROTO_DIR, "activity.proto"),
|
|
8
8
|
AUTH: (0, path_1.join)(PROTO_DIR, "auth.proto"),
|
|
9
9
|
MAIL: (0, path_1.join)(PROTO_DIR, "mail.proto"),
|
|
10
|
+
PAYMENTS: (0, path_1.join)(PROTO_DIR, "payments.proto"),
|
|
10
11
|
PRODUCTS: (0, path_1.join)(PROTO_DIR, "products.proto"),
|
|
11
12
|
SUPPORT: (0, path_1.join)(PROTO_DIR, "support.proto"),
|
|
12
13
|
TAXONOMY: (0, path_1.join)(PROTO_DIR, "taxonomy.proto"),
|
|
@@ -17,6 +18,7 @@ exports.PROTO_PACKAGES = {
|
|
|
17
18
|
ACTIVITY: "activity.v1",
|
|
18
19
|
AUTH: "auth.v1",
|
|
19
20
|
MAIL: "mail.v1",
|
|
21
|
+
PAYMENTS: "payments.v1",
|
|
20
22
|
PRODUCTS: "products.v1",
|
|
21
23
|
SUPPORT: "support.v1",
|
|
22
24
|
TAXONOMY: "taxonomy.v1",
|
package/gen/payments.ts
ADDED
|
@@ -0,0 +1,466 @@
|
|
|
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
|
+
price: string;
|
|
28
|
+
/** PENDING | COMPLETED | FAILED | REFUNDED */
|
|
29
|
+
status: string;
|
|
30
|
+
paymentId: string;
|
|
31
|
+
/** BALANCE | YOOKASSA */
|
|
32
|
+
paymentMethod: string;
|
|
33
|
+
commissionPercent: string;
|
|
34
|
+
sellerAmount: string;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
completedAt: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface TopupRequest {
|
|
40
|
+
userId: string;
|
|
41
|
+
/** >= 10.00 */
|
|
42
|
+
amount: string;
|
|
43
|
+
returnUrl: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface CreateCheckoutRequest {
|
|
47
|
+
userId: string;
|
|
48
|
+
productId: string;
|
|
49
|
+
/** BALANCE | YOOKASSA (default YOOKASSA) */
|
|
50
|
+
paymentMethod: string;
|
|
51
|
+
returnUrl: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface CheckoutResponse {
|
|
55
|
+
purchaseId: string;
|
|
56
|
+
paymentId: string;
|
|
57
|
+
/** empty when paid from balance (instant) */
|
|
58
|
+
confirmationUrl: string;
|
|
59
|
+
/** PENDING (redirect) | COMPLETED (balance) */
|
|
60
|
+
status: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface GetMyPurchasesRequest {
|
|
64
|
+
userId: string;
|
|
65
|
+
page: number;
|
|
66
|
+
limit: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface PurchasesListResponse {
|
|
70
|
+
items: Purchase[];
|
|
71
|
+
total: number;
|
|
72
|
+
page: number;
|
|
73
|
+
limit: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface GetPurchaseRequest {
|
|
77
|
+
id: string;
|
|
78
|
+
userId: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface RefundPurchaseRequest {
|
|
82
|
+
purchaseId: string;
|
|
83
|
+
actorUserId: string;
|
|
84
|
+
isAdmin: boolean;
|
|
85
|
+
reason: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* ---------------------------------------------------------------------------
|
|
90
|
+
* Wallet & statement
|
|
91
|
+
* ---------------------------------------------------------------------------
|
|
92
|
+
*/
|
|
93
|
+
export interface GetWalletRequest {
|
|
94
|
+
userId: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface WalletResponse {
|
|
98
|
+
spending: string;
|
|
99
|
+
pending: string;
|
|
100
|
+
payout: string;
|
|
101
|
+
/** spending + payout */
|
|
102
|
+
spendable: string;
|
|
103
|
+
/** payout */
|
|
104
|
+
withdrawable: string;
|
|
105
|
+
currency: string;
|
|
106
|
+
lifetimeSales: number;
|
|
107
|
+
currentCommissionPercent: string;
|
|
108
|
+
}
|
|
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
|
+
*/
|
|
145
|
+
export interface Withdrawal {
|
|
146
|
+
id: string;
|
|
147
|
+
sellerId: string;
|
|
148
|
+
amount: string;
|
|
149
|
+
/** PENDING | PROCESSING | COMPLETED | REJECTED */
|
|
150
|
+
status: string;
|
|
151
|
+
method: string;
|
|
152
|
+
details: string;
|
|
153
|
+
comment: string;
|
|
154
|
+
processedBy: string;
|
|
155
|
+
processedAt: string;
|
|
156
|
+
createdAt: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface RequestWithdrawalRequest {
|
|
160
|
+
sellerId: string;
|
|
161
|
+
amount: string;
|
|
162
|
+
method: string;
|
|
163
|
+
details: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface ListWithdrawalsRequest {
|
|
167
|
+
sellerId: string;
|
|
168
|
+
status: string;
|
|
169
|
+
page: number;
|
|
170
|
+
limit: number;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface WithdrawalsListResponse {
|
|
174
|
+
items: Withdrawal[];
|
|
175
|
+
total: number;
|
|
176
|
+
page: number;
|
|
177
|
+
limit: number;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface ProcessWithdrawalRequest {
|
|
181
|
+
withdrawalId: string;
|
|
182
|
+
adminId: string;
|
|
183
|
+
action: string;
|
|
184
|
+
comment: string;
|
|
185
|
+
}
|
|
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
|
+
|
|
316
|
+
export const PAYMENTS_V1_PACKAGE_NAME = "payments.v1";
|
|
317
|
+
|
|
318
|
+
/**
|
|
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).
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
export interface PaymentsServiceClient {
|
|
325
|
+
/** ----- buyer ----- */
|
|
326
|
+
|
|
327
|
+
topup(request: TopupRequest): Observable<CheckoutResponse>;
|
|
328
|
+
|
|
329
|
+
createCheckout(request: CreateCheckoutRequest): Observable<CheckoutResponse>;
|
|
330
|
+
|
|
331
|
+
getMyPurchases(request: GetMyPurchasesRequest): Observable<PurchasesListResponse>;
|
|
332
|
+
|
|
333
|
+
getPurchase(request: GetPurchaseRequest): Observable<Purchase>;
|
|
334
|
+
|
|
335
|
+
refundPurchase(request: RefundPurchaseRequest): Observable<Purchase>;
|
|
336
|
+
|
|
337
|
+
/** ----- wallet ----- */
|
|
338
|
+
|
|
339
|
+
getWallet(request: GetWalletRequest): Observable<WalletResponse>;
|
|
340
|
+
|
|
341
|
+
listTransactions(request: ListTransactionsRequest): Observable<TransactionsListResponse>;
|
|
342
|
+
|
|
343
|
+
/** ----- withdrawals ----- */
|
|
344
|
+
|
|
345
|
+
requestWithdrawal(request: RequestWithdrawalRequest): Observable<Withdrawal>;
|
|
346
|
+
|
|
347
|
+
listWithdrawals(request: ListWithdrawalsRequest): Observable<WithdrawalsListResponse>;
|
|
348
|
+
|
|
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>;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
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).
|
|
372
|
+
*/
|
|
373
|
+
|
|
374
|
+
export interface PaymentsServiceController {
|
|
375
|
+
/** ----- buyer ----- */
|
|
376
|
+
|
|
377
|
+
topup(request: TopupRequest): Promise<CheckoutResponse> | Observable<CheckoutResponse> | CheckoutResponse;
|
|
378
|
+
|
|
379
|
+
createCheckout(
|
|
380
|
+
request: CreateCheckoutRequest,
|
|
381
|
+
): Promise<CheckoutResponse> | Observable<CheckoutResponse> | CheckoutResponse;
|
|
382
|
+
|
|
383
|
+
getMyPurchases(
|
|
384
|
+
request: GetMyPurchasesRequest,
|
|
385
|
+
): Promise<PurchasesListResponse> | Observable<PurchasesListResponse> | PurchasesListResponse;
|
|
386
|
+
|
|
387
|
+
getPurchase(request: GetPurchaseRequest): Promise<Purchase> | Observable<Purchase> | Purchase;
|
|
388
|
+
|
|
389
|
+
refundPurchase(request: RefundPurchaseRequest): Promise<Purchase> | Observable<Purchase> | Purchase;
|
|
390
|
+
|
|
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 ----- */
|
|
400
|
+
|
|
401
|
+
requestWithdrawal(request: RequestWithdrawalRequest): Promise<Withdrawal> | Observable<Withdrawal> | Withdrawal;
|
|
402
|
+
|
|
403
|
+
listWithdrawals(
|
|
404
|
+
request: ListWithdrawalsRequest,
|
|
405
|
+
): Promise<WithdrawalsListResponse> | Observable<WithdrawalsListResponse> | WithdrawalsListResponse;
|
|
406
|
+
|
|
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;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export function PaymentsServiceControllerMethods() {
|
|
435
|
+
return function (constructor: Function) {
|
|
436
|
+
const grpcMethods: string[] = [
|
|
437
|
+
"topup",
|
|
438
|
+
"createCheckout",
|
|
439
|
+
"getMyPurchases",
|
|
440
|
+
"getPurchase",
|
|
441
|
+
"refundPurchase",
|
|
442
|
+
"getWallet",
|
|
443
|
+
"listTransactions",
|
|
444
|
+
"requestWithdrawal",
|
|
445
|
+
"listWithdrawals",
|
|
446
|
+
"processWithdrawal",
|
|
447
|
+
"handlePaymentEvent",
|
|
448
|
+
"getAdminOverview",
|
|
449
|
+
"adminListTransactions",
|
|
450
|
+
"getUserFinance",
|
|
451
|
+
"createAdjustment",
|
|
452
|
+
"getSalesAnalytics",
|
|
453
|
+
];
|
|
454
|
+
for (const method of grpcMethods) {
|
|
455
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
456
|
+
GrpcMethod("PaymentsService", method)(constructor.prototype[method], method, descriptor);
|
|
457
|
+
}
|
|
458
|
+
const grpcStreamMethods: string[] = [];
|
|
459
|
+
for (const method of grpcStreamMethods) {
|
|
460
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
461
|
+
GrpcStreamMethod("PaymentsService", method)(constructor.prototype[method], method, descriptor);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export const PAYMENTS_SERVICE_NAME = "PaymentsService";
|
package/package.json
CHANGED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package payments.v1;
|
|
4
|
+
|
|
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).
|
|
8
|
+
service PaymentsService {
|
|
9
|
+
// ----- buyer -----
|
|
10
|
+
rpc Topup(TopupRequest) returns (CheckoutResponse);
|
|
11
|
+
rpc CreateCheckout(CreateCheckoutRequest) returns (CheckoutResponse);
|
|
12
|
+
rpc GetMyPurchases(GetMyPurchasesRequest) returns (PurchasesListResponse);
|
|
13
|
+
rpc GetPurchase(GetPurchaseRequest) returns (Purchase);
|
|
14
|
+
rpc RefundPurchase(RefundPurchaseRequest) returns (Purchase);
|
|
15
|
+
|
|
16
|
+
// ----- wallet -----
|
|
17
|
+
rpc GetWallet(GetWalletRequest) returns (WalletResponse);
|
|
18
|
+
rpc ListTransactions(ListTransactionsRequest) returns (TransactionsListResponse);
|
|
19
|
+
|
|
20
|
+
// ----- withdrawals -----
|
|
21
|
+
rpc RequestWithdrawal(RequestWithdrawalRequest) returns (Withdrawal);
|
|
22
|
+
rpc ListWithdrawals(ListWithdrawalsRequest) returns (WithdrawalsListResponse);
|
|
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);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
message Ok { bool ok = 1; }
|
|
37
|
+
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Purchase / checkout / topup
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
message Purchase {
|
|
42
|
+
string id = 1;
|
|
43
|
+
string product_id = 2;
|
|
44
|
+
string product_name = 3;
|
|
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;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
message CreateCheckoutRequest {
|
|
63
|
+
string user_id = 1;
|
|
64
|
+
string product_id = 2;
|
|
65
|
+
string payment_method = 3; // BALANCE | YOOKASSA (default YOOKASSA)
|
|
66
|
+
string return_url = 4;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
message CheckoutResponse {
|
|
70
|
+
string purchase_id = 1;
|
|
71
|
+
string payment_id = 2;
|
|
72
|
+
string confirmation_url = 3; // empty when paid from balance (instant)
|
|
73
|
+
string status = 4; // PENDING (redirect) | COMPLETED (balance)
|
|
74
|
+
}
|
|
75
|
+
|
|
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; }
|
|
80
|
+
|
|
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 {
|
|
97
|
+
string user_id = 1;
|
|
98
|
+
string type = 2; // optional filter (TOPUP|PURCHASE|SALE_CLEAR|WITHDRAWAL|REFUND|ADJUSTMENT)
|
|
99
|
+
int32 page = 3;
|
|
100
|
+
int32 limit = 4;
|
|
101
|
+
}
|
|
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;
|
|
111
|
+
}
|
|
112
|
+
message TransactionsListResponse { repeated StatementEntry items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
113
|
+
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// Withdrawals
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
message Withdrawal {
|
|
118
|
+
string id = 1;
|
|
119
|
+
string seller_id = 2;
|
|
120
|
+
string amount = 3;
|
|
121
|
+
string status = 4; // PENDING | PROCESSING | COMPLETED | REJECTED
|
|
122
|
+
string method = 5;
|
|
123
|
+
string details = 6;
|
|
124
|
+
string comment = 7;
|
|
125
|
+
string processed_by = 8;
|
|
126
|
+
string processed_at = 9;
|
|
127
|
+
string created_at = 10;
|
|
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; }
|
|
133
|
+
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
// Webhook
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
message PaymentEventRequest { string event = 1; string payment_id = 2; }
|
|
138
|
+
|
|
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
|
|
203
|
+
}
|