New to the forums? Click here to read the "How To" Guide.

Developer? Click here to go to the Developer Forums.

IAP Question

ki7aki7a Posts: 42 Oculus Start Member
Hi!
I am trying for the first time, using the IAP system for GearVR using Unity.
I've managed to make a purchase for a Durable item. but when I get back to the game it crashes. 
My guess is that I can't purchase the same item again, but maybe the crash is because something is wrong with my check script.
I am using the script example from powerballs, with just a bool I've added for my internal check (interntalcheckok). maybe I am doing it all wrong.. Please help!

public void FetchPurchasedProducts()
{
     IAP.GetViewerPurchases().OnComplete(GetViewerPurchasesCallback);
}

void GetViewerPurchasesCallback(Message<PurchaseList> msg)
{
    if (msg.IsError)
    {
         PlatformManager.TerminateWithError(msg);
          return;
     }

    foreach (Purchase p in msg.GetPurchaseList())
    {
        Debug.LogFormat("Purchased: sku:{0} granttime:{1} id:{2}", p.Sku, p.GrantTime, p.ID);
       interntalcheckok = true;
     }
}

private void LaunchCheckoutFlowCallback(Message<Purchase> msg)
{
   if (msg.IsError)
   {
     PlatformManager.TerminateWithError(msg);
     return;
    }

   Purchase p = msg.GetPurchase();
   Debug.Log("purchased " + p.Sku);
   interntalcheckok = true;
}
Sign In or Register to comment.