case iap_ev_purchase:
var product = iap_data[? "index"];
var map = ds_map_create();
iap_purchase_details(product, map);
switch (map[? "status"])
{
case iap_failed:
if (global.analytics==true && global.purchase_pathfinder==true && string(map[? "payload"])=="iwillalwaysloveyou")
{
ga_addDesignEvent("Monetization:IAP:Failed:"+string(map[? "product"]));
global.purchase_pathfinder=false;
}
if (script_exists(global.purchase_fail_script)){script_execute(global.purchase_fail_script,string(map[? "product"]))};
break;
case iap_purchased:
if (global.analytics==true && global.purchase_pathfinder==true && string(map[? "payload"])=="iwillalwaysloveyou")
{
var currency,price,type;
currency = purchase_get_currency();
price = global.pmap[? string(product)+"_price"];
type = string_copy(argument[i],1,2);
if (type=="du")
{
ga_addBusinessEvent(currency, price, "Durable IAP", string(map[? "product"]), "Menu", "", "");
ga_addDesignEvent("Monetization:IAP:Purchased:"+string(map[? "product"]));
}
else
{
ga_addBusinessEvent(currency, price, "Consumable IAP", string(map[? "product"]), "Menu", "", "");
ga_addDesignEvent("Monetization:IAP:Purchased:"+string(map[? "product"]));
}
show_debug_message("Purchase Happened. Currency : "+string(currency)+" - Price : "+string(price)+" Type : "+string(type));
global.purchase_pathfinder=false;
}
ds_map_set(global.pmap,string(map[? "product"]),true);
ds_map_secure_save(global.pmap,"pdata.json");
if (script_exists(global.purchase_success_script)){script_execute(global.purchase_success_script,string(map[? "product"]))};
break;
case iap_canceled:
if (global.analytics==true && global.purchase_pathfinder==true && string(map[? "payload"])=="iwillalwaysloveyou")
{
ga_addDesignEvent("Monetization:IAP:Cancelled:"+string(map[? "product"]));
global.purchase_pathfinder=false;
}
if (script_exists(global.purchase_cancel_script)){script_execute(global.purchase_cancel_script,string(map[? "product"]))};
break;
}
ds_map_destroy(map);
break;
}