简体   繁体   中英

Windows Phone In-app purchase Error

I used this wrapper for store functions to add to my Windows Phone 7 project condition to find out if user hase WP8 and enabled him in-apps and if not then just tell him.

I am using it like this:

        if (Environment.OSVersion.Version.Major >= 8)
        {
            _store = StoreLauncher.GetStoreInterface("InAppPurchaseWrapper.Store, InAppPurchaseWrapper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
        }

        if (_store != null)
        {
            var productListAsync = _store.LoadListingInformationAsync();
            productListAsync.Completed = (async, status) =>
                {
                    var listingInformation = async.GetResults();
                    var removeAdItem = listingInformation.ProductListings[Constants.RemoveAddKey];

                    PurchaseItem(removeAdItem.ProductId, Result);
                };
        }
        else
        {
            MessageBox.Show(AppResources.remove_ads_notworking);
        }

    public void PurchaseItem(string id, Action<bool> result)
    {
            var purchaseAsync = _store.RequestProductPurchaseAsync(id, false);
            purchaseAsync.Completed = (async, status) =>
            {
                try
                {
                    if (status == StoreAsyncStatus.Completed)
                    {
                        var licenseInfo = _store.LicenseInformation;
                        if (licenseInfo.ProductLicenses[id].IsActive)
                        {
                            MessageBox.Show(AppResources.remove_ad_success);
                            appSettings.IsAdVisible = false;
                        }
                        else
                        {
                            MessageBox.Show(AppResources.remove_ads_something_goes_wrong);
                        }
                    }
                    else
                    {
                        if (status == StoreAsyncStatus.Error)
                        {
                            var forceException = async.GetResults();
                        }
                        result(false);
                    }
                }
                catch (Exception)
                {

                    throw;
                }
            };
       }

The problem is when I am calling RequestProductPurchaseAsync then I get: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) . But It was working. For one time I can buy that in-app and when I downloaded licenses I get it there. But not anymore. I was trying to restart emulator, OS but so far nothing helps. Anyone knows where could be problem? Thanks

Edit: I find out that if I first run some sample application with same ProductId and that app is target for WP8. Then it's okay and I can buy in-app. If then I run original app (target for WP7) then I can buy in-apps too. So where could be problem? Is it posible to have working wrapper for Store functions for WP7 project? Should I send first WP8 app to Beta test and then use it's productId for WP7?

不允许WP7使用Windows Phone Store应用内购买您应该实施自己的应用内购买服务

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