Skip to content

[BE-55] Membership plan management: backend (rebuild deleted module) #1293

Description

@yusuftomilola

Overview

The membership-plans module (backend/src/membership-plans/) was removed from the working tree. Membership tiers are a core revenue driver — without plan management, every booking is one-off and the hub loses recurring subscription revenue.

Context

  • The original module entities (MembershipPlan, UserMembership) and enums exist in git history but are deleted — rebuild
  • PaymentsModule for Paystack subscription payments
  • User entity: add activeMembershipId FK (nullable)
  • EmailModule for subscription confirmation and cancellation emails

Tasks

  • Create MembershipPlan entity: id, name, description (text), priceKobo (int), billingCycle (MONTHLY/QUARTERLY/YEARLY), features (JSONB string array, e.g. ["Unlimited hot-desk access", "5 meeting room hours/month"]), bookingHoursIncluded (int, 0 = unlimited), guestPassesPerMonth (int, default 0), isActive (bool), displayOrder (int), createdAt, updatedAt
  • Create UserMembership entity: id, userId (FK), planId (FK), status (ACTIVE/CANCELLED/EXPIRED/PAST_DUE), startDate, currentPeriodEnd, cancelledAt (nullable), paystackSubscriptionCode (nullable), createdAt
  • GET /membership-plans — list active plans sorted by displayOrder (public, no auth)
  • GET /membership-plans/:id — plan detail (public)
  • POST /membership-plans — create plan (admin only)
  • PATCH /membership-plans/:id — update plan (admin only); cannot change priceKobo if plan has active subscribers
  • POST /membership-plans/:id/subscribe — member subscribes to a plan; initialises Paystack recurring charge; creates UserMembership with ACTIVE status; sends welcome email
  • DELETE /membership-plans/my-subscription — cancel subscription; sets cancelledAt; membership remains ACTIVE until currentPeriodEnd; sends cancellation email
  • GET /membership-plans/my-subscription — get current user's active subscription with plan details
  • Register MembershipPlansModule in AppModule

Files to Modify / Create

  • New: backend/src/membership-plans/ (module, entities, controller, providers)
  • backend/src/app.module.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions