Subscription and recurring billing logic#158
Merged
codebestia merged 7 commits intoShadeProtocol:mainfrom Feb 27, 2026
Merged
Conversation
codebestia
approved these changes
Feb 27, 2026
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.
Subscription Engine — Recurring Billing for Merchants
Summary
Implements a Stripe-like recurring billing system on Soroban using a pull model. Merchants can create billing plans, customers can subscribe, and an authorized caller (merchant or bot) triggers charges once the billing interval has elapsed.
New Files
contracts/shade/src/components/subscription.rs— full subscription engine implementationModified Files
types.rs— addedSubscriptionPlan,Subscription,SubscriptionStatusstructs andSubscriptionPlan(u64),Subscription(u64),PlanCount,SubscriptionCountDataKey variantsevents.rs— fixed existing conflicts/incomplete sections; addedSubscriptionPlanCreated,Subscribed,SubscriptionCharged,SubscriptionCancelledeventsinterface.rs— added 6 new methods toShadeTrait:create_subscription_plan,get_subscription_plan,subscribe,get_subscription,charge_subscription,cancel_subscriptionerrors.rs— added 8 new error variants:NotFound,InvalidAmount,InvalidInterval,PlanNotActive,SubscriptionNotActive,IntervalNotElapsed,MerchantNotFound,MerchantAccountNotFoundshade.rs— wired subscription functions into the contract impl blockcomponents/mod.rs— registered newsubscriptionmoduleHow It Works
create_subscription_plansubscribecharge_subscriptiontransfer_fromif interval has elapsedcancel_subscriptionFee Model
Mirrors the existing invoice fee logic — fee is read in basis points from
FeeInBasisPoints(token), deducted from the charge amount, and sent to the Shade contract. The net amount goes to the merchant's account contract.Closes
closes #87