First announced in the keynote for Unite 2015, Unity is planning to add their own in-app purchase API in Unity 5.3, integrated into the Analytics service. As an Asset Store developer supporting external billing plugins, this is highly interesting for me.
I couldn’t find it in the list of initial (preview) features though. Is this something to expect at a later beta stage?
Any news on docs? I can’t even seem to figure out how to properly initialize billing.
var builder = ConfigurationBuilder.Instance( --- what is going on here!? ---);
builder.AddProduct("100_gold_coins", ProductType.Consumable);
UnityPurchasing.Initialize(this, builder);
Have you enabled IAP in the services window? See attached image, there was a problem that was preventing this step for which a fix was recently rolled out.
You then need to import our store implementations by hitting the ‘import’ button in the attached image. If you have any trouble with that, import the unitypackage directly.
You’re on the right track with your code. Here’s an example initialisation with a single consumable product with a bunch of different identifiers on different platforms:
var module = StandardPurchasingModule.Instance();
var builder = ConfigurationBuilder.Instance(module);
builder.AddProduct("100.coins", ProductType.Consumable, new IDs {
{"com.outlinegames.100goldcoins.v2.c", GooglePlay.Name, AmazonApps.Name},
{"com.outlinegames.100goldcoins.6", AppleAppStore.Name},
{"com.outlinegames.100goldcoins.mac", MacAppStore.Name},
{"com.outlinegames.100goldcoins.win8", WinRT.Name}
});
// Now we're ready to initialize.
UnityPurchasing.Initialize(this, builder);
@Banderous@markychoi
Thanks to both of you! This definitely helps and the scripting reference included is enough to figure out the rest. It all makes sense with the ProductDefinition and meta data, btw - great design work on that.
Is there a reason for not having all platforms as an enum? When building an editor window for creating IAPs, I would like this to be more dynamic rather than hardcoding platform names with their scripts such as GooglePlay.Name, AmazonApps.Name etc.
and have the IDs array created dynamically too in a separate method and just pass that in.
IDs productIds = new IDs();
for (int i = 0; i < localIds.Length; i++)
productIds.Add(localIds[i], ((PlatformType)i).ToString());
builder.AddProduct(globalId, productType, productIds);
The reason there’s no enum is because Unity IAP is plugin based; there is no definitive list of supported stores. You could install another module supporting further stores each with their own name.
If you want to dynamically gather a list of stores you can instantiate the StandardPurchasingModule and call it’s Process method yourself, but you’re probably best off creating your own enum.
I wish Unity 5.3 IAP could also support Samsung Android IAP. This is basic. Unibill supports it. Please add this and the build in IAP system will be complete.
“Windows Universal Apps” is actually misnomer that we recently recognized is causing some confusion. We’re updating the copy to read “Windows Store” to more accurately describe that IAP will support transactions for any apps sold through the store (including Windows Phone apps and desktop apps).
I might be missing something, but i cant get to the Unity Manual in b4. If i click it in the help menu nothing happens… Where can i find the documentation for IAP?
P.S. Your example for IAP has an “OnDeferred” method, but it’s never registered with IAppleExtensions.
Did you install the documentation? If you installed only the Editor download (not the Download Assistant) then documentation is missing. Documentation is it’s own modular install now. The Download Assistant allows for full options.
@ You are right, I did not install the documentation, I tried downloading it now, but the download link on the beta page seems to be broken (503 server error).
I believe it was just a clash of Class names. I already deleted Unibill because it has been deprecated from the Asset Store, which is what prompted me to implement the new Unity IAP instead.
@sschan Could we also request for some information in the documentation about how receipt validation could be implemented with the Purchasing module?