Failure Prediction
Predict payment failures before they happen with card expiration monitoring, anomaly detection, and proactive customer outreach in LostChurn.
Failure prediction helps you anticipate payment failures before they happen. Instead of reacting to failed payments, LostChurn can proactively reach out to at-risk customers and optimize retry timing after a failure occurs.
Advanced prediction features including custom ML models are available on Revenue Command and Enterprise tiers.
Overview
LostChurn's prediction capabilities operate in two modes:
- Pre-failure prediction -- Identifies payments likely to fail before the charge is attempted, enabling proactive outreach
- Post-failure scoring -- Scores each retry attempt to optimize timing, channel, and routing for maximum recovery
Card Expiration Prediction
The simplest and most reliable prediction: cards that are about to expire will almost certainly fail on the next billing cycle.
How It Works
LostChurn monitors the expiration dates on stored payment methods. When a card is within a configurable window of expiration (default: 30 days), the system flags the associated subscriptions and can trigger pre-dunning campaigns.
Prediction Timeline
| Days Before Expiry | Action |
|---|---|
| 60 days | Flag subscription as at-risk (visible in dashboard) |
| 30 days | Trigger pre-dunning campaign (if configured) |
| 14 days | Send urgent card update reminder |
| 7 days | Final reminder with subscription cancellation warning |
| 0 days | Card expires; next charge will fail |
Card Update Flow
When a customer receives a pre-dunning message about an expiring card:
- They click the payment update link in the message
- The self-service portal shows their current card details (masked) and the expiration date
- They enter new card information
- LostChurn updates the payment method with the PSP
- The subscription continues uninterrupted -- no failed payment ever occurs
Merchants who enable card expiration prediction typically see a 15-25% reduction in involuntary churn from expired cards, because customers update their payment method before the charge fails.
Card Expiry Alerts
For detailed configuration of expiry-based alerts, see Card Expiry Alerts.
Payment Pattern Anomaly Detection
Beyond simple card expiration, LostChurn analyzes payment patterns to detect anomalies that predict failures. The detect_payment_anomalies reducer scans a merchant's recent payment events across two 7-day windows and inserts failure_prediction rows when patterns are detected.
Four Anomaly Patterns
LostChurn's anomaly engine (anomaly-v1 model) monitors four distinct patterns:
| Pattern | Detection Logic | Probability Range | Recommended Action |
|---|---|---|---|
| Decline rate spike | >20% increase in declines period-over-period (current vs. previous 7-day window) | 0.50 -- 1.00 (scales with spike magnitude) | pre_dunning |
| Card expiration wave | 3+ customer cards expiring in the same month | Fixed at 0.70 | card_update_reminder |
| High-value terminal failure | Terminal decline on a transaction over $500 | Fixed at 0.85 | pre_dunning |
| Repeated customer failures | 3+ failures from the same customer within 7 days | 0.60 -- 0.95 (scales with failure count) | pre_dunning |
Predictions are deduplicated -- if an unexpired prediction already exists for a customer with the same model version, a new one is not created. All predictions expire after 7 days and are garbage-collected by the clear_expired_predictions reducer.
Monitored Signals
| Signal | What It Detects | Risk Indicator |
|---|---|---|
| Consecutive soft declines | Customer's bank is intermittently declining | Escalating failure likelihood |
| Sudden plan downgrade | Customer reduced their subscription tier | Potential payment sensitivity |
| Billing amount increase | Subscription price increased (plan change, add-ons) | Higher decline risk at new amount |
| Geographic mismatch | Card issuer country differs from customer's current location | Cross-border decline risk |
| Payment method age | Card has been on file for 3+ years without update | Approaching natural expiration |
| Historical failure rate | Customer has failed payments in the past | Repeat failure pattern |
Anomaly Scoring
Each prediction receives a failure_probability score from 0.0 to 1.0 (displayed as 0--100 in the dashboard):
| Score Range | Risk Level | Recommended Action |
|---|---|---|
| 0-20 | Low | No action needed |
| 21-50 | Moderate | Monitor; consider pre-dunning if approaching billing date |
| 51-80 | High | Send proactive outreach to update payment method |
| 81-100 | Critical | Immediate outreach; consider pausing subscription |
View anomaly scores in the Subscriptions list. Sort by risk score to focus on the most vulnerable subscriptions.
Prediction Data Model
Each failure_prediction row stores:
| Field | Description |
|---|---|
failure_probability | Score from 0.0 to 1.0 |
risk_factors | JSON array of contributing factors (e.g., ["decline_rate_spike", "increase_35pct"]) |
recommended_action | Either pre_dunning or card_update_reminder |
model_version | Currently anomaly-v1 for pattern detection, rule-based-v0.1 for card expiry |
predicted_at / expires_at | Timestamp range (7-day TTL) |
Alert Configuration
To enable anomaly detection alerts:
- Navigate to Settings > Recovery > Failure Prediction
- Toggle Anomaly Detection to on
- Set the high-value threshold (default: $500) for terminal decline monitoring
- Configure the spike sensitivity -- the minimum percentage increase to trigger a decline rate spike alert (default: 20%)
- Set the repeated failure threshold -- minimum failures per customer in 7 days (default: 3)
- Choose whether anomaly predictions should auto-enroll customers in pre-dunning campaigns
Proactive Outreach Triggers
When the prediction engine identifies an at-risk subscription, it can automatically trigger pre-failure outreach.
Pre-Dunning Campaigns
Pre-dunning campaigns use the Pre-Dunning trigger type in the campaign builder. They fire before a payment fails:
- Trigger: Prediction score exceeds threshold (configurable, default: 60)
- Message tone: Helpful and proactive, not urgent
- Goal: Get the customer to update their payment method before the next charge
- Stop condition: Customer updates their payment method
Example Pre-Dunning Email
Subject: Quick heads-up about your {{merchant_name}} subscription
Hi {{customer_name}},
We noticed your payment method on file may need updating before
your next billing date on {{next_billing_date}}.
To avoid any interruption to your subscription, please take a
moment to verify your payment details:
[Update Payment Method]({{update_url}})
This only takes a minute and ensures your service continues
without interruption.
Thanks,
The {{merchant_name}} TeamTrigger Configuration
Navigate to Settings > Recovery > Failure Prediction to configure:
- Prediction threshold -- Minimum anomaly score to trigger pre-dunning (default: 60)
- Lookahead window -- How far before the billing date to evaluate predictions (default: 7 days)
- Cooldown period -- Minimum days between pre-dunning campaigns for the same customer (default: 30 days)
- Eligible triggers -- Which prediction signals can trigger outreach (card expiry, anomaly score, or both)
ML Retry Scoring
After a payment fails, the prediction engine shifts to optimizing recovery. The score_retry_ml procedure evaluates each potential retry attempt and returns a confidence score that influences when, how, and where the retry happens.
Scoring Model
LostChurn uses a two-tier scoring architecture:
- Rule-based scoring (
rule-based-v0.2) -- The primary scoring path. Evaluates 7 features: decline category (35% weight), decline code (25%), attempt number (15%), time of day (10%), day of week (5%), transaction amount (5%), and customer lifetime value (5%). - ONNX XGBoost inference (Phase 5.2, planned) -- An optional ML model that can replace rule-based scoring. Until the ONNX model is loaded, rule-based scoring is always used as the fallback.
The scoring procedure considers the merchant's timezone when calculating time-of-day and day-of-week features, and factors in the customer's 90-day failure history and lifetime value.
Confidence Scores
Each retry attempt receives a confidence score from 0.0 to 1.0 representing the probability of success:
| Score Range | Interpretation | Action |
|---|---|---|
| 0.8 - 1.0 | Very likely to succeed | Retry immediately |
| 0.5 - 0.8 | Good chance of success | Retry at optimal time |
| 0.2 - 0.5 | Uncertain | Retry with caution; consider dunning |
| 0.0 - 0.2 | Unlikely to succeed | Skip retry; escalate to dunning |
Each score also includes a confidence interval that widens with higher attempt numbers (reflecting increasing uncertainty), and a recommended delay in hours based on the decline code:
| Decline Code | Recommended Delay |
|---|---|
insufficient_funds, card_velocity_exceeded | 72 hours |
processing_error, try_again_later | 12 hours |
issuer_not_available | 6 hours |
| All other codes | 48 hours |
How Scores Influence Recovery
The retry score affects multiple decisions in the recovery pipeline:
- Retry timing -- Higher scores justify faster retries; lower scores suggest waiting longer (via
recommended_delay_hours) - Cascade routing -- Scores can differ by PSP, influencing gateway cascading order
- Dunning escalation -- Low scores trigger earlier escalation to customer communication
- Channel selection -- Scores inform whether to use email, SMS, or voice outreach
Card Expiry Prediction Model
The predictFailure function evaluates card expiration proximity and recent failure history:
| Factor | Probability Contribution |
|---|---|
| Card already expired | +0.60 |
| Expiring within 30 days | +0.40 |
| Expiring within 60 days | +0.20 |
| 3+ recent failures (90-day window) | +0.25 |
| 1-2 recent failures | +0.10 |
| Base probability | 0.10 |
When probability exceeds 0.5, the recommended action is card_update_reminder. Between 0.3 and 0.5, the action is pre_dunning. Below 0.3, no action is taken.
Viewing Predictions in the Dashboard
Subscription Risk View
Navigate to Subscriptions > At Risk to see all subscriptions with elevated prediction scores:
- Sort by risk score, next billing date, or subscription value
- Filter by risk level (Low, Moderate, High, Critical)
- Bulk-enroll high-risk subscriptions in pre-dunning campaigns
Retry Score History
In the Recovery Detail view for any payment, the Prediction tab shows:
- The retry score for each attempt
- Which factors contributed most to the score
- How the prediction changed between attempts
What's Next
- How Automatic Recovery Works -- Understand the full recovery pipeline
- Decline Intelligence -- Learn how decline codes are enriched and categorized
- Recovery Metrics -- Track how predictions improve your recovery performance