In-app purchase in Unity 5.3 not working
Hello everybody.
Need your help. Internal Unity In-app. Unity version: 5.3.1p1
Situation: I make everything well in code (I hope), and then I was tested purchases on real devices with working acount (and with credit card).
And I have a problem with initialising purchases ~1 week already. And can not understnad what wrong.
Error message on start: PurchasesUnavailable. Error on Android.
Windows Store not working too.
May be wrong here? :
// vars:
public class Purchaser : MonoBehaviour, IStoreListener
{
private string B3000 = "2000_gold_coins";
private string B10000 = "10000_gold_coins";
private string ADS = "noads";
// procedure:
public void InitializePurchasing () {
if (IsInitialized ()) {
if (characterController.DebugMode) {
Debug.Log ("AIP already INITED");
}
return;
} else {
var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
builder.AddProduct (ADS, ProductType.Consumable, new IDs
{
{"noads_google", GooglePlay.Name},
{"noads_windows", WindowsPhone8.Name},
{"noads_mac", MacAppStore.Name}
});
builder.AddProduct (B3000, ProductType.Consumable, new IDs
{
{"2000_gold_coins_google", GooglePlay.Name},
{"3000_coins_windows", WindowsPhone8.Name},
{"2000_gold_coins_mac", MacAppStore.Name}
});
UnityPurchasing.Initialize (this, builder);
}
// Call
IAPScript.GetComponent<Purchaser> ().Buy (productString);
// Request
public void Buy (string productId)
{
InitializePurchasing ();
if (IsInitialized ()) {
controller.InitiatePurchase (productId);
}
else {
Debug.LogError ("BuyProductID FAIL. Not initialized.");
AVATAR.GetComponent<characterController>().PurchaseInitFail();
}
}
Thank you!
And Happy New Year!
Windows error:
UnibillWin8:Exception loading listing information:Exception from HRESULT: 0x805A0194
(Filename: C:/buildslave/unity/build/artifacts/generated/$$anonymous$$etro/runtime/UnityEngineDebugBindings.gen.cpp Line: 40)
Answer by bitween · Jan 15, 2016 at 09:32 AM
Hey guys,
this need an immediate attention don't waste time people like me are waiting to submit some games for this issue please fix it ASAP
Thanks
This is not the right place for technical support. Please go to the Unity forums.
Answer by navi2121 · Dec 28, 2015 at 05:45 AM
Very strange with this 5.3 build. People now report me: IAP works on 4.3 Android one time of four-five attempts. ON BETA!
Not working on Windows Phone 10 and Windows Phone 8.1 (Windows Store);
wtf with this? :-}
Answer by Banderous · Dec 28, 2015 at 06:10 PM
@navi2121 Have you set up your products and followed the steps outlined [here]?[1]
Please attach an adb trace from application startup through to the unexpected behaviour.
Edit - I suggest the forums are more appropriate for this, it is impossible to give an answer to IAP related questions such as this when there are many publisher configuration specific problems that can cause IAP not to work.
[1]: http://docs.unity3d.com/Manual/UnityIAPGooglePlay.html
App not crashing. Just in-app not working. I see, this is problem inside in-app module. Now testing again - PurchasingUnavalible. This is lottery.
In-app not woking on published game too. And, ofcourse, app signed. And sometimes working on beta, sometime not working ONE version.
if not have a solution, I will try more. Thanx for answer.
Answer by fyy · Jan 09, 2016 at 09:03 AM
Can you fix it ?? I get the same problem.
Where is the problem?
Need your help~
@fyy, IAP not working in Windows Store.
For Google Play a make this small solution: Awake runs Invoke for init IAP every 5 seconds. After 30 second if can't init - CancelInvoke and Close Shop in game (like as "Offine status").
If (isInitialized) CancelInvoke.
This helps for second, third and next executes, but NOT FOR FIRST. idk, why.
Do you try App Store? I just can't Initialized.Everytime i run project in Xcode,it just report "OnInitializedFailed". I don't know what's wrong with it. So sad.
No, I have not tried the Apple Store. Just Windows Store and Google Play for now.
Please raise this in the forums, this is the place for answers to specific questions rather than technical discussions.
Answer by basavaraj_guled · Jan 27, 2016 at 06:53 AM
hi there, in my game(android platform ) i have non consumable product google play store , how can i restore those item .
You can do that by calling Restore Purchase Function in your game. You can find sample script from Unity Forum. I will attach it here too for assistance. Restore Purchase feature will return all the purchases in case user uninstall the game and reinstall it later.
public void RestorePurchases ()
{
if (!IsInitialized ())
{
Debug.Log ("RestorePurchases FAIL. Not initialized.");
return;
}
if (Application.platform == RuntimePlatform.IPhonePlayer ||
Application.platform == RuntimePlatform.OSXPlayer)
{
Debug.Log ("RestorePurchases started ...");
var apple = m_StoreExtensionProvider.GetExtension<IAppleExtensions> ();
apple.RestoreTransactions ((result) => {
Debug.Log ("RestorePurchases continuing: " + result + ". If no further messages, no purchases available to restore.");
});
}
else
{
Debug.Log ("RestorePurchases FAIL. Not supported on this platform. Current = " + Application.platform);
}
}
Your answer
Follow this Question
Related Questions
Changing to Mobile Platform 0 Answers
Unity Engine Not Intialized?!? 0 Answers
Android build problem 0 Answers
What Emulator For Android Is The Best For Unity 3D? 0 Answers