@withpotter/subscriptions — module reference

HTTP routes this module mounts, plus its internal use-cases, entities, and repositories. The exhaustive request/response contract is the engine’s OpenAPI document at /docs; the layered structure below follows the package internal architecture.

HTTP routes

MerchantSubscriptionsController /merchant-subscriptions

MethodPathAuthDescription
GET/merchant-subscriptions/plansList plans
GET/merchant-subscriptions/plans/:idGet plan
GET/merchant-subscriptions/plans/activeGet active plans
GET/merchant-subscriptions/subscriptionsList subscriptions
GET/merchant-subscriptions/subscriptions/:idGet subscription
GET/merchant-subscriptions/subscriptions/attentionGet needing attention
GET/merchant-subscriptions/subscriptions/customer/:customerIdGet by customer
GET/merchant-subscriptions/subscriptions/statsGet stats
POST/merchant-subscriptions/plansYesCreate new plan
POST/merchant-subscriptions/plans/:id/activateYesActivate plan
POST/merchant-subscriptions/plans/:id/deactivateYesDeactivate plan
POST/merchant-subscriptions/subscriptionsCreate new subscription
POST/merchant-subscriptions/subscriptions/:id/cancelCancel subscription
POST/merchant-subscriptions/subscriptions/:id/pausePause renewal
POST/merchant-subscriptions/subscriptions/:id/resumeResume renewal
PUT/merchant-subscriptions/plans/:idYesUpdate plan
DELETE/merchant-subscriptions/plans/:idYesArchive plan

Internals

Use-cases

Application operations. Each is a single-purpose class with one execute() method.

Use-caseSignature
ActivatePlanUseCaseexecute(tenantId: string, planId: string)
ArchivePlanUseCaseexecute(tenantId: string, planId: string)
CancelSubscriptionUseCaseexecute(tenantId: string, subscriptionId: string)
CreatePlanUseCaseexecute(tenantId: string, dto: CreatePlanDto)
CreateSubscriptionUseCaseexecute(tenantId: string, dto: CreateSubscriptionDto)
DeactivatePlanUseCaseexecute(tenantId: string, planId: string)
GetActivePlansUseCaseexecute(tenantId: string)
GetCustomerSubscriptionsUseCaseexecute(tenantId: string, customerId: string)
GetPlanUseCaseexecute(tenantId: string, planId: string)
GetSubscriptionsNeedingAttentionUseCaseexecute(tenantId: string)
GetSubscriptionStatsUseCaseexecute(tenantId: string)
GetSubscriptionUseCaseexecute(tenantId: string, subscriptionId: string)
ListPlansUseCaseexecute(tenantId: string, query: ListPlansQueryDto)
ListSubscriptionsUseCaseexecute(tenantId: string, query: ListSubscriptionsQueryDto)
PauseSubscriptionRenewalUseCaseexecute(tenantId: string, subscriptionId: string)
ResumeSubscriptionRenewalUseCaseexecute(tenantId: string, subscriptionId: string)
UpdatePlanUseCaseexecute(tenantId: string, planId: string, dto: UpdatePlanDto)

Entities

Sequelize models owned by this module.

CustomerSubscription — table customer_subscriptions

FieldType
idstring
tenantIdstring
tenantTenant
planIdstring
planMerchantPlan
customerIdstring
customerMember
customerEmailstring
paystackSubscriptionCodestring | null
paystackPlanCodestring | null
paystackEmailTokenstring | null
authorizationCodestring | null
statusCustomerSubscriptionStatus
amountnumber
currencystring
currentPeriodStartDate | null
currentPeriodEndDate | null
nextPaymentDateDate | null
cancelledAtDate | null
paymentsCountnumber
metadataRecord<string, unknown>
createdAtDate
updatedAtDate

CustomerSubscriptionLineItem — table customer_subscription_line_items

FieldType
idstring
customerSubscriptionIdstring
customerSubscriptionCustomerSubscription
contentIdstring | null
contentContent
titlestring
variant{ id: string
quantitynumber
unitPriceSnapshotnumber
currencystring
createdAtDate
updatedAtDate

Repositories

Data-access classes wrapping the entities.

CustomerSubscriptionLineItemRepository

bulkCreate · listForSubscription

CustomerSubscriptionRepository

create · findById · findByPaystackSubscriptionCode · findByCustomerAndPlan · findActiveByCustomer · listByTenant · listByPlan · getStats · update · updateByPaystackCode · incrementPaymentsCount · cancel · getSubscriptionsNeedingAttention

Generated from the module’s source. Routes are relative to the engine root (default http://localhost:3001). For full request/response schemas use the live OpenAPI document.