Store

Allow the user to purchase your app or add ons

Calls to store functions should be wrapped in try / catch blocks as they can throw exceptions

Testing

See the Microsoft documentation here for details on how to test your in-app purchases

Reference the library

C#
using CI.WSANative.Store;

Get available add ons

Returns a collection of add ons that are available for your app. This will include Durable, Consumable and Unmanaged Consumables. It will also include products that are already owned by the user

C#
WSANativeStore.GetAddOns(response => { // All products published in the store var products = response.Products; // Iterate though all products foreach (var product in products) { // The id of the product - this can be used when purchasing it var id = product.Key; // Does the user already own this product var userOwns = product.Value.IsInUserCollection; // The product title var title = product.Value.Title; // The product description var description = product.Value.Description; // The product price var title = product.Value.FormattedPrice; // product.Value of type WSAStoreProduct contains many other useful properties about the product } });

Purchase an add on / app

Purchase a single product by it's id

C#
WSANativeStore.RequestPurchase("id", result => { if (result.Status == WSAStorePurchaseStatus.Succeeded) { // The purchase was successful } });

Consume a consumable add on

Quantity should be 1 for developer managed consumables and the amount to consume for store managed consumables

If a consumable add on is not reported as fulfilled it cannot be purchased again

Consume a consumable add on by reducing its balance by the specified amount

C#
WSANativeStore.ConsumeAddOn("id", 1, result => { if (result.Status == WSAStoreConsumableStatus.Succeeded) { // Action was successful // How many items are remaining var remainingBalance = result.BalanceRemaining; } });

Get the remaining balance for a consumable add on

Returns the remaining balance for a consumable add on

C#
WSANativeStore.GetRemainingBalanceForConsumableAddOn("id", result => { if (result.Status == WSAStoreConsumableStatus.Succeeded) { // Action was successful // How many items are remaining var remainingBalance = result.BalanceRemaining; } });

Gets license info for the current app, including licenses for add-ons

Returns license information for your app, including add ons that the user owns and trial information

C#
var license = WSANativeStore.GetAppLicense(); // Get add ons that the user owns var ownedAddOns = license.AddOnLicenses; // Is the app in trial mode var isTrial = license.IsTrial; // Does the user currently have an active license for your app var hasLicense = license.IsActive;

Get Microsoft Store listing info for the current app

Gets store listing information about your app, including detail such as its title, description and price

C#
WSANativeStore.GetAppInfo(result => { // Get the price of your app var price = result.Product.FormattedPrice; // result.Product of type WSAStoreProduct contains many other useful properties about your app });