Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

How to save a purchase?

Discussion in 'Unity IAP' started by Calvares, Aug 14, 2021.

Thread Status:
Not open for further replies.
  1. Calvares

    Calvares

    Joined:
    Jul 11, 2018
    Posts:
    17
    So I was reading documentation, watching some examples on Youtube on how to set up IAPs, but I still don't understand how to save a Non-consumable purchase. Should I do that myself manually? If so, what's the best way of doing it for Google Play and Appstore?
    Thanks in advance.
     
  2. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,171
    You could save purchases locally on the device, or not. Let me explain several approaches for this:
    - use PlayerPrefs (not secure, but you could encrypt them)
    - use a cloud save provider (for example PlayFab, which includes receipt validation and a login system)

    Or do not save it at all: you can access the product.hasReceipt property of Unity IAP after initialization. If it returns true, the product was purchased before and you can e.g. set a bool on your game manager script for accessing it and unlocking your game content now or later.
     
    alecfilios and Calvares like this.
  3. Calvares

    Calvares

    Joined:
    Jul 11, 2018
    Posts:
    17
    Thanks!
     
  4. alecfilios

    alecfilios

    Joined:
    May 21, 2019
    Posts:
    8
    What if there are IAPs but also Items that can be bought with Currency inside the game? How do I save those skins fo instance?
    Also how do I keep the coins the player has?

    I prefer to avoid Player Prefs
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    That would be up to you. You might prototype it with PlayerPrefs and swap it out for something more secure if you choose at a later time. Baroni's post would still apply https://forum.unity.com/threads/how-to-save-a-purchase.1156388/#post-7420100 . I will go ahead and close this thread now, saving other than IAPs is going off topic.
     
Thread Status:
Not open for further replies.