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.