Listing available products
We need to present the details about what products or subscriptions are available for purchase so that the users can verify what they want before making any purchases.
How to do it...
We can request a list of Product
instances using the QueryInventoryAsync()
method:
- The
QueryInventoryAsync()
method returns the product details when invoked with the desired product IDs and theProduct ItemType
instance:var productIds = new string[] { "managed.one", "managed.two" }; var products = await billing.QueryInventoryAsync( productIds, ItemType.Product);
- If we have any subscriptions, we can repeat the same process but we will use the
Subscription ItemType
type this time:var productIds = new string[] { "subscription.one" }; var subscriptions = await billing.QueryInventoryAsync( productIds, ItemType.Subscription);
- Similar to do the process for all the requests, errors may occur, such as when there is no connectivity. We can respond to these...