iap_acquire

This requests acquisition of the given product.

Syntax:

iap_acquire(purchase_id, payload);


Argument Description
purchase_id The product ID string for the purchase.
payload This is a string that can be used for purchase verification on Google Play (use an empty string, "", on all other platforms).


Returns: Real


Description

This function is the one that you use to acquire a purchase through the target store for the device running your game. This product ID string is that which you specify when activating the IAP using iap_activate, and should be the same as that which you used to identify the product on the target store. This function will return an value as it's "index" so that it can be identified when the purchase data comes through and calling the function will trigger an IAP Event of the "type" iap_ev_purchase, which will contain the following additional key:

This purchase ID can then be used to check which purchase has triggered the event (comparing it to the returned index value that you stored), so you can deal with it accordingly. If you are developing for Google Play (on the Android target), then you can also set the "Payload" string. This is used by Google to verify the product and is sent along with the purchase request to Google Play. When a purchase is successfully completed the game will receive the payload used as part of the purchase information. By generating a payload with each purchase you can therefore provide a simple form of purchase verification.


Example:

if mouse_check_button_pressed(mb_left)
   {
   iap_acquire("noads", "")
   }

The above code will send a purchase request when the mouse button is pressed.


Back: In App Purchases
Next: iap_consume
© Copyright YoYo Games Ltd. 2018 All Rights Reserved