B4X:
I want the user to buy the item as many times as he wants because he buy a service inside my app but i am receiving in my test account an error "Unable to buy item, Error response: 7:Item Already Owned". When he purchase the the item the variable CanPrint must become true and after he can use the service. Any advice please? Thank you!
Sub Process_Globals
Private sqlRecords As SQL
Private Key As String = "...."
Private developerPayload As String = "MyApp"
Private canPrint As Boolean = False
Private manager As BillingManager3
End Sub
Sub Activity_Create(FirstTime As Boolean)
If(FirstTime) Then
manager.Initialize("purchase", Key)
printer.Initialize("")
End If
manager.DebugLogging = True
End sub
Sub fabExport_Click
manager.RequestPayment("export", "inapp", DeveloperPayload)
If canPrint = True Then
print("Report.pdf")
End If
End Sub
Sub manager_PurchaseCompleted(Success As Boolean, Product As Purchase)
If Success Then
manager.ConsumeProduct(Product) '******************
End If
End Sub
Sub manager_ProductConsumed (Success As Boolean, Product As Purchase)
Log("product consumed: " & Product.ProductId)
If Product.Productid.Contains("export") Then
canPrint = True
End If
End Sub
Sub manager_OwnedProducts (Success As Boolean, purchases As Map)
Log(Success)
If Success Then
Log(purchases)
For Each p As Purchase In purchases.Values
Log(p.Productid & ", Purchased? " & (p.PurchaseState = p.STATE_PURCHASED))
Next
End If
End Sub
Sub manager_BillingSupported (Supported As Boolean)
Log(Supported)
Log("Subscriptions supported: " & manager.SubscriptionsSupported)
If Supported Then
manager.GetOwnedProducts
End If
End Sub