Pull Request: Enterprise Readiness & Compliance Suite (#143, #144, #145, #146)#189
Merged
elizabetheonoja-art merged 1 commit intoApr 24, 2026
Conversation
|
@JamesEjembi 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
This PR transitions SubStream-Protocol from a crypto-payment processor to a full-stack B2B subscription platform. It addresses the critical "last-mile" problems of crypto adoption: automated recovery, tax-compliant documentation, granular privacy control, and dashboard performance.
🎯 Key Changes by Module
Orchestration: Implemented a state-machine in the backend to handle the 7-day grace period.
Smart Abort: Integrated a listener for SubscriptionBilled events that instantly halts the email sequence if a user tops up their wallet mid-cycle.
Merchant Notification: Added an automated final-day trigger that notifies the merchant's endpoint to revoke service access.
Compliance: Developed a service using pdfmake to generate localized receipts that map Soroban transactions to their fiat-equivalent value at the time of billing.
Storage: Integrated AWS S3 for secure, asynchronous storage of PDF buffers, with signed URLs saved to the database.
verification: Every invoice footer now embeds the unique Stellar transaction hash for immutable proof of payment.
User Control: Added a PrivacyPreferences table and corresponding PATCH endpoint for GDPR/CCPA compliance.
Dynamic Scrubbing: The webhook dispatcher now checks these preferences in real-time, scrubbing email and PII from payloads if the user has opted for anonymity.
Performance: Introduced Redis to cache heavy MRR and churn calculations, reducing dashboard load times from seconds to <50ms.
Event-Driven Invalidation: Implemented a "cache-aside" pattern where new billing events automatically purge the associated merchant's analytics cache to prevent stale data.
💻 Implementation Snippet: Dynamic Privacy Scrubbing
TypeScript
// src/modules/webhooks/webhook.dispatcher.ts
async dispatch(merchantId: string, payload: any) {
const preferences = await this.privacyRepo.findOne({ where: { merchantId } });
if (!preferences.share_email_with_merchants) {
// Scrub PII before the payload leaves our infrastructure
delete payload.user.email;
delete payload.user.full_name;
payload.user.is_anonymous = true;
}
return this.http.post(merchant.webhook_url, payload);
}
✅ Acceptance Criteria Checklist
[x] Dunning: Integration tests verify that payment during Day 4 successfully kills the Day 7 suspension trigger.
[x] Invoicing: Generated PDFs correctly display fiat math matching the historical price feed.
[x] Privacy: Webhook tests confirm that PII is removed when toggles are OFF.
[x] Caching: Redis "misses" correctly trigger SQL execution and subsequent "hits" serve from memory.
🚀 How to Verify
Test Dunning: Trigger a PaymentFailedGracePeriodStarted event and check the dunning_sequences table for active tracking.
Generate Invoice: Hit GET /api/v1/invoices/:id/download and verify the PDF contains the correct Stellar transaction hash.
Check Cache: Monitor Redis logs (MONITOR) while refreshing the Merchant Dashboard to see the cache hits in action.
🔗 Linked Issues
Closes #143,
Closes #144,
Closes #145,
Closes #146