Hello, in my app after a purchase, I set the purchase’s state to pending and when my server verifies it, then I ConfirmPendingPurchase and end the transaction. However, after relaunch I don’t add this product to the builder to pass it into the UnityPurchasing.Initialize and therefore the ProcessPurchase function of the Unity doesn’t get called. Shouldn’t unity receive the pending transactions even though I don’t initialize UnityPurchasing with the pending product, is this a GooglePlay restriction. Because I was planning to add new products after the initialization with FetchAdditionalProducts but if these newly added products’ purchases become pending then the transaction won’t be closed because I don’t add the products on initialization.
I am targeting for both iOS and android but I only tested this on android.
Using Unity 2020.3.12f1
IAP version 4.0.3
Google Play Billing Library 3.0.3
Please see the release notes for 4.1.0, I believe you’ll be able to call IGooglePlayExtensions.RestorePurchases(Action) after you FetchAdditionalProducts and have the product in the controller. This should properly trigger the ProcessPurchase for this pending product. Is there a specific reason you aren’t initializing with all products up front? It’s certainly valid to not do so, but doing so is a quick solution.
Thank you for your response Jeff.
The game might not have the product on relaunch. Depending on time, ab testing group the game might get a different product from server at runtime so if it is stuck at pending, at relaunch game won’t get the correct product that’s why it won’t be able to call FetchAdditionalProducts with the correct product to close the transaction. I don’t want to initialize all the products at launch because I get all the items from my server and package size might be too big. Would 4.1.0 solve this problem?
If a user purchases a product, you need to have it available for them. I’m not quite sure I understand. As mentioned, call the method mentioned to trigger the ProcessPurchase after you’ve added the product to the controller after you call FetchAdditionalProducts
My bad Jeff, let me simplify, I’ve attached a picture.
Imagine the step 6 has failed and the product is in the pending state. Then the app is closed, client doesn’t know what product it purchased anymore. Then the app is restarted but the pending product is not available on the client to pass it to neither UnityPurchasing.Initialize nor FetchAdditionalProducts. Because client retrieves it from my server in a very specific time. So can unitysdk call process purchase on its own without client having the productid available. Client doesn’t know what product is in pending nor my server will say which one. Can we complete the transaction in this conditions?
@inquisitor5 You will want to call FetchAdditionalProducts, that will allow you to add the product to the controller later, after initialization. Get the productID from your server when needed, then call FetchAdditionalProducts. Otherwise, front load all your products. Only those two approaches are supported. The client is required to know about a product before ProcessPurchase is triggered. Is this an actual issue you are trying to solve? Or something you “think” may happen. In your case, just load all products up front. Your products are defined on your store dashboard, not on your server. Your server may “store” them, but does not “define” them. Is IAP working for you in general? Again, I’m not quite following your scenario, sorry.
