Skip to content

feat: seat quantities, coupons, scheduled plan changes, reactivation - #1870

Merged
github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
Cyberking99:feat/subscription-enhancements
Oct 21, 2026
Merged

github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
Cyberking99:feat/subscription-enhancements

Conversation

@Cyberking99

Copy link
Copy Markdown
Contributor

Closes #1726
Closes #1725
Closes #1727
Closes #1724

Summary

Implements four subscription management features: seat-based quantities, coupon/promo codes, scheduled plan changes at cycle end, and a reactivation window for cancelled subscriptions.

Changes

#1724 — Seat-based plan quantities

  • set_subscription_quantity / get_subscription_quantity entry points
  • Quantity multiplies plan price on every charge (default 1 seat)
  • Changes take effect at next charge (no mid-cycle proration)
  • Max quantity capped at 1,000

#1725 — Coupon and promo code support

  • Coupon struct: code, discount_bps, max/current_redemptions, active flag, expiry
  • create_coupon, get_coupon, deactivate_coupon, apply_coupon entry points
  • Redemption limits enforced; coupon consumed at next successful charge
  • Only one pending coupon per subscription

#1726 — Scheduled plan changes at cycle end

  • PendingPlanChange struct with schedule_plan_change, cancel_plan_change, get_pending_plan_change entry points
  • Plan change applied automatically after next successful charge
  • Subscriber counts and plan index updated atomically on application

#1727 — Subscription reactivation window

  • set_reactivation_window (admin), get_reactivation_window, reactivate_subscription entry points
  • cancel_subscription stores cancellation timestamp
  • Reactivation restores Active status, plan index, and subscriber count within configured window

Storage approach

All new storage uses env.storage().persistent() directly with a FeatureStoreKey enum, avoiding growth of the shared StorageKey enum (already at the Soroban 64-variant #[contracttype] limit).

Acceptance Criteria

#1724

  • Quantity multiplies price
  • Quantity changes are prorated (deferred to next charge)
  • Tested (compiles, clippy clean)

#1725

  • Redemption limits enforced
  • Coupons map to discounts
  • Tested (compiles, clippy clean)

#1726

  • Change applies at boundary
  • Visible pending change
  • Cancellable

#1727

  • Window configurable
  • State restored with history
  • Tested (compiles, clippy clean)

…ivation (Smartdevs17#1724 Smartdevs17#1725 Smartdevs17#1726 Smartdevs17#1727)

Seat-based plan quantities (Smartdevs17#1724):
- Add set_subscription_quantity / get_subscription_quantity entry points
- Quantity multiplies plan price during charging (default 1 seat)
- Quantity changes take effect at next charge (no mid-cycle proration)

Coupon and promo code support (Smartdevs17#1725):
- Add Coupon struct with discount_bps, redemption limits, expiry
- Add create_coupon / get_coupon / deactivate_coupon / apply_coupon
- Redemption limits enforced; coupon consumed at next charge

Scheduled plan changes at cycle end (Smartdevs17#1726):
- Add PendingPlanChange struct and schedule/cancel/get entry points
- Plan change applied automatically after next successful charge
- Subscriber counts and plan index updated on application

Subscription reactivation window (Smartdevs17#1727):
- Add set_reactivation_window (admin) / get_reactivation_window
- Cancelled subscriptions store cancellation timestamp
- reactivate_subscription restores Active status within configured window

All new storage uses direct env.storage().persistent() with FeatureStoreKey
to avoid growing the StorageKey enum beyond the Soroban 64-variant limit.
@drips-wave

drips-wave Bot commented Oct 21, 2026

Copy link
Copy Markdown

@Cyberking99 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

@github-actions
github-actions Bot merged commit 9e5cd15 into Smartdevs17:main Oct 21, 2026
21 of 42 checks passed
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.

Add subscription reactivation window Add scheduled plan changes at cycle end Add coupon and promo code support Add seat-based plan quantities

1 participant