简体   繁体   中英

Windows 8 Store In-App purchases

I've been searching the internet for hours now and I still cannot resolve an issue I'm having with my IAP 's, I have 2 in app products and I have this in my code:

private async void RenderStoreItems()
    {
        picItems.Clear();

        try
        {

            ListingInformation li = await CurrentApp.LoadListingInformationAsync();

            foreach (string key in li.ProductListings.Keys)
            {
                ProductListing pListing = li.ProductListings[key];
                System.Diagnostics.Debug.WriteLine(key);

                string status = CurrentApp.LicenseInformation.ProductLicenses[key].IsActive ? "Purchased" : pListing.FormattedPrice;

                string imageLink = string.Empty;

                picItems.Add(
                    new ProductItem
                    {
                        imgLink = key.Equals("AdvertBlocker") ? "/Assets/Purchases/NoAds.png" : "/Assets/Purchases/NoAds.png",
                        Name = pListing.Name,
                        Status = status,
                        key = key,

                    }
                );
            }

            pics.ItemsSource = picItems;
        }
        catch (Exception e)
        {
            System.Diagnostics.Debug.WriteLine(e.ToString());
        }
    }

This is called upon Page_Load however on this line ListingInformation li = await Windows.ApplicationModel.Store.CurrentApp.LoadListingInformationAsync(); I receive an exception. I've searched everywhere as to why I'd receive such exception, here are the reasons:

  1. I haven't added any IAP's
  2. My ProductID is incorrect to the one specified on the dev center dashboard

However, I have done every single possible reason as to why it shouldn't be working but it still doesn't work?

I've also tried, rather than CurrentApp I've used CurrentAppSimulator it works but I receive invalid information, for example a name of a product would be "Spinner" but the received name would be "ProductName1"

Does anyone understand what I am doing wrong?

You need to edit the ProductID or PhoneProductID in Package.AppManifest to the one MSFT provides you on DevCenter. That error mean's the API 404'd when trying to contact the store using the wrong GUID (aka the one that Visual Studio provided you).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM