1. <tfoot id='jI0R1'></tfoot>
    2. <small id='jI0R1'></small><noframes id='jI0R1'>

      <i id='jI0R1'><tr id='jI0R1'><dt id='jI0R1'><q id='jI0R1'><span id='jI0R1'><b id='jI0R1'><form id='jI0R1'><ins id='jI0R1'></ins><ul id='jI0R1'></ul><sub id='jI0R1'></sub></form><legend id='jI0R1'></legend><bdo id='jI0R1'><pre id='jI0R1'><center id='jI0R1'></center></pre></bdo></b><th id='jI0R1'></th></span></q></dt></tr></i><div id='jI0R1'><tfoot id='jI0R1'></tfoot><dl id='jI0R1'><fieldset id='jI0R1'></fieldset></dl></div>

        <bdo id='jI0R1'></bdo><ul id='jI0R1'></ul>
      <legend id='jI0R1'><style id='jI0R1'><dir id='jI0R1'><q id='jI0R1'></q></dir></style></legend>

        如何在 Windows 10 应用中实现应用内购买?

        How to Implement In-App Purchases in Windows 10 Apps?(如何在 Windows 10 应用中实现应用内购买?)
      1. <legend id='3iuZE'><style id='3iuZE'><dir id='3iuZE'><q id='3iuZE'></q></dir></style></legend>
      2. <small id='3iuZE'></small><noframes id='3iuZE'>

              <tbody id='3iuZE'></tbody>

            • <bdo id='3iuZE'></bdo><ul id='3iuZE'></ul>
                  <i id='3iuZE'><tr id='3iuZE'><dt id='3iuZE'><q id='3iuZE'><span id='3iuZE'><b id='3iuZE'><form id='3iuZE'><ins id='3iuZE'></ins><ul id='3iuZE'></ul><sub id='3iuZE'></sub></form><legend id='3iuZE'></legend><bdo id='3iuZE'><pre id='3iuZE'><center id='3iuZE'></center></pre></bdo></b><th id='3iuZE'></th></span></q></dt></tr></i><div id='3iuZE'><tfoot id='3iuZE'></tfoot><dl id='3iuZE'><fieldset id='3iuZE'></fieldset></dl></div>
                  <tfoot id='3iuZE'></tfoot>

                  本文介绍了如何在 Windows 10 应用中实现应用内购买?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想在我的 Windows 通用应用中集成应用内购买.我在编码之前做了以下事情.

                  • 当它什么都不返回时,很有可能 WindowsStoreProxy.xml 中的某些东西是错误的.我建议您创建自己的 WindowsStoreProxy.xml 并使用 CurrentAppSimulator.ReloadSimulatorAsync 方法读取它,如下所示:

                    var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"TestingWindowsStoreProxy.xml");等待 CurrentAppSimulator.ReloadSimulatorAsync(file);

                  • 对我来说,使用 C:UsersAppDataLocalPackagesLocalStateMicrosoftWindows StoreApiDataWindowsStoreProxy 中的默认值.xml没用,但一个更改已经解决了问题:我更改了这部分

                    <LicenseInformation><应用程序><IsActive>true</IsActive><IsTrial>true</IsTrial></应用程序></许可证信息>

                    到这里:

                    <LicenseInformation><应用程序><IsActive>true</IsActive><IsTrial>假</IsTrial></应用程序></许可证信息>

                    (所以 IsTrial 被设置为 false...)

                  • 现在我还想提一下,这有点奇怪,因为在默认的 WindowsStoreProxy.xml 中没有为我的应用内购买定义产品.所以对于我的RemoveAds",一个合适的 WindowsStoreProxy.xml 应该是这样的:

                    <?xml version="1.0" encoding="utf-16" ?><当前应用程序><房源信息><应用程序><AppId>00000000-0000-0000-0000-000000000000</AppId><LinkUri>http://apps.microsoft.com/webpdp/app/00000000-0000-0000-0000-000000000000</LinkUri><CurrentMarket>zh-CN</CurrentMarket><AgeRating>3</AgeRating><MarketData xml:lang="en-US"><名称>应用名称</名称><描述>应用描述</描述><价格>1.00</价格><CurrencySymbol>$</CurrencySymbol><CurrencyCode>USD</CurrencyCode></市场数据></应用程序><Product ProductId="RemoveAds" LicenseDuration="1" ProductType="Durable"><MarketData xml:lang="en-US"><名称>移除广告</名称><价格>1.00</价格><CurrencySymbol>$</CurrencySymbol><CurrencyCode>USD</CurrencyCode></市场数据></产品></列表信息><许可证信息><应用程序><IsActive>true</IsActive><IsTrial>假</IsTrial></应用程序><产品ProductId="1"><IsActive>true</IsActive></产品></许可证信息><消耗品信息><Product ProductId="RemoveAds" TransactionId="10000000-0000-0000-0000-000000000000" Status="Active"/></ConsumableInformation></当前应用程序>

                  • 我想指出的另一件事是带有两个参数的 CurrentAppSimulator.RequestProductPurchaseAsync 已过时.去掉 true 参数,你会得到 PurchaseResults 实例作为结果,它包含 ReceiptXML 属性中的收据.

                  I want to integrate in-app purchasing in my windows universal app. I do the following thing before coding.

                  • Make App on Windows Dev Center

                  • Add products with details in IAPs section and submit to Store as you can see in Image

                  • After that I use the following code in my app to get list of products of In-App purchasing and button to purchase product. I also used CurrentApp instead of CurrentAppSimulator in my code but it goes in exception.

                  private async void RenderStoreItems()
                      {
                          picItems.Clear();
                  
                          try
                          {
                              //StoreManager mySM = new StoreManager();
                              ListingInformation li = await CurrentAppSimulator.LoadListingInformationAsync();
                  
                              System.Diagnostics.Debug.WriteLine(li);
                  
                              foreach (string key in li.ProductListings.Keys)
                              {
                                  ProductListing pListing = li.ProductListings[key];
                                  System.Diagnostics.Debug.WriteLine(key);
                  
                                  string status = CurrentAppSimulator.LicenseInformation.ProductLicenses[key].IsActive ? "Purchased" : pListing.FormattedPrice;
                  
                                  string imageLink = string.Empty;
                  
                                  picItems.Add(
                                      new ProductItem
                                      {
                                          imgLink = key.Equals("BaazarMagzine101") ? "block-ads.png" : "block-ads.png",
                                          Name = pListing.Name,
                                          Status = status,
                                          key = key,
                                          BuyNowButtonVisible = CurrentAppSimulator.LicenseInformation.ProductLicenses[key].IsActive ? false : true
                                      }
                                  );
                              }
                  
                              pics.ItemsSource = picItems;
                          }
                          catch (Exception e)
                          {
                              System.Diagnostics.Debug.WriteLine(e.ToString());
                          }
                      }
                  
                      private async void ButtonBuyNow_Clicked(object sender, RoutedEventArgs e)
                      {
                          Button btn = sender as Button;
                  
                          string key = btn.Tag.ToString();
                  
                          if (!CurrentAppSimulator.LicenseInformation.ProductLicenses[key].IsActive)
                          {
                              ListingInformation li = await CurrentAppSimulator.LoadListingInformationAsync();
                              string pID = li.ProductListings[key].ProductId;
                  
                              string receipt = await CurrentAppSimulator.RequestProductPurchaseAsync(pID, true);
                  
                              System.Diagnostics.Debug.WriteLine(receipt);
                  
                              // RenderStoreItems();
                          }
                      }
                  

                  I also Associate my app with Store and my app package is same as in MS Dev Center App as you can see in Image

                  When I run my app and click on Buy button, I got this dialogue box as you can see in Image after that I did not get receipt data from Store.

                  If I'm doing wrong then Please give me proper guide to implement the In-app purchase and test that In-app purchase in my laptop device.

                  解决方案

                  I also had this issue and the problem was in the WindowsStoreProxy.xml file.

                  Solution in short

                  By default in the WindowsStoreProxy.xml the IsTrial is set to true and in that mode in-app purchases do not seem to work. When I changed it to false it started to work for me.

                  Solution a little bit longer

                  • So first of all here we are talking about the simulation of an In-App Purchase in development time (by using the CurrentAppSimulator class). In that case you need a WindowsStoreProxy.xml file. It’s described here

                  • Now the window you showed is opened by the CurrentAppSimulator.RequestProductPurchaseAsync line. It basically controls the return value of a Windows Runtime native method (which is very strange for me… I think it’s not intentional by Microsoft… something else should be done there), but if you let it return S_OK that basically is the case when the user paid for the in-App Purchase.

                  • When it returns nothing then with very high probability something in the WindowsStoreProxy.xml is wrong. I suggest you to create your own WindowsStoreProxy.xml and read it with the CurrentAppSimulator.ReloadSimulatorAsync method like this:

                    var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"TestingWindowsStoreProxy.xml");
                    await CurrentAppSimulator.ReloadSimulatorAsync(file);
                    

                  • For me using the default one from C:Users<username>AppDataLocalPackages<app package folder>LocalStateMicrosoftWindows StoreApiDataWindowsStoreProxy.xml did not work, but a single change already solved the problem: I changed this part

                    <LicenseInformation>
                            <App>
                                <IsActive>true</IsActive>
                                <IsTrial>true</IsTrial>
                            </App>
                    </LicenseInformation>
                    

                    To this:

                    <LicenseInformation>
                            <App>
                                <IsActive>true</IsActive>
                                <IsTrial>false</IsTrial>
                            </App>
                    </LicenseInformation>
                    

                    (So IsTrial was set to false...)

                  • Now at this point I also would like to mention that this was a little bit strange, since in in the default WindowsStoreProxy.xml there was no Product defined for my In-App Purchase. So for my "RemoveAds" a proper WindowsStoreProxy.xml would be something like this:

                    <?xml version="1.0" encoding="utf-16" ?>
                    <CurrentApp>
                        <ListingInformation>
                            <App>
                                <AppId>00000000-0000-0000-0000-000000000000</AppId>
                                <LinkUri>http://apps.microsoft.com/webpdp/app/00000000-0000-0000-0000-000000000000</LinkUri>
                                <CurrentMarket>en-US</CurrentMarket>
                                <AgeRating>3</AgeRating>
                                <MarketData xml:lang="en-US">
                                    <Name>AppName</Name>
                                    <Description>AppDescription</Description>
                                    <Price>1.00</Price>
                                    <CurrencySymbol>$</CurrencySymbol>
                                    <CurrencyCode>USD</CurrencyCode>
                                </MarketData>
                            </App>
                            <Product ProductId="RemoveAds" LicenseDuration="1" ProductType="Durable">
                                <MarketData xml:lang="en-US">
                                    <Name>RemoveAds</Name>
                                    <Price>1.00</Price>
                                    <CurrencySymbol>$</CurrencySymbol>
                                    <CurrencyCode>USD</CurrencyCode>
                                </MarketData>
                            </Product>      
                        </ListingInformation>
                        <LicenseInformation>
                            <App>
                                <IsActive>true</IsActive>
                                <IsTrial>false</IsTrial>
                            </App>
                            <Product ProductId="1">
                                <IsActive>true</IsActive>
                            </Product>
                        </LicenseInformation>
                        <ConsumableInformation>
                            <Product ProductId="RemoveAds" TransactionId="10000000-0000-0000-0000-000000000000" Status="Active" />
                        </ConsumableInformation>
                    </CurrentApp>
                    

                  • Another thing I would like to point out is that the CurrentAppSimulator.RequestProductPurchaseAsync with two parameter is obsolete. Leave the true parameter out and you get PurchaseResults instance as the result, which contains the receipt in the ReceiptXML property.

                  这篇关于如何在 Windows 10 应用中实现应用内购买?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  IBM.Data.DB2.Core connection problems(IBM.Data.DB2.Core 连接问题)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  Datetime field overflow with IBM Data Server Client v9.7fp5(IBM Data Server Client v9.7fp5 的日期时间字段溢出)
                  Using entity Framework with .NET Core and DB2(将实体框架与 .NET Core 和 DB2 结合使用)

                  <small id='WaX2q'></small><noframes id='WaX2q'>

                  <tfoot id='WaX2q'></tfoot>

                    <i id='WaX2q'><tr id='WaX2q'><dt id='WaX2q'><q id='WaX2q'><span id='WaX2q'><b id='WaX2q'><form id='WaX2q'><ins id='WaX2q'></ins><ul id='WaX2q'></ul><sub id='WaX2q'></sub></form><legend id='WaX2q'></legend><bdo id='WaX2q'><pre id='WaX2q'><center id='WaX2q'></center></pre></bdo></b><th id='WaX2q'></th></span></q></dt></tr></i><div id='WaX2q'><tfoot id='WaX2q'></tfoot><dl id='WaX2q'><fieldset id='WaX2q'></fieldset></dl></div>

                      • <bdo id='WaX2q'></bdo><ul id='WaX2q'></ul>
                            <tbody id='WaX2q'></tbody>
                          1. <legend id='WaX2q'><style id='WaX2q'><dir id='WaX2q'><q id='WaX2q'></q></dir></style></legend>