Dim jo As JavaObject = PurchaseItem
Dim raw As String = jo.RunMethod("getOriginalJson", null)
Dim parser As JSONParser
parser.Initialize(raw)
Dim root As Map = parser.NextObject
Dim productId As String = root.Get("productId")
Dim price As String = root.Get("price")
Dim description As String = root.Get("description")
Dim title As String = root.Get("title")
Dim mtype As String = root.Get("type")
Dim price_amount_micros As Int = root.Get("price_amount_micros")
Dim price_currency_code As String = root.Get("price_currency_code")
Dim jo As JavaObject = PurchaseItem
Dim raw As String = jo.RunMethod("getOriginalJson", null)
Dim parser As JSONParser
parser.Initialize(raw)
Dim root As Map = parser.NextObject
Dim productId As String = root.Get("productId")
Dim price As String = root.Get("price")
Dim description As String = root.Get("description")
Dim title As String = root.Get("title")
Dim mtype As String = root.Get("type")
Dim price_amount_micros As Int = root.Get("price_amount_micros")
Dim price_currency_code As String = root.Get("price_currency_code")
Thank you for your reply. unfortunately there is no price and price_currency_code in the json obtained by the purchase item. You get the price in the internal logs when the product information is obtained but not in the purchase item.
i answered after i read the link you posted... So i was coding (copy and pasting ;-)) blind.
I do not use IAB so i guess you need to wait for another answer, sorry.
Since the sku full details that includes price and currency is posted in the internal logs, is there any way the method can be exposed to access all the details. OriginalJson method only retrieves partial data. It would be great to access the price and price types since there are multiple currency transactions and getting the details means one can upload such information to the server immediately when the transaction happens and not wait for google play records to refresh.
Sometimes google play takes days to update the revenue count that's is the reason I am asking.
I've sent you an email with an updated version (v1.15).
Please try it with code similar to:
B4X:
Sub BillingManager_OwnedProducts (Success As Boolean, Purchases As Map)
If Success Then
Dim skus As JavaObject = billingManager
Dim items As List = skus.GetField("SkuDetails")
For Each sku As JavaObject In items
Log(sku.RunMethod("getSku", Null))
Log(sku.RunMethod("getPrice", Null))
Log(sku.RunMethod("getTitle", Null))
Log(sku.RunMethod("getDescription", Null))
Next
End If
End Sub
Getting the below error. I tried to use map or object but it didnt work.
B4X:
Dim items As List = skus.GetField("SkuDetails")
java.lang.ClassCastException: anywheresoftware.b4a.objects.collections.List cannot be cast to java.util.List
The new Inapp billing jar you sent, the purchase_completed sub is not called after purchasing a product. Also when I call manager.getownedproducts the second time I am getting the below error.
B4X:
starter_request_owned_products (B4A line: 579)
manager.GetOwnedProducts
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.IbHelper.queryInventoryAsync(anywheresoftware.b4a.objects.IbHelper$QueryInventoryFinishedListener)' on a null object reference
at anywheresoftware.b4a.inappbilling3.BillingManager3.GetOwnedProducts(BillingManager3.java:89)
at starter._request_owned_products(starter.java:975)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:897)
at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:831)
at main._sercheck_user_bytestoobject(main.java:5310)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA$2.run(BA.java:328)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
I'm not sure that this error is related to the change I did. Are you sure that the BillingManager was initialized properly? Make sure that it is a process global variable.
The issue was I was calling the manager in starter service. Once i moved it to the main activity everything worked fine. Since manager_OwnedProducts was called inthe service I thought the purchase would also be called but It did not.