Skip to content

feat: implement Subscription and SubscriptionPlan contract entry points #376

Description

@Pvsaint

Problem

lib.rs defines Subscription, SubscriptionPlan, and SubscriptionStatus as #[contracttype] structs, and EVENTS.md documents a SUBSCRIPTION/CREATED event — but there are zero callable entry points for subscriptions anywhere in the codebase. This is dead code that will trigger Clippy warnings and confuse integrators.

Required Entry Points

  • create_plan(merchant, plan_id, name, description, amount, currency, interval_secs) — merchant creates a billing plan
  • subscribe(payer, subscription_id, plan_id) — payer subscribes to a plan
  • process_subscription(operator, subscription_id) — operator triggers a recurring charge
  • cancel_subscription(payer_or_merchant, subscription_id) — cancel an active subscription
  • get_subscription(subscription_id)Subscription
  • get_plan(plan_id)SubscriptionPlan

Acceptance Criteria

  • All six entry points are implemented on a contract (PaymentProcessor or dedicated SubscriptionManager)
  • process_subscription enforces next_payment_at — rejects if called before due date
  • max_payments is respected; subscription auto-cancels when limit is reached
  • SUBSCRIPTION/CREATED, SUBSCRIPTION/CHARGED, SUBSCRIPTION/CANCELLED events are emitted
  • EVENTS.md and CHANGELOG.md are updated
  • Unit tests cover: subscribe, charge on time, reject early charge, cancel, max_payments limit
  • cargo test --all-features passes

Branch & Commit Examples

branch: feat/subscription-manager
commit: feat(subscriptions): implement create_plan, subscribe, process_subscription, cancel_subscription

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions