c# - 在实现Soomla Unity3d插件的同时进行购买时,Google播放错误

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

我正在创建一个实现Soomla Unity IAP插件的应用程序。为了使IAP正常运行,我已经做好准备,可以在编辑器中进行购买了。 (不是真正的购买,它只是更新用户可以在游戏中购买/消费的虚拟货币)。

在Android设备上启动此错误时,出现以下错误:需要身份验证。您需要登录自己的Google帐户。

现在,我已经阅读了多篇不同的文章,这些文章都困扰着人们,似乎无济于事。

这是到目前为止我尝试过的列表:

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

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

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

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

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

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

15年8月26日

我现在已经创建了一个Google网上论坛和一个Google社区来测试此应用。我将其他Android设备的电子邮件都添加到了这两个设备中,并使用提供的链接下载了该应用程序。这样做仍然导致与以前相同的错误。

15年8月27日

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

15年8月31日

最终在Google Play上验证了我的商家帐户后,我似乎仍然遇到相同的问题。修复我的商家帐户并没有改变我无法告知的任何内容。

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

15年9月7日

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

15年9月9日

就像一个快速更新一样,我尝试在未在build设置中选择开发构建的情况下构建项目,然后将链接发送给Google社区中的所有人,以便进行尝试。每个人仍然和我的测试设备有同样的错误。

15年9月11日

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

15年9月12日

在soomla网站上浏览完该教程之后,我做了所有说明的事情,只是在后台启动了Iab并提供了欺诈保护,因为这不是必需的。 onBillingSupported方法仍然没有被调用,并且在Android设备上我仍然收到与以前相同的错误。

15年9月12日

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

15年9月16日

真的不知道我在这里想念的是什么。删除所有Soomla插件,然后再次添加后,多次尝试后仍然出现相同的错误。我已经按照教程中的说明进行了所有操作,并且上面有所有代码。

最佳答案

我从来没有遇到您描述的问题。不过,我创建了一个私有(private)Google+社区,并将该社区添加为测试人员。将我的应用转移到Beta版。并邀请人们进入我的私有(private)社区,那里有一个链接可以下载该应用程序并对其进行测试。很容易。

第二点是上面的代码。您要提取4个商品和3个货币包,但是代码未反射(reflect)出这一点。也许您只粘贴了一半的类(class)。

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

顺便说一下,SOOMLA有一个专门的站点,用于解决SOOMLA相关的问题。

关于c# - 在实现Soomla Unity3d插件的同时进行购买时,Google播放错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32193489/

相关文章:

c# - 将 TransactionScope 与 MySQL 和读锁一起使用

c# - 从一个基类继承两个类给出错误 3024

c# - 使用 Kinect SDK 的 body 点云

android - 出现软键盘时如何调整布局

unity3d - 如何在 Unity DOTS 中卡住/约束 PhysicsBody 的旋转?

android - 在 react-native 应用程序中添加 Native Android UnityPlayer 导致黑屏

c# - WCF/REST 将图像放入图片框?

java - 如何解决Gradle错误找不到符号

android - Mifare 超轻 : lock specific pages

unity3d - 车轮碰撞器 Unity : after adding torque the vehicle starts moving sideways