Sub Class_Globals
Dim manager As BillingManager3
Public products,idlist,prices As List
Public googleplayid As String
Public title As String
Public purchasedids As List
Public callingmod As Object
Public storeready As Boolean
End Sub
Public Sub Initialize(callingmodule As Object,googleid As String)
callingmod=callingmodule
googleplayid=googleid
misc.LogM("initializing key="&googleplayid)
manager.Initialize("manager", googleplayid)
manager.DebugLogging = True
End Sub
Sub Purchase_Item(id As String, payload As String)
Try
manager.RequestPayment(id,"subs",payload)
Catch
misc.ProApp("Billing Crash")
End Try
End Sub
Sub Simulate_Purchase_Item(id As String, payload As String)
Dim p As Purchase
manager_PurchaseCompleted (True, p)
End Sub
Sub Start_Store(storetitle As String, image As String)
title=storetitle
CallSubDelayed3(StoreActivity,"Start_Store", title,image)
End Sub
#Region Billing
Sub Manager_BillingSupported (Supported As Boolean, Message As String)
misc.LogM("in store class")
misc.LogM(Supported & ", " & Message)
' misc.LogM("Subscriptions supported: " & manager.SubscriptionsSupported)
storeready=Supported
Try
If Supported Then
manager.GetOwnedProducts
Else
CallSubDelayed(callingmod,"No_Purchased_Features")
End If
Catch
CallSubDelayed(callingmod,"No_Purchased_Features")
Log(LastException.Message)
End Try
End Sub
Sub manager_OwnedProducts (Success As Boolean, purchases As Map)
misc.LogM(Success)
storeready=Success
Dim purchasesAvailable As Boolean
purchasedids.Initialize
If Success Then
misc.LogM(purchases)
Try
For Each p As Purchase In purchases.Values
misc.LogM(p.productid & ", Purchased? " & (p.PurchaseState = p.STATE_PURCHASED))
purchasedids.Add(p.DeveloperPayload)
'payload=p.DeveloperPayload
'productid=p.productid
If p.PurchaseState = p.STATE_PURCHASED Then purchasesAvailable=True
Next
Catch
purchasesAvailable=False
Log(LastException.Message)
End Try
End If
If purchasesAvailable Then
CallSubDelayed2(callingmod,"Enable_Purchased_Features",purchasedids)
Else
CallSubDelayed(callingmod,"No_Purchased_Features")
End If
End Sub
Sub manager_PurchaseCompleted (Success As Boolean, Product As Purchase)
' LogColor("manager_PurchaseCompleted storeclass "&Success,Colors.Yellow)
If Not(purchasedids.IsInitialized) Then purchasedids.Initialize
If Success Then
purchasedids.Add(Product)
Main.adsenabled=False
CallSubDelayed(StoreActivity,"btnBack_Click")
CallSubDelayed2(callingmod,"Enable_Purchased_Features",purchasedids)
End If
End Sub