No updates when Google in-app purchase flow continues on another device - android

I'm developing a react-native app that targets Android TV and tvOS. Using react-native-iap I've have successfully added support for Google Play inapp products and latest subscription model (billing API 5.0.0).
Purchase updates are received and handled perfectly well in all test scenarious except when I'm testing the "More payment options" flow, which expects the user to continue the purchase flow an another device. In this scenario the user is able to pick up the purchase flow from a desktop browser, or on an Android mobile device, and then choose to pay with "Slow test card approved after a few minutes". However, after completing the payment I can't see that we ever receive updates on PurchasesUpdatedListener. Calling RNiap.getAvailablePurchases() (equivalent to BillingClient.queryPurchasesAsync()) also returns an empty list!
Has anybody come across this issue before? Is it a development environment problem or does it happen for real/end users as well?
Worth mentioning is that meanwhile the "slow card payment" is being processed I'm also exiting the purchase UI on Android TV (by pressing back button), in order to re-activate the app so it can check for purchase updates.
I was able to reproduce this problem with Google's sample app TrivialDriver, https://github.com/android/play-billing-samples/tree/main/TrivialDriveKotlin, so I don't think there's an issue with react-native-iap.
Thanks!

Related

Flutter in_app_purchase . Get active Google Play subscriptions

I'm new to flutter. I want to check if user already has active GP subscription when my app starts.
In native I could use 'queryPurchasesAsync' for that, and I could check sub status even in offline-mode (Google Play cache).
But in Flutter I have only purchaseStream with purchaseDetailsList. It works after making purchase, but after restarting the app (even if I use InAppPurchase.instance.restorePurchases()) purchaseDetailsList length is 0 even though the subscription is active.
The package documentation lists all the examples except this one, although this is needed for any application with subscriptions.
How can I fix it?

Best way to start an app in Free or Pro mode

I have an Android app and I also offer 1 inapp purchase to unlock such app to the Pro version.
I know how to do use the inapp purchase API and such but I found discordant ways on how to check if the app should start as Free or Pro.
Many people suggest that after a successful purchase the app should store the Google Play receipt or other information in a local database and let the app check the presence of that information at startup (in order to start properly as Free or Pro)
My question is, instead of bothering saving the purchase information and retrieving it from a local database why not calling the restore purchase API RestorePurchases(), have a look at the returned object if the InApp item is present and unlock the app accordingly?
As far as I know the call doesn't require internet connection, it's just a local call to the local Google Play authority... am I missing something?
Let me explain how we manage it at QuitNow!, an app with the same behavior than yours.
We only have one SKU called unlock_all_pro_features. If the user has it, it means that the user bought the PRO features before.
So, in the Android side, everytime the app is started we try connecting to IInAppBillingService. When onServiceConnected() is called, we ask it for all the user owned SKU's. If it has our lovely SKU, we store in a SharedPreference that the user was a PRO one. And then, if it wasn't PRO before doing all this magic, we update the screen to show the brand new features.
Bad things there: the user can return the SKU!
To face that, when we consider that a user was a PRO one, we also ask if the user has the needed SKU. If that check fails 20 times, we reset the features to the FREE version.
Why checking it 20 times instead of just one time? Sometimes, we found that the service said that the user had any SKU, while he actually had the PRO one. Why? Don't know. So, checking it 20 times is a simple way to assure that we don't kick PRO users when unneded.

Android consumable: "already own that item" but inventory.hasPurchase() is false

I'm stuck with Google In App v3 - I tested a purchase without consumption (e.g. when app crashes between buying and consuming) - now I don't find a way out.
If I try to buy again, it says 'you already own that item'. But when I test for ownership, it says I don't own it:
Inventory inv = mHelper.queryInventory(false, null);
inv.getPurchase(sku); // null
inv.hasPurchase(sku); // false
I can't consume something either, as I don't have a purchase to consume. How to proceed here?
EDIT
Reproduce it like the following: purchase in-app consumable, then disable internet connection. After that, you're not able to purchase the product again for some hours. Just tested with a popular app from the play store (Diamond Digger Saga), I had the exact same behaviour. Is there really no possibility to avoid/solve this?
I ran into this exact problem. I had two Google accounts on the phone, one which was the developer account (which I foolishly used my personal account for) and another which was the test account I registered in the developer console. I had removed and re-added the developer account from my accounts on the phone, which allowed me to make test-purchases from my app, thinking if the developer account was the second on this list it would use the first for purchases.
Alas, after a couple of runs of the app I ran into your issue. I gave up trying to have both and removed the developer account from my phone. While incredibly inconvenient, this got rid of this problem and allowed me to test purchase, consume, query, etc.
If you are doing everything correctly and your code is ok - most likely the problem is in cached Google Play Services data.
For example when you make a test purchase on your device A - on your device B (with the same Google account logged in) you will keep receiving inventory without your purchase for some time. And your inventory.getPurchase(sku) will return null and inventory.hasPurchase(sku) will return false;
To fix this try to open Google Play and close it using Recent Apps button (click it and then swipe the app away) this will terminate the app faster than usual "back" button. Then turn your device off for couple of minutes.
Our goal here is to make Google Play to update it's cache.
Be sure that you're on wifi because it may update rarely if you're on mobile data.
Eventually data will be updated and you will get your purchase.
In my case it happened after 5 minutes or smth.

intermittent erros with android (google play) in-app purchase

Some people trying to do in-app purchase within my Android game report that they can never complete the purchase -- that they always get an error message. (I.e., The market app reports an error to my application, and I show the user this error.)
Unfortunately, I don't have any real log data for this one, because it only happens for certain customers of my game, not for me.
What's strange is that after updating to a new version of the app, for some users the problem goes away, and for some users the problem starts. So user A might have the problem in version 1 of the app, but it clears up when they update to version 2. User B might not have the problem in version 1, but it appears when they update to version 2.
I say "intermittent" above, but by that I mean that it only seems to affect a small number of users. But for any given user, once they get in this state, they seem to get the message all the time. HOWEVER, I have had some cases where the problem does clear up suddenly, without an app update. I'm not sure if, for instance, power cycling, or, say, making an in-app-purchase in another app is away to "break out" of this state.
I realize that without a specific error message or API call to name/blame, this question is difficult to answer. I'm just trying to understand if this pattern -- of some users mysteriously getting stuck in a state where they are unable to make any in-app-purchase within a given app -- sounds familiar to anyone for Google Play in-app-purchase.
Also, I build my apps on top of Marmalade, so it's possible that the problem is in the Marmalade layer, not in my app or in the Google Play market itself.
The same problem here: a lot of users can buy items in my app but some users send me emails complaining why they can't buy considering that they can successful purchase items in other apps. I think it occurs because of a temporary problem on the Google Play server or is something to do with the service on Android. I am still looking for an answer to this weird problem...

Android In-App purchase issue

I'm experiencing a weird problem after we've submitted our first app on the Android Market. The app has a in-app purchasing feature which have been fully tested before the release (or at least I thought so).
I'm aware that similar questions might already exists, but I haven't found them and it's quite difficult to describe my problem with only a few words.
The problem appears when a user:
a) downloads our app from Android Market
b) opens the app after download through the OPEN link in Android Market
c) starts a purchase which takes the user back to Android Market.
d) either cancels or completes the purchase
Then:
Instead of returning to our app, the user returns to Android Market (which displays an description of our app with a button to open the app etc). In the LogCat an Response Code is sent from Android Market to the Purchase Observer, but our app (now being in the background) doesn't receive the code and therefor stalls, forever waiting for a response from Android Market. So it's actually two problems, because it's not intentional that the user should return to the Android Market screen after purchasing - our app should be before Market in the history.
Everything works correctly if the user opens our app outside Android Market (e.g. the Home screen). The observer receives either the cancel or complete Response Code.
We've used Google's own In-App Billing example as our foundation.
I hope this is somewhat understandable.
Thanks in advance
All right, I finally found the answer myself.
I'll try to explain the solution without using any code :)
The PurchaseObserver instance is only available when my activity is active - but it's not active, in the example described above. I made the mistake to think that the PurchaseObserver is where the order should be saved in the database - only to find out that you cannot be certain that the PurchaseObserver exists when a purchase is made. Instead, I now only use the Observer to change the UI and then handle the order information and the database through the ResponseHandler, which always gets called when an purchase has been made in Android Market.
I still think it's odd the user gets thrown back to Android Market instead of our app when an purchase is made (only when the user starts the app through Android Market), but I cannot seem to find an solution or explanation for this.
This is btw impossible to test or reproduce the problem, without having the app on Android Market - so I hope this explanation can help you guys not make the same mistake I've made ;)

Categories

Resources