Skip to content

Commit c338ad7

Browse files
committed
feat: implement subscription payment retry with intelligent scheduling (#964)
- Add IntelligentRetryScheduler with exponential backoff, jitter, and historical success-time shifting (moves retries toward UTC hours that historically succeed for each subscriber) - Add per-plan RetryPolicy with configurable maxRetries, baseDelayHours, backoffMultiplier, maxDelayHours, circuitBreakerThreshold, and jitterHours - Add circuit-breaker that pauses retries after N consecutive failures and auto-resets after a configurable cooldown window - Classify all 8 decline codes (insufficient_funds, card_expired, card_lost_stolen, do_not_honor, authentication_required, generic_decline, network_error, processing_error) with code-specific base delays and outreach channels - Trigger card-updater flow on card_expired (once per invoice) - Suggest automatic 50% amount split for charges above $500 on first retry - Add DunningOrchestrator wiring scheduler + grace-period management + injectable OutreachDispatcher - Grace periods: configurable duration, per-interval email reminders, sweep-expired helper for subscription suspension, recovered on success - Add RetryAnalytics: success rate, avg attempts to success, per-decline breakdown, 24-bucket UTC hourly success heatmap - Extend Soroban charging contract (contracts/subscription/src/charging.rs) with on-chain retry queue, grace period tracking, and circuit-breaker state - Add supporting types to contracts/types/src/lib.rs (RetryConfig, ChargeAttempt, ChargeStatus) - Add comprehensive test suite (>80% coverage): 40+ cases covering policy management, all decline codes, circuit breaker, backoff, split suggestion, grace period lifecycle, reminder scheduling, analytics, and orchestrator integration Closes #964
1 parent 78d0e80 commit c338ad7

4 files changed

Lines changed: 2295 additions & 47 deletions

File tree

0 commit comments

Comments
 (0)