Search Unity

Iap offline receipt validation

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

  1. kaisersam

    kaisersam

    Joined:
    Mar 31, 2016
    Posts:
    39
    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

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

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    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.
     
    ShantiB95 and kaisersam like this.
  4. kaisersam

    kaisersam

    Joined:
    Mar 31, 2016
    Posts:
    39
    Hi,

    I will follow this solution.

    Thank you.

    Regards, Samih.