flutter_inapp_purchase icon indicating copy to clipboard operation
flutter_inapp_purchase copied to clipboard

Upgrade/Downgrade subscription not working

Open drikanius opened this issue 2 years ago • 6 comments

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:

  1. Purchase the subscription:
    FlutterInappPurchase.instance.requestSubscription(
      productId, //play console id
      obfuscatedAccountIdAndroid: uuId,
    );

This part works as expected.

  1. 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.

drikanius avatar Apr 11 '22 15:04 drikanius

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

offline-first avatar May 23 '22 07:05 offline-first

i have tried purchaseTokenAndroid but it show me failed to get data from server did you get any solution ?

AhmedAbogameel avatar Jun 07 '22 22:06 AhmedAbogameel

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,
    );

AhmedAbogameel avatar Jun 07 '22 23:06 AhmedAbogameel

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 ??

AhmedAbogameel avatar Jun 07 '22 23:06 AhmedAbogameel

    FlutterInappPurchase.instance.requestSubscription(productList[index],purchaseTokenAndroid: oldToken,prorationModeAndroid: AndroidProrationMode.DEFERRED),

I can not Upgrade/Downgrade subscription

chhsh122 avatar Aug 22 '22 08:08 chhsh122

and auto renew my subscription

chhsh122 avatar Aug 22 '22 08:08 chhsh122

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.

github-actions[bot] avatar Nov 21 '22 00:11 github-actions[bot]