Unity IAP calls PurchaseFailed even though the purchase is success?

I’m using Unity IAP with the version of 2.2.2. I uploaded my game to Play Store in an Alpha track, and I use this code to handle IAP. (I simplified the code a little bit)

    private IStoreController Controller = null;
    private IGooglePlayStoreExtensions PlayStoreExtensions = null;

    public void Initialize()
    {
        StandardPurchasingModule module = StandardPurchasingModule.Instance(AppStore.GooglePlay);
        ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);

        // IAP is a dictionary that has the product IDs
        foreach (var item in Items.Singleton.IAP)
        {
            builder.AddProduct(item.Key, ProductType.Consumable);
        }

        UnityPurchasing.Initialize(this, builder);
    }

    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        Controller = controller;
        PlayStoreExtensions = extensions.GetExtension<IGooglePlayStoreExtensions>();
    }

    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent)
    {
        /** This part is never executed! */

        // ... check the purchase and spawns a popup saying the purchase is success
    }

    public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
    {
        /** This function is called after every purchase even though the purchase is successful (even though I get a valid receipt) */

        // ... show a popup saying the purchase is failed
    }

    public void OnClick_Purchase(in string productID)
    {
        // This function is called to initiate the purcahse. There is no problem in the code. I can see the Play Store purchasing window and buy products without any problem
        Controller.InitiatePurchase(productID);
    }

Unity IAP always calls OnPurchaseFailed method. What am I doing wrong?

Nevermind. This thread can be deleted.

The problem was a mistake on the server side. IAP plugin works.

1 Like