Search Unity

[FEATURE REQUEST] Differentiate between new purchases and restored purchases

Discussion in 'Unity IAP' started by josephsaade, May 29, 2019.

  1. josephsaade

    josephsaade

    Joined:
    Apr 18, 2016
    Posts:
    41
    In the current implementation, any IAP goes to the IStoreListener function ProcessPurchase
    .
    There is no differentiation being made between a new purchase and a restored purchase.
    So if we send any analytics to a 3rd party platform, non-consumable purchases are being reported twice as the 2nd time happens when the IAP is restored.

    In our naive solution, we tried to set a flag when the user clicks on an IAP button so we know that this IAP is actually being purchased and not restored.

    But this fails, as on iOS, if the user clicks on the button, he can be prompted by Unity to "restore" that purchase for free and we as developers do not have any knowledge or callback that this IAP has been restored and is not a new one.

    Please advise.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,180
    Restore on iOS is a separate method, and requires a separate button click.
     
  3. josephsaade

    josephsaade

    Joined:
    Apr 18, 2016
    Posts:
    41
    Hi Jeff, I am not sure that you have understood my issue.

    iOS Restore is a separate method and I agree, but there is a specific scenario:
    - User does not click on "Restore" button on iOS
    - User clicks on non-consumable IAP that he has previously purchased.
    - Unity IAP prompts the user that a restore will happen and if he wants the item for free, Unity IAP sends me a call to process the purchase but I do not have any way of knowing that this purchase has been restored and is not a new purchase.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,180
    A user should not be able to click on a Non-Consumable button if they have already purchased it. Your UI should not allow this in the first place as the product should already be available for them. How are you tracking and locally persisting user purchases? PlayPrefs is one way.
     
  5. josephsaade

    josephsaade

    Joined:
    Apr 18, 2016
    Posts:
    41

    On iOS, if a player removes and re-installs the game, we do not know that he already purchased the non-consumable until he clicks on "Restore Purchases". So if he clicks on the non-consumable before clicking on "Restore Purchases" after a new install, the above scenario triggers.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,180
    You would want to track purchases using persistent storage, or in the cloud. This is a feature we are considering adding, but no time frame
     
  7. josephsaade

    josephsaade

    Joined:
    Apr 18, 2016
    Posts:
    41
    Currently the Unity IAP is prompting the user that this is a free purchase, It would be great if they send us (as developers) that info too so we can manage it internally.
     
  8. technobayo

    technobayo

    Joined:
    Apr 8, 2017
    Posts:
    7
    Hi @josephsaade ,

    I have a similar situation and here's how I'm handling it. In my case, a user is first authenticated before making any purchase. When the 'Buy' button is pressed, I call a method to check my database if the user already has the item. If the user has the item in the database then I simply prompt the user to use the 'Restore' button. This way, I bypass Apple's prompt.
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,180
    That is not a good solution. You should not be presenting a Buy button to the user if they can't actually make a purchase. Please see my previous post. You are correct, PlayerPrefs can be removed during reinstall, that is why many studios opt for saving purchases to the cloud. If they already made a purchase, then don't enable the Buy button in the first place. Don't wait for them to click it.