Search Unity

PurchaseFailureReason: Unknown

Discussion in 'Unity IAP' started by stefanplc, Apr 18, 2018.

  1. MaxBNvizzio

    MaxBNvizzio

    Joined:
    Jan 28, 2020
    Posts:
    2
    The IAP version we use is 2.0.3 (as indicated by the Package Manager).
    However, our logs show the following lines mentioning "version 1.22.0":

    Code (CSharp):
    1. [Log] UnityIAP Version: 1.22.0
    2. UnityEngine.Purchasing.StandardPurchasingModule:Instance(AppStore)
    3. Nvizzio.RCTM.IAP.UnityIAPManager:InitializePurchasing()
    4. Nvizzio.RCTM.Social.SocialPlatformsManager:CompleteInitialization()
    The SocialPlatformsManager:CompleteInitialization call:
    Code (CSharp):
    1.  private void CompleteInitialization()
    2. {
    3.      InAppPurchaseManager.Instance.ConnectToStore();
    Code (CSharp):
    1. public static class InAppPurchaseManager
    2. {
    3.     private static IPurchaseManager instance;
    4.     public static IPurchaseManager Instance
    5.     {
    6.         get
    7.         {
    8.             if (instance == null)
    9.             {
    10.                 instance = new UnityIAPManager();
    11.             }
    12.             return instance;
    13.         }
    14.     }
    15. }
    What does this version number refer to?
    In which circumstances can it be different from our actual package version?
    Thank you.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, 1.22 was a bit buggy. I would encourage you to upgrade. You are mixing Package Manager and IAP versions. IAP requires both an Asset package and a PacMan package. The latest for both is IAP 2.0.0 and "In App Purchasing" in PacMan which is 2.1.1. Confusing, we are working to improve this. You can tell your version by going to menu Window/Unity IAP/IAP Updates... . Can you share your "ConnectToStore" script?
     
  3. Laurent_Giroud_Nvizzio

    Laurent_Giroud_Nvizzio

    Joined:
    Mar 18, 2019
    Posts:
    4
    Note: I am relaying for MaxBNvizzio (I am the lead prog on his team).

    We did upgrade the Asset Store package and the PacMan package (and yes, this is super confusing ;) ).
    But this actually increased the number of devices on which we got the "Unknown" error.

    Here it is:
    Code (CSharp):
    1.         public void ConnectToStore()
    2.         {
    3.             if (!(storeController != null && storeExtensionProvider != null))
    4.             {
    5.                 catalog = ProductCatalog.LoadDefaultCatalog();
    6.  
    7.                 StandardPurchasingModule module = StandardPurchasingModule.Instance();
    8.  
    9.                 ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);
    10.  
    11.                 IAPConfigurationHelper.PopulateConfigurationBuilder(ref builder, catalog);
    12.  
    13.                 UnityPurchasing.Initialize(this, builder);
    14.             }
    15.         }
    16.  
    The PopulateConfigurationBuilder() function simply calls builder.AddProduct() for every product in the catalog.allValidProducts of which the product.allStoreIDs.Count is strictly greater than zero:


    Code (CSharp):
    1.         public static void PopulateConfigurationBuilder(ref ConfigurationBuilder builder, ProductCatalog catalog)
    2.         {
    3.             foreach (ProductCatalogItem product in catalog.allValidProducts)
    4.             {
    5.                 IDs ids = null;
    6.  
    7.                 if (product.allStoreIDs.Count > 0)
    8.                 {
    9.                     ids = new IDs();
    10.                     foreach (var storeID in product.allStoreIDs)
    11.                     {
    12.                         ids.Add(storeID.id, storeID.store);
    13.                     }
    14.                 }
    15.  
    16.                 List<PayoutDefinition> payoutDefinitions = new List<PayoutDefinition>();
    17.                 foreach (ProductCatalogPayout payout in product.Payouts)
    18.                 {
    19.                     payoutDefinitions.Add(new PayoutDefinition(payout.typeString, payout.subtype, payout.quantity, payout.data));
    20.                 }
    21.                 builder.AddProduct(product.id, product.type, ids, payoutDefinitions.ToArray());
    22.             }
    23.         }
    24.  
    the IStoreController is then stored in storeController (when OnInitialized() gets called).
    Purchases are made simply by calling
    Code (CSharp):
    1.                 storeController.InitiatePurchase(product);
    2.  
    Also, note that the emergence of these "PurchaseFailureReason.Unknown" errors arised only in the recent weeks (last week if I recall correctly).
    We never experienced those before.

    More importantly, another project of our company has also been experiencing them this week when they also have made no changes in their purchasing code.

    So this spawns the following questions:
    - given the above, do you see anything wrong in how the IAP is setup on our side?
    - what could explain the sudden emergence of these errors in the past week(s) on multiple projects?
    - why would upgrading to IAP 2.0.3 and the 2.0.0 asset store package cause the error to occur on multiple devices instead of only one for version 1.22.0?

    We will gladly provide more information if needed.

    Thanks in advance.
    Cheers,
    Laurent Giroud
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Understood, I've heard of this same report from another developer. I will pass this along with high priority.
     
  5. Laurent_Giroud_Nvizzio

    Laurent_Giroud_Nvizzio

    Joined:
    Mar 18, 2019
    Posts:
    4
    Thanks, this is much appreciated.

    If this is any help, on iOS devices the resulting end user experience is the following:
    - user opts to purchase a product
    - we call storeController.InitiatePurchase()
    - an Apple purchase confirmation dialog pops in (offers Cancel/Buy)
    - user taps "Buy"
    - popup goes away, a few seconds elapse
    - an Apple purchase dialogs pops in, recapitulates the purchase and asks user to enter their password
    - user enters password then taps "Buy"
    - popup goes away, a few seconds elapse
    - OnPurchaseFailed() gets called with "Unknown" as the reason.

    Since no code of our own is executed in between the call to InitiatePurchase() and the call to OnPurchaseFailed(), it looks like the issue comes from the interaction between the Unity purchase code and the Apple services.

    Note however that this also happens on Android devices (with a slightly different flow however).
    Correction on that point: the issue does not occur on our Android builds anymore (we have not changed anything).

    Cheers,
    Laurent
     
    Last edited: Oct 16, 2020
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Password? Is this on Apple sandbox, or are you testing on a live app. I just tested on iOS 14 with IAP 2.0 using TestFlight, and did not see this issue and there was no password popup.
     
    Last edited: Oct 16, 2020
  7. rizawerx

    rizawerx

    Joined:
    May 30, 2013
    Posts:
    38
    Hi,
    I also experience always fail purchases. I use Codeless IAP and while it works in Android, but always fail in IOS and always rejected because of this. I have create bank account, manage IAP, sandbox tester. But when I try to purchase with sandbox tester, apple always ask password which always fail. I don't know why my sandbox tester password always fail. When I check log via xcode, no reason why fail. I search about this and find some problem related, like "it's apple problem" but I'm not sure about it...help..
    btw I'm using unity2019.4.11f1 and IAP2.0.0

    Update:
    Wait...I just pushed new build to test flight and now I CAN purchase my IAP using my own account...I haven't checked sandbox tester account, but...ummm, it's now working. Weird...the only difference codeless IAP from previous version is Automatically initialize Unity Purchasing is turned off in newest build and I only use IAP listener. Is that the culprit? And I also made my apple ID password same with sandbox tester. Don't know if that is also the culprit...but fact is, no more password always fail, just enter my password and voila, purchase accepted..
     
    Last edited: Oct 17, 2020
  8. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    We are also experiencing a similar behavior for iOS 13 users when building with development profile. Using a production profile works as expected.

    Purchase starting, the password popup shown, and returns with a Unknown failure reason.

    The XCode logs do not tell much:
    2020-10-18 15:44:56.000532+0300 spadesroyale[950:150462] UnityIAP: PurchaseProduct: {OUR_INTERNAL_ID}
    2020-10-18 15:44:56.023492+0300 spadesroyale[950:150462] UnityIAP: UpdatedTransactions
    2020-10-18 15:45:33.141725+0300 spadesroyale[950:150462] UnityIAP: UpdatedTransactions
    2020-10-18 15:45:33.142031+0300 spadesroyale[950:150462] UnityIAP: PurchaseFailed: 0


    We are using Unity 2019.4.4 and IAP 2.0.0
     
    Last edited: Oct 18, 2020
  9. Shankar-Ganesh

    Shankar-Ganesh

    Joined:
    Sep 23, 2013
    Posts:
    32
    JeffDUnity3D,

    I am testing my game with Unity IAP V1.23.4 with Unity LTS version 2019.4.8f1 and the purchase fails with the reason (PurchaseFailureReason.Unknown) in iOS sandbox testing. I'm sure that there are no problems with the code because it works for Android. Also the previous version iOS test build iAP also not working.
     
  10. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    I have noticed this problem appears on iOS 13 devices with development builds. Production builds on iOS 13, or development builds on iOS 14 works
     
  11. Shankar-Ganesh

    Shankar-Ganesh

    Joined:
    Sep 23, 2013
    Posts:
    32
    @rankornfeld, If that is the case it shouldn't work with previous version of my app. But in previous version of my app I have unit tested and uploaded for App Store.
     
  12. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    If you uploaded to AppStore it means you built with a production profile?
    I have tested the same development build on 2 devices, iOS14 worked great, iOS13 did not every time.
    Later I have tested the same build with a production profile, worked on IOS13 as well.
     
  13. Shankar-Ganesh

    Shankar-Ganesh

    Joined:
    Sep 23, 2013
    Posts:
    32
    @rankornfeld, Thank you for help me out. I have updated my iPad to iOS 14.0.1 and it works fine now. Will test on iOS 13 with production profile...
     
  14. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,264
    Getting the "Unknown" error on a iOS 12.4 iPod Touch 6 (unable to update), regardless of the profile type used. Using a non-sandbox user account, the native purchase popup appears once, followed by the error. Using sandbox user credentials, the purchase popup appears twice, then the error.

    It is impossible to purchase something successfully. Unity IAP 2.0 and 1.23.5 on Unity 2018.4.0.
     
  15. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    IAP works for me with IAP 2.0 and iOS 14.01 using TestFlight, and not Sandbox testing. But we are hearing of increasing reports of the Unknown error, so any additional insights are appreciated. We made note of the development profile mention.
     
    Last edited: Oct 20, 2020
  16. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you confirm that you've updated the terms on your Apple developer dashboard? Something to check.
     
  17. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can uses confirm that the error reason code is Unknown vs AppNotKnown?
     
  18. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,264
    @JeffDUnity3D unfortunately there is no iOS 13 or 14 for iPod Touch 6 gen anymore, so I am unable to test against iOS 14 on that device.

    Yes, contracts & terms for paid application etc. are accepted on the Apple developer dashboard. Unity IAP initializes correctly and receives products. We are displaying the error code on purchase in the UI via PurchaseFailureReason.ToString() and it is giving out the value "Unknown".
     
    JeffDUnity3D likes this.
  19. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you share the device logs from XCode? https://forum.unity.com/threads/how-to-capturing-device-logs-on-ios.529920/ And rule out account issues. But if it happens for all your customers, then not relevant https://developer.apple.com/documentation/storekit/skerror/code/unknown?changes=latest_minor
     
  20. DomantasGarsvas

    DomantasGarsvas

    Joined:
    Jul 13, 2020
    Posts:
    3
    We have the same problem with the Unity IAP, when the user is performing a purchase the purchase will fail with the error code PurchaseFailureReason.Unknown.

    The initialization goes through fine, and we can retrieve the product list from the IStoreController.products so the connection to the store is good up until this point.

    We tried debuging it and the problem arises after we call
    m_StoreController.InitiatePurchase(product)


    We are using Unity 2019.4.4f1 with Unity IAP 2.0.0 (haven't updated to 2.1.0)
    Code (CSharp):
    1.    
    2. public void BuyProductID(string productId)
    3.     {
    4.         if (IsInitialized())
    5.         {
    6.             Debug.Log("Purchaser::BuyProductID(" + productId + ")");
    7.             Product product = m_StoreController.products.WithID(productId);
    8.  
    9.             if (product != null && product.availableToPurchase)
    10.             {
    11.                 Debug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
    12.                 m_StoreController.InitiatePurchase(product);
    13.             }
    14.             else
    15.             {
    16.                 InitializePurchasing(true);
    17.                 MessagePopup.instance.ShowMessage("Purchase failed, check internet connection.", () =>
    18.                 {
    19.                     World.instance.SetIAPFade(0f);
    20.                 });
    21.                 Debug.LogError("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
    22.             }
    23.         }
    24.         else
    25.         {
    26.             InitializePurchasing(true);
    27.             MessagePopup.instance.ShowMessage("Purchase failed, check internet connection.", () =>
    28.             {
    29.                 World.instance.SetIAPFade(0f);
    30.             });
    31.             Debug.LogError("BuyProductID FAIL. Store Not initialized. Trying to initialize the store again.");
    32.         }
    33.     }
    34.  
    35.  
    36.    public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
    37.     {
    38.         switch (failureReason)
    39.         {
    40.             case PurchaseFailureReason.PaymentDeclined:
    41.                 MessagePopup.instance.ShowMessage("Purchase failed, payment declined.");
    42.                 break;
    43.             case PurchaseFailureReason.Unknown:
    44.                 MessagePopup.instance.ShowMessage("Purchase failed, check internet connection.");
    45.                 break;
    46.             case PurchaseFailureReason.PurchasingUnavailable:
    47.                 MessagePopup.instance.ShowMessage("Purchase failed, payment is turned off in the device settings.");
    48.                 break;
    49.         }
    50.  
    51.         Debug.Log($"Purchase failed: '{product.definition.storeSpecificId}', Reason: {failureReason}");
    52.         World.instance.SetIAPFade(0f);
    53.     }
    54.  
    We got the report that this happens when apple rejected our app.
     
  21. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are you able to reproduce? Regardless, we are aware of the problem and working on it.
     
  22. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    We are seeing this problem on Android as well. No other error, just Unknown error returns when trying to purchase.

    Unfortunately I see this on our production environment so I do not have the full logcat output with the native UnityIAP logs.
     
  23. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Did you mean to say you "don't" see this in your production environment? If you can reproduce, you would have access to the logs https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/
     
  24. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    No, I mean we do not know how to reproduce, but we do see this issue on our production environment.

    We are collecting logs on production, and sent them to our servers on errors, and we see some purchases that just fail with Unknown.

    UnityPurchasing is initialized successfully on those cases (we do see some AppNotKnown issues as well but that's another issue), and still users get the Unknown error.
     
  25. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Understood, you're in the same boat as several other developers. There is an increase in both errors in recent IAP releases, and we are working to determine the cause.
     
  26. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,264
    I relaunched the exact same build to gather some device logs for posting them here - today, 4 days later the UNKNOWN error does not occur anymore on my test device. I am not sure what changed. On Tuesday, I deleted all sandbox users and created a new one, which did run into the 'unknown' error too. Maybe the additional time passed worked, or something changed on the Apple / Unity IAP backend in the meantime.

    macOS 10.15.7, XCode 12.0.1, Unity IAP 1.23.5, Unity 2018.4.0, iOS 12.4, sandbox user, auto managed signing and development certificate
     
    makaka-org likes this.
  27. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I have heard similar which points to a possible issue on the Apple store side.
     
    Sushantha_SV likes this.
  28. unity_cf8op2urKKw1iw

    unity_cf8op2urKKw1iw

    Joined:
    Aug 26, 2019
    Posts:
    3
    Hello, wanted to contribute to the conversation as my app also fails to process purchases successfully. Alongside the typical Unknown unity error, I get this xcode error on iOS with a test account on sandbox mode.

    <SKPaymentQueue: 0x280eb0540>: Payment completed with error: Error Domain=ASDErrorDomain Code=500 “Unhandled exception” UserInfo={NSUnderlyingError=0x281ee74b0 {Error Domain=AMSErrorDomain Code=100 “Authentication Failed” UserInfo={NSLocalizedFailureReason=The verify credentials call failed., NSLocalizedDescription=Authentication Failed, NSUnderlyingError=0x281ee6d30 {Error Domain=AKAuthenticationError Code=-7013 “The operation couldn’t be completed. (AKAuthenticationError error -7013.)” UserInfo={NSLocalizedDescription=The operation couldn’t be completed. (AKAuthenticationError error -7013.), NSUnderlyingError=0x281ee5f80 {Error Domain=AKAuthenticationError Code=-7075 “The operation couldn’t be completed. (AKAuthenticationError error -7075.)” UserInfo=0x280b5af00 (not displayed)}}}}}, NSLocalizedFailureReason=An unknown error occurred, NSLocalizedDescription=Unhandled exception}
     
  29. Remstam

    Remstam

    Joined:
    Oct 6, 2017
    Posts:
    23
    Also caught "PurchaseFailureReason: Unknown" a few days ago and start catching from now on, but that all is only for subscription purchases only (and sandbox testing only).

    But the detailed message from IAP args says it is "APPLE_Cannot connect to iTunes Store"
    And native logs says the same

    StoreKitClient: Buy failed with error: Error Domain=SSErrorDomain Code=109 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store, SSErrorHTTPStatusCodeKey=502} for payment: <private>


    In that case it is not a Unity IAP fault I guess, but I am not 100% sure it is related to other messages about "Unknown" from late-October.

    Android subsciption purchase flow was always OK during that period.

    IAP 2.1.1, test devices are iOS 12, iOS 13.
     
  30. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We believe this is due to an artifact on the Apple side with passwords in Sandbox. Please try with a new Sandbox user account, as a test.
     
  31. lipengfei111

    lipengfei111

    Joined:
    Sep 11, 2020
    Posts:
    3
    Hello,

    I have Galaxy S8 and IAP2.0.0 ,and the IAP target is Samsung, it works good in test mode, but online the Samsung Checkout always crashed ,I don't know where is the wrong

    Thanks.
     
  32. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please provide the device logs. Are you receiving the Unknown error? If not, please open a new thread. https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/
     
  33. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    Hi Jeff

    Does the new version (2.2.0) targets the Unknown issues?
     
  34. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    One would hope, please test!
     
  35. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    I can see that you upgraded the Google play APIs, but we see Unknown from iOS as well
     
  36. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are you using 2.2.0 and still seeing the error?
     
  37. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    No, just got the update notification today..

    But since our game is in production, and updating the iOS version is always a long process, we can actually know if something has changed only several days after deployment.

    So hopefully you found something there..
     
  38. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    No you would want to test yourself before publishing. Are you able to reproduce?
     
  39. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    Unfortunately this behavior is not persistent
     
  40. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Again, that would point more to a possible issue on the Apple side. If you can find definite steps to reproduce, it would be helpful
     
  41. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    Some more xcode log info, I am getting this:
    UnityIAP: UpdatedTransactions
    UnityIAP: PurchaseFailed: 0

    Any idea what is purchase failed 0? in Unity I am getting Unknown for this.
    Version 2.0.0
     
  42. max427857

    max427857

    Joined:
    Sep 9, 2020
    Posts:
    8
  43. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please provide steps to reproduce. When do you see this log error, during a purchase? Please add additional Debug.Log statements to your purchase code to track the execution flow, they will show in the XCode logs
     
  44. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    Hey, I've just started getting the unknown error bug when trying to update my app.

    I'm on Unity 2018.4.31 all these different ways of finding and installing the IAP package is confusing, can you please tell me:

    A) is the iOS sandbox unknown error issue fixed?
    B) What packages do i need for IAP in Unity 2018.4.31?
     
  45. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please see my previous post for A). For B), you need IAP 2.2.6 and In App Purchasing Library 2.2.2
     
  46. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    ok thanks,

    one more thing: are you meant to also turn iap on in the services window?
     
  47. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes