Search Unity

[Solved] GooglePlayTangle.Data() error

Discussion in 'Unity IAP' started by gegagome, Dec 19, 2016.

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

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Would anyone know why GooglePlayTangle.Data() is throwing these errors:

    Assets/Purchaser.cs(258,79): error CS0103: The name `GooglePlayTangle' does not exist in the current context

    Assets/Purchaser.cs(259,58): error CS1502: The best overloaded method match for `UnityEngine.Purchasing.Security.CrossPlatformValidator.CrossPlatformValidator(byte[], byte[], string)' has some invalid arguments

    Assets/Purchaser.cs(259,58): error CS1503: Argument `#1' cannot convert `object' expression to type `byte[]'

    Code (CSharp):
    1.     public PurchaseProcessingResult ReceiptCheck (PurchaseEventArgs e)
    2.     {
    3.         #if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX
    4.         CrossPlatformValidator validator = new CrossPlatformValidator(GooglePlayTangle.Data(), // 258
    5.         AppleTangle.Data(), Application.bundleIdentifier);   // 259
    6.  
    7.         try {
    8.             // On Google Play, result has a single product ID.
    9.             // On Apple stores, receipts contain multiple products.
    10.             var result = validator.Validate(e.purchasedProduct.receipt);
    11.             // For informational purposes, we list the receipt(s)
    12.             Debug.Log("Receipt is valid. Contents:");
    13.             foreach (IPurchaseReceipt productReceipt in result) {
    14.                 Debug.Log(productReceipt.productID);
    15.                 Debug.Log(productReceipt.purchaseDate);
    16.                 Debug.Log(productReceipt.transactionID);
    17.         }
    18.         } catch (IAPSecurityException) {
    19.             Debug.Log("Invalid receipt, not unlocking content");
    20.         }
    21.  
    22.         return PurchaseProcessingResult.Complete;
    23.  
    24.         #endif
    25.     }
     
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
  3. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    This is what I did:
    CrossPlatformValidator validator = new CrossPlatformValidator (null, AppleTangle.Data (), Application.bundleIdentifier);

    But I doubt this would work for Android. For now I need iOS IAP but very soon I will need Google Play IAP so I don't know what to do.


    Thanks
     
  4. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @gegagome

    The first parameter shouldn't be `null`. It should have the `GooglePlayTangle.Data()`. The process for obfuscating your keys is described in the Manual. For Google, you will need your API key from the Google Play Developer Console.

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

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    @ap-unity

    When I added GooglePlayTangle.Data() back in I got that parameter highlighted in fuchsia and the following error in the contextual hover in monodevelop:
    error CS0103: The name GooglePlayTangle does not exist in the current context.

    But when I run the editor no error is shown and was able to build successfully.

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

    Attached Files:

Thread Status:
Not open for further replies.