Android Question In app billing questions


Active Member
Licensed User
Hello, i have a about in app billing.

In my app i sell one item, this item can be purchased over and over.
So i have followed the in app billing tutorial and setup a managed product in google developer console.

I am using this code for testing:

If FirstTime Then
  manager.Initialize("manager", key)
  manager.DebugLogging = True
  End If

Sub Manager_BillingSupported (Supported As Boolean, Message As String)
  Log(Supported & ", " & Message)
  Log("Subscriptions supported: " & manager.SubscriptionsSupported)
  ' manager.GetOwnedProducts
End Sub

Sub manager_OwnedProducts (Success As Boolean, purchases As Map)
  If Success Then
  For Each p As Purchase In purchases.Values
  Log(p.ProductId & ", Purchased? " & (p.PurchaseState = p.STATE_PURCHASED))

         'Consume the product > raise Product Consumed
         If purchases.ContainsKey("android.test.purchased") Then
         End If

  End If
End sub

Sub manager_ProductConsumed (Success As Boolean, Product As Purchase)

   Log("product cosumed")

End Sub

'The PurchaseCompleted event will be raised when the operation completes.
Sub manager_PurchaseCompleted (Success As Boolean, Product As Purchase)

If Success = True Then
'What to do here? if i don't call productConsumed then the product cannot be purchased again.
End If

End Sub

Sub buy

manager.RequestPayment("android.test.purchased","inapp", "loadXy")

End sub

First off i want to ask if consumeproduct should called in both cases of success and failure, because if i don't call manager.ConsumeProduct(Product) then i get the error response that the product has been already owned.

I am right to think this?

Sub manager_PurchaseCompleted (Success As Boolean, Product As Purchase)

if success True Then
'Payment success give the item
'Payment failed > error message
End if

End sub

I get a bunch of errors even in google popup (0,99 fake visa) say the payment is okay, here the log:

Starting async operation: launchPurchaseFlow
Constructing buy intent for android.test.purchased, item type: inapp
requestCode = 4
** Activity (preview_grave) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
Arrived: 4, 4
Ending async operation: launchPurchaseFlow
Successful resultcode from purchase activity.
Purchase data: {"packageName":"","orderId":"","productId":"android.test.purchased","developerPayload":"loadXy","purchaseTime":0,"purchaseState":0,"purchaseToken":""}
Data signature:
Extras: Bundle[{INAPP_PURCHASE_DATA={"packageName":"","orderId":"","productId":"android.test.purchased","developerPayload":"loadXy","purchaseTime":0,"purchaseState":0,"purchaseToken":""}, INAPP_DATA_SIGNATURE=, RESPONSE_CODE=0}]
Expected item type: inapp
Purchase signature verification FAILED for sku android.test.purchased
Signature verification failed for Product ID android.test.purchased (response: -1003:Purchase signature verification failed)
Starting async operation: refresh inventory
Querying owned items, item type: inapp
Package name:
** Activity (preview_grave) Resume **
Calling getPurchases with continuation token: null
Owned items response: 0
Purchase signature verification **FAILED**. Not adding item.
  Purchase data: {"packageName":"","orderId":"","productId":"android.test.purchased","developerPayload":"loadXy","purchaseTime":0,"purchaseState":0,"purchaseToken":""}
Consuming sku: android.test.purchased, token:
Successfully consumed sku: android.test.purchased
Continuation token: null
Ending async operation: refresh inventory
I am not really familiar with all this, thanks.


Active Member
Licensed User
It is better in this case to consume the product in PurchaseCompleted event. This way you won't need to call GetOwnedProducts at all.

Is the PurchaseCompleted event raised with Success = True ?
Should be that way no? payment success = True, fail or cancel False:

I am right to think that PurchaseCompleted is raised whent the operation is complete and the payment successful?
or it is raised in both cases? user cancel for example?

The order is consumed by calling manager.ConsumeProduct(Product) which will raise the event ProductConsumed.

But product consume must be called in both cases??

Additionally i need to access the Purchase data: {} json array as i need to store on a db the order_id and the purchaseToken,
i did not test this code jet:

Dim r As Reflector
r.Target = Product Dim orderID As String = r.GetField("order_id")
r.Target = Product Dim tokenP As String = r.GetField("purchaseToken")

Thanks for your time


Active Member
Licensed User
You must handle PurchaseCompleted event. It is raised after you call RequestPayment. Lets solve the issues one by one.
Ok so the PurchaseCompleted event will return true if success and false if no.

My question is do i have to consume the product in both cases?
with product id: android.test.purchased if you dont call cosumeproduct you wont be able to buy again, however i tried with a real account and consumproduct is needed only if the payment has been made, you know something about this?
I think that android.test.purchased is bugged, or i am bugged (most probably)

Thanks for your time


Active Member
Licensed User
Ok thanks, by using android.test.purchased you need do consume the managed product in both cases or wont be able to buy.