Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

IAP 2.2.0 product.metadata.localizedPrice is 0

Discussion in 'Unity IAP' started by YuriBazila, Nov 11, 2020.

  1. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    47
    product.metadata.localizedPrice for all products is always 0 after Unity IAP update to 2.2.0 version.
    product.metadata.localizedPriceString works as good as before.

    The bug reproduces only on android. iOS works good.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We are looking into this.
     
  3. pixelnodrock

    pixelnodrock

    Joined:
    Jan 18, 2018
    Posts:
    3
    Same issue here and I have also problem that when I cancel payment (tap outside payment on Android) I exception inside PurchasingManager.

    11-11 21:09:53.166 16465 16465 E Unity : ArgumentNullException: Value cannot be null.
    11-11 21:09:53.166 16465 16465 E Unity : Parameter name: key
    11-11 21:09:53.166 16465 16465 E Unity : at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key)
    11-11 21:09:53.166 16465 16465 E Unity : at System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value)
    11-11 21:09:53.166 16465 16465 E Unity : at UnityEngine.Purchasing.ProductCollection.WithStoreSpecificID (System.String id)
    11-11 21:09:53.166 16465 16465 E Unity : at UnityEngine.Purchasing.PurchasingManager.OnPurchaseFailed (UnityEngine.Purchasing.Extension.PurchaseFailureDescription description)
    11-11 21:09:53.166 16465 16465 E Unity : at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
    11-11 21:09:53.166 16465 16465 E Unity : at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args)

    The biggest problem is that OnPurchaseFailed on IStoreListener is not called because of exception so I have no way to handle this problem. So the new IAP 2.2.0 is unusable.
     
    Pixel2015 likes this.
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Understood, we are looking into this.
     
  5. studiolumiere_unity

    studiolumiere_unity

    Joined:
    Apr 24, 2020
    Posts:
    21
    Unity IAP update to 2.2.0 version. Found problem (GooglePlayStore)

    1. Delayed purchase Test Error

    2. OnPurchaseFailed Error

    3. product.metadata.localizedPrice Zero

    4. When to use proguard
    You need to add new to proguard_user.txt to make it work
    - keep class com.android.billingclient.** { *; }
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please describe each in detail, with steps for someone else to reproduce. You mentioned "make it work", make what work? Do you get an error when it "doesn't work"?
     
  7. studiolumiere_unity

    studiolumiere_unity

    Joined:
    Apr 24, 2020
    Posts:
    21
    If you select [User Proguard File] in version 2.2.0,
    When calling an in-app function
    I am getting AndroidJavaException: java.lang.ClassNotFoundException: com.android.billingclient.api error.
    So proguard_user.txt
    -keep class com.android.billingclient. ** {*; }
    Solved by adding.
     
  8. studiolumiere_unity

    studiolumiere_unity

    Joined:
    Apr 24, 2020
    Posts:
    21
    The OnPurchaseFailed error I mentioned is the same as this.
     
  9. studiolumiere_unity

    studiolumiere_unity

    Joined:
    Apr 24, 2020
    Posts:
    21
    Words can be confusing because you are using a translator.

    [Purchase delay test error replay process]
    1. In-app initialization
    2. Purchase of goods
    3. The Android payment window opens.
    4. Payment delay test among 4 types (attach screenshot file)
    5. Error log occurrence (attach log)
    6. But success after a few minutes

    ------------------------------------error log----------------------------------
    Exception
    NullReferenceException: Object reference not set to an instance of an object.
    UnityEngine.Purchasing.GooglePlayStoreExtensions.NotifyDeferredPurchase (System.String productId, System.String transactionId)
    UnityEngine.Purchasing.GooglePurchaseUpdatedListener.ApplyOnPurchases (UnityEngine.AndroidJavaObject purchasesList, System.Action`1[T] action)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters)
    UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args)
    UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs)
    Rethrow as TargetInvocationException: UnityEngine.Purchasing.GooglePurchaseUpdatedListener.onPurchasesUpdated(UnityEngine.AndroidJavaObject,UnityEngine.AndroidJavaObject)
    UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args)
    UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs)
     

    Attached Files:

  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @studiolumiere I'm glad you solved your issue by using the Proguard file entry.
     
  11. ShoaibAslamTintash

    ShoaibAslamTintash

    Joined:
    Sep 6, 2018
    Posts:
    11
    Were you able to resolve the localized price 0 issue ?
     
  12. John_Corbett

    John_Corbett

    Joined:
    May 17, 2019
    Posts:
    151
    Hi @ShoaibAslamTintash,

    Are you still experiencing this issue? Which versions are you using? We've made several fixes for this in previous releases.
     
  13. ShoaibAslamTintash

    ShoaibAslamTintash

    Joined:
    Sep 6, 2018
    Posts:
    11
    I have used 2.1.1 and 2.2.2 but localized price always gives 0. I have tested both cases
    - Reinstalling the app and the IAP gets restored
    - Creating a new IAP and buying it for first time
    Anyhow metadata.localizedPriceString is giving correct price but I have to parse it to get the original amount. The issue with the parsing is that some currencies use comma instead of decimal.
     
  14. John_Corbett

    John_Corbett

    Joined:
    May 17, 2019
    Posts:
    151
    Hi @ShoaibAslamTintash

    Have you updated the Asset Store plugin? Its current version is 2.2.7.
    Were you referring to the com.unity.purchasing in Package manager when you mentioned 2.2.2?

    We recommend updating both packages to have all of the fixes for this. One of these issues was fixed in Asset Store plugin version 2.2.6, but we recommend 2.2.7 for overall stability.
     
  15. ShoaibAslamTintash

    ShoaibAslamTintash

    Joined:
    Sep 6, 2018
    Posts:
    11
    I have updated the IAP plugin version to 2.2.7 and it is working fine now. @John_Corbett Thanks for the help
     
  16. kkl888

    kkl888

    Joined:
    Dec 6, 2014
    Posts:
    55
    I'm having the similar error too. Not able to reproduce the error in my devices, but the error found in Unity Cloud Diagnostic.
    Code (CSharp):
    1. UnityEngine.Purchasing.GooglePlayStoreExtensions.NotifyDeferredPurchase (System.String productId, System.String transactionId) (at <00000000000000000000000000000000>:0)
    2. UnityEngine.Purchasing.GooglePurchaseUpdatedListener.ApplyOnPurchases (UnityEngine.AndroidJavaObject purchasesList, System.Action`1[T] action) (at <00000000000000000000000000000000>:0)
    3. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <00000000000000000000000000000000>:0)
    4. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <00000000000000000000000000000000>:0)
    5. UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
    6. UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)
    7. Rethrow as TargetInvocationException: UnityEngine.Purchasing.GooglePurchaseUpdatedListener.onPurchasesUpdated(UnityEngine.AndroidJavaObject,UnityEngine.AndroidJavaObject)
    8. UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
    9. UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)
    * Using Unity IAP 2.2.2 (from package manager) and Unity IAP Plugin 2.2.7 (from asset store).
     
  17. sergdv

    sergdv

    Joined:
    Jul 30, 2020
    Posts:
    4
    I'm having the similar error too, when I select "Slow test card, declines after a few minutes". UnityIAP Version: 2.2.7:

    Code (CSharp):
    1. E/Unity   ( 3867): NullReferenceException: Object reference not set to an instance of an object.
    2. E/Unity   ( 3867):   at UnityEngine.Purchasing.GooglePlayStoreExtensions.NotifyDeferredPurchase (System.String productId, System.String transactionId) [0x00000] in <00000000000000000000000000000000>:0
    3. E/Unity   ( 3867):   at UnityEngine.Purchasing.GooglePurchaseUpdatedListener.ApplyOnPurchases (UnityEngine.AndroidJavaObject purchasesList, System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
    4. E/Unity   ( 3867):   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0
    5. E/Unity   ( 3867):   at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <00000000000000000000000000000000>:0
    6. E/Unity   ( 3867):   at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0
     
    Last edited: Apr 6, 2021
  18. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please show your code. It's working for me here. When do you receive this exception? Do the other purchase options work OK? The Sample IAP Project v2 works as expected, please compare https://forum.unity.com/threads/sample-iap-project.529555/#post-6950270 Can you test with IAP 3.0.1 ?
     
  19. sergdv

    sergdv

    Joined:
    Jul 30, 2020
    Posts:
    4
    Ah, it looks like I found the problem. I needed to add this code in OnInitialized:
    Code (CSharp):
    1. var googleExtensions = extensions.GetExtension<IGooglePlayStoreExtensions>();
    2. if (googleExtensions != null)
    3.     googleExtensions.SetDeferredPurchaseListener(OnPurchaseDeferred);
     
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    The Sample IAP Project uses a deferred listener
     
  21. sergdv

    sergdv

    Joined:
    Jul 30, 2020
    Posts:
    4
  22. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  23. sergdv

    sergdv

    Joined:
    Jul 30, 2020
    Posts:
    4