Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用应用内购买在商店中购买商品_C#_Xaml_Windows Phone 8.1 - Fatal编程技术网

C# 使用应用内购买在商店中购买商品

C# 使用应用内购买在商店中购买商品,c#,xaml,windows-phone-8.1,C#,Xaml,Windows Phone 8.1,我只是想在我的演示程序中实现应用内购买 Guid product1TempTransactionId; async void BuyFirstProduct() { if (!LicenceInfo.ProductLicenses["test_coins10"].IsActive) { try { await CurrentAppSimulator.RequestProductP

我只是想在我的演示程序中实现应用内购买

  Guid product1TempTransactionId;
   async void BuyFirstProduct()
   {
       if (!LicenceInfo.ProductLicenses["test_coins10"].IsActive)
       {
           try
           {
               await CurrentAppSimulator.RequestProductPurchaseAsync("test_coins10",false);

               PurchaseResults purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync("test_coins10");


               switch (purchaseResults.Status)
               {
                   case ProductPurchaseStatus.Succeeded:
                       product1TempTransactionId = purchaseResults.TransactionId;
                       Debug.WriteLine("Sucess" + product1TempTransactionId.ToString());
                       // Grant the user their purchase here, and then pass the product ID and transaction ID to currentAppSimulator.reportConsumableFulfillment
                       // To indicate local fulfillment to the Windows Store.
                       break;

                   case ProductPurchaseStatus.NotFulfilled:
                       //product1TempTransactionId = purchaseResults.TransactionId;
                       Debug.WriteLine("Fail");
                       break;
                   case ProductPurchaseStatus.NotPurchased:
                       Debug.WriteLine("Not Purchase");
                       break;
               }


           }
           catch (Exception e)
           {
               msg.Content = "" + e.ToString();
               msg.Title = "Error";
                 msg.ShowAsync();

           }

       }
       else
       {
           msg.Content = "You Already Have a This Pack";
           msg.Title = "Error";
           await msg.ShowAsync();
       }
   }
这里test_coins10是我在应用商店注册的产品id

操作试图访问有效范围之外的数据(HRESULT异常:0x800000B)

而我只是写下面的代码

        await CurrentAppSimulator.RequestProductPurchaseAsync("test_coins10");
它的工作非常完美,但编译器总是不停地运行

请注意,产品测试10是消耗品

如果任何人有任何不同的想法,请回复。

参考:-

为什么会出现异常?

您正在获取试图访问有效范围之外的数据的操作
(HRESULT:0x800000B的异常)
此异常是因为:-

 await CurrentAppSimulator.RequestProductPurchaseAsync("test_coins10",false);
新版本中不推荐使用此方法。因此你例外。因此,请使用:-

CurrentAppSimulator.RequestProductPurchaseAsync("test_coins10");
为什么不进行PurchaseBlock?

您总是要去NotPurchaseBLock,因为您没有
向门店
报告消耗品的履行情况。 这可以通过以下方式实现:-

FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync("product2", product2TempTransactionId);
编辑:-“完成要求时出现问题。请稍后再试。询问者可能会发现此错误代码很有用:805a0194”

这可能是由于多种原因造成的:-所以谷歌it已经有很多结果了

但对于此错误代码:-805a0194:-

  • 问题:-存在临时服务时会发生此错误 破坏
  • 解决方案:-请稍等片刻,然后重试

  • 希望能有所帮助:)

    有什么解决方案吗..但我如何发送履行,因为履行需要transactionId,但购买未正确完成,因此如何传递事务id。事务id值为0000-000-00000。我是初学者,因此可能会有一些错误。据我所知,事务id仅在如果购买是正确的。@ChiragSolanki如果购买是不正确的,那么在这种情况下你什么都做不了,首先要做正确的事情。同时删除代码中的“wait CurrentAppSimulator.RequestProductPurchaseAsync(“test_coins10”,false);”。。试试看。当您转到此切换案例“case ProductPurchaseStatus.Successed:”时,请检查代码本身中的注释。这里有一些您将如何完成完整填充的信息。很抱歉,兄弟,它有相同的错误。编译器没有进入成功块。您知道为什么购买没有成功吗。??谢谢你的回复