【问题标题】:purchase item in Store using In App purchase使用应用内购买在商店中购买商品
【发布时间】:2015-02-26 12:00:13
【问题描述】:

我只是想在我的演示程序上实现应用内购买。我正在执行以下代码。

  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 是我在 App Store 中注册的产品 ID。在此代码中我收到以下错误

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

虽然我只是写以下代码

        await CurrentAppSimulator.RequestProductPurchaseAsync("test_coins10");

它的工作完美,但编译器总是继续不购买块。

请注意产品 test_coins10 是消耗品

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

【问题讨论】:

    标签: c# xaml windows-phone-8.1


    【解决方案1】:

    参考:- Enable consumable in-app product purchases

    为什么要例外?

    你得到的操作试图访问有效范围之外的数据(Exception from HRESULT: 0x8000000B)这个异常,因为:-

     await CurrentAppSimulator.RequestProductPurchaseAsync("test_coins10",false);
    

    此方法在新版本中已弃用。因此你的例外。所以使用:-

    CurrentAppSimulator.RequestProductPurchaseAsync("test_coins10");
    

    为什么不购买区块?

    你总是会去 NotPurchaseBLock 因为你不是reporting back to Store 关于消耗品的履行。 这可以通过以下方式实现:-

    FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync("product2", product2TempTransactionId);
    

    编辑:- '完成您的请求时出现问题。请稍后再试。询问的人可能会发现此错误代码有帮助:805a0194'

    这可能由于多种原因而发生:- 所以谷歌它已经有很多结果了..

    但是对于这个错误代码:- 805a0194:-

    1. 问题:- 当有临时服务时出现此错误 中断。
    2. 解决方案:- 稍等片刻,然后重试。
    3. Cross check your region

    希望它会有所帮助:)

    【讨论】:

    • 有什么解决办法..??
    • 但是我如何发送履行,因为需要履行 transactionId 但是购买没有正确完成,所以如何通过 Transaction id.Transaction Id 值为 0000-000-00000。
    • 我是初学者,所以它可能有一些错误。据我所知,交易 ID 仅当且仅当购买正确完成时才会获得。
    • @ChiragSolanki 如果购买不正确,那么在这种情况下您将无能为力,首先请先纠正。同时删除“等待 CurrentAppSimulator.RequestProductPurchaseAsync("test_coins10",false);"为您的代码.. 并尝试。当您转到此切换案例“case ProductPurchaseStatus.Succeeded:”时,请检查代码本身中的注释。有一些信息你将如何完成..
    • 我很抱歉兄弟它有相同的错误。编译器无法成功阻止。你知道为什么购买不成功吗??并感谢回复
    猜你喜欢
    • 2015-12-09
    • 1970-01-01
    • 1970-01-01
    • 2012-06-09
    • 2012-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多