Inheritance: IProductLicense
Exemplo n.º 1
0
        /// <summary>
        /// Creates a new ProductLicense class based on a listing supplied directly from the Windows Store APIs
        /// </summary>
        /// <param name="source">An original Windows.ApplicationModel.Store.ProductLicense from the CurrentApp class</param>
        /// <returns>A populated ProductLicense class</returns>
        public static ProductLicense Create(Windows.ApplicationModel.Store.ProductLicense source)
        {
            var productLicense = new ProductLicense
            {
#if WINDOWS_PHONE                                         //Windows Phone 8
                ExpirationDate = DateTimeOffset.MaxValue, //MaxValue means that the license is active and will not expire
                IsConsumable   = source.IsConsumable,
#else //WinRT
                ExpirationDate = source.ExpirationDate,
#endif

                IsActive  = source.IsActive,
                ProductId = source.ProductId
            };

            return(productLicense);
        }
        /// <summary>
        /// Tries to fulfill a Gold IAP with the given amount.
        /// </summary>
        /// <param name="productLicense">The store product license.</param>
        private async Task TryFulfillGold(ProductLicense productLicense)
        {
            if (productLicense.IsConsumable && productLicense.IsActive)
            {
                var receipt = await CurrentAppProxy.RequestProductPurchaseAsync(productLicense.ProductId);

                // Fulfill on PhotoSharingApp servers
                var user = await _photoService.FulfillGold(receipt.ReceiptXml);

                // If previous step was successful, fulfill in Store
                await CurrentAppProxy.ReportConsumableFulfillmentAsync(productLicense.ProductId, receipt.TransactionId);

                // Now update local gold balance
                AppEnvironment.Instance.CurrentUser.GoldBalance = user.GoldBalance;
            }
        }
Exemplo n.º 3
0
 private static void MaybeGiveMePremium(ProductLicense productLicense)
 {
     if (!productLicense.IsConsumable && productLicense.IsActive)
     {
         CurrentApp.ReportProductFulfillment(productLicense.ProductId);
     }
 }