InAppPurchaser -> error CS1520: Method must have a return type

This is the code from thsi thread

    using UnityEngine;
    using UnityEngine.Purchasing;
    using UnityEngine.Purchasing.Security;
    
    /// <summary>
    /// This class is primarly taken from Unity's example:
    /// https://learn.unity.com/tutorial/unity-iap#5c7f8528edbc2a002053b46e
    /// </summary>
    public class InAppPurchaser : IStoreListener
    {
        public static string FullGameID = "com.redbluegames.sparklite";
    
        private IStoreController controller;
        private IExtensionProvider extensions;
    
        public event System.Action GamePurchased;
    
        public InAppPurchaser()
        {
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
            builder.AddProduct(FullGameID, ProductType.NonConsumable);
    
            Debug.Log("UnityIAP: Initializing.");
            UnityPurchasing.Initialize(this, builder);
        }
    
        public void UnlockTheGame()
        {
            BuyProductID(FullGameID);
        }
    
        /// <summary>
        /// Called when Unity IAP is ready to make purchases.
        /// </summary>
        public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            Debug.Log("UnityIAP: Initialized");
            this.controller = controller;
            this.extensions = extensions;
    
            this.UnlockPreviousPurchase();
        }
    
        /// <summary>
        /// Called when Unity IAP encounters an unrecoverable initialization error.
        ///
        /// Note that this will not be called if Internet is unavailable; Unity IAP
        /// will attempt initialization until it becomes available.
        /// </summary>
        public void OnInitializeFailed(InitializationFailureReason error)
        {
            Debug.Log("UnityIAP: Initialize FAILED");
        }
    
        /// <summary>
        /// Called when a purchase completes.
        ///
        /// May be called at any time after OnInitialized().
        /// </summary>
        public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
        {
            VerifyAndUnlockPurchaseForReceipt(e.purchasedProduct.receipt);
    
            Debug.Log(string.Format("UnityIAP: ProcessPurchase: PASS. Product: '{0}'", e.purchasedProduct.definition.id));
            return PurchaseProcessingResult.Complete;
        }
    
        private void UnlockPreviousPurchase()
        {
            Debug.Log("UnityIAP: Unlocking Any Previous Purchases");
            var product = this.controller.products.WithID(FullGameID);
            if (product.availableToPurchase && product.hasReceipt)
            {
                VerifyAndUnlockPurchaseForReceipt(product.receipt);
            }
        }
    
        private bool VerifyAndUnlockPurchaseForReceipt(string receipt)
        {
            bool validPurchase = true;
    
    #if UNITY_ANDROID
            Debug.Log("UnityIAP: Validating Receipt: " + receipt);
            // Prepare the validator with the secrets we prepared in the Editor
            // obfuscation window.
            var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
                AppleTangle.Data(), Application.identifier);
    
            try
            {
                var result = validator.Validate(receipt);
    
                Debug.Log("UnityIAP: Receipt is valid. Contents:");
                foreach (IPurchaseReceipt productReceipt in result)
                {
                    Debug.Log(productReceipt.productID);
                    Debug.Log(productReceipt.purchaseDate);
                    Debug.Log(productReceipt.transactionID);
                }
            }
            catch (IAPSecurityException)
            {
                Debug.Log("UnityIAP: Invalid receipt, not unlocking content");
                validPurchase = false;
    
    #if UNITY_EDITOR
                Debug.Log("UnityIAP: Just kidding, we call invalid receipts in Editor valid because Editor throws IAPSecurityException.");
                validPurchase = true;
    #endif
            }
    #endif
    
            if (validPurchase)
            {
                Debug.Log("UnityIAP: This was a valid purchase. Unlocking content based on purchase.");
                ApplicationManager.Instance.SetFullGameUnlocked(true);
                GamePurchased?.Invoke();
            }
    
            return validPurchase;
        }
    
        /// <summary>
        /// Called when a purchase fails.
        /// </summary>
        public void OnPurchaseFailed(Product i, PurchaseFailureReason p)
        {
            Debug.Log(string.Format("UnityIAP: ProcessPurchase: FAIL. Product: '{0}', Reason: {1}", i.definition.id, p));
        }
    
        private void BuyProductID(string productId)
        {
            if (IsInitialized())
            {
                Product product = controller.products.WithID(productId);
    
                if (product != null && product.availableToPurchase)
                {
                    Debug.Log(string.Format("UnityIAP: Purchasing product asychronously: '{0}'", product.definition.id));
    
                    // Async purchase call
                    controller.InitiatePurchase(product);
                }
                else
                {
                    Debug.Log("UnityIAP: BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
                }
            }
            else
            {
                Debug.Log("UnityIAP: BuyProductID FAIL. Not initialized.");
            }
        }
    
        private bool IsInitialized()
        {
            return controller != null && extensions != null;
        }
    }

I have managed to add my sha in validator and i have GooglePlayTangle and the AppleTangle

But now, i got this error “error CS1520: Method must have a return type”

public InAppPurchaser()
        {
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
            builder.AddProduct(FullGameID, ProductType.NonConsumable);

            Debug.Log("UnityIAP: Initializing.");
            UnityPurchasing.Initialize(this, builder);
        }

So, what should return this method? should i call from start()?

You haven’t defined any return type for this method, this is not related to IAP. It’s up to you to define the return type. Look at the other methods you have, and notice yours is different. It probably should be:

public void InAppPurchaser();

But more importantly, it looks like you haven’t got the basics of IAP working, yet you are adding custom code. I would suggest you get the basics working first, perhaps start with the Sample IAP Project here https://discussions.unity.com/t/700293/4

using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
// Static instance of the Game Manager,
// can be access from anywhere
public static GameManager instance = null;
// Player score
public int score = 0;
// High score
public int highScore = 0;
// Level, starting in level 1
public int currentLevel = 1;
// Highest level available in the game
public int highestLevel = 2;
// Called when the object is initialized
public Awake()
{
{
// Destroy the current object, so there is just one manager
Destroy(gameObject);
}
// Don’t destroy this object when loading scenes
DontDestroyOnLoad(gameObject);
}
}

Assets\Scripts\GameManager.cs(22,12): error CS1520: Method must have a return type
what should i do?

Learn to use code tags, learn not to necro an old thread, learn to read the documentation, and just like above, the error is right, you need to have a return type. The error tells you the line, it tells you where it decided the error was - now sometimes its wrong when it comes to braces, or something to do with unterminated strings, but in this sort of case… no its right.