Search Unity

Validate receipt with Codeless IAP

Discussion in 'Unity IAP' started by Koval331, Aug 5, 2019.

  1. Koval331

    Koval331

    Joined:
    Feb 3, 2019
    Posts:
    114
    From here I figured out that I could implement receipt validation from code inside ProcessPurchase method.

    But what if I use Codeless IAP? Can Codeless IAP do receipt validation automatically? And if no, then how do I implement it if I am using IAP Buttons and IAP Listeners instead of the actual scripting API?
     
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @Koval331

    Currently, it is not possible to do receipt validation if you are using Codeless IAP. You can modify the scripts to perform the necessary validation, but there is no pre-built system for doing this at the moment.
     
    Koval331 likes this.
  3. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    Hi, I am using the codelessIAP. If i change the script on IAPButton.cs (as you can see on the image) with the Receipt validation manual codes, can i do the validation?
     

    Attached Files:

    • png1.png
      png1.png
      File size:
      52.7 KB
      Views:
      858
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, that should work but we haven't tested it. But if you're going that route, you might consider not using Codeless in the first place. Also, be careful when you update IAP versions as the update would likely overwrite your changes. There are the Sample IAP projects here, the first one is scripted, the second is Codeless. https://forum.unity.com/threads/sample-iap-project.529555/
     
  5. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    Can you test it for me pls? I think most of the unity iap user wanted to know it.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry no, this would be up to you. As mentioned, I would recommend the scripted approach since you are customizing.
     
  7. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    Ok if anyone have tried this pls write here.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Is it not working in your testing?
     
  9. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    I didnt try, everything is ok in my test project and it is on google play and i tested with test accounts and everything seems correct but i wanted to use validation for illegal buys
     
    Last edited: Aug 15, 2019
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    So you've implemented your suggested code and uploaded to Google Play, and now you are testing your new validation code. You can use Debug.Log to monitor the device logs for debugging. Also, note how the Sample IAP project writes debug information to the UI, very handy for debugging.
     
  11. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    I will check, and then i will write here tomorrow.
     
  12. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    Now, i tried with my phone but i have more than 10 account and validation was coming always true(altough i tried with new google play account) and the paying screen didnt come to screen, but i think it was a problem for me and then i tried with another fresh mobile phone and the paying screen came and i paid with test card ofc, after that because of the i added the validation confirmed text to the end of the validpurchase code, i saw the validpurchased text on the screen.I tried replay the game eveything was good(Using playerprefs).After that, tried reinsalling.Approximately 5 seconds later i saw the validpurchase text so i think everything is ok so far.
    (I added the image of the code i was changed.)
     

    Attached Files:

    • 2.png
      2.png
      File size:
      86.4 KB
      Views:
      550
    Last edited: Aug 16, 2019
  13. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sounds good. Please provide the device logs too, they will contain your Debug.Log statements.
     
  14. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    Ok sorry for delay i have to look for device logs.I reinstall the app to my iap bought fresh phone.So i didnt buy the items again google play just refreshed it.
     

    Attached Files:

    • log.txt
      File size:
      32.5 KB
      Views:
      521
  15. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Actually I was mentioning debugging techniques for your (future) benefit. If it's working, there is no need to attach the logs or perform additional troubleshooting.
     
  16. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    Oh ok :D.Do you see any problem on log?
     
  17. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    No, why? Did you? :)
     
  18. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    No just want to be sure about it.Thanks for everyting.
     
  19. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    And i think from receipt validation code it is return always PurchaseProcessingResult.Complete; so if i use IAP listeners for complete purchases, it wont be a good choice.Am i right?
     
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    It should work, you just don't give the product to the user. Probably let them know too.
     
  21. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    Ye i will give the product when the validpurchase return true.But i dont know what can i write different on listeners
     
  22. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Then don't use codeless, as mentioned. It was not meant for customization and coding, therefore the name. Your approach is not supported, and would be overwritten on the next update. One note though, if you are using the listeners, that means you are doing either a Restore operation or processing a Pending purchase. I doubt you are returning Pending, so that just leaves Restore. A Restore by nature implies the receipt was already checked during initial purchase. Seems to me that you are coding for the exception rather than the rule and handling the exception, instead of the other way around. If only one car on the highway can do 40 miles an hour, do you lower the speed limit to accommodate? Probably not. You keep the speed limit, and handle for the exception for a slower car. Maybe not the best analogy, but you are making this task too hard. Get the basics working first! It's more fun that way anyway, to see your code properly working.
     
  23. proxstudios

    proxstudios

    Joined:
    Jun 29, 2018
    Posts:
    14
    Understood.Thanks for answers.
     
  24. hasnainktofficial

    hasnainktofficial

    Joined:
    Aug 30, 2022
    Posts:
    1
    I'm using codeless IAP and its working fine with (Test card, always approves) but on (Slow test card. Approves after a few minutes) not calling IAP Button OnPurchaseComplete function is there any way to track if product is purchased or not in that case?