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:
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?
I get a bunch of errors even in google popup (0,99 fake visa) say the payment is okay, here the log:
I am not really familiar with all this, thanks.
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:
B4X:
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
manager.ConsumeProduct(purchases.Get("android.test.purchased"))
End If
Next
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
manager.GetOwnedProducts
Log("success")
Else
Log("failed")
'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?
B4X:
Sub manager_PurchaseCompleted (Success As Boolean, Product As Purchase)
if success True Then
'Payment success give the item
Else
'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:
B4X:
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":"com.billtest.xxx","orderId":"transactionId.android.test.purchased","productId":"android.test.purchased","developerPayload":"loadXy","purchaseTime":0,"purchaseState":0,"purchaseToken":"inapp:com.billtest.xxx:android.test.purchased"}
Data signature:
Extras: Bundle[{INAPP_PURCHASE_DATA={"packageName":"com.billtest.xxx","orderId":"transactionId.android.test.purchased","productId":"android.test.purchased","developerPayload":"loadXy","purchaseTime":0,"purchaseState":0,"purchaseToken":"inapp:com.billtest.xxx:android.test.purchased"}, 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)
failed
Starting async operation: refresh inventory
Querying owned items, item type: inapp
Package name: com.billtest.xxx
** Activity (preview_grave) Resume **
Calling getPurchases with continuation token: null
Owned items response: 0
Purchase signature verification **FAILED**. Not adding item.
Purchase data: {"packageName":"com.billtest.xxx","orderId":"transactionId.android.test.purchased","productId":"android.test.purchased","developerPayload":"loadXy","purchaseTime":0,"purchaseState":0,"purchaseToken":"inapp:com.billtest.xxx:android.test.purchased"}
Signature:
Consuming sku: android.test.purchased, token: inapp:com.billtest.xxx:android.test.purchased
Successfully consumed sku: android.test.purchased
Continuation token: null
Ending async operation: refresh inventory
I am not really familiar with all this, thanks.