Solved

Upgrading and Downgrading

  • 15 December 2021
  • 2 replies
  • 353 views

Badge +2

Please assist as I am a bit lost:

I am trying to wrap my head around upgrading and downgrading users, however I am not dure how to actuallky do this. 

I am aware the documents say:  that you need to pass the UpgradeInfo object to either purchaseProduct or purchasePackage

Where do I get this  UpgradeInfo ? 

I am using flutter.

Applogies for the noob question.

icon

Best answer by Riccardo Busato 16 December 2021, 20:47

View original

2 replies

Badge +2

I think i figured it out.

For anyone who is also confused, this helped me:

(I am using flutter)

static Future<bool> purchase(Package package) async {

try{

//this gets the packages currently subscribed to
PurchaserInfo purchaserInfo = await Purchases.getPurchaserInfo();

//then we take the entitlement id and add that into the upgradeInfo

PurchaserInfo purchase = await Purchases.purchasePackage(package,upgradeInfo: UpgradeInfo(purchaserInfo.activeSubscriptions[0],prorationMode: ProrationMode.immediateWithTimeProration));

return true;

} on PlatformException catch (e) {
var errorCode = PurchasesErrorHelper.getErrorCode(e);
if (errorCode == PurchasesErrorCode.purchaseCancelledError) {
print("User cancelled");
} else if (errorCode == PurchasesErrorCode.purchaseNotAllowedError) {
print("User not allowed to purchase");
} else if (errorCode == PurchasesErrorCode.configurationError) {
print("Config error");
print(e);
}

return false;
}

//Note this is only for one subscription at a time
}

 

I’m facing the same problem. I’m using React Native.

I have two different base plans with one offer each. Monthly and Yearly with 14 days trial respectively.

On iOS users have the option to tap on manage subscriptions where they have the option to switch to other subscription. For Example Monthly to Yearly and vice versa.

However, I’m not sure how to have the same option for the Android users. I have created a Paywall where users can view the name of their existing subscription. When they click on manage subscription they are redirected to the Play Store where they can view details of their subscription along with details.

Problem:

  • I want to allow my subscribers to switch (upgrade / downgrade) their subscription.
  • If they are monthly subscriber i will show them “Upgrade” button and vice versa.
  • I’m not able to find any tutorial or documentation which tells how to actually implement upgrade/downgrade and how and where exactly should I use  UpgradeInfo .

Apologies in advance for my amateur question.

Any help would be highly appreciated.

 

 

Reply