Android Question SOLVED - B4XPages Google Billing

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I've been spinning my wheels for a few days so I have to ask much as I hate to ask this question

Has anyone verified that B4XPages & Google Billing Client are working nicely together?


When I do
B4X:
BillingClient.QueryPurchases("inapp")


I get a good return code (no error message).
But there are no purchases returned (and I know there is one)

NOTE: cBBsGlobals is a Code module that contains ALL my global variables (kind of like how I use to have everything in Starter)

B4X:
Private Sub ReshowPurchases
            Wait For(cBBsGlobals.gBillingClient.ConnectIfNeeded) Billing_Client_Connected(Result As BillingResult)
          
            Dim ALLPurchases As List
              
            ALLPurchases.Initialize
          
            If     Result.IsSuccess Then              
                Wait For(cBBsGlobals.gBillingClient.QueryPurchases("inapp")) Billing_Client_PurchasesQueryCompleted(Result As BillingResult, Purchases As List)
                Log($"pSubscriptions::Query completed for inapp: ${Result.IsSuccess}   Size: ${Purchases.Size}"$)
                          
                If     Result.IsSuccess Then
                    For Each p As Purchase In Purchases
                        If     p.PurchaseState <> p.STATE_PURCHASED Then
                            Continue
                        End If
                      
                        If     cBBsGlobals.gBillingClient.VerifyPurchase(p, cBBsGlobals.gBMK) = False Then
                            Log("pSubscriptions::RestorePurchases - inapp Purchase NOT Verified")                          
                            Continue
                        End If
                      
                        Log($"pSubscriptions::RestorePurchases - inapp Purchase Acknowledged1:${p.IsAcknowledged}   ProductID:${p.Sku}"$)
                        ALLPurchases.Add(p)
                    Next
                End If
              
                Wait For(cBBsGlobals.gBillingClient.QueryPurchases("subs")) Billing_Client_PurchasesQueryCompleted(Result As BillingResult, Purchases As List)
                Log($"pSubscriptions::Query completed for subs: ${Result.IsSuccess}   Size: ${Purchases.Size}"$)
                          
                If     Result.IsSuccess Then
                    For Each p As Purchase In Purchases
                        If     p.PurchaseState <> p.STATE_PURCHASED Then
                            Continue
                        End If
                      
                        If     cBBsGlobals.gBillingClient.VerifyPurchase(p, cBBsGlobals.gBMK) = False Then
                            Log("pSubscriptions::RestorePurchases - subs Purchase NOT Verified")                          
                            Continue
                        End If

                        Log($"pSubscriptions::RestorePurchases - subs Purchase Acknowledged1:${p.IsAcknowledged}   ProductID:${p.Sku}"$)
                        ALLPurchases.Add(p)                      
                    Next
                End If              
            End If
          
            '  If AllPurchases.Size > 0 then
           '  end if

            Return              
End Sub

Log messages are
B4X:
pSubscriptions::Query completed for inapp: true   Size: 0
pSubscriptions::Query completed for subs: true   Size: 0

Using the production version I get
B4X:
aSubscriptions::Query completed for InApp: true  Size:1
aSubscriptions::RestorePurchases - Purchase Acknowledged1:true  ProductID:device_license
aSubscriptions::Query completed for Subs: true  Size:0
DoSubscriptions - DoFreeStuff


*************************************Before Billing - cBBsGlobals.gBillingClient.ConnectIfNeeded
B4XMainPage::B4XPage_Disappear
manageDisableList userId=0 what=0x0 pkg=Window{6e7dc42 u0 d0 com.BOBs.BBs/com.BOBs.BBs.main}
Focus left window: 32710
Focus entered window: 32710
setMouseIconStyle1 pointerType: 1001 iconType:101 flag:0 pid:748 uid:1000
setMouseCustomIcon IconType is same.101
*************************************Before QueryPurchases - cBBsGlobals.gBillingClient.QueryPurchases("inapp")
[12405] ikd.a(14): com.BOBs.BBs: Account from first account - [iT920ccWqp_ZWcT7g5PYn5abUYlruTLD88HEMMDpmcU]
windowGainedFocus mCurrentFocusedUserId - 0 and mSecureKeypadEnabled-false
Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@2e9e9423 attribute=null, token = android.os.BinderProxy@14d4228d
[HARDWARE_KEYBOARD] (refreshImeWindowVis) mImeWindowVis= 0 inputVisible = falsehaveHardKeyboard = false hardKeyShown = false
*************************************After QueryPurchases
 
Last edited:

Robert Valentino

Well-Known Member
Licensed User
Longtime User
WOW, finally after a lot of time looking at the unfiltered logs figured out what it was.

In the production Package Name it is com.BOBs.BBS and in my testing name I had a typo and had lower case s com.BOBs.BBs - what a wasted 2+ days.

Guess that's what can happen when you type instead of copy/paste

Sorry to waste everyone's time. Thanks for the help.

In case someone else has a similiar problem the unfiltered messages that let me find the problem were:

' Production BBs
[13644] ikd.a(12): com.BOBs.BBS: Account determined from installer data - [t89XMBqQ6c..................................]

'Testing BBs_Pages
[13640] ikd.a(14): com.BOBs.BBs: Account from first account - [iT920ccWqp_ZWc................................]
 
Upvote 0
Top