Skip to content

Choose or change the subscription plan

POST
/v1/billing/plan-change
curl --request POST \
--url https://api.emite.cr/v1/billing/plan-change \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "planCode": "pj_t3", "interval": "month", "timing": "now", "expectedChargeCentimos": 1 }'

Classifies the change (Onvo can't swap a sub's price, so a change is always a new subscription). An UPGRADE over a live plan credits the unused days of the plan being left (at its list price) against the whole days that remain to the anniversary at the new plan's price. When a card has something to pay it returns mode='checkout' with paymentType='one_time': a payment intent for that net (the exact amount the preview quotes); once the SDK confirms it, /billing/plan-change/sync creates the subscription that renews the plan — with a trial of those days, so its first invoice is the full price — and retires the old one. When the credit covers the days (an annual plan moving to a monthly price) or the net is under the minimum charge, it returns mode='applied': the plan is already on, with a trial of the days bought plus the days the surplus credit bought, and nothing to pay. 409 PLAN_UPGRADE_QUOTE_CHANGED when expectedChargeCentimos no longer matches. A fresh subscribe returns mode='checkout' with paymentType='subscription' (the full price, a cycle from today). A DOWNGRADE or interval switch returns mode='scheduled' — deferred to the period end with no charge now (the current plan + features are kept until then).

Media typeapplication/json
object
planCode
required

Code of a self-service plan: pf_t1…pf_t3 (persona física) or pj_t1…pj_t4 (persona jurídica). The list a given tenant may buy is GET /billing/plans/available.

string
Example
pj_t3
interval

Billing cadence. Annual gets 2 months free.

string
default: month
Allowed values: month year
timing

WHEN an upgrade takes effect. now (default, and the historical behaviour) creates the new subscription today and charges it — prorated to the current anniversary, so only the remaining days are billed. period_end defers it exactly like a downgrade: nothing is charged now, the current plan and any add-on run out the month already paid for, and the new plan starts at the renewal date. Ignored for downgrades and interval switches, which are always deferred — charging those today would destroy paid time.

string
default: now
Allowed values: now period_end
expectedChargeCentimos

What the customer was SHOWN an immediate upgrade charges — quote.chargeCentimos of the preview. The quote is taken again on this call, and a day boundary crossed in between moves it: then the answer is 409 PLAN_UPGRADE_QUOTE_CHANGED and the client asks again, instead of charging a figure nobody saw. Omit it to charge whatever the quote says now.

number
Media typeapplication/json
object
mode
required

'checkout' → an immediate upgrade/subscribe; render the Onvo SDK with the returned ids. 'applied' → an immediate upgrade whose days the credit of the plan being left covered (or whose net was under the minimum charge): the plan is ALREADY on, nothing to pay, no SDK — read paidThrough, creditCentimos and renewalCentimos and say so. 'scheduled' → a downgrade/interval switch/deferred upgrade at period end (no payment now).

string
Allowed values: checkout scheduled applied
paymentType

What the SDK confirms (checkout mode). subscription: a plain subscription at the full price, whose cycle starts today (a fresh subscribe, a recovery) — call /billing/subscription/sync on success. one_time: an UPGRADE over a live plan — a one-time intent for the whole days that remain to the plan's anniversary, at the new plan's price; the subscription that renews the plan is created once it collects, with a trial of exactly those days — call /billing/plan-change/sync on success.

string
Allowed values: subscription one_time
subscriptionId

Onvo subscription id (checkout mode, subscription).

string
paymentIntentId

Onvo payment intent id (checkout mode, one_time).

string
customerId

Onvo customer id (checkout mode).

string
publishableKey

Onvo publishable key for the SDK (checkout mode).

string
effectiveAt

ISO date the scheduled change applies (scheduled mode).

string
nullable
planCode

Target plan slug (scheduled and applied modes).

string
interval

Target interval (scheduled and applied modes).

string
firstChargeCentimos

What the card will be charged NOW, in céntimos (checkout mode). For a one_time upgrade it is the amount fixed on the intent — our own proration MINUS the credit of the plan being left, the same figure the preview quotes; for a subscription it is the full price of the period, read back from the subscription Onvo created. Absent when Onvo did not report it.

number
listChargeCentimos

The days bought at the new plan's list price, in céntimos, before the credit (checkout mode, one_time) — what the checkout's breakdown starts from.

number
creditCentimos

The credit of the plan being left, in céntimos, IVA included (one_time checkout and applied modes): the unused whole days of that plan at its list price. In checkout mode it was subtracted from firstChargeCentimos; in applied mode it covered the days bought and the surplus became days of the new plan.

number
creditDays

Whole days credited.

number
creditPlanCode

The plan those days belonged to.

string
nullable
trialDays

The trial the new subscription was created with (applied mode): the days bought to the anniversary plus the days the surplus credit bought.

number
paidThrough

ISO instant the new plan is paid through (applied mode) — its first full charge, at renewalCentimos.

string
renewalCentimos

What every renewal charges from then on: one full interval, in céntimos (applied mode).

number
firstChargeNetCentimos

Base imponible of that same charge, in céntimos (checkout mode). Served so the checkout can render a tax breakdown that ADDS UP to the amount being charged — a prorated first charge matches no catalog price, so a breakdown built from the monthly catalog figures would state numbers that do not sum to the total right above them. The IVA is the remainder.

number
proratedTo

ISO instant the days bought run out — when the new plan first renews at its full price (checkout mode, one_time). Its presence is what makes "you are paying for the days that remain" true rather than copy.

string
expiresAt

ISO instant past which the checkout must not be paid (checkout mode). Always present on a one_time upgrade (its days were counted from today); on a subscription only when the one being replaced is in dunning — a plan chosen over a failed payment is a recovery, see POST /billing/recovery.

string
pendingPayment

Present on a one_time upgrade when the customer already started an asynchronous payment (SINPE Móvil) for THIS upgrade on an earlier checkout and Onvo is still waiting for the transfer (a processing intent started within the last 24 hours). Neither reused nor canceled: tell the customer to wait if they already sent it instead of paying again on paymentIntentId.

object
paymentIntentId
required

The Onvo payment intent still waiting for that transfer.

string
startedAt
required

ISO instant the customer started it.

string
Example
{
"mode": "checkout",
"paymentType": "subscription"
}