Windows应用商店 - 应用内商品问题

时间:2012-12-10 09:13:57

标签: windows

我已经将我的游戏提交到商店,但我失败了,它从未结束试用和应用内购买。  查看代码后,审阅者收到的消息是licenseInformation.ProductLicenses [product] .IsActive为false  如果他没有买它怎么可能呢? (用他发给我的图像,我可以保证)。

在App.xaml.cs中我添加了:

public static LicenseInformation licenseInformation = null;
    public static bool IsTrial { get { return licenseInformation.IsActive && licenseInformation.IsTrial; } }

    private async void LoadMoneyInfo()
    {
        //StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("data");
        //StorageFile proxyFile = await proxyDataFolder.GetFileAsync("in-app-purchase.xml");
        //await CurrentApp.ReloadSimulatorAsync(proxyFile);
        // setup application upsell message
        //ListingInformation listing = await CurrentApp.LoadListingInformationAsync();
        //await CurrentApp.LoadListingInformationAsync();
        licenseInformation = CurrentApp.LicenseInformation;
    }

在购买部分,我补充道:

private async void BuyCommandInvokedHandler(IUICommand command)
    {
        if (command.Label == "Buy")
        {
            LicenseInformation licenseInformation = CurrentApp.LicenseInformation;

            string product = String.Empty;

            switch (Product)
            {
                case Products.OneHundred:
                    product = String.Concat("oneh", OneHundred); //In-app product with Stored Counter
                    break;
                case Products.FiveHundred:
                    product = String.Concat("fiveh", FiveHundred); //In-app product with Stored Counter
                    break;
                case Products.OneThousand:
                    product = String.Concat("onet", OneThousand); //In-app product with Stored Counter
                    break;
                default:
                    break;
            }

            var productLicense = licenseInformation.ProductLicenses[product];
            if (!productLicense.IsActive)
            {
                try
                {
                    await CurrentApp.RequestProductPurchaseAsync(product, false);

                    if (licenseInformation.ProductLicenses[product].IsActive)
                    {
                        switch (Product)
                        {
                            case Products.OneHundred:
                                GoldenCards += 100;
                                OneHundred++;
                                CheckAllEnable();
                                break;
                            case Products.FiveHundred:
                                GoldenCards += 500;
                                FiveHundred++;
                                CheckAllEnable();
                                break;
                            case Products.OneThousand:
                                GoldenCards += 1000;
                                OneThousand++;
                                CheckAllEnable();
                                break;
                            default:
                                break;
                        }

                        m.Content = "You bought " + message + " golden cards";
                        m.Commands.RemoveAt(0);
                        await m.ShowAsync();
                        IsButtonEnabled = true;
                    }
                    else
                    {
                        m.Content = "For security reasons this product is not available until tomorrow.";
                        m.Commands.RemoveAt(0);
                        await m.ShowAsync();
                        IsButtonEnabled = true;
                    }
                }
                catch (Exception ex)
                {
                    m.Content = "It was not able to buy " + message + " golden cards, try it later.";
                    m.Commands.RemoveAt(0);
                    m.ShowAsync();
                    IsButtonEnabled = true;
                }
            }
            else //<-- 'The reviewer is here'

           {
                MessageDialog msc = new MessageDialog("For security reasons this product is not available until tomorrow.", "Note");
                Actions.Delayed(1.0, async () => 
                    {
                        await msc.ShowAsync();
                        IsButtonEnabled = true;
                    });
            }
        }
    }

1.-此代码是否适合提交?他到达'审稿人在这里'

然后我检查Is trial就像sdk示例:

public async void ShowTrial()
    {
        LicenseInformation licenseInformation = CurrentApp.LicenseInformation;
        if (licenseInformation.IsTrial)
        {
            try
            {
                await CurrentApp.RequestAppPurchaseAsync(false);
                if (!licenseInformation.IsTrial && licenseInformation.IsActive)
                {
                    MessageDialog ms = new MessageDialog("You successfully upgraded AnimalCards to the fully-licensed version. Enjoy the full game, Thank you.");
                    await ms.ShowAsync();
                    if (AcceptAction != null)
                        AcceptAction.Invoke();
                }
                else
                {
                    MessageDialog ms = new MessageDialog("You still have a trial license for AnimalCards.");
                    await ms.ShowAsync();
                    if (CancelAction != null)
                        CancelAction.Invoke();
                }
            }
            catch (Exception)
            {
                MessageDialog ms = new MessageDialog("The upgrade transaction failed. You still have a trial license for AnimalCards.");
                ms.ShowAsync();
                if (CancelAction != null)
                    CancelAction.Invoke();
            }
        }
        else
        {
            MessageDialog ms = new MessageDialog("You already bought AnimalCards and have a fully-licensed version.");
            await ms.ShowAsync();

        }
    }

2.-这段代码是对的吗?

0 个答案:

没有答案
相关问题