Search Unity

[SOLVED] Binary Rejected for InApp Purchases (iOS)

Discussion in 'iOS and tvOS' started by Jacowaco, Apr 4, 2020.

  1. Jacowaco

    Jacowaco

    Joined:
    Aug 23, 2013
    Posts:
    8
    Hello, my binary has been rejected 3 times for the same motive.

    -----------------------------------------------------------------------
    Guideline 2.1 - Performance - App Completeness

    We found that your in-app purchase products exhibited one or more bugs when reviewed on iPad running iOS 13.4 on Wi-Fi.

    Specifically, an error message still occurred when we attempted to purchase In App Purchases in the app.

    Next Steps

    When validating receipts on your server, your server needs to be able to handle a production-signed app getting its receipts from Apple’s test environment. The recommended approach is for your production server to always validate receipts against the production App Store first. If validation fails with the error code "Sandbox receipt used in production," you should validate against the test environment instead.
    -----------------------------------------------------------------------

    The "Next Steps" part i have found in internet is a "generic response" they give to all developers with different problems that have been solved in many different ways, so it is not helpful at all.

    They sent me an screenshot which i attach here. They are getting a PopUp which is programmed to appear at the BuyProduct function when the Manager hasn't been initialized:

    Code (CSharp):
    1.  
    2. public void BuyProduct(ProductsName name)
    3.     {
    4.         if (!IsInitialized())
    5.         {
    6.             //Debug.Log("Buy product not initialized");
    7.             if (PopupsManager.Instance != null)
    8.                 PopupsManager.Instance.OpenPopUpMessage("Hubo un problema con la compra (Error 1).");
    9.             return;
    10.         }
    11.        [...]
    12.     }
    13.  
    screen3.png

    The code works perfectly on Android, it is already on the Store.
    And in iOS, for me and my testers, it works perfectly on TestFlight and also using a test account in the Sandbox Enviroment.
    I've never gotten that error in an iOS device so i don't really have a clue as to why it may be different for them.

    Any clue that may help?

    The game has release date on this Thursday 9 for thousands of fans of the product and i don't have many more days to come and go with the Apple Review team.
     
  2. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    516
    How does your IsInitialized() function work?

    Unity IAP initialization is asynchronous and does not time out when the internet is bad. It happened to me before. You may want to implement a wait.

    Also, I assume the Spanish message said "There was a problem with the purchase"? The reviewer could easily conclude that it is an issue with your game based on that message, not App Store. I think the error message could also be more meaningful, for example, you can frame the Apple's server to be the issue if IAP system did not initialize in time, say "There is a connection issue getting IAP information from App Store".
     
  3. Jacowaco

    Jacowaco

    Joined:
    Aug 23, 2013
    Posts:
    8
    Hello Neonlyte. Thank you very much for answering me.

    Here is the Initialization part of the code:

    Code (CSharp):
    1. public void InitializePurchasing()
    2.     {
    3.         if (IsInitialized()) return;
    4.  
    5.         var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    6.  
    7.         foreach (var product in IAPProducts.products)
    8.         {
    9.             builder.AddProduct(product.Value.name, product.Value.type);
    10.         }
    11.  
    12.         UnityPurchasing.Initialize(this, builder);
    13.     }
    14.  
    15.     public bool IsInitialized()
    16.     {
    17.         return controller != null && extensions != null;
    18.     }
    19.  
    20.     public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    21.     {
    22.         //Debug.Log("IAP: Initialized successfully");
    23.         this.controller = controller;
    24.         this.extensions = extensions;
    25.     }
    26.  
    27.     public void OnInitializeFailed(InitializationFailureReason error)
    28.     {
    29.         //Debug.Log("Initialization Failure");
    30.         if (PopupsManager.Instance != null)
    31.             PopupsManager.Instance.OpenPopUpMessage("Hubo un problema con la compra (Error 5). " + error.ToString());
    32.     }
    And here is the full class:
    https://drive.google.com/file/d/1wZXjwMEWgv478_wyIou6oZb3aKp4FyCR/view?usp=sharing

    I like your ideas of being more explicit with the errors and i will apply it in the next build, but i still don't have a clue how to stop the error from happening. I sent a new build with some minor changes and will post as soon as i have an answer.
     
  4. Jacowaco

    Jacowaco

    Joined:
    Aug 23, 2013
    Posts:
    8
    So they approved the last build even though i didn't touch the initialize function. I don't know which of the changes made it approve. I just converted the class to a Monobehavior (it was an static class) and i added the receipt validation.
     
  5. IMWinter

    IMWinter

    Joined:
    Nov 18, 2013
    Posts:
    3
    @Jacowaco how did you do the receipt validation? is that an existing unity iAP function?
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  7. GameEver

    GameEver

    Joined:
    Apr 28, 2020
    Posts:
    12
    Yes we added the CrossPlatformValidator. I think that solved it.
     
  8. BloomBigGames

    BloomBigGames

    Joined:
    Mar 30, 2020
    Posts:
    2
    Still not resolved. I have tried adding receipt validation as well in it.
    upload_2021-6-18_12-26-54.png
     
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446