I made an example project with IAP included and it still gives the same error:
PEX-CatalogAvailabilityDataNotFound
QaT+TOhel02uKXWP
Here is the script:
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
#if WINDOWS_UWP
using Windows.Services.Store;
#endif
public class IapScript : MonoBehaviour
{
#if WINDOWS_UWP
private StoreContext storeContext = null;
#endif
// Add-on product IDs in the Store
private string speed_x1 = "Speed_x1";
private string speed_x3 = "Speed_x3";
private string jump_x1 = "Jump_x1";
private string jump_x3 = "Jump_x3";
private string poison_x1 = "Poison_x1";
private string poison_x3 = "Poison_x3";
// UI elements for displaying prices
public TextMeshProUGUI speed_x1PriceText;
public TextMeshProUGUI speed_x3PriceText;
public TextMeshProUGUI jump_x1PriceText;
public TextMeshProUGUI jump_x3PriceText;
public TextMeshProUGUI poison_x1PriceText;
public TextMeshProUGUI poison_x3PriceText;
//Powerup Count
private int speedPowerupCount = 1;
private int jumpPowerupCount = 1;
private int poisonPowerupCount = 1;
public TextMeshProUGUI speedAmountText;
public TextMeshProUGUI jumpAmountText;
public TextMeshProUGUI poisonAmountText;
void Start()
{
#if WINDOWS_UWP
storeContext = StoreContext.GetDefault();
#endif
if (PlayerPrefs.HasKey("speedCount") && PlayerPrefs.HasKey("jumpCount") && PlayerPrefs.HasKey("poisonCount"))
{
LoadPrices();
}
else
{
PlayerPrefs.SetInt("speedCount", speedPowerupCount);
PlayerPrefs.SetInt("jumpCount", jumpPowerupCount);
PlayerPrefs.SetInt("poisonCount", poisonPowerupCount);
SaveData();
}
}
private void Update()
{
speedAmountText.text = speedPowerupCount.ToString();
jumpAmountText.text = jumpPowerupCount.ToString();
poisonAmountText.text = poisonPowerupCount.ToString();
}
private async void LoadPrices()
{
//#if WINDOWS_UWP
// string[] productKinds = { "Consumable" };
// StoreProductQueryResult result = await storeContext.GetAssociatedStoreProductsAsync(productKinds);
// if (result.ExtendedError != null)
// {
// Debug.LogError("Error retrieving add-ons: " + result.ExtendedError.Message);
// return;
// }
// foreach (KeyValuePair<string, StoreProduct> product in result.Products)
// {
// //ForSpeed
// if (product.Key == speed_x1 && product.Value is StoreProduct speed_x1Product)
// {
// speed_x1PriceText.text = speed_x1Product.Price.FormattedBasePrice;
// }
// else if (product.Key == speed_x3 && product.Value is StoreProduct speed_x3Product)
// {
// speed_x3PriceText.text = speed_x3Product.Price.FormattedBasePrice;
// }
// //ForJump
// else if (product.Key == jump_x1 && product.Value is StoreProduct jump_x1Product)
// {
// jump_x1PriceText.text = jump_x1Product.Price.FormattedBasePrice;
// }
// else if (product.Key == jump_x3 && product.Value is StoreProduct jump_x3Product)
// {
// jump_x3PriceText.text = jump_x3Product.Price.FormattedBasePrice;
// }
// //ForPoison
// else if (product.Key == poison_x1 && product.Value is StoreProduct poison_x1Product)
// {
// poison_x1PriceText.text = poison_x1Product.Price.FormattedBasePrice;
// }
// else if (product.Key == poison_x3 && product.Value is StoreProduct poison_x3Product)
// {
// poison_x3PriceText.text = poison_x3Product.Price.FormattedBasePrice;
// }
// }
//#endif
#if WINDOWS_UWP
// Define the product types you're looking for in a List<string>
string[] productKinds = { "Consumable" };
List<string> filterList = new List<string>(productKinds);
// Query the associated store products with the filter list
StoreProductQueryResult result = await storeContext.GetAssociatedStoreProductsAsync(filterList);
if (result.ExtendedError != null)
{
Debug.LogError("Error retrieving add-ons: " + result.ExtendedError.Message);
return;
}
foreach (KeyValuePair<string, StoreProduct> product in result.Products)
{
// For Speed Power-Ups
if (product.Key == speed_x1 && product.Value is StoreProduct speed_x1Product)
{
speed_x1PriceText.text = speed_x1Product.Price.FormattedBasePrice;
}
else if (product.Key == speed_x3 && product.Value is StoreProduct speed_x3Product)
{
speed_x3PriceText.text = speed_x3Product.Price.FormattedBasePrice;
}
// For Jump Power-Ups
else if (product.Key == jump_x1 && product.Value is StoreProduct jump_x1Product)
{
jump_x1PriceText.text = jump_x1Product.Price.FormattedBasePrice;
}
else if (product.Key == jump_x3 && product.Value is StoreProduct jump_x3Product)
{
jump_x3PriceText.text = jump_x3Product.Price.FormattedBasePrice;
}
// For Poison Power-Ups
else if (product.Key == poison_x1 && product.Value is StoreProduct poison_x1Product)
{
poison_x1PriceText.text = poison_x1Product.Price.FormattedBasePrice;
}
else if (product.Key == poison_x3 && product.Value is StoreProduct poison_x3Product)
{
poison_x3PriceText.text = poison_x3Product.Price.FormattedBasePrice;
}
}
#endif
}
// Methods for purchasing the add-ons
//ForSpeed
public async void BuySpeed_x1()
{
await PurchaseAddOn(speed_x1, 1, "speed");
//RewardPlayer(1, "speed");
}
public async void BuySpeed_x3()
{
await PurchaseAddOn(speed_x3, 3, "speed");
//RewardPlayer(3, "speed");
}
//ForJump
public async void BuyJump_x1()
{
await PurchaseAddOn(jump_x1, 1, "jump");
//RewardPlayer(1, "jump");
}
public async void BuyJump_x3()
{
await PurchaseAddOn(jump_x3, 3, "jump");
//RewardPlayer(3, "jump");
}
//ForPoison
public async void BuyPoison_x1()
{
await PurchaseAddOn(poison_x1, 1, "poison");
//RewardPlayer(1, "poison");
}
public async void BuyPoison_x3()
{
await PurchaseAddOn(poison_x3, 3, "poison");
//RewardPlayer(3, "poison");
}
private async Task PurchaseAddOn(string productId, int rewardAmount, string powerUpType)
{
#if WINDOWS_UWP
StorePurchaseResult result = await storeContext.RequestPurchaseAsync(productId);
if (result.ExtendedError != null)
{
Debug.LogError("Error during purchase: " + result.ExtendedError.Message);
return;
}
switch (result.Status)
{
case StorePurchaseStatus.Succeeded:
RewardPlayer(rewardAmount, powerUpType);
break;
case StorePurchaseStatus.AlreadyPurchased:
RewardPlayer(rewardAmount, powerUpType);
Debug.Log("You already own this item.");
break;
case StorePurchaseStatus.NotPurchased:
Debug.Log("Purchase canceled.");
break;
case StorePurchaseStatus.NetworkError:
Debug.Log("Network error during purchase.");
break;
case StorePurchaseStatus.ServerError:
Debug.Log("Server error during purchase.");
break;
default:
Debug.Log("Unknown error during purchase.");
break;
}
#endif
}
// Rewarding the player with Speed PowerUps
private void RewardPlayer(int amount, string powerUpType)
{
if (powerUpType == "speed")
{
speedPowerupCount += amount;
SaveData();
}
else if (powerUpType == "jump")
{
jumpPowerupCount += amount;
SaveData();
}
else if (powerUpType == "poison")
{
poisonPowerupCount += amount;
SaveData();
}
}
public void LoadData()
{
PlayerPrefs.GetInt("speedCount");
PlayerPrefs.GetInt("jumpCount");
PlayerPrefs.GetInt("poisonCount");
}
public void SaveData()
{
PlayerPrefs.SetInt("speedCount", speedPowerupCount);
PlayerPrefs.SetInt("jumpCount", jumpPowerupCount);
PlayerPrefs.SetInt("poisonCount", poisonPowerupCount);
}
}
The same error keeps occuring.