O'Reilly logo

Xamarin Mobile Development for Android Cookbook by Matthew Leibowitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required