/// <summary>
 /// This method begins a purchase request.
 /// </summary>
 /// <param name="product">product which you must specify in the application's product list on the Google Play Console.</param>
 /// <param name="developerPayload">
 /// A developer-specified string that contains supplemental information about an order.
 /// You can specify a value for this field when you make a Purchase request.
 /// </param>
 /// <param name="callback">Purchase request callback</param>
 public static void Purchase(AN_Product product, string developerPayload, Action <AN_BillingPurchaseResult> callback)
 {
     foreach (var sku in m_LoadedSkus)
     {
         if (sku.Sku.Equals(product.ProductId))
         {
             m_Client.Purchase(sku, developerPayload, callback);
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// This method begins a purchase request.
        /// </summary>
        /// <param name="product">product which you must specify in the application's product list on the Google Play Console.</param>
        /// <param name="developerPayload">
        /// A developer-specified string that contains supplemental information about an order.
        /// You can specify a value for this field when you make a Purchase request.
        /// </param>
        /// <param name="callback">Purchase request callback</param>
        public static void Purchase(AN_Product product, string developerPayload, Action <AN_BillingPurchaseResult> callback)
        {
            var request = new AN_VendingLib.AN_PurchaseRequest();

            request.m_product          = product;
            request.m_developerPayload = developerPayload;

            AN_VendingLib.API.Purchase(request, (result) => {
                if (result.IsSucceeded)
                {
                    Inventory.Purchases.Add(result.Purchase);
                }
                else
                {
                    //me might try to resolve some know response codes
                    switch (result.Error.Code)
                    {
                    case (int)AN_BillingRessponceCodes.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED:
                        AN_Purchase purchase = Inventory.GetPurchaseByProductId(product.ProductId);
                        if (purchase != null)
                        {
                            result = new AN_BillingPurchaseResult(purchase);
                            callback.Invoke(result);
                        }
                        else
                        {
                            GetPurchases((purchasesLoadResult) => {
                                purchase = Inventory.GetPurchaseByProductId(product.ProductId);
                                if (purchase != null)
                                {
                                    result = new AN_BillingPurchaseResult(purchase);
                                }
                                callback.Invoke(result);
                            });
                        }
                        return;
                    }
                }

                callback.Invoke(result);
            });
        }
Exemple #3
0
 /// <summary>
 /// This method begins a purchase request.
 /// </summary>
 /// <param name="product">product which you must specify in the application's product list on the Google Play Console.</param>
 /// <param name="callback">Purchase request callback</param>
 public static void Purchase(AN_Product product, Action <AN_BillingPurchaseResult> callback)
 {
     Purchase(product, string.Empty, callback);
 }