• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android IAP Coding Issue (Android)

D

DarkArtJason

Guest
I'm am totally lost with the IAP example when trying to create a IAP code to do just one simple little thing.
I'm not trying to sell things over and over again I just want to offer people an option to open up a certain room after they buy a ticket. Attempting to follow the example and a few other tortillas on IAP my mind is now just overwhelmed. It is most likely something simple I'm overlooking but here is the codes I created>>>

I first started with creating an obj_IAP_initiate’ and add a ‘Create’ event to it>>>
/// IAP initiate

Product_List = ds_list_create();

Green = ds_map_create();
Gold = ds_map_create();
ds_map_add(Green, "id", "myproducti'mselling1");
ds_map_add(Gold, "id", "myproducti'mselling2");
if(os_type == os_winphone){
ds_map_add(Green, "type", "Durable");
ds_map_add(Green, "title", "Field Goal");
ds_map_add(Gold, "type", "Durable");
ds_map_add(Gold, "title", Pass Ticket");
}
ds_list_add(Product_List,Green);
ds_list_add(Product_Gold);
iap_activate(Product_List);
ds_map_destroy(Green);
ds_map_destroy(Gold);
ds_list_destroy(Product_List);


After that I created two Left Pressed buttons and and dragged into each one this code>>>

button 1
iap_acquire("myproducti'mselling1", "");

button 2
iap_acquire("myproducti'mselling2", "");


After that I created an obj_IAP_Handle using the Asynchronous’ and select ‘IAP’. Drag & drop an ‘Execute Code’ and added this code>>>

var val = ds_map_find_value(iap_data, "type");
switch (val){
case iap_ev_purchase:
var map = ds_map_create();
var purchase_id = ds_map_find_value(iap_data, "index");
iap_purchase_details(purchase_id, map);
if (ds_map_find_value(map, "status") == iap_purchased){
var product_id = ds_map_find_value(map, "product");
iap_consume(product_id);
}
ds_map_destroy(map);
break;
case iap_ev_consume:
var product_id = ds_map_find_value(iap_data, "product");
if (ds_map_find_value(iap_data, "consumed")){
// Go To Room Green
if(product_id == "myproducti'mselling1"){
room_goto(rm_Room1);
break;
case iap_ev_consume:
var product_id = ds_map_find_value(iap_data, "product");
if (ds_map_find_value(iap_data, "consumed")){
// Go To Room Gold
if(product_id == "myproducti'mselling2"){
room_goto(rm_Room2);
break;
}
}
}
break;
}
}

I have attempted to go back and reread the example many times and have tried looking into other tutorials to find what code I should be using. Again all I want is to sell people a single ticket. After they buy it they are free to enter a room So I ask,"What am I not doing correctly here?". Without adding the google play services or these codes everything works great. But after adding them and try to create an application I get "UNFORTUNATELY ,(name of game) Has Stopped".
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Okay, you need to have the extension installed and you need to change all the IAP functions to the google specific ones in the extension. The docs will be updated sometime soon to reflect this as they are currently a bit out of date...
 
D

DarkArtJason

Guest
After taking a much needed rest I was able to start working on all this again. Code wise they just need a little tune up. But when it came to the extensions I needed not only the Google Play Services but both Google Play APK Expansion and Google Play Licensing. But another thing that has to be enabled is the BlueTooth in the Globals Settings for Permissions in Android/Fire.
 
Last edited by a moderator:
Okay, you need to have the extension installed and you need to change all the IAP functions to the google specific ones in the extension. The docs will be updated sometime soon to reflect this as they are currently a bit out of date...
When is this going to happen? :)
 
Top