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
See the Microsoft documentation here for details on how to test your in-app purchases
C#using CI.WSANative.Store;
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 a single product by it's id
C#WSANativeStore.RequestPurchase("id", result =>
{
if (result.Status == WSAStorePurchaseStatus.Succeeded)
{
// The purchase was successful
}
});
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;
}
});
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;
}
});
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;
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
});