In-app purchase success method not being called after app build

IAP에 연결된 버튼을 누르면 구글에서 제공하는 UI에 제품 상세정보가 나오고, 구매 버튼을 누르면 성공 메시지와 함께 구매 메일이 도착하고, 테스트 빌드라서 취소 메일도 도착한다.

그런데 구매 성공 함수가 호출되지 않고 있습니다.

Logcat으로 확인해보니 아래와 같은 오류 메시지가 나옵니다.

2024-04-11 13:33:20.553 27983 28179 Error Unity NullReferenceException: Object reference not set to an instance of an object.
2024-04-11 13:33:20.553 27983 28179 Error Unity at UnityEngine.GlobalJavaObjectRef.op_Implicit (UnityEngine.GlobalJavaObjectRef obj) [0x00000] in <00000000000000000000000000000000>:0
2024-04-11 13:33:20.553 27983 28179 Error Unity at UnityEngine.AndroidJavaObject._Call[ReturnType] (System.String methodName, System.Object[ ] args) [0x00000] in <00000000000000000000000000000000>:0
2024-04-11 13:33:20.553 27983 28179 Error Unity at UnityEngine.Purchasing.Utils.GooglePurchaseBuilder+<>c__DisplayClass6_1.b__1 (UnityEngine.AndroidJavaObject skuDetail) [0x00000] in <00000000000000000000000000000000>:0
2024-04-11 13:33:20.553 27983 28179 Error Unity at System.Func2[T,TResult].Invoke (T arg) [0x00000] in <00000000000000000000000000000000>:0 2024-04-11 13:33:20.553 27983 28179 Error Unity at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable1[T] source, System.Func2[T,TResult] predicate) [0x00000] in <00000000000000000000000000000000>:0 2024-04-11 13:33:20.553 27983 28179 Error Unity at System.Func2[T,TResult].Invoke (T arg) [0x00000] in <00000000000000000000000000000000>:0
2024-04-11 13:33:20.553 27983 28179 Error Unity at System.Linq.Enumerable+<>c__DisplayClass7_0`3[TSource,TMiddle,TResult].<Combi

To resolve the issue, I also tried adding the following content to the AndroidManifest.xml:

And I also added the following content to the mainTemplate.gradle to address the version conflict issue with billingclient:
configurations.all { exclude group: ‘com.android.billingclient’, module: ‘billing’ }

My Unity version is 2020.3.48f1, and I’m currently using IAP SDK version 4.11.0.

1 Like

Let’s try downgrading the version to 4.10.0

Wow, the problem has been solved.
thank you.

Thank you for the report, I was able to reproduce this and we will fix this in IAP 4.12.0.

If you are using Unity Editor 2020.3, we recommend avoiding IAP 4.11.0 to avoid this issue.
Newer versions of the editor are not affected by this.

2 Likes

UnityEngine.GlobalJavaObjectRef.op_Implicit (UnityEngine.GlobalJavaObjectRef obj) (at <00000000000000000000000000000000>:0)

UnityEngine.AndroidJavaObject._Call[ReturnType] (System.String methodName, System.Object[ ] args) (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.Utils.GooglePurchaseBuilder+<>c__DisplayClass6_1.b__1 (UnityEngine.AndroidJavaObject productDetail) (at <00000000000000000000000000000000>:0)

System.Func`2[T,TResult].Invoke (T arg) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable1[T] source, System.Func2[T,TResult] predicate) (at <00000000000000000000000000000000>:0)

System.Func`2[T,TResult].Invoke (T arg) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable+<>c__DisplayClass7_0`3[TSource,TMiddle,TResult].b__0 (TSource x) (at <00000000000000000000000000000000>:0)

System.Func`2[T,TResult].Invoke (T arg) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable+WhereSelectListIterator`2[TSource,TResult].MoveNext () (at <00000000000000000000000000000000>:0)

System.Collections.Generic.List1[T]..ctor (System.Collections.Generic.IEnumerable1[T] collection) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.Models.GooglePurchase…ctor (UnityEngine.AndroidJavaObject purchase, System.Collections.Generic.IEnumerable`1[T] productDetailsEnum) (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.Utils.GooglePurchaseBuilder.BuildPurchase (UnityEngine.AndroidJavaObject purchase) (at <00000000000000000000000000000000>:0)

System.Func`2[T,TResult].Invoke (T arg) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable+WhereSelectListIterator`2[TSource,TResult].MoveNext () (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.EnumerableExtensions+d__1`2[T,TException].MoveNext () (at <00000000000000000000000000000000>:0)

System.Collections.Generic.List1[T]..ctor (System.Collections.Generic.IEnumerable1[T] collection) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.GoogleQueryPurchasesService+<>c__DisplayClass4_0.b__0 (UnityEngine.Purchasing.Models.IGoogleBillingResult billingResult, System.Collections.Generic.IEnumerable`1[T] purchases) (at <00000000000000000000000000000000>:0)

System.Action`2[T1,T2].Invoke (T1 arg1, T2 arg2) (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.GooglePurchasesResponseListener.onQueryPurchasesResponse (UnityEngine.AndroidJavaObject billingResult, UnityEngine.AndroidJavaObject purchases) (at <00000000000000000000000000000000>:0)

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)

UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[ ] args) (at <00000000000000000000000000000000>:0)

UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)

Rethrow as TargetInvocationException: UnityEngine.Purchasing.GooglePurchasesResponseListener.onQueryPurchasesResponse(UnityEngine.AndroidJavaObject,UnityEngine.AndroidJavaObject)

UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[ ] args) (at <00000000000000000000000000000000>:0)

UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)

My Unity version is 2020.3.41f1, and I’m currently using IAP SDK version 4.12.0.

I have a same problem. When i testing purchasing IAP, sometime i bought IAP but it has not trigger successful event and hasn’t completed purchased even though payment has been success. After that a google store will be refunded which IAP item when I bought before.
My Unity version is 2020.3.25f1, using package com.unity.purchasing 4.12.0

UnityEngine.GlobalJavaObjectRef.op_Implicit (UnityEngine.GlobalJavaObjectRef obj) (at <00000000000000000000000000000000>:0)

UnityEngine.AndroidJavaObject._Call[ReturnType] (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.Utils.GooglePurchaseBuilder+<>c__DisplayClass6_1.<TryFindAllProductDetails>b__1 (UnityEngine.AndroidJavaObject productDetail) (at <00000000000000000000000000000000>:0)

System.Func`2[T,TResult].Invoke (T arg) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) (at <00000000000000000000000000000000>:0)

System.Func`2[T,TResult].Invoke (T arg) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable+<>c__DisplayClass7_0`3[TSource,TMiddle,TResult].<CombineSelectors>b__0 (TSource x) (at <00000000000000000000000000000000>:0)

System.Func`2[T,TResult].Invoke (T arg) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable+WhereSelectListIterator`2[TSource,TResult].MoveNext () (at <00000000000000000000000000000000>:0)

System.Collections.Generic.List`1[T]..ctor (System.Collections.Generic.IEnumerable`1[T] collection) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.Models.GooglePurchase..ctor (UnityEngine.AndroidJavaObject purchase, System.Collections.Generic.IEnumerable`1[T] productDetailsEnum) (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.Utils.GooglePurchaseBuilder.BuildPurchase (UnityEngine.AndroidJavaObject purchase) (at <00000000000000000000000000000000>:0)

System.Func`2[T,TResult].Invoke (T arg) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable+WhereSelectListIterator`2[TSource,TResult].MoveNext () (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.EnumerableExtensions+<IgnoreExceptions>d__1`2[T,TException].MoveNext () (at <00000000000000000000000000000000>:0)

System.Collections.Generic.List`1[T]..ctor (System.Collections.Generic.IEnumerable`1[T] collection) (at <00000000000000000000000000000000>:0)

System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.GoogleQueryPurchasesService+<>c__DisplayClass4_0.<QueryPurchasesWithSkuType>b__0 (UnityEngine.Purchasing.Models.IGoogleBillingResult billingResult, System.Collections.Generic.IEnumerable`1[T] purchases) (at <00000000000000000000000000000000>:0)

System.Action`2[T1,T2].Invoke (T1 arg1, T2 arg2) (at <00000000000000000000000000000000>:0)

UnityEngine.Purchasing.GooglePurchasesResponseListener.onQueryPurchasesResponse (UnityEngine.AndroidJavaObject billingResult, UnityEngine.AndroidJavaObject purchases) (at <00000000000000000000000000000000>:0)

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)

UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)

UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)

Rethrow as TargetInvocationException: UnityEngine.Purchasing.GooglePurchasesResponseListener.onQueryPurchasesResponse(UnityEngine.AndroidJavaObject,UnityEngine.AndroidJavaObject)

UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)

UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)

We encountered same issue with Unity IAP version 4.12.0, this is NOT fixed in Unity Version: 2020.3.39f1
We had to update to IAP version 4.12.0 due to this issue →

But the new package has another BUG…

1 Like

Thank you for the reports, we have reproduced this and are working on a fix.
From our findings, this only affects editor versions 2020.3 and earlier, 2021.2 and earlier.

2 Likes

Hello Yannick_D, Is this issue resolved for 2020.3 or do you still recommend using the purchasing package 4.10.0?