Unity IAP 4.4.1 : I need help error IstoreController.ConfirmPendingPurchase(product)

Hello, I have updated the IAP version from 2.2.2 → 4.4.1 to Google Payments Library this time. After that, an error was found in the code syntax below.

I am a non-Codeless IAP method that receives products with a script,
As a result of various tests, it was confirmed that in the 2.x.x and 3.x.x versions, Transaction ID was received as a null value, but no error appeared.

And through Google’s internal test, it was confirmed that the payment attempt was normal.

But I still don’t know why I’m getting that error.

I would like to get help.

 public void ReleaseAllUnfinishedUnityIAPTransactions()
    {
        Debug.Log("--------------ReleaseAllUnfinishedUnityIAPTransactions------------");
       
        foreach(string prodjctid in sProductids)
        {  
            Product p = storeController.products.WithID(prodjctid);

            if (p != null)
            {
                [COLOR=#ff4d4d]storeController.ConfirmPendingPurchase(p);[/COLOR]
                Debug.LogWarning("product Name : " +p.definition + "Transaction Id" +p.transactionID);
            }
        }
       
    }

Hello @Fixinc ,

Looking at the implementation, the Google Play API requires a valid transaction ID in order to complete the transaction via ConfirmPendingPurchase.

When do you call your function, exactly? Normally the StoreController will assign the transaction id to it’s product within products once the purchase is successful, or the set of previous purchases are fetched.

This may be a timing issue. Do you wait until you receive your ProcessPurchase call from your IStoreListener? Or is this on Initialization? If you have set SetFetchPurchasesAtInitialize(false) in your GooglePlayConfiguration, old purchases won’t be retrieved and transaction IDs will be null, you need to call RestoreTransactions from your GooglePlayStoreExtenstions to update them.

First, Thanks for your help.
This function is executed after adding the product after initializing the IAP when the game is running. So, I checked that the product list (number) was properly imported.

In fact, I’m not familiar with it, but I’m not sure exactly what the ConfirmPendingPurchase function does, even looking at the Unity Docs.

If so, should this function be called after purchasing the product?

In some cases, Unity IAP may call ConfirmPendingPurchase by default, but what this does is send an acknowledgement or consume signal to stores like GooglePlay so they can stop reporting these purchases as new ones to be fulfilled.

If you need to do security checks or receipt validation on the purchase before awarding the payout to the player, we suggest doing so before calling ConfirmPendingPurchase.

Thank you for answer.
As a result of rechecking our in-app payment script logic
In OnInitialized() function
I checked calling the ConfirmPendingPurchase() function, and found that the order was wrong.
We found that we don’t need to use ConfirmPendingPurchase() because we currently use PurchaseProcessingResult.complete after receipt verification in the product purchase process.

After the build, we confirmed that the payment works normally as a result of Google’s internal test.