如何在Windows应用商店应用中实现应用内购买

时间:2015-03-16 23:24:40

标签: c# windows unity3d product in-app

我想知道如何在Windows应用商店应用中实现完全应用内购买(意味着不是Windows Phone),仅仅是因为我已经在网上和微软的教程中看到,我发现似乎没有利用我。

我使用Unity开发游戏,然后导出Windows Store 8.1文件。具体来说,我在Unity代码中实现了一个事件,该事件链接到Visual Studio中可访问的MainPage.xaml.cs文件中的方法(我正在运行Express 2013 for Windows)。实际的方法正在执行,但是当我按照这样的方法请求购买产品时,我收到一个错误:

    // This is assigned to the event that is called in Unity whenever the "Get Points" button is pressed.
    private async void PurchasePoints(object arg)
    {
        // Find the GameManager GameObject.
        UnityEngine.GameObject gameManager = UnityEngine.GameObject.FindGameObjectWithTag("GameManager");

        // Get the script attached to it.
        GameManager gameManagerScript = gameManager.GetComponent<GameManager>();

        // Get the license information for this app.
        Windows.ApplicationModel.Store.LicenseInformation licenseInformation = Windows.ApplicationModel.Store.CurrentAppSimulator.LicenseInformation;

        if (licenseInformation.ProductLicenses["SectorDefense_Points_250"].IsActive)
        {
            await Windows.ApplicationModel.Store.CurrentAppSimulator.RequestProductPurchaseAsync("SectorDefense_Points_250");

            gameManagerScript.playerScore += 250;
        }
    }

我对于如何实现这种功能感到困惑。

我确保查看WindowsStoreProxy.xml文件并自定义其中的所有内容以满足应用程序的需求,尽管我之前从未真正使用过XML。

非常感谢任何帮助!

提前致谢。

1 个答案:

答案 0 :(得分:-1)

无需硬编码,这是为任何应用程序实施应用内购买的最简单方法。访问此链接并免费下载该插件。 Microsoft Store插件 - https://prime31.com/plugins