首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在实现Soomla Unity3d插件时进行购买时的Google错误

在实现Soomla Unity3d插件时进行购买时的Google错误
EN

Stack Overflow用户
提问于 2015-08-24 23:49:38
回答 4查看 1.8K关注 0票数 23

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

当我在Android设备上启动它时,我会得到以下错误:身份验证是必需的。你需要登录你的Google帐户.

现在,我读了好几篇不同的文章,人们都有过这个问题,但似乎没有什么能帮到我。

以下是我迄今尝试过的内容清单:

1)确保将应用程序发布到alpha或beta进行测试。

2)确保游戏价格与开发者控制台相匹配。

3)使用不使用开发人员电子邮件的用户登录的设备。

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

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

6)确认商户账户设置正确无误。

7)确保构建为发行版,而不是开发(不确定这是否重要,但我尝试了这两种方法)。

8)从项目中完全删除了所有Soomla插件,然后在非常密切地跟踪教程的同时将其重新添加进来,以确保没有遗漏任何小插件。还是没有骰子。

我有核心和存储组件添加到场景,他们是必要的。请让我知道,如果你有任何其他想法,我应该做什么来解决这个问题。同时,下面是用于设置Soomla的StoreAssets.cs代码:

代码语言:javascript
复制
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)
        )
    );

}

为了购买物品,我呼吁:

代码语言:javascript
复制
StoreInventory.BuyItem("the id of my item");

为了使用已购买的物品,我呼吁:

代码语言:javascript
复制
StoreInventory.TakeItem("the id of my item");

StoreInventory是一个类,当它被导入到统一中时,它包含在Soomla中。

以下是完成购买和项目消费的代码:

代码语言:javascript
复制
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

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

8/27/15

我只是注意到我的商人账户上的信用卡已经过期了。我读过的一篇文章提到,如果商人帐户有问题的话,就会有类似的问题。我已经更新了信息,现在我必须等待他们将存款存入我的帐户,以确保它的工作。一旦完成,我将更新这是否解决了我目前的问题。

8/31/15

在最终验证了我的商家帐户在谷歌播放,我似乎仍然有同样的问题。修正我的商人帐户并没有改变我所不能说的任何事情。

我刚刚更新了我的帖子,包括我的整个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方法仍未被调用,而且我仍然收到与以前在安卓设备上相同的错误。

9/12/15

我刚刚删除了Soomla插件的所有内容,导入了最新版本,并再次按照说明执行,我仍然得到了相同的错误。

9/16/15

真的不知道我在这里错过了什么。在删除所有Soomla插件,然后再添加它,并得到相同的错误后,多次尝试。正如本教程所述,我已经遵循了所有的内容,我有上面所有的代码。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2015-09-20 20:57:50

在我的例子中,我没有意识到我所使用的项目ID和产品ID是混在一起的。项目ID只是为了识别soomla中的项目,产品ID是我在google中设置的实际的我想要的。

票数 1
EN

Stack Overflow用户

发布于 2015-08-25 07:14:56

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

第二点是上面的代码。您正在获取4个商品和3个货币包,但代码没有反映这一点。也许你

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

顺便说一下,SOOMLA有一个专门处理SOOMLA相关问题的站点answers.soom.la。

票数 5
EN

Stack Overflow用户

发布于 2015-09-09 09:07:57

你试过用另一种设备买东西吗?我以前也有过这个问题,但是我不记得我是怎么解决的。据我所知,当它对我来说失败的时候,它在不同的同事的设备上工作。试着在不同的设备上测试它。另外,您的设备上有多个google帐户吗?我记得我尝试过的一件事就是从我的设备上删除所有的google帐户,然后离开我的主帐户注册。不幸的是,我不记得这是否有效,但我希望它能帮助你。如果您知道如何修复它,请在这里发布一个更新。祝好运

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32193489

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档