Microsoft Store IAP Initialisation Exception

Apologies, think I mislead with my post. If you look at my original post the IAP.Init is called then I yield until it’s initialised (waiting 2 seconds each time). In this case, the init fails, but does not raise a failed event, so just keeps retrying indefinitely.

The purchase happens from within the app (well after init) so not relevant here. Apologies for misleading.

Well that’s a shame if true, I’d based my entire beta programme around the basis of a private audience. I didn’t feel that was something that even needed questioning in terms of Unity support. Surely it should make no difference? If you could please confirm if that’s the case as I will need to go away and re-think my entire strategy.

I searched through the forum btw and found many instances of others having the same issue…

IL2CPP seems to be a theme here, maybe that’s a factor?

The third thread also mentions this…

For any unfortunate soul struggling to get UWP initialization working and stumbling on this thread… As was suggested previously here, there really is a delay of 24-48 hours after finalizing submission and seeing “In the Store” on the dev center dashboard before IAP initialization works. That was our experience anyhow.

Are there any plans to improve support for the Microsoft Store? I see Unity saying they support it, but too many people posting issues and\or abandoning it for an alternate solution.

One other thing…

If using a private audience is the issue, is it possible to use public audience (available but not discoverable)?

That would probably be an acceptable alternative.

Although support for private audiences would be the preferable long term fix.

HI @PeachyPixels

The mock config code you showed looks good, just make sure it’s set before initializing IAP. You mentioned In-Editor? Do you mean in Play-In-Editor? Mock UWP billing only works in UWP builds, not in the Editor. I don’t believe there’s any way to emulate UWP In-Editor.

Or am I misunderstanding? Please correct me if I am.

Regarding the CrossPlatformValidator, just make sure not to create it on Non-Google, Non-Apple platforms until we release the next version. You can temporarily copy the #if guards from the Tangle files in the meantime and wrap your calls in them, or you can manually remove them from your Tangle files. The new version will essentially do the latter.

The continuous polling during initialization has been reported previously, as you mention. We added additional logging as mentioned here Unity IAP package 4.12.2 is now available page-2#post-6256032 and In-app purchases and trials - Microsoft Store | Microsoft Learn

Apologies John, tiredness induced typo. Was late here and had been a long day :slight_smile: Meant to say local build. Stripping out irrelevant stuff, my code is as follows…

protected override IEnumerator DoInitialise()
{
  ConfigurationBuilder builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
  DoAddProducts(builder);
#if IAP_MOCKSTORE_ENABLED
  DoEnableMockStore(builder);
#endif
  UnityPurchasing.Initialize(this, builder);
  // Yield until init here...
}

And it’s been working fine for months, hence the frustration when it’s live and doesn’t work even though I was sure it was setup correctly.

Hi Jeff,

As per my original post, mine isn’t a continuous poll. Rather it throws a single generic System.Exception and fails to call the init failed event as a result.

The link you sent states “UWP - Additional logging during initialization to diagnose developer portal misconfigurations” but I see no such logging in the log. Just the generic exception. That was IAP 2.0.X and I’m using 3.0.X so is this a regression?

Are you able to confirm 100% if it’s the private audience that’s causing the issue please?

What about if it’s a public audience (visibility) but still hidden \ stop acquisition? (discoverability, see attachment)

I only ask as the screenshots from the Unity Windows IAP Configuration link are very outdated now and don’t cover discoverability.

Sorry I’m not certain on the audience type, I was hoping it might be an easy test for you. We are discussing internally on the best path forward, we may need to update IAP with the latest Windows Store namespace in a future release. But unfortunately we don’t have an immediate answer for you.

Ok, thanks Jeff. If you could keep me updated on any news that would be much appreciated.

In the meantime, I’ll tweak the discoverability and visibility settings on the add-ons and app and let you know the outcome.

Jeff, just to clarify the above link you sent…

Does Unity uses the Windows.ApplicationModel.Store namespace (as opposed to Windows.Services.Store)?

So I’m using my product id (com...) as opposed to the 12 character store generated id (ABC123DEF456GHI) when calling builder.AddProduct()?

You would want to follow these instructions https://docs.unity3d.com/Manual/UnityIAPWindowsConfiguration.html

Hi @PeachyPixels ,

Try reversing your call order here. There’s some strange internal esoterics in the WindowsStore’s internal factory. It seems once it’s been made with Mock, or non-mock it’s locked and not changeable. I think adding products does this (setting it up as non-mock and locking that).

Please try this and see if it works…

#if IAP_MOCKSTORE_ENABLED
  DoEnableMockStore(builder);
#endif
DoAddProducts(builder);

Please try with the Sample IAP Project as-is with no coroutines to remove any possible threading issues also.

Thanks John.

Tbh the mock store code (in that order) has been working just fine for a long time now, but I will happily switch it around if you think it’s a better approach.

But coroutines aren’t threads, or do you mean in the literal sense?

I have it all working now (so init in a coroutine must be ok) but it’s late again and I need to switch off :slight_smile: I’ll report back tomorrow with the findings.

Thanks for the help again today!

I was suggesting that you try the code we are familiar with so we are on the same page, we’ve seen some timing issues with the store APIs. If you can reproduce with common code, then the more likely we can do the same and hopefully identify and address the issue.

Hi Jeff,

Before I post my findings\resolution, I’m seeing something that I would be grateful if you could clarify please.

So I was testing the add-on purchase and after purchasing it in-game (then re-opening the game) I’m noticing the following in the log (some of it is mine, others Unity)…

Setup IAP manager
IAP platform supported [True]
IAP manager initialising
UnityIAPWin8:Begin PollForProducts() persistent = True, delay = 0, productsOnly = False
UnityIAPWin8:Building full product list with existing purchases
UnityIAPWin8:Fake transactionID: Set transactionMap[] = -12345678
Unity IAP version [3.0.1]
IAP manager initialised
IAP product retrieved [ProductId=, StoreId=, ProductType=NonConsumable, ProductEnabled=True, ProductAvailable=True, TransactionId=-12345678]
IAP product retrieved [ProductId=, StoreId=, ProductType=NonConsumable, ProductEnabled=True, ProductAvailable=True, TransactionId=Unknown]
IAP product retrieved [ProductId=, StoreId=, ProductType=NonConsumable, ProductEnabled=True, ProductAvailable=True, TransactionId=Unknown]
IAP processing purchase [ProductId=]

Firstly, the reference to fake is interesting. This is neither (obviously) using the mock store or a ‘fake’ purchase.

Secondly, the use of a negative transaction id seems strange (that’s obviously not the real number)

Thirdly, I’m not issuing a restore transaction post IAP init. So it’s either the Unity or Windows API’s doing that. Is that correct behaviour?

Happy to take this to another thread if you would prefer.

Are you enabling the mock store?

As I said, not using the mock store. This was a master build from the MS store with the mock store disabled.

1 Like

Yeah, missed that, sorry. We are looking into our current UWP support for IAP, no immediate suggestions unfortunately

So I uninstalled the app and re-installed to see what would happen.

The first run logs were the same as above, but a second run now shows this now…

UnityIAP Version: 3.0.1
UnityIAPWin8:Begin PollForProducts() persistent = True, delay = 0, productsOnly = False
UnityIAPWin8:Building full product list with existing purchases
UnityIAPWin8:Fake transactionID: Set transactionMap[] = -12345678
Unity IAP version [3.0.1]
Already recorded transaction -12345678
Fulfilling transaction -12345678
ProductID
UnityIAPWin8:Consuming:
UnityIAPWin8:Exception consuming : Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). (non-fatal)

Everything ‘appears’ to be working as expected, no visual errors and the product is restored on first run. I found this thread that has some similarity and that was two years ago…

There are just too many kinks with Unity’s Windows implementation of IAP. It really doesn’t inspire confidence.

I know it’s not your fault, but I wish Unity would take Windows seriously. They say they support it yet I’ve just hit one issue or limitation after the other.

I’ve wasted an entire week trying to get Unity IAP running (on the MS store) when it’s been running (on the mock store) fine for months now.

Maybe you could suggest to the powers to be that they look at improving the existing implementation first please?

I know you say an upgrade is in the works (moving to the newer MS API hopefully) but that’s realistically a long way off. So why not improve what’s there in the meantime.

Sorry just incredibly frustrated. It looks like I’ll have to release the game on Windows with underlying errors and strangeness and just hope it doesn’t turn into a support nightmare.