Skip to content

What a plan change would do — without doing it

GET
/v1/billing/plan-change/preview
curl --request GET \
--url 'https://api.emite.cr/v1/billing/plan-change/preview?planCode=example' \
--header 'Authorization: Bearer <token>'

Read-only: no row touched (and at most one Onvo read, only when the locally recorded period end is stale). Answers the three things a client needs before it can ask the customer anything — is this an upgrade (the only change with a timing choice), when does the current period end, and which held add-ons the target plan bundles. Served rather than derived because the web cannot import the plan catalog, and a client that classified the change itself could offer a choice the subsequent write then contradicts.

planCode
required
string
Media typeapplication/json
object
kind
required

How the change would be classified. Only upgrade has a timing choice — everything else is always deferred to the period end, because charging it today would destroy paid time.

string
Allowed values: upgrade downgrade interval same invalid
currentPlanCode

The EFFECTIVE plan running today.

string
nullable
effectiveAt

ISO end of the current period — the date a deferred change would start, and what an immediate upgrade gives up. Null when there is no live period to measure against, which is also what makes the timing choice unofferable. The date an immediate upgrade is prorated TO is proratedTo.

string
nullable
proratedTo

ISO instant an IMMEDIATE upgrade is paid through — when the days bought run out and the new plan first renews at its price: the next anniversary of the current period COUNTED IN THE TARGET INTERVAL, or within 24 h after it (days are bought whole). On an annual plan moving to a monthly price it is at most a month away, while effectiveAt (when the running period ends, and what is lost by upgrading now) can be most of a year. Null unless the change is an upgrade over a live period.

string
nullable
bundledAddons
required

Add-ons the tenant HOLDS whose feature the target plan bundles — the ones whose paid month overlaps (upgrading now) or runs out untouched (upgrading at the renewal). Same derivation the cascade acts on, so the disclosure and the behaviour cannot describe different things.

Array<string>
quote

What upgrading NOW would charge — the exact figure, since the proration is ours: the days that remain, what they cost, the date they run to, and what every renewal charges after that. POST /billing/plan-change recomputes it at that instant and fixes it on the intent, so the checkout shows the amount actually collected. Null unless the change is an upgrade over a live period.

object
planCode
required

The plan being bought.

string
interval
required

Cadence of the price being bought. The days are counted to the running plan's next anniversary in THIS cadence, and every renewal (renewalCentimos) is one interval of it.

string
Allowed values: month year
chargeCentimos
required

What the card is charged NOW, in céntimos, IVA included: listChargeCentimos minus creditCentimos, never below zero. 0 when the credit of the plan being left covered the days bought, and when waived.

number
chargeNetCentimos
required

Base imponible of that charge, in céntimos. The IVA is the remainder.

number
listChargeCentimos
required

The days bought at the new plan's list price, in céntimos, IVA included, BEFORE the credit: the whole days that remain to the running plan's next anniversary — counted in the cadence of the price being bought — at the new plan's daily price.

number
creditCentimos
required

The unused days of the plan being LEFT, at its own list price, in céntimos, IVA included — credited against the charge in the same operation. 0 when there is nothing to credit. It is not a balance: whatever it does not cover of the list charge is paid, whatever exceeds it buys extraDays of the new plan, and nothing is ever left over.

number
creditDays
required

Whole days credited.

number
creditPeriodDays
required

Days of the window the credit was priced over — the window of the plan being left, in its own cadence, ending at its period end (28–31 for a month, 365–366 for a year). 0 with nothing to credit.

number
creditPlanCode
required

The plan those days belonged to.

string
nullable
creditInterval
required

Its cadence.

string
nullable
Allowed values: month year
days
required

Whole days the list charge pays for.

number
extraDays
required

Days of the new plan the SURPLUS credit bought (credit > list charge: an annual plan moving to a monthly price), at the new plan's daily price, rounded up. 0 when a card pays.

number
trialDays
required

days + extraDays: what the new plan is served before its first full charge — the trial the subscription is created with.

number
periodDays
required

Days of the anniversary window the purchase falls in — the denominator of the proration, so days === periodDays is a full interval at the full price.

number
anniversary
required

ISO instant of the running plan's anniversary, in the target's cadence.

string
paidThrough
required

ISO instant the days served (trialDays) run out — when the new plan first renews at its full price. With no surplus credit it falls on the anniversary or within the 24 hours after it; with one it is as far out as the credit reaches.

string
renewalCentimos
required

What every renewal charges: one full interval, in céntimos, IVA included.

number
waived
required

True when the net (list charge minus credit) was positive but under the minimum charge: nothing is charged, and asking to upgrade now APPLIES the plan on the spot all the same (mode='applied').

boolean
Example
{
"kind": "upgrade",
"quote": {
"interval": "month",
"creditInterval": "month"
}
}