switchPlan method

Future<bool> switchPlan(
  1. LinkFivePlan oldLinkFivePlan,
  2. LinkFiveProductDetails productDetails, {
  3. ProrationMode? prorationMode,
})

Handles the Up and Downgrade of a Subscription plans

oldPurchaseDetails given by the LinkFive Plugin

You can pass linkFiveProductDetails or productDetails. But one must be present.

linkFiveProductDetails productDetails from the purchases you want to switch to prorationMode Google Only: default replaces immediately the subscription, and the remaining time will be prorated and credited to the user. Check https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.ProrationMode for more information

Implementation

Future<bool> switchPlan(LinkFivePlan oldLinkFivePlan, LinkFiveProductDetails productDetails,
    {ProrationMode? prorationMode}) async {
  makeSureIsInitialize();
  if (Platform.isAndroid) {
    return handleAndroidSwitchPlan(oldLinkFivePlan, productDetails, prorationMode: prorationMode);
  }
  if (Platform.isIOS) {
    return handleIosSwitchPlan(productDetails);
  }
  return false;
}