@aepstore-dev/contracts 1.32.0 → 1.34.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/proto/mail.proto CHANGED
@@ -1,42 +1,42 @@
1
- syntax = "proto3";
2
-
3
- package mail.v1;
4
-
5
- // Legacy mail-service used @EventPattern (fire-and-forget). In the new gRPC
6
- // stack each becomes a unary RPC that returns an Ack. Callers ignore the
7
- // response if they don't care about delivery.
8
- service MailService {
9
- rpc SendReg(SendRegRequest) returns (MailAck);
10
- rpc Send2fa(Send2faRequest) returns (MailAck);
11
- rpc SendPasswordReset(SendPasswordResetRequest) returns (MailAck);
12
- rpc SendRegistrationConfirm(SendRegistrationConfirmRequest) returns (MailAck);
13
- }
14
-
15
- message MailAck {
16
- bool queued = 1;
17
- }
18
-
19
- message SendRegRequest {
20
- string user_id = 1;
21
- string email = 2;
22
- string username = 3;
23
- string full_name = 4;
24
- }
25
-
26
- message Send2faRequest {
27
- string email = 1;
28
- string code = 2;
29
- string username = 3;
30
- }
31
-
32
- message SendPasswordResetRequest {
33
- string email = 1;
34
- string code = 2;
35
- string username = 3;
36
- }
37
-
38
- message SendRegistrationConfirmRequest {
39
- string email = 1;
40
- string code = 2;
41
- string username = 3;
42
- }
1
+ syntax = "proto3";
2
+
3
+ package mail.v1;
4
+
5
+ // Legacy mail-service used @EventPattern (fire-and-forget). In the new gRPC
6
+ // stack each becomes a unary RPC that returns an Ack. Callers ignore the
7
+ // response if they don't care about delivery.
8
+ service MailService {
9
+ rpc SendReg(SendRegRequest) returns (MailAck);
10
+ rpc Send2fa(Send2faRequest) returns (MailAck);
11
+ rpc SendPasswordReset(SendPasswordResetRequest) returns (MailAck);
12
+ rpc SendRegistrationConfirm(SendRegistrationConfirmRequest) returns (MailAck);
13
+ }
14
+
15
+ message MailAck {
16
+ bool queued = 1;
17
+ }
18
+
19
+ message SendRegRequest {
20
+ string user_id = 1;
21
+ string email = 2;
22
+ string username = 3;
23
+ string full_name = 4;
24
+ }
25
+
26
+ message Send2faRequest {
27
+ string email = 1;
28
+ string code = 2;
29
+ string username = 3;
30
+ }
31
+
32
+ message SendPasswordResetRequest {
33
+ string email = 1;
34
+ string code = 2;
35
+ string username = 3;
36
+ }
37
+
38
+ message SendRegistrationConfirmRequest {
39
+ string email = 1;
40
+ string code = 2;
41
+ string username = 3;
42
+ }
@@ -1,203 +1,356 @@
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
- }
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
+ // ----- premium -----
29
+ rpc GetPremiumPlans(GetPremiumPlansRequest) returns (PremiumPlansResponse);
30
+ rpc PurchasePremium(PurchasePremiumRequest) returns (PurchasePremiumResponse);
31
+ // 7-day refund window from completedAt. Reverses ledger, calls YooKassa for
32
+ // card purchases, rolls back the subscription's expiresAt by the period.
33
+ rpc RefundPremium(RefundPremiumRequest) returns (RefundPremiumResponse);
34
+ rpc GetMyPremiumPayments(GetMyPremiumPaymentsRequest) returns (PremiumPaymentsListResponse);
35
+ // Internal — InternalServiceGuard. tasks-service cron triggers due renewals;
36
+ // payments-service iterates ACTIVE subscriptions with autoRenew+savedCard.
37
+ rpc RunPremiumRenewals(RunPremiumRenewalsRequest) returns (RunPremiumRenewalsResponse);
38
+
39
+ // ----- saved cards -----
40
+ rpc ListSavedCards(ListSavedCardsRequest) returns (ListSavedCardsResponse);
41
+ rpc DeleteSavedCard(DeleteSavedCardRequest) returns (Ok);
42
+ rpc SetDefaultSavedCard(SetDefaultSavedCardRequest) returns (SavedCard);
43
+ rpc UpdateSavedCard(UpdateSavedCardRequest) returns (SavedCard);
44
+
45
+ // ----- payout details -----
46
+ rpc UpdatePayoutDetails(UpdatePayoutDetailsRequest) returns (UpdatePayoutDetailsResponse);
47
+ rpc GetPayoutDetails(GetPayoutDetailsRequest) returns (UpdatePayoutDetailsResponse);
48
+
49
+ // ----- admin -----
50
+ rpc GetAdminOverview(AdminOverviewRequest) returns (AdminOverviewResponse);
51
+ rpc AdminListTransactions(AdminListTransactionsRequest) returns (AdminTransactionsListResponse);
52
+ rpc GetUserFinance(GetUserFinanceRequest) returns (UserFinanceResponse);
53
+ rpc CreateAdjustment(CreateAdjustmentRequest) returns (Ok);
54
+ rpc GetSalesAnalytics(SalesAnalyticsRequest) returns (SalesAnalyticsResponse);
55
+ }
56
+
57
+ message Ok { bool ok = 1; }
58
+
59
+ // ---------------------------------------------------------------------------
60
+ // Purchase / checkout / topup
61
+ // ---------------------------------------------------------------------------
62
+ message Purchase {
63
+ string id = 1;
64
+ string product_id = 2;
65
+ string product_name = 3;
66
+ string user_id = 4;
67
+ string price = 5;
68
+ string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
69
+ string payment_id = 7;
70
+ string payment_method = 8; // BALANCE | YOOKASSA
71
+ string commission_percent = 9;
72
+ string seller_amount = 10;
73
+ string created_at = 11;
74
+ string completed_at = 12;
75
+ }
76
+
77
+ message TopupRequest {
78
+ string user_id = 1;
79
+ string amount = 2; // >= 10.00
80
+ string return_url = 3;
81
+ }
82
+
83
+ message CreateCheckoutRequest {
84
+ string user_id = 1;
85
+ string product_id = 2;
86
+ string payment_method = 3; // BALANCE | YOOKASSA (default YOOKASSA)
87
+ string return_url = 4;
88
+ }
89
+
90
+ message CheckoutResponse {
91
+ string purchase_id = 1;
92
+ string payment_id = 2;
93
+ string confirmation_url = 3; // empty when paid from balance (instant)
94
+ string status = 4; // PENDING (redirect) | COMPLETED (balance)
95
+ }
96
+
97
+ message GetMyPurchasesRequest { string user_id = 1; int32 page = 2; int32 limit = 3; }
98
+ message PurchasesListResponse { repeated Purchase items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
99
+ message GetPurchaseRequest { string id = 1; string user_id = 2; }
100
+ message RefundPurchaseRequest { string purchase_id = 1; string actor_user_id = 2; bool is_admin = 3; string reason = 4; }
101
+
102
+ // ---------------------------------------------------------------------------
103
+ // Wallet & statement
104
+ // ---------------------------------------------------------------------------
105
+ message GetWalletRequest { string user_id = 1; }
106
+ message WalletResponse {
107
+ string spending = 1;
108
+ string pending = 2;
109
+ string payout = 3;
110
+ string spendable = 4; // spending + payout
111
+ string withdrawable = 5; // payout
112
+ string currency = 6;
113
+ int32 lifetime_sales = 7;
114
+ string current_commission_percent = 8;
115
+ }
116
+
117
+ message ListTransactionsRequest {
118
+ string user_id = 1;
119
+ string type = 2; // optional filter (TOPUP|PURCHASE|SALE_CLEAR|WITHDRAWAL|REFUND|ADJUSTMENT)
120
+ int32 page = 3;
121
+ int32 limit = 4;
122
+ }
123
+ message StatementEntry {
124
+ string id = 1; // ledger entry id
125
+ string tx_id = 2;
126
+ string type = 3; // tx type
127
+ string account_kind = 4; // which of the user's accounts
128
+ string direction = 5; // DEBIT | CREDIT
129
+ string amount = 6;
130
+ string description = 7;
131
+ string created_at = 8;
132
+ }
133
+ message TransactionsListResponse { repeated StatementEntry items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
134
+
135
+ // ---------------------------------------------------------------------------
136
+ // Withdrawals
137
+ // ---------------------------------------------------------------------------
138
+ message Withdrawal {
139
+ string id = 1;
140
+ string seller_id = 2;
141
+ string amount = 3;
142
+ string status = 4; // PENDING | PROCESSING | COMPLETED | REJECTED
143
+ string method = 5;
144
+ string details = 6;
145
+ string comment = 7;
146
+ string processed_by = 8;
147
+ string processed_at = 9;
148
+ string created_at = 10;
149
+ }
150
+ message RequestWithdrawalRequest { string seller_id = 1; string amount = 2; string method = 3; string details = 4; }
151
+ message ListWithdrawalsRequest { string seller_id = 1; string status = 2; int32 page = 3; int32 limit = 4; }
152
+ message WithdrawalsListResponse { repeated Withdrawal items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
153
+ message ProcessWithdrawalRequest { string withdrawal_id = 1; string admin_id = 2; string action = 3; string comment = 4; }
154
+
155
+ // ---------------------------------------------------------------------------
156
+ // Webhook
157
+ // ---------------------------------------------------------------------------
158
+ message PaymentEventRequest { string event = 1; string payment_id = 2; }
159
+
160
+ // ---------------------------------------------------------------------------
161
+ // Admin
162
+ // ---------------------------------------------------------------------------
163
+ message AdminOverviewRequest { string from = 1; string to = 2; }
164
+ message AdminOverviewResponse {
165
+ string revenue = 1; // platform commission earned (period)
166
+ string gmv = 2; // gross merchandise value (period)
167
+ string liabilities = 3; // Σ all users' (pending+payout+spending) — what we owe
168
+ string psp_clearing = 4; // money in transit at PSP
169
+ string payouts_payable = 5; // reserved for approved withdrawals
170
+ string refunds_total = 6;
171
+ string topups_total = 7;
172
+ string withdrawals_total = 8;
173
+ int32 sales_count = 9;
174
+ string currency = 10;
175
+ }
176
+
177
+ message AdminListTransactionsRequest {
178
+ string type = 1;
179
+ string user_id = 2;
180
+ string account_kind = 3;
181
+ string from = 4;
182
+ string to = 5;
183
+ int32 page = 6;
184
+ int32 limit = 7;
185
+ }
186
+ message AdminEntry { string account_id = 1; string account_kind = 2; string owner_id = 3; string direction = 4; string amount = 5; }
187
+ message AdminLedgerTx {
188
+ string id = 1;
189
+ string type = 2;
190
+ string status = 3;
191
+ string ref_type = 4;
192
+ string ref_id = 5;
193
+ string description = 6;
194
+ string created_by = 7;
195
+ string created_at = 8;
196
+ repeated AdminEntry entries = 9;
197
+ }
198
+ message AdminTransactionsListResponse { repeated AdminLedgerTx items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
199
+
200
+ message GetUserFinanceRequest { string user_id = 1; }
201
+ message AccountBalance { string kind = 1; string balance = 2; string currency = 3; }
202
+ message UserFinanceResponse {
203
+ WalletResponse wallet = 1;
204
+ repeated AccountBalance accounts = 2;
205
+ repeated StatementEntry recent = 3;
206
+ }
207
+
208
+ message CreateAdjustmentRequest {
209
+ string admin_id = 1;
210
+ string user_id = 2;
211
+ string account_kind = 3; // USER_SPENDING | USER_PAYOUT | USER_PENDING
212
+ string direction = 4; // CREDIT (give) | DEBIT (take)
213
+ string amount = 5;
214
+ string reason = 6;
215
+ }
216
+
217
+ message SalesAnalyticsRequest { string from = 1; string to = 2; string granularity = 3; } // day|week|month
218
+ message SalesPoint { string date = 1; int32 sales_count = 2; string gmv = 3; string revenue = 4; }
219
+ message SellerStat { string seller_id = 1; string username = 2; int32 sales = 3; string gmv = 4; }
220
+ message SalesAnalyticsResponse {
221
+ repeated SalesPoint points = 1;
222
+ repeated SellerStat top_sellers = 2;
223
+ string refund_rate = 3; // % refunded purchases
224
+ }
225
+
226
+ // ---------------------------------------------------------------------------
227
+ // Premium
228
+ // ---------------------------------------------------------------------------
229
+ message GetPremiumPlansRequest {}
230
+
231
+ // One plan per (period). Prices are computed server-side from BASE_PRICE × months
232
+ // × (1 − discount); kept here as canonical strings so the gateway has no math.
233
+ message PremiumPlan {
234
+ string period = 1; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
235
+ int32 months = 2;
236
+ string price = 3; // total to charge, Decimal-as-string
237
+ string monthly_price = 4; // for UI "≈ X ₽/month"
238
+ string discount_percent = 5;
239
+ string currency = 6;
240
+ }
241
+
242
+ message PremiumPlansResponse {
243
+ repeated PremiumPlan plans = 1;
244
+ string base_monthly_price = 2;
245
+ }
246
+
247
+ message PurchasePremiumRequest {
248
+ string user_id = 1;
249
+ string period = 2; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
250
+ string payment_method = 3; // BALANCE | YOOKASSA
251
+ string return_url = 4; // YooKassa only
252
+ // Save the YooKassa payment_method for future auto-renewals. Ignored for
253
+ // BALANCE. Default true — the UI surfaces a checkbox.
254
+ bool save_payment_method = 5;
255
+ }
256
+
257
+ message PurchasePremiumResponse {
258
+ string payment_id = 1; // PremiumPayment.id
259
+ string confirmation_url = 2; // empty for BALANCE (instant) or YooKassa-issued
260
+ string status = 3; // PENDING (redirect) | COMPLETED (balance)
261
+ }
262
+
263
+ message RunPremiumRenewalsRequest {
264
+ int32 max_batch = 1; // safety cap; default 100
265
+ }
266
+
267
+ message RunPremiumRenewalsResponse {
268
+ int32 attempted = 1;
269
+ int32 succeeded = 2;
270
+ int32 failed = 3;
271
+ }
272
+
273
+ message PremiumPaymentRow {
274
+ string id = 1;
275
+ string user_id = 2;
276
+ string amount = 3;
277
+ string period = 4; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
278
+ string method = 5; // BALANCE | YOOKASSA
279
+ string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
280
+ bool is_renewal = 7;
281
+ string created_at = 8;
282
+ string completed_at = 9;
283
+ string refunded_at = 10;
284
+ string refunded_amount = 11;
285
+ // Convenience: true if this payment is currently inside the 7-day refund
286
+ // window AND status == COMPLETED AND not already refunded.
287
+ bool refundable = 12;
288
+ }
289
+
290
+ message RefundPremiumRequest {
291
+ string user_id = 1;
292
+ string payment_id = 2;
293
+ string reason = 3; // optional
294
+ }
295
+
296
+ message RefundPremiumResponse {
297
+ PremiumPaymentRow payment = 1;
298
+ string new_expires_at = 2; // ISO 8601 after rollback
299
+ bool subscription_revoked = 3; // true when rollback put expiresAt <= now
300
+ }
301
+
302
+ message GetMyPremiumPaymentsRequest {
303
+ string user_id = 1;
304
+ int32 page = 2;
305
+ int32 limit = 3;
306
+ }
307
+
308
+ message PremiumPaymentsListResponse {
309
+ repeated PremiumPaymentRow items = 1;
310
+ int32 total = 2;
311
+ int32 page = 3;
312
+ int32 limit = 4;
313
+ }
314
+
315
+ // ---------------------------------------------------------------------------
316
+ // Saved cards (YooKassa payment_method tokens; we never see PAN)
317
+ // ---------------------------------------------------------------------------
318
+ message SavedCard {
319
+ string id = 1;
320
+ string brand = 2; // "MIR" | "VISA" | "MASTERCARD" | ""
321
+ string last4 = 3; // "0000" etc, display-only
322
+ int32 exp_month = 4;
323
+ int32 exp_year = 5;
324
+ bool is_default = 6;
325
+ string nickname = 7; // user-set label
326
+ string created_at = 8;
327
+ }
328
+
329
+ message ListSavedCardsRequest { string user_id = 1; }
330
+ message ListSavedCardsResponse { repeated SavedCard items = 1; }
331
+
332
+ message DeleteSavedCardRequest { string user_id = 1; string id = 2; }
333
+
334
+ message SetDefaultSavedCardRequest { string user_id = 1; string id = 2; }
335
+
336
+ message UpdateSavedCardRequest {
337
+ string user_id = 1;
338
+ string id = 2;
339
+ string nickname = 3; // empty = clear
340
+ }
341
+
342
+ // ---------------------------------------------------------------------------
343
+ // Payout details (persistent default; per-withdrawal override still allowed)
344
+ // ---------------------------------------------------------------------------
345
+ message UpdatePayoutDetailsRequest {
346
+ string user_id = 1;
347
+ string method = 2; // "card" | "sbp" | "bank" | "" (clear)
348
+ string details = 3; // JSON string — payments-service treats opaquely
349
+ }
350
+
351
+ message UpdatePayoutDetailsResponse {
352
+ string method = 1;
353
+ string details = 2;
354
+ }
355
+
356
+ message GetPayoutDetailsRequest { string user_id = 1; }