ConfirmPendingPurchase doesn't seem to always work

Hi,

we’re using the Unity IAP system currently at version 2.1.1. We verify the purchases with the server, perform de-duplication there, etc.

We’re running into an issue where the UnityIAP system will report a certain Google Play transaction. After the server confirms the purchase (even in the case of a duplicate it confirms the purchase again), the client then calls ConfirmPendingPurchase. This works most of the time, but for some purchases they will be re-discovered every single time the application is started. So far, I have not found a way to “get rid” of those purchases, but ConfirmPendingPurchase definitely doesn’t seem to work.

One particular thing I’ve noticed is that the Unity IAP subsystem itself will print this in the log for one of the problematic transactions:

11-02 15:51:57.497 I/Unity ( 900): Already recorded transaction GPA.XXXX-XXXX-XXXX-37949

11-02 15:51:57.497 I/Unity ( 900): UnityEngine.Purchasing.PurchasingManager:ProcessPurchaseIfNew(Product)

11-02 15:51:57.497 I/Unity ( 900): UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)

11-02 15:51:57.497 I/Unity ( 900): UnityEngine.Purchasing.JSONStore:OnProductsRetrieved(String)

11-02 15:51:57.497 I/Unity ( 900): System.Action:Invoke()

11-02 15:51:57.497 I/Unity ( 900): UnityEngine.Purchasing.Extension.UnityUtil:Update()

It actually prints this log 4 times.

The code path is:

  • We call FetchAdditionalProducts to get all products
  • If one of the products has the transactionid field set, we will send this to the server to get verified
  • Once verification is completed, we call ConfirmPendingPurchase

The other code path is similar but triggers the verification through the ProcessPurchase callback.

This seems to have worked well, but we recently upgraded Unity IAPs to 2.1 and since then we’ve been seeing this issue.

Are we doing anything wrong here? Is there a way to tell if a product with a transactionid is confirmed/unconfirmed?

PS: We need the FetchAdditionalProducts code path as ProcessPurchase isn’t called reliably for some recoveries and purchases that didn’t go through correctly the first time around.

We are looking into this issue. It seems related to receiving receipts during initialization for products that haven’t been loaded yet via FetchAdditionalProducts. I will try to keep this thread updated. In the meantime, you might want to avoid using FetchAdditionalProducts if possible and load all products up front.

Thanks for the quick reply! In our case, we can’t really avoid FetchAdditionalProducts as we’re pushing down additional product IDs from the server and dynamically update the list.

1 Like

Hi!

I can confirm that I’m seeing a similar issue on our end.
The purchase recovers properly, but when trying to purchase the same (consumable) product again, the user gets a DuplicateTransaction error.
We do call ConfirmPendingPurchase at the same time as giving the rewards.

Are you using FetchAdditionalProducts?

Yes we are getting the product list from our server. We have different calls to fetch different shops (coins, energy, offers, etc). So we might register some products much later in the app lifecycle.

Also note we are on Unity 2019.4.12f1 LTS.

It appears that we may have issues when using FetchAdditionalProducts. In particular, when we receive a receipt during IAP initialization for a product that has not been loaded yet. We are looking into this, and hope to address the issue soon.

Hi Jeff!

I’ve ran a couple of tests and I can confirm that initializing all my products on UnityPurchasing.Initialize works.

However, this is not a viable option for us as our architecture relies on loading new products at various points in the game.

Do you have an ETA for when a fix could be provided?

Sorry no ETA but given the high priority, I would expect within a few weeks.

Any workarounds? Like being able to tell if this purchase/transaction has already been processed from the request.

This is affecting real users, right now, so we’re thinking about adding our own client-local de-duplication.

No work arounds that we are aware of.

@Volcore From our testing, recovery seems to work if you call Initialize UnityIAP with the products you’d like to recover.
So on our end, we will try to fetch the list of pending products from our server, then initialize UnityIAP with those products.
If this works properly, it will be our workaround until Unity fixes this issue.