@aepstore-dev/contracts 1.52.0 → 1.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gen/activity.js +1 -1
- package/gen/activity.ts +1 -1
- package/gen/auth.js +1 -1
- package/gen/auth.ts +1 -1
- package/gen/mail.js +1 -1
- package/gen/mail.ts +1 -1
- package/gen/payments.js +1 -1
- package/gen/payments.ts +1 -1
- package/gen/products.js +1 -1
- package/gen/products.ts +1 -1
- package/gen/support.js +1 -1
- package/gen/support.ts +1 -1
- package/gen/taxonomy.js +1 -1
- package/gen/taxonomy.ts +1 -1
- package/gen/upload.js +1 -1
- package/gen/upload.ts +1 -1
- package/gen/users.d.ts +30 -0
- package/gen/users.js +2 -1
- package/gen/users.ts +38 -1
- package/package.json +35 -35
- package/proto/activity.proto +200 -200
- package/proto/auth.proto +195 -195
- package/proto/mail.proto +54 -54
- package/proto/payments.proto +445 -445
- package/proto/products.proto +402 -402
- package/proto/support.proto +144 -144
- package/proto/taxonomy.proto +105 -105
- package/proto/upload.proto +171 -171
- package/proto/users.proto +700 -679
package/proto/payments.proto
CHANGED
|
@@ -1,445 +1,445 @@
|
|
|
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
|
-
|
|
29
|
-
// ----- premium -----
|
|
30
|
-
rpc GetPremiumPlans(GetPremiumPlansRequest) returns (PremiumPlansResponse);
|
|
31
|
-
rpc PurchasePremium(PurchasePremiumRequest) returns (PurchasePremiumResponse);
|
|
32
|
-
// 7-day refund window from completedAt. Reverses ledger, calls YooKassa for
|
|
33
|
-
// card purchases, rolls back the subscription's expiresAt by the period.
|
|
34
|
-
rpc RefundPremium(RefundPremiumRequest) returns (RefundPremiumResponse);
|
|
35
|
-
rpc GetMyPremiumPayments(GetMyPremiumPaymentsRequest) returns (PremiumPaymentsListResponse);
|
|
36
|
-
// Internal — InternalServiceGuard. tasks-service cron triggers due renewals;
|
|
37
|
-
// payments-service iterates ACTIVE subscriptions with autoRenew+savedCard.
|
|
38
|
-
rpc RunPremiumRenewals(RunPremiumRenewalsRequest) returns (RunPremiumRenewalsResponse);
|
|
39
|
-
|
|
40
|
-
// ----- saved cards -----
|
|
41
|
-
rpc ListSavedCards(ListSavedCardsRequest) returns (ListSavedCardsResponse);
|
|
42
|
-
rpc DeleteSavedCard(DeleteSavedCardRequest) returns (Ok);
|
|
43
|
-
rpc SetDefaultSavedCard(SetDefaultSavedCardRequest) returns (SavedCard);
|
|
44
|
-
rpc UpdateSavedCard(UpdateSavedCardRequest) returns (SavedCard);
|
|
45
|
-
// Standalone "bind card" flow: creates a 1₽ YooKassa charge with
|
|
46
|
-
// save_payment_method=true; after the webhook the SavedCard row is
|
|
47
|
-
// persisted and the 1₽ credits USER_SPENDING so the user keeps it.
|
|
48
|
-
rpc BindCard(BindCardRequest) returns (CheckoutResponse);
|
|
49
|
-
// Poll an intent after returnUrl redirect: TOPUP/PREMIUM completion, bind-card
|
|
50
|
-
// completion. Ownership-checked by user_id.
|
|
51
|
-
rpc GetPaymentIntent(GetPaymentIntentRequest) returns (PaymentIntentStatus);
|
|
52
|
-
|
|
53
|
-
// ----- payout details -----
|
|
54
|
-
rpc UpdatePayoutDetails(UpdatePayoutDetailsRequest) returns (UpdatePayoutDetailsResponse);
|
|
55
|
-
rpc GetPayoutDetails(GetPayoutDetailsRequest) returns (UpdatePayoutDetailsResponse);
|
|
56
|
-
|
|
57
|
-
// ----- admin -----
|
|
58
|
-
rpc GetAdminOverview(AdminOverviewRequest) returns (AdminOverviewResponse);
|
|
59
|
-
rpc AdminListTransactions(AdminListTransactionsRequest) returns (AdminTransactionsListResponse);
|
|
60
|
-
rpc GetUserFinance(GetUserFinanceRequest) returns (UserFinanceResponse);
|
|
61
|
-
rpc CreateAdjustment(CreateAdjustmentRequest) returns (Ok);
|
|
62
|
-
rpc GetSalesAnalytics(SalesAnalyticsRequest) returns (SalesAnalyticsResponse);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
message Ok { bool ok = 1; }
|
|
66
|
-
|
|
67
|
-
// ---------------------------------------------------------------------------
|
|
68
|
-
// Purchase / checkout / topup
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
message Purchase {
|
|
71
|
-
string id = 1;
|
|
72
|
-
string product_id = 2;
|
|
73
|
-
string product_name = 3;
|
|
74
|
-
string user_id = 4;
|
|
75
|
-
string price = 5;
|
|
76
|
-
string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
|
|
77
|
-
string payment_id = 7;
|
|
78
|
-
string payment_method = 8; // BALANCE | YOOKASSA
|
|
79
|
-
string commission_percent = 9;
|
|
80
|
-
string seller_amount = 10;
|
|
81
|
-
string created_at = 11;
|
|
82
|
-
string completed_at = 12;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
message TopupRequest {
|
|
86
|
-
string user_id = 1;
|
|
87
|
-
string amount = 2; // >= 10.00
|
|
88
|
-
string return_url = 3;
|
|
89
|
-
string payment_method = 4; // YOOKASSA | SAVED_CARD (default YOOKASSA)
|
|
90
|
-
string saved_card_id = 5; // required when payment_method=SAVED_CARD
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
message CreateCheckoutRequest {
|
|
94
|
-
string user_id = 1;
|
|
95
|
-
string product_id = 2;
|
|
96
|
-
string payment_method = 3; // BALANCE | YOOKASSA | SAVED_CARD (default YOOKASSA)
|
|
97
|
-
string return_url = 4;
|
|
98
|
-
// When payment_method=SAVED_CARD — required. ID of a SavedCard row owned
|
|
99
|
-
// by user_id. Ignored otherwise.
|
|
100
|
-
string saved_card_id = 5;
|
|
101
|
-
// When payment_method=YOOKASSA — optional. If true, save the card token
|
|
102
|
-
// after success; the bound card becomes available in /account/cards.
|
|
103
|
-
bool save_payment_method = 6;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
message BindCardRequest {
|
|
107
|
-
string user_id = 1;
|
|
108
|
-
string return_url = 2;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
message GetPaymentIntentRequest {
|
|
112
|
-
string intent_id = 1;
|
|
113
|
-
string user_id = 2; // ownership check
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
message PaymentIntentStatus {
|
|
117
|
-
string id = 1;
|
|
118
|
-
string user_id = 2;
|
|
119
|
-
string purpose = 3; // TOPUP | PREMIUM
|
|
120
|
-
string status = 4; // PENDING | COMPLETED | FAILED | CANCELED
|
|
121
|
-
string amount = 5;
|
|
122
|
-
string currency = 6;
|
|
123
|
-
string purchase_id = 7; // set when purpose=PREMIUM (else empty)
|
|
124
|
-
string created_at = 8;
|
|
125
|
-
string updated_at = 9;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
message CheckoutResponse {
|
|
129
|
-
string purchase_id = 1;
|
|
130
|
-
string payment_id = 2;
|
|
131
|
-
string confirmation_url = 3; // empty when paid from balance (instant)
|
|
132
|
-
string status = 4; // PENDING (redirect) | COMPLETED (balance)
|
|
133
|
-
string intent_id = 5; // poll via GetPaymentIntent for TOPUP / bind-card flows
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
message GetMyPurchasesRequest { string user_id = 1; int32 page = 2; int32 limit = 3; }
|
|
137
|
-
message PurchasesListResponse { repeated Purchase items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
138
|
-
message GetPurchaseRequest { string id = 1; string user_id = 2; }
|
|
139
|
-
message RefundPurchaseRequest { string purchase_id = 1; string actor_user_id = 2; bool is_admin = 3; string reason = 4; }
|
|
140
|
-
|
|
141
|
-
// ---------------------------------------------------------------------------
|
|
142
|
-
// Wallet & statement
|
|
143
|
-
// ---------------------------------------------------------------------------
|
|
144
|
-
message GetWalletRequest { string user_id = 1; }
|
|
145
|
-
message WalletResponse {
|
|
146
|
-
string spending = 1;
|
|
147
|
-
string pending = 2;
|
|
148
|
-
string payout = 3;
|
|
149
|
-
string spendable = 4; // spending + payout
|
|
150
|
-
string withdrawable = 5; // payout
|
|
151
|
-
string currency = 6;
|
|
152
|
-
int32 lifetime_sales = 7;
|
|
153
|
-
string current_commission_percent = 8;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
message ListTransactionsRequest {
|
|
157
|
-
string user_id = 1;
|
|
158
|
-
// Legacy low-level filter (one of LedgerTxType). Kept for backward
|
|
159
|
-
// compatibility — admin tooling still uses it directly.
|
|
160
|
-
string type = 2;
|
|
161
|
-
int32 page = 3;
|
|
162
|
-
int32 limit = 4;
|
|
163
|
-
// ↓ added for the wallet statement page (Round 3)
|
|
164
|
-
// UI-semantic filter mapped onto displayKind:
|
|
165
|
-
// ALL | SALES | INCOME | OUTCOME | REFUND | WITHDRAWAL | PREMIUM
|
|
166
|
-
// SALES = the seller's earnings on this account (USER_PENDING credits from
|
|
167
|
-
// PURCHASE transactions); these stay separate from INCOME (TOPUP).
|
|
168
|
-
string flow = 5;
|
|
169
|
-
// Period selection. `month` is the convenience form (YYYY-MM) used by the
|
|
170
|
-
// month dropdown; from/to override it for an arbitrary range.
|
|
171
|
-
string month = 6;
|
|
172
|
-
string from = 7;
|
|
173
|
-
string to = 8;
|
|
174
|
-
// Filter wallet to purchases/refunds of a specific Product category. Has
|
|
175
|
-
// no effect on TOPUP/WITHDRAWAL/PREMIUM/ADJUSTMENT entries (they have no
|
|
176
|
-
// product).
|
|
177
|
-
string product_category_id = 9;
|
|
178
|
-
// sort_by ∈ { date | amount | type }. Default: date.
|
|
179
|
-
string sort_by = 10;
|
|
180
|
-
// order ∈ { asc | desc }. Default: desc.
|
|
181
|
-
string order = 11;
|
|
182
|
-
}
|
|
183
|
-
message StatementEntry {
|
|
184
|
-
string id = 1;
|
|
185
|
-
string tx_id = 2;
|
|
186
|
-
string type = 3; // raw tx type (TOPUP|PURCHASE|...)
|
|
187
|
-
string account_kind = 4;
|
|
188
|
-
string direction = 5; // DEBIT | CREDIT
|
|
189
|
-
string amount = 6;
|
|
190
|
-
string description = 7;
|
|
191
|
-
string created_at = 8;
|
|
192
|
-
// ↓ added for the wallet statement page (Round 3)
|
|
193
|
-
// UI-friendly classification computed server-side:
|
|
194
|
-
// TOPUP | PURCHASE | SALE | REFUND | PREMIUM | WITHDRAWAL | ADJUSTMENT
|
|
195
|
-
// SALE is the seller's view of someone else's PURCHASE (CREDIT to their
|
|
196
|
-
// USER_PENDING) — distinct from PURCHASE which is the buyer's DEBIT.
|
|
197
|
-
// PREMIUM is split out of PURCHASE/REFUND so the UI can show
|
|
198
|
-
// "Продление Premium" / refund-of-premium in their own filter bucket.
|
|
199
|
-
// SALE_CLEAR transactions are excluded from the wallet view — the maturity
|
|
200
|
-
// event is surfaced via sale_status on the original SALE row instead.
|
|
201
|
-
string display_kind = 9;
|
|
202
|
-
string balance_after = 10; // affected-account running balance, Decimal-as-string
|
|
203
|
-
string product_id = 11; // empty for non-product entries
|
|
204
|
-
string product_name = 12;
|
|
205
|
-
string product_category = 13; // "Assets" | "Project File" | "Templates"
|
|
206
|
-
string product_preview = 14; // optional thumbnail URL for richer rows
|
|
207
|
-
// Sale lifecycle. Populated only when display_kind=SALE.
|
|
208
|
-
// PENDING — held in USER_PENDING, not yet withdrawable.
|
|
209
|
-
// MATURED — SALE_CLEAR has fired; money is in USER_PAYOUT.
|
|
210
|
-
string sale_status = 15;
|
|
211
|
-
// ISO 8601 when the sale becomes withdrawable (sale_completed_at +
|
|
212
|
-
// GRACE_DAYS). Empty for non-sale rows.
|
|
213
|
-
string matures_at = 16;
|
|
214
|
-
}
|
|
215
|
-
message TransactionsListResponse { repeated StatementEntry items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
216
|
-
|
|
217
|
-
message GetTransactionMonthsRequest { string user_id = 1; }
|
|
218
|
-
message GetTransactionMonthsResponse {
|
|
219
|
-
// Newest first. "YYYY-MM" strings; the dropdown renders them
|
|
220
|
-
// localized client-side.
|
|
221
|
-
repeated string months = 1;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// ---------------------------------------------------------------------------
|
|
225
|
-
// Withdrawals
|
|
226
|
-
// ---------------------------------------------------------------------------
|
|
227
|
-
message Withdrawal {
|
|
228
|
-
string id = 1;
|
|
229
|
-
string seller_id = 2;
|
|
230
|
-
string amount = 3;
|
|
231
|
-
string status = 4; // PENDING | PROCESSING | COMPLETED | REJECTED
|
|
232
|
-
string method = 5;
|
|
233
|
-
string details = 6;
|
|
234
|
-
string comment = 7;
|
|
235
|
-
string processed_by = 8;
|
|
236
|
-
string processed_at = 9;
|
|
237
|
-
string created_at = 10;
|
|
238
|
-
}
|
|
239
|
-
message RequestWithdrawalRequest { string seller_id = 1; string amount = 2; string method = 3; string details = 4; }
|
|
240
|
-
message ListWithdrawalsRequest { string seller_id = 1; string status = 2; int32 page = 3; int32 limit = 4; }
|
|
241
|
-
message WithdrawalsListResponse { repeated Withdrawal items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
242
|
-
message ProcessWithdrawalRequest { string withdrawal_id = 1; string admin_id = 2; string action = 3; string comment = 4; }
|
|
243
|
-
|
|
244
|
-
// ---------------------------------------------------------------------------
|
|
245
|
-
// Webhook
|
|
246
|
-
// ---------------------------------------------------------------------------
|
|
247
|
-
message PaymentEventRequest { string event = 1; string payment_id = 2; }
|
|
248
|
-
|
|
249
|
-
// ---------------------------------------------------------------------------
|
|
250
|
-
// Admin
|
|
251
|
-
// ---------------------------------------------------------------------------
|
|
252
|
-
message AdminOverviewRequest { string from = 1; string to = 2; }
|
|
253
|
-
message AdminOverviewResponse {
|
|
254
|
-
string revenue = 1; // platform commission earned (period)
|
|
255
|
-
string gmv = 2; // gross merchandise value (period)
|
|
256
|
-
string liabilities = 3; // Σ all users' (pending+payout+spending) — what we owe
|
|
257
|
-
string psp_clearing = 4; // money in transit at PSP
|
|
258
|
-
string payouts_payable = 5; // reserved for approved withdrawals
|
|
259
|
-
string refunds_total = 6;
|
|
260
|
-
string topups_total = 7;
|
|
261
|
-
string withdrawals_total = 8;
|
|
262
|
-
int32 sales_count = 9;
|
|
263
|
-
string currency = 10;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
message AdminListTransactionsRequest {
|
|
267
|
-
string type = 1;
|
|
268
|
-
string user_id = 2;
|
|
269
|
-
string account_kind = 3;
|
|
270
|
-
string from = 4;
|
|
271
|
-
string to = 5;
|
|
272
|
-
int32 page = 6;
|
|
273
|
-
int32 limit = 7;
|
|
274
|
-
}
|
|
275
|
-
message AdminEntry { string account_id = 1; string account_kind = 2; string owner_id = 3; string direction = 4; string amount = 5; }
|
|
276
|
-
message AdminLedgerTx {
|
|
277
|
-
string id = 1;
|
|
278
|
-
string type = 2;
|
|
279
|
-
string status = 3;
|
|
280
|
-
string ref_type = 4;
|
|
281
|
-
string ref_id = 5;
|
|
282
|
-
string description = 6;
|
|
283
|
-
string created_by = 7;
|
|
284
|
-
string created_at = 8;
|
|
285
|
-
repeated AdminEntry entries = 9;
|
|
286
|
-
}
|
|
287
|
-
message AdminTransactionsListResponse { repeated AdminLedgerTx items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
288
|
-
|
|
289
|
-
message GetUserFinanceRequest { string user_id = 1; }
|
|
290
|
-
message AccountBalance { string kind = 1; string balance = 2; string currency = 3; }
|
|
291
|
-
message UserFinanceResponse {
|
|
292
|
-
WalletResponse wallet = 1;
|
|
293
|
-
repeated AccountBalance accounts = 2;
|
|
294
|
-
repeated StatementEntry recent = 3;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
message CreateAdjustmentRequest {
|
|
298
|
-
string admin_id = 1;
|
|
299
|
-
string user_id = 2;
|
|
300
|
-
string account_kind = 3; // USER_SPENDING | USER_PAYOUT | USER_PENDING
|
|
301
|
-
string direction = 4; // CREDIT (give) | DEBIT (take)
|
|
302
|
-
string amount = 5;
|
|
303
|
-
string reason = 6;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
message SalesAnalyticsRequest { string from = 1; string to = 2; string granularity = 3; } // day|week|month
|
|
307
|
-
message SalesPoint { string date = 1; int32 sales_count = 2; string gmv = 3; string revenue = 4; }
|
|
308
|
-
message SellerStat { string seller_id = 1; string username = 2; int32 sales = 3; string gmv = 4; }
|
|
309
|
-
message SalesAnalyticsResponse {
|
|
310
|
-
repeated SalesPoint points = 1;
|
|
311
|
-
repeated SellerStat top_sellers = 2;
|
|
312
|
-
string refund_rate = 3; // % refunded purchases
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// ---------------------------------------------------------------------------
|
|
316
|
-
// Premium
|
|
317
|
-
// ---------------------------------------------------------------------------
|
|
318
|
-
message GetPremiumPlansRequest {}
|
|
319
|
-
|
|
320
|
-
// One plan per (period). Prices are computed server-side from BASE_PRICE × months
|
|
321
|
-
// × (1 − discount); kept here as canonical strings so the gateway has no math.
|
|
322
|
-
message PremiumPlan {
|
|
323
|
-
string period = 1; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
|
|
324
|
-
int32 months = 2;
|
|
325
|
-
string price = 3; // total to charge, Decimal-as-string
|
|
326
|
-
string monthly_price = 4; // for UI "≈ X ₽/month"
|
|
327
|
-
string discount_percent = 5;
|
|
328
|
-
string currency = 6;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
message PremiumPlansResponse {
|
|
332
|
-
repeated PremiumPlan plans = 1;
|
|
333
|
-
string base_monthly_price = 2;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
message PurchasePremiumRequest {
|
|
337
|
-
string user_id = 1;
|
|
338
|
-
string period = 2; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
|
|
339
|
-
string payment_method = 3; // BALANCE | YOOKASSA
|
|
340
|
-
string return_url = 4; // YooKassa only
|
|
341
|
-
// Save the YooKassa payment_method for future auto-renewals. Ignored for
|
|
342
|
-
// BALANCE. Default true — the UI surfaces a checkbox.
|
|
343
|
-
bool save_payment_method = 5;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
message PurchasePremiumResponse {
|
|
347
|
-
string payment_id = 1; // PremiumPayment.id
|
|
348
|
-
string confirmation_url = 2; // empty for BALANCE (instant) or YooKassa-issued
|
|
349
|
-
string status = 3; // PENDING (redirect) | COMPLETED (balance)
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
message RunPremiumRenewalsRequest {
|
|
353
|
-
int32 max_batch = 1; // safety cap; default 100
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
message RunPremiumRenewalsResponse {
|
|
357
|
-
int32 attempted = 1;
|
|
358
|
-
int32 succeeded = 2;
|
|
359
|
-
int32 failed = 3;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
message PremiumPaymentRow {
|
|
363
|
-
string id = 1;
|
|
364
|
-
string user_id = 2;
|
|
365
|
-
string amount = 3;
|
|
366
|
-
string period = 4; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
|
|
367
|
-
string method = 5; // BALANCE | YOOKASSA
|
|
368
|
-
string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
|
|
369
|
-
bool is_renewal = 7;
|
|
370
|
-
string created_at = 8;
|
|
371
|
-
string completed_at = 9;
|
|
372
|
-
string refunded_at = 10;
|
|
373
|
-
string refunded_amount = 11;
|
|
374
|
-
// Convenience: true if this payment is currently inside the 7-day refund
|
|
375
|
-
// window AND status == COMPLETED AND not already refunded.
|
|
376
|
-
bool refundable = 12;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
message RefundPremiumRequest {
|
|
380
|
-
string user_id = 1;
|
|
381
|
-
string payment_id = 2;
|
|
382
|
-
string reason = 3; // optional
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
message RefundPremiumResponse {
|
|
386
|
-
PremiumPaymentRow payment = 1;
|
|
387
|
-
string new_expires_at = 2; // ISO 8601 after rollback
|
|
388
|
-
bool subscription_revoked = 3; // true when rollback put expiresAt <= now
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
message GetMyPremiumPaymentsRequest {
|
|
392
|
-
string user_id = 1;
|
|
393
|
-
int32 page = 2;
|
|
394
|
-
int32 limit = 3;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
message PremiumPaymentsListResponse {
|
|
398
|
-
repeated PremiumPaymentRow items = 1;
|
|
399
|
-
int32 total = 2;
|
|
400
|
-
int32 page = 3;
|
|
401
|
-
int32 limit = 4;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// ---------------------------------------------------------------------------
|
|
405
|
-
// Saved cards (YooKassa payment_method tokens; we never see PAN)
|
|
406
|
-
// ---------------------------------------------------------------------------
|
|
407
|
-
message SavedCard {
|
|
408
|
-
string id = 1;
|
|
409
|
-
string brand = 2; // "MIR" | "VISA" | "MASTERCARD" | ""
|
|
410
|
-
string last4 = 3; // "0000" etc, display-only
|
|
411
|
-
int32 exp_month = 4;
|
|
412
|
-
int32 exp_year = 5;
|
|
413
|
-
bool is_default = 6;
|
|
414
|
-
string nickname = 7; // user-set label
|
|
415
|
-
string created_at = 8;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
message ListSavedCardsRequest { string user_id = 1; }
|
|
419
|
-
message ListSavedCardsResponse { repeated SavedCard items = 1; }
|
|
420
|
-
|
|
421
|
-
message DeleteSavedCardRequest { string user_id = 1; string id = 2; }
|
|
422
|
-
|
|
423
|
-
message SetDefaultSavedCardRequest { string user_id = 1; string id = 2; }
|
|
424
|
-
|
|
425
|
-
message UpdateSavedCardRequest {
|
|
426
|
-
string user_id = 1;
|
|
427
|
-
string id = 2;
|
|
428
|
-
string nickname = 3; // empty = clear
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// ---------------------------------------------------------------------------
|
|
432
|
-
// Payout details (persistent default; per-withdrawal override still allowed)
|
|
433
|
-
// ---------------------------------------------------------------------------
|
|
434
|
-
message UpdatePayoutDetailsRequest {
|
|
435
|
-
string user_id = 1;
|
|
436
|
-
string method = 2; // "card" | "sbp" | "bank" | "" (clear)
|
|
437
|
-
string details = 3; // JSON string — payments-service treats opaquely
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
message UpdatePayoutDetailsResponse {
|
|
441
|
-
string method = 1;
|
|
442
|
-
string details = 2;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
message GetPayoutDetailsRequest { string user_id = 1; }
|
|
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
|
+
|
|
29
|
+
// ----- premium -----
|
|
30
|
+
rpc GetPremiumPlans(GetPremiumPlansRequest) returns (PremiumPlansResponse);
|
|
31
|
+
rpc PurchasePremium(PurchasePremiumRequest) returns (PurchasePremiumResponse);
|
|
32
|
+
// 7-day refund window from completedAt. Reverses ledger, calls YooKassa for
|
|
33
|
+
// card purchases, rolls back the subscription's expiresAt by the period.
|
|
34
|
+
rpc RefundPremium(RefundPremiumRequest) returns (RefundPremiumResponse);
|
|
35
|
+
rpc GetMyPremiumPayments(GetMyPremiumPaymentsRequest) returns (PremiumPaymentsListResponse);
|
|
36
|
+
// Internal — InternalServiceGuard. tasks-service cron triggers due renewals;
|
|
37
|
+
// payments-service iterates ACTIVE subscriptions with autoRenew+savedCard.
|
|
38
|
+
rpc RunPremiumRenewals(RunPremiumRenewalsRequest) returns (RunPremiumRenewalsResponse);
|
|
39
|
+
|
|
40
|
+
// ----- saved cards -----
|
|
41
|
+
rpc ListSavedCards(ListSavedCardsRequest) returns (ListSavedCardsResponse);
|
|
42
|
+
rpc DeleteSavedCard(DeleteSavedCardRequest) returns (Ok);
|
|
43
|
+
rpc SetDefaultSavedCard(SetDefaultSavedCardRequest) returns (SavedCard);
|
|
44
|
+
rpc UpdateSavedCard(UpdateSavedCardRequest) returns (SavedCard);
|
|
45
|
+
// Standalone "bind card" flow: creates a 1₽ YooKassa charge with
|
|
46
|
+
// save_payment_method=true; after the webhook the SavedCard row is
|
|
47
|
+
// persisted and the 1₽ credits USER_SPENDING so the user keeps it.
|
|
48
|
+
rpc BindCard(BindCardRequest) returns (CheckoutResponse);
|
|
49
|
+
// Poll an intent after returnUrl redirect: TOPUP/PREMIUM completion, bind-card
|
|
50
|
+
// completion. Ownership-checked by user_id.
|
|
51
|
+
rpc GetPaymentIntent(GetPaymentIntentRequest) returns (PaymentIntentStatus);
|
|
52
|
+
|
|
53
|
+
// ----- payout details -----
|
|
54
|
+
rpc UpdatePayoutDetails(UpdatePayoutDetailsRequest) returns (UpdatePayoutDetailsResponse);
|
|
55
|
+
rpc GetPayoutDetails(GetPayoutDetailsRequest) returns (UpdatePayoutDetailsResponse);
|
|
56
|
+
|
|
57
|
+
// ----- admin -----
|
|
58
|
+
rpc GetAdminOverview(AdminOverviewRequest) returns (AdminOverviewResponse);
|
|
59
|
+
rpc AdminListTransactions(AdminListTransactionsRequest) returns (AdminTransactionsListResponse);
|
|
60
|
+
rpc GetUserFinance(GetUserFinanceRequest) returns (UserFinanceResponse);
|
|
61
|
+
rpc CreateAdjustment(CreateAdjustmentRequest) returns (Ok);
|
|
62
|
+
rpc GetSalesAnalytics(SalesAnalyticsRequest) returns (SalesAnalyticsResponse);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
message Ok { bool ok = 1; }
|
|
66
|
+
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// Purchase / checkout / topup
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
message Purchase {
|
|
71
|
+
string id = 1;
|
|
72
|
+
string product_id = 2;
|
|
73
|
+
string product_name = 3;
|
|
74
|
+
string user_id = 4;
|
|
75
|
+
string price = 5;
|
|
76
|
+
string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
|
|
77
|
+
string payment_id = 7;
|
|
78
|
+
string payment_method = 8; // BALANCE | YOOKASSA
|
|
79
|
+
string commission_percent = 9;
|
|
80
|
+
string seller_amount = 10;
|
|
81
|
+
string created_at = 11;
|
|
82
|
+
string completed_at = 12;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
message TopupRequest {
|
|
86
|
+
string user_id = 1;
|
|
87
|
+
string amount = 2; // >= 10.00
|
|
88
|
+
string return_url = 3;
|
|
89
|
+
string payment_method = 4; // YOOKASSA | SAVED_CARD (default YOOKASSA)
|
|
90
|
+
string saved_card_id = 5; // required when payment_method=SAVED_CARD
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
message CreateCheckoutRequest {
|
|
94
|
+
string user_id = 1;
|
|
95
|
+
string product_id = 2;
|
|
96
|
+
string payment_method = 3; // BALANCE | YOOKASSA | SAVED_CARD (default YOOKASSA)
|
|
97
|
+
string return_url = 4;
|
|
98
|
+
// When payment_method=SAVED_CARD — required. ID of a SavedCard row owned
|
|
99
|
+
// by user_id. Ignored otherwise.
|
|
100
|
+
string saved_card_id = 5;
|
|
101
|
+
// When payment_method=YOOKASSA — optional. If true, save the card token
|
|
102
|
+
// after success; the bound card becomes available in /account/cards.
|
|
103
|
+
bool save_payment_method = 6;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
message BindCardRequest {
|
|
107
|
+
string user_id = 1;
|
|
108
|
+
string return_url = 2;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
message GetPaymentIntentRequest {
|
|
112
|
+
string intent_id = 1;
|
|
113
|
+
string user_id = 2; // ownership check
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
message PaymentIntentStatus {
|
|
117
|
+
string id = 1;
|
|
118
|
+
string user_id = 2;
|
|
119
|
+
string purpose = 3; // TOPUP | PREMIUM
|
|
120
|
+
string status = 4; // PENDING | COMPLETED | FAILED | CANCELED
|
|
121
|
+
string amount = 5;
|
|
122
|
+
string currency = 6;
|
|
123
|
+
string purchase_id = 7; // set when purpose=PREMIUM (else empty)
|
|
124
|
+
string created_at = 8;
|
|
125
|
+
string updated_at = 9;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
message CheckoutResponse {
|
|
129
|
+
string purchase_id = 1;
|
|
130
|
+
string payment_id = 2;
|
|
131
|
+
string confirmation_url = 3; // empty when paid from balance (instant)
|
|
132
|
+
string status = 4; // PENDING (redirect) | COMPLETED (balance)
|
|
133
|
+
string intent_id = 5; // poll via GetPaymentIntent for TOPUP / bind-card flows
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
message GetMyPurchasesRequest { string user_id = 1; int32 page = 2; int32 limit = 3; }
|
|
137
|
+
message PurchasesListResponse { repeated Purchase items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
138
|
+
message GetPurchaseRequest { string id = 1; string user_id = 2; }
|
|
139
|
+
message RefundPurchaseRequest { string purchase_id = 1; string actor_user_id = 2; bool is_admin = 3; string reason = 4; }
|
|
140
|
+
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
// Wallet & statement
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
message GetWalletRequest { string user_id = 1; }
|
|
145
|
+
message WalletResponse {
|
|
146
|
+
string spending = 1;
|
|
147
|
+
string pending = 2;
|
|
148
|
+
string payout = 3;
|
|
149
|
+
string spendable = 4; // spending + payout
|
|
150
|
+
string withdrawable = 5; // payout
|
|
151
|
+
string currency = 6;
|
|
152
|
+
int32 lifetime_sales = 7;
|
|
153
|
+
string current_commission_percent = 8;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
message ListTransactionsRequest {
|
|
157
|
+
string user_id = 1;
|
|
158
|
+
// Legacy low-level filter (one of LedgerTxType). Kept for backward
|
|
159
|
+
// compatibility — admin tooling still uses it directly.
|
|
160
|
+
string type = 2;
|
|
161
|
+
int32 page = 3;
|
|
162
|
+
int32 limit = 4;
|
|
163
|
+
// ↓ added for the wallet statement page (Round 3)
|
|
164
|
+
// UI-semantic filter mapped onto displayKind:
|
|
165
|
+
// ALL | SALES | INCOME | OUTCOME | REFUND | WITHDRAWAL | PREMIUM
|
|
166
|
+
// SALES = the seller's earnings on this account (USER_PENDING credits from
|
|
167
|
+
// PURCHASE transactions); these stay separate from INCOME (TOPUP).
|
|
168
|
+
string flow = 5;
|
|
169
|
+
// Period selection. `month` is the convenience form (YYYY-MM) used by the
|
|
170
|
+
// month dropdown; from/to override it for an arbitrary range.
|
|
171
|
+
string month = 6;
|
|
172
|
+
string from = 7;
|
|
173
|
+
string to = 8;
|
|
174
|
+
// Filter wallet to purchases/refunds of a specific Product category. Has
|
|
175
|
+
// no effect on TOPUP/WITHDRAWAL/PREMIUM/ADJUSTMENT entries (they have no
|
|
176
|
+
// product).
|
|
177
|
+
string product_category_id = 9;
|
|
178
|
+
// sort_by ∈ { date | amount | type }. Default: date.
|
|
179
|
+
string sort_by = 10;
|
|
180
|
+
// order ∈ { asc | desc }. Default: desc.
|
|
181
|
+
string order = 11;
|
|
182
|
+
}
|
|
183
|
+
message StatementEntry {
|
|
184
|
+
string id = 1;
|
|
185
|
+
string tx_id = 2;
|
|
186
|
+
string type = 3; // raw tx type (TOPUP|PURCHASE|...)
|
|
187
|
+
string account_kind = 4;
|
|
188
|
+
string direction = 5; // DEBIT | CREDIT
|
|
189
|
+
string amount = 6;
|
|
190
|
+
string description = 7;
|
|
191
|
+
string created_at = 8;
|
|
192
|
+
// ↓ added for the wallet statement page (Round 3)
|
|
193
|
+
// UI-friendly classification computed server-side:
|
|
194
|
+
// TOPUP | PURCHASE | SALE | REFUND | PREMIUM | WITHDRAWAL | ADJUSTMENT
|
|
195
|
+
// SALE is the seller's view of someone else's PURCHASE (CREDIT to their
|
|
196
|
+
// USER_PENDING) — distinct from PURCHASE which is the buyer's DEBIT.
|
|
197
|
+
// PREMIUM is split out of PURCHASE/REFUND so the UI can show
|
|
198
|
+
// "Продление Premium" / refund-of-premium in their own filter bucket.
|
|
199
|
+
// SALE_CLEAR transactions are excluded from the wallet view — the maturity
|
|
200
|
+
// event is surfaced via sale_status on the original SALE row instead.
|
|
201
|
+
string display_kind = 9;
|
|
202
|
+
string balance_after = 10; // affected-account running balance, Decimal-as-string
|
|
203
|
+
string product_id = 11; // empty for non-product entries
|
|
204
|
+
string product_name = 12;
|
|
205
|
+
string product_category = 13; // "Assets" | "Project File" | "Templates"
|
|
206
|
+
string product_preview = 14; // optional thumbnail URL for richer rows
|
|
207
|
+
// Sale lifecycle. Populated only when display_kind=SALE.
|
|
208
|
+
// PENDING — held in USER_PENDING, not yet withdrawable.
|
|
209
|
+
// MATURED — SALE_CLEAR has fired; money is in USER_PAYOUT.
|
|
210
|
+
string sale_status = 15;
|
|
211
|
+
// ISO 8601 when the sale becomes withdrawable (sale_completed_at +
|
|
212
|
+
// GRACE_DAYS). Empty for non-sale rows.
|
|
213
|
+
string matures_at = 16;
|
|
214
|
+
}
|
|
215
|
+
message TransactionsListResponse { repeated StatementEntry items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
216
|
+
|
|
217
|
+
message GetTransactionMonthsRequest { string user_id = 1; }
|
|
218
|
+
message GetTransactionMonthsResponse {
|
|
219
|
+
// Newest first. "YYYY-MM" strings; the dropdown renders them
|
|
220
|
+
// localized client-side.
|
|
221
|
+
repeated string months = 1;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ---------------------------------------------------------------------------
|
|
225
|
+
// Withdrawals
|
|
226
|
+
// ---------------------------------------------------------------------------
|
|
227
|
+
message Withdrawal {
|
|
228
|
+
string id = 1;
|
|
229
|
+
string seller_id = 2;
|
|
230
|
+
string amount = 3;
|
|
231
|
+
string status = 4; // PENDING | PROCESSING | COMPLETED | REJECTED
|
|
232
|
+
string method = 5;
|
|
233
|
+
string details = 6;
|
|
234
|
+
string comment = 7;
|
|
235
|
+
string processed_by = 8;
|
|
236
|
+
string processed_at = 9;
|
|
237
|
+
string created_at = 10;
|
|
238
|
+
}
|
|
239
|
+
message RequestWithdrawalRequest { string seller_id = 1; string amount = 2; string method = 3; string details = 4; }
|
|
240
|
+
message ListWithdrawalsRequest { string seller_id = 1; string status = 2; int32 page = 3; int32 limit = 4; }
|
|
241
|
+
message WithdrawalsListResponse { repeated Withdrawal items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
242
|
+
message ProcessWithdrawalRequest { string withdrawal_id = 1; string admin_id = 2; string action = 3; string comment = 4; }
|
|
243
|
+
|
|
244
|
+
// ---------------------------------------------------------------------------
|
|
245
|
+
// Webhook
|
|
246
|
+
// ---------------------------------------------------------------------------
|
|
247
|
+
message PaymentEventRequest { string event = 1; string payment_id = 2; }
|
|
248
|
+
|
|
249
|
+
// ---------------------------------------------------------------------------
|
|
250
|
+
// Admin
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
message AdminOverviewRequest { string from = 1; string to = 2; }
|
|
253
|
+
message AdminOverviewResponse {
|
|
254
|
+
string revenue = 1; // platform commission earned (period)
|
|
255
|
+
string gmv = 2; // gross merchandise value (period)
|
|
256
|
+
string liabilities = 3; // Σ all users' (pending+payout+spending) — what we owe
|
|
257
|
+
string psp_clearing = 4; // money in transit at PSP
|
|
258
|
+
string payouts_payable = 5; // reserved for approved withdrawals
|
|
259
|
+
string refunds_total = 6;
|
|
260
|
+
string topups_total = 7;
|
|
261
|
+
string withdrawals_total = 8;
|
|
262
|
+
int32 sales_count = 9;
|
|
263
|
+
string currency = 10;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
message AdminListTransactionsRequest {
|
|
267
|
+
string type = 1;
|
|
268
|
+
string user_id = 2;
|
|
269
|
+
string account_kind = 3;
|
|
270
|
+
string from = 4;
|
|
271
|
+
string to = 5;
|
|
272
|
+
int32 page = 6;
|
|
273
|
+
int32 limit = 7;
|
|
274
|
+
}
|
|
275
|
+
message AdminEntry { string account_id = 1; string account_kind = 2; string owner_id = 3; string direction = 4; string amount = 5; }
|
|
276
|
+
message AdminLedgerTx {
|
|
277
|
+
string id = 1;
|
|
278
|
+
string type = 2;
|
|
279
|
+
string status = 3;
|
|
280
|
+
string ref_type = 4;
|
|
281
|
+
string ref_id = 5;
|
|
282
|
+
string description = 6;
|
|
283
|
+
string created_by = 7;
|
|
284
|
+
string created_at = 8;
|
|
285
|
+
repeated AdminEntry entries = 9;
|
|
286
|
+
}
|
|
287
|
+
message AdminTransactionsListResponse { repeated AdminLedgerTx items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
|
|
288
|
+
|
|
289
|
+
message GetUserFinanceRequest { string user_id = 1; }
|
|
290
|
+
message AccountBalance { string kind = 1; string balance = 2; string currency = 3; }
|
|
291
|
+
message UserFinanceResponse {
|
|
292
|
+
WalletResponse wallet = 1;
|
|
293
|
+
repeated AccountBalance accounts = 2;
|
|
294
|
+
repeated StatementEntry recent = 3;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
message CreateAdjustmentRequest {
|
|
298
|
+
string admin_id = 1;
|
|
299
|
+
string user_id = 2;
|
|
300
|
+
string account_kind = 3; // USER_SPENDING | USER_PAYOUT | USER_PENDING
|
|
301
|
+
string direction = 4; // CREDIT (give) | DEBIT (take)
|
|
302
|
+
string amount = 5;
|
|
303
|
+
string reason = 6;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
message SalesAnalyticsRequest { string from = 1; string to = 2; string granularity = 3; } // day|week|month
|
|
307
|
+
message SalesPoint { string date = 1; int32 sales_count = 2; string gmv = 3; string revenue = 4; }
|
|
308
|
+
message SellerStat { string seller_id = 1; string username = 2; int32 sales = 3; string gmv = 4; }
|
|
309
|
+
message SalesAnalyticsResponse {
|
|
310
|
+
repeated SalesPoint points = 1;
|
|
311
|
+
repeated SellerStat top_sellers = 2;
|
|
312
|
+
string refund_rate = 3; // % refunded purchases
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// ---------------------------------------------------------------------------
|
|
316
|
+
// Premium
|
|
317
|
+
// ---------------------------------------------------------------------------
|
|
318
|
+
message GetPremiumPlansRequest {}
|
|
319
|
+
|
|
320
|
+
// One plan per (period). Prices are computed server-side from BASE_PRICE × months
|
|
321
|
+
// × (1 − discount); kept here as canonical strings so the gateway has no math.
|
|
322
|
+
message PremiumPlan {
|
|
323
|
+
string period = 1; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
|
|
324
|
+
int32 months = 2;
|
|
325
|
+
string price = 3; // total to charge, Decimal-as-string
|
|
326
|
+
string monthly_price = 4; // for UI "≈ X ₽/month"
|
|
327
|
+
string discount_percent = 5;
|
|
328
|
+
string currency = 6;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
message PremiumPlansResponse {
|
|
332
|
+
repeated PremiumPlan plans = 1;
|
|
333
|
+
string base_monthly_price = 2;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
message PurchasePremiumRequest {
|
|
337
|
+
string user_id = 1;
|
|
338
|
+
string period = 2; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
|
|
339
|
+
string payment_method = 3; // BALANCE | YOOKASSA
|
|
340
|
+
string return_url = 4; // YooKassa only
|
|
341
|
+
// Save the YooKassa payment_method for future auto-renewals. Ignored for
|
|
342
|
+
// BALANCE. Default true — the UI surfaces a checkbox.
|
|
343
|
+
bool save_payment_method = 5;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
message PurchasePremiumResponse {
|
|
347
|
+
string payment_id = 1; // PremiumPayment.id
|
|
348
|
+
string confirmation_url = 2; // empty for BALANCE (instant) or YooKassa-issued
|
|
349
|
+
string status = 3; // PENDING (redirect) | COMPLETED (balance)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
message RunPremiumRenewalsRequest {
|
|
353
|
+
int32 max_batch = 1; // safety cap; default 100
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
message RunPremiumRenewalsResponse {
|
|
357
|
+
int32 attempted = 1;
|
|
358
|
+
int32 succeeded = 2;
|
|
359
|
+
int32 failed = 3;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
message PremiumPaymentRow {
|
|
363
|
+
string id = 1;
|
|
364
|
+
string user_id = 2;
|
|
365
|
+
string amount = 3;
|
|
366
|
+
string period = 4; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
|
|
367
|
+
string method = 5; // BALANCE | YOOKASSA
|
|
368
|
+
string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
|
|
369
|
+
bool is_renewal = 7;
|
|
370
|
+
string created_at = 8;
|
|
371
|
+
string completed_at = 9;
|
|
372
|
+
string refunded_at = 10;
|
|
373
|
+
string refunded_amount = 11;
|
|
374
|
+
// Convenience: true if this payment is currently inside the 7-day refund
|
|
375
|
+
// window AND status == COMPLETED AND not already refunded.
|
|
376
|
+
bool refundable = 12;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
message RefundPremiumRequest {
|
|
380
|
+
string user_id = 1;
|
|
381
|
+
string payment_id = 2;
|
|
382
|
+
string reason = 3; // optional
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
message RefundPremiumResponse {
|
|
386
|
+
PremiumPaymentRow payment = 1;
|
|
387
|
+
string new_expires_at = 2; // ISO 8601 after rollback
|
|
388
|
+
bool subscription_revoked = 3; // true when rollback put expiresAt <= now
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
message GetMyPremiumPaymentsRequest {
|
|
392
|
+
string user_id = 1;
|
|
393
|
+
int32 page = 2;
|
|
394
|
+
int32 limit = 3;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
message PremiumPaymentsListResponse {
|
|
398
|
+
repeated PremiumPaymentRow items = 1;
|
|
399
|
+
int32 total = 2;
|
|
400
|
+
int32 page = 3;
|
|
401
|
+
int32 limit = 4;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// ---------------------------------------------------------------------------
|
|
405
|
+
// Saved cards (YooKassa payment_method tokens; we never see PAN)
|
|
406
|
+
// ---------------------------------------------------------------------------
|
|
407
|
+
message SavedCard {
|
|
408
|
+
string id = 1;
|
|
409
|
+
string brand = 2; // "MIR" | "VISA" | "MASTERCARD" | ""
|
|
410
|
+
string last4 = 3; // "0000" etc, display-only
|
|
411
|
+
int32 exp_month = 4;
|
|
412
|
+
int32 exp_year = 5;
|
|
413
|
+
bool is_default = 6;
|
|
414
|
+
string nickname = 7; // user-set label
|
|
415
|
+
string created_at = 8;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
message ListSavedCardsRequest { string user_id = 1; }
|
|
419
|
+
message ListSavedCardsResponse { repeated SavedCard items = 1; }
|
|
420
|
+
|
|
421
|
+
message DeleteSavedCardRequest { string user_id = 1; string id = 2; }
|
|
422
|
+
|
|
423
|
+
message SetDefaultSavedCardRequest { string user_id = 1; string id = 2; }
|
|
424
|
+
|
|
425
|
+
message UpdateSavedCardRequest {
|
|
426
|
+
string user_id = 1;
|
|
427
|
+
string id = 2;
|
|
428
|
+
string nickname = 3; // empty = clear
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// ---------------------------------------------------------------------------
|
|
432
|
+
// Payout details (persistent default; per-withdrawal override still allowed)
|
|
433
|
+
// ---------------------------------------------------------------------------
|
|
434
|
+
message UpdatePayoutDetailsRequest {
|
|
435
|
+
string user_id = 1;
|
|
436
|
+
string method = 2; // "card" | "sbp" | "bank" | "" (clear)
|
|
437
|
+
string details = 3; // JSON string — payments-service treats opaquely
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
message UpdatePayoutDetailsResponse {
|
|
441
|
+
string method = 1;
|
|
442
|
+
string details = 2;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
message GetPayoutDetailsRequest { string user_id = 1; }
|