EmilAlipiev / XFInAppBilling

MIT License
12 stars 3 forks source link

Upgrade/Downgrade Subscriptions #12

Closed WorldOfBasti closed 2 years ago

WorldOfBasti commented 3 years ago

Hello, I am using the InAppBilling plugin from James.. my problem is, that there isn't the possibility to upgrade/downgrade subscriptions. As I need this feature soon, is my question: Is this planned for this plugin?

EmilAlipiev commented 3 years ago

is it only for android or ios supports it as well? i think that i should take a look at the android side first there seems to be a lot of new features and updates but on ios might take them if there is also.

WorldOfBasti commented 3 years ago

That would be great! Yeah its only for Android, iOS handles it in the backend with subscription groups, so there is no implementation necessary..

EmilAlipiev commented 3 years ago

Moin Basti,

Please check the 4.0.2-alpha version. There UpdateSubscriptionsAsync is implemented but I havent tested yet. If it works fine, I will merge to stable release later. https://github.com/EmilAlipiev/XFInAppBilling/pull/19

Process is pretty complicated. Make sure you read the documentation through. Especially below lines are bit important I believe.

The Google Play Developer API returns a linkedPurchaseToken in the subscription resource. Be sure to invalidate the token provided in the linkedPurchaseToken to ensure that the old token is not used to gain access to your services. See Upgrades, downgrades, and resignups for information on handling upgrade and downgrade purchases.

The linkedPurchaseToken in the subscription resource can be used to determine which user in your subscription backend, if applicable, should be updated with the new entitlement. Your app should not rely on the user opening the app and acknowledging via BillingClient.acknowledgePurchase(), since the user might not open the app within three days of the plan change taking effect.

https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions

WorldOfBasti commented 3 years ago

Hi Emil, I'm sorry for replying so late, but I had a lot of work to do.. Thank you for the implementation, I have looked at it and tested it in the 4.0.2-alpha version and it works as expected. So if there aren't any other problems you can merge it later.. .