Unity IAP Docs

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?

1 Like

Docs being worked on…

4 Likes

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);

1 Like

And to answer the original question of documentation, it should be available as part of the Unity Manual that ships with the next beta Unity 5.3.0b2.

1 Like

@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.

With an enum, I could create products like this:

string[] localIds = ...

builder.AddProduct(globalId, productType, new IDs {
           {localIds[0], ((PlatformType)0).ToString()},
           {localIds[1], ((PlatformType)1).ToString()},
           {localIds[2], ((PlatformType)2).ToString()},
           {localIds[3], ((PlatformType)3).ToString()}
   });
  • 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.

FYI, updated the preview post with a link to an IAP doc

1 Like

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.

Thanks for your feedback @giorgos_gs . Adding support for Samsung in our IAP implementation is on our roadmap. Stay tuned for more details.

When you say IAP will support Windows Universal Apps, do you mean also apps not universal but solo Windows Phone 8.1 or Windows Store apps?

“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.

Hi @mihakinova - Here is documentation for IAP. I’ll look into why it’s not showing up in the b4 Unity Manual.

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.

The nomenclature conflicts with unibill … means iap is an integration of unibill ¿?

@Banderous ??

Thanks for the documentation @sschan !

@ 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?

For iOS, there is a Display name and a Reference name for In-App Purchases.

Which one do we use to connect the product to the App store?