Android Question GooglePlayBilling - Consume Purchase

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am using GooglePlayBilling v5, and got a question about consume with the purchase.

In my app I am using an in-app purchase (not subscription) and the customer may purchase the in-app purchase, it will then send an API to my B4J app to make it do something and I want the customer to repurchase it again in the future. I have this working using the GooglePlayBilling v3 but now I am trying to work out what the Consume does.

I have followed the tutorials on the forum but got a question..

From my understanding I start the in-app purchase like:
billing.LaunchBillingFlow(SkuDetails.Get(0)):
billing.LaunchBillingFlow("MySkuHere")

This will then cause it to popup asking the customer to do the in-app purchase.

If the transaction was successful then it will trigger billing_PurchasesUpdated.

(Hopefully I am correct so far.)

I can then check if the purchase was valid or not by calling:

B4X:
If billing.VerifyPurchase(p, BILLING_KEY) = True then ...

If the transaction is valid then I can call:
B4X:
If p.IsAcknowledged = False Then
   Wait For (billing.AcknowledgePurchase(p.PurchaseToken, "")) Billing_AcknowledgeCompleted (Result As BillingResult)
      Log("Acknowledged: " & Result.IsSuccess)
      ' If Result.isSuccess Then
            ' might be a good place to send the API to my B4J app ?
      ' End If
End If

I believe this will then Acknowledge the purchase in the app. (I have 3 days do to acknowledge the payment else Google will refund the customer).

However, what does the following code below do ?

B4X:
Wait For (billing.Consume(p.PurchaseToken, "")) Billing_ConsumeCompleted (Result As BillingResult)
   If Result.IsSuccess Then
      Log("consumed")
   End If

From the tutorial: Consuming a purchase removes it from the "owned" products.

Just trying to understand what consuming does if I was to call the above code after I acknowledge the in-app purchase.

Would I be correct in saying it will allow the customer to purchase the same in-app purchase again at a later time, or does it do something else ?
 

aeric

Expert
Licensed User
Longtime User
I have a demo app where I can purchase a "test" product. This test product will be available every time I open the app as long as I don't consume it.

 
Upvote 0
Top