Android Question Six questions about the NEW InAppBilling library that every one wish to know I believe

hatzisn

Well-Known Member
Licensed User
Longtime User
Hi every one,

the title of the question says it all, so I start:


1st Question: BILLING_KEY. see this code of Erel:
B4X:
    If p.Sku.StartsWith("android.test") = False And billing.VerifyPurchase(p, BILLING_KEY) = False Then
        Log("Invalid purchase")
        Return
    End If

I just want to clarify that the Billing Key is the key displayed (covered in grey) in the following picture.

upload_2019-10-9_10-19-18.png



2nd Question: Does the "inapp" displayed in the following code imply it is intented for managed products and for subscriptions we have to change it with "subs"?

B4X:
Dim sf As Object = billing.QuerySkuDetails("inapp", Array(ProductID))
Wait For (sf) Billing_SkuQueryCompleted (Result As BillingResult, SkuDetails As List)


3rd Question: See the following code:

B4X:
Wait For (billing.QueryPurchases("inapp")) Billing_PurchasesQueryCompleted (Result As BillingResult, Purchases As List)

Billing_PurchasesQueryCompleted is the event called like this because we have set the BillingClient object's event to "billing" (f.e. billing.initialize("billing"))

4th & 5th & 6th Questions: These questions derive from the same root. How do we get the inventory of the IAP?

(4th part)
Do we execute this code for each of the Product IDs?

B4X:
Dim sf As Object = Starter.billing.QuerySkuDetails("inapp", Array(Starter.ADS_SDK_ID))
        Wait For (sf) Billing_SkuQueryCompleted (Result As BillingResult, SkuDetails As List)
        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))

            'Manage SkuDetails.Get(0) for the inventory
            If Result.IsSuccess Then Return
        End If


(5th part)
Can we send in the array more product IDs? f.e.

B4X:
Dim sf As Object = Starter.billing.QuerySkuDetails("inapp", Array(productid1, productid2))

(6th part)
Why is this line of the code like this (.Size = 1)?

B4X:
"If Result.IsSuccess And SkuDetails.Size = 1 Then"


All of you that liked Erel's post in the New InApp Purchase library and Erel please share with the community your experiences. It could save time to me and to others.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I just want to clarify that the Billing Key is the key displayed (covered in grey) in the following picture.
True.

Does the "inapp" displayed in the following code imply it is intented for managed products and for subscriptions we have to change it with "subs"?
inapp - regular orders. Not subscriptions.
subs - subscriptions.

Billing_PurchasesQueryCompleted is the event called like this because we have set the BillingClient object's event to "billing" (f.e. billing.initialize("billing"))
True.

4, 5 & 6:
You can and should pass multiple ids in the array if you want to get information for multiple products.
If you pass a wrong id then the result will still be successful. This is why I checked the list size.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Thank you Erel. I think you have forgotten to add to the library a field to check if the user can make payments or am I missing something obvious here?
 
Upvote 0
Top