@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/plansn/aList plans
GET/merchant-subscriptions/plans/:idn/aGet plan
GET/merchant-subscriptions/plans/activen/aGet active plans
GET/merchant-subscriptions/subscriptionsn/aList subscriptions
GET/merchant-subscriptions/subscriptions/:idn/aGet subscription
GET/merchant-subscriptions/subscriptions/attentionn/aGet needing attention
GET/merchant-subscriptions/subscriptions/customer/:customerIdn/aGet by customer
GET/merchant-subscriptions/subscriptions/statsn/aGet stats
POST/merchant-subscriptions/plansYesCreate new plan
POST/merchant-subscriptions/plans/:id/activateYesActivate plan
POST/merchant-subscriptions/plans/:id/deactivateYesDeactivate plan
POST/merchant-subscriptions/subscriptionsn/aCreate new subscription
POST/merchant-subscriptions/subscriptions/:id/canceln/aCancel subscription
POST/merchant-subscriptions/subscriptions/:id/pausen/aPause renewal
POST/merchant-subscriptions/subscriptions/:id/resumen/aResume 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.