Claim Pending Purchase on Runtime

Hello, I am having a problem when my IAP has a pending purchase. When I attempt to buy item again, it gives me DuplicateTransaction. I already tried to call ConfirmPendingPurchase, it shows the log that the product is claimed but I can not receive the item and the purchase state is still pending. Is there a way to claim pending purchase in runtime?

After IAP is initialized, you can process pending products in ProcessPurchase, there is no other way to claim pending purchase at runtime.

Is this a consumable product or a non-consumable product?

In addition, could you debug the product ID in ProcessPurchase to see if the product you ConfirmPendingPurchase is the corresponding product?

public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
    {
        Debug.Log("product ID: " + e.purchasedProduct.definition.id);
        ......
    }

Thank you.

I got that problem on consumable item and do not check it for non-consumable yet.

@SamOYUnity3D I have more question, I try to accept pending purchase that occurs in the previous version of my app.

Here’s how I test it

  1. Create a pending purchase in the app v.1
  2. Uninstall the app v.1 and install the app v.2

but I can not get the pending purchase. In my app, I save pending purchase in PlayerPrefs and load it again when init the IAP. I check my Pending Purchase cache after install the new version but it seems the data is gone.

Is there a way I can claim pending purchase in my previous app?

Are you testing it on IOS or Android platform?

I am testing on Android.

After reinstalling the test app on my Android device, I can see previous pending purchases in ProcessPurchase. Are you installing your app on the Google Play Store or directly? Are there any changes other than reinstalling the app? Such as version or package name.

I install it directly not from google play. I change the version of the app.

This can happen if you install the app directly instead of from Google Play, please try installing from Google Play.

I will try to upload it first and install it from Google Play. Thank you

Are you returning Pending from ProcessPurchase?

Yes, I return Pending from ProcessPurchase.

Do I need to make DuplicatePurchase before I can claim pending purchase?

I try to make a pending purchase, by disabling a hotspot and my device connect to my office wifi. When I restart the app I do not get the item I purchase. but when I try to purchase again after my device connects with the internet it will return DuplicatePurchase and when I restart the app I can get the item.

For a Pending transaction, you would want to call ConfirmPendingTransaction on the first purchase. Why are you returning Pending, if I may ask? https://docs.unity3d.com/2017.2/Documentation/ScriptReference/Purchasing.IStoreController.ConfirmPendingPurchase.html

Sorry, I just check the post. I return pending purchase when the player purchase and there is no internet connection. I will try to call ConfirmPendingTransaction.

You should not allow purchasing when there is no Internet connection