What a plan change would do — without doing it
const url = 'https://api.emite.cr/v1/billing/plan-change/preview?planCode=example';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Responses
Section titled “Responses”object
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.
The EFFECTIVE plan running today.
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.
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.
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.
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
The plan being bought.
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.
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.
Base imponible of that charge, in céntimos. The IVA is the remainder.
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.
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.
Whole days credited.
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.
The plan those days belonged to.
Its cadence.
Whole days the list charge pays for.
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.
days + extraDays: what the new plan is served before its first full charge — the trial the subscription is created with.
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.
ISO instant of the running plan's anniversary, in the target's cadence.
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.
What every renewal charges: one full interval, in céntimos, IVA included.
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').
Example
{ "kind": "upgrade", "quote": { "interval": "month", "creditInterval": "month" }}