Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

IAP Validation

Discussion in 'Unity IAP' started by KreizLand, Apr 7, 2019.

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

    KreizLand

    Joined:
    Jul 12, 2017
    Posts:
    57
    This part of code:
    var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
    AppleTangle.Data(), Application.bundleIdentifier);

    Throw me this:
    The type or namespace name 'CrossPlatformValidator' could not be found (are you missing a using directive or an assembly reference?)
    The name 'GooglePlayTangle' does not exist in the current context
    The name 'AppleTangle' does not exist in the current context
    'Application' does not contain a definition for 'bundleIdentifier'

    Shall i use any specific libraries (except using UnityEngine.Purchasing)?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    using UnityEngine.Purchasing.Security;

    //Unity IAP's validation logic is only included on these platforms.

    #if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX

    var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
    AppleTangle.Data(), Application.identifier);

    You create the Tangle files from Window/Unity IAP/Receipt Obfuscation Validator. More information here:

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

    KreizLand

    Joined:
    Jul 12, 2017
    Posts:
    57
    Unity 2018.3.7f1. After adding - using UnityEngine.Purchasing.Security; Still have this errors when compiling script with this code:
    #if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX
    var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
    AppleTangle.Data(), Application.bundleIdentifier);
    #endif
    Errors:
    The name 'GooglePlayTangle' does not exist in the current context
    The name 'AppleTangle' does not exist in the current context
    'Application' does not contain a definition for 'bundleIdentifier'
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Did you create the tangle files?
     
  5. KreizLand

    KreizLand

    Joined:
    Jul 12, 2017
    Posts:
    57
    I missed this step (thought it was enought that i put my Google API key into Services-IAP-Options). Now 1 error with Application.bundleIdentifier:
    'Application' does not contain a definition for 'bundleIdentifier'
    I can replace it with Application.identifier: No errors since now but does it returns the same thing?
    I also can replace it with UnityEditor.PlayerSettings.applicationIdentifier will it work on Android or IOS? (I`m scared oif this "UnityEditor")
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    As always, Google is your friend. "unity iap Application does not contain a definition for bundleIdentifier"
     
  7. KreizLand

    KreizLand

    Joined:
    Jul 12, 2017
    Posts:
    57
    Ok I found that Application.bundleidentifier returns package name (that probably previously was called "bundle identifier") so now I`m using Application.identifier that returns it (or we can use UnityEditor.PlayerSettings.applicationIdentifier - same result in debug logs: com.company.prodname)
     
  8. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    If I understood correctly, the Public Key we have to add is just like a password/code to encrypt/decrypt right? we can set there whatever we want?

    ¿Any advice on how to generate a safe one?

    Thanks in advance
     
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    For a new topic, please open a new thread. Ensure to state which key you are referring to .
     
Thread Status:
Not open for further replies.