# Upgrade Checkout: Prorated Billing

## Overview

When a user upgrades their current subscription to a higher-tier plan **before the current cycle ends**, the system supports proration to ensure fair and transparent billing.

Instead of charging the full price of the new plan, we **calculate the remaining value of the current plan** (unused days), and **deduct it from the price of the new plan**. After payment, the user is granted the full new billing cycle from the upgrade date.

## Why Proration Is Important

Without proration, users would be required to pay the full price of the new package regardless of how much time remains in their current plan. Proration:

* Avoids overcharging users.
* Encourages mid-cycle upgrades.
* Reflects time-based value on active plans.

## Calculation Formula

```
RemainingDays = ExpiryDate - CurrentUTCDate

PricePerDayCurrent = CurrentPrice.Amount / TotalDaysCurrent
PricePerDayNew = NewPrice.Amount / TotalDaysNew

ProrationAmount = (PricePerDayNew - PricePerDayCurrent) × RemainingDays
```

### Parameters

| Name                  | Description                                      |
| --------------------- | ------------------------------------------------ |
| `CurrentPrice.Amount` | Total price of the current subscription plan     |
| `NewPrice.Amount`     | Total price of the new upgraded plan             |
| `RemainingDays`       | Number of unused days in the current cycle       |
| `TotalDaysCurrent`    | Total number of days in the current plan’s cycle |
| `RemainingValue`      | The value of unused time from the current plan   |
| `ProrationAmount`     | The amount user must pay to upgrade immediately  |

#### Example

* **Current Package**: Essentials – $20/month
* **Target Package**: Professional – $50/month
* **Remaining Days**: 10
* **Total Cycle Days**: 30

**Calculation**:

```
PricePerDayCurrent = 20 / 30 = $0.66
PricePerDayNew     = 50 / 30 = $1.67

ProrationAmount = (1.67 - 0.66) × 10 = $0.67 × 10 = $10.10
TotalPay = 50 - 10.10 = $39.9
```

→ The user only will pay $39.9 upgrade immediately. The system will activate the **Professional plan for 30 days from today**, and the Essentials plan is canceled.

### Behavior Summary

| Condition                         | Behavior                                                          |
| --------------------------------- | ----------------------------------------------------------------- |
| User upgrades early               | Remaining time of the current plan is converted to monetary value |
| A new cycle is started            | 30-day cycle begins from the upgrade date                         |
| Full features of new plan applied | Immediately after payment                                         |
| User pays only the difference     | Between new plan and remaining value of current plan              |

## Additional Notes

* **Free to Paid** upgrades are **not prorated**. Full payment for the new package is required.
* If the current plan is nearing the end of its billing cycle (e.g., 1–2 days remaining), proration may result in a minimal charge.
* The proration logic may differ depending on **subscription term** (monthly, yearly) and **custom business rules**.

***

### Benefits of This Approach

* Fair and accurate billing
* Encourages users to upgrade anytime
* No wasted value from old plan
* Simple for both users and support teams to explain


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jframework.gitbook.io/help/services/subscription/plans-and-pricing/upgrade-checkout-prorated-billing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
