Beispiel #1
0
        private async void loadTestData(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
        {
            bool pass = true;

            try
            {
                MockIAPLib.MockIAP.Init();
                MockIAPLib.MockIAP.RunInMockMode(true);
                MockIAPLib.MockIAP.SetListingInformation(1, "en-us", "Some description", "1", "TestApp");

                int i = 1;
                foreach (var inApp in desc.WP8_MicrosoftStore_InAppIDs)
                {
                    var product = new MockIAPLib.ProductListing
                    {
                        Name           = inApp.ID,
                        ImageUri       = new Uri("/Res/ReignIcon.png", UriKind.Relative),
                        ProductId      = inApp.ID,
                        ProductType    = inApp.Type == InAppPurchaseTypes.NonConsumable ? ProductType.Durable : ProductType.Consumable,
                        Keywords       = new string[] { "image" },
                        Description    = "Product Desc " + i,
                        FormattedPrice = inApp.CurrencySymbol + inApp.Price,
                        Tag            = string.Empty
                    };

                    MockIAPLib.MockIAP.AddProductListing(inApp.ID, product);
                    ++i;
                }

                wp8TestListingInformation = await CurrentAppSimulator.LoadListingInformationAsync();

                MockIAPLib.MockIAP.ClearCache();
                wp8TestLicenseInformation = CurrentAppSimulator.LicenseInformation;
                wp8TestLicenseInformation.LicenseChanged += licenseChanged;
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                pass = false;
            }

            if (createdCallback != null)
            {
                createdCallback(pass);
            }
        }
Beispiel #2
0
        public async void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback)
        {
            if (callback == null)
            {
                return;
            }
            var infos = new List <InAppPurchaseInfo>();

            try
            {
                                #if WINDOWS_PHONE
                if (testing)
                {
                    var listingInfo = wp8TestListingInformation;
                    foreach (var l in listingInfo.ProductListings)
                    {
                        var info = new InAppPurchaseInfo()
                        {
                            ID             = l.Value.ProductId,
                            FormattedPrice = l.Value.FormattedPrice
                        };
                        infos.Add(info);
                    }
                }
                else
                {
                    var listingInfo = await CurrentApp.LoadListingInformationAsync();

                    foreach (var l in listingInfo.ProductListings)
                    {
                        var info = new InAppPurchaseInfo()
                        {
                            ID             = l.Value.ProductId,
                            FormattedPrice = l.Value.FormattedPrice
                        };
                        infos.Add(info);
                    }
                }
                                #else
                ListingInformation listingInfo;
                if (testing)
                {
                    listingInfo = await CurrentAppSimulator.LoadListingInformationAsync();
                }
                else
                {
                    listingInfo = await CurrentApp.LoadListingInformationAsync();
                }
                foreach (var l in listingInfo.ProductListings)
                {
                    var info = new InAppPurchaseInfo()
                    {
                        ID             = l.Value.ProductId,
                        FormattedPrice = l.Value.FormattedPrice
                    };
                    infos.Add(info);
                }
                                #endif

                callback(infos.ToArray(), true);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                callback(null, false);
            }
        }
        public async void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback)
        {
            if (callback == null)
            {
                return;
            }

                        #if WINDOWS_PHONE
            WinRTPlugin.Dispatcher.BeginInvoke(async delegate()
                        #else
            await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate()
                        #endif
            {
                var infos = new List <InAppPurchaseInfo>();
                try
                {
                                        #if WINDOWS_PHONE
                    if (testing)
                    {
                        var listingInfo = wp8TestListingInformation;
                        foreach (var l in listingInfo.ProductListings)
                        {
                            var info = new InAppPurchaseInfo()
                            {
                                ID             = l.Value.ProductId,
                                FormattedPrice = l.Value.FormattedPrice
                            };
                            infos.Add(info);
                        }
                    }
                    else
                    {
                        var listingInfo = await CurrentApp.LoadListingInformationAsync();
                        foreach (var l in listingInfo.ProductListings)
                        {
                            var info = new InAppPurchaseInfo()
                            {
                                ID             = l.Value.ProductId,
                                FormattedPrice = l.Value.FormattedPrice
                            };
                            infos.Add(info);
                        }
                    }
                                        #else
                    ListingInformation listingInfo;
                    if (testing)
                    {
                        listingInfo = await CurrentAppSimulator.LoadListingInformationAsync();
                    }
                    else
                    {
                        listingInfo = await CurrentApp.LoadListingInformationAsync();
                    }
                    foreach (var l in listingInfo.ProductListings)
                    {
                        var info = new InAppPurchaseInfo()
                        {
                            ID             = l.Value.ProductId,
                            FormattedPrice = l.Value.FormattedPrice
                        };
                        infos.Add(info);
                    }
                                        #endif

                    ReignServices.InvokeOnUnityThread(delegate
                    {
                        callback(infos.ToArray(), true);
                    });
                }
                catch (Exception e)
                {
                    Debug.LogError(e.Message);
                    ReignServices.InvokeOnUnityThread(delegate
                    {
                        callback(null, false);
                    });
                }
            });
        }