Feat/organizer functions - #109
Merged
Merged
Conversation
Bull queue that withdraws an organizer's escrowed USDC from the Diamond via withdrawTicketBalance, signed by the organizer's Circle wallet (they are the ticket admin) and paid to that same wallet. Escrow only accrues for refundable crypto events; non-refundable crypto pays instantly at mint and fiat splits to the organizer's bank at purchase, so neither touches this queue. Engine + producer only — the trigger (organizer request endpoint / cron) and the Payout-record lifecycle land in #46. - PayoutQueueService: producer, one job per ticket type (the on-chain unit), eager BlockchainTransaction (WITHDRAW) audit row - PayoutProcessor: zero-balance no-op preflight, organizer-signed withdraw, terminal-vs-retryable revert classification (InsufficientWithdrawBalance/etc → UnrecoverableError, WithdrawPeriodNotReached → retry), webhook-or-poll completion - PayoutFinalizerService: parses TicketBalanceWithdrawn, audit-logs tx hash + destination + amount - circle-webhook.processor: route confirmed WITHDRAW txs to finalizer Tests: payout.processor (7); suite green (140).
Crypto-only payout flow that gives the #37 withdraw engine its trigger. - POST /organizer/payouts/request: validates ownership, event status, on-chain refund window (getRefundPeriod), duplicate guard, and escrow > 0; creates a Payout (USDC/CRYPTO, amount = summed on-chain escrow), fans out enqueuePayout per ticket type holding a balance, flips to PROCESSING - GET /organizer/payouts: status filter, pagination, all-time summary (totalPaid / pendingAmount / totalPayouts) - PayoutFinalizerService: wire the #37 seam — once an event's escrow is fully drained, close its active Payout to COMPLETED + processedAt + providerReference (compare-and-set, idempotent) Fiat revenue already settles to the organizer's bank at purchase via split subaccounts, so only escrowed refundable-crypto revenue is withdrawable here. Tests: payouts.service (7) + payout-finalizer (3); suite green (150). Closes #37 Closes #46
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.
closes #37
closes #46