Skip to Content

Plans

A plan is a reusable price: an amount, a billing frequency, and a failure policy. Use one when several customers get the same offer; otherwise price the subscription inline.

Create a plan

const plan = await vectapay.subscriptions.createPlan({ code: "starter-monthly", name: "Starter", billingInterval: "monthly", intervalCount: 1, amount: 2500, // KES 2,500.00 trialPeriodDays: 7, gracePeriodDays: 2, retryOffsetHours: [24, 48, 72], status: "active", });

The SDK method names map one-to-one in the other languages (create_plan in Python, CreatePlanAsync in C#).

FieldRequiredNotes
codeYesStable identifier, unique per business. Trimmed, lowercased, whitespace becomes - ("Starter Monthly" → starter-monthly). Max 60 chars.
nameYesMax 160 chars.
billingIntervalYesdaily, weekly, monthly, yearly.
intervalCountNoUnits per period, 1–365. Default 1.
amountYesShillings, at least 1, max two decimals.
currencyNoAlways KES; only KES is supported for subscriptions.
trialPeriodDaysNo0–365. 0 and null both mean no trial.
gracePeriodDaysNo0–365. Recovery window after a failure.
retryOffsetHoursNo1–10 entries, each 1–2160 hours. Default [24, 48, 72].
statusNoDefault draft. Only active plans can be attached.
allowPause, allowCustomerCancelNoDefault true. Customer-portal permissions only (allowPause also gates portal resume); they never restrict the SDK.
descriptionNoMax 800 chars.
metadataNoFree-form object.

Status

A new plan is draft and cannot be subscribed to. Set it active with updatePlan(id, { status: "active" }). archived means “stop selling”; existing subscriptions keep billing. The API does not enforce a workflow; draft → active → archived is a convention.

Billing frequency

billingInterval is the unit; intervalCount is how many units make one period.

BillbillingIntervalintervalCount
Every two weeksweekly2
Monthlymonthly1
Quarterlymonthly3
Every six monthsmonthly6
Yearlyyearly1

A subscription bills on its start day. Anchors on the 29th–31st clamp to the month’s last day, then return to the anchor (31st → 28 Feb → 31 Mar). Yearly billing clamps 29 Feb to 28 Feb in non-leap years.

Trials

A subscription on a plan with a trial starts trialing, pays nothing, and first charges at trialEndsAt. When creating a subscription you can override the trial: omit trialPeriodDays to use the plan’s, or send 0 to skip it. No trial is ever added unless the plan or the subscription states one.

Don’t shorten a trial with initiateCharge(). It charges immediately and ends the trial.

Retry policy and grace

A failed charge puts the subscription in past_due. Both settings count from the first failure.

  • retryOffsetHours: retry times after the first failure. [24, 48, 72] means retries at +24h, +48h, and +72h, not gaps between attempts. The number of retries is the number of offsets.
  • gracePeriodDays: the recovery window closes at failure + max(last retry offset, gracePeriodDays × 24h).

A short grace never cancels a retry. With [24, 48, 72] and a 2-day grace, the window is 3 days.

Events: charge_failed + dunning_started on first failure, retry_scheduled per retry, dunning_exhausted when none remain, expired when the window closes.

The default [24, 48, 72] is too slow for daily or weekly billing. Set offsets shorter than the period:

FrequencyOffsets
Daily[4, 8, 12]
Weekly[12, 24, 48]
Monthly or longer[24, 48, 72]

Inline subscriptions have no plan, so they fall back to these same values by frequency.

Editing a plan

updatePlan() changes the plan only. Existing subscriptions keep their copied price and frequency; archiving doesn’t cancel anyone. The exception is retry policy: it is read from the plan at failure time, so editing retryOffsetHours or gracePeriodDays affects existing subscriptions on their next failure.

To reprice a subscription, use change plan.

Listing plans

listPlans() returns active plans only by default, so new drafts are easy to miss.

const active = await vectapay.subscriptions.listPlans(); const all = await vectapay.subscriptions.listPlans({ includeAll: true }); const drafts = await vectapay.subscriptions.listPlans({ status: "draft" }); // status wins over includeAll

Results are ordered by status, then name, then creation date (newest first).

When not to use a plan

Send amount, billingInterval, and intervalCount (all required, no default) directly on the subscription for per-customer prices, grandfathered imports, or one-offs. Trade-offs:

  • planId, planCode, and planName are null.
  • allowPause and allowCustomerCancel default to true.
  • No plan-level trial or grace; retries use the frequency defaults above.

If more than a handful of customers share the price, make a plan.

Last updated on