public Sub HandleAdsPurchase (p As Purchase)
If p.PurchaseState <> p.STATE_PURCHASED Then Return
'Verify the purchase signature.
'This cannot be done with the test id.
If p.Sku.StartsWith("android.test") = False And billing.VerifyPurchase(p, BILLING_KEY) = False Then
Log("Invalid purchase")
Return
End If
If p.IsAcknowledged = False Then
'we either acknowledge the product or consume it.
Wait For (billing.AcknowledgePurchase(p.PurchaseToken, "")) Billing_AcknowledgeCompleted (Result As BillingResult)
If Result.IsSuccess Then
If p.Sku = ADS_SDK_Token Then
Wait For (billing.QueryPurchases("inapp")) Billing_PurchasesQueryCompleted (Result As BillingResult, Purchases As List)
myLog.Add($"(HandleAdsPurchase) Info received from PS Result - ${Result.ResponseCodeString}"$)
If Result.IsSuccess Then
B4XPages.MainPage.Pages.PagePINCalc.sendPINRequest(Purchases,p.OrderId)
End If
End If
End If
Else
If p.Sku = ADS_SDK_ID Or p.Sku = ADS_SDK_ID2 Or p.Sku = ADS_SDK_ID3 Then
productID = p.OrderId
purchaseTime = p.PurchaseTime
SKU_Purchased = p.Sku
token = p.PurchaseToken
subsID = p.Sku
Main.AppSubscriptionActive = True
Main.OKToPost = True
Else
productID = ""
Main.AppSubscriptionActive = False
Main.OKToPost = False
End If
End If
End Sub