Пример #1
0
 private static void OnLicenseChanged()
 {
     if (LicenseChangedEvent != null)
     {
         EtceteraWindows.RunOnUnityThread(LicenseChangedEvent);
     }
 }
Пример #2
0
        private static async void Purchase(string productId, Action <PurchaseResults, Exception> completionHandler)
        {
            Exception exception = null;
            string    result    = null;

            try
            {
                result = await CurrentApp.RequestProductPurchaseAsync(productId, true);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            if (completionHandler != null)
            {
                PurchaseResults purchase = null;
                if (result != null)
                {
                    purchase = new PurchaseResults();
                    //purchase.offerId = result.OfferId;
                    purchase.Status     = ProductPurchaseStatus.Succeeded;
                    purchase.ReceiptXml = result;
                    //purchase.transactionId = result.TransactionId;
                }

                EtceteraWindows.RunOnUnityThread(() => completionHandler(purchase, exception));
            }
        }
Пример #3
0
        private static async void LoadListing(Action <ListingInformation, Exception> onComplete)
        {
            try
            {
#if DEBUG
                var task = CurrentApp.LoadListingInformationAsync();
#else
                var task = CurrentApp.LoadListingInformationAsync().AsTask();
#endif
                await task;

                var information = task.Result;

                if (information != null)
                {
                    var listing = new ListingInformation();
                    listing.AgeRating       = information.AgeRating;
                    listing.CurrentMarket   = information.CurrentMarket;
                    listing.Description     = information.Description;
                    listing.FormattedPrice  = information.FormattedPrice;
                    listing.Name            = information.Name;
                    listing.ProductListings = new Dictionary <string, ProductListing>();
                    var productListings = information.ProductListings;

                    foreach (var productListing in productListings)
                    {
                        var value   = productListing.Value;
                        var product = new ProductListing();
                        product.ProductId      = value.ProductId;
                        product.ProductType    = (ProductType)value.ProductType;
                        product.FormattedPrice = value.FormattedPrice;
                        product.Name           = value.Name;
                        listing.ProductListings.Add(productListing.Key, product);
                    }
                    if (onComplete != null)
                    {
                        EtceteraWindows.RunOnUnityThread(() => onComplete(listing, null));
                    }
                }
                else
                {
                    if (onComplete != null)
                    {
                        EtceteraWindows.RunOnUnityThread(() => onComplete(null, new Exception("ListingInformation is null")));
                    }
                }
            }
            catch (Exception ex)
            {
                if (onComplete != null)
                {
                    EtceteraWindows.RunOnUnityThread(() => onComplete(null, ex));
                }
            }
        }
Пример #4
0
        private static async void LoadProductReceipts(List <string> productIds, Action <List <ProductReceipt>, Exception> onComplete)
        {
            var receipts = new List <ProductReceipt>();

            for (int index = 0; index < productIds.Count; index++)
            {
                var productId = productIds[index];

                if (string.IsNullOrEmpty(productId))
                {
                    continue;
                }

                try
                {
#if DEBUG
                    var task = CurrentApp.GetProductReceiptAsync(productId);
#else
                    var task = CurrentApp.GetProductReceiptAsync(productId).AsTask();
#endif
                    await task;

                    var receiptXml = task.Result;

                    var receipt = ProductReceipt.CreateReceipt(receiptXml);

                    receipts.Add(receipt);
                }
                catch (Exception ex)
                {
                    if (onComplete != null)
                    {
                        EtceteraWindows.RunOnUnityThread(() => onComplete(null, ex));
                    }
                    return;
                }
            }

            if (onComplete != null)
            {
                EtceteraWindows.RunOnUnityThread(() => onComplete(receipts, null));
            }
        }
Пример #5
0
        /// <summary>
        /// Reports a consumable as fullfilled. You should call this once you have granted the consumable to the player.
        ///
        /// </summary>
        /// <param name="productId"/><param name="transactionId"/><param name="completionHandler"/>

        public static void ReportConsumableFulfillment(string productId, Guid transactionId, Action <FulfillmentResult, Exception> onComplete)
        {
            Exception exception = null;

            try
            {
                CurrentApp.ReportProductFulfillment(productId);
                if (onComplete != null)
                {
                    EtceteraWindows.RunOnUnityThread(() => onComplete(FulfillmentResult.Succeeded, null));
                }
            }
            catch (Exception ex)
            {
                if (onComplete != null)
                {
                    EtceteraWindows.RunOnUnityThread(() => onComplete(FulfillmentResult.ServerError, ex));
                }
            }
        }