This event can only be triggered when you have activated In App Purchases for your game. If you have this functionality added, then the event will be triggered under the following circumstances:
- The store state changes.
- A product (or products) have been activated.
- The product and purchases have been restored.
- A product has been purchased.
- A product has been consumed.
The event will always create a special ds_map
with an index ID stored in the built in variable
iap_data. This map will always contain the
key "type", which will hold one of the following constant
values:
Constant | Description |
---|---|
iap_ev_storeload | This is triggered when a change is detected in the target platform store. |
iap_ev_product | This event is triggered when a product is activated and will contain additional information about the product. |
iap_ev_restore | This event is only triggered when you use the iap_restore_all function. |
iap_ev_purchase | When a purchase has been completed, this event is triggered. |
iap_ev_consume | When you use the function iap_consume it triggers this event. |
Each of these possible event "types" will add extra keys to the
iap_data ds_map, which can then be parsed to get the
purchase or product information necessary. The exact contents of
the iap_data map are listed below for each event
"type".
When you activate your purchases, your game will try to contact
the target store, triggering this event in the process. The
iap_data map will then have an addition key
"status", which will have one of the following constants as
it's value:
Constant | Description |
---|---|
iap_storeload_ok | The store has been contacted and the connection is good. |
iap_storeload_failed | There has been a connection error or for some reason the store is unavailable. |
All activated purchases will trigger this event "type", but only
once per purchase, so if you have activated ten products you should
expect this event to trigger ten times. If you have received this
event, the iap_data ds_map will hold the additional key
"index" which holds the unique product ID string for
the product being activated. You can then use the function
iap_product_details along with this product ID to get
further information.
NOTE: Google Play (Android) can only request details for
products 20 at a time which can lead to quite long load times for
applications with a significant number of products.
When you call the function
iap_restore_all it will trigger this event, adding a
"result" key to the iap_data ds_map. This key will
hold either true or false to indicate whether the
purchase data has been successfully restored from the target
store.
On requesting a purchase using the function iap_acquire
this event type will be triggered. The iap_data ds_map
will have the additional key "index" which holds the unique
purchase ID value for the product being purchased. You can
then use the function
iap_purchase_details along with this purchase ID to
get further information.
NOTE: If the product purchased is consumable then it
must be used using iap_consume before a further
purchase can be made.
When using the function iap_consume
this event type will be triggered. The iap_data ds_map
will have the additional key "product" which holds the
unique product ID string for the product being consumed.
NOTE: The iap_data ds_map created for the in app
purchase event is only valid in this event and should not be
accessed anywhere else in your game.