【问题标题】:Google play error when making a purchase while implementing Soomla Unity3d plugin在实施 Soomla Unity3d 插件时进行购买时出现 Google 播放错误
【发布时间】:2015-11-18 12:53:22
【问题描述】:

我正在创建一个实现 Soomla Unity IAP 插件的应用程序。在我努力让 IAP 工作的过程中,我已经到了可以在编辑器中进行购买的地步。 (不是真正的购买,它只是更新用户可以在游戏中购买/消费的虚拟货币)。

当我在 Android 设备上启动它时,我收到此错误:需要身份验证。您需要登录您的 Google 帐户。

现在我已经阅读了多篇不同的文章,人们遇到了这个问题,但似乎没有任何帮助。

这是我迄今为止尝试过的列表:

1) 确保应用发布到 Alpha 版或 Beta 版进行测试。(现在处于 Alpha 版)

2) 确保游戏和开发者控制台中的价格匹配。

3) 使用以未使用开发者电子邮件的用户身份登录的设备。

4) 确保测试设备上的电子邮件在开发者控制台中列为测试人员。

5) 确保 Android 清单中列出了必要的权限。

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);
    }
}

8/26/15

我现在已经创建了一个谷歌组和一个谷歌社区来测试这个应用程序。我将我的其他 android 设备的电子邮件添加到这两个设备中,并使用提供的链接下载该应用程序。执行所有这些操作仍然会导致与以前相同的错误。

8/27/15

我刚刚注意到我的商家帐户中的信用卡已过期。我读过的一篇文章提到,如果商家帐户出现问题,就会出现这样的问题。我已经更新了信息,现在我必须等待他们将存款存入我的帐户以确保它正常工作。完成后,我将更新这是否解决了我当前的问题。

8/31/15

最终在 Google Play 上验证了我的商家帐户后,我似乎仍然遇到了同样的问题。修复我的商家帐户并没有改变我无法判断的任何事情。

我刚刚更新了我的帖子以包含我的整个 StoreAssets.cs 脚本以及我在玩家使用它们时用来购买和消耗物品的内容。我添加了这个,因为我不知道还有什么问题。

9/7/15

到目前为止仍然没有运气。问题在android中仍然存在。编辑器本身会进行测试购买,但如果无法从 android 设备进行购买,则会出现与上面列出的相同的错误。

9/9/15

作为快速更新,我尝试在构建设置中未选择开发构建的情况下构建项目,并将链接发送给我的 Google 社区中的所有人,以便试一试。每个人的错误仍然与我的测试设备相同。

9/11/15

在尝试了 Tony 指出的一些事情之后,我注意到当我使用这个时没有调用 onBillingSupported() 函数:StoreEvents.OnBillingSupported += onBillingSupported;我还不知道为什么。

9/12/15

在完成了 soomla 网站上的教程之后,除了在后台启动 Iab 和欺诈保护之外,我已经完成了它所说的一切,因为它们不是必需的。仍然没有调用 onBillingSupported 方法,我仍然在 android 设备上遇到与以前相同的错误。

9/12/15

我刚刚删除了 Soomla 插件的所有内容并导入了最新版本并再次按照说明进行操作,但仍然出现相同的错误。

9/16/15

真的不知道我在这里缺少什么。删除所有 Soomla 插件然后再次添加后,多次尝试后仍然出现相同的错误。正如教程所说,我已经遵循了所有内容,并且我拥有上面的所有代码。

【问题讨论】:

  • 我没有看到您实际用于向 google 进行身份验证或初始化商店的代码。检查此线程可能会有所帮助,但需要更多代码来提供更多帮助。 stackoverflow.com/questions/28079738/…
  • @Tony 我更新了更多代码。谢谢。
  • @Tony 我还注意到你给我看的帖子初始化了类中的 StoreAssets。我删除了它,因为我看到它已经在 SoomlaUtils.cs 中初始化。它在检查器中显示为正在初始化,并且购买和消费显示在检查器中。
  • @Tony 如果这不正确,请告诉我,我仍然应该自己初始化它。令人困惑的是,它在检查器中自行初始化,而我看到的所有内容都需要初始化。

标签: c# android unity3d in-app-purchase soomla


【解决方案1】:

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

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

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

顺便说一下,SOOMLA 有一个专门的网站 answers.soom.la 用于解决 SOOMLA 相关问题。

【讨论】:

  • 是的,这只是代码的一部分,只是为了得到这个想法。我会检查你发送的链接。谢谢
  • 您是否需要做一些特别的事情来建立社区?或者只是创建一个社区并邀请您的测试电子邮件?我只需要知道是否有办法以某种方式链接应用程序。
  • 不,我创建了私有社区,然后在APK页面的开发者仪表板中添加它-> Beta选项卡。那里应该有“添加 Google 群组或 Google+ 社区”。
  • 我为它设置了一个组和一个社区,然后添加了它们。稍后我会看到这是否可以仅使用电子邮件。完成后我会更新。
  • 还是没有运气。我设置了一个组和一个社区,在使用该链接在我的另一台设备上下载该应用程序后,它仍然给我同样的错误消息。
【解决方案2】:

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

【讨论】:

  • 我在我拥有的单独设备上进行了尝试,并且我的 google 社区中的其他 2 人也尝试过,他们都得到了同样的错误。
  • 如果您还记得您尝试解决此问题的其他任何内容,请告诉我。我很乐意为此提供赏金。谢谢。
【解决方案3】:

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

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

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

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

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

SoomlaStore.Initialize(new YourStoreAssetsImplementation());

在 MonoBehaviour 和 NOT 的 Start 函数中初始化 SoomlaStore 在唤醒功能中。 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(new Soomla.Example.MuffinRushAssets());

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

StoreEvents.OnBillingSupported += onBillingSupported;

public void onBillingSupported() { // ...您的游戏特定实现在这里... }

【讨论】:

  • 好的,所以我现在初始化我的 StoreAssets 类,并在上面对其进行了更改以反映这一点。由于似乎其他任何事情都不是强制性的,因此我正在对此进行测试以确保它可以作为一个开始。但是和以前一样,它似乎可以在检查器中工作并进行购买,但是一旦我在我的测试设备上尝试,它就会给我同样的错误。
  • 您是否尝试将日志记录添加到 onbillingsupported 事件以确保成功命中?我还会确保您配置了正确的 google dev api 密钥。
  • 我刚刚对其进行了测试,但我没有在控制台中获得我放入该方法的调试语句,因此它无法正常工作。我不确定有什么问题。然而,它确实适用于 onSoomlaStoreInitialized 方法。
  • 还有一个不支持的计费事件,尝试在那里登录。当然,如果您使用的是 Google,它应该受支持,但我很想知道它是否说它不支持。
  • 我也没有从不支持的方法中得到任何东西。
【解决方案4】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-30
    • 2020-03-02
    相关资源
    最近更新 更多