Search Unity

Resolved 3 best practice questions regarding Unity IAP in Editor Play Mode

Discussion in 'Unity IAP' started by Endahs, Mar 28, 2023.

  1. Endahs

    Endahs

    Joined:
    Sep 16, 2014
    Posts:
    94
    Hi folks! First, thank you to the Unity IAP Team. Unity IAP is one of the best Unity packages and the support here is excellent. Don't get me started on Addressables...

    Three "best practice" questions about Unity IAP. Let me preface them by saying that I've followed all of the Unity IAP tutorials and documentation (which is excellent) and I already have 11 apps published using Unity IAP today. I am 100% code based and don't use any of the Editor UI for IAP (store, products, etc are all in code).

    1) Is it possible to validate receipts in Editor Play Mode? A year ago I swear we used to be able to instantiate the CrossPlatformValidator in Play Mode but receipts would always fail (because they are test ones, which is expected) and so I would override the validation to test in Play Mode. Today I can't even get the CrossPlatformValidator to instantiate due to missing tangle data in Play Mode. Not a big deal but slightly less code able to be tested before it heads to device.

    2) What is the best practice for dealing with receipts that fail validation? Specifically, what do we do with the receipt that is now stored in product.receipt? In Play Mode the receipts are obviously going to fail validation because they are fake, but also in Production if someone attempts to stuff a bad receipt I will deal with the same issue. I already know that we will not fulfill the reward, but should we also manually erase the receipt saved in product.receipt upon validation failure?

    3) Are test receipts that are created in Editor Play Mode automatically purged? In Play Mode I can test an IAP purchase and it generates a fake receipt, and if I bypass the receipt validation I can grant the Player the reward. However when I stop and restart Play Mode, the receipt saved in product.receipt (in the IAP Controller) is gone. Is this expected? In Production I can still count on the controller retaining the receipt there permanently, correct?

    Thanks for your input!
     
    Last edited: Mar 28, 2023
    JoWenk likes this.
  2. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    183
    Hi @Endahs,
    Thank you for the feedback, it is appreciated! Feel free to reach out if you have more to share!

    For your points:
    1- Unfortunately not, but it is something under our radar.

    2- As you mentioned, yes, it would be better to purge the information. It could be good to log the event as well prior to purging the data, it can be useful for fraud prevention.

    3- Yes, it is intended to wipe the data on the Play Mode restart. This behavior is for debugging purpose, so yes it will be different once on production. Your assumptions are correct.

    To jump back on receipts validation, we have upcoming ideas to have a seamless implementation of it within the editor to be part of integrating UGS Economy. It is indeed an important topic that we will look at this year.
     
    JoWenk and Endahs like this.
  3. Endahs

    Endahs

    Joined:
    Sep 16, 2014
    Posts:
    94
    Thank you @agorain, for your fast reply and for answering all those questions. Excited to see what you folks come up with receipt validation.
     
    Laurie-Unity and Arnaud_Gorain like this.