Hi, I am having trouble completing the IAP purchase with UDP. I am using a demo project to simplify things, and am able to initialize correctly, with sandbox login. I also get the appropriate prompt from UDP.
But when i attempt to purchase (these are both buttons outside, initialize() and purchaseitem()) I get “Invalid Operation: iap 1500keys needs to be consumed first.”
Could anyone tell what I am doing wrong? Any Help will be appreciated.
From What I can tell, it goes to OnPurchaseFailed() instead of OnPurchase(), where I assume I am supposed to consume the product.
I have already checked the Client ID, Client Secret, etc and they match with the original project’s.
Edit : Error code - 300 on Android Studio.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UDP;
using UnityEngine.UI;
public class UDPManager : MonoBehaviour, IPurchaseListener
{
#region public variables
public static UDPManager Instance;
public Text text;
#endregion
#region private variables
private int val = 0;
private InitListner initListner = new InitListner();
#endregion
private void Awake()
{
Instance = this;
}
public void Initialize()
{
text.text = val.ToString();
StoreService.Initialize(initListner);
StoreService.QueryInventory(this);
StoreService.EnableDebugLogging(true);
}
public void PurchaseItem()
{
StoreService.Purchase("1500keys", "", this);
}
public void OnPurchase(PurchaseInfo purchaseInfo)
{
StoreService.ConsumePurchase(purchaseInfo, this);
}
public void OnPurchaseFailed(string message, PurchaseInfo purchaseInfo)
{
Debug.LogError("Purchase Failed ::: " + message);
}
public void OnPurchaseRepeated(string productId)
{
throw new NotImplementedException();
}
public void OnPurchaseConsume(PurchaseInfo purchaseInfo)
{
val += 5;
text.text = val.ToString();
// AdditiveUIManager.instance.loadingPopup.HideView();
}
public void OnPurchaseConsumeFailed(string message, PurchaseInfo purchaseInfo)
{
Debug.Log("Purchase Consume Failed!! " + message);
}
public void OnQueryInventory(Inventory inventory)
{
Debug.Log("Query Inventory Successful");
}
public void OnQueryInventoryFailed(string message)
{
Debug.Log("Query Inventory Failed");
}
}