Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Iap offline receipt validation

Discussion in 'Unity IAP' started by kaisersam, Jun 29, 2020.

  1. kaisersam

    kaisersam

    Joined:
    Mar 31, 2016
    Posts:
    37
    Hi,

    after implementing Unity Iap for my game on Android, i had an issue regarding the receipt validation.

    Indeed, when the user has a network connectivity, i could check if the product was purchased with the following code in the documentation https://docs.unity3d.com/560/Documentation/Manual/UnityIAPValidatingReceipts.html

    But in the case, when the user bought a product in game, and relaunch the game later, with no network connectivity, i can't check the receipt because Unity Iap can't initialized (need a network connectivity).

    So i would like to know how do i need to proceed to check the receipt when the user has no network connectivity?

    I saw that i could retrieve product receipts offline on iOS. Is it available on Android? do i need to store it on the user device?

    If it's not possible, is it recommended to lock the product that the user bought, until he's connected to internet?

    Thank you.

    Regards, Samih.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,372
    You would need to use local storage like PlayerPrefs to store user purchase information.
     
    kaisersam likes this.
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,372
    And you don't need to store the receipt, just a flag that says the user purchased. You really don't want to store the receipt anyway. If you have verified it once, that is sufficient. Storing only invites tampering, so you might as well make it easy and just store the purchase boolean for the product. Keep in mind that PlayerPrefs is fairly easy to tamper with and can be deleted if the user reinstalls, so you might consider binary storage.
     
    kaisersam likes this.
  4. kaisersam

    kaisersam

    Joined:
    Mar 31, 2016
    Posts:
    37
    Hi,

    I will follow this solution.

    Thank you.

    Regards, Samih.
     
unityunity