Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity IAP SubscriptionManager getSubscriptionInfo NullReceiptException on Android

Discussion in 'Unity IAP' started by Le_Poulet, Dec 12, 2019.

  1. Le_Poulet

    Le_Poulet

    Joined:
    May 18, 2017
    Posts:
    24
    Hi,

    I got NullReceiptException when I try to do getSubscriptionInfo().
    I updated UnityIAP to the last version.

    Do I need to subscribe to have subscriptionManger.getsubscriptioninfo working?

    UnityIAP version 1.23.1
    In App Purchasing 2.0.6

    Code (CSharp):
    1. subscriptionDict = m_GoogleExtensions.GetProductJSONDictionary();
    2.         string intro_json = (subscriptionDict == null || !subscriptionDict.ContainsKey(itemInfo[8].product.definition.storeSpecificId)) ? null : subscriptionDict[itemInfo[8].product.definition.storeSpecificId];
    3.         SubscriptionManager subManager = new SubscriptionManager(subProduct, intro_json);
    4.         subManager.getSubscriptionInfo();
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, you need to check to make sure the receipt is not null. You need a purchase first.
     
    shadermanger likes this.
  3. Le_Poulet

    Le_Poulet

    Joined:
    May 18, 2017
    Posts:
    24
    Thanks a lot.
     
  4. Le_Poulet

    Le_Poulet

    Joined:
    May 18, 2017
    Posts:
    24
    Hi again,

    another question : how can I know if the player has access to the introductory period. In my tests, I don't have any receipt when I am unsubscribed after the test period with the test approved card.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
  6. Nrjwolf

    Nrjwolf

    Joined:
    Mar 2, 2014
    Posts:
    4
    Bump, have the same issue
     
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please see my previous post, just before yours.
     
  8. SyedUmair

    SyedUmair

    Joined:
    Sep 2, 2013
    Posts:
    42
    @JeffDUnity3D , if user cancels the subscription after subscribing it for some time. Do the method getSubscriptionInfo() will still return data or will throw exception ?
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please test and see. It should not throw an exception. However I believe the receipt will be empty.
     
  10. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,845
    Hi @JeffDUnity3D

    getSubscriptionInfo().isSubscribed()

    whats the point of adding isSubcribed if getSubcription going to throw null anyway if you are not already subscribed?
    I want to understand the use case of this method.

    Thanks
     
  11. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446