Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
katemode's avatar
katemode
Honored Guest
1 year ago

Trouble with In App Purchases IAP

I can't get IAP working.

In the developer dashboard:

  1. I have created an app
  2. done the data privacy checkup
  3. activated IAP on the platform services page
  4. created and published a SKU for testing

In unity

  1.  Imported the Meta XR all-in-one SDK, and verified that platform services is a part of that
  2.  Set my app ID for both "oculus rift" and "Meta Quest/2/Pro"

 

In my script I have the following

 

void Awake ()
    {
        try
        {
            Core.AsyncInitialize();
#if UNITY_ANDROID && !UNITY_EDITOR
            IAP.GetViewerPurchases().OnComplete(ViewerPurchasesCallback);
#elif UNITY_EDITOR
            Debug.LogWarning("Running in Unity Editor. Oculus platform initialization is skipped.");
#endif
        }
        catch(UnityException e)
        {
            Debug.LogError("Platform failed to initialize due to exception.");
            Debug.LogException(e);
            // Immediately quit the application.
            UnityEngine.Application.Quit();
        }
    }

    void ViewerPurchasesCallback(Message<PurchaseList> msg) {
        Debug.Log("Callback");
        if (msg.IsError) {
            Debug.LogError("Error retrieving purchases: " + msg.GetError().Message);
            Debug.LogError("Error retrieving purchases: " + msg.GetError().Code);
        } else {
            foreach (Purchase purchase in msg.Data) {
                Debug.Log("User has purchased: " + purchase.Sku);
            }
        }
    }

 

 

I get the error message

"Error retrieving purchases: package not in library"

"Error retrieving purchases: 2"

 

I can not find any documentation with that error message or any information about error codes

3 Replies

  • katemode's avatar
    katemode
    Honored Guest

    Hmm.

    I did get it working, and my code is still almost identical to this. 

    I *think* this issue was that I needed to actually set my app on the developer platform and set up platform services. https://developer.oculus.com/

    I think I even had to do a push out to an alpha channel before it started working, though after that a regular build from unity worked.

    Good Luck

    • Wang_Shi's avatar
      Wang_Shi
      Explorer

      Thanks, it works. I push my app to an alpha channel and it works.