Android Question In-App Subscriptions in a nutshell - Right or Wrong?

tsteward

Well-Known Member
Licensed User
Longtime User
I am trying to set up annual subscriptions. Can anyone tell my if I have the right idea or have a missed the plot please.
B4X:
Sub Process_Globals
    Dim publicKey As String
    publicKey = "MIIBI....”
    Dim SubManager As BillingManager3
    Dim Payload As String
    Dim SubsPaid As Boolean :SubsPaid = False
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")
    If FirstTime Then
        SubManager.Initialize("SubManager", publicKey)
    Else
        SubManager.GetOwnedProducts
    End If
    SubManager.DebugLogging = True
End Sub

Sub SubManager_BillingSupported (Supported As Boolean, Message As String)
    If Supported Then
          SubManager.GetOwnedProducts
    End If
End Sub

Sub SubManager_OwnedProducts (Success As Boolean, purchases As Map)
  If Success Then
      For Each p As Purchase In purchases.Values
        If p.ProductId = "subslevel1" Then
            SubsPaid = True
        End If
      Next
  End If
End Sub

Sub SubManager_PurchaseCompleted (Success As Boolean, Product As Purchase)
    If Success Then
        SubManager.GetOwnedProducts
    Else
        'failed
    End If
End Sub

Sub UpdateDB_Click
    If SubsPaid = True Then
        '… download database and do stuff
    Else
        SubManager.RequestPayment("accesslevel1", "subs", Payload)
    End If
End Sub
 
Top