3

我已将我的游戏提交到商店但我失败了,它永远不会结束试用和应用内购买。查看代码后,审阅者收到 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.- 此代码是否适合提交?他到达“审稿人来了”

然后我检查是否像 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.- 这段代码对吗?

4

0 回答 0