Android Question Problem with in-app billing

welu1805

Active Member
Licensed User
Longtime User
Hi all,

I am confused with in-app billing.

I published an app in production state which contains in-app billing.

On a tablet I have several google accounts:

[email protected]
[email protected]
[email protected]

With account [email protected] I purchased my own app (not in alpha or beta test but in published production state).

Now I created a new google account: [email protected]. In the Play Store app in the menu I choosed my new account [email protected]. Then I deinstalled my app and then reinstalled it from Play Store.

With manager.GetOwnedProducts I test if the app is already purchased.

In Sub manager_OwnedProducts (Success As Boolean, purchases As Map) the result is: Yes, already purchased!!!

How could that be? Purchased with [email protected]. But with the new account [email protected] is also purchased.

Is there a possibility to get the current logged in account from B4A? I'm not really sure that is [email protected].

What is my mistake?

Lutz
 

JohnC

Expert
Licensed User
Longtime User
Could it be that both accounts are active on the device? - try removing the account (that you purchased the app from) using the "Accounts" section of the device's system settings.
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
Thanks for your reply. I don't like to remove this account generally but remove it from my tablet only. I can't find a menu item to do so ...
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
If several accounts are active on a device, which account is used for manager.GetOwnedProducts? How can I get the used account via B4A code or how can I choose the account?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
It may be different on your device, but on my device I go to "Accounts", then go into the google account I want to delete, then click the email address displayed for that account, and it should display another screen that has the "Remove Account" button/option on it.
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
I found on my device the Remove account and removed account [email protected] (from which I purchased my app). Then I deinstalled the app and reinstalled from Play Store with account [email protected]

In Sub manager_OwnedProducts (Success As Boolean, purchases As Map) the result now is: NOT purchased. That's OK.

But it becomes more and more curious:
Then I deinstalled the app again, added the old account [email protected] to my device (from which purchased) and installed from PlayStore with account [email protected]

In Sub manager_OwnedProducts (Success As Boolean, purchases As Map) the result now is: NOT purchased. That's wrong!!!

I have no idea what to do.
 
Last edited:
Upvote 0

JohnC

Expert
Licensed User
Longtime User
It may be a caching issue - try rebooting your device and make sure playstore sees your "purchased with" account, and see if the app now shows up as purchased.
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
I rebooted my tablet. In Play Store choose [email protected] (which purchased) and go to Account - Order history: "Unlocking of the DEMO of ..." - Yes, I purchased with this account!

In Sub manager_OwnedProducts (Success As Boolean, purchases As Map) the result: NOT purchased.

I have another phone where I did a factory reset. For the primary account I took [email protected] (nothing purchased).

In Sub manager_OwnedProducts (Success As Boolean, purchases As Map) the result: NOT purchased. That's ok, because NO other account is available.

Then I added the account [email protected] (which purchased my app).

Deinstall my app and reinstall from Play Store with account [email protected]: In Sub manager_OwnedProducts (Success As Boolean, purchases As Map) the result: NOT purchased!!!

In Play Store with account [email protected], Account - Order history: Again "Unlocking of the DEMO of ..." - Yes, I purchased with this account!

Is there really no possibility in manager.GetOwnedProducts to GET or SET the actual account? That is the worst case for me!!!
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
A new knowledge:

On my phone which was factory resetted: The primary account was [email protected] (nothing purchased) and an additional account [email protected] (which purchased my app). Sub manager_OwnedProducts (Success As Boolean, purchases As Map) says NOT purchased - what is wrong!

I removed [email protected], deinstalled and reinstalled my app in Play Store with the only one available account [email protected]
Sub manager_OwnedProducts (Success As Boolean, purchases As Map) says PURCHASED - OK

All very strange!!!
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
Here is an example of my code:

B4X:
Sub manager_OwnedProducts (Success As Boolean, purchases As Map)
    Dim erg As Int
   
  Log(Success)
  If Success Then
    Log(purchases)
    For Each p As Purchase In purchases.Values
      Log(p.ProductId & ", Purchased? " & (p.PurchaseState = p.STATE_PURCHASED))
        ' User purchased MyApp ?
            If p.ProductId  = MyAppID Then
                If p.PurchaseState = p.STATE_PURCHASED Then
                    ' set a flag PURCHASED in a database

                    
                    Return
                End If
        End If
    Next
  End If

  Log("not found in OwnedProducts, try to purchase")
  DoPurchase
End Sub
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
When u get the log "not purchased" log also "success" to see if the app really went trough the map loop or jumped straight to the end of the sub.

U may also log the map size.
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
So, I had a new test:

1. For clear conditions I did a factory reset of my phone again
2. First accound is [email protected] (really nothing purchased)
3. Installed MyApp from Play Store
4. manager_OwnedProducts: NOT purchased, that's OK
5. Added account [email protected] (which purchased myApp)
6. Deinstalled and reinstalled my app in Play Store with account [email protected]
7. manager_OwnedProducts: NOT purchased, that's WRONG
8. Recompiled MyApp in debug-mode and copied with b4a bridge to the phone (to see the logs)
9. Logs:
Success = True
Purchases.Size = 0

It seems, that the FIRST account on the phone (d) is used for manager_OwnedProducts, and d has nothing purchased.
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
Furthermore:

In Play Store signed in as [email protected]
In MyApp manager_OwnedProducts: NOT purchased, that's WRONG

I go to purchase MyApp. The dialogbox from Google is:

Zahlungsoptionen (payment options???)
[email protected]

That is the first account I established on the phone, not the account in Play Store!
 
Upvote 0
Top