我正在创建一个实现 Soomla Unity IAP 插件的应用程序。在我努力让 IAP 工作的过程中,我已经到了可以在编辑器中进行购买的地步。(不是真正的购买,它只是更新用户可以在游戏中购买/消费的虚拟货币)。
当我在 Android 设备上启动它时,我收到此错误:需要身份验证。您需要登录您的 Google 帐户。
现在我已经阅读了多篇不同的文章,人们遇到了这个问题,但似乎没有任何帮助。
这是我迄今为止尝试过的列表:
1)确保应用程序发布到 alpha 或 beta 以进行测试。(现在在 alpha 中)
2) 确保游戏和开发者控制台中的价格匹配。
3) 使用以不使用开发者电子邮件的用户身份登录的设备。
4) 确保测试设备上的电子邮件在开发者控制台中列为测试人员。
5) 确保在 Android Manifest 中列出了必要的权限。
6) 确认商家帐户设置正确并经过验证。
7)确保构建为发布而不是开发(不确定这是否重要,但我尝试了两种方式)。
8) 从项目中完全删除所有 Soomla 插件,然后将其重新添加,同时非常密切地遵循教程,以确保没有遗漏任何小东西。还是没有骰子。
我已将核心和存储组件添加到场景中,它们是必需的。如果您对我应该如何解决此问题有任何其他想法,请告诉我。同时,这里是我用来设置 Soomla 的 StoreAssets.cs 代码:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Soomla.Store;
public class StoreAssets : IStoreAssets
{
public static bool purchased = false;
public int GetVersion()
{
return 0;
}
public void onItemPurchased(PurchasableVirtualItem pvi, string payload)
{
purchased = true;
}
public VirtualCurrency[] GetCurrencies()
{
return new VirtualCurrency[]{TOKEN_CURRENCY};
}
public VirtualGood[] GetGoods()
{
return new VirtualGood[] {BACKUP_FORCEFIELD, IMMUNITY, EMP, MULTIPLIER};
}
public VirtualCurrencyPack[] GetCurrencyPacks()
{
return new VirtualCurrencyPack[] {FIVE_TOKEN_PACK, TEN_TOKEN_PACK, FIFTY_TOKEN_PACK};
}
public VirtualCategory[] GetCategories()
{
return new VirtualCategory[]{};
}
/** Virtual Currencies **/
public static VirtualCurrency TOKEN_CURRENCY = new VirtualCurrency
(
"Token", // Name
"Token currency", // Description
"token_currency_ID" // Item ID
);
/** Virtual Currency Packs **/
public static VirtualCurrencyPack FIVE_TOKEN_PACK = new VirtualCurrencyPack
(
"5 Tokens", // Name
"5 token currency units", // Description
"5_tokens_id", // Item ID
5, // Number of currencies in the pack
"token_currency_ID", // ID of the currency associated with this pack
new PurchaseWithMarket
( // Purchase type (with real money $)
"tokens_5_PROD_ID", // Product ID
0.99 // Price (in real money $)
)
);
public static VirtualCurrencyPack TEN_TOKEN_PACK = new VirtualCurrencyPack
(
"10 Tokens", // Name
"10 token currency units", // Description
"10_tokens_id", // Item ID
10, // Number of currencies in the pack
"token_currency_ID", // ID of the currency associated with this pack
new PurchaseWithMarket
( // Purchase type (with real money $)
"tokens_10_PROD_ID", // Product ID
1.99 // Price (in real money $)
)
);
public static VirtualCurrencyPack FIFTY_TOKEN_PACK = new VirtualCurrencyPack
(
"50 Tokens", // Name
"50 token currency units", // Description
"50_tokens_id", // Item ID
50, // Number of currencies in the pack
"token_currency_ID", // ID of the currency associated with this pack
new PurchaseWithMarket
( // Purchase type (with real money $)
"tokens_50_PROD_ID", // Product ID
4.99 // Price (in real money $)
)
);
/** Virtual Goods **/
public static VirtualGood BACKUP_FORCEFIELD = new SingleUseVG
(
"BackupForcefield", // Name
"Secondary forcefield for extra protection.", // Description
"bff_ID", // Item ID
new PurchaseWithVirtualItem
( // Purchase type (with virtual currency)
"token_currency_ID", // ID of the item used to pay with
1 // Price (amount of coins)
)
);
public static VirtualGood EMP = new SingleUseVG
(
"Emp", // Name
"Clear the surrounding space of all lasers.", // Description
"emp_ID", // Item ID
new PurchaseWithVirtualItem
( // Purchase type (with virtual currency)
"token_currency_ID", // ID of the item used to pay with
5 // Price (amount of coins)
)
);
public static VirtualGood IMMUNITY = new SingleUseVG
(
"Immunity", // Name
"Immune to damage.", // Description
"immunity_ID", // Item ID
new PurchaseWithVirtualItem
( // Purchase type (with virtual currency)
"token_currency_ID", // ID of the item used to pay with
10 // Price (amount of coins)
)
);
public static VirtualGood MULTIPLIER = new SingleUseVG
(
"Multiplier", // Name
"Double your score per deflected laser.", // Description
"multiplier_ID", // Item ID
new PurchaseWithVirtualItem
( // Purchase type (with virtual currency)
"token_currency_ID", // ID of the item used to pay with
15 // Price (amount of coins)
)
);
}
为了购买物品,我打电话给:
StoreInventory.BuyItem("the id of my item");
要使用已购买的物品,我会致电:
StoreInventory.TakeItem("the id of my item");
StoreInventory 是一个在 Soomla 导入 Unity 时包含在其中的类。
这是完成购买和物品消耗的代码:
public class Purchase : MonoBehaviour
{
public Text tokens;
public static bool bffFilled = false,
immFilled = false, empFilled = false,
multFilled = false, init = false;
void Start()
{
if (!init)
{
init = true;
SoomlaStore.Initialize(new StoreAssets());
}
Token.updateTokens (tokens);
}
void Update()
{
if (StoreEvents.balanceChanged)
{
StoreEvents.balanceChanged = false;
Token.updateTokens(tokens);
}
}
public void BuyItem (int item)
{
if (item == 1)
{
StoreInventory.BuyItem (StoreAssets.FIVE_TOKEN_PACK.ItemId);
}
else if (item == 2)
{
StoreInventory.BuyItem (StoreAssets.TEN_TOKEN_PACK.ItemId);
}
else if (item == 3)
{
StoreInventory.BuyItem (StoreAssets.FIFTY_TOKEN_PACK.ItemId);
}
Token.updateTokens(tokens);
}
public void getUpgrade(int upgrade)
{
if (upgrade == 1)
{
bool bffNotBought = PlayerPrefs.GetInt("Bff Available", 0) == 0;
if (StoreAssets.TOKEN_CURRENCY.GetBalance() >= 1 && bffNotBought)
{
PlayerPrefs.SetInt("Bff Available", 1);
PlayerPrefs.Save();
bffFilled = true;
StoreInventory.TakeItem(StoreAssets.TOKEN_CURRENCY.ItemId, 1);
}
}
else if (upgrade == 2)
{
bool empNotBought = PlayerPrefs.GetInt("Emp Available", 0) == 0;
if (StoreAssets.TOKEN_CURRENCY.GetBalance() >= 5 && empNotBought)
{
PlayerPrefs.SetInt("Emp Available", 1);
PlayerPrefs.Save();
empFilled = true;
StoreInventory.TakeItem(StoreAssets.TOKEN_CURRENCY.ItemId, 5);
}
}
else if (upgrade == 3)
{
bool immNotBought = PlayerPrefs.GetInt("Imm Available", 0) == 0;
if (StoreAssets.TOKEN_CURRENCY.GetBalance() >= 10 && immNotBought)
{
PlayerPrefs.SetInt("Imm Available", 1);
PlayerPrefs.Save();
immFilled = true;
StoreInventory.TakeItem(StoreAssets.TOKEN_CURRENCY.ItemId, 10);
}
}
else if (upgrade == 4)
{
bool multNotBought = PlayerPrefs.GetInt("Mult Available", 0) == 0;
if (StoreAssets.TOKEN_CURRENCY.GetBalance() >= 15 && multNotBought)
{
PlayerPrefs.SetInt("Mult Available", 1);
PlayerPrefs.Save();
multFilled = true;
StoreInventory.TakeItem(StoreAssets.TOKEN_CURRENCY.ItemId, 15);
}
}
Token.updateTokens (tokens);
}
}
2015 年 8 月 26 日
我现在已经创建了一个谷歌组和一个谷歌社区来测试这个应用程序。我将我的其他 android 设备的电子邮件添加到这两个设备中,并使用提供的链接下载该应用程序。这样做仍然会导致与以前相同的错误。
2015 年 8 月 27 日
我刚刚注意到我的商家帐户上的信用卡已过期。我读过的一篇文章提到,如果商家帐户出现问题,就会出现这样的问题。我已经更新了信息,现在我必须等待他们将存款存入我的帐户以确保它正常工作。完成后,我将更新这是否解决了我当前的问题。
2015 年 8 月 31 日
最终在 Google Play 上验证了我的商家帐户后,我似乎仍然遇到了同样的问题。修复我的商家帐户并没有改变我无法分辨的任何事情。
我刚刚更新了我的帖子以包含我的整个 StoreAssets.cs 脚本以及我在玩家使用它们时用来购买和消费物品的内容。我添加了这个,因为我不知道还有什么问题。
2015 年 9 月 7 日
到目前为止仍然没有运气。问题在android中仍然存在。编辑器本身会进行测试购买,但如果无法从 android 设备进行购买,则会出现与上面列出的相同的错误。
15 年 9 月 9 日
作为一个快速更新,我尝试在没有在构建设置中选择开发构建的情况下构建项目,并将链接发送给我的 Google 社区中的所有人以便试一试。每个人的错误仍然与我的测试设备相同。
2015 年 9 月 11 日
在尝试了托尼指出的一些事情之后,我注意到当我使用它时没有调用 onBillingSupported() 函数:StoreEvents.OnBillingSupported += onBillingSupported; 我还不确定为什么。
2015 年 9 月 12 日
在完成了 soomla 网站上的教程之后,除了在后台启动 Iab 和欺诈保护之外,我已经完成了它所说的一切,因为它们不是必需的。仍然没有调用 onBillingSupported 方法,我仍然在 android 设备上遇到与以前相同的错误。
2015 年 9 月 12 日
我刚刚删除了 Soomla 插件的所有内容并导入了最新版本并再次按照说明进行操作,但仍然出现相同的错误。
2015 年 9 月 16 日
真的不知道我在这里缺少什么。删除所有 Soomla 插件然后再次添加后,多次尝试后仍然出现相同的错误。正如教程所说,我已经遵循了所有内容,并且我拥有上面的所有代码。