Skip to content

feat: implement Pre-Billing Health Check (3-Day Warning) #142#186

Merged
elizabetheonoja-art merged 3 commits into
SubStream-Protocol:mainfrom
KarenZita01:feat/pre-billing-health-check
Apr 22, 2026
Merged

feat: implement Pre-Billing Health Check (3-Day Warning) #142#186
elizabetheonoja-art merged 3 commits into
SubStream-Protocol:mainfrom
KarenZita01:feat/pre-billing-health-check

Conversation

@KarenZita01
Copy link
Copy Markdown
Contributor

Overview

This PR implements a proactive "Health Check" cron job designed to identify failing subscriptions before the billing date. This reduces gas waste for merchants and churn for users.ChangesCron Job: Added a daily worker that scans for subscriptions due in $T+3$ days.On-Chain Verification: Integrated Soroban RPC calls to check real-time balance and allowance.Anti-Spam: Updated the Subscription schema with warning_sent_at to ensure users only receive one warning per cycle.Gas Optimization: By identifying "doomed" transactions early, merchants can skip execution for underfunded wallets, saving gas.Acceptance Criteria[x] Users with insufficient funds receive email alerts 3 days prior.[x] RPC checks correctly identify revoked allowances.[x] Database queries are optimized for large datasets.Testing[x] Mocked SorobanClient to return 0 balance; verified email triggers.[x] Verified warning_sent_at prevents duplicate emails on subsequent cron runs. Fixes #142

…otocol#142)

- Add SorobanBalanceChecker service for RPC balance and authorization verification
- Implement PreBillingHealthCheck service with database schema enhancements
- Create PreBillingHealthWorker with node-cron daily scheduling (2 AM UTC)
- Add PreBillingEmailService with professional warning email templates
- Build comprehensive API endpoints for management and monitoring
- Create standalone runner script with CLI interface
- Add database schema: next_billing_date, warning_sent_at, required_amount columns
- Implement RPC rate limiting (1 req/min per wallet) and caching (30s)
- Add batch processing for efficient large dataset handling
- Create comprehensive test suite with mocked RPC calls
- Include complete documentation and deployment guide
- Support multiple deployment modes: daemon, cron, Docker
- Add performance metrics and monitoring endpoints
- Implement graceful shutdown and error recovery

Acceptance Criteria:
- Users receive proactive warnings 3 days before payment failures
- Merchants experience lower churn and save gas on failed transactions
- System efficiently handles large datasets without RPC rate limit hits

Resolves SubStream-Protocol#142
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 22, 2026

@KarenZita01 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@elizabetheonoja-art elizabetheonoja-art merged commit 4e1e61c into SubStream-Protocol:main Apr 22, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create "Pre-Billing Health Check" Cron Job (3-Day Warning)

2 participants