No Revisions Have Been Made To This Page
Can you suggest an edit for this page? Click Here
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, Android, Windows 8, Windows Phone or Tizen target modules.
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:
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.
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:
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:
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().
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.