Skip to content

API: BullMQ - Payout scheduling and recurring jobs - #170

Merged
0xdevcollins merged 13 commits into
0xdevcollins:mainfrom
enochakinbode:feat/bullMQ-schedule-payments
Jul 31, 2026
Merged

API: BullMQ - Payout scheduling and recurring jobs#170
0xdevcollins merged 13 commits into
0xdevcollins:mainfrom
enochakinbode:feat/bullMQ-schedule-payments

Conversation

@enochakinbode

Copy link
Copy Markdown
Contributor

Summary

  • implement BullMQ-backed scheduled payout execution and startup reconciliation
  • add recurring payout configuration, repeatable jobs, and due-recurring dispatcher
  • add balance checks, ledger debits/releases, high-value confirmation, and payout-ready seed data
  • add focused payout scheduling/job tests

Tests

  • npm run lint
  • npm run build
  • npm test -- --runInBand --silent

Closes #73

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

@enochakinbode is attempting to deploy a commit to the Threadflow Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@enochakinbode Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@enochakinbode enochakinbode changed the title API: Payout scheduling and recurring jobs API: BullMQ - Payout scheduling and recurring jobs Jul 28, 2026
@enochakinbode

Copy link
Copy Markdown
Contributor Author

@0xdevcollins kindly review

- Guard recurring runs with an atomic nextRunAt claim so the repeatable
  job and the due-recurring dispatcher cannot double-generate a payout
- Remove stale BullMQ jobs before re-enqueuing so retried payouts are
  not silently deduped against completed jobs from earlier attempts
- Key MerchantBalance by (merchantId, currency) so credits in different
  currencies are never summed into one amount
- Enforce at-most-once payment credits with a unique (paymentId, type)
  ledger constraint and a single transactional credit path shared by
  both Stripe webhook handlers
- Add completeExternalPayout/failExternalPayout so external settlement
  outcomes release debited funds instead of leaking them
- Derive the Stellar source asset from the payout currency instead of
  always sending XLM; fail unsupported currencies and missing paths
- Cap payout confirmation attempts at 5, then fail the payout
- Remove cancelled payouts' queued jobs; warn on relay-key fallback and
  invalid PAYOUT_2FA_THRESHOLD; handle destinationType-only updates
@0xdevcollins
0xdevcollins merged commit ed528a3 into 0xdevcollins:main Jul 31, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API: Payout Scheduling & Recurring Jobs (BullMQ)

2 participants