Search Unity

[Closed] Storing Purchases offline

Discussion in 'Unity IAP' started by Voronoi, Feb 7, 2018.

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

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    590
    There is a closed thread that describes the problem I have run into here. The explanation does not explain where I would make this call:

    Code (CSharp):
    1. ConfigurationBuilder config = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    2. IAppleConfiguration appleStoreConfig = config.Configure<IAppleConfiguration>();
    3. appleStoreConfig.appReceipt; // process
    4.  
    Like the author, I am basing my project on the IAPDemo.cs project. Where should I process the receipt?

    My goal is to build the menu that is normally built online. My app works by having a list of non-consumable buttons in the UI at all times. Purchased buttons 'work', while the other buttons require an in-App purchase before they are converting to a 'working' button. So, a person should be able to see both, but when online be able to buy the buttons they don't already own.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. Voronoi

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    590
    I have gone through the tutorial and I think my question is also about best practices for storing purchases for items. To elaborate, here is a screenshot of what my end goal is:



    The user can buy 3-packs of content, and then use one sword at any given time. I want to combine the list of purchased swords with those available, to make it easy to expand their collection. All of the swords exist in the game but need to be activated by a flag that they have bought the pack.

    Right now, this will work when the user is online by matching item ID's in the IAP Catalog and what I have manually entered on the Apple App Store. The descriptions and titles come from the Apple store, regardless of what I've entered in the IAP Catalog. It's quite inconvenient that the Apple Store does not allow importing the csv export from the Unity IAP Catalog and so I'm trying to figure out a reliable way to populate my scroll view of buttons, offline and online.

    If the user is offline, I get no list at all, so I need to figure out how to populate the scroll view to look like this offline. I can add a note or warning that no purchase can be made until they are back online.

    As far as I can tell both IAP demos assume the user will be online and builds out the lists. So, my questions are about implementing this in the most efficient and secure way possible. I see two options to pursue, which one is better?

    • Create a local json file of purchased items, secured with a hash entry as described in this 2016 Best Practices talk
      -Disadvantage is I need to also store all the descriptions and titles from the App store or IAP Catalog (which may not match)
    • Parse the appReceipt as described above
      -will the receipt include descriptions
      -can I get a list of all products from the appReceipt?
      -is there any encryption advantage using the appReceipt for tracking purchases?
     
    Last edited: Feb 7, 2018
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
Thread Status:
Not open for further replies.