//<GetUnfulfilledConsumables>
        private async void GetUnfulfilledConsumables()
        {
            products = await CurrentApp.GetUnfulfilledConsumablesAsync();

            foreach (UnfulfilledConsumable product in products)
            {
                logMessage += "\nProduct Id: " + product.ProductId + " Transaction Id: " + product.TransactionId;
                // This is where you would pass the product ID and transaction ID to
                // currentAppSimulator.reportConsumableFulfillment to indicate local fulfillment to the Windows Store.
            }
        }
Ejemplo n.º 2
0
 private IAsyncOperation <IReadOnlyList <UnfulfilledConsumable> > GetUnfulfilledConsumablesAsync()
 {
     if (_useSimulator)
     {
         return(CurrentAppSimulator.GetUnfulfilledConsumablesAsync());
     }
     else
     {
         return(CurrentApp.GetUnfulfilledConsumablesAsync());
     }
 }
 public static IAsyncOperation <IReadOnlyList <UnfulfilledConsumable> > GetUnfulfilledConsumablesAsync()
 {
     if (testmode == null)
     {
         throw new NotSupportedException();
     }
     else if (testmode.Value)
     {
         return(CurrentAppSimulator.GetUnfulfilledConsumablesAsync());
     }
     else
     {
         return(CurrentApp.GetUnfulfilledConsumablesAsync());
     }
 }
Ejemplo n.º 4
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);
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a list of unfulfilled consumable products
        /// </summary>
        /// <param name="response">A callback containing the found unfulfilled consumable products</param>
        public static void GetUnfulfilledConsumableProducts(Action <List <WSAUnfulfilledConsumable> > response)
        {
#if NETFX_CORE || (ENABLE_IL2CPP && UNITY_WSA_10_0)
            if (_isTest)
            {
                UnityEngine.WSA.Application.InvokeOnUIThread(async() =>
                {
                    IReadOnlyList <UnfulfilledConsumable> products = await CurrentAppSimulator.GetUnfulfilledConsumablesAsync();

                    List <WSAUnfulfilledConsumable> unfulfilled = products.Select(x => new WSAUnfulfilledConsumable()
                    {
                        OfferId = x.OfferId, ProductId = x.ProductId, TransactionId = x.TransactionId
                    }).ToList();

                    UnityEngine.WSA.Application.InvokeOnAppThread(() =>
                    {
                        if (response != null)
                        {
                            response(unfulfilled != null ? unfulfilled : new List <WSAUnfulfilledConsumable>());
                        }
                    }, true);
                }, false);
            }
            else
            {
                UnityEngine.WSA.Application.InvokeOnUIThread(async() =>
                {
                    IReadOnlyList <UnfulfilledConsumable> products = await CurrentApp.GetUnfulfilledConsumablesAsync();

                    List <WSAUnfulfilledConsumable> unfulfilled = products.Select(x => new WSAUnfulfilledConsumable()
                    {
                        OfferId = x.OfferId, ProductId = x.ProductId, TransactionId = x.TransactionId
                    }).ToList();

                    UnityEngine.WSA.Application.InvokeOnAppThread(() =>
                    {
                        if (response != null)
                        {
                            response(unfulfilled != null ? unfulfilled : new List <WSAUnfulfilledConsumable>());
                        }
                    }, true);
                }, false);
            }
#endif
        }
Ejemplo n.º 6
0
        public static void LoadUnfulfilledConsumables(Action <CallbackResponse <List <UnfulfilledConsumable> > > OnLoadUnfulfilledConsumablesFinished)
        {
            Utils.RunOnWindowsUIThread(async() =>
            {
                IReadOnlyList <Windows.ApplicationModel.Store.UnfulfilledConsumable> unfulfilledConsumables = null;
                List <UnfulfilledConsumable> deliveryFormatUnfulfilledConsumables = new List <UnfulfilledConsumable>();
                try
                {
                    if (_isLicenseSimulationOn)
                    {
                        unfulfilledConsumables = await CurrentAppSimulator.GetUnfulfilledConsumablesAsync();
                    }
                    else
                    {
                        unfulfilledConsumables = await CurrentApp.GetUnfulfilledConsumablesAsync();
                    }


                    foreach (var oneUnfConsumable in unfulfilledConsumables)
                    {
                        deliveryFormatUnfulfilledConsumables.Add(new UnfulfilledConsumable(oneUnfConsumable));
                    }
                }
                catch (Exception ex)
                {
                    DebugLog.Log(LogLevel.Error, "Error while reporting consumable fulfillment " + ex.ToString());
                    Utils.RunOnUnityAppThread(() => { OnLoadUnfulfilledConsumablesFinished(new CallbackResponse <List <UnfulfilledConsumable> > {
                            Status = CallbackStatus.Failure, Exception = ex, Result = null
                        }); });
                    return;
                }

                // deliver all the unfulfilled consumables at once
                Utils.RunOnUnityAppThread(() => { if (OnLoadUnfulfilledConsumablesFinished != null)
                                                  {
                                                      OnLoadUnfulfilledConsumablesFinished(new CallbackResponse <List <UnfulfilledConsumable> > {
                            Status = CallbackStatus.Success, Result = deliveryFormatUnfulfilledConsumables, Exception = null
                        });
                                                  }
                                          });
            });
        }
Ejemplo n.º 7
0
        private async Task <bool> FulfillDonation()
        {
            var unfulfilledConsumables = await CurrentApp.GetUnfulfilledConsumablesAsync();

            foreach (UnfulfilledConsumable consumable in unfulfilledConsumables)
            {
                if (consumable.ProductId == "donation")
                {
                    FulfillmentResult fulfillmentResult = await CurrentApp.ReportConsumableFulfillmentAsync(consumable.ProductId, consumable.TransactionId);

                    switch (fulfillmentResult)
                    {
                    case FulfillmentResult.Succeeded:
                    case FulfillmentResult.NothingToFulfill:
                    case FulfillmentResult.PurchaseReverted:
                        return(true);
                    }
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 8
0
 public static async Task <IEnumerable <UnfulfilledConsumable> > GetAvailableConsumables(bool isTestingMode)
 {
     return(isTestingMode ? await CurrentAppSimulator.GetUnfulfilledConsumablesAsync() : await CurrentApp.GetUnfulfilledConsumablesAsync());
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Returns a list of purchased consumable in-app products
 /// that have not been reported to the Windows Store as fulfilled.
 /// </summary>
 /// <returns>
 /// When the operation completes, a list of consumable
 /// in-app products not yet reported as fulfilled is returned
 /// (UnfulfilledConsumable objects).
 /// </returns>
 public static IAsyncOperation <IReadOnlyList <UnfulfilledConsumable> > GetUnfulfilledConsumablesAsync()
 {
     return(IsMockEnabled
         ? CurrentAppSimulator.GetUnfulfilledConsumablesAsync()
         : CurrentApp.GetUnfulfilledConsumablesAsync());
 }
Ejemplo n.º 10
0
        public static async Task <ProductPurchaseStatus> PurchaseAsync(ProductListing product)
        {
            ProductPurchaseStatus status = ProductPurchaseStatus.NotPurchased;

            try
            {
                Guid            productTransactionId;
                List <Guid>     grantedConsumableTransactionIds = new List <Guid>();
                PurchaseResults purchaseResults = await CurrentApp.RequestProductPurchaseAsync(product.ProductId);

                status = purchaseResults.Status;

                switch (status)
                {
                case ProductPurchaseStatus.Succeeded:
                    productTransactionId = purchaseResults.TransactionId;

                    FulfillmentResult fulfillmentResult = await FulfillAsync(product.ProductId, productTransactionId);

                    break;

                case ProductPurchaseStatus.NotFulfilled:

                    if (ApplicationInfo.Current.HasInternetConnection)
                    {
                        var unfulfilledPurchases = await CurrentApp.GetUnfulfilledConsumablesAsync();

                        foreach (UnfulfilledConsumable unfulfilledConsumable in unfulfilledPurchases)
                        {
                            await FulfillAsync(unfulfilledConsumable.ProductId, unfulfilledConsumable.TransactionId);
                        }
                    }

                    break;

                case ProductPurchaseStatus.NotPurchased:

                    break;
                }

                //switch (purchaseResults.Status)
                //{
                //    case ProductPurchaseStatus.Succeeded:
                //        product1TempTransactionId = purchaseResults.TransactionId;
                //        // Grant the user their purchase here, and then pass the product ID and transaction ID to CurrentAppSimulator.reportConsumableFulfillment
                //        // To indicate local fulfillment to the Windows Store.
                //        break;

                //    case ProductPurchaseStatus.NotPurchased:

                //        break;

                //    case ProductPurchaseStatus.NotFulfilled:
                //        product1TempTransactionId = purchaseResults.TransactionId;

                //        // First check for unfulfilled purchases and grant any unfulfilled purchases from an earlier transaction.
                //        // Once products are fulfilled pass the product ID and transaction ID to CurrentAppSimulator.reportConsumableFulfillment
                //        // To indicate local fulfillment to the Windows Store.
                //        break;
                //}
            }
            catch
            {
            }

            return(status);
        }
Ejemplo n.º 11
0
 protected async Task <IReadOnlyList <UnfulfilledConsumable> > GetUnfulfilledConsumablesAsyncInternal()
 {
     return(await CurrentApp.GetUnfulfilledConsumablesAsync());
 }