Private Sub manager_OwnedProducts (Success As Boolean, purchases As Map)
Starter.monthlySub = False
Starter.sixMonthlySub = False
Starter.yearlySub = False
Starter.lifeTimeSub = False
Log($"ownedProducts (purchase): ${Success}"$)
If Success Then
Log("PURCHASES: " & purchases) 'ignore
For Each p As Purchase In purchases.Values
Log(p.ProductId & ", Purchased? " & (p.PurchaseState = p.STATE_PURCHASED))
If p.ProductId = "monthly_sub" Then
If p.PurchaseState = p.STATE_PURCHASED Then Starter.monthlySub = True
Else If p.ProductId = "six_monthly_sub" Then
If p.PurchaseState = p.STATE_PURCHASED Then Starter.sixMonthlySub = True
Else If p.ProductId = "annual_sub" Then
If p.PurchaseState = p.STATE_PURCHASED Then Starter.yearlySub = True
Else If p.ProductId = "lifetime_license" Then
If p.PurchaseState = p.STATE_PURCHASED Then Starter.lifeTimeSub = True
End If
Next
End If
Starter.cOpts.updateSub("Monthly", Starter.monthlySub)
Starter.cOpts.updateSub("SixMonthly", Starter.sixMonthlySub)
Starter.cOpts.updateSub("Yearly", Starter.yearlySub)
Starter.cOpts.updateSub("Lifetime", Starter.lifeTimeSub)
If Not(Starter.monthlySub) And Not(Starter.sixMonthlySub) And Not(Starter.yearlySub) And Not(Starter.lifeTimeSub) Then
Log("No Remote Subscription")
updateButtons
End If
Private lst As List
lst.Initialize
lst.AddAll(Array As String("monthly_sub", "six_monthly_sub", "annual_sub", "lifetime_license"))
Starter.manager.GetInventoryInformation(lst)
End Sub
Private Sub manager_InventoryCompleted (Success As Boolean, Products As List)
Log(Products) 'ignore
If Success Then
For Each sk As SkuDetails In Products
Select Case sk.Sku
Case "monthly_sub"
lblMonthly.Text = $"Monthly (${sk.Price})"$
Case "six_monthly_sub"
lblSixMonthly.Text = $"Six Monthly (${sk.Price})"$
Case "annual_sub"
lblYearly.Text = $"Yearly (${sk.Price})"$
Case "lifetime_license"
lblLifeTime.Text = $"Lifetime License (${sk.Price})"$
End Select
Next
End If
End Sub
Sub manager_PurchaseCompleted(Success As Boolean, Product As Purchase)
If Success Then
Select Case Product.ProductId
Case "monthly_sub"
Starter.monthlySub = True
Starter.cOpts.updateSub("Monthly", Starter.monthlySub)
Case "six_monthly_sub"
Starter.sixMonthlySub = True
Starter.cOpts.updateSub("SixMonthly", Starter.sixMonthlySub)
Case "annual_sub"
Starter.yearlySub = True
Starter.cOpts.updateSub("Yearly", Starter.yearlySub)
Case "lifetime_license"
Starter.lifeTimeSub = True
Starter.cOpts.updateSub("Lifetime", Starter.lifeTimeSub)
End Select
ToastMessageShow("Thanks for purchasing!", False)
updateButtons
Main.newTheme = True
Else
ToastMessageShow("Purchase canceled", False)
End If
End Sub
'
Sub buy_Click
Private btn As Button = Sender
Msgbox2Async("Purchase the selected subscription?", "Subscription Purchase", "Yes", "", "No", Null, False)
Wait for MsgBox_Result(iRes As Int)
If iRes = DialogResponse.POSITIVE Then
Private tag As String = btn.Tag
If tag.Contains("sub") Then Starter.manager.RequestPayment(btn.tag, "subs", "myPets") Else Starter.manager.RequestPayment(btn.tag, "inapp", "myPets")
End If
End Sub