In App Purchases

This section deals with setting up in app purchases for your game.

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

NOTE: This functionality is limited to the Professional Version of GameMaker: Studio, and only those versions that have the Mac, iOS, or Android target modules. For Android you will have to have downloaded and installed the Google Play Services extension along with the Google Play In App Purchases extension from the YoYo Games Marketplace. Once you have added the extensions to the project you can go to the Android Global Game options and select the Social tab, then check the appropriate check-boxes.

Getting Started

Setting up in app purchases within your game is relatively simple with GameMaker: Studio, 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 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 in app purchases are enabled in the Global Game Settings before they will be functional in your game (more information can be found on the page Global Game Settings - In App Purchases Tab). You will also need to 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 identifies each product and purchase.

To help those of you that have never worked with any type if IAP services and to explain the different ways that IAP can be tested on different devices, please see the following pages:

  1. IAP Example
  2. IAP Testing

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

WARNING: You will not be able to make purchases when debugging titles using the GameMaker IDE. Instead you will need to create final executables to ensure the title can correctly communicate with the respective store servers.

GameMaker: Studio Functions

Below are listed the functions that are integrated in GameMaker: Studio to enable in app purchases on iOS and Android target devices (this is the ability to buy extra credits, items, levels and other things from within the game itself). Many of these functions will trigger an asynchronous IAP Event, which contains a special ds_map with an initial key "type". This can then be queried to get the type of IAP event that has been triggered, which will then permit you to get further data from the map.

The available in app purchase functions are:

  1. iap_activate
  2. iap_status
  3. iap_enumerate_products
  4. iap_restore_all
  5. iap_acquire
  6. iap_consume
  7. iap_product_details
  8. iap_purchase_details
  9. iap_is_purchased

You should also be aware that GameMaker: Studio 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:

  1. ds_map_secure_save
  2. ds_map_secure_load

GameMaker: Studio 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 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().

Deprecated Functions

With the update to version 1.3, the In App Purchasing routines were made more secure and also simplified somewhat, meaning that some functions have been made obsolete and will no longer do anything. These functions are listed below for reference only and should not be used. Any games created with these that you wish to update on a store will need to be re-written using the newer system.

  1. iap_store_status
  2. iap_event_queue
  3. iap_product_status
  4. iap_is_downloaded
  5. iap_product_files
  6. iap_files_purchased


Back: Reference
© Copyright YoYo Games Ltd. 2018 All Rights Reserved