> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.qonversion.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Upgrade and Downgrade in Google

> When upgrading or downgrading a subscription, you can set the update policy, or how the change affects your subscribers. The following table lists available update policies:

| Name                  | Description                                                                                                                                                                              |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ChargeFullPrice`     | The new plan takes effect immediately, and the user is charged full price of new plan and is given a full billing cycle of subscription, plus remaining prorated time from the old plan. |
| `ChargeProratedPrice` | The new plan takes effect immediately, and the billing cycle remains the same.                                                                                                           |
| `WithTimeProration`   | The new plan takes effect immediately, and the remaining time will be prorated and credited to the user.                                                                                 |
| `Deferred`            | The new purchase takes effect immediately, the new plan will take effect when the old item expires.                                                                                      |
| `WithoutProration`    | The new plan takes effect immediately, and the new price will be charged on next recurrence time.                                                                                        |

Upgrading, downgrading, or changing a subscription on the Google Play Store requires calling the `purchase()` function with `setOldProduct` purchase options.

See [Google Play Documentation](https://developer.android.com/google/play/billing/subscriptions#upgrade-downgrade) for more details.

Use Qonversion SDK for upgrading, downgrading, or changing Google Play Store subscription:

<CodeGroup>
  ```java Java theme={null}
  final QPurchaseOptions purchaseOptions = new QPurchaseOptions.Builder()
          .setOldProduct(oldProduct)
          .build();
  Qonversion.getSharedInstance().purchase(this, product, purchaseOptions, new QonversionPurchaseCallback() {
      @Override
      public void onResult(@NonNull QPurchaseResult result) {
          if (result.isSuccessful()) {
              QEntitlement premium = result.getEntitlements().get("premium");
              if (premium != null && premium.isActive()) {
                  // Grant user access to premium features
              }
          } else if (result.isCanceledByUser()) {
              // Handle canceled purchase
          } else if (result.isPending()) {
              // Handle pending purchase
          } else {
              // Handle errors
          }
      }
  });
  ```

  ```kotlin Kotlin theme={null}
  val purchaseOptions = QPurchaseOptions.Builder()
      .setOldProduct(oldProduct)
      .build()
  Qonversion.shared.purchase(this, product, purchaseOptions, object : QonversionPurchaseCallback {
      override fun onResult(result: QPurchaseResult) {
          when {
              result.isSuccessful -> {
                  val premium = result.entitlements["premium"]
                  if (premium != null && premium.isActive) {
                      // Grant user access to premium features
                  }
              }
              result.isCanceledByUser -> {
                  // Handle canceled purchase
              }
              result.isPending -> {
                  // Handle pending purchase
              }
              else -> {
                  // Handle errors
              }
          }
      }
  })
  ```

  ```dart Flutter theme={null}
  // Build purchase options with old product for upgrade/downgrade
  final options = QPurchaseOptionsBuilder()
      .setOldProduct(oldProduct)  // Product to upgrade from
      .setUpdatePolicy(QPurchaseUpdatePolicy.chargeFullPrice)  // Optional: update policy
      .build();

  final QPurchaseResult result = await Qonversion.getSharedInstance().purchaseWithResult(
    newProduct,
    purchaseOptions: options,
  );

  if (result.isSuccess) {
    final premium = result.entitlements?['premium'];
    if (premium != null && premium.isActive) {
      // User successfully upgraded to new subscription
    }
  } else if (result.isCanceled) {
    // Handle canceled upgrade
  } else if (result.isPending) {
    // Handle pending upgrade
  } else {
    // Handle errors
  }
  ```

  ```typescript React Native theme={null}
  // Build purchase options with old product for upgrade/downgrade
  const options = new PurchaseOptionsBuilder()
    .setOldProduct(oldProduct)  // Product to upgrade from
    .setUpdatePolicy(PurchaseUpdatePolicy.CHARGE_FULL_PRICE)  // Optional: update policy
    .build();

  const result: PurchaseResult = await Qonversion.getSharedInstance().purchaseWithResult(
    newProduct,
    options,
  );

  if (result.isSuccess) {
    const premium = result.entitlements?.get('premium');
    if (premium && premium.isActive) {
      // User successfully upgraded to new subscription
    }
  } else if (result.isCanceled) {
    // Handle canceled upgrade
  } else if (result.isPending) {
    // Handle pending upgrade
  } else {
    // Handle errors
  }
  ```

  ```csharp Unity theme={null}
  // Build purchase options with old product for upgrade/downgrade
  var options = new PurchaseOptionsBuilder()
      .SetOldProduct(oldProduct)  // Product to upgrade from
      .SetUpdatePolicy(PurchaseUpdatePolicy.ChargeFullPrice)  // Optional: update policy
      .Build();

  Qonversion.GetSharedInstance().Purchase(newProduct, options, (result) =>
  {
      if (result.IsSuccess)
      {
          if (result.Entitlements != null &&
              result.Entitlements.TryGetValue("premium", out var premium) &&
              premium.IsActive)
          {
              // User successfully upgraded to new subscription
          }
      }
      else if (result.IsCanceled)
      {
          // Handle canceled upgrade
      }
      else if (result.IsPending)
      {
          // Handle pending upgrade
      }
      else
      {
          // Handle errors
      }
  });
  ```

  ```typescript Cordova theme={null}
  // Build purchase options with old product for upgrade/downgrade
  const options = new Qonversion.PurchaseOptionsBuilder()
    .setOldProduct(oldProduct)  // Product to upgrade from
    .setUpdatePolicy(PurchaseUpdatePolicy.CHARGE_FULL_PRICE)  // Optional: update policy
    .build();

  const result = await Qonversion.getSharedInstance().purchase(
    newProduct,
    options,
  );

  if (result.isSuccess) {
    const premium = result.entitlements?.get('premium');
    if (premium && premium.isActive) {
      // User successfully upgraded to new subscription
    }
  } else if (result.isCanceled) {
    // Handle canceled upgrade
  } else if (result.isPending) {
    // Handle pending upgrade
  } else {
    // Handle errors
  }
  ```

  ```typescript Capacitor theme={null}
  // Build purchase options with old product for upgrade/downgrade
  const options = new PurchaseOptionsBuilder()
    .setOldProduct(oldProduct)  // Product to upgrade from
    .setUpdatePolicy(PurchaseUpdatePolicy.CHARGE_FULL_PRICE)  // Optional: update policy
    .build();

  const result = await Qonversion.getSharedInstance().purchase(
    newProduct,
    options,
  );

  if (result.isSuccess) {
    const premium = result.entitlements?.get('premium');
    if (premium && premium.isActive) {
      // User successfully upgraded to new subscription
    }
  } else if (result.isCanceled) {
    // Handle canceled upgrade
  } else if (result.isPending) {
    // Handle pending upgrade
  } else {
    // Handle errors
  }
  ```
</CodeGroup>

***

[Publish your Android App](app-publication-in-google-play-console)

[Sample Apps](sample-apps)
