Unity IAP initializes Google Play store to early?

I’m getting the full Logcat of warnings as soon as I call ConfigurationBuilder.Instance(module): Unity IAP: Unable to process purchase with order id: <order_id> and purchase token: <purchase_token> because the product details associated with the purchased products were not found.

It isn’t surprising that is this point IAP can’t find product details, as I yet to have to call UnityPurchasing.Initialize.

I am adding products manually in code.

Unity: 2021.3.21f1
Unity IAP: 4.7.0

Hi amjaliks,

Thanks for sharing the details of your issue.

Can you check that the product that is being referenced in the error message is configured and enabled in the store?

I also wonder if this might be a pending, promotional or test purchase that is triggering the process purchase callback on game launch, perhaps causing a race condition if UnityPurchaing isn’t initialized.

Can you provide any further info on the specific purchase or reproduction steps?
If you don’t want to share the details publicly on the forum, please feel free to open a support ticket and one of my colleagues or I will pick it up and see if we can help.

Hi @Laurie-Unity ,

Yes, these products are configured and enabled in the Google Play store.

These purchases has been made from the game, using a Google Play test account. These are not promotional purchases.
These can’t be pending purchases, as Google Play cancels purchases made with a test account in a few minutes, if they are not confirmed (acknowledged). However, I will try add bit more logging to check, if get IStoreListener about these products.
And just to clarify. These warnings appears not on a game launch, but only after I call ConfigurationBuilder.Instance().

All products are non-consumables.
The game has been a lot of time reinstalled or got all data deleted.

Hi Laurie!
I wonder if there’s any update on this warning? I started to get the same one in logs, also on test devices.
Besides this warning everything else looks good: I can validation the receipts, the the purchased items appear to be purchased in my app, and when I refund them they don’t return receipts, so they become locked again as expected.

So, I wonder if we have to worry and do something about this warning, or it’s just some minor glitch we can ignore?

Thanks a lot!

Same warning here, and I think I found the root cause. It still reproduces on
com.unity.purchasing 5.0.2 (Unity 6000.5.7f1), so this has been around for a while.

Root cause

It is not really a race condition in the general sense — it is a hard ordering
requirement that is neither enforced nor documented:

FetchPurchases() silently discards any owned purchase whose product is not
already in the fetched product catalog.

In Runtime/Stores/Android/GooglePlay/AAR/Utils/GooglePurchaseBuilder.cs:

// line 25 — exceptions are swallowed, only a warning is logged
.IgnoreExceptions<IGooglePurchase, ArgumentException>(LogWarningForException).ToList();

// line 35 — purchases are built from the *cached* product details
var cachedProductDetails = m_CachedQueryProductDetailsService.GetCachedQueriedProducts();

// line 48 — thrown when the purchased SKU is not in that cache
throw new ArgumentException($"Unable to process purchase with order id: {orderId} " +
    $"and purchase token: {purchaseToken} because the product details associated " +
    $"with the purchased products were not found.");

So if FetchPurchases() resolves before FetchProducts() has populated the cache,
the purchase is dropped, OnPurchasesFetched still fires as a success with an
incomplete (often empty) list, and OnPurchasesFetchFailed is never called.

Deterministic repro

No timing games needed — just make the catalog unavailable:

await storeController.Connect();
storeController.FetchProducts(products);   // do NOT await / do not wait for OnProductsFetched
storeController.FetchPurchases();          // owned purchases are discarded 100% of the time

The user owns a non-consumable, Google Play returns it, and the app sees
OnPurchasesFetched with 0 confirmed orders.

Why this is worse than a warning

The caller cannot distinguish “the user owns nothing” from “we threw the user’s
purchases away”. Any code that treats the store as the source of truth for
entitlements — which is the recommended pattern for non-consumables — will
happily revoke a paid entitlement.

That is exactly what happened to us: users who had bought our remove-ads
non-consumable had it silently revoked on launch, and re-purchasing returned
DuplicateTransaction, which of course does not grant anything either.

Real device log (Pixel 7a, Android 16)

23:29:11.683 W/Unity: InAppPurchasing: Unable to process purchase with order id:
  GPA.xxxx-xxxx-xxxx-xxxxx and purchase token: xxxx... because the product details
  associated with the purchased products were not found.
23:29:11.689 I/Unity: OnPurchasesFetched: 0 confirmed, 0 pending
23:29:11.695 I/Unity: Products fetched: 2          <-- 6 ms too late

On iOS the catalog happened to arrive 462 ms before the purchases, so the same
code worked there. The arrival order is not guaranteed, which is why this looks
like a flaky, platform-specific bug.

Workaround

Call FetchPurchases() from OnProductsFetched, never right after FetchProducts():

private void OnProductsFetched(List<Product> products)
{
    // ... handle metadata ...
    productsFetched = true;
    storeController.FetchPurchases();   // catalog is guaranteed to be ready here
}

Guard every other FetchPurchases() call site on that flag as well
(restore flows, retry-on-failure paths, etc.).

Suggested fix

Either of these would remove the footgun:

  1. Queue purchase processing until the product details query has completed, or
  2. Surface it through OnPurchasesFetchFailed (or an error in the result) instead
    of a bare LogWarning, so callers can tell “owns nothing” from “fetch was
    incomplete” and avoid revoking entitlements.

The current docs attribute this warning to being offline or to an expired Google
Play cache. The ordering case is far more common and is not mentioned anywhere.

Hi @yuki2006

We have a fix in progress for purchases of un-fetched products being dropped, as this was not the intended behaviour. When fixed, orders should return with Products of type Unknown in these cases.