@aepstore-dev/contracts 1.32.0 → 1.33.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,303 @@
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
+ // ----- admin -----
40
+ rpc GetAdminOverview(AdminOverviewRequest) returns (AdminOverviewResponse);
41
+ rpc AdminListTransactions(AdminListTransactionsRequest) returns (AdminTransactionsListResponse);
42
+ rpc GetUserFinance(GetUserFinanceRequest) returns (UserFinanceResponse);
43
+ rpc CreateAdjustment(CreateAdjustmentRequest) returns (Ok);
44
+ rpc GetSalesAnalytics(SalesAnalyticsRequest) returns (SalesAnalyticsResponse);
45
+ }
46
+
47
+ message Ok { bool ok = 1; }
48
+
49
+ // ---------------------------------------------------------------------------
50
+ // Purchase / checkout / topup
51
+ // ---------------------------------------------------------------------------
52
+ message Purchase {
53
+ string id = 1;
54
+ string product_id = 2;
55
+ string product_name = 3;
56
+ string user_id = 4;
57
+ string price = 5;
58
+ string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
59
+ string payment_id = 7;
60
+ string payment_method = 8; // BALANCE | YOOKASSA
61
+ string commission_percent = 9;
62
+ string seller_amount = 10;
63
+ string created_at = 11;
64
+ string completed_at = 12;
65
+ }
66
+
67
+ message TopupRequest {
68
+ string user_id = 1;
69
+ string amount = 2; // >= 10.00
70
+ string return_url = 3;
71
+ }
72
+
73
+ message CreateCheckoutRequest {
74
+ string user_id = 1;
75
+ string product_id = 2;
76
+ string payment_method = 3; // BALANCE | YOOKASSA (default YOOKASSA)
77
+ string return_url = 4;
78
+ }
79
+
80
+ message CheckoutResponse {
81
+ string purchase_id = 1;
82
+ string payment_id = 2;
83
+ string confirmation_url = 3; // empty when paid from balance (instant)
84
+ string status = 4; // PENDING (redirect) | COMPLETED (balance)
85
+ }
86
+
87
+ message GetMyPurchasesRequest { string user_id = 1; int32 page = 2; int32 limit = 3; }
88
+ message PurchasesListResponse { repeated Purchase items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
89
+ message GetPurchaseRequest { string id = 1; string user_id = 2; }
90
+ message RefundPurchaseRequest { string purchase_id = 1; string actor_user_id = 2; bool is_admin = 3; string reason = 4; }
91
+
92
+ // ---------------------------------------------------------------------------
93
+ // Wallet & statement
94
+ // ---------------------------------------------------------------------------
95
+ message GetWalletRequest { string user_id = 1; }
96
+ message WalletResponse {
97
+ string spending = 1;
98
+ string pending = 2;
99
+ string payout = 3;
100
+ string spendable = 4; // spending + payout
101
+ string withdrawable = 5; // payout
102
+ string currency = 6;
103
+ int32 lifetime_sales = 7;
104
+ string current_commission_percent = 8;
105
+ }
106
+
107
+ message ListTransactionsRequest {
108
+ string user_id = 1;
109
+ string type = 2; // optional filter (TOPUP|PURCHASE|SALE_CLEAR|WITHDRAWAL|REFUND|ADJUSTMENT)
110
+ int32 page = 3;
111
+ int32 limit = 4;
112
+ }
113
+ message StatementEntry {
114
+ string id = 1; // ledger entry id
115
+ string tx_id = 2;
116
+ string type = 3; // tx type
117
+ string account_kind = 4; // which of the user's accounts
118
+ string direction = 5; // DEBIT | CREDIT
119
+ string amount = 6;
120
+ string description = 7;
121
+ string created_at = 8;
122
+ }
123
+ message TransactionsListResponse { repeated StatementEntry items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
124
+
125
+ // ---------------------------------------------------------------------------
126
+ // Withdrawals
127
+ // ---------------------------------------------------------------------------
128
+ message Withdrawal {
129
+ string id = 1;
130
+ string seller_id = 2;
131
+ string amount = 3;
132
+ string status = 4; // PENDING | PROCESSING | COMPLETED | REJECTED
133
+ string method = 5;
134
+ string details = 6;
135
+ string comment = 7;
136
+ string processed_by = 8;
137
+ string processed_at = 9;
138
+ string created_at = 10;
139
+ }
140
+ message RequestWithdrawalRequest { string seller_id = 1; string amount = 2; string method = 3; string details = 4; }
141
+ message ListWithdrawalsRequest { string seller_id = 1; string status = 2; int32 page = 3; int32 limit = 4; }
142
+ message WithdrawalsListResponse { repeated Withdrawal items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
143
+ message ProcessWithdrawalRequest { string withdrawal_id = 1; string admin_id = 2; string action = 3; string comment = 4; }
144
+
145
+ // ---------------------------------------------------------------------------
146
+ // Webhook
147
+ // ---------------------------------------------------------------------------
148
+ message PaymentEventRequest { string event = 1; string payment_id = 2; }
149
+
150
+ // ---------------------------------------------------------------------------
151
+ // Admin
152
+ // ---------------------------------------------------------------------------
153
+ message AdminOverviewRequest { string from = 1; string to = 2; }
154
+ message AdminOverviewResponse {
155
+ string revenue = 1; // platform commission earned (period)
156
+ string gmv = 2; // gross merchandise value (period)
157
+ string liabilities = 3; // Σ all users' (pending+payout+spending) — what we owe
158
+ string psp_clearing = 4; // money in transit at PSP
159
+ string payouts_payable = 5; // reserved for approved withdrawals
160
+ string refunds_total = 6;
161
+ string topups_total = 7;
162
+ string withdrawals_total = 8;
163
+ int32 sales_count = 9;
164
+ string currency = 10;
165
+ }
166
+
167
+ message AdminListTransactionsRequest {
168
+ string type = 1;
169
+ string user_id = 2;
170
+ string account_kind = 3;
171
+ string from = 4;
172
+ string to = 5;
173
+ int32 page = 6;
174
+ int32 limit = 7;
175
+ }
176
+ message AdminEntry { string account_id = 1; string account_kind = 2; string owner_id = 3; string direction = 4; string amount = 5; }
177
+ message AdminLedgerTx {
178
+ string id = 1;
179
+ string type = 2;
180
+ string status = 3;
181
+ string ref_type = 4;
182
+ string ref_id = 5;
183
+ string description = 6;
184
+ string created_by = 7;
185
+ string created_at = 8;
186
+ repeated AdminEntry entries = 9;
187
+ }
188
+ message AdminTransactionsListResponse { repeated AdminLedgerTx items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
189
+
190
+ message GetUserFinanceRequest { string user_id = 1; }
191
+ message AccountBalance { string kind = 1; string balance = 2; string currency = 3; }
192
+ message UserFinanceResponse {
193
+ WalletResponse wallet = 1;
194
+ repeated AccountBalance accounts = 2;
195
+ repeated StatementEntry recent = 3;
196
+ }
197
+
198
+ message CreateAdjustmentRequest {
199
+ string admin_id = 1;
200
+ string user_id = 2;
201
+ string account_kind = 3; // USER_SPENDING | USER_PAYOUT | USER_PENDING
202
+ string direction = 4; // CREDIT (give) | DEBIT (take)
203
+ string amount = 5;
204
+ string reason = 6;
205
+ }
206
+
207
+ message SalesAnalyticsRequest { string from = 1; string to = 2; string granularity = 3; } // day|week|month
208
+ message SalesPoint { string date = 1; int32 sales_count = 2; string gmv = 3; string revenue = 4; }
209
+ message SellerStat { string seller_id = 1; string username = 2; int32 sales = 3; string gmv = 4; }
210
+ message SalesAnalyticsResponse {
211
+ repeated SalesPoint points = 1;
212
+ repeated SellerStat top_sellers = 2;
213
+ string refund_rate = 3; // % refunded purchases
214
+ }
215
+
216
+ // ---------------------------------------------------------------------------
217
+ // Premium
218
+ // ---------------------------------------------------------------------------
219
+ message GetPremiumPlansRequest {}
220
+
221
+ // One plan per (period). Prices are computed server-side from BASE_PRICE × months
222
+ // × (1 − discount); kept here as canonical strings so the gateway has no math.
223
+ message PremiumPlan {
224
+ string period = 1; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
225
+ int32 months = 2;
226
+ string price = 3; // total to charge, Decimal-as-string
227
+ string monthly_price = 4; // for UI "≈ X ₽/month"
228
+ string discount_percent = 5;
229
+ string currency = 6;
230
+ }
231
+
232
+ message PremiumPlansResponse {
233
+ repeated PremiumPlan plans = 1;
234
+ string base_monthly_price = 2;
235
+ }
236
+
237
+ message PurchasePremiumRequest {
238
+ string user_id = 1;
239
+ string period = 2; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
240
+ string payment_method = 3; // BALANCE | YOOKASSA
241
+ string return_url = 4; // YooKassa only
242
+ // Save the YooKassa payment_method for future auto-renewals. Ignored for
243
+ // BALANCE. Default true — the UI surfaces a checkbox.
244
+ bool save_payment_method = 5;
245
+ }
246
+
247
+ message PurchasePremiumResponse {
248
+ string payment_id = 1; // PremiumPayment.id
249
+ string confirmation_url = 2; // empty for BALANCE (instant) or YooKassa-issued
250
+ string status = 3; // PENDING (redirect) | COMPLETED (balance)
251
+ }
252
+
253
+ message RunPremiumRenewalsRequest {
254
+ int32 max_batch = 1; // safety cap; default 100
255
+ }
256
+
257
+ message RunPremiumRenewalsResponse {
258
+ int32 attempted = 1;
259
+ int32 succeeded = 2;
260
+ int32 failed = 3;
261
+ }
262
+
263
+ message PremiumPaymentRow {
264
+ string id = 1;
265
+ string user_id = 2;
266
+ string amount = 3;
267
+ string period = 4; // MONTH_1 | MONTH_3 | MONTH_6 | MONTH_12
268
+ string method = 5; // BALANCE | YOOKASSA
269
+ string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
270
+ bool is_renewal = 7;
271
+ string created_at = 8;
272
+ string completed_at = 9;
273
+ string refunded_at = 10;
274
+ string refunded_amount = 11;
275
+ // Convenience: true if this payment is currently inside the 7-day refund
276
+ // window AND status == COMPLETED AND not already refunded.
277
+ bool refundable = 12;
278
+ }
279
+
280
+ message RefundPremiumRequest {
281
+ string user_id = 1;
282
+ string payment_id = 2;
283
+ string reason = 3; // optional
284
+ }
285
+
286
+ message RefundPremiumResponse {
287
+ PremiumPaymentRow payment = 1;
288
+ string new_expires_at = 2; // ISO 8601 after rollback
289
+ bool subscription_revoked = 3; // true when rollback put expiresAt <= now
290
+ }
291
+
292
+ message GetMyPremiumPaymentsRequest {
293
+ string user_id = 1;
294
+ int32 page = 2;
295
+ int32 limit = 3;
296
+ }
297
+
298
+ message PremiumPaymentsListResponse {
299
+ repeated PremiumPaymentRow items = 1;
300
+ int32 total = 2;
301
+ int32 page = 3;
302
+ int32 limit = 4;
303
+ }