2015-12-21 62 views
14

我試圖在我的應用程序(已在Windows 10商店中)上啓用應用程序內購買項目,但試圖購買此項目時我總是收到相同的錯誤消息:Windows 10中的應用程序內購買問題UWP

This in-App Purchase item is no longer available in MyAppName

此應用程序內購買產品不再提供MyAppName

的代碼是相當簡單的,只是什麼樣的文檔建議:

var itemName = "app.advanced_items.full"; 
if (CurrentApp.LicenseInformation.ProductLicenses[itemName].IsActive) { 
    return true; 
} 
var results = await CurrentApp.RequestProductPurchaseAsync(itemName); 

if (results.Status == ProductPurchaseStatus.Succeeded || 
    results.Status == ProductPurchaseStatus.AlreadyPurchased) { 
    return true; 
} else { 
    return false; 
} 

的更多信息:

  • 我創建並submited在應用程序的項目店裏構建軟件包之前的文檔告訴我
  • 該項目的名稱是相同的兩個在商店和應用程序(itemName上的代碼)
  • 我試過這之前提交到商店
  • 我試過後提交到商店(我的應用程序目前打破了那裏! - 無法購買物品)

我懷疑問題可能與以下有關:

  • 該應用程序的顯示名稱(上Package.appxmanifest)是不是在商店相同的應用程序名稱(我想要的名稱是不可用的,所以我做了更長的時間,但安裝後的應用程序將顯示原始名稱)。這個較短的名稱是錯誤信息中的一個...

我將「顯示名稱」更改爲應用程序的全名,但錯誤相同。我不知道這是否發送到商店可能會改變這一點(我不希望部署的另一個版本,越野車只是爲了驗證這一理論)

附加: 唯一的資源,我在網上找到關於這個問題是無用的並與Windows 8相關:link

建議?

+1

我有一個消耗品顯示爲IAPs溢價和標籤是溢價和我使用的密鑰也溢價。所以可能會使用點和其他符號在某個地方有一個錯誤,誰知道 –

+1

@JuanPabloGarciaCoello如果我只能在將應用程序提交到商店之前進行可靠的測試,那麼我相信商店會修改軟件包以包含應用程序內購買信息 – JBernardo

+0

在我的案例中,此消息'選擇另一個項目'在IAP項目認證後的幾天內顯示。但後來,錯誤消息已經消失。 – pnp0a03

回答

5

經過兩個月與微軟的支持交談,他們終於在他們身上修正了一些問題,我的IAP開始工作。

我相信修復是全球性的,但如果您的IAP仍然無法使用,請與他們聯繫以重新發布它。

下面是他們給我發電子郵件的摘錄:

我們已經發布了在這個應用程式單邊行動計劃重新發布。這應該是 在過程完成後立即糾正這種情況。您可能希望 在接下來的幾個小時內定期檢查,看看您是否能夠 確認修復工作適合您。讓我知道你看到了什麼。

+0

終於:)問題不在於代碼然後:P – Razor

+0

是的,這是MS問題,新的應用程序仍然有空的ProductLicenses集合,但ProductListing包含產品,並且在WinPhone商店應用程序中查看時,新應用程序沒有圖標和屏幕截圖。 – f14shm4n

4

請檢查IAP的產品ID。我猜你在代碼中提到的那個與商店中的不一樣。

如果它相同,我建議使用方法LoadListingInformationAsync它返回IAP的列表,然後從該列表中選擇所需的IAP。 如果名稱不匹配,那麼您將無法檢索該IAP。所以我們可以找到它,因爲命名問題。 我也添加了一個示例代碼。試一下。

 try 
     { 
      var listing = await CurrentApp.LoadListingInformationAsync(); 
      var iap = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == "removeads"); 
      receipt = await CurrentApp.RequestProductPurchaseAsync(iap.Value.ProductId, true); 
      if (CurrentApp.LicenseInformation.ProductLicenses[iap.Value.ProductId].IsActive) 
      { 
       CurrentApp.ReportProductFulfillment(iap.Value.ProductId); 
       //your code after purchase is successful 
      } 
     } 
     catch (Exception ex) 
     { 
      //exception 
     } 
+0

問題是,就像我上面寫的評論一樣,我的'ProductListings'總是空的'IReadOnlyDictionary' ...我的儀表板上有3個IAP項目,並且它們都在幾天前被標記爲已發佈。然而,我收到了一個空對象 – JBernardo

+0

,您是在新儀表板中創建了您的IAP嗎?還是使用在舊儀表板中創建的對象?如果舊儀表板更新IAP並將其設置爲可用的所有市場。看看MSDN ......看起來很多人都有這個問題。 [original MSDN post](https://social.msdn.microsoft.com/Forums/en-US/a44b7364-4017-4d98-ad40-dcc03dac4311/cant-find-item-in-catalog?forum=wpdevelop&prof=required) – Razor

+0

我在新的儀表板上創建了 – JBernardo

1

我相信這裏的問題是您需要區分測試和生產。除非您在商店中發佈,否則您無法使用生產模式。請參閱CurrentAppCurrentAppSimulator

CurrentAppSimiulator頁:

備註

直到應用從Windows應用商店已經上市,CurrentApp對象將不會在應用程序工作。使用CurrentAppSimulator在開發應用程序時測試應用程序的許可和應用程序內產品。在測試應用程序之後,在將其提交到Windows應用商店之前,必須用CurrentApp替換CurrentAppSimulator的實例。如果使用CurrentAppSimulator,您的應用程序將無法通過認證。

這是我如何解決這個問題在我的應用程序與我的測試/生產改變的#define,那CurrentApp和CurrentAppSimulator之間切換,使我的其他代碼的眼睛更容易的代理類。

App.xaml.cs,應用程序()

  // 
      // configure in-app purchasing 
      // 
#if false 
#warning WARNING: You are using CurrentAppProxy in TEST MODE! 
      CurrentAppProxy.SetTestMode(true); // true for test, false for production 
#else 
      CurrentAppProxy.SetTestMode(false); // true for test, false for production 

CurrentAppProxy.cs

public static class CurrentAppProxy 
{ 
    static bool? testmode = null; 
    public static async void SetTestMode(bool mode) 
    { 
     testmode = mode; 
     if (mode) 
     { 
      var file = await Package.Current.InstalledLocation.GetFileAsync("WindowsStoreProxy.xml"); 
      if (file != null) 
      { 
       await CurrentAppSimulator.ReloadSimulatorAsync(file); 
      } 
     } 
    } 

    public static LicenseInformation LicenseInformation 
    { 
     get 
     { 
      if (testmode == null) throw new NotSupportedException(); 
      else if (testmode.Value) return CurrentAppSimulator.LicenseInformation; 
      else return CurrentApp.LicenseInformation; 
     } 
    } 

    public static IAsyncOperation<IReadOnlyList<UnfulfilledConsumable>> GetUnfulfilledConsumablesAsync() 
    { 
     if (testmode == null) throw new NotSupportedException(); 
     else if (testmode.Value) return CurrentAppSimulator.GetUnfulfilledConsumablesAsync(); 
     else return CurrentApp.GetUnfulfilledConsumablesAsync(); 
    } 

    public static IAsyncOperation<ListingInformation> LoadListingInformationAsync() 
    { 
     if (testmode == null) throw new NotSupportedException(); 
     else if (testmode.Value) return CurrentAppSimulator.LoadListingInformationAsync(); 
     else return CurrentApp.LoadListingInformationAsync(); 
    } 

    public static IAsyncOperation<FulfillmentResult> ReportConsumableFulfillmentAsync(string productId, Guid transactionId) 
    { 
     if (testmode == null) throw new NotSupportedException(); 
     else if (testmode.Value) return CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, transactionId); 
     else return CurrentApp.ReportConsumableFulfillmentAsync(productId, transactionId); 
    } 

    public static IAsyncOperation<PurchaseResults> RequestProductPurchaseAsync(string productId) 
    { 
     if (testmode == null) throw new NotSupportedException(); 
     else if (testmode.Value) return CurrentAppSimulator.RequestProductPurchaseAsync(productId); 
     else return CurrentApp.RequestProductPurchaseAsync(productId); 
    } 
} 

在我的應用程序使用...

private async Task RefreshInAppOffers() 
    { 
     // in-app offers 
     List<KeyValuePair<string, ProductListing>> products = null; 
     UnfulfilledConsumable unfulfilledConsumable = null; 

     InAppOffers.Children.Clear(); 

     try 
     { 
      var listinginfo = await CurrentAppProxy.LoadListingInformationAsync(); 
      products = listinginfo.ProductListings.ToList(); 
      products.Sort((p1, p2) => p1.Value.FormattedPrice.CompareTo(p2.Value.FormattedPrice)); 

CurrentAppProxy是他們在這裏的關鍵。如果它適用於模擬器,它應該適用於您的生產項目。你只需要爲所有各種條件準備好所有其他部分。一些測試在調試器中最容易實現。

+1

事情是,我不能在生產中使用CurrentApp,很難相信即使我的應用程序已經發布,我也只能使用CurrentAppSimulator,即使我在商店上發佈的應用程序的行爲與CurrentApp的行爲方式相同 – JBernardo

0

我有同樣的問題。在我的情況下,解決方案是在IAP中添加所有語言描述,然後工作正常

+0

我試過了,但它沒有工作 – JBernardo

0

我的新UWP應用程序「Midi Player」有類似的問題。 IAP在認證和發佈後即可在WP 8.1上購買,但在W10M(Windows 10 Mobile)平臺上顯示同樣的錯誤(我相信所有Windows 10 UWP應用都有相同的商店)。 我向微軟公開了一個問題,但他們無法幫助我。幸運的是,現在的問題是走了:)我做了什麼:

  • 公佈的初步應用修訂創建IAP
  • 測試IAP(適用於WP8.1,不工作的W10M)
  • 我發現我Package.appxmanifest文件略有變化(該字符串熔點:PhoneIdentity PhoneProductId = 「7f32ab79-XXX-XXX-AFF3-ce228745b36f」 PhonePublisherId = 「00000000-0000-0000-0000-000000000000」)發佈
  • 我改變了版本(次要號碼),並提交新的版本更改Package.appxmanifest
  • 今天,我檢查了W10M Lumia 950的IAP,它的工作原理。

所以,我的結論是:

  • 你需要創建IAP
  • 後重新發布應用您應該等待一點點
+0

我發佈了e應用程序創建IAP(所有時間)後,等待兩週... :( – JBernardo

+0

對不起,您是否嘗試聯繫商店的客戶支持? MS商店是有點兒越野車,我仍然有一對未解決的問題(並沒有希望解決因爲支持是非常不專業) – SeNS

+0

是的,支持是非常不專業的那裏...我發佈了[答案](http:///stackoverflow.com/a/34663266/754991)以我的經驗 – JBernardo

1

我試了一下這個聯繫微軟問題,他們要求我使IAP不可用,然後再次提供。 我必須說,它並沒有解決我的問題,但如果你想給它一個嘗試,請按照下列步驟操作:

  1. 的IAP
  2. 創建一個更新下的分配和可見性設置IAP爲不可供購買
  3. 提交更新
  4. 等待更新發布
  5. 創建IAP
  6. 一個新的更新
  7. 集合分發和可見回可供購買
  8. 提交更新
  9. 一旦更新發布,複試IAP

之後,他們告訴我要嘗試使整個應用程序無法使用到所有國家和發佈。然後做相反的事情。沒有成功...