Class: SubscriptionsResource
Recurring billing — plans, customer subscriptions, and per-period charges.
createPlan()once per offering. 2.create()per customer.initiateCharge()per cycle from the merchant checkout:cardneedsemail(returnscheckoutRedirectUrl),mobile_moneyneedsphone(STK prompt). Settle from webhooks, notchargeStatus.
Constructors
Constructor
new SubscriptionsResource(http): SubscriptionsResource;Parameters
http
Returns
SubscriptionsResource
Methods
activity()
activity(subscriptionId): Promise<SubscriptionActivity>;Subscription timeline — record plus recent events + charge attempts.
Parameters
subscriptionId
string
Returns
Promise<SubscriptionActivity>
analytics()
analytics(): Promise<SubscriptionAnalytics>;Revenue analytics — MRR, churn, retry recovery, failure reasons.
Returns
Promise<SubscriptionAnalytics>
audit()
audit(params?): Promise<SubscriptionAuditPage>;Audit feed — every subscription action with actor + outcome.
Parameters
params?
cursor?
string
limit?
number
Returns
Promise<SubscriptionAuditPage>
cancel()
cancel(subscriptionId, request?): Promise<CustomerSubscriptionMutationResult>;Cancels now, or at period end with cancelAtPeriodEnd: true.
Parameters
subscriptionId
string
request?
Returns
Promise<CustomerSubscriptionMutationResult>
changeBillingDate()
changeBillingDate(subscriptionId, request): Promise<CustomerSubscriptionMutationResult>;Moves the next billing date (reschedules the pending charge attempt).
Parameters
subscriptionId
string
request
Returns
Promise<CustomerSubscriptionMutationResult>
changePlan()
changePlan(subscriptionId, request): Promise<CustomerSubscriptionMutationResult>;Moves a subscription to another plan. The change takes effect at the next billing boundary; there is no mid-period proration and no credit is issued.
Parameters
subscriptionId
string
request
Returns
Promise<CustomerSubscriptionMutationResult>
chargeStatus()
chargeStatus(subscriptionId, checkoutRequestId): Promise<SubscriptionChargeStatus>;One-off throttled status lookup — a support tool, not a poll target.
Parameters
subscriptionId
string
checkoutRequestId
string
Returns
Promise<SubscriptionChargeStatus>
clearEnd()
clearEnd(subscriptionId, request?): Promise<CustomerSubscriptionMutationResult>;Clears a previously scheduled end date.
Parameters
subscriptionId
string
request?
ClearSubscriptionEndInput = {}
Returns
Promise<CustomerSubscriptionMutationResult>
create()
create(request): Promise<CustomerSubscriptionMutationResult>;Puts a customer on a plan (or on inline amount/interval pricing).
customerId must already exist — create the customer in the dashboard first; the SDK does not
expose a customers resource yet. A custom amount is in major units: 1500 means KES 1,500.
Pass an externalReference to key the subscription to your own user/workspace id.
Parameters
request
CreateCustomerSubscriptionInput
Returns
Promise<CustomerSubscriptionMutationResult>
createPlan()
createPlan(request): Promise<MerchantSubscriptionPlan>;Creates a merchant plan — one offering customers can subscribe to.
amount is in major units: 1500 means KES 1,500, not 1,500 cents.
Parameters
request
CreateMerchantSubscriptionPlanInput
Returns
Promise<MerchantSubscriptionPlan>
enableStandingOrder()
enableStandingOrder(subscriptionId, request): Promise<CustomerSubscriptionMutationResult>;Registers an M-Pesa Ratiba standing order (M-Pesa accounts only).
Parameters
subscriptionId
string
request
EnableStandingOrderInput
Returns
Promise<CustomerSubscriptionMutationResult>
get()
get(subscriptionId): Promise<CustomerSubscriptionRecord>;Reads one customer subscription.
Parameters
subscriptionId
string
Returns
Promise<CustomerSubscriptionRecord>
initiateCharge()
initiateCharge(subscriptionId, request): Promise<InitiateSubscriptionChargeResult>;Charges one billing period — card or mobile_money. Settle from webhooks; do not poll
chargeStatus.
A card-only subscription (customer has an email but no phone) is not auto-charged by the scheduler until a reusable card has been captured. Call this for each period until then; after the first reusable card charge, renewal becomes automatic.
Parameters
subscriptionId
string
request
InitiateSubscriptionChargeInput
Returns
Promise<InitiateSubscriptionChargeResult>
list()
list(params?): Promise<CustomerSubscriptionsPage>;Lists customer subscriptions with cursor pagination + filters.
Parameters
params?
ListCustomerSubscriptionsQuery = {}
Returns
Promise<CustomerSubscriptionsPage>
listAttempts()
listAttempts(params?): Promise<SubscriptionChargeAttemptsPage>;Paginated charge attempts across subscriptions.
Parameters
params?
ListSubscriptionChargeAttemptsQuery = {}
Returns
Promise<SubscriptionChargeAttemptsPage>
listByExternalReference()
listByExternalReference(externalReference, params?): Promise<CustomerSubscriptionsPage>;Finds subscriptions by your own exact externalReference.
Parameters
externalReference
string
params?
Omit<ListCustomerSubscriptionsQuery, "externalReference"> = {}
Returns
Promise<CustomerSubscriptionsPage>
listByStatus()
listByStatus(status, params?): Promise<CustomerSubscriptionsPage>;Filters subscriptions by status — convenience over list({ status }).
Parameters
status
CustomerSubscriptionStatus
params?
Omit<ListCustomerSubscriptionsQuery, "status"> = {}
Returns
Promise<CustomerSubscriptionsPage>
listPlans()
listPlans(params?): Promise<MerchantSubscriptionPlan[]>;Lists merchant plans, optionally filtered by status.
Parameters
params?
includeAll?
boolean
status?
MerchantSubscriptionPlanStatus
Returns
Promise<MerchantSubscriptionPlan[]>
overview()
overview(): Promise<SubscriptionOperationsOverview>;Operations overview — counts, MRR, next due charge.
Returns
Promise<SubscriptionOperationsOverview>
pause()
pause(subscriptionId, request?): Promise<CustomerSubscriptionMutationResult>;Pauses billing — nothing is charged while paused.
Parameters
subscriptionId
string
request?
Returns
Promise<CustomerSubscriptionMutationResult>
repair()
repair(request): Promise<SubscriptionRepairRunResult>;Runs an operator repair pass (queue due attempts, recover stuck ones).
Parameters
request
Returns
Promise<SubscriptionRepairRunResult>
resume()
resume(subscriptionId, request?): Promise<CustomerSubscriptionMutationResult>;Resumes a paused subscription.
Parameters
subscriptionId
string
request?
Returns
Promise<CustomerSubscriptionMutationResult>
retryCharge()
retryCharge(subscriptionId, request): Promise<RetryCustomerSubscriptionChargeResult>;Queues an operator retry for the current billing period.
Parameters
subscriptionId
string
request
RetryCustomerSubscriptionChargeInput
Returns
Promise<RetryCustomerSubscriptionChargeResult>
scheduleEnd()
scheduleEnd(subscriptionId, request): Promise<CustomerSubscriptionMutationResult>;Schedules a future end date (max 2 years out).
Parameters
subscriptionId
string
request
Returns
Promise<CustomerSubscriptionMutationResult>
updatePlan()
updatePlan(planId, request): Promise<MerchantSubscriptionPlan>;Updates a merchant plan (code, pricing, retry policy, flags).
Parameters
planId
string
request
UpdateMerchantSubscriptionPlanInput
Returns
Promise<MerchantSubscriptionPlan>