Search Unity

[Closed] How to use CrossPlatformValidator: ProcessPurchase()?

Discussion in 'Unity IAP' started by LandonC, Jul 13, 2018.

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

    LandonC

    Joined:
    Dec 20, 2012
    Posts:
    83
    Hello all! I'm building an android game and I'm trying to validate in app purchase receipts from google play.
    I have a couple of questions regarding this, please do help if you can answer them.

    https://docs.unity3d.com/Manual/UnityIAPValidatingReceipts.html

    When attempting this, I encountered this problem.

    1. After obfuscating, I got two new scripts as mentioned in the docs. However, in the script below, GooglePlayTangle is marked red in monodevelop and when my mouse hovered on top of it, it displayed that "it does not exist in current context". Surprisingly, there was no error thrown in Unity Editor.

    Code (CSharp):
    1. var validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.identifier);
    2.  

    Also, since validation is done inside of ProcessPurchase(), will there be any issues running this at Start() to check if player has made purchases? Or is there another function I am not aware of for this particular use?
     
  2. LandonC

    LandonC

    Joined:
    Dec 20, 2012
    Posts:
    83
    I just read this:

    On platforms that support it (e.g. Google Play and Universal Windows Applications) Unity IAP automatically restores any products the user owns during the first initialization following reinstallation; the ProcessPurchase method of your IStoreListener will be called for each owned item.

    Docs: https://docs.unity3d.com/Manual/UnityIAPRestoringTransactions.html

    What if the user had refunded the non-consumable product, and the app was not reinstalled?
    Is this check done every time initialization is done? or only when the app is reinstalled?

    If I would like to check every time the app starts, is m_StoreController.products.WithID(productID).hasReceipt reliable to do this job? I've read else where that this method may cause problems.:confused:
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @LandonC I would need to check this. Are you able to valid receipts during the normal ProcessPurchase flow?
     
  4. LandonC

    LandonC

    Joined:
    Dec 20, 2012
    Posts:
    83
    Hi! Thanks for replying! I'm still testing at the moment, the "it does not exist in current context" error I mentioned above has disappeared once I restarted my computer. Strange.

    I found a related question here, however it does not seemed to point to a solid solution.

    Anyway, I'm still going to test hasReceipt for my next test since there is no other suggestion.
     
Thread Status:
Not open for further replies.