I am developing an app with android in-app subscription purchase with a self login procedure, basically which means multiple user can use single device to access app. Everything works fine as long as i use a single user in my app, but as i logout and login another user and try to do a subscription purchase it either tells me you already have this subscription or changes my subscription to new requested subscription.
This happens because previous user had a subscription which is reflecting in this user, as subscriptions/purchases are associated with the primary play store account.
So How can i manage this situation with multiple user each with a same or different subscription on a single device? Is it possible ?
Thanks in advance for help.
Related
I am new to Android / IOS apps development with React Native. I am using react-native-iap to implement in app purchases.
I want to know whether an Android / IOS single app can have both Subscription and Full Purchase Methods ?
If yes, what will happens
When user first subscribed the app, and then try to purchase the full app ? will subscription get cancelled ?
When user purchased full app and try to do a subscription ?
Thank you.
Subscriptions and "one-time-purchases" are different.
When you buy 2 subscriptions, you can manage the replacement of one by another one. Although, the behaviour is different in iOS and android:
On the Apple App Store, you have the notion of "subscription group". If you try buying another product in the same subscription group, the previous subscription will be automatically replaced by Apple (at the next renewal date for a downgrade, immediately for a crossgrade/upgrade).
On the Google Play Store, you don't have this notion and you'll have to manage the replacement by yourself (more info on this here: Allow users to upgrade, downgrade, or change their subscription)
When you want to replace a subscription by a one-time-purchase, you can manage the "replacement" manually on the Google Play Store, but not on iOS:
On Google, you have an API to cancel a subscription: use it after your user buy the "full-app"
On Apple, such API doesn't exist and the only thing you can do for now, is explaining to your user the different steps to cancel his subscription. You can help him with this deeplink: https://apps.apple.com/account/subscriptions
Opening this URL launches iTunes or iTunes Store and displays the Manage Subscriptions page where the user can upgrade, downgrade, or cancel their subscription by disabling auto-renew
Concerning the full app => subscription, I don't know. You could refund the purchase, but it would mean you would have lost money during the corresponding period of time.
I am maintaining and updating the subscription state through the real time developer notification.
When an user purchased a subscription in app, my server is called to link the purchase with the user.
Whenever user repurchases a subscription after expiry, I get a notification from Google pub-sub in my server as a "SUBSCRIPTION_PURCHASED" notification. I just don't know to which user I have to link this purchase? Since the repurchase is happening from the play store and it has no link with the app, I am unable to register the subscription to the user. Kindly please help me.
Just to clarify the different cases, even if I know that's not what you're asking for here :
whenever a subscription expires on the Play Store because of a payment issue, it enters in a grace period (if you havent deactivated this feature). If the payment method is not fixed, the subscription enters into an "account hold" period (30 days) where any payment method resolution or re-subscription will bring back the subscription. In this case, you'll receive a SUBSCRIPTION_RECOVERED S2S notification with the purchaseToken known by your server and everything should work just fine (more on this here: https://developer.android.com/google/play/billing/subscriptions#account-hold)
in your case, the user has re-purchased the subscription in another context than an "account hold", that's why you'll have an unknown purchaseToken and you won't be able to associate the subscription with any user. I'm afraid in this case, you can't do much.
The only solution for your user is to "restore" his subscription within your app. In another words, you should add a link in your Paywall which, when clicked, will retrieve the subscription from the Play Store and send them back to your server (like for a normal purchase). Your server will detect the new subscription and will linked the subscription to the correct user.
Here is an example of a Paywall with this restore link:
You could thought that it would be a good idea to always look in the Play Store for subscriptions when your app launch... and whenever your detect a subscription that isn't attached to your user, send the receipt to your server to attach the subscription to your user. It would be an error though since a same device can be used by 2 persons and one user would "steal" the subscription from the other.
I am using google in-app billing v-3 to implement auto renewal subscription process of google in my android application.
In my application user can go for different types of subscriptions, like Subs-1 for 30MB of space, Subs-2 for 90MB and so on. Now if, user chooses initially Subs-1 and then upgrades it to Subs-2, as a result now there are two simultaneous subscriptions on user's account.
I want to cancel first subscription, when second is purchased. Is there any method for the same in android code, or do I have to go for server-side implementation of the same here.
Google docs are really confusing, and I didn't find any solution there.
Yes you could use the cancel method, detailed here https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/cancel#request
All you would need is the subscription_id and token which you got when user purchased the subscription
I am developing an application with subscription feature using Inapp Billing v3.There is login mechanism to access the application. If a user 'X' subscribes to a feature and logs out. If user 'Y' logs into application in same device and if the user attempts to subscribe, Google play tells that product is already bought. Are the subscriptions based on account synced in the device and not based on the user who logged onto the application? If so how is it possible to implement my scenario?
Google Play in-app billing subscription is bound to Google Play account. So as long and Google account is not changed the subscription is considered valid for this account and you cannot purchase it one more time.
If you want to substitute Google account system with your own accounts you need to "cheat" Google Play. What you can do is to create a pool of several different in-app billing subscriptions (like subscription #1, subscription #2, etc). When you subscribe you pass your own login as an additional parameter in developerPayload field.
Now when you enumerate all available subscriptions you check if there is one with current user account in the developerPayload field. If not, then you consider that current user has no subscription and allow to subscribe using the first not used yet subscription from the pool of subscriptions (subscription #1, subscription #2, etc) you generated. Just make sure that there is number of subscriptions in your pool is bigger than number of users on the same device you could have.
It is not a straightforward way, but rather a cheat to find a workaround for your situation.
Currently google IAB supports only one account(Primary gmail account on device) on one device. But from Android 4.2 multiuser feature is available and google is working on giving same support for IAB.
Does InApp billing (V2 or V3) works for a user who uses several accounts and makes the purchase with an account that isn't the primary one?
PD: Some explanation required, no simple Yes/No
In App Billing support multiple accounts reported as a bug in code.google, have a look at it
According to Mr.Sergej (posted in G+ android dev community) in-app products purchased with the first account won't be active anymore while using multiple user accounts!.
InApp billing just charges the user and tells your app whether it was successful or not. It is up to you to figure out how to give the user what they purchased.
You can...
toggle the SharedPreferences of the app to save their purchase. Obviously multiple people can use the same app on the same device with the purchase.
provide login functionality to save a purchase to a server, in case the user deletes the app or gets a new device.
Use one-time purchases to check whether the user has purchased previously. This won't carry over to several accounts on different devices/multiple-accounts-per-device.