- Knowledge Base
- Homa Belly SDK
- API References
Homa Belly Purchases - API Reference
Table of Content
Find below all the available classes on Homa Belly Purchases.
Product
public class Product
{
/// <summary>
/// The item ID. Usually the same as its Sku
/// </summary>
public string Id;
/// <summary>
/// Item unique identifier on the corresponding store
/// </summary>
public string Sku;
/// <summary>
/// Item title
/// </summary>
public string Title;
/// <summary>
/// Item description
/// </summary>
public string Description;
/// <summary>
/// Raw product price
/// </summary>
public float Price;
/// <summary>
/// Price string already converted to user's currency
/// </summary>
public string PriceString;
/// <summary>
/// The currency code
/// </summary>
public string CurrencyCode;
/// <summary>
/// The product type
/// </summary>
public ProductType Type;
/// <summary>
/// Holds all necessary information for a subscription product: if it is active,
/// cancelled, expired, etc...
///
/// Will be null for non-subscription products
/// </summary>
[CanBeNull] public SubscriptionInfo SubscriptionInfo;
/// <summary>
/// Determines if this product has already been purchased and it
/// is active (for example, user did not request a refund)
/// </summary>
public bool PurchaseActive;
}
SubscriptionInfo
public class SubscriptionInfo
{
/// <summary>
/// If the subscription is currently active
/// </summary>
public bool IsSubscribed;
/// <summary>
/// If the subscription has expired
/// </summary>
public bool IsExpired;
/// <summary>
/// If the subscription is cancelled
/// </summary>
public bool IsCancelled;
/// <summary>
/// If the subscription is currently under free trial period
/// </summary>
public bool IsFreeTrial;
/// <summary>
/// If the subscription will be renewed automatically
/// </summary>
public bool IsAutoRenewing;
/// <summary>
/// Time until the subscription becomes inactive or it is auto-renewed
/// </summary>
[CanBeNull] public TimeSpan? RemainingTime;
[CanBeNull] public DateTime? PurchaseDate;
[CanBeNull] public DateTime? ExpireDate;
public bool IsIntroductoryPricePeriod;
[CanBeNull] public TimeSpan? IntroductoryPricePeriod;
public long IntroductoryPricePeriodCycles;
public string IntroductoryPrice;
}
HomaStore
public static class HomaStore
{
/// <summary>
/// Invoked upon successfully store initialization
/// </summary>
public static event Action OnInitialized;
/// <summary>
/// Invoked upon failed store initialization
/// </summary>
public static event Action OnInitializeFailed;
/// <summary>
/// Invoked upon the purchase process has been initiated
/// </summary>
public static event Action<Product> OnPurchaseInitiatedForProduct;
/// <summary>
/// Invoked upon successfully product purchase
/// </summary>
public static event Action<Product> OnPurchaseSuccessForProduct;
/// <summary>
/// Invoked upon failed product purchase
/// </summary>
public static event Action<Error, Product> OnPurchaseFailedWithError;
/// <summary>
/// Invoked when the purchase process has finished, either
/// successfully or with failure. See #OnPurchaseSuccess and #OnPurchaseFailed
/// </summary>
public static event Action<Product> OnPurchaseFinishedForProduct;
/// <summary>
/// Invoked after store initialization and product fetching. Product
/// fetching happens automatically upon initialization.
/// </summary>
public static event Action<Product[]> OnProductsRetrieved;
/// <summary>
/// Invoked upon the restore purchases process has started
/// </summary>
public static event Action OnPurchasesRestoreInitiated;
/// <summary>
/// Invoked upon successfully purchases restore
/// </summary>
public static event Action<Product[]> OnPurchasesRestored;
/// <summary>
/// Invoked upon successfully subscription update
/// </summary>
public static event Action<Product> OnStoreSubscriptionUpdateSuccessWithProduct;
/// <summary>
/// Invoked upon subscription update failure
/// </summary>
public static event Action<Error, Product> OnStoreSubscriptionUpdateFailedWithError;
/// <summary>
/// Informs if the Purchaser module is initialized.
/// </summary>
public static bool Initialized
/// <summary>
/// Initialize Homa Games IAP with <c>Catalog</c> configuration.
///
/// <para>
/// Upon initialization, Homa Games IAP queries all configured products
/// in <c>Catalog</c> from the target <c>Store</c>, calling <c>OnProductsRetrieved</c>
/// when done.
/// </para>
///
/// <para>
/// Usage example:
/// <code>
/// HomaStore.OnProductsRetrieved += OnProductsRetrieved;
/// HomaStore.OnPurchaseSuccess += OnPurchaseSuccess;
/// HomaStore.Initialize();
/// </code>
/// </para>
/// </summary>
public static void Initialize();
/// <summary>
/// Obtains cached product once fetched from the store (if any).
/// This method won't request an updated product nor connect to the store
/// in any way.
/// </summary>
/// <param name="produtId">The identifier string of the product</param>
/// <returns>The cached product if any, null otherwise</returns>
[CanBeNull]
public static Product GetProduct(string produtId);
/// <summary>
/// Obtains cached products collection fetched from the store
/// upon initialization. This method won't request an updated products
/// collection from the store.
/// </summary>
/// <returns>The collection of cached products fetched from the store</returns>
[CanBeNull]
public static Dictionary<string, Product> GetProducts();
/// <summary>
/// Request a product purchase. This method triggers the
/// corresponding store process in order to purchase the given product.
/// </summary>
/// <param name="productId">The internal product ID. Can be the same than the SKU</param>
public static void PurchaseProduct(string productId);
/// <summary>
/// Request a product purchase. This method triggers the
/// corresponding store process in order to purchase the given product.
/// </summary>
/// <param name="product">The product to be purchased</param>
public static void PurchaseProduct(Product product);
/// <summary>
/// Restores all purchases from the user
/// </summary>
public static void RestorePurchases();
/// <summary>
/// Obtains if the default `NO ADS` has already been purchased
/// by this user
/// </summary>
/// <returns></returns>
public static bool IsDefaultNoAdsAlreadyPurchased();
/// <summary>
/// Requests to purchase Default No Ads IAP item
/// </summary>
public static void PurchaseDefaultNoAds();
/// <summary>
/// Updates user subscription from oldProduct to newProduct, either
/// if its an upgrader or a downgrade
/// </summary>
public UpdateSubscription(Product oldProduct,
Product newProduct,
HomaStore.HomaStoreProrationMode prorationMode =
HomaStore.HomaStoreProrationMode.UnknownSubscriptionUpgradeDowngradePolicy);
/// <summary>
/// Adds a list of products to be fetched/purchased dynamically, this is,
/// without need of previously being defined in Catalog
///
/// Use case example: obtain a new SKU from N-Testing and allow the user
/// to purchase it. This unblocks A/B Test SKUs within your game
/// </summary>
public AddDynamicProductsToCatalog(params ProductSimpleDefinition[] products);
}