Platforms to show: All Mac Windows Linux Cross-Platform

/WinFrameworks/Windows Store


Required plugins for this example: MBS WinFrameworks Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /WinFrameworks/Windows Store

This example is the version from Fri, 16th Feb 2023.

Project "Windows Store.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control GetAppLicenseButton Inherits PushButton
ControlInstance GetAppLicenseButton Inherits PushButton
EventHandler Sub Action() GetAppLicenseAsync End EventHandler
End Control
Control GetStoreProductForCurrentAppButton Inherits PushButton
ControlInstance GetStoreProductForCurrentAppButton Inherits PushButton
EventHandler Sub Action() GetStoreProductForCurrentAppAsync End EventHandler
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control RequestRateAndReviewAppAsyncButton Inherits PushButton
ControlInstance RequestRateAndReviewAppAsyncButton Inherits PushButton
EventHandler Sub Action() RequestRateAndReviewAppAsync End EventHandler
End Control
Control RequestPurchaseButton Inherits PushButton
ControlInstance RequestPurchaseButton Inherits PushButton
EventHandler Sub Action() RequestPurchaseAsync End EventHandler
End Control
EventHandler Sub Open() context = New WindowsStoreContextMBS(Self) End EventHandler
Sub GetAppLicenseAsync() Log "GetAppLicenseAsync..." context.GetAppLicenseAsync AddressOf GetAppLicenseCompleted End Sub
Sub GetAppLicenseCompleted(ErrorCode as Integer, appLicense as WindowsStoreAppLicenseMBS) If ErrorCode <> 0 Then MsgBox "Windows error: "+ErrorCode.ToString Return End If List.AddRow "GetAppLicenseCompleted: "+Str(ErrorCode) Break if appLicense <> nil then log "SkuStoreId: " + appLicense.SkuStoreId Log "IsActive: " + appLicense.IsActive.YesNo Log "IsTrial: " + appLicense.IsTrial.YesNo log "TrialUniqueId: " + appLicense.TrialUniqueId Log "TrialTimeRemaining: " + CStr(appLicense.TrialTimeRemaining) end if End Sub
Sub GetStoreProductForCurrentAppAsync() Log "GetStoreProductForCurrentAppAsync..." context.GetStoreProductForCurrentAppAsync AddressOf GetStoreProductForCurrentAppCompleted End Sub
Sub GetStoreProductForCurrentAppCompleted(ErrorCode as Integer, result as WindowsStoreProductResultMBS) If ErrorCode <> 0 Then MsgBox "Windows error: "+ErrorCode.ToString Return End If List.AddRow "GetStoreProductForCurrentAppCompleted: "+Str(ErrorCode) Break if result <> nil then dim product as WindowsStoreProductMBS = result.Product if product = nil then log "no product found." else log "StoreId: " + product.StoreId log "Title: " + product.Title log "Description: " + product.Description log "Language: " + product.Language Log "FormattedPrice: " + product.Price.FormattedPrice Log "" Dim SKUs() As WindowsStoreSKUMBS = product.SKUs For Each SKU As WindowsStoreSKUMBS In SKUs Log "SKU: "+sku.StoreId Log "Title: "+sku.Title Log "Price: "+sku.Price.FormattedPrice Log "Description "+sku.Description Log "IsTrial: "+sku.IsTrial.YesNo Log "IsSubscription: "+sku.IsSubscription.YesNo Next end if end if End Sub
Sub GetStoreProductsAsync() Log "GetStoreProductsAsync..." // please change ID for the item to find Dim StoreIds() As String = Array("12345", "67890") Dim ProductKinds() As String = Array("**Application**", "**Game**", "**Consumable**", "**UnmanagedConsumable**", "**Durable**") context.GetStoreProductsAsync ProductKinds, StoreIds, AddressOf GetStoreProductsAsyncCompleted 'String value Description '**Application** ' An app that belongs To any category other than **Games**. For more info, see [Category And subcategory table](https://docs.microsoft.com/windows/uwp/publish/category-and-subcategory-table). '**Game** ' An app that belongs To the **Games** category. For more info, see [Category And subcategory table](https://docs.microsoft.com/windows/uwp/publish/category-and-subcategory-table). '**Consumable** ' A Store-managed consumable add-on that can be purchased, used, And purchased again. Microsoft keeps track Of the user's balance for these types of add-ons. '**UnmanagedConsumable** ' A developer-managed consumable add-on that can be purchased, used, And purchased again. Microsoft does Not keep track Of the user's balance for these types of add-ons; the developer is responsible for keeping track of the user's balance. '**Durable** ' An add-on that persists For the lifetime that you specify In [Partner Center](https://partner.microsoft.com/dashboard). By default, durable add-ons never expire, in which case they can only be purchased once. If you specify a particular duration for the add-on, the user can repurchase the add-on after it expires. '**Note** ' A **StoreProduct** that represents a [subscription add-on](https://docs.microsoft.com/windows/uwp/monetize/enable-subscription-add-ons-for-your-app) has the type **Durable**. End Sub
Sub GetStoreProductsAsyncCompleted(ErrorCode as Integer, result as WindowsStoreProductQueryResultMBS) If ErrorCode <> 0 Then MsgBox "Windows error: "+ErrorCode.ToString Return End If List.AddRow "GetStoreProductsAsyncCompleted: "+Str(ErrorCode) Break If result <> nil then Dim products As dictionary = result.Products Dim ProductStoreIDs() As Variant = products.Keys For Each key As Variant In ProductStoreIDs dim product as WindowsStoreProductMBS = products.Value(key) log "StoreId: " + product.StoreId log "Title: " + product.Title log "Description: " + product.Description log "Language: " + product.Language Log "FormattedPrice: " + product.Price.FormattedPrice Log "" next end if End Sub
Sub Log(s as string) List.AddRow s List.ScrollPosition = List.LastIndex End Sub
Sub RequestPurchaseAsync() Log "RequestPurchaseAsync..." // please change ID for the item to purchase Const StoreID = "9NCMFFPJRVHC" context.RequestPurchaseAsync AddressOf RequestPurchaseCompleted, StoreID End Sub
Sub RequestPurchaseCompleted(ErrorCode as Integer, result as WindowsStorePurchaseResultMBS) If ErrorCode <> 0 Then MsgBox "Windows error: "+ErrorCode.ToString Return End If Select Case result.Status Case result.kStatusSucceeded MsgBox "Purchase Succeeded." Case result.kStatusAlreadyPurchased MsgBox "Already Purchased." Case result.kStatusNotPurchased MsgBox "Not Purchased." Case result.kStatusNetworkError MsgBox "Network error." Case result.kStatusServerError MsgBox "Server error." End Select Break // see in debugger End Sub
Sub RequestRateAndReviewAppAsync() Log "RequestRateAndReviewAppAsync..." context.RequestRateAndReviewAppAsync AddressOf RequestRateAndReviewAppCompleted End Sub
Sub RequestRateAndReviewAppCompleted(ErrorCode as Integer, result as WindowsStoreRateAndReviewResultMBS) If ErrorCode <> 0 Then MsgBox "Windows error: "+ErrorCode.ToString Return End If List.AddRow "RequestRateAndReviewAppCompleted: "+str(ErrorCode) Break if result <> nil then dim status as integer = result.Status dim StatusText as string select case status case result.kStatusCanceledByUser StatusText = " CanceledByUser" case result.kStatusError StatusText = " Error" case result.kStatusNetworkError StatusText = " Network Error" case result.kStatusSucceeded StatusText = " Succeeded" else StatusText = " ?" end Select Log "Status: " + Str(result.Status) + StatusText Log "WasUpdated: " + result.WasUpdated.YesNo log "ExtendedError: " + str(result.ExtendedError) log "ExtendedJsonData: " + result.ExtendedJsonData end if End Sub
Property context As WindowsStoreContextMBS
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Module Util
Function YesNo(extends b as Boolean) As string If b Then Return "yes" Else Return "no" End If End Function
End Module
End Project

See also:

The items on this page are in the following plugins: MBS WinFrameworks Plugin.


The biggest plugin in space...