-
Notifications
You must be signed in to change notification settings - Fork 7
Labels
Description
Problem
Batch payments only collect protocol fee, NOT platform fee. Platform is losing revenue on every batch transaction.
Affects both:
- Batch payouts (creates new requests via
requestsarray) - fee fields placed insiderequests[]instead of body level - Batch invoice payments (pays existing requests via
requestIdsarray) - fee fields not sent at all
Both use the same batchPay function calling POST v2/payouts/batch.
Root cause: batchPay endpoint doesn't place feePercentage and feeAddress at body level where the API expects them.
Proposed Solution
Move fee fields to body level (fixes both batch payouts and batch invoice payments):
// CURRENT (broken) - src/server/routers/payment.ts lines 60-74
const response = await apiClient.post("v2/payouts/batch", {
requests: input.payouts?.map((payout) => ({
...
feePercentage: process.env.FEE_PERCENTAGE_FOR_PAYMENT, // ❌ Wrong location
feeAddress: process.env.FEE_ADDRESS_FOR_PAYMENT, // ❌ Wrong location
})),
requestIds: input.requestIds, // ❌ No fee fields for this path
payer: input.payer,
});
// FIXED
const response = await apiClient.post("v2/payouts/batch", {
requests: input.payouts?.map((payout) => ({ ... })), // No fee fields here
requestIds: input.requestIds,
payer: input.payer,
...(process.env.FEE_PERCENTAGE_FOR_PAYMENT && process.env.FEE_ADDRESS_FOR_PAYMENT && {
feePercentage: process.env.FEE_PERCENTAGE_FOR_PAYMENT, // ✅ Body level
feeAddress: process.env.FEE_ADDRESS_FOR_PAYMENT, // ✅ Body level
}),
});Considerations
- Severity: CRITICAL - Revenue loss bug
- Affected file:
src/server/routers/payment.ts(lines 60-74) - Single payout (
pay) is correct, onlybatchPayis broken - API schema reference:
request-api/src/validation/schemas/pay.schema.ts(lines 343-414)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
🆕 New