我已经完成了关于此错误的不同文章中所说的每一件事。我已经添加了测试帐户。我在更改项目代码时升级版本代码。
在日志文件中,我收到此购买错误
D/Finsky﹕ [1] PurchaseFragment.handleError: Error: PurchaseError{type=3 subtype=4}
我错在哪里?我还删除并清除了我的应用程序数据,并将版本代码设置为默认值1。这是我的统一代码
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Soomla.Store;
public class ExampleAssets : IStoreAssets{
public int GetVersion() {
return 1;
}
public VirtualCurrency[] GetCurrencies() {
return new VirtualCurrency[]{};
}
public VirtualGood[] GetGoods() {
return new VirtualGood[] {NO_ADS_LTVG};
}
public VirtualCurrencyPack[] GetCurrencyPacks() {
return new VirtualCurrencyPack[] {};
}
public VirtualCategory[] GetCategories() {
return new VirtualCategory[]{};
}
/** Static Final members **/
public const string NO_ADS_LIFETIME_PRODUCT_ID = "1";
/** LifeTimeVGs **/
// Note: create non-consumable items using LifeTimeVG with PuchaseType of PurchaseWithMarket
public static VirtualGood NO_ADS_LTVG = new LifetimeVG(
"No Adss", // name
"No More Ads!", // description
"1", // item id
new PurchaseWithMarket(NO_ADS_LIFETIME_PRODUCT_ID, 1)); // the way this virtual good is purchased
}
,另一个文件是
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using Soomla;
using Soomla.Store;
public class IAPCode : MonoBehaviour {
public static VirtualItem virtualGoods = null;
// Use this for initialization
void Start () {
StoreEvents.OnSoomlaStoreInitialized += onSoomlaStoreInitialized;
SoomlaStore.Initialize(new ExampleAssets());
foreach (VirtualGood vg in StoreInfo.Goods) {
Debug.LogError(vg.Name+"");
}
}
public void onSoomlaStoreInitialized()
{
virtualGoods = StoreInfo.GetItemByItemId ("1");
}
// Update is called once per frame
void Update () {
}
public void no_ads() // This function is calling from a canvas button then error appears
{
StoreInventory.BuyItem (virtualGoods.ItemId);
}catch(UnityException e)
{
Debug.Log(e.Message);
}
}
}
产品名称,ID和说明与google play开发者控制台中的相同,并且项目处于活动状态。我这样做只适用于no_ads项目。