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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

IAP failure during Apple Review. Binary Rejected

Discussion in 'Unity IAP' started by chand81, Sep 20, 2019.

  1. chand81

    chand81

    Joined:
    Jun 2, 2011
    Posts:
    25
    New build was submitted with addition of new consumable in-app products. Unity was upgraded from 2017.4.26f1 LTS. Testing purchasing with test accounts worked just fine. Game code uses only Local validation.

    Unity 2018.4.8.f1
    Unity IAP 1.20.0

    Message from Apple:

    ========================================
    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 12.4.1 on Wi-Fi.

    Specifically, we were able to trigger the in-app purchase window, however, our purchases failed due to an error.

    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.

    Resources

    You can learn more about testing in-app purchase products in your development sandbox environment in App Store Connect Developer Help.

    For more information on receipt validation, please see What url should I use to verify my receipt? in the In-App Purchase FAQ.

    Learn how to generate a receipt validation code in App Store Connect Developer Help.



    Please see attached screenshots for details.
    ========================================

    The screenshots show the game's message dialog saying purchase failed.
    Error message for failure (we send this in an analytics event):
    <game's package name>.conscombo006 Unknown

    InitiatePurchase is called only after UnityPurchasing.Initialize is successful.

    Kindly advice.
    Thank you.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, this looks like a possible new policy from Apple. You need to incorporate Receipt Validation. Unfortunately it is not easy to do if you are using Codeless IAP as you would need to edit the files directly. Once you start editing the Codeless files, it's a good time to move to scripting instead. There is more information here: https://docs.unity3d.com/Manual/UnityIAPValidatingReceipts.html I should add, is IAP working for you, in your TestFlight testing?
     
  3. chand81

    chand81

    Joined:
    Jun 2, 2011
    Posts:
    25
    Yes, with app freshly installed from TestFlight or updated from a previous version using TestFlight, all IAP's are working as expected.
    Please note: we are not using codeless IAP. Receipt Validation is done in code, but that step is only after purchase completes (IStoreListener.ProcessPurchase).
    The problem is, instead of IStoreListener.ProcessPurchase, IStoreListener.OnPurchaseFailed is getting called with reason = "Unknown".
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    So you didn't get rejected because of receipt validation, it may be boilerplate text. They occasionally have this problem (false positive) in their testing environment, so I would encourage you to submit again or submit an appeal if IAP is working in your testing.
     
  5. Jacowaco

    Jacowaco

    Joined:
    Aug 23, 2013
    Posts:
    8
    Hi @chand81, were you able to solve your problem? I'm experiencing almost the same thing.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Almost may be for different reasons.
     
  7. uareurapid

    uareurapid

    Joined:
    May 14, 2014
    Posts:
    5
    Hi guys, any news on this? @chand81 @Jacowaco ?? I have exact the same problem. They rejected the app with the same kind of message for 3 times already. All works fine when i test it on Testflight, with my devices. They give the same 1st line about the iPad 13x on Wifi , and then say there is no activity, no dialog shows nothing.
    It clearly seems some bug on unity / iap side
    thanks in advance
     
  8. linktolinh

    linktolinh

    Joined:
    Sep 17, 2012
    Posts:
    3
    I also have the same problem as uareurapid.
    Do you have suggestions for me on what to do?
     
  9. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    603
    Last edited: May 28, 2020
    linktolinh likes this.
  10. linktolinh

    linktolinh

    Joined:
    Sep 17, 2012
    Posts:
    3
    Thank you so much!
     
  11. SimonVigMillard

    SimonVigMillard

    Joined:
    Jul 25, 2018
    Posts:
    13
    Did anyone have this same issue recently? We have had a build rejected in review twice the last couple of days because it seems the store (UnityPurchasing) fails to initialize when the reviewer is testing the build. However, it works every single time when we test it in TestFlight... And we have tested on almost 10 different iOS devices (iPads, iPhones, old and new models).
     
  12. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I've heard of this behavior previously, it seems like it's an issue with the particular reviewer. They may be prompted for Sandbox credentials. If you are able to appeal, you might try providing the credentials.
     
    ilmario and SimonVigMillard like this.
  13. SimonVigMillard

    SimonVigMillard

    Joined:
    Jul 25, 2018
    Posts:
    13
    We appealed and sure enough, it got approved with no further questions asked...
     
  14. AppSD

    AppSD

    Joined:
    Feb 9, 2021
    Posts:
    11
    We are also experiencing the same problem that Unity IAP does not get initialized to make a purchase during the app review. From the screenshot Apple provided, the IAP is just not initialized yet, and not failed. The app is reviewed on IOS 15.2 with WIFI. The IAP uses the script sample HeffDUnity provided and works reliably in all our tests on numerous devices in TestFlight. Interestingly, in IOS 15.1 and higher, the account used for IAP purchase in TestFlight has to be a regular Apple ID, not the Sandbox ID. Sandbox account is only good for local xCode testing. Considering Apple review facility must have internet connection, what could be the cause of this. Does Unity IAP only initialize if the device has a connection to Unity server?
     
    Last edited: Dec 29, 2021
  15. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    IAP does not connect to any Unity servers. It does require network access to the Apple servers. There are no specific Unity IAP flags for Sandbox, this would be an Apple issue.
     
    ilmario likes this.
  16. nithinsb

    nithinsb

    Joined:
    Dec 17, 2020
    Posts:
    12
    We are also facing an issue on similar lines. We are using codeless IAP. Works fine on iPad on every try. But doesn't work on iPhone (model:8S).
    Issue is that the subscription purchase goes through successfully, but the IAP On Purchase event does not get triggered. Can you please help us here?
    Additional info: WIFI connection is working with no issues. The last few lines of the logs received below

    UnityIAP: PurchaseProduct: GS_Yearly_1_Player

    2022-03-04 07:00:54.859779-0600 Raykindle[1166:155847] UnityIAP: UpdatedTransactions

    -> applicationWillResignActive()

    -> applicationDidBecomeActive()

    -> applicationWillResignActive()

    2022-03-04 07:01:31.009221-0600 Raykindle[1166:155847] UnityIAP: UpdatedTransactions

    -> applicationDidBecomeActive()

    2022-03-04 07:01:31.174842-0600 Raykindle[1166:155847] UnityIAP: Finishing transaction 2000000001729904

    2022-03-04 07:02:51.614111-0600 Raykindle[1166:156964] [tcp] tcp_input [C3.1:3] flags=[R.] seq=435034499, ack=1952449132, win=0 state=ESTABLISHED rcv_nxt=435034499, snd_una=1952449132

    2022-03-04 07:02:51.617348-0600 Raykindle[1166:156964] [connection] nw_read_request_report [C3] Receive failed with error "Connection reset by peer"
     
  17. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    What version of IAP? Do you see the system purchase dialog? What do you mean "goes through successfully", because apparently it does not.
     
  18. nithinsb

    nithinsb

    Joined:
    Dec 17, 2020
    Posts:
    12
    IAP Version is 4.0.3.
    Yes, system purchase dialog opens up. I am able to make a purchase and when I go to my AppStore account I see the subscription activated. This is what I meant by "goes through successfully".
    Problem is that the IAP event of 'OnPurchaseComplete(Product)' does not get called as a result of the successful subscription. Since the App doesn't know that the subscription was successful it is not able to handle the subscription activation internally.
    Weird part is that this happens only for iPhone
     
    Last edited: Mar 2, 2022
  19. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Is the failure callback called? Please show your code for both.
     
  20. nithinsb

    nithinsb

    Joined:
    Dec 17, 2020
    Posts:
    12
    public void OnIAPCompleted(Product prd)
    {
    Debug.Log("In IAP subscription success");
    var activeUser = AppFlowManager.ActiveUser;

    SubscriptionPurchaseData subPurchaseData = new SubscriptionPurchaseData();
    subPurchaseData.UserId = activeUser.User.UserId;
    subPurchaseData.PlanId = SelectedPlanId;
    subPurchaseData.ClientId = GSStaticstrings.ClientID;
    if(Application.platform == RuntimePlatform.Android)
    {
    subPurchaseData.BillingSystem = GSStaticstrings.AndroidSystem;
    }
    else
    {
    subPurchaseData.BillingSystem = GSStaticstrings.AppleSystem;
    }
    subPurchaseData.Status = "COMPLETED";
    subPurchaseData.Remarks = "COMPLETED";
    subPurchaseData.TransactionID = prd.transactionID;
    Receipt receipt = new Receipt();

    receipt = JsonConvert.DeserializeObject<Receipt>(prd.receipt);

    subPurchaseData.Payload = receipt.Payload;
    subPurchaseData.RawResponseFromPaymentSystem = JsonConvert.SerializeObject(prd);


    //Trigger this event to continue the user flow without blocking the user.
    EventManager.TriggerEvent(GSStaticstrings.EventSubscriptionSuccessful);
    //Sending purchase data to server will happen parallely below
    StartCoroutine(SessionManager.CaptureSuccessfulIAPPurchase(subPurchaseData));
    }


    ---------------------------------------------------------------------------------------------------------------------------------------------------------
    public void OnIAPFailed(Product prd,PurchaseFailureReason PFR)
    {
    Debug.Log("In IAP subscription FAILED");
    var activeUser = AppFlowManager.ActiveUser;
    SubscriptionPurchaseFailureData subPurchaseData = new SubscriptionPurchaseFailureData();

    subPurchaseData.PlanId = SelectedPlanId;
    subPurchaseData.UserId = activeUser.User.UserId;
    subPurchaseData.PlanId = SelectedPlanId;
    subPurchaseData.ClientId = GSStaticstrings.ClientID;
    if (Application.platform == RuntimePlatform.Android)
    {
    subPurchaseData.BillingSystem = GSStaticstrings.AndroidSystem;
    }
    else
    {
    subPurchaseData.BillingSystem = GSStaticstrings.AppleSystem;
    }

    subPurchaseData.TransactionTime = "";
    subPurchaseData.Reason = PFR.ToString();
    subPurchaseData.RawResponseFromPaymentSystem = JsonConvert.SerializeObject(prd);

    if (ErrorMessage != null)
    ErrorMessage.SetActive(true);
    EventManager.TriggerEvent(GSStaticstrings.EventSubscriptionFailed);
    StartCoroutine(SessionManager.CaptureFailedIAPPurchase(subPurchaseData));
    }
     
  21. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @nithinsb So when you run in XCode, you don't see the Debug.Log statements in the XCode console output? We do have some known limitations with Codeless IAP. You might consider scripted IAP instead, perhaps start with the Sample IAP Project here. I would recommend that you update to IAP 4.1.3, we fixed some issues with iOS receipts https://forum.unity.com/threads/sample-iap-project.529555/#post-7922275
     
  22. nithinsb

    nithinsb

    Joined:
    Dec 17, 2020
    Posts:
    12
    Ok. Let me try with upgraded IAP.
    Meanwhile, I'll post the full log here to help figure out any obvious issues

    REMOVED LOGS
     
    Last edited: Mar 4, 2022
  23. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @nithinsb Got it, please keep me posted on your Scripted IAP testing. You have several errors in your logs that you will want to address, separate from IAP. How are you doing receipt validation? It's currently not supported in Codeless IAP, and is required by Apple. This line in the logs is concerning, you'll want to address it: Have your products been disapproved in itunes connect?
     
  24. nithinsb

    nithinsb

    Joined:
    Dec 17, 2020
    Posts:
    12
    We have started working Scripted IAP testing piece to replace codeles IAP.i'll definitely keep you posted. Regarding the Have your products been disapproved in itunes connect? message, we are baffled. We see it only on iPhone 8S. the products are on Test flight and are properly configured I guess, since they work on iPad and newer iPhones.

    Also, you mentioned about the errors other than IAP. I was told that these errors could be ignored. which errors should we be specifically concerned about?
     
  25. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I would typically try to fix all errors, at least to rule out if they might be related.
     
  26. nithinsb

    nithinsb

    Joined:
    Dec 17, 2020
    Posts:
    12
    Wanted to circle back on this.
    This issue was fixed. Problem was with the device settings. We did a factory reset on the iPhone device, configured the right accounts and it started working