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. Dismiss Notice

[Resolve]Unity iap and European Strong Customer Authentication (SCA) / Interrupted purchases

Discussion in 'Unity IAP' started by EmilieCollard191, Dec 21, 2020.

  1. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    We recently got an email by apple on Strong Customer Authentication that will be active on December 31
    This triggers an Interrupted purchases. I have tested our app and a blank app and it not working.

    The purchase flow stop a step 9 here of section Test an Interrupted Purchase:
    https://developer.apple.com/documen...g_in-app_purchases_with_sandbox?language=objc

    Here the paste bin of the log:https://pastebin.com/SBBLsQxF

    I have debug a little bit the file UnityPurchasing.m Especially the paymentQueue function.
    Only SKPaymentTransactionStatePurchasing and SKPaymentTransactionStateFailed seem to by returned

    I found a similar issue here:
    https://forum.unity.com/threads/solved-ios-iap-flow-breaks-if-user-needs-to-update-billing.410107/

    Does anyone have info on that?

    On our app
    We are using unity 2019.4.14
    The package version is 2.1.1
    and the plugin version is 2.2.2

    On the blank test app
    We are using unity 2019.4.14
    The package version is 2.1.1
    and the plugin version is 2.2.5

    Resolve: I just created a new sandbox account and it worked.
     
    Last edited: Dec 22, 2020
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please place numerous Debug.Log statements in your purchasing code to follow the flow and provide the device logs via XCode https://forum.unity.com/threads/how-to-capturing-device-logs-on-ios.529920/ Also, I might recommend adding the following code and add similar Debug.Log statements. These callbacks generally do not provide additional transaction information, but simply and immediately let you know that you should expect a ProcessPurchase some time in the future. It's not determined if the stores would call these callbacks in the SCA flow.

    The iOS Ask to Buy deferred listener is described here:

    https://docs.unity3d.com/Manual/UnityIAPiOSMAS.html

    For Android, the code would look similar to:

    Code (CSharp):
    1. m_GoogleExtensions = extensions.GetExtension<IGooglePlayStoreExtensions>();
    2. m_GoogleExtensions?.SetDeferredPurchaseListener(OnPurchaseDeferred);
     
    Last edited: Mar 8, 2021
  3. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    Yes I tested with extensions.GetExtension<IAppleExtensions>().RegisterPurchaseDeferredListener
    The same thing occur. Here the log.
     

    Attached Files:

    • Test.txt
      File size:
      11.4 KB
      Views:
      279
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I wouldn't expect any different behavior when testing with the deferred listener, as described. Do normal purchases succeed? Only these deferred purchases fail?
     
  5. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    Yes if i buy without Interrupted purchases it work as expected.
    May I add I'm testing on xcode simulator so the test flow is a bit different.
    https://developer.apple.com/documen...sting_in-app_purchases_in_xcode?language=objc The flow stop at step 6 of "Test an Interrupted Purchase" so I do not even see the transaction in the Xcode debug windows

    My initial test were on testflight I use the simulator for faster iteration.
    Thanks
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please confirm on an actual iOS device per the Apple instructions ("...on the device")
     
  7. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    It does not work more on device. RegisterPurchaseDeferredListener is not called either.
    Here the log
     

    Attached Files:

  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Thanks for checking, we will look into this.
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
  10. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    Yes step 8 go as expected. I can do step 9 but step 10 never come. I never receive SKPaymentTransactionStatePurchased
     
  11. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it, I'm doing the same test here now and will follow up with my results.
     
  12. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
  13. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    Thanks I will test with that.
     
  14. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    Nope not working here the log.
    New was tested with 2.2.5
    Old was tested with the iap version in the sample
    I tested with unity 2019.4.14

    I tested with a subscription purchase because we do not have consumable.

    What was your step and environment?
     

    Attached Files:

    • old.txt
      File size:
      7.2 KB
      Views:
      256
    • new.txt
      File size:
      6.5 KB
      Views:
      246
    Last edited: Dec 21, 2020
  15. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, I tested with a subscription also, using IAP 2.2.5. I'm not using Codeless however, I suspect that is the issue. Please test with the first (scripted) Sample IAP project. I would not recommend Codeless at this time especially with iOS as it does not currently support receipt validation (an Apple requirement) nor SubscriptionManager.
     
  16. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    It dosent work either.
    Here my step:
    1. Open the project with unity 2019.4.14
    2. Update asset database
    3. Update unity iap
    4. Change the subscription product id to ours
    5. link unity service
    6. change Bundle id
    7. Build
    8. Clicked play on xcode
    9. Buy subscription
    10. Failed
    Here the log.
    My colleague will test on his mac.

    Edit: I tested initially with the codeless sample. This test was with the other sample
     

    Attached Files:

    • log.txt
      File size:
      6.5 KB
      Views:
      255
  17. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    You need to publish to Apple first, define your products, create the screenshots, etc. I tested here without issue. The Sample IAP project writes the debug info to the UI, you should see failed followed by success after you accept the Terms and Conditions. Also, ensure you are using In App Purchasing package manager version 2.2.1 and IAP 2.2.5
     
  18. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    Yes I was testing with our apple store app that is already published.
    The package version is 2.2.1 and the plugin is 2.2.5
    I build directly on my ipad.

    Edit: my colleague tested and it does not work either.
     

    Attached Files:

    • log.txt
      File size:
      6.5 KB
      Views:
      239
    Last edited: Dec 21, 2020
  19. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Unfortunately I don't have additional suggestions. Perhaps try making a video (perhaps using a second phone) of the end-to-end testing process. Create a new subscription product if necessary, and create a new test account if necessary. Ensure both OnPurchaseFailed and ProcessPurchase write to MyDebug.
     
  20. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
  21. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    You are just testing with the Sample IAP Project, you should have no user base with a test app. During app testing I always create several subscriptions, several non-consumables, and several test accounts. I'm doing the same test as you, on my iPhone 7. Hopefully there isn't any difference with an iPad, unfortunately I don't have one to test with. Here are my steps:

    1. Created a sandbox account, set for deferred purchasing
    2. Built and deployed a development build from XCode directly to my iPhone
    3. Purchased a subscription
    4. Was prompted for my Sandbox account. This cannot be your developer account.
    5. I was prompted for Terms and Conditions
    6. I immediately received OnPurchaseFailed followed by ProcessPurchase
     
  22. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    I could create a completely different app for testing but we want to be sure it will work on our app and existing subscription product. I will test on an iphone. And see if I can test on a blank app.
     
  23. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    How are you testing a subscription with a single product and a single user? They can only purchase once. Just create a second subscription product, much easier than publishing another app. You can always delete it after your test if you are concerned that users might see it on Google Play
     
  24. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    …It worked we created new sandbox account and it working now thanks
     
    Petr777 and JeffDUnity3D like this.
  25. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    89
    For me I only see this window after acception Terms & Conditions which says "Terms and Conditions of Apple Media Services". I need to press the home key to get rid of it end then nothing happens.

    Using Sandbox user and app is published already a year ago. Just trying the Interrupted Purchases.

    Is it intended that this window doesn't have any accept buttons?

    Bild von iOS.png
     
    nicholasr likes this.
  26. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    That is an Apple dialog, you would need to contact them. What iOS device are you testing on?
     
  27. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    89
    I'm testing on an iPad Air 2.

    So the dialog should normally behave different, yeah?
     
  28. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    In English, there is a lot of text on that dialog and you need to scroll down on the dialog to see the button. You might try scrolling even if it's blank.
     
  29. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    89
    I can scroll but everything's blank. Ok, thanks for the info!
     
  30. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    This has happen to me too but on iPhone 7 plus with iOS 13.5.1. It seem to be a bug on apple side. Maybe older device do that
     
  31. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I'm using an iPhone 7 with iOS 13.5.1 and it works fine. It's more likely a language/locale issue and probably wouldn't happen when published live to the App Store.
     
    nicholasr likes this.
  32. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    89
    Our publisher already told that it might be related to iOS 12.x, but I can't update with this old iPad. Anyways, thanks so far :)
     
    JeffDUnity3D likes this.
  33. Petr777

    Petr777

    Joined:
    Nov 8, 2017
    Posts:
    48
    1. Creating new sandbox account helped us, too. With new account all works as described in Apple docs.


    2.
    This happens for us on some devices, and we didnt found a way to fix this. So we take another device and test on it.
     
    nicholasr likes this.
  34. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    I've just tried this and it works fine for me, but why isn't the IAppleExtensions purchase deferred listener fired if this is deferred purchase?

    What are the conditions for that to get fired?
     
  35. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Personally I don't think it does get fired, it's not an actual deferred purchase, just interrupted. But this callback is a no-op regardless, it doesn't do anything. You couldn't pop up a dialog or take any action, the user is currently busy elsewhere confirming their payment info. You would just want to wait for the eventual ProcessPurchase.
     
  36. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    That's good to know.
     
  37. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Is there any way to know anything about the initial fail so that you can maybe show the user an alternate message when it's an interrupted purchase? I can't see that there is.
     
  38. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    There is no failure, ProcessPurchase is just called after a minute or so. As mentioned, you don't want to show anything to the user, they are busy confirming their bank info. Don't interrupt their interrupted purchase!
     
  39. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    An OnPurchaseFailed event gets fired. You even said so in your post above.
     
  40. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    You will want to test yourself, I'm not certain this is expected behavior when live. Regardless, what action do you plan to take? You shouldn't do anything, correct? Also, we don't have any control on which callback is called, this is done by the store API (Apple StoreKit and Google Play Billing)
     
  41. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    I have tested it myself (in the sandbox). We show a message to the user when a purchase fails.
     
  42. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Agreed, that seems problematic to me also. Let's hope in production, that isn't the case. So far, we haven't heard of any issues with this flow.
     
  43. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    My understanding is that this similar to Ask to Buy. Have you seen how that works live?
     
  44. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Ask To Buy does indeed trigger the DeferredListener . Did you test with a DeferredListener in place? I would be surprised if this method was triggered during an interrupted purchase, but Apple does state that is the case. If I recall, I didn't have the deferred listener in place during my testing for an interrupted purchase.
     
  45. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Yes, I had the deferred listener set up. It wasn't fired.

    Just to confirm. OnProcessPurchase is called for Ask to Buy? DeferredListener is just an extra event that is fired too.
     
  46. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    It's ProcessPurchase, and yes, after the parent approves. I have seen mixed results on this however, as others have stated too. But their docs say yes.
     
  47. JGhadban

    JGhadban

    Joined:
    Apr 1, 2020
    Posts:
    1
    So, just to confirm. The expected solution is to wait after a PurchaseFailed for some amount of time and see if ProcessPurchase happens? Is there a difference between the PurchaseFailed here and one where the purchase actually fails (where we would want to show a message to the user)? I am trying to support SCA in our app, and the user will get a failure message even if everything is working correctly as it stands.
     
  48. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Unless there is a deferred listener call, I don't see a way to tell the difference. I'm not sure why Apple did it that way https://docs.unity3d.com/Manual/UnityIAPiOSMAS.html
     
  49. lolerji

    lolerji

    Joined:
    Jan 7, 2016
    Posts:
    19
    Hello, I am having a similar issue right now.

    Using the IStoreListener, we don't receive ProcessPurchase callback after an interrupted purchase on iOS. You can find the related logs inside the logA file. Apple only notifies failure to purchase, then unity updates transactions and nothing. But if I move the application to the background and refocus it, unity updates transactions again and receives process purchase callback and the purchase is rewarded. Logs for this are included in logB file. This essentially forces the user to either unfocus and focus the app, or close and reopen the app.

    Is there a way to manually trigger the action that starts UpdateTransactions process and eventually invokes the ProcessPurchase callback?
     

    Attached Files:

  50. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    What version of Unity and IAP? Please provide specific steps to reproduce. Can you elaborate "using the IStoreListener"?