PhoenixKitBilling. Workers. SubscriptionDunningWorker
(PhoenixKitBilling v0.2.0)
Copy Markdown
View Source
Oban worker for dunning (failed payment recovery).
When a subscription payment fails, the subscription enters past_due status
and this worker handles retry attempts during the grace period.
Dunning Process
- Initial payment fails → subscription status =
past_due - Grace period starts (configurable, default 3 days)
- This worker retries payment at intervals
- If payment succeeds → status =
active - If max attempts reached or grace period ends → status =
cancelled
Retry Schedule
Default retry schedule (can be configured):
- Attempt 1: Immediate (handled by RenewalWorker)
- Attempt 2: 24 hours later
- Attempt 3: 48 hours later (2 days)
- Attempt 4: 72 hours later (3 days, grace period ends)
Configuration
# Settings (stored in database)
billing_subscription_grace_days: 3
billing_dunning_max_attempts: 3Manual Trigger
%{subscription_uuid: "019145a1-0000-7000-8000-000000000001"}
|> SubscriptionDunningWorker.new()
|> Oban.insert()