Commerce
Mid-cycle plan proration API
Computes the unused credit on the old plan and the prorated charge for the new plan over the remaining days of a billing cycle, netting to an immediate charge or credit. Answers 'What do I owe for a mid-cycle upgrade?', 'How much credit for a downgrade?'.
Price$0.02per request
MethodPOST
Route/v1/commerce/subscription-proration
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
commercesubscriptionprorationsaasupgradedowngradebillingmid-cycle
API URL
Integration docshttps://x402.hexl.dev/v1/commerce/subscription-prorationExample request
{
"oldPlanPrice": 30,
"newPlanPrice": 90,
"cycleDays": 30,
"daysRemaining": 20
}Example response
{
"oldPlanPrice": 30,
"newPlanPrice": 90,
"cycleDays": 30,
"daysRemaining": 20,
"prorationFraction": 0.6667,
"unusedCreditFromOldPlan": 20,
"proratedNewPlanCharge": 60,
"netAmountDue": 40,
"direction": "upgrade",
"chargeOrCredit": "charge",
"interpretation": "Charge $40 now (prorated $60 for new plan, less $20 unused credit)."
}Input schema
{
"type": "object",
"required": [
"oldPlanPrice",
"newPlanPrice",
"cycleDays",
"daysRemaining"
],
"properties": {
"oldPlanPrice": {
"type": "number",
"examples": [
30
]
},
"newPlanPrice": {
"type": "number",
"examples": [
90
]
},
"cycleDays": {
"type": "integer",
"examples": [
30
]
},
"daysRemaining": {
"type": "integer",
"examples": [
20
]
}
}
}Output schema
{
"type": "object",
"additionalProperties": true
}