flutter_inapp_purchase
flutter_inapp_purchase copied to clipboard
Upgrade/Downgrade subscription not working
Version of flutter_inapp_purchase
flutter_inapp_purchase: ^5.1.2
Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git Framework • revision c860cba910 (2 weeks ago) • 2022-03-25 00:23:12 -0500 Engine • revision 57d3bac3dd Tools • Dart 2.16.2 • DevTools 2.9.2
Platforms you faced the error (IOS or Android or both?)
Android
Expected behavior
The app should create an upgrade request (as well as the upgrade UI)
Actual behavior
The app is creating a request to create a new subscription (as well as a UI for creating a new subscription), making the app have two subscriptions at the same time.
Tested environment (Emulator? Real Device?)
Emulator and Real Device
Steps to reproduce the behavior
After starting FlutterInappPuchase, with all settings and stream working:
- Purchase the subscription:
FlutterInappPurchase.instance.requestSubscription(
productId, //play console id
obfuscatedAccountIdAndroid: uuId,
);
This part works as expected.
- Upgrade the subscription:
FlutterInappPurchase.instance.requestSubscription(
productId, //play console id
oldSkuAndroid: oldProductId, //id created in step 1
obfuscatedAccountIdAndroid: uuId,
prorationModeAndroid: AndroidProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE,
);
According to the documentation: Create (request) a subscription to a sku. For upgrading/downgrading subscription on Android pass second parameter with current subscription ID, on iOS this is handled automatically by store. purchaseUpdatedListener will receive the result.
I must confess that at some point this feature stopped working. That same code worked, but now, even testing previous versions, I still couldn't upgrade/downgrade.
oldSkuAndroid
is deprecated! You need to set the purchaseTokenAndroid
from the subscription.
Please check my PR #365 if the error still exists.
For more information how to handler the proration mode check this link https://developer.android.com/google/play/billing/subscriptions
i have tried purchaseTokenAndroid but it show me failed to get data from server did you get any solution ?
i have tried purchaseTokenAndroid but it show me failed to get data from server did you get any solution ?
it worked for me i think i was sending an invalid token
FlutterInappPurchase.instance.requestSubscription(
lastPurchase.productId == 'month' ? 'year' : 'month',
purchaseTokenAndroid: lastPurchase.purchaseToken,
prorationModeAndroid: AndroidProrationMode.DEFERRED,
);
i have tried purchaseTokenAndroid but it show me failed to get data from server did you get any solution ?
it worked for me i think i was sending an invalid token
FlutterInappPurchase.instance.requestSubscription( lastPurchase.productId == 'month' ? 'year' : 'month', purchaseTokenAndroid: lastPurchase.purchaseToken, prorationModeAndroid: AndroidProrationMode.DEFERRED, );
my question is will this work on iOS or there is another way to upgrade / downgrade users plans ??
FlutterInappPurchase.instance.requestSubscription(productList[index],purchaseTokenAndroid: oldToken,prorationModeAndroid: AndroidProrationMode.DEFERRED),
I can not Upgrade/Downgrade subscription
and auto renew my subscription
This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.