Hello, I’ve met some problems with implementing subscription in unity (google) shop.
When there is just subscription added and no ordinary products (consumable or non-consumable) - it doesn’t initialize ( StoreController). Coming up with an error:
" OnInitializeFailed NoProductsAvailable".
If I add one non-consumable product it initializes and works successfully, ( StoreController initializes also). And clicking the buy button openes the google shop dialogue where i can buy this item as a tester.
I add subscription the same way as I do with the ordinary products:
builder.AddProduct(subscriptionProductId, ProductType.Subscription);
I copy ProductID directly from code to the console.
In Google Console I added subscription in the corresponding section. It show “active” just near the item.
I attach both logs. With only subscription added it fires OnInitializeFailed. If I add one non-consumable product - It initializes the shop (but still doesn’t buy the subscription).
Am i right, that products being added via configuration builder are compared with products in google play console? And if it can not find corresponding products - it fires “OnInitializeFailed”?
It looks like something is wrong with subscription. Though there are not much to do with it in google. Product ID is
“com.digitalempire.koalasrevenge.sub”. And it shows “Active” near subscription in Google console. Are there any other setting that can affect the process?
The first logs say Unavailable Product com.digitalempire.koalasrevenge.sub but I don’t see any products in the second log. Are you testing via Closed testing on Google, and have created a (second) Google account and added them as a tester? For IAP, you need to accept the tester invite and download the app from Google Play the first time. Subsequently you can side-load directly via USB. And yes, if IAP can’t find any available products or there is a productID misspelling, it will not initialize. You might want to compare to the Sample IAP Project here and publish it as a second test project https://discussions.unity.com/t/700293/4 and https://docs.unity3d.com/Packages/com.unity.purchasing@4.4/manual/UnityIAPGoogleConfiguration.html
I use internal testing. ( Consumable and non-consumable products work fine. - Are subscriptions blocked in internal testing? )
Yes, I use second google account, it is in the testers. I used the link to “accept the invitation in testing”.
With ordinary products (again) it works fine - google identificate him as a tester with tester card. And I can buy it.
I passed through sample project, and even made another project with working shop based on it. That’s why I don’t think issue is there ( if subscriptions managed as ordinary products). I can share my code.
Do not use internal testing, use Closed testing. Remove your internal test. No need to share your code which you claim is not working. Instead, you would want to review the Sample code which is known to work.
Thanks for the logs. It looks like there’s a nullpointer in your product metadata, either in its isoCurrencyCode or its localized price. Since this is a public interface, you can probably debug the object within your product. Do you display these in your UI?
Normally these fields are populated when your product is fetched from the GooglePlay store, which happens on initialization. Are you adding these products after initializing your UnityPurchasing object? Or are they perhaps not defined in your local catalog definitions?
You can try calling FetchAdditionalProducts with any missing definitions added after you initialize IAP.
Can you please explain what you mean by this? Is the subscription your only product that is configured like this?
Do you mean to debug log product metadata after UnityPurchasing.Initialize?
I add products via ConfigurationBuilder.Instance and then initialize Unity Purchasing.
Actually my code is just code of example (attached to Unity in-app-purchasing) with some customization.
What is local catalog definition? - I use scripting, not iAP button. Should I add something to subscription besides product ID?
I’ll read about it, thanks for the link.
First I checked all countries so the prices were in local currencies. As far as error reported some problems with converter - I made a new subscription with just one country checked and price is in USD. But the error is still the same.
Yes I did mean debug log product metadata after UnityPurchasing.Initialize, or after FetchAdditionalProducts (whichever gets your subscription).
So, if I understand correctly, you have the problem with subscriptions regardless if you only set one country’s currency or many?
Also, yes it’s fine if you only use scripting for your catalog information. You are not obliged to use the Catalog Editor. As for the product id alone being sufficient, there are several versions of ConfigurationBuilder.AddProduct. If you need special overrided store IDs for Google, Apple, etc, or are leveraging our Payout system, then use another version of the function, as needed. It’s up to your needs. See our API here: Class ConfigurationBuilder | In App Purchasing | 4.4.1
In the meantime I will go take a look at the Analytics package code and see if there is a bug in their currency converter, and if so, report it.
I did logging in OnInitialized method through all items. First item is consumable - and metadata is Ok. Second item is - subscription and metadata is wrong (and also on 2022.09.14 18:26:07.825 it marked as an unavailable product).
While logging subscription - it falls from “try” to “catch” on this line: item.metadata.GetGoogleProductMetadata().introductoryPrice
For now i don’t understand - what can be the reason of such behaviour. Is it some Google restrictions which make product unavailable? Or is it code issue?
This time I used internal testing to speed up the things, but i had same errors in closed testing. ( It took over a week to pass the closed testing for this tiny game). Nevertheless I plan to release it there anyway.
As to why your product is unavailable, or you not getting the metadata, either it’s a new product that hasn’t been pushed to your app yet (This could take a few days to become available if you just added it and published your app), or there is an mismatch between the store specific ID for the product on Google Play with that of your ProductID. Is this only happening on Google and is working on iOS or some other store?
You can try using the AddProduct where you can pass Store-Specific IDs for each store and make sure it matches GooglePlay’s. Also note these IDs are case-sensitive. Check your Google Play Store dashboard for your app to be sure you’re using the exact same string with no typos.
I’ve made a new app, took unity samples which comes with the in-app purchases. I added 2 consumable products in google console and they were available in 5 minutes.
I use copy+paste for this, but of course, i checked it for 10 times, and i’ve been doublechecked by collegues.
It only happens with google shop, for now it is the only shop we use.
I used both: codeless and scriptable way, adding subscription in builder or fetch it OnInitialized. Every time consumable products give me test window to buy it, while subscription can not be found.
If I recall correctly Apple takes longer to approve subscriptions, specifically. This is because they are the ones managing renewal and expiry, but we recall Google being much faster and being available sooner, so I doubt it is this because it’s been some time already.
Either way it’s very odd…
I see in your logs that you have a price of zero #MyLog metadata price: 0 || definition com.companyname.gamename.sub3 || available to purchase: False || type: Subscription </color></size>. It could be that Google will not honor a price of zero if this is what you set, or perhaps they send 0 if it’s unavailable.
Possible issues:
Do you have the subscription deactivated on your google dashboard?
Is it available in “All Regions”?
Are you in the region with a valid price set that matches the currency useable in that region?
Is your region’s price set to 0 USD?
As for adding Store Specific IDs (although at this point I am convince this isn’t your problem, but posting anyway):
Here’s a code sample:
var ids = new IDs();
ids.Add("com.unity.iap.test.triple.damage.google", new string[] { GooglePlay.Name });
builder.AddProduct("com.unity.iap.test.triple.damage", ProductType.Subscription, ids);
I set a price of 1 USD, because zero is likely to be wrong value for the price. So it is what happens when i try to get metadata from the subscription product ( unavailable at all or being initialized with error).
yes
[quote=“John_Corbett, post:16, topic: 892212, username:John_Corbett”]
Are you in the region with a valid price set that matches the currency useable in that region?
[/quote] Most likely “yes”. It should be 1 USD. It is totally ok with the consumable purchases - i can buy them for 1 USD.
[quote=“John_Corbett, post:16, topic: 892212, username:John_Corbett”]
Do you have the subscription deactivated on your google dashboard?
[/quote] Subsriptions are “activated” in their preferences. Are there any place in Google Console when all them can be deactivated??
Thank you for code example. I try it tomorrow or on monday.
A bugfix for that TransactionFailed event NullReferenceException is going to be released with IAP 4.5.1 soon. I don’t have a release date yet, but keep an eye on the forums for an announcement.
As to why your subscription isn’t enabled, I am still unsure, as your problem seems unique and I don’t have enough information. Do you see your subscription as Active in the list?