Last active
February 16, 2017 18:46
-
-
Save jonathanpeppers/3e03bf1cb673b41e50498b04896d16a5 to your computer and use it in GitHub Desktop.
Abstract PurchaseService for IAPs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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