Plans
A Plan is pricing configuration reused across subscriptions. Create it once, subscribe many cardholders to it.
Plan types (type enum)β
The Migo middleware models recurrence around four type values β they decide how Migo computes the next charge date. Send the lowercase camelCase value (the spec example renders the enum key in uppercase but the runtime accepts only the values shown below):
| Enum key | API value (type) | Meaning | When to use |
|---|---|---|---|
INTERVAL | "interval" | Charges every N days from the subscription's anchor date | Most common β weekly, every 30 days, every 90 days |
FIXED_DAY | "fixedDay" | Charges on a specific day of the month | "1st of the month" or "15th of every month" billing |
ANNIVERSARY | "anniversary" | Charges on the same calendar day each cycle (handles month-length quirks) | Yearly subscriptions, anniversary billing |
AUTOMATIC | "automatic" | Migo defers next-charge calculation to the processor (legacy/manual) | Rare; only for processors with their own scheduler |
Source of truth: libs/mongo-database/src/lib/enums/plan.enum.ts.
Create a planβ
curl -X POST https://mw.migopayments.com/v1/plans \
-H "Authorization: Bearer <middleware-jwt>" \
-H "Content-Type: application/json" \
-d '{
"plan": {
"name": "Pro Monthly",
"amount": 29.99,
"currency": "USD",
"type": "interval",
"frequency": {
"frequency": 30,
"day": 1,
"shortDescription": "Monthly",
"longDescription": "Charged every 30 days"
},
"methods": ["fac-2", "visa-cybersource"],
"installments": [1],
"autoRenewal": true,
"dailyAttempts": 3,
"daysNotifyExpiringCard": 7
},
"client": "client_abc123"
}'
| Field | Type | Required | Notes |
|---|---|---|---|
plan.name | string | β | Shown on cardholder statements |
plan.amount | number | β | Decimal, up to 4 places |
plan.currency | ISO 4217 | β | GTQ, USD, etc. |
plan.type | enum | β | "interval" | "fixedDay" | "anniversary" | "automatic". Not required by validation; fixedDay only enforces frequency > 30 |
plan.frequency.frequency | integer | β | Days between charges (used by interval); 0 for fixedDay |
plan.frequency.day | 1β28 | β | Day of month, only relevant for fixedDay plans; not required by validation |
plan.frequency.shortDescription | string | β | One-word cadence label (e.g. Monthly) |
plan.frequency.longDescription | string | β | Full cadence description |
plan.methods | string[] | β | Allowed processors for charges |
plan.installments | number[] | β | Allowed installment counts ([1] for single-payment) |
plan.autoRenewal | boolean | β | Whether Migo schedules the next charge automatically |
plan.dailyAttempts | integer | β | Retry attempts per day on failed charges |
plan.daysNotifyExpiringCard | integer | β | Days before card expiry to notify the cardholder |
client | string | β | Merchant client slug |
The
interval/intervalCountfields used by other billing platforms do not apply here β Migo derives cadence fromtype+frequency.frequency+frequency.day.
List plansβ
curl "https://mw.migopayments.com/v1/plans/list?client=client_abc123" \
-H "Authorization: Bearer <middleware-jwt>"
Get plan detail for a specific clientβ
curl "https://mw.migopayments.com/v1/plans/{planId}/client/{client}/detail" \
-H "Authorization: Bearer <middleware-jwt>"
Returns the plan plus client-specific overrides (currency conversion, localized name, etc.) and the next charge date computed against the merchant's timezone.
Update a planβ
curl -X PUT https://mw.migopayments.com/v1/plans \
-H "Authorization: Bearer <middleware-jwt>" \
-H "Content-Type: application/json" \
-d '{
"client": "client_abc123",
"planId": "pln_01HXXX",
"plan": {
"name": "Pro Monthly",
"amount": 34.99
}
}'
The fields to update must be nested under a plan object, and that object must carry the plan name (the handler reads body.plan.name). Sending amount at the top level has no effect.
Updating a plan's amount or frequency does not change existing subscriptions β they continue at their original price/cadence. The API does not support changing a subscription's plan, so migrating existing subscriptions to the new pricing requires creating new subscriptions (via the verify-card flow).
Versioningβ
You cannot delete a plan that has active subscriptions. Create a new plan and migrate subscriptions instead. This preserves historical billing accuracy.
Relatedβ
- Live spec:
Planstag Β·POST /v1/plansΒ·GET /v1/plans/listΒ·PUT /v1/plans. - Create a subscription
- Lifecycle management