Hello Unity Team and Community,
I’m currently maintaining a project using code-based IAP (not codeless). During our upgrade testing from Unity IAP 4.12 to 5.0.0pre5, we discovered several changes that appear to be breaking or at least significantly disruptive. I would like to share our findings and ask for clarification or guidance regarding these issues:
1. ConfigurationBuilder.Instance
-
Observation:
In Unity IAP 4.12, each call toConfigurationBuilder.Instancereturned a new instance, meaning that previously added products viaAddProductwere not retained. However, in 5.0.0pre5,ConfigurationBuilder.Instancenow returns a singleton instance. As a result, products registered during a previous initialization persist. If we subsequently callAddProductwith the same product, we encounter a “Same key” error fromProductDetailConverter::ConvertOnQueryProductDetailsResponse. -
Current Workaround:
Using the new public constructor introduced in 5.0.0 (instead of theInstancemethod) effectively clears the previous state. However, we’re unsure if this approach is the intended usage, and it took considerable time to diagnose the root cause. -
Request:
Could you please clarify if this singleton behavior is intentional? We believe that avoiding a singleton—so that each initialization starts with a clean slate—might be more robust, especially for scenarios where a product list needs to be refreshed.
2. UnityPurchasing.Initialize and IStoreController.FetchAdditionalProducts
-
Observation:
BothUnityPurchasing.InitializeandIStoreController.FetchAdditionalProductsinternally utilize methods such asProductService::AddProductsUpdateActionandAddProductsFetchFailedAction. However, since the delegates are passed as new instances each time, the corresponding event removal using “-=” does not work as intended. Consequently, each call to these methods accumulates event handlers, which leads to unintended callbacks and eventually system instability. -
Issue:
There is no public method provided to clear or reset these event handlers (i.e., forOnProductsUpdatedandOnProductsFetchFailed), forcing developers to modify the IAP code directly to prevent cascading issues. -
Request:
We would appreciate it if the design could be revisited to either allow clearing of these events or be reset them internally by Unity IAP.
3. FetchProductsUseCase::m_ActiveRequest
-
Observation:
The memberm_ActiveRequestis used to indicate whether a product fetch is still in progress. WithinOnProductRetrieved, the methodProcessRetrievedProductsAndInvokeCallbacksis called first, and only afterward ism_ActiveRequestset tonull. This means that ifInvokeSuccessis called insideProcessRetrievedProductsAndInvokeCallbacks—and that callback, in turn, triggers anotherFetchProductscall—it will be treated as if the previous fetch is still active, resulting in an error. -
Note:
This error did not occur in version 4.12 and can be easily overlooked, which makes it particularly concerning. -
Request:
We ask that this logic be reviewed to ensure that successive fetch calls can be handled gracefully without false-positive errors regarding an active request.