TidyLinker.com
TypeScript
Pull Request Opened
PR #56 opened: Fix ProcessWeeklyPayouts Stripe integration with proper error handling
Summary
- Rewrites
ProcessWeeklyPayoutsjob to properly use theCreatePayoutaction instead of creating local Payout records directly - Adds Stripe best practices:
source_transactionandtransfer_groupfor proper transfer tracking - Implements robust error handling following existing patterns (
RetryPaymentCapture) - Adds admin alerting for payout failures
Changes
ProcessWeeklyPayouts Job
- Uses
CreatePayoutaction for actual Stripe transfers - Catches only
PayoutException(Stripe errors) - unexpected errors bubble up for retry - Adds
$tries = 3,$backoff, andfailed()method - Sends
PayoutBatchFailureAlertemail on partial or complete failure - Logs with full context from
PayoutException::context()
CreatePayout Action
- Adds
source_transactionto tie transfer to original charge (avoids insufficient balance errors) - Adds
transfer_groupfor tracking related transactions
New Files
app/Mail/Admin/PayoutBatchFailureAlert.php- Admin alert mailableresources/views/mail/admin/payout-batch-failure-alert.blade.php- Email templatetests/Feature/Jobs/ProcessWeeklyPayoutsTest.php- 10 test cases
Test plan
- All 10 ProcessWeeklyPayouts tests pass
- Tests cover: happy path, skip conditions, PayoutException handling, unexpected exception bubbling, admin alerts, empty batch
- Manual: Verify weekly schedule runs (Mondays 6am)
- Manual: Verify admin receives email on failure
+592
additions
-31
deletions
5
files changed