Android Question Still struggling with in App Purchase... [Solved]

MitchBu

Well-Known Member
Licensed User
I have been trying to implement the Google Play Billing service, as described in

1. I placed the Starter module from the billing example in my Check Printer Free app.
2. I added a managed In App Product Check Printer Free app in Store Presence
3. I added the Base64-encoded RSA public key in Starter, as well as app ID:


B4X:
Public const ADS_SDK_ID As String = "com.bujardet.checkprinterfree"
    Public const BILLING_KEY As String = "MIIBIjANBgkqhkiG9w0BAQEFAAOCA ... 'it is much longer. Cut to post.

When I run the app, billing is connected in Service_Create: Result.isSuccess.

However, when I try to purchase with the below, SkuDetails.size: 0 and I get "Error starting billing process".

It must be something simple, but I am at a loss. Any help will be deeply appreciated.

B4X:
    'make sure that the store service is connected
    Wait For (Starter.billing.ConnectIfNeeded) Billing_Connected (Result As BillingResult)
    If Result.IsSuccess Then
        'get the sku details
        Dim sf As Object = Starter.billing.QuerySkuDetails("inapp", Array(Starter.ADS_SDK_ID))
        Wait For (sf) Billing_SkuQueryCompleted (Result As BillingResult, SkuDetails As List)
        Log("Result.Issuccess: " & Result.IsSuccess)
        Log("SkuDetails.size: " & SkuDetails.Size)
        If Result.IsSuccess And SkuDetails.Size = 1 Then
            'start the billing process. The PurchasesUpdated event will be raised in the starter service
            Result = Starter.billing.LaunchBillingFlow(SkuDetails.Get(0))
            Log("Result.IsSuccess And SkuDetails.Size = 1")
            If Result.IsSuccess Then Return
        End If
    End If
    'ToastMessageShow("Error starting billing process", True)
    ToastMessageShow(M("ErrorStartingBillingProcess"), True)
 

MitchBu

Well-Known Member
Licensed User
Can you post the logs? Right click to copy. Make sure to run the app in debug mode.


** Service (starter) Destroy (ignored)**
*** Service (starter) Create ***
Starter.Service_Create
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Samsung device
Air motion: false
Button: false
***************************************** EN
AddMenu
** Activity (main) Resume **
Samsung device
Air motion: false
Button: false
Loadlayout Check
DeviceLanguage: |en|
LoadLayout PnlCheck.Parent = Activity true
Registerlastrow: -1
CurrentcheckNo: 0
End Placer
-InitEditTexts currentaccount Default
End Check_Click
Pnlcheck is initialized
PnlCheck.Parent = Activity true
Registerlastrow: 0
CurrentcheckNo: 1
End Placer
-InitEditTexts currentaccount Default
End Check_Click
billing connected
Query completed: true
com.bujardet.checkprinter
Result.Issuccess: true
SkuDetails.size: 0
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
Starter.Service_Create
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Samsung device
Air motion: false
Button: false
***************************************** EN
AddMenu
** Activity (main) Resume **
Samsung device
Air motion: false
Button: false
Loadlayout Check
DeviceLanguage: |en|
LoadLayout PnlCheck.Parent = Activity true
Registerlastrow: -1
CurrentcheckNo: 0
End Placer
-InitEditTexts currentaccount Default
End Check_Click
Pnlcheck is initialized
PnlCheck.Parent = Activity true
Registerlastrow: 0
CurrentcheckNo: 1
End Placer
-InitEditTexts currentaccount Default
End Check_Click
billing connected
Query completed: true
Purchase: com.bujardet.checkprinter
Result.Issuccess: true
SkuDetails.size: 0
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Samsung device
Air motion: false
Button: false
Pnlcheck is initialized
PnlCheck.Parent = Activity false
Registerlastrow: 0
CurrentcheckNo: 1
End Placer
-InitEditTexts currentaccount Default
End Check_Click
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
Starter.Service_Create
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Samsung device
Air motion: false
Button: false
***************************************** EN
AddMenu
** Activity (main) Resume **
Samsung device
Air motion: false
Button: false
Loadlayout Check
DeviceLanguage: |en|
LoadLayout PnlCheck.Parent = Activity true
Registerlastrow: -1
CurrentcheckNo: 0
End Placer
-InitEditTexts currentaccount Default
End Check_Click
Pnlcheck is initialized
PnlCheck.Parent = Activity true
Registerlastrow: 0
CurrentcheckNo: 1
End Placer
-InitEditTexts currentaccount Default
End Check_Click
billing connected
Query completed: true
com.bujardet.checkprinter
Result.Issuccess: true
SkuDetails.size: 0
 
Last edited:
Upvote 0

MitchBu

Well-Known Member
Licensed User
OK. I have two apps in the Play Store: Check Printer+ and Check Printer Free.

In Check Printer Free, in Managed Product, I created a managed app com.bujardet.checkprinterfree as unlock features.

My app never saw it.

Today, I wondered what would happen if instead, I created it in Check Printer+, the first app I put in the store.

Well, what do you know ? My app sees the managed app, and offers to buy it. My code was good, I only needed to create the managed app elsewhere. Mysteries of in app purchase.

Now, my app is in the store with the planned way to unlock all features by buying it within. Solved ! :)

I am posting this for other people struggling with in app purchase.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
You should always allow a grace period to Google. They check the In App purchase and then allow it to go on-line. Google has started resembling to Apple in the way it gets to your nerves. Regarding the restoring of the goods when you develop your app if you use Fiddler to check the communications of the app the products are not restored. You have to go on-line without the Fiddler proxy to restore the products or get inventory. Was this your case?
 
Last edited:
Upvote 0

MitchBu

Well-Known Member
Licensed User
The example billing app works just fine. I picked the Starter module from it.

If I leave the example app in there, I get the purchase dialog just fine. So the app's communication are just fine, since the devices communicate on a fast fiber network.

What is puzzling is that when I create the Check Printer free managed app in Check Printer Free (would seem logical), the app cannot see it.

If I create the managed app in Check Printer+ (the pay-for app), the app sees it fine.

What counts for me is to have found a way to reliably offer in app purchase of unlocking the app pictures.

As for Apple reviewers, one could probably write entire books about how finicky they can be...

Apple is becoming extreme in some ways. It is now mandatory to communicate in https://. And top it off, one has to get an interview in case of export of the app, because it exports encryption technology. :p
 
Upvote 0
Top