Feature/issue 929 trial management - #1075
Open
Tekgodfrey wants to merge 2 commits into
Open
Conversation
|
@Tekgodfrey 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 implements Subscription Trial Management with Conversion Optimization across the Node.js backend and the Soroban smart contract, resolving Issue #929.
Key Changes
Closes #929
Smart Contract Integration (
contracts/subscription&contracts/types)Trialingstatus to theSubscriptionStatusenum to differentiate trials from fully active and billed subscriptions.TrialConfigstruct and introduced aPlanTrial(u64)variant in theStorageKeyenum. This allows us to link trial settings to a plan without modifying the existingPlanstruct signature, ensuring backward compatibility with existing storage entries.contracts/subscription/src/trial.rswhich providesset_plan_trialandget_plan_trialto configure a plan's trial duration. These endpoints are exported in the primarySubTrackrSubscriptionblock (lib.rs).subscribemethod. If a plan has an active trial configuration, the resulting subscription starts withSubscriptionStatus::Trialing, andnext_charge_atis correctly deferred until the end of the trial period instead of the standard billing interval.Backend Integration (
backend/services/billing)TrialManagementService(trialService.ts) to handle conversion optimizations.checkTrialsEndingSoon, which scans subscriptions and emitstrial_ending_soonwebhook alerts for subscribers nearing their trial end date (e.g. within a 3-day threshold) to prompt conversion reminders or discounts.processExpiredTrialsto batch-process trials that have reached theirnext_charge_attimestamp.getTrialAnalyticsto track and measure the conversion rate of trials to paid subscriptions.backend/services/billing/index.ts.Testing & Validation
backend/services/billing/__tests__/trialService.test.tsto validate threshold alerting, expired trial processing, and correct analytics reporting.cargo checkinside thecontracts/subscriptiondirectory. (Note: local environment issues with the upstreamsoroban-sdktoolchain block full localcargo testexecution, but the logic changes are syntactically and architecturally complete).This PR will not be mergeable until all quality gates pass.