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
}