0

我一直在(慢)通过应用程序内购买示例。 我在应用程序中为我的应用程序购买了2个应用程序。我已将Visual Studio关联到该应用程序。当我通过请求我的应用程序购买进入回调函数时,我终于没有任何错误。Windows通用应用程序 - 应用程序内购买

的错误:它说,有0产品时,应该有2

我的代码:

var ProductsARR = []; 

var storeContext = Windows.Services.Store.StoreContext.getDefault(); 
var productKinds = ["Consumable", "Durable", "UnmanagedConsumable"]; 
storeContext.getAssociatedStoreProductsAsync(productKinds).then(function (addOns) { 
    var i; 
    if (addOns.extendedError) { 
     if (addOns.extendedError === (0x803f6107 | 0)) { 
      alert("This sample has not been properly configured."); 
     } else { 
      // The user may be offline or there might be some other server failure. 
      alert("ExtendedError: " + addOns.extendedError.toString()); 
     } 
    } else if (addOns.products.size === 0) { 
     alert("No configured Add-ons found for this Store Product."); 
    } else { 
     for (i = 0; i < addOns.products.size;i++){ 
      var item = { 
       title: addOns.products[i].title, 
       price: addOns.products[i].price.formattedPrice, 
       inCollection: addOns.products[i].isInUserCollection, 
       productKind: addOns.products[i].productKind, 
       storeId: addOns.products[i].storeId 
      }; 

      ProductsARR .push(item); 
     } 
    } 
}); 

什么能导致它认为有没有在应用内购买,其中有2个?

我认为唯一可能导致混淆的是我还没有将实际的xapproduct提交给商店,但我不想这样做,直到我充实了代码的其余部分。我现在正在开发应用内购买代码。这可能会导致问题吗?

如果不是,还有什么可能导致问题。它在我的仪表板中说应用内购买是'In Store'。

回答

1

The only thing I think could be causing confusion is I have not submitted the actual xapproduct to the store yet, but I do not want to do that until I have fleshed out the rest of the code.

您使用Windows.Services.Store命名空间,它不提供类,您可以使用测试过程中模拟许可证信息,不像Windows.ApplicationModel.Store provding的CurrentAppSimulator类。因此,您必须发布应用程序并将其下载到开发设备以使用其许可证进行测试。

为了测试目的,此应用程序不需要是您的真实版本,而是满足最低Windows应用程序认证套件要求的基本应用程序。此外,您可以先选择hide this app以防止客户在测试期间看到您的应用。

有关测试指导的更多详细信息,请参阅Test your in-app purchase or trial implementation

2

您必须将产品提交给商店。他们通过认证过程,你应该收到2封电子邮件,说明“你的productX已被认证”。

如果您不希望此产品出现并且只能用于Beta测试,请确保它的可用性设置为“在应用商店中隐藏此应用”。

Here's some info