Recover from a failed renewal
const url = 'https://api.emite.cr/v1/billing/recovery';const options = {method: 'POST', 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 POST \ --url https://api.emite.cr/v1/billing/recovery \ --header 'Authorization: Bearer <token>'For a subscription in past_due or unpaid (paymentRecovery in the entitlements). Recovery is a NEW subscription to the same plan, paid in the Onvo SDK, whose period starts today; confirming it retires the one that failed, which stops its retries. The failed subscription is never charged again by this flow. The server looks before it sells: if the charge had already been collected (Onvo's own retry, or a checkout paid earlier), the plan is restored and the response is mode='recovered'. 400 NOTHING_TO_RECOVER when the subscription is not in dunning; 400 RECOVERY_PLAN_UNAVAILABLE when its plan has no checkout: neither a self-service plan nor a quoted plan with its quote in force (a quoted plan is sold again on that quote). The card is collected by the Onvo iframe — never our servers.
Authorizations
Section titled “Authorizations”Responses
Section titled “Responses”object
'checkout' → a NEW subscription to the plan whose payment failed; render the Onvo SDK with the returned ids and call /subscription/sync on success. 'recovered' → nothing to pay: the charge had already been collected and the plan was restored.
Plan being bought again (checkout mode).
Its cadence (checkout mode).
Always subscription here: a recovery is a plain subscription paid in the Onvo SDK.
Onvo subscription id to pay (checkout mode).
Onvo customer id (checkout mode).
Onvo publishable key for the SDK (checkout mode).
What the card will be charged, in céntimos (checkout mode) — the full price of the period, read back from the subscription Onvo created. Absent when Onvo did not report it.
Base imponible of that charge, in céntimos (checkout mode). The IVA is the remainder.
ISO instant past which the checkout must not be paid (checkout mode). Onvo keeps retrying the subscription being recovered from, so an old checkout risks collecting both.
Example
{ "mode": "checkout", "interval": "month", "paymentType": "subscription"}