Xamarin Releases Android In-App Billing Component

Posted on Dec 6, 2013

Xamarin just released a new component that makes it easy to include Google Play In-App Billing support into a Xamarin.Android mobile application. Get a copy of the component here: http://components.xamarin.com/view/xamarin.inappbilling 

About Xamarin.InAppBilling

In-app Billing is a Google Play service that lets you sell a wide range digital content such as new game levels, downloadable media, or premium features directly from inside your Xamarin.Android mobile application. These purchases can either be standard, one-time billed products or recurring, automatically billed subscriptions.

The Xamarin.InAppBilling component simplifies the process of supporting In-App Billing (Version 3 API) by reducing the amount of common, repetitive code required and by adding several useful, helper functions.

About Xamarin.InAppBilling

In-app Billing is a Google Play service that lets you sell a wide range digital content such as new game levels, downloadable media, or premium features directly from inside your Xamarin.Android mobile application. These purchases can either be standard, one-time billed products or recurring, automatically billed subscriptions.

The Xamarin.InAppBilling component simplifies the process of supporting In-App Billing (Version 3 API) by reducing the amount of common, repetitive code required and by adding several useful, helper functions.

Features

Xamarin.InAppBilling supports the following features:

  • Connect – Attaches your Xamarin.Android app to Google Play to process In-App Purchases.

  • QueryInventoryAsync – Given a list of product IDs, this routine will return all available products matching those IDs not already purchased by the current user.

  • GetPurchases – Returns a list of all purchases made by the current user.

  • BuyProduct – Calls Google Play to purchase the given product.

  • ConsumePurchase – Given a purchased product, this routine informs Google Play that the given product has been consumed and is available for purchase again.

  • Disconnect – Unbinds from Google Play when your Activity ends.

Events

Xamarin.InAppBilling defines the following events that you can monitor and respond to:

  • OnConnected – Raised when the component attaches to Google Play.

  • OnDisconnected – Raised when the component detaches from Google Play.

  • OnInAppBillingError – Raised when an error occurs inside the component.

  • OnProductPurchasedError – Raised when there is an error purchasing a product or subscription.

  • OnProductPurchase – Raised when a product is successfully purchased.

  • OnPurchaseConsumedError – Raised when there is an error consuming a purchase.

  • OnPurchaseConsumed – Raised when a purchase is successfully consumed.

Secure Transactions

When developing Xamarin.Android applications that support In-App Billing there are several steps that must be taken to protect your app from being hacked by a malicious user and keep unlocked content safe (See Google’s Security and Design for more details).

While the best practice is to perform signature verification on a remote server and not on a device, this might not always be possible. Another technique is to obfuscate your Google Play public key and never store the assembled key in memory.

Xamarin.InAppBilling provides a quick and simple method to break your public key into a several pieces and to obfuscate those pieces. Once a public key has been provided to Xamarin.InAppBilling it is never stored as plain text, it is always encrypted in memory.