Пример #1
0
 public static void RequestProductPurchase(string productId, Action <InAppProductPurchaseResult> callback)
 {
     if (callback == null)
     {
         return;
     }
     Execute.ExecuteOnUIThread(async delegate
     {
         InAppProductPurchaseResult inAppProductPurchaseResult = new InAppProductPurchaseResult
         {
             Status = InAppProductPurchaseStatus.Cancelled
         };
         try
         {
             productId = InAppPurchaseService.ToInAppProductId(productId);
             PurchaseResults purchaseResults = await CurrentApp.RequestProductPurchaseAsync(productId);
             if (purchaseResults != null)
             {
                 inAppProductPurchaseResult.ReceiptXml    = purchaseResults.ReceiptXml;
                 inAppProductPurchaseResult.TransactionId = purchaseResults.TransactionId;
                 if (!string.IsNullOrEmpty(purchaseResults.ReceiptXml))
                 {
                     inAppProductPurchaseResult.Status = InAppProductPurchaseStatus.Purchased;
                 }
             }
         }
         catch
         {
             inAppProductPurchaseResult.Status = InAppProductPurchaseStatus.Error;
         }
         callback.Invoke(inAppProductPurchaseResult);
     });
 }
Пример #2
0
 public static async void LoadUnfulfilledConsumables(string productId, Action <List <InAppUnfulfilledProduct> > callback)
 {
     if (callback != null)
     {
         List <InAppUnfulfilledProduct> list = new List <InAppUnfulfilledProduct>();
         if (AppGlobalStateManager.Current.GlobalState.PaymentType == AccountPaymentType.money)
         {
             callback.Invoke(list);
         }
         else
         {
             try
             {
                 IEnumerator <UnfulfilledConsumable> var_2 = (await CurrentApp.GetUnfulfilledConsumablesAsync()).GetEnumerator();
                 try
                 {
                     while (var_2.MoveNext())
                     {
                         UnfulfilledConsumable var_3_BD = var_2.Current;
                         string var_4_C9 = InAppPurchaseService.ToServerMerchantProductId(var_3_BD.ProductId);
                         if (string.IsNullOrEmpty(productId) || !(var_4_C9 != productId))
                         {
                             list.Add(new InAppUnfulfilledProduct
                             {
                                 ProductId     = var_4_C9,
                                 TransactionId = var_3_BD.TransactionId
                             });
                         }
                     }
                 }
                 finally
                 {
                     if (var_2 != null)
                     {
                         var_2.Dispose();
                     }
                 }
             }
             catch
             {
             }
             callback.Invoke(list);
         }
     }
 }
Пример #3
0
        public static async void LoadProductReceipt(string productId, Action <string> callback)
        {
            if (callback != null)
            {
                string text = "";
                try
                {
                    productId = InAppPurchaseService.ToInAppProductId(productId);
                    string text2 = await CurrentApp.GetProductReceiptAsync(productId);

                    text = text2;
                }
                catch
                {
                }
                callback.Invoke(text);
            }
        }
Пример #4
0
 public static void Generate(AccountPaymentType paymentType, List <StockItem> stockItems, Action <List <VotesPack> > callback)
 {
     if (paymentType == AccountPaymentType.inapp)
     {
         InAppPurchaseService.LoadProductPrices((Action <Dictionary <string, string> >)(votesPrices =>
         {
             if (votesPrices == null)
             {
                 return;
             }
             VotesPacksGenerator.CreateVotesPacks((IEnumerable <StockItem>)stockItems, (IDictionary <string, string>)votesPrices, callback);
         }));
     }
     else
     {
         VotesPacksGenerator.CreateVotesPacks((IEnumerable <StockItem>)stockItems, null, callback);
     }
 }
Пример #5
0
 public static void ReportConsumableProductFulfillment(InAppUnfulfilledProduct product, Action callback = null)
 {
     if (product == null)
     {
         return;
     }
     Execute.ExecuteOnUIThread(async delegate
     {
         try
         {
             await CurrentApp.ReportConsumableFulfillmentAsync(InAppPurchaseService.ToInAppProductId(product.ProductId), product.TransactionId);
         }
         catch
         {
         }
         Action expr_A2 = callback;
         if (expr_A2 != null)
         {
             expr_A2.Invoke();
         }
     });
 }