Skip to content

Instantly share code, notes, and snippets.

@jonathanpeppers
Last active February 16, 2017 18:46
Show Gist options
  • Save jonathanpeppers/3e03bf1cb673b41e50498b04896d16a5 to your computer and use it in GitHub Desktop.
Save jonathanpeppers/3e03bf1cb673b41e50498b04896d16a5 to your computer and use it in GitHub Desktop.
Abstract PurchaseService for IAPs
//NOTE: to be used as a singleton in your app
public abstract class PurchaseService
{
/// <summary>
/// Retrieves the prices from iTunes or Google Play
/// </summary>
public abstract Task<Purchase[]> GetPrices(params string[] ids);
/// <summary>
/// Buys an in-app purchase
/// </summary>
public async Task Buy(Purchase purchase)
{
var receipt = await BuyNative(purchase);
//TODO: validate from our server here
}
protected abstract Task<Receipt> BuyNative(Purchase purchase);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment