Enables support for making in app purchases.


GML Code Example


Argument Description
product_index The index of the ds_list that contains the available purchases.

Returns: N/A


This function enables support for making in-app purchases and prepares GameMaker: Studio by supplying the product ds_list that holds a series of ds_maps with the information on each available purchase. This means that you will need to tell GameMaker: Studio all the available purchase options by setting them in individual ds_maps (one for each available purchase), which are then stored within a ds_list, which is then "activated" with this function.

The individual purchase maps that are to be stored in the ds_list should have the following format of key-value pairs:

  • "id" - The product ID for the purchase, eg: "LevelPack".

  • "title" - The name of the purchase, eg: "Level Pack 1".

  • "description" - The description of the purchase, eg: "Level Pack 1 for Catch The Clown".

  • "price" - The price of the purchase, eg: "$1.00".

  • "type" - Windows 8 and Windows Phone only! The type of purchase, which should be either "Consumable" or "Durable". "Durable" is the default value (non-consumable).

It is worth noting that the only essential keys for any target store setup (per product ID) is the "id", except for Windows 8 and Windows Phone targets, in which case you also need the "type" key. Note that for these target platforms, if you want the store to report meaningful (correct) data when in Sandbox mode, then the "title", "description", etc... are necessary.

Activating purchases will also trigger an IAP Event, which creates a special iap_data ds_map of the event type iap_ev_product. This ds_map will have the following additional key:

  • "index" - The product ID for the activated product.

If you are activating multiple products, then each product will trigger its own IAP Event of the type iap_ev_product where you can then get the product ID. It is worth noting that the Google Play store (for Android) can only process details for products 20 at a time which can lead to quite long load times for applications with a significant number of products.

NOTE: All the key/value pairs that comprise a purchase map are strings!


GML Code Example

var purchaseList, purchase1;
 purchaseList = ds_list_create();
 purchase1 = ds_map_create();
 ds_map_add(purchase1, "id", "LevelPack");
 ds_map_add(purchase1, "title", "ExtraLevels1");
 ds_map_add(purchase1, "description", "Level Pack 1 for Catch The Clown");
 ds_map_add(purchase1, "price", "$1.00");
 ds_list_add(purchaseList, purchase1);

The above code will create a ds_list and a ds_map, which is then populated by the information for making a purchase. This map is added to the list and then activated as an available purchase for the game. Finally the ds_list and ds_map are removed to prevent memory leaks as they are no longer needed.

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here