Prerequisites
- An API key. See API keys.
What a version is
A version has aversionNumber. The first version of a plan is 1. Each new version has the next
number.
A version holds a list of price lines. Each line has a key and a price. The key is the name of
the line. It stays the same when you change the price of the line, so you can follow one line
through all the versions of the plan.
A version never changes. A later edit to a price does not change the values in an older version.
The plan itself, such as its name, is not part of a version. If you change only the name of a plan,
the API changes the name and makes no new version.
Paygentic creates a version when you:
- create a plan with prices. The plan starts with version
1. - change the prices of a plan with
PATCH /v0/plans/{id}. - edit a price that a plan uses with
PATCH /v0/prices/{id}. See Editing prices. - create a version yourself with
POST /v0/plans/{id}/versions.
The default version
One version of the plan is the default version. The default version is the version that a new subscription bills from.defaultVersionId in the plan response shows it.
When Paygentic creates a version, it becomes the default version immediately. You can also make an older
version the default again. See Roll back a plan.
Read the versions
subscriptionCount is the number of subscriptions that were on the version when they were
created. It does not show which version each subscription bills from now.
To read the price lines of one version, use its number:
prices list. Each item has the key of the line and the fields of the price.
Use the key to address the line in a price interval.
Only an account that can manage the plan can read its versions. A version can show pricing that
you have not yet released, so read-only access is not enough.
Create a version
Most edits create a version for you. To create a version yourself, send the full list of prices that the new version must hold. Make the prices first withPOST /v0/prices.
key with the
current default version:
- A key with a different price ID replaces the line.
- A key that is only in the request adds a line.
- A key that the current version has and the request does not have removes the line.
key adds a line with a key that the API makes. You can send a price ID alone
instead of an object.
Send basedOnVersionId to protect against an old read. If the default version is not the version
that you name, the API refuses the request with status 409. A price list that you built from an old
read then cannot remove a line that another person added. If you do not send it, the API writes the
set without a check.
The response is the new version. It is published, and it is the default version.
A version must have one price or more. The API refuses an empty list.
What a new default version does to a subscription
When a new version becomes the default version, the version policy of each subscription decides what happens.
A subscription that you create without a
versionPolicy is floating. All the subscriptions that
existed before the field was available are also floating.
A change of the default version never changes a period that the customer has been invoiced for.
Choose a policy
SendversionPolicy when you create the subscription, or when you update it:
versionPolicy. It also shows planVersionId and
versionNumber, which are the version that the subscription holds.
Use pinned when a customer must keep the prices that you agreed. The subscription then keeps
the prices, the entitlements, and the grants of its version, also when you roll the plan back.
Use floating when you want each customer to get your latest prices.
To move a pinned subscription to the default version, change its policy to floating. The
subscription then moves to the default version under the plan’s versionTransition. It does not go
back to pinned by itself.
When a version change takes effect
TheversionTransition of a plan decides when a subscription moves to a new version. It has two
fields, effectiveDate and proration. Paygentic supports two values:
The API refuses every other value with status
400.
Set the policy when you create a plan with POST /v0/plans, or change it with PATCH /v0/plans/{id}:
versionTransition. A plan that you create without it gets
end_of_current_period. A new policy applies only to moves that occur after the change. A move that
occurred before it keeps its dates.
An immediate move
An immediate move has three effective times:- Entitlements and grants change at the move. A
floatingsubscription moves at the next billing run after the new default version is published. A migration moves at the request. - In-arrears prices, fees and metered prices, change at the start of the current period. The invoice that closes the period bills the whole period at the new version.
- In-advance prices change at the end of the current period. The period that the customer has paid for is not billed again and gets no credit.
A grant that the move changes for a feature that both versions have changes at its next reset. In
the example, a grant that goes from 1,000 to 2,000 calls counts March against 1,000 calls and April
against 2,000. Calls above the grant in March bill at the new rate.
Some in-arrears prices move at the end of the current period instead, on both sides, as in an
end-of-period move:
- a price whose payment term or billing cadence changes between the versions;
- a price whose line in the subscription already starts or ends inside the current period, for example after a price interval edit or an end-of-period move that is still pending;
- a price with a line of the current period that is already invoiced.
Costs of an immediate move
Know these costs before you chooseimmediate. If one of them is not acceptable, keep
end_of_current_period.
- One move has more than one effective time.
- An added in-advance fee gives access free of charge for the rest of the current period.
- In-arrears and in-advance prices act differently. An added in-arrears fee bills the whole current period. An added in-advance fee bills nothing for it.
- Usage of a removed in-arrears price before the move is not billed.
- A
floatingsubscription uses one policy for each move, for its additions and its removals.
Migrate one subscription
To move one subscription to a version that you choose, send the number of that version astargetVersionNumber.
The version can be newer or older than the version that the subscription holds.
To choose when the migration takes effect, send timing. next_period moves everything at the end
of the current period. immediate applies the rules of an immediate move. If
you do not send timing, the plan’s versionTransition applies.
subscription.
effectiveAtis the end of the current billing period. Withnext_period, the subscription bills from the new version from that instant, and the current period does not change. Withimmediate, in-advance prices change at that instant.entitlementsEffectiveAtis when the entitlements change:effectiveAtwithnext_period, and the time of the request withimmediate.- A subscription with no price timeline yet moves at once. For this subscription,
effectiveAtandentitlementsEffectiveAtare the time of the request. - A migration always sets
versionPolicytopinned. A later default version does not move the subscription. To follow the default version again, sendPATCH /v0/subscriptions/{id}with{ "versionPolicy": "floating" }. - If the subscription holds that version already, nothing moves and
changedisfalse. You can send the same request again safely. - To cancel a migration before
effectiveAt, migrate the subscription back to the version that it held. - When the subscription changes, Paygentic sends a
subscription.updated.v0webhook.
Roll back a plan
You can make any published version the default version, to a newer version or to an older version. To go back to an older price set, make the older version the default:floating subscription
goes back to version 1 from its next billing period. A pinned subscription does not change.
The older version can lack a feature that the pinned version has. The pinned subscription then keeps its entitlement and its grant for that feature.
If the version is already the default version, the request changes nothing.
What a version change does not change
- A billed period. Paygentic never recalculates a period that it has invoiced. A new version changes only the periods that start after the change.
- An invoice that exists. An issued invoice is final. See Invoices.
- A subscription that is
pinned. It changes only when you change its policy or migrate it.
What a version change keeps
These rules apply to every version change: afloating subscription that follows a new default
version, and a migration.
- A price that you set for one subscription. If you changed the rate or the quantity of a line in a price interval, the subscription keeps your value on the new version. If the new version does not sell that line, the subscription keeps the line with your value.
- A line that you removed from one subscription. If both versions sell the line, the subscription does not get it again.
- A price that you added to one subscription. An added price continues after the change, with
its
endDateif it has one.
8 would
then be 8 for each year. The same applies when the metric, the price model, or the
denomination of the line changes, or when a feature changes its reset period or its metric. A
migration returns 409. A floating subscription stays on its version until you change the
subscription or the plan.
Features and grants
Access to a feature changes exactly at the start of the new version: the end of the current period, or the move itself when the move is immediate. The version change writes the entitlement changes itself, so you do not need to reconcile the subscription.- A feature that only the new version has gets its entitlement and its grant from the start of the new version. Access starts at that instant.
- A feature that the new version does not have ends at the start of the new version. The last period before it keeps its allowance, so that period is billed against the grant it had. Access ends at that instant.
- If you change the version again before the start, the entitlements follow the last choice. A scheduled end is cleared, and a start that has not happened is removed.
- A grant for a feature that both versions have takes the allowance of the new version at its next reset.
- An entitlement whose
activeTohas passed has the statusexpired. - If you cancel an entitlement yourself after the change, Paygentic does not issue it again.
Next steps
- Plans — make a plan and its prices
- Editing prices — how a price edit reaches existing subscribers
- Price intervals — change a price for one subscription only
- Subscriptions — the subscription lifecycle