Search Unity

Restoring Failed Consumable Purchases

Discussion in 'Unity IAP' started by devon_b, Oct 3, 2019.

  1. devon_b

    devon_b

    Joined:
    Aug 2, 2018
    Posts:
    9
    Hi there, as part of investigations into issues with our app and consumable IAPs, I was playing around with my Android device and discovered that if I...
    1. Make a purchase in app
    2. Wait until google confirms it completed successfully
    3. Cut my device's internet before the purchase is validated remotely (we send receipts to our server for validation and to reflect the purchase in the user's data)
    4. Quit the app
    5. Delete Google Play's cache
    The purchase seems to be lost forever. It does not come in again automatically on restarting the app as a pending receipt to be sent away for validation and reflection in the app, as it would if I stopped at 4 and just restarted the app. So far as I can tell, ProcessPurchase is not being called like it should.

    The purchase remains visible in purchase history, an e-mail also arrives at my google account saying the purchase was made successfully.

    I have tried:
    • Restarting the phone
    • Syncing the google account on the device
    • Removing and re-adding the google account on the device
    • Changing to another google account and back again on the device
    • Uninstalling then re-installing the app on the device
    • Buying the same consumable again
    • Buying a different consumable
    • Restarting the app
    Nothing has worked. These are purchases using a test card that always succeeds on an Android 9 device. Unity IAP package version is 2.0.6.

    Is this expected behaviour or is there some step I can take that I have missed?
    Cheers
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. devon_b

    devon_b

    Joined:
    Aug 2, 2018
    Posts:
    9
    Your post originally started with the sentence "I would not think that users would ever experience this behavior, is this an actual customer issue for you?" Which I found to be unprofessional and unhelpful. This has damaged my impression of the Unity team and may effect my decision to use or recommend Unity in the future. I appreciate you appear to have edited it out but it remains in the notification e-mail I received. Please be careful.

    We have customers who have been able to make purchase after failures, which should not be possible as the app currently checks for pending receipts, and shows a dialog directing them to complete the transaction by pushing a button if it detects any.

    Like I said, the above behaviour arose in the course of investigations trying to replicate that situation (where the app detects no pending receipts despite not all having been confirmed). These issues are being reported by a small minority of our customers. Whether this specifically is occurring or not, I do not know, but it was worth me asking the question here as I could find no solid answers elsewhere.

    Asset version is 1.22.

    This is occurring on a release build which to my knowledge does not output any Unity logs. I will see if I can replicate the behaviour with a debug build and get a log and post back here either way. Thanks.
     
    Last edited: Oct 4, 2019
  4. devon_b

    devon_b

    Joined:
    Aug 2, 2018
    Posts:
    9
    Just an update.

    I'm very sorry, but I'm unable to obtain a build that can both output logging information and carry out IAPs. It's an organisational thing. If that changes and I can get a log I will update again.

    In the meantime I believe we will be using logs and adding the contents consumable purchases to accounts when this happens.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    All Android apps produce logcat logs, it's not a function of the build. Unity IAP automatically writes debug runtime information to the logs.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, it sounded like an edge case as part of a testing process. I wanted to see if customers were actually experiencing the issue which affects the issue priority. Thank you for the clarification.
     
  7. devon_b

    devon_b

    Joined:
    Aug 2, 2018
    Posts:
    9
    Thanks. I wasn't being thorough and just thought it wasn't outputting any logging.

    I had another go and managed to collect the following log:

    To simplify things I have removed my personal account from the device and the below was carried out with my work account as the only google account on the device. To clarify, most of my testing yesterday was carried out with two accounts on the device yesterday (and just switching them around in google play store/restarting) but cutting to one account doesn't seem to have changed things.

    This log covers...
    1. Starting the app
    2. Carrying out a successful purchase
    3. Failing a second purchase by cutting wifi after it succeeds before it is confirmed (as above)
    4. Starting the app again
    5. Confirming the past purchase receipt exists (a dialog shows when I attempt to make another purchase)
    6. Quitting the app
    7. Killing google play app and deleting its storage
    8. Starting the app
    9. Confirming the past purchase receipt is no longer there (no dialog shows when I attempt to make another purchase)
    I should mention though I didn't for this specific purchase, I have collected server data that shows that not all the receipts I have in my inbox from google play were processed by the game's server and added to my account.

    I start this process at 15:51 but the log only seems to show subtantial UnityIAP information for the last startup. Let me know if this is a problem. I used "adb logcat -d | findstr -i unity > log.txt" command from the post you linked me to to gather the log. In any case, it looks like the purchase is gone.

    I see purchase history is returning with 0 but the continuation token is null. I don't know if that is ok or not. I was not responsible for creating this subsystem, I inherited it after the chap who did left the company. Is it possible I am missing a setting somewhere that might fix this?

    Also, at this point there must be like five or six test consumable purchases made with this google account that are unconfirmed/unprocessed by the game server at this point.
     

    Attached Files:

  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  9. devon_b

    devon_b

    Joined:
    Aug 2, 2018
    Posts:
    9
     
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Unfortunately then we don't have the full logs. The way I capture logs is to run adb logcat on my PC (and keep it running, it will scroll to the end of the current logs, then will wait and may appear to hang, it's just waiting for more logs), THEN launch the app on the device so I capture all the logs.
     
  11. devon_b

    devon_b

    Joined:
    Aug 2, 2018
    Posts:
    9
    Good morning, Jeff. I hope you had a great weekend. Did you see Joker? I did. It was really good.



    Thanks for the alternative method of gathering logs. I copied everything in the command window and pasted it into Notepad++. I then did a find-all for "UnityIAP", which yielded the attached results. To make sure nothing was disappearing I took three different logs at different stages.

    purchase_success covers the app starting and a successful IAP.

    purchase_failure covers an unconfirmed IAP (by cutting off WiFi after the purchase goes through on Google's end, as above). It also covers starting up the app again afterwards.

    purchase_disappears logs a startup of the app after I have deleted Google Play's storage in the settings.

    I notice in purchase failure the following is visible:

     UnityIAP: Sku is owned: rilakkuma_jewel_5 


    This line appears to be abscent in purchase_disappears. Do you have any idea why? Perhaps there is something completely wrong that is being overlooked. If you have any useful insight or ideas on what to try to solve the problem, that would actually be really useful.

    As for my purchase, follow this method and...


    Edited for humour.
     

    Attached Files:

    Last edited: Oct 7, 2019
  12. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You must be using a very old version of IAP because the version is not showing in the logs. Is there any reason you are not able to use adb logcat?
     
  13. devon_b

    devon_b

    Joined:
    Aug 2, 2018
    Posts:
    9
    Hi Jeff. It's getting cold here in Japan, is it the same where you are?

    Thank you for pointing out that I could be using the wrong version of Unity IAP, no matter how slim the possibility!

    lies.PNG

    I took a screenshot that shows I have the 1.22 version. Can you confirm this is the case? I even tried re-downloading the package and installing it again, but the importer showed it would not add or refresh anything. Is my Unity Editor lying to me? This is truly shocking. Perhaps I never even made a game at all. I shall have to ponder on this.

    As for adb logcat, well, I have been using it every time to gather logs. But it appears to be a lazy logcat if it's missing the version log you are looking for. Perhaps I should feed it some logfish, would that help? Or a bit of logcatnip might work too.
     
    egcaragay likes this.
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We have your steps to reproduce, I'll check into it. I should add, if this is blocking your testing, you could create another tester account.
     
    Last edited: Oct 8, 2019
    devon_b likes this.
  15. IgorPanchenko

    IgorPanchenko

    Joined:
    Oct 17, 2018
    Posts:
    1
    Hi, I was faced with exactly the same situation, was there any news about this
     
  16. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please open a separate thread and describe your issue in detail and provide the logs.