In App Purchases


In App Purchases are an important part of modern, cross platform games, permitting you to have "freemium" content where your game is free, but certain content is only available through a purchase from within the game itself. For example, your puzzle game is free, but the extra levels are going to cost the user 0.99$. This app model is very common and can be set up with a minimum amount of work from within GameMaker Studio 2 , and this section of the manual has details of all the available functions that enable you to do just that, as well as some advice for setting up and information on how to test on the different platforms.

Setting up in app purchases within your game is relatively simple with GameMaker Studio 2, but it still requires some amount of knowledge of the target platform setup as well as careful planning before starting to create your game, so it is not recommended that you use this functionality if you are just starting with GameMaker Studio 2 or if you are not sure how the different stores for each target platform are set up.

Before doing anything else you will have to make sure that you have set up the purchase details on the target store for each platform that you wish to support, taking careful note of each of the Product IDs that you define, as these ID strings are how GameMaker Studio 2 identifies each product and purchase. Most of the stores will require you to have uploaded a base file too, even if the game doesn't have in-app purchases included yet.

NOTE: GameMaker Studio 2 currently permits up to 128 distinct purchase options per title, except if you are using the Amazon Store (for Android) where it is limited to 100.


Below are listed the functions that are integrated in GameMaker Studio 2 to enable in app purchases on the different target platforms (these give the ability to buy extra credits, items, levels and other things from within the game itself). Many of these functions will trigger an IAP Asynchronous Event, which contains a special ds_map called iap_data which will have an initial key "type" that can be queried to get the type of IAP event that has been triggered. Once you know which type of IAP event it is, you can then get further data from the map relevant to the event.

The available in app purchase functions are:


You should also be aware that GameMaker Studio 2 does not persist active purchase state across multiple plays of the game (and thus iap_is_purchased() is unreliable if a store has not successfully loaded). This means that you will have to store this information yourself and retrieve it again on each start-up of your game. You can use the special "secure" save and load functions provided for ds_maps for this purpose:


GameMaker Studio 2 does not persist purchase state across multiple plays of the game because it is not appropriate for us to provide a secure method of verifying whether or not an individual purchase is valid and therefore any automatically stored purchase state would be presumptuous. On most platforms "receipt" data will be available through iap_purchase_details() which users can use to verify a purchase, although Google Play uses "token" data instead.

GameMaker Studio 2 requires the Google Play Public Key for simple local purchase verification and you may check that the "payload" data returned with a purchase result matches that used with the matching call to iap_acquire() (see the section on Packaging in the Android Game Options for more information on the Google Public Key) .

In-app purchases are available for Android, Amazon Fire, iOS and macOS targets, and there are articles available on the YoYo Games helpdesk (and a tutorial for Amazon Fire) to help you get each one set up correctly: