23

我正在创建一个实现 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 插件然后再次添加后,多次尝试后仍然出现相同的错误。正如教程所说,我已经遵循了所有内容,并且我拥有上面的所有代码。

4

4 回答 4

5

我从来没有遇到过你描述的问题。不过,我创建了一个私人 Google+ 社区,并将该社区添加为测试人员。将我的应用程序转移到测试版。并邀请人们到我的私人社区,那里有一个下载应用程序和测试它的链接。很容易。

第二点,是你上面的代码。您正在获取 4 个商品和 3 个货币包,但代码并未反映这一点。也许你只粘贴了一半的课程。

最后,看看这个线程是否有帮助:http ://answers.soom.la/t/solved-some-clarification-about-iab-testing/2067/8

顺便说一句,SOOMLA 有一个专门的站点 answers.soom.la 用于 SOOMLA 相关问题。

于 2015-08-25T07:14:56.340 回答
1

您是否尝试从其他设备购买商品?我以前遇到过这个问题,但不记得我是如何解决的。据我记得当它对我失败时,它在不同同事的设备上工作。尝试在不同的设备上进行测试。另外,您的设备上是否有多个 Google 帐户?我记得我尝试过的一件事是从我的设备中删除所有 google 帐户,然后只注册我的主帐户。不幸的是,我不记得这是否有效,但我希望它会对你有所帮助。如果您知道如何修复它,请在此处发布更新。祝你好运

于 2015-09-09T09:07:57.193 回答
1

就我而言,我没有意识到我用于我的项目 ID 和我的产品 ID 的内容是混淆的。商品 ID 只是为了在 soomla 中识别商品,商品 ID 是我在 google play 中设置的实际我给你的。

于 2015-09-20T20:57:50.553 回答
0

从评论中的简短讨论看来,您可能没有实现所有内容。

查看此链接: http: //know.soom.la/unity/store/store_gettingstarted/

在“入门”部分中,它指出..

  1. 创建您自己的 IStoreAssets 实现以描述您游戏的特定资产。

  2. 使用您刚刚创建的类初始化 SoomlaStore:

SoomlaStore.Initialize(new YourStoreAssetsImplementation());

在 MonoBehaviour 的 Start 函数中初始化 SoomlaStore 而不是在 Awake 函数中。SOOMLA 有自己的 MonoBehaviour,需要在初始化之前“唤醒”它。

当您的应用程序加载时,仅初始化一次 SoomlaStore。

初始化也在此页面上得到确认。 http://know.soom.la/unity/store/store_istoreassets/

这表示它不是强制性的,但看起来很有帮助

如果您在游戏中实现了自己的店面,建议您在商店打开时在后台打开 IAB 服务,并在商店关闭时关闭它。

// 启动 Iab 服务 SoomlaStore.StartIabServiceInBg();

// 停止 Iab 服务 SoomlaStore.StopIabServiceInBg();

这不是强制性的,您的游戏可以在没有它的情况下运行,但我们建议您这样做,因为它可以提高性能。这里的想法是先发制人地使用谷歌(或亚马逊)的服务器启动应用内计费设置过程。

您可以尝试将日志记录添加到初始化事件以确保它正在初始化。这是您可以尝试从中记录的事件列表。

http://know.soom.la/unity/store/store_events/

注意:你需要注意的一件事是,如果你想监听 OnSoomlaStoreInitialized 事件,你必须在初始化 SoomlaStore 之前设置监听器。所以你需要这样做:

StoreEvents.OnSoomlaStoreInitialized += onSoomlaStoreInitialized;

Soomla.SoomlaStore.Initialize(新 Soomla.Example.MuffinRushAssets());

您还可以使用一些日志记录设置 OnBillingSetup 事件,以确保它正确初始化您的计费。

StoreEvents.OnBillingSupported += onBillingSupported;

public void onBillingSupported() { // ... 你的游戏具体实现在这里 ... }

于 2015-09-11T03:16:10.600 回答