feat: payout API — single, bulk, cancel, retry (#72)#129
Merged
0xdevcollins merged 1 commit intomainfrom Apr 5, 2026
Merged
Conversation
…ints - Add idempotencyKey field to Payout model with unique constraint - Add missing DB indexes on merchantId, status, batchId, createdAt - DTOs: Zod schemas for create-payout (BANK_ACCOUNT, MOBILE_MONEY, CRYPTO_WALLET, STELLAR destinations), bulk-payout (up to 10,000), and payout-filters (status, type, currency, date range, pagination) - Service: idempotency deduplication, async fire-and-forget processing, Stellar path payment execution for STELLAR/CRYPTO_WALLET destinations, row-level error capture for bulk payouts - Controller: POST /v1/payouts, POST /v1/payouts/bulk, GET /v1/payouts, GET /v1/payouts/:id, POST /v1/payouts/:id/cancel, POST /v1/payouts/:id/retry - Webhook events: payout.initiated, payout.completed, payout.failed - Wire StellarModule and WebhooksModule into PayoutsModule Closes #72 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
idempotencyKey String? @uniquetoPayoutmodel plus DB indexes onmerchantId,status,batchId,createdAtPOST /v1/payouts: create single payout with optionalIdempotency-Keyheader; validates destination shape per type (BANK_ACCOUNT,MOBILE_MONEY,CRYPTO_WALLET,STELLAR)POST /v1/payouts/bulk: up to 10,000 recipients in one request; row-level validation — each row independently succeeds or fails; returns per-indexpayoutIdorerrorGET /v1/payouts: paginated list filterable bystatus,destinationType,currency,dateFrom,dateTo,batchIdGET /v1/payouts/:id: payout detailPOST /v1/payouts/:id/cancel: cancelsPENDINGpayouts onlyPOST /v1/payouts/:id/retry: resetsFAILEDpayouts toPENDINGand re-processesSTELLAR/CRYPTO_WALLET(network=stellar)destinations execute viaStellarService.executePathPaymentwith auto path-finding and 1% slippage tolerance;BANK_ACCOUNTandMOBILE_MONEYremainPROCESSINGfor external disbursement systempayout.initiated,payout.completed,payout.faileddispatched via existingWebhooksServiceTest plan
POST /v1/payoutswithSTELLARdestination → payout created, Stellar tx executed, status →COMPLETEDPOST /v1/payoutswith duplicateIdempotency-Key→ returns same payout (no duplicate)POST /v1/payouts/bulkwith 3 valid + 1 invalid row → 3 accepted, 1 rejected with per-index errorPOST /v1/payouts/bulkwith 10,001 rows → 400 validation errorGET /v1/payouts?status=PENDING→ filtered resultsPOST /v1/payouts/:id/cancelon PENDING → status CANCELLEDPOST /v1/payouts/:id/cancelon PROCESSING → 400 errorPOST /v1/payouts/:id/retryon FAILED → status resets to PENDING, processing re-triggeredpayout.initiated,payout.completed,payout.failedCloses #72
🤖 Generated with Claude Code