Pfap
Member
I'm setting up a consumable iap and when I tap to add 36 to my currency it is adding 144. I am currently testing with 1 product.
I made 2 scripts called product_bought() and product_consumed() which I will post below the code used in my async object.
Here the relevant code is:
init_purchases script:
This is the async iap event:
This is the create event code (the stuff I'm using to debug) for the object that has my iap async event
This is the draw event:
And here are the 2 aforementioned scripts.
product_bought script:
product_consumed script:
The above must be firing 4 times.
And finally here is the tap event of the button I am using to get the purchase event to fire:
To sum up everything works, except that it gives out 144 instead of 36...
And when drawing my debug variables to the screen (purchase_fires and consumes), the purchase_fires variable is showing 1 as expected, but the consumes variable is showing 2. Which, would make me think thst if anything it should be returning 72 of the currency and not 144.
But, if the iap_ev_purchase is only firing once and the iap_consume() is only firing once why is the map position of global.save_purchases[? "amount"] displaying 144 more than its starting value?
I am testing on an iPhone 6 through testflight if that is needed information.
I made 2 scripts called product_bought() and product_consumed() which I will post below the code used in my async object.
Here the relevant code is:
init_purchases script:
Code:
if os_type == os_ios{
var purchaseList = ds_list_create();
var product1 = ds_map_create();
ds_map_add(product1, "id", "currency_pack_ios");
ds_list_add(purchaseList, product1);
iap_activate(purchaseList);
ds_map_destroy(product1);
ds_list_destroy(purchaseList);
}
This is the async iap event:
Code:
var type = iap_data[? "type"];
// the load check will run on game start if iap are activated
if type == iap_ev_storeload{
if (iap_data[? "status"] == iap_storeload_ok){
global.store_available = true;
}
else{
global.store_available = false;
}
}
// check for a purchase below. Will fire on game start if the item was not consumed.
if type == iap_ev_purchase{
var index = iap_data[? "index"];
var temp = ds_map_create();
iap_purchase_details(index,temp);
// give the user their product
if ds_map_find_value(temp, "status") == iap_purchased{
var product_id = ds_map_find_value(temp, "product");
// figure out which item is triggering this purchase
product_bought(product_id);
purchase_fires += 1;// used to debug
}
ds_map_destroy(temp);
}
// consume items
if type == iap_ev_consume{
consumes += 1;// used to debug
var product_id = ds_map_find_value(iap_data, "product");
// figure out which item is triggering this purchase
product_consumed(product_id);
}
This is the create event code (the stuff I'm using to debug) for the object that has my iap async event
Code:
purchase_fires = 0;
consumes = 0;
Code:
draw_text(10,332,string(purchase_fires));// showed 1
draw_text(10,364,string(consumes));// showed 2
And here are the 2 aforementioned scripts.
product_bought script:
Code:
if os_type == os_ios{
if product_id == "currency_pack_ios"{
iap_consume(product_id);
}
}
product_consumed script:
Code:
if os_type == os_ios{
if product_id == "currency_pack_ios"{
global.save_purchases[? "amount"] += 36;
ds_map_secure_save(global.save_purchases, "iap.json");
}
}
And finally here is the tap event of the button I am using to get the purchase event to fire:
Code:
iap_acquire("currency_pack_ios", "");
To sum up everything works, except that it gives out 144 instead of 36...
And when drawing my debug variables to the screen (purchase_fires and consumes), the purchase_fires variable is showing 1 as expected, but the consumes variable is showing 2. Which, would make me think thst if anything it should be returning 72 of the currency and not 144.
But, if the iap_ev_purchase is only firing once and the iap_consume() is only firing once why is the map position of global.save_purchases[? "amount"] displaying 144 more than its starting value?
I am testing on an iPhone 6 through testflight if that is needed information.