@aepstore-dev/contracts 1.18.1 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,203 +1,203 @@
1
- syntax = "proto3";
2
-
3
- package payments.v1;
4
-
5
- // Commerce + double-entry wallet/ledger (D9 / D9.2). See payments-service/docs/FINANCE.md.
6
- // Money = Decimal-as-string (D7). Statuses/enums as strings (avoid proto enum
7
- // value-name clashes within one package).
8
- service PaymentsService {
9
- // ----- buyer -----
10
- rpc Topup(TopupRequest) returns (CheckoutResponse);
11
- rpc CreateCheckout(CreateCheckoutRequest) returns (CheckoutResponse);
12
- rpc GetMyPurchases(GetMyPurchasesRequest) returns (PurchasesListResponse);
13
- rpc GetPurchase(GetPurchaseRequest) returns (Purchase);
14
- rpc RefundPurchase(RefundPurchaseRequest) returns (Purchase);
15
-
16
- // ----- wallet -----
17
- rpc GetWallet(GetWalletRequest) returns (WalletResponse);
18
- rpc ListTransactions(ListTransactionsRequest) returns (TransactionsListResponse);
19
-
20
- // ----- withdrawals -----
21
- rpc RequestWithdrawal(RequestWithdrawalRequest) returns (Withdrawal);
22
- rpc ListWithdrawals(ListWithdrawalsRequest) returns (WithdrawalsListResponse);
23
- rpc ProcessWithdrawal(ProcessWithdrawalRequest) returns (Withdrawal);
24
-
25
- // ----- provider webhook (gateway forwards a verified event) -----
26
- rpc HandlePaymentEvent(PaymentEventRequest) returns (Ok);
27
-
28
- // ----- admin -----
29
- rpc GetAdminOverview(AdminOverviewRequest) returns (AdminOverviewResponse);
30
- rpc AdminListTransactions(AdminListTransactionsRequest) returns (AdminTransactionsListResponse);
31
- rpc GetUserFinance(GetUserFinanceRequest) returns (UserFinanceResponse);
32
- rpc CreateAdjustment(CreateAdjustmentRequest) returns (Ok);
33
- rpc GetSalesAnalytics(SalesAnalyticsRequest) returns (SalesAnalyticsResponse);
34
- }
35
-
36
- message Ok { bool ok = 1; }
37
-
38
- // ---------------------------------------------------------------------------
39
- // Purchase / checkout / topup
40
- // ---------------------------------------------------------------------------
41
- message Purchase {
42
- string id = 1;
43
- string product_id = 2;
44
- string product_name = 3;
45
- string user_id = 4;
46
- string price = 5;
47
- string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
48
- string payment_id = 7;
49
- string payment_method = 8; // BALANCE | YOOKASSA
50
- string commission_percent = 9;
51
- string seller_amount = 10;
52
- string created_at = 11;
53
- string completed_at = 12;
54
- }
55
-
56
- message TopupRequest {
57
- string user_id = 1;
58
- string amount = 2; // >= 10.00
59
- string return_url = 3;
60
- }
61
-
62
- message CreateCheckoutRequest {
63
- string user_id = 1;
64
- string product_id = 2;
65
- string payment_method = 3; // BALANCE | YOOKASSA (default YOOKASSA)
66
- string return_url = 4;
67
- }
68
-
69
- message CheckoutResponse {
70
- string purchase_id = 1;
71
- string payment_id = 2;
72
- string confirmation_url = 3; // empty when paid from balance (instant)
73
- string status = 4; // PENDING (redirect) | COMPLETED (balance)
74
- }
75
-
76
- message GetMyPurchasesRequest { string user_id = 1; int32 page = 2; int32 limit = 3; }
77
- message PurchasesListResponse { repeated Purchase items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
78
- message GetPurchaseRequest { string id = 1; string user_id = 2; }
79
- message RefundPurchaseRequest { string purchase_id = 1; string actor_user_id = 2; bool is_admin = 3; string reason = 4; }
80
-
81
- // ---------------------------------------------------------------------------
82
- // Wallet & statement
83
- // ---------------------------------------------------------------------------
84
- message GetWalletRequest { string user_id = 1; }
85
- message WalletResponse {
86
- string spending = 1;
87
- string pending = 2;
88
- string payout = 3;
89
- string spendable = 4; // spending + payout
90
- string withdrawable = 5; // payout
91
- string currency = 6;
92
- int32 lifetime_sales = 7;
93
- string current_commission_percent = 8;
94
- }
95
-
96
- message ListTransactionsRequest {
97
- string user_id = 1;
98
- string type = 2; // optional filter (TOPUP|PURCHASE|SALE_CLEAR|WITHDRAWAL|REFUND|ADJUSTMENT)
99
- int32 page = 3;
100
- int32 limit = 4;
101
- }
102
- message StatementEntry {
103
- string id = 1; // ledger entry id
104
- string tx_id = 2;
105
- string type = 3; // tx type
106
- string account_kind = 4; // which of the user's accounts
107
- string direction = 5; // DEBIT | CREDIT
108
- string amount = 6;
109
- string description = 7;
110
- string created_at = 8;
111
- }
112
- message TransactionsListResponse { repeated StatementEntry items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
113
-
114
- // ---------------------------------------------------------------------------
115
- // Withdrawals
116
- // ---------------------------------------------------------------------------
117
- message Withdrawal {
118
- string id = 1;
119
- string seller_id = 2;
120
- string amount = 3;
121
- string status = 4; // PENDING | PROCESSING | COMPLETED | REJECTED
122
- string method = 5;
123
- string details = 6;
124
- string comment = 7;
125
- string processed_by = 8;
126
- string processed_at = 9;
127
- string created_at = 10;
128
- }
129
- message RequestWithdrawalRequest { string seller_id = 1; string amount = 2; string method = 3; string details = 4; }
130
- message ListWithdrawalsRequest { string seller_id = 1; string status = 2; int32 page = 3; int32 limit = 4; }
131
- message WithdrawalsListResponse { repeated Withdrawal items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
132
- message ProcessWithdrawalRequest { string withdrawal_id = 1; string admin_id = 2; string action = 3; string comment = 4; }
133
-
134
- // ---------------------------------------------------------------------------
135
- // Webhook
136
- // ---------------------------------------------------------------------------
137
- message PaymentEventRequest { string event = 1; string payment_id = 2; }
138
-
139
- // ---------------------------------------------------------------------------
140
- // Admin
141
- // ---------------------------------------------------------------------------
142
- message AdminOverviewRequest { string from = 1; string to = 2; }
143
- message AdminOverviewResponse {
144
- string revenue = 1; // platform commission earned (period)
145
- string gmv = 2; // gross merchandise value (period)
146
- string liabilities = 3; // Σ all users' (pending+payout+spending) — what we owe
147
- string psp_clearing = 4; // money in transit at PSP
148
- string payouts_payable = 5; // reserved for approved withdrawals
149
- string refunds_total = 6;
150
- string topups_total = 7;
151
- string withdrawals_total = 8;
152
- int32 sales_count = 9;
153
- string currency = 10;
154
- }
155
-
156
- message AdminListTransactionsRequest {
157
- string type = 1;
158
- string user_id = 2;
159
- string account_kind = 3;
160
- string from = 4;
161
- string to = 5;
162
- int32 page = 6;
163
- int32 limit = 7;
164
- }
165
- message AdminEntry { string account_id = 1; string account_kind = 2; string owner_id = 3; string direction = 4; string amount = 5; }
166
- message AdminLedgerTx {
167
- string id = 1;
168
- string type = 2;
169
- string status = 3;
170
- string ref_type = 4;
171
- string ref_id = 5;
172
- string description = 6;
173
- string created_by = 7;
174
- string created_at = 8;
175
- repeated AdminEntry entries = 9;
176
- }
177
- message AdminTransactionsListResponse { repeated AdminLedgerTx items = 1; int32 total = 2; int32 page = 3; int32 limit = 4; }
178
-
179
- message GetUserFinanceRequest { string user_id = 1; }
180
- message AccountBalance { string kind = 1; string balance = 2; string currency = 3; }
181
- message UserFinanceResponse {
182
- WalletResponse wallet = 1;
183
- repeated AccountBalance accounts = 2;
184
- repeated StatementEntry recent = 3;
185
- }
186
-
187
- message CreateAdjustmentRequest {
188
- string admin_id = 1;
189
- string user_id = 2;
190
- string account_kind = 3; // USER_SPENDING | USER_PAYOUT | USER_PENDING
191
- string direction = 4; // CREDIT (give) | DEBIT (take)
192
- string amount = 5;
193
- string reason = 6;
194
- }
195
-
196
- message SalesAnalyticsRequest { string from = 1; string to = 2; string granularity = 3; } // day|week|month
197
- message SalesPoint { string date = 1; int32 sales_count = 2; string gmv = 3; string revenue = 4; }
198
- message SellerStat { string seller_id = 1; string username = 2; int32 sales = 3; string gmv = 4; }
199
- message SalesAnalyticsResponse {
200
- repeated SalesPoint points = 1;
201
- repeated SellerStat top_sellers = 2;
202
- string refund_rate = 3; // % refunded purchases
203
- }
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
+ }