whisper-money/app/Console/Commands
Víctor Falcón f9bf0ea5ff
feat(discord): enrich Stripe event messages and dedupe deliveries (#460)
## Why

The Stripe subscription events posted to the Discord admin feed weren't
useful (only status + raw `cus_123` id) and sometimes arrived duplicated
— including two cancellation messages for the same subscription.

## What changed

**Richer messages** (`PostStripeEventToDiscord`)
- Customer name + email (resolved via the Stripe API), plan + interval
(`€19.99 / month`), status, subscription id.
- A `Changed` field built from Stripe's `previous_attributes` diff (e.g.
`Status: trialing → active`).
- Cancellation reason, trial-end and period-end dates where relevant.
- Invoices now show invoice number + subscription id.

**Deduplication (two causes fixed)**
- *Webhook/queue retries*: guard on the Stripe event id via
`Cache::add(..., 24h)` — first delivery wins, retries skipped.
- *Double cancellation*: Stripe fires `subscription.updated` (cancel
scheduled) **then** `subscription.deleted`. We now label the scheduled
one `🗓️ Cancellation scheduled` distinctly from `👋 Subscription
cancelled`, and only post `subscription.updated` when something
meaningful changed (status, plan, or cancellation), dropping trivial
churn.

**New** `StripeCustomerResolver` service — resolves `Name (email)` from
a customer id, falls back to the id on any error. Injectable so it's
stubbed in tests (no network).

## Tests

9 cases covering rich fields, dedup, scheduled-vs-deleted cancellation,
status-change diff, trivial-update skip, deletion reason, and invoice
amounts. All passing.

Note: this adds one Stripe API call per subscription/invoice event, made
inside the queued listener (no webhook latency).
2026-05-31 12:50:37 +02:00
..
Concerns refactor(real-estate): remove Pennant gating (#308) 2026-04-20 13:31:49 +01:00
ApplyRealEstateRevaluationCommand.php fix(real-estate): compound annual revaluation monthly (#337) 2026-04-27 07:35:51 +01:00
BackfillAccountIbans.php fix(banking): correct backfill-ibans endpoint and handle expired sessions gracefully (#222) 2026-03-12 11:57:54 +00:00
BackfillUserCurrencyCode.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
CancelFreeEnableBankingConnectionsCommand.php Support soft-deleted users with reusable emails (#316) 2026-04-22 11:41:41 +01:00
CheckBankLogosCommand.php Add weekly bank logo audit command (#211) 2026-03-06 11:05:13 +00:00
DeleteUserCommand.php Support soft-deleted users with reusable emails (#316) 2026-04-22 11:41:41 +01:00
EnsureLaunchCouponsCommand.php feat(leads): cohort-based launch invitations with per-user Stripe coupons (#333) 2026-04-30 15:10:28 +01:00
FeatureDisableCommand.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
FeatureEnableCommand.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
GenerateBudgetPeriods.php fix: Budget period not found on last day of period (#91) 2026-02-01 11:33:10 +01:00
GenerateLandingAuthLinkCommand.php feat(landing): add signed auth links (#312) 2026-04-21 08:28:59 +01:00
GenerateMonthlyLoanBalances.php feat(accounts): add loan amortization projections for loan accounts (#246) 2026-03-26 15:06:09 +01:00
GenerateStripePromotionCodesCommand.php feat(stripe): add promo code generator (#311) 2026-04-20 18:15:28 +01:00
ResendLeadVerificationEmailsCommand.php feat: resend verification emails to unverified leads (#287) 2026-04-15 09:13:27 +01:00
ResendSyncCommand.php feat: Sync new users to Resend contacts (#85) 2026-01-28 21:25:58 +01:00
ResendSyncLeadsCommand.php perf(resend): default sync-leads to last 24h window (#354) 2026-05-05 09:57:25 +01:00
ResetDemoAccountCommand.php fix(budgets): remove Custom period type to fix duplicate-key crash (#355) 2026-05-05 16:07:16 +02:00
ResetUserCategories.php Refactor: Optimize category management in CreateDefaultCategories and ResetUserCategories 2025-12-01 15:37:53 +01:00
RetryLeadFailedJobsCommand.php feat: selective retry of failed lead email jobs (#286) 2026-04-15 08:00:29 +01:00
SendDailyStatsReportCommand.php feat(discord): enrich Stripe event messages and dedupe deliveries (#460) 2026-05-31 12:50:37 +02:00
SendSubscriptionCancelledEmailCommand.php Add subscription cancellation email with manual trigger command (#47) 2025-12-30 20:32:44 +01:00
SendTestEmails.php chore(commands): unify command signatures 2025-12-30 07:22:18 +01:00
SendUpdateEmailCommand.php fix: delay emails to avoid reaching daily resend limit 2026-01-09 11:11:38 +01:00
SendUserLeadInvitations.php fix: keep lead invite command aliases (#406) 2026-05-20 12:26:21 +02:00
SendUserLeadReInvitations.php feat(leads): add user lead re-invite campaign (#432) 2026-05-26 08:35:31 +02:00
SetBankLogoCommand.php fix(banks:set-logo): add JPEG support test coverage and prompt for missing arguments (#214) 2026-03-07 16:33:54 +00:00
SetupMainUser.php fix(static-analysis): clear phpstan-baseline by fixing all suppressed errors (#183) 2026-03-02 12:22:30 +00:00
StripeSubscriptionStatsCommand.php feat: add Discord admin feed for daily stats and Stripe events (#458) 2026-05-30 18:14:46 +02:00
SyncBankingConnections.php Notify users about expired bank connections (#404) 2026-05-20 09:20:13 +02:00
SyncStripePricesCommand.php chore: upgrade Laravel 12 to 13 (#242) 2026-03-25 12:56:33 +00:00
TestScheduledDripEmailCommand.php Test mail drip command 2025-12-30 07:22:18 +01:00