- Home /
IAP Plugins on Android Unity Not Working For Me
Hey guys, first post here. I'm having a really nerve-racking issue when it comes to integrating In-App Purchases for my game made for the Android on Unity. It seems like every plugin I try doesn't work out for me, where the purchase window simply won't pop up. I'm thinking this is an issue on my end as I had been trying APIs like OpenIAB, Gamedonia, etc. I've imported the plugins correctly and scripted the purchasing process as instructed.
Could it be something I'm missing on my Google Play Store draft? Here are my In-App Products listed on there (imbedding image doesn't seem to be working)
I have used OpenIAB in a project and it does work, when I first started implementing IAP it was very frustrating to learn how and not entirely sure whether these plugins work, so at least knowing OpenIAB does work should give you some confidence.
Next, without seeing any of your code all I can guess it that your Id's that you send for your purchases are not matching, but just a guess.
You are right. After constant troubleshooting I've narrowed the problem down to being my ID for my products under my Google Play Dev Console. Could you give me an example on how to properly reference these in code?
You cannot test IAP with a draft app anymore, it must be published as Alpha or Beta, and you have to set an alpha test and a tester list.
Answer by Nomibuilder · Sep 02, 2016 at 04:12 AM
This is the Example for Soomla IAP
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Soomla;
using Soomla.Store;
public class IAPHandler : MonoBehaviour, IStoreAssets
{
public string removeAdsId;
private VirtualGood noAds;// = new LifetimeVG("Remove Ads", "Feeling Annoyed! Buy this product to remove ads.", removeAdsId,
// new PurchaseWithMarket(new MarketItem(removeAdsId, 0.99f)));
public VirtualGood[] GetGoods()
{
return new VirtualGood[] {noAds};
}
public int GetVersion(){return 0;}
public VirtualCurrency[] GetCurrencies(){return new VirtualCurrency[] {};}
public VirtualCurrencyPack[] GetCurrencyPacks(){return new VirtualCurrencyPack[] {};}
public VirtualCategory[] GetCategories(){return new VirtualCategory[] {};}
void Start ()
{
noAds = new LifetimeVG("Remove Ads", "Feeling Annoyed! Buy this product to remove ads.", removeAdsId,
new PurchaseWithMarket(new MarketItem(removeAdsId, 0.99f)));
// noAds = new VirtualGood (products [0].name, products [0].description, products [0].id,
// new PurchaseWithMarket(new MarketItem(products[0].id, products[0].price)));
SoomlaStore.Initialize (this);
StoreEvents.OnMarketPurchaseStarted += OnMarketPurchaseStarted;
StoreEvents.OnMarketPurchase += onMarketPurchase;
StoreEvents.OnItemPurchaseStarted += OnItemPurchaseStarted;
StoreEvents.OnItemPurchased += onItemPurchased;
StoreEvents.OnRestoreTransactionsStarted += onRestoreTransactionsStarted;
StoreEvents.OnRestoreTransactionsFinished += onRestoreTransactionsFinished;
}
public void RemoveAds()
{
StoreInventory.BuyItem (removeAdsId, "0.99$");
}
public void RestorePurchase()
{
SoomlaStore.RestoreTransactions ();
}
public void OnMarketPurchaseStarted( PurchasableVirtualItem pvi ) {
Debug.Log( "OnMarketPurchaseStarted: " + pvi.ItemId );
}
public void onMarketPurchase(PurchasableVirtualItem pvi, string payload, Dictionary<string, string> extra)
{
if (pvi.ItemId.Equals (removeAdsId))
{
PlayerPrefs.SetString("NoAds", "true");
GSSdk.Instance.HideBanner();
Debug.Log("Remove Ads purchased");
}
}
public void OnItemPurchaseStarted( PurchasableVirtualItem pvi ) {
Debug.Log( "OnItemPurchaseStarted: " + pvi.ItemId );
}
public void onItemPurchased(PurchasableVirtualItem pvi, string payload) {
Debug.Log( "OnItemPurchased: " + pvi.ItemId );
}
public void onRestoreTransactionsStarted()
{
Debug.Log ("Restore Transaction Started");
}
public void onRestoreTransactionsFinished(bool success)
{
Debug.Log ("Restore Transaction Finished With: " + success);
}
}
Your answer
Follow this Question
Related Questions
GooglePlayGames plugin path not correct? 0 Answers
Failed to re-package resources after adding unity in-app purchase service 1 Answer
android time cheat plugin problem with broadcastreceiver 1 Answer
BroadcastReceiver onReceive does not work (custom Unity Android plugin) 1 Answer
How to write a java lib for unity as a plugin to make run another android app? 1 Answer