Purchasing products

Once the user has selected a product for purchase, we can start the checkout process.

How to do it...

When we have obtained a list of products, we can present the user with the opportunity to make a purchase. There are two ways to make a purchase, either using a Product instance or just the product ID:

  1. The QueryInventoryAsync() method returns a list of:
    var products = await billing.QueryInventoryAsync(
      new [] { "managed.one" }, ItemType.Product);
    var product = products[0];
    billing.BuyProduct(product);
    
  2. This method also has an overload that accepts a string payload that will be included with any server responses:
    billing.BuyProduct(product, "DeveloperPayload");
  3. Another way to purchase a product is to simply pass the product ID to the ...

Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.