Subscriptions
A subscription puts a customer on a plan and bills it period after period. This page covers its statuses, what changes them, how billing periods are dated, and what happens when the plan changes or the subscription is canceled.
A subscription holds one plan, set when it is created (plan_id). The
plan’s base fee is charged once each period, and usage is billed by the
plan’s prices. To bill a customer for two plans, create two subscriptions.
A customer has at most one active subscription on a plan, and two may not
bill the same meter.
Statuses
Section titled “Statuses”| Status | What it means | What you do |
|---|---|---|
active |
Billing, period after period. | Nothing. |
canceled |
Ended. It never bills again, and it cannot be restarted. | Create a new subscription to bill the customer again. |
A subscription starts when it is created, so there is no status for one that is set up now and billed later. Create the subscription when it should bill. A plan billed in advance is invoiced when the subscription is created.
What changes a subscription
Section titled “What changes a subscription”All the routes are under /. Each change sends a
webhook.
| From | Caused by | Webhook | To |
|---|---|---|---|
| (new) | POST / |
subscription. |
active |
active |
POST / |
subscription. |
canceled |
active |
POST / |
subscription. |
no change yet |
active |
Hardcount, when the period a cancel is scheduled for ends | subscription. |
canceled |
active |
DELETE / |
subscription. |
no change |
active |
Hardcount, when the payment retries for an unpaid invoice (dunning) run out and the dunning policy says cancel | subscription. |
canceled |
A subscription bills whether or not the customer has saved a card. Its first invoice is collected like any other. Once email is set up, a customer with no card gets an email:
- with a link to add a card, when Stripe is connected and
PAYMENT_andUPDATE_ URL PAYMENT_are set;UPDATE_ RETURN_ URL - with the invoice itself, when Stripe is not connected.
With Stripe connected and either address unset, the first email is the reminder of the first payment retry, which asks the customer to pay the invoice.
Billing periods
Section titled “Billing periods”A billing period is the stretch of time one invoice covers. It includes its start and not its end. Periods start and end at midnight in your account’s billing timezone (a setting, UTC unless you change it).
A plan bills monthly or yearly. billing_ on the subscription sets the
day monthly periods start on:
calendar, the default: the 1st of each month. A subscription that starts on June 18 has a short first period, June 18 to July 1, then July 1 to August 1, and so on.anniversary: the day the subscription started. A subscription that starts on June 18 bills June 18 to July 18, then July 18 to August 18.
Yearly plans always bill on the anniversary.
When the start day does not exist in a month, the period starts on that month’s last day, and goes back to the start day when it can. A subscription that starts on January 31, on anniversary billing, bills:
| Period | Start | End |
|---|---|---|
| 1 | January 31 | February 28 (February 29 in a leap year) |
| 2 | February 28 | March 31 |
| 3 | March 31 | April 30 |
| 4 | April 30 | May 31 |
Plan changes
Section titled “Plan changes”To move a subscription to another plan, send
POST / with
{"plan_. The change applies at the end of the current
period:
- Hardcount sends
subscription., and the subscription shows the new plan inpending_ change. scheduled pending_and when it applies inplan_ id pending_.plan_ effective_ at - When the period ends, Hardcount bills it on the current plan, then moves
the subscription and sends
subscription.. The next period is billed on the new plan.pending_ change. applied - Cancel the change before then with
DELETE /.v1/ subscriptions/ {id}/ scheduled-plan-change
Nothing is charged or credited when you schedule the change, so no money moves in the middle of a period.
To move a customer to another plan now, cancel the subscription now (see Cancel), which bills the usage so far, and create a new subscription on the other plan.
Cancel
Section titled “Cancel”- Now:
POST /. Hardcount makes a final invoice for the part of the period so far: usage, and a base fee billed in arrears for those days. It collects that invoice like any other.v1/ subscriptions/ {id}/ cancel - A base fee billed in advance is kept, paid or not. The cancel changes no invoice that already exists: an unpaid one stays owed and its payment retries go on, and a draft stays a draft until it is finalized.
- To give money back, issue a credit note on the invoice, or grant
credit with
POST /.v1/ credits/ grant
- At the end of the period:
POST /, with no body. Until then the subscription bills as usual. The period’s invoice is its last: it bills the period as usual, and a base fee billed in advance is not billed for the next period. The customer gave notice, and what they paid for the period is used up.v1/ subscriptions/ {id}/ schedule-cancel DELETE /undoes it, until the period ends.v1/ subscriptions/ {id}/ scheduled-cancel - A body is refused with
422.
Before a change: the ended period is billed first
Section titled “Before a change: the ended period is billed first”Each change above first bills any period that has already ended, then
applies the change. If that period cannot be billed, the change is refused
with 409 unbilled_, and nothing changes.
A cancel now that finds an ended period not billed yet bills it first, as the billing run would have. With plans that bill a base fee in advance, that bills the fee for the period the cancel lands in, and the fee is kept. To end a subscription without it, cancel before the period ends, or schedule the cancel at the period’s end.
Next: the invoice a period becomes: Invoices. More: every route and field is in the API reference.
Stuck, or found a bug? Ask in Discussions · Open an issue