@aepstore-dev/contracts 1.102.0 → 1.104.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.
@@ -1,84 +1,84 @@
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
- rpc GetTransactionMonths(GetTransactionMonthsRequest) returns (GetTransactionMonthsResponse);
20
-
21
- // ----- withdrawals -----
22
- rpc RequestWithdrawal(RequestWithdrawalRequest) returns (Withdrawal);
23
- rpc ListWithdrawals(ListWithdrawalsRequest) returns (WithdrawalsListResponse);
24
- rpc ProcessWithdrawal(ProcessWithdrawalRequest) returns (Withdrawal);
25
-
26
- // ----- provider webhook (gateway forwards a verified event) -----
27
- rpc HandlePaymentEvent(PaymentEventRequest) returns (Ok);
28
- // Generalized per-provider callback (POST /payments/webhook/:provider).
29
- // Carries the EXACT raw JSON body: signed providers (Heleket) hash the
30
- // byte-exact payload, so re-serializing a parsed body would break the sign.
31
- rpc HandleProviderCallback(ProviderCallbackRequest) returns (Ok);
32
-
33
- // ----- premium -----
34
- rpc GetPremiumPlans(GetPremiumPlansRequest) returns (PremiumPlansResponse);
35
- rpc PurchasePremium(PurchasePremiumRequest) returns (PurchasePremiumResponse);
36
- rpc SetPremiumPaymentMethod(SetPremiumPaymentMethodRequest) returns (PremiumPaymentMethodResponse);
37
- // 7-day refund window from completedAt. Reverses ledger, calls YooKassa for
38
- // card purchases, rolls back the subscription's expiresAt by the period.
39
- rpc RefundPremium(RefundPremiumRequest) returns (RefundPremiumResponse);
40
- rpc GetMyPremiumPayments(GetMyPremiumPaymentsRequest) returns (PremiumPaymentsListResponse);
41
- rpc GetPremiumPayment(GetPremiumPaymentRequest) returns (PremiumPaymentRow);
42
- // Internal — InternalServiceGuard. tasks-service cron triggers due renewals;
43
- // payments-service iterates ACTIVE subscriptions with autoRenew+savedCard.
44
- rpc RunPremiumRenewals(RunPremiumRenewalsRequest) returns (RunPremiumRenewalsResponse);
45
-
46
- // ----- saved cards -----
47
- rpc ListSavedCards(ListSavedCardsRequest) returns (ListSavedCardsResponse);
48
- rpc DeleteSavedCard(DeleteSavedCardRequest) returns (Ok);
49
- rpc SetDefaultSavedCard(SetDefaultSavedCardRequest) returns (SavedCard);
50
- rpc UpdateSavedCard(UpdateSavedCardRequest) returns (SavedCard);
51
- // Standalone "bind card" flow: creates a 1₽ YooKassa charge with
52
- // save_payment_method=true; after the webhook the SavedCard row is
53
- // persisted and the 1₽ credits USER_SPENDING so the user keeps it.
54
- rpc BindCard(BindCardRequest) returns (CheckoutResponse);
55
- // Poll an intent after returnUrl redirect: TOPUP/PREMIUM completion, bind-card
56
- // completion. Ownership-checked by user_id.
57
- rpc GetPaymentIntent(GetPaymentIntentRequest) returns (PaymentIntentStatus);
58
-
59
- // ----- FX / available methods (public, cached) -----
60
- // Daily CBR rates (RUB base). Frontend uses this for the "≈" display hint;
61
- // the authoritative charge amount is always computed server-side at checkout.
62
- rpc GetRates(GetRatesRequest) returns (GetRatesResponse);
63
- // Payment methods derived from live provider capabilities — the client
64
- // renders only what is actually available (e.g. CRYPTO appears once the
65
- // Heleket merchant is configured).
66
- rpc GetPaymentMethods(GetPaymentMethodsRequest) returns (GetPaymentMethodsResponse);
67
-
68
- // ----- payout details -----
69
- rpc UpdatePayoutDetails(UpdatePayoutDetailsRequest) returns (UpdatePayoutDetailsResponse);
70
- rpc GetPayoutDetails(GetPayoutDetailsRequest) returns (UpdatePayoutDetailsResponse);
71
-
72
- // ----- admin -----
73
- rpc GetAdminOverview(AdminOverviewRequest) returns (AdminOverviewResponse);
74
- rpc AdminListTransactions(AdminListTransactionsRequest) returns (AdminTransactionsListResponse);
75
- rpc GetUserFinance(GetUserFinanceRequest) returns (UserFinanceResponse);
76
- rpc CreateAdjustment(CreateAdjustmentRequest) returns (Ok);
77
- rpc GetSalesAnalytics(SalesAnalyticsRequest) returns (SalesAnalyticsResponse);
78
- }
79
-
80
- message Ok { bool ok = 1; }
81
-
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
+ rpc GetTransactionMonths(GetTransactionMonthsRequest) returns (GetTransactionMonthsResponse);
20
+
21
+ // ----- withdrawals -----
22
+ rpc RequestWithdrawal(RequestWithdrawalRequest) returns (Withdrawal);
23
+ rpc ListWithdrawals(ListWithdrawalsRequest) returns (WithdrawalsListResponse);
24
+ rpc ProcessWithdrawal(ProcessWithdrawalRequest) returns (Withdrawal);
25
+
26
+ // ----- provider webhook (gateway forwards a verified event) -----
27
+ rpc HandlePaymentEvent(PaymentEventRequest) returns (Ok);
28
+ // Generalized per-provider callback (POST /payments/webhook/:provider).
29
+ // Carries the EXACT raw JSON body: signed providers (Heleket) hash the
30
+ // byte-exact payload, so re-serializing a parsed body would break the sign.
31
+ rpc HandleProviderCallback(ProviderCallbackRequest) returns (Ok);
32
+
33
+ // ----- premium -----
34
+ rpc GetPremiumPlans(GetPremiumPlansRequest) returns (PremiumPlansResponse);
35
+ rpc PurchasePremium(PurchasePremiumRequest) returns (PurchasePremiumResponse);
36
+ rpc SetPremiumPaymentMethod(SetPremiumPaymentMethodRequest) returns (PremiumPaymentMethodResponse);
37
+ // 7-day refund window from completedAt. Reverses ledger, calls YooKassa for
38
+ // card purchases, rolls back the subscription's expiresAt by the period.
39
+ rpc RefundPremium(RefundPremiumRequest) returns (RefundPremiumResponse);
40
+ rpc GetMyPremiumPayments(GetMyPremiumPaymentsRequest) returns (PremiumPaymentsListResponse);
41
+ rpc GetPremiumPayment(GetPremiumPaymentRequest) returns (PremiumPaymentRow);
42
+ // Internal — InternalServiceGuard. tasks-service cron triggers due renewals;
43
+ // payments-service iterates ACTIVE subscriptions with autoRenew+savedCard.
44
+ rpc RunPremiumRenewals(RunPremiumRenewalsRequest) returns (RunPremiumRenewalsResponse);
45
+
46
+ // ----- saved cards -----
47
+ rpc ListSavedCards(ListSavedCardsRequest) returns (ListSavedCardsResponse);
48
+ rpc DeleteSavedCard(DeleteSavedCardRequest) returns (Ok);
49
+ rpc SetDefaultSavedCard(SetDefaultSavedCardRequest) returns (SavedCard);
50
+ rpc UpdateSavedCard(UpdateSavedCardRequest) returns (SavedCard);
51
+ // Standalone "bind card" flow: creates a 1₽ YooKassa charge with
52
+ // save_payment_method=true; after the webhook the SavedCard row is
53
+ // persisted and the 1₽ credits USER_SPENDING so the user keeps it.
54
+ rpc BindCard(BindCardRequest) returns (CheckoutResponse);
55
+ // Poll an intent after returnUrl redirect: TOPUP/PREMIUM completion, bind-card
56
+ // completion. Ownership-checked by user_id.
57
+ rpc GetPaymentIntent(GetPaymentIntentRequest) returns (PaymentIntentStatus);
58
+
59
+ // ----- FX / available methods (public, cached) -----
60
+ // Daily CBR rates (RUB base). Frontend uses this for the "≈" display hint;
61
+ // the authoritative charge amount is always computed server-side at checkout.
62
+ rpc GetRates(GetRatesRequest) returns (GetRatesResponse);
63
+ // Payment methods derived from live provider capabilities — the client
64
+ // renders only what is actually available (e.g. CRYPTO appears once the
65
+ // Heleket merchant is configured).
66
+ rpc GetPaymentMethods(GetPaymentMethodsRequest) returns (GetPaymentMethodsResponse);
67
+
68
+ // ----- payout details -----
69
+ rpc UpdatePayoutDetails(UpdatePayoutDetailsRequest) returns (UpdatePayoutDetailsResponse);
70
+ rpc GetPayoutDetails(GetPayoutDetailsRequest) returns (UpdatePayoutDetailsResponse);
71
+
72
+ // ----- admin -----
73
+ rpc GetAdminOverview(AdminOverviewRequest) returns (AdminOverviewResponse);
74
+ rpc AdminListTransactions(AdminListTransactionsRequest) returns (AdminTransactionsListResponse);
75
+ rpc GetUserFinance(GetUserFinanceRequest) returns (UserFinanceResponse);
76
+ rpc CreateAdjustment(CreateAdjustmentRequest) returns (Ok);
77
+ rpc GetSalesAnalytics(SalesAnalyticsRequest) returns (SalesAnalyticsResponse);
78
+ }
79
+
80
+ message Ok { bool ok = 1; }
81
+
82
82
  // ---------------------------------------------------------------------------
83
83
  // Purchase / checkout / topup
84
84
  // ---------------------------------------------------------------------------
@@ -94,78 +94,78 @@ message PurchaseProductCategory {
94
94
  }
95
95
 
96
96
  message Purchase {
97
- string id = 1;
98
- string product_id = 2;
99
- string product_name = 3;
100
- string user_id = 4;
101
- string price = 5; // settled RUB amount
102
- string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
103
- string payment_id = 7;
104
- string payment_method = 8; // BALANCE | YOOKASSA | CRYPTO
105
- string commission_percent = 9;
106
- string seller_amount = 10;
107
- string created_at = 11;
108
- string completed_at = 12;
109
- // FX snapshot at checkout (empty for legacy RUB purchases).
110
- string listing_currency = 13; // RUB | USD | EUR
97
+ string id = 1;
98
+ string product_id = 2;
99
+ string product_name = 3;
100
+ string user_id = 4;
101
+ string price = 5; // settled RUB amount
102
+ string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
103
+ string payment_id = 7;
104
+ string payment_method = 8; // BALANCE | YOOKASSA | CRYPTO
105
+ string commission_percent = 9;
106
+ string seller_amount = 10;
107
+ string created_at = 11;
108
+ string completed_at = 12;
109
+ // FX snapshot at checkout (empty for legacy RUB purchases).
110
+ string listing_currency = 13; // RUB | USD | EUR
111
111
  string listing_price = 14; // Decimal as string, in listing_currency
112
112
  string preview = 16;
113
113
  PurchaseProductUser user = 17;
114
114
  repeated PurchaseProductCategory categories = 18;
115
- string fx_rate = 15; // listing→RUB rate used (Decimal as string)
116
- }
117
-
118
- message TopupRequest {
119
- string user_id = 1;
120
- string amount = 2; // >= 10.00
121
- string return_url = 3;
122
- string payment_method = 4; // YOOKASSA | SAVED_CARD | CRYPTO (default YOOKASSA)
123
- string saved_card_id = 5; // required when payment_method=SAVED_CARD
124
- }
125
-
126
- message CreateCheckoutRequest {
127
- string user_id = 1;
128
- string product_id = 2;
129
- string payment_method = 3; // BALANCE | YOOKASSA | SAVED_CARD | CRYPTO (default YOOKASSA)
130
- string return_url = 4;
131
- // When payment_method=SAVED_CARD — required. ID of a SavedCard row owned
132
- // by user_id. Ignored otherwise.
133
- string saved_card_id = 5;
134
- // When payment_method=YOOKASSA — optional. If true, save the card token
135
- // after success; the bound card becomes available in /account/cards.
136
- bool save_payment_method = 6;
137
- }
138
-
139
- message BindCardRequest {
140
- string user_id = 1;
141
- string return_url = 2;
142
- }
143
-
144
- message GetPaymentIntentRequest {
145
- string intent_id = 1;
146
- string user_id = 2; // ownership check
147
- }
148
-
149
- message PaymentIntentStatus {
150
- string id = 1;
151
- string user_id = 2;
152
- string purpose = 3; // TOPUP | PREMIUM
153
- string status = 4; // PENDING | COMPLETED | FAILED | CANCELED
154
- string amount = 5;
155
- string currency = 6;
156
- string purchase_id = 7; // set when purpose=PREMIUM (else empty)
157
- string created_at = 8;
158
- string updated_at = 9;
159
- }
160
-
161
- message CheckoutResponse {
162
- string purchase_id = 1;
163
- string payment_id = 2;
164
- string confirmation_url = 3; // empty when paid from balance (instant)
165
- string status = 4; // PENDING (redirect) | COMPLETED (balance)
166
- string intent_id = 5; // poll via GetPaymentIntent for TOPUP / bind-card flows
167
- }
168
-
115
+ string fx_rate = 15; // listing→RUB rate used (Decimal as string)
116
+ }
117
+
118
+ message TopupRequest {
119
+ string user_id = 1;
120
+ string amount = 2; // >= 10.00
121
+ string return_url = 3;
122
+ string payment_method = 4; // YOOKASSA | SAVED_CARD | CRYPTO (default YOOKASSA)
123
+ string saved_card_id = 5; // required when payment_method=SAVED_CARD
124
+ }
125
+
126
+ message CreateCheckoutRequest {
127
+ string user_id = 1;
128
+ string product_id = 2;
129
+ string payment_method = 3; // BALANCE | YOOKASSA | SAVED_CARD | CRYPTO (default YOOKASSA)
130
+ string return_url = 4;
131
+ // When payment_method=SAVED_CARD — required. ID of a SavedCard row owned
132
+ // by user_id. Ignored otherwise.
133
+ string saved_card_id = 5;
134
+ // When payment_method=YOOKASSA — optional. If true, save the card token
135
+ // after success; the bound card becomes available in /account/cards.
136
+ bool save_payment_method = 6;
137
+ }
138
+
139
+ message BindCardRequest {
140
+ string user_id = 1;
141
+ string return_url = 2;
142
+ }
143
+
144
+ message GetPaymentIntentRequest {
145
+ string intent_id = 1;
146
+ string user_id = 2; // ownership check
147
+ }
148
+
149
+ message PaymentIntentStatus {
150
+ string id = 1;
151
+ string user_id = 2;
152
+ string purpose = 3; // TOPUP | PREMIUM
153
+ string status = 4; // PENDING | COMPLETED | FAILED | CANCELED
154
+ string amount = 5;
155
+ string currency = 6;
156
+ string purchase_id = 7; // set when purpose=PREMIUM (else empty)
157
+ string created_at = 8;
158
+ string updated_at = 9;
159
+ }
160
+
161
+ message CheckoutResponse {
162
+ string purchase_id = 1;
163
+ string payment_id = 2;
164
+ string confirmation_url = 3; // empty when paid from balance (instant)
165
+ string status = 4; // PENDING (redirect) | COMPLETED (balance)
166
+ string intent_id = 5; // poll via GetPaymentIntent for TOPUP / bind-card flows
167
+ }
168
+
169
169
  message GetMyPurchasesRequest {
170
170
  string user_id = 1;
171
171
  int32 page = 2;
@@ -179,366 +179,366 @@ message GetMyPurchasesRequest {
179
179
  string sort_by = 10;
180
180
  string sort_order = 11;
181
181
  }
182
- message PurchasesListResponse { repeated Purchase items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
183
- message GetPurchaseRequest { string id = 1; string user_id = 2; }
184
- message RefundPurchaseRequest { string purchase_id = 1; string actor_user_id = 2; bool is_admin = 3; string reason = 4; }
185
-
186
- // ---------------------------------------------------------------------------
187
- // Wallet & statement
188
- // ---------------------------------------------------------------------------
189
- message GetWalletRequest { string user_id = 1; }
182
+ message PurchasesListResponse { repeated Purchase items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
183
+ message GetPurchaseRequest { string id = 1; string user_id = 2; }
184
+ message RefundPurchaseRequest { string purchase_id = 1; string actor_user_id = 2; bool is_admin = 3; string reason = 4; }
185
+
186
+ // ---------------------------------------------------------------------------
187
+ // Wallet & statement
188
+ // ---------------------------------------------------------------------------
189
+ message GetWalletRequest { string user_id = 1; }
190
190
  message WalletResponse {
191
191
  string spending = 1;
192
192
  string pending = 2;
193
193
  string payout = 3;
194
194
  string spendable = 4; // spending + payout
195
- string withdrawable = 5; // payout
195
+ string withdrawable = 5; // payout
196
196
  string currency = 6;
197
197
  int32 lifetime_sales = 7;
198
198
  string current_commission_percent = 8;
199
199
  bool hide_balance = 9;
200
200
  }
201
-
202
- message ListTransactionsRequest {
203
- string user_id = 1;
204
- // Legacy low-level filter (one of LedgerTxType). Kept for backward
205
- // compatibility — admin tooling still uses it directly.
206
- string type = 2;
207
- int32 page = 3;
208
- int32 limit = 4;
209
- // ↓ added for the wallet statement page (Round 3)
210
- // UI-semantic filter mapped onto displayKind:
211
- // ALL | SALES | INCOME | OUTCOME | REFUND | WITHDRAWAL | PREMIUM
212
- // SALES = the seller's earnings on this account (USER_PENDING credits from
213
- // PURCHASE transactions); these stay separate from INCOME (TOPUP).
214
- string flow = 5;
215
- // Period selection. `month` is the convenience form (YYYY-MM) used by the
216
- // month dropdown; from/to override it for an arbitrary range.
217
- string month = 6;
218
- string from = 7;
219
- string to = 8;
220
- // Filter wallet to purchases/refunds of a specific Product category. Has
221
- // no effect on TOPUP/WITHDRAWAL/PREMIUM/ADJUSTMENT entries (they have no
222
- // product).
223
- string product_category_id = 9;
224
- // sort_by ∈ { date | amount | type }. Default: date.
225
- string sort_by = 10;
226
- // order ∈ { asc | desc }. Default: desc.
227
- string order = 11;
228
- }
229
- message StatementEntry {
230
- string id = 1;
231
- string tx_id = 2;
232
- string type = 3; // raw tx type (TOPUP|PURCHASE|...)
233
- string account_kind = 4;
234
- string direction = 5; // DEBIT | CREDIT
235
- string amount = 6;
236
- string description = 7;
237
- string created_at = 8;
238
- // ↓ added for the wallet statement page (Round 3)
239
- // UI-friendly classification computed server-side:
240
- // TOPUP | PURCHASE | SALE | REFUND | PREMIUM | WITHDRAWAL | ADJUSTMENT
241
- // SALE is the seller's view of someone else's PURCHASE (CREDIT to their
242
- // USER_PENDING) — distinct from PURCHASE which is the buyer's DEBIT.
243
- // PREMIUM is split out of PURCHASE/REFUND so the UI can show
244
- // "Продление Premium" / refund-of-premium in their own filter bucket.
245
- // SALE_CLEAR transactions are excluded from the wallet view — the maturity
246
- // event is surfaced via sale_status on the original SALE row instead.
247
- string display_kind = 9;
248
- string balance_after = 10; // affected-account running balance, Decimal-as-string
249
- string product_id = 11; // empty for non-product entries
250
- string product_name = 12;
251
- string product_category = 13; // "Assets" | "Project File" | "Templates"
252
- string product_preview = 14; // optional thumbnail URL for richer rows
253
- // Sale lifecycle. Populated only when display_kind=SALE.
254
- // PENDING — held in USER_PENDING, not yet withdrawable.
255
- // MATURED — SALE_CLEAR has fired; money is in USER_PAYOUT.
256
- string sale_status = 15;
257
- // ISO 8601 when the sale becomes withdrawable (sale_completed_at +
258
- // GRACE_DAYS). Empty for non-sale rows.
259
- string matures_at = 16;
260
- }
261
- message TransactionsListResponse { repeated StatementEntry items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
262
-
263
- message GetTransactionMonthsRequest { string user_id = 1; }
264
- message GetTransactionMonthsResponse {
265
- // Newest first. "YYYY-MM" strings; the dropdown renders them
266
- // localized client-side.
267
- repeated string months = 1;
268
- }
269
-
270
- // ---------------------------------------------------------------------------
271
- // Withdrawals
272
- // ---------------------------------------------------------------------------
273
- message Withdrawal {
274
- string id = 1;
275
- string seller_id = 2;
276
- string amount = 3;
277
- string status = 4; // PENDING | PROCESSING | COMPLETED | REJECTED
278
- string method = 5;
279
- string details = 6;
280
- string comment = 7;
281
- string processed_by = 8;
282
- string processed_at = 9;
283
- string created_at = 10;
284
- }
285
- message RequestWithdrawalRequest { string seller_id = 1; string amount = 2; string method = 3; string details = 4; }
286
- message ListWithdrawalsRequest { string seller_id = 1; string status = 2; int32 page = 3; int32 limit = 4; }
287
- message WithdrawalsListResponse { repeated Withdrawal items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
288
- message ProcessWithdrawalRequest { string withdrawal_id = 1; string admin_id = 2; string action = 3; string comment = 4; }
289
-
290
- // ---------------------------------------------------------------------------
291
- // Webhook
292
- // ---------------------------------------------------------------------------
293
- message PaymentEventRequest { string event = 1; string payment_id = 2; }
294
-
295
- message ProviderCallbackRequest {
296
- string provider = 1; // yookassa | heleket | …
297
- string raw_body = 2; // exact raw JSON body as received (signature input)
298
- }
299
-
300
- // ---------------------------------------------------------------------------
301
- // FX rates / payment methods
302
- // ---------------------------------------------------------------------------
303
- message GetRatesRequest {}
304
-
305
- message FxRate {
306
- string currency = 1; // USD | EUR
307
- string rate = 2; // RUB per 1 unit, Decimal as string
308
- }
309
-
310
- message GetRatesResponse {
311
- string base = 1; // always RUB
312
- string as_of = 2; // YYYY-MM-DD the rates are for
313
- repeated FxRate rates = 3;
314
- }
315
-
316
- message GetPaymentMethodsRequest {}
317
-
318
- message PaymentMethodInfo {
319
- string method = 1; // YOOKASSA | SAVED_CARD | CRYPTO | BALANCE
320
- string provider = 2; // yookassa | heleket | '' (BALANCE)
321
- repeated string currencies = 3;
322
- }
323
-
324
- message GetPaymentMethodsResponse {
325
- repeated PaymentMethodInfo methods = 1;
326
- }
327
-
328
- // ---------------------------------------------------------------------------
329
- // Admin
330
- // ---------------------------------------------------------------------------
331
- message AdminOverviewRequest { string from = 1; string to = 2; }
332
- message AdminOverviewResponse {
333
- string revenue = 1; // platform commission earned (period)
334
- string gmv = 2; // gross merchandise value (period)
335
- string liabilities = 3; // Σ all users' (pending+payout+spending) — what we owe
336
- string psp_clearing = 4; // money in transit at PSP
337
- string payouts_payable = 5; // reserved for approved withdrawals
338
- string refunds_total = 6;
339
- string topups_total = 7;
340
- string withdrawals_total = 8;
341
- int32 sales_count = 9;
342
- string currency = 10;
343
- }
344
-
345
- message AdminListTransactionsRequest {
346
- string type = 1;
347
- string user_id = 2;
348
- string account_kind = 3;
349
- string from = 4;
350
- string to = 5;
351
- int32 page = 6;
352
- int32 limit = 7;
353
- }
354
- message AdminEntry { string account_id = 1; string account_kind = 2; string owner_id = 3; string direction = 4; string amount = 5; }
355
- message AdminLedgerTx {
356
- string id = 1;
357
- string type = 2;
358
- string status = 3;
359
- string ref_type = 4;
360
- string ref_id = 5;
361
- string description = 6;
362
- string created_by = 7;
363
- string created_at = 8;
364
- repeated AdminEntry entries = 9;
365
- }
366
- message AdminTransactionsListResponse { repeated AdminLedgerTx items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
367
-
368
- message GetUserFinanceRequest { string user_id = 1; }
369
- message AccountBalance { string kind = 1; string balance = 2; string currency = 3; }
370
- message UserFinanceResponse {
371
- WalletResponse wallet = 1;
372
- repeated AccountBalance accounts = 2;
373
- repeated StatementEntry recent = 3;
374
- }
375
-
376
- message CreateAdjustmentRequest {
377
- string admin_id = 1;
378
- string user_id = 2;
379
- string account_kind = 3; // USER_SPENDING | USER_PAYOUT | USER_PENDING
380
- string direction = 4; // CREDIT (give) | DEBIT (take)
381
- string amount = 5;
382
- string reason = 6;
383
- }
384
-
385
- message SalesAnalyticsRequest { string from = 1; string to = 2; string granularity = 3; } // day|week|month
386
- message SalesPoint { string date = 1; int32 sales_count = 2; string gmv = 3; string revenue = 4; }
387
- message SellerStat { string seller_id = 1; string username = 2; int32 sales = 3; string gmv = 4; }
388
- message SalesAnalyticsResponse {
389
- repeated SalesPoint points = 1;
390
- repeated SellerStat top_sellers = 2;
391
- string refund_rate = 3; // % refunded purchases
392
- }
393
-
394
- // ---------------------------------------------------------------------------
395
- // Premium
396
- // ---------------------------------------------------------------------------
397
- message GetPremiumPlansRequest {}
398
-
399
- // One plan per (period). Prices are computed server-side from BASE_PRICE × months
400
- // × (1 − discount); kept here as canonical strings so the gateway has no math.
401
- message PremiumPlan {
402
- string period = 1; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
403
- int32 months = 2;
404
- string price = 3; // total to charge, Decimal-as-string
405
- string monthly_price = 4; // for UI "≈ X ₽/month"
406
- string discount_percent = 5;
407
- string currency = 6;
408
- }
409
-
410
- message PremiumPlansResponse {
411
- repeated PremiumPlan plans = 1;
412
- string base_monthly_price = 2;
413
- }
414
-
415
- message PurchasePremiumRequest {
416
- string user_id = 1;
417
- string period = 2; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
418
- string payment_method = 3; // BALANCE | YOOKASSA | SAVED_CARD (empty = smart default)
419
- string return_url = 4; // YooKassa only
420
- // Save the YooKassa payment_method for future auto-renewals. Ignored for
421
- // BALANCE. Kept for backwards compatibility; auto_renew=true implies save.
422
- bool save_payment_method = 5;
423
- bool auto_renew = 6; // default false; requires off-session-capable method
424
- string saved_card_id = 7; // optional for SAVED_CARD; empty = default card
425
- }
426
-
427
- message PurchasePremiumResponse {
428
- string payment_id = 1; // PremiumPayment.id
429
- string confirmation_url = 2; // empty for BALANCE (instant) or YooKassa-issued
430
- string status = 3; // PENDING (redirect) | COMPLETED (balance)
431
- }
432
-
433
- message RunPremiumRenewalsRequest {
434
- int32 max_batch = 1; // safety cap; default 100
435
- }
436
-
437
- message RunPremiumRenewalsResponse {
438
- int32 attempted = 1;
439
- int32 succeeded = 2;
440
- int32 failed = 3;
441
- }
442
-
443
- message SetPremiumPaymentMethodRequest {
444
- string user_id = 1;
445
- string method = 2; // BALANCE | YOOKASSA | SAVED_CARD
446
- string saved_card_id = 3; // optional for SAVED_CARD; empty = default card
447
- }
448
-
449
- message PremiumPaymentMethodResponse {
450
- string method = 1; // BALANCE | YOOKASSA | SAVED_CARD
451
- string saved_card_id = 2; // empty unless SAVED_CARD
452
- bool auto_renew = 3;
453
- }
454
-
455
- message PremiumPaymentRow {
456
- string id = 1;
457
- string user_id = 2;
458
- string amount = 3;
459
- string period = 4; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
460
- string method = 5; // BALANCE | YOOKASSA
461
- string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
462
- bool is_renewal = 7;
463
- string created_at = 8;
464
- string completed_at = 9;
465
- string refunded_at = 10;
466
- string refunded_amount = 11;
467
- // Convenience: true if this payment is currently inside the 7-day refund
468
- // window AND status == COMPLETED AND not already refunded.
469
- bool refundable = 12;
470
- }
471
-
472
- message RefundPremiumRequest {
473
- string user_id = 1;
474
- string payment_id = 2;
475
- string reason = 3; // optional
476
- }
477
-
478
- message RefundPremiumResponse {
479
- PremiumPaymentRow payment = 1;
480
- string new_expires_at = 2; // ISO 8601 after rollback
481
- bool subscription_revoked = 3; // true when rollback put expiresAt <= now
482
- }
483
-
201
+
202
+ message ListTransactionsRequest {
203
+ string user_id = 1;
204
+ // Legacy low-level filter (one of LedgerTxType). Kept for backward
205
+ // compatibility — admin tooling still uses it directly.
206
+ string type = 2;
207
+ int32 page = 3;
208
+ int32 limit = 4;
209
+ // ↓ added for the wallet statement page (Round 3)
210
+ // UI-semantic filter mapped onto displayKind:
211
+ // ALL | SALES | INCOME | OUTCOME | REFUND | WITHDRAWAL | PREMIUM
212
+ // SALES = the seller's earnings on this account (USER_PENDING credits from
213
+ // PURCHASE transactions); these stay separate from INCOME (TOPUP).
214
+ string flow = 5;
215
+ // Period selection. `month` is the convenience form (YYYY-MM) used by the
216
+ // month dropdown; from/to override it for an arbitrary range.
217
+ string month = 6;
218
+ string from = 7;
219
+ string to = 8;
220
+ // Filter wallet to purchases/refunds of a specific Product category. Has
221
+ // no effect on TOPUP/WITHDRAWAL/PREMIUM/ADJUSTMENT entries (they have no
222
+ // product).
223
+ string product_category_id = 9;
224
+ // sort_by ∈ { date | amount | type }. Default: date.
225
+ string sort_by = 10;
226
+ // order ∈ { asc | desc }. Default: desc.
227
+ string order = 11;
228
+ }
229
+ message StatementEntry {
230
+ string id = 1;
231
+ string tx_id = 2;
232
+ string type = 3; // raw tx type (TOPUP|PURCHASE|...)
233
+ string account_kind = 4;
234
+ string direction = 5; // DEBIT | CREDIT
235
+ string amount = 6;
236
+ string description = 7;
237
+ string created_at = 8;
238
+ // ↓ added for the wallet statement page (Round 3)
239
+ // UI-friendly classification computed server-side:
240
+ // TOPUP | PURCHASE | SALE | REFUND | PREMIUM | WITHDRAWAL | ADJUSTMENT
241
+ // SALE is the seller's view of someone else's PURCHASE (CREDIT to their
242
+ // USER_PENDING) — distinct from PURCHASE which is the buyer's DEBIT.
243
+ // PREMIUM is split out of PURCHASE/REFUND so the UI can show
244
+ // "Продление Premium" / refund-of-premium in their own filter bucket.
245
+ // SALE_CLEAR transactions are excluded from the wallet view — the maturity
246
+ // event is surfaced via sale_status on the original SALE row instead.
247
+ string display_kind = 9;
248
+ string balance_after = 10; // affected-account running balance, Decimal-as-string
249
+ string product_id = 11; // empty for non-product entries
250
+ string product_name = 12;
251
+ string product_category = 13; // "Assets" | "Project File" | "Templates"
252
+ string product_preview = 14; // optional thumbnail URL for richer rows
253
+ // Sale lifecycle. Populated only when display_kind=SALE.
254
+ // PENDING — held in USER_PENDING, not yet withdrawable.
255
+ // MATURED — SALE_CLEAR has fired; money is in USER_PAYOUT.
256
+ string sale_status = 15;
257
+ // ISO 8601 when the sale becomes withdrawable (sale_completed_at +
258
+ // GRACE_DAYS). Empty for non-sale rows.
259
+ string matures_at = 16;
260
+ }
261
+ message TransactionsListResponse { repeated StatementEntry items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
262
+
263
+ message GetTransactionMonthsRequest { string user_id = 1; }
264
+ message GetTransactionMonthsResponse {
265
+ // Newest first. "YYYY-MM" strings; the dropdown renders them
266
+ // localized client-side.
267
+ repeated string months = 1;
268
+ }
269
+
270
+ // ---------------------------------------------------------------------------
271
+ // Withdrawals
272
+ // ---------------------------------------------------------------------------
273
+ message Withdrawal {
274
+ string id = 1;
275
+ string seller_id = 2;
276
+ string amount = 3;
277
+ string status = 4; // PENDING | PROCESSING | COMPLETED | REJECTED
278
+ string method = 5;
279
+ string details = 6;
280
+ string comment = 7;
281
+ string processed_by = 8;
282
+ string processed_at = 9;
283
+ string created_at = 10;
284
+ }
285
+ message RequestWithdrawalRequest { string seller_id = 1; string amount = 2; string method = 3; string details = 4; }
286
+ message ListWithdrawalsRequest { string seller_id = 1; string status = 2; int32 page = 3; int32 limit = 4; }
287
+ message WithdrawalsListResponse { repeated Withdrawal items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
288
+ message ProcessWithdrawalRequest { string withdrawal_id = 1; string admin_id = 2; string action = 3; string comment = 4; }
289
+
290
+ // ---------------------------------------------------------------------------
291
+ // Webhook
292
+ // ---------------------------------------------------------------------------
293
+ message PaymentEventRequest { string event = 1; string payment_id = 2; }
294
+
295
+ message ProviderCallbackRequest {
296
+ string provider = 1; // yookassa | heleket | …
297
+ string raw_body = 2; // exact raw JSON body as received (signature input)
298
+ }
299
+
300
+ // ---------------------------------------------------------------------------
301
+ // FX rates / payment methods
302
+ // ---------------------------------------------------------------------------
303
+ message GetRatesRequest {}
304
+
305
+ message FxRate {
306
+ string currency = 1; // USD | EUR
307
+ string rate = 2; // RUB per 1 unit, Decimal as string
308
+ }
309
+
310
+ message GetRatesResponse {
311
+ string base = 1; // always RUB
312
+ string as_of = 2; // YYYY-MM-DD the rates are for
313
+ repeated FxRate rates = 3;
314
+ }
315
+
316
+ message GetPaymentMethodsRequest {}
317
+
318
+ message PaymentMethodInfo {
319
+ string method = 1; // YOOKASSA | SAVED_CARD | CRYPTO | BALANCE
320
+ string provider = 2; // yookassa | heleket | '' (BALANCE)
321
+ repeated string currencies = 3;
322
+ }
323
+
324
+ message GetPaymentMethodsResponse {
325
+ repeated PaymentMethodInfo methods = 1;
326
+ }
327
+
328
+ // ---------------------------------------------------------------------------
329
+ // Admin
330
+ // ---------------------------------------------------------------------------
331
+ message AdminOverviewRequest { string from = 1; string to = 2; }
332
+ message AdminOverviewResponse {
333
+ string revenue = 1; // platform commission earned (period)
334
+ string gmv = 2; // gross merchandise value (period)
335
+ string liabilities = 3; // Σ all users' (pending+payout+spending) — what we owe
336
+ string psp_clearing = 4; // money in transit at PSP
337
+ string payouts_payable = 5; // reserved for approved withdrawals
338
+ string refunds_total = 6;
339
+ string topups_total = 7;
340
+ string withdrawals_total = 8;
341
+ int32 sales_count = 9;
342
+ string currency = 10;
343
+ }
344
+
345
+ message AdminListTransactionsRequest {
346
+ string type = 1;
347
+ string user_id = 2;
348
+ string account_kind = 3;
349
+ string from = 4;
350
+ string to = 5;
351
+ int32 page = 6;
352
+ int32 limit = 7;
353
+ }
354
+ message AdminEntry { string account_id = 1; string account_kind = 2; string owner_id = 3; string direction = 4; string amount = 5; }
355
+ message AdminLedgerTx {
356
+ string id = 1;
357
+ string type = 2;
358
+ string status = 3;
359
+ string ref_type = 4;
360
+ string ref_id = 5;
361
+ string description = 6;
362
+ string created_by = 7;
363
+ string created_at = 8;
364
+ repeated AdminEntry entries = 9;
365
+ }
366
+ message AdminTransactionsListResponse { repeated AdminLedgerTx items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
367
+
368
+ message GetUserFinanceRequest { string user_id = 1; }
369
+ message AccountBalance { string kind = 1; string balance = 2; string currency = 3; }
370
+ message UserFinanceResponse {
371
+ WalletResponse wallet = 1;
372
+ repeated AccountBalance accounts = 2;
373
+ repeated StatementEntry recent = 3;
374
+ }
375
+
376
+ message CreateAdjustmentRequest {
377
+ string admin_id = 1;
378
+ string user_id = 2;
379
+ string account_kind = 3; // USER_SPENDING | USER_PAYOUT | USER_PENDING
380
+ string direction = 4; // CREDIT (give) | DEBIT (take)
381
+ string amount = 5;
382
+ string reason = 6;
383
+ }
384
+
385
+ message SalesAnalyticsRequest { string from = 1; string to = 2; string granularity = 3; } // day|week|month
386
+ message SalesPoint { string date = 1; int32 sales_count = 2; string gmv = 3; string revenue = 4; }
387
+ message SellerStat { string seller_id = 1; string username = 2; int32 sales = 3; string gmv = 4; }
388
+ message SalesAnalyticsResponse {
389
+ repeated SalesPoint points = 1;
390
+ repeated SellerStat top_sellers = 2;
391
+ string refund_rate = 3; // % refunded purchases
392
+ }
393
+
394
+ // ---------------------------------------------------------------------------
395
+ // Premium
396
+ // ---------------------------------------------------------------------------
397
+ message GetPremiumPlansRequest {}
398
+
399
+ // One plan per (period). Prices are computed server-side from BASE_PRICE × months
400
+ // × (1 − discount); kept here as canonical strings so the gateway has no math.
401
+ message PremiumPlan {
402
+ string period = 1; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
403
+ int32 months = 2;
404
+ string price = 3; // total to charge, Decimal-as-string
405
+ string monthly_price = 4; // for UI "≈ X ₽/month"
406
+ string discount_percent = 5;
407
+ string currency = 6;
408
+ }
409
+
410
+ message PremiumPlansResponse {
411
+ repeated PremiumPlan plans = 1;
412
+ string base_monthly_price = 2;
413
+ }
414
+
415
+ message PurchasePremiumRequest {
416
+ string user_id = 1;
417
+ string period = 2; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
418
+ string payment_method = 3; // BALANCE | YOOKASSA | SAVED_CARD (empty = smart default)
419
+ string return_url = 4; // YooKassa only
420
+ // Save the YooKassa payment_method for future auto-renewals. Ignored for
421
+ // BALANCE. Kept for backwards compatibility; auto_renew=true implies save.
422
+ bool save_payment_method = 5;
423
+ bool auto_renew = 6; // default false; requires off-session-capable method
424
+ string saved_card_id = 7; // optional for SAVED_CARD; empty = default card
425
+ }
426
+
427
+ message PurchasePremiumResponse {
428
+ string payment_id = 1; // PremiumPayment.id
429
+ string confirmation_url = 2; // empty for BALANCE (instant) or YooKassa-issued
430
+ string status = 3; // PENDING (redirect) | COMPLETED (balance)
431
+ }
432
+
433
+ message RunPremiumRenewalsRequest {
434
+ int32 max_batch = 1; // safety cap; default 100
435
+ }
436
+
437
+ message RunPremiumRenewalsResponse {
438
+ int32 attempted = 1;
439
+ int32 succeeded = 2;
440
+ int32 failed = 3;
441
+ }
442
+
443
+ message SetPremiumPaymentMethodRequest {
444
+ string user_id = 1;
445
+ string method = 2; // BALANCE | YOOKASSA | SAVED_CARD
446
+ string saved_card_id = 3; // optional for SAVED_CARD; empty = default card
447
+ }
448
+
449
+ message PremiumPaymentMethodResponse {
450
+ string method = 1; // BALANCE | YOOKASSA | SAVED_CARD
451
+ string saved_card_id = 2; // empty unless SAVED_CARD
452
+ bool auto_renew = 3;
453
+ }
454
+
455
+ message PremiumPaymentRow {
456
+ string id = 1;
457
+ string user_id = 2;
458
+ string amount = 3;
459
+ string period = 4; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
460
+ string method = 5; // BALANCE | YOOKASSA
461
+ string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
462
+ bool is_renewal = 7;
463
+ string created_at = 8;
464
+ string completed_at = 9;
465
+ string refunded_at = 10;
466
+ string refunded_amount = 11;
467
+ // Convenience: true if this payment is currently inside the 7-day refund
468
+ // window AND status == COMPLETED AND not already refunded.
469
+ bool refundable = 12;
470
+ }
471
+
472
+ message RefundPremiumRequest {
473
+ string user_id = 1;
474
+ string payment_id = 2;
475
+ string reason = 3; // optional
476
+ }
477
+
478
+ message RefundPremiumResponse {
479
+ PremiumPaymentRow payment = 1;
480
+ string new_expires_at = 2; // ISO 8601 after rollback
481
+ bool subscription_revoked = 3; // true when rollback put expiresAt <= now
482
+ }
483
+
484
484
  message GetMyPremiumPaymentsRequest {
485
485
  string user_id = 1;
486
486
  int32 page = 2;
487
487
  int32 limit = 3;
488
488
  string refundable = 4; // optional: "true"|"false"
489
489
  }
490
-
491
- message GetPremiumPaymentRequest {
492
- string user_id = 1;
493
- string payment_id = 2;
494
- }
495
-
496
- message PremiumPaymentsListResponse {
497
- repeated PremiumPaymentRow items = 1;
498
- int32 total = 2;
499
- int32 page = 3;
500
- int32 limit = 4;
501
- }
502
-
503
- // ---------------------------------------------------------------------------
504
- // Saved cards (YooKassa payment_method tokens; we never see PAN)
505
- // ---------------------------------------------------------------------------
506
- message SavedCard {
507
- string id = 1;
508
- string brand = 2; // "MIR" | "VISA" | "MASTERCARD" | ""
509
- string last4 = 3; // "0000" etc, display-only
510
- int32 exp_month = 4;
511
- int32 exp_year = 5;
512
- bool is_default = 6;
513
- string nickname = 7; // user-set label
514
- string created_at = 8;
515
- }
516
-
517
- message ListSavedCardsRequest { string user_id = 1; }
518
- message ListSavedCardsResponse { repeated SavedCard items = 1; }
519
-
520
- message DeleteSavedCardRequest { string user_id = 1; string id = 2; }
521
-
522
- message SetDefaultSavedCardRequest { string user_id = 1; string id = 2; }
523
-
524
- message UpdateSavedCardRequest {
525
- string user_id = 1;
526
- string id = 2;
527
- string nickname = 3; // empty = clear
528
- }
529
-
530
- // ---------------------------------------------------------------------------
531
- // Payout details (persistent default; per-withdrawal override still allowed)
532
- // ---------------------------------------------------------------------------
533
- message UpdatePayoutDetailsRequest {
534
- string user_id = 1;
535
- string method = 2; // "card" | "sbp" | "bank" | "" (clear)
536
- string details = 3; // JSON string — payments-service treats opaquely
537
- }
538
-
539
- message UpdatePayoutDetailsResponse {
540
- string method = 1;
541
- string details = 2;
542
- }
543
-
544
- message GetPayoutDetailsRequest { string user_id = 1; }
490
+
491
+ message GetPremiumPaymentRequest {
492
+ string user_id = 1;
493
+ string payment_id = 2;
494
+ }
495
+
496
+ message PremiumPaymentsListResponse {
497
+ repeated PremiumPaymentRow items = 1;
498
+ int32 total = 2;
499
+ int32 page = 3;
500
+ int32 limit = 4;
501
+ }
502
+
503
+ // ---------------------------------------------------------------------------
504
+ // Saved cards (YooKassa payment_method tokens; we never see PAN)
505
+ // ---------------------------------------------------------------------------
506
+ message SavedCard {
507
+ string id = 1;
508
+ string brand = 2; // "MIR" | "VISA" | "MASTERCARD" | ""
509
+ string last4 = 3; // "0000" etc, display-only
510
+ int32 exp_month = 4;
511
+ int32 exp_year = 5;
512
+ bool is_default = 6;
513
+ string nickname = 7; // user-set label
514
+ string created_at = 8;
515
+ }
516
+
517
+ message ListSavedCardsRequest { string user_id = 1; }
518
+ message ListSavedCardsResponse { repeated SavedCard items = 1; }
519
+
520
+ message DeleteSavedCardRequest { string user_id = 1; string id = 2; }
521
+
522
+ message SetDefaultSavedCardRequest { string user_id = 1; string id = 2; }
523
+
524
+ message UpdateSavedCardRequest {
525
+ string user_id = 1;
526
+ string id = 2;
527
+ string nickname = 3; // empty = clear
528
+ }
529
+
530
+ // ---------------------------------------------------------------------------
531
+ // Payout details (persistent default; per-withdrawal override still allowed)
532
+ // ---------------------------------------------------------------------------
533
+ message UpdatePayoutDetailsRequest {
534
+ string user_id = 1;
535
+ string method = 2; // "card" | "sbp" | "bank" | "" (clear)
536
+ string details = 3; // JSON string — payments-service treats opaquely
537
+ }
538
+
539
+ message UpdatePayoutDetailsResponse {
540
+ string method = 1;
541
+ string details = 2;
542
+ }
543
+
544
+ message GetPayoutDetailsRequest { string user_id = 1; }