예제 #1
0
        /// <summary>
        /// Gets the product receipt for the given productId.
        ///
        /// </summary>
        /// <param name="productIds"/>
        /// <returns/>
        public static async void GetProductReceipts(List <string> productIds, Action <List <ProductReceipt>, Exception> onComplete)
        {
            try
            {
                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    try
                    {
                        var task = CurrentApp.GetAppReceiptAsync().AsTask();

                        await task;

                        if (onComplete != null)
                        {
                            var receiptXml = task.Result;
                            var receipts   = ProductReceipt.CreateReceipts(receiptXml);
                            onComplete(receipts, null);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (onComplete != null)
                        {
                            onComplete(null, ex);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                if (onComplete != null)
                {
                    onComplete(null, ex);
                }
            }
        }