• 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 Questions about the new IAP system - Google Play Billing

Hello everyone good night / day / afternoon !!!

After crying for several days in depression they are asking for help !!!

So as you know google updated several things and the whole system of IAPs was renewed, making me redo everything again in my game that was already ready.


I followed the official yoyogames tutorial and downloaded and checked the .pdfs too

https://help.yoyogames.com/hc/en-us/articles/360031457831-Android-Google-Play-Billing-IAPs-


Only I can't complete the purchase. The time to know if the purchase was successful or canceled by the player. That is, it is currently working perfectly but I can't get the right information to know after the google buy window appears and the purchase is executed in order to give the player the reward. = (



Could someone explain to me or make some tutorial engine showing, because I can configure everything perfectly but only in the end time to give the reward to the player after the purchase is made I'm not getting T_T
 
L

Latahunden

Guest
I'm in a similar position.
I have a game out on the market that I cant update since I cant wrap my head around this new billing system.
If anyone can make a more straight forward tutorial it would be much appreciated.
 
I'm in a similar position.
I have a game out on the market that I cant update since I cant wrap my head around this new billing system.
If anyone can make a more straight forward tutorial it would be much appreciated.



Hello @Latahunden ! Yeah, I couldn't either. >. <

I will show what I did who knows can help you in something.

My idea is to simplify to the maximum, because for my project I just want to make a simple consumable purchase. Player purchase data is being stored on server so in my case much of the tutorial is not for me.


I created an ob_shop_control object that controls the whole store when the player opens it.

CREATE
Code:
GPBilling_Init();
alarm[0]=30;
ALARM 0
Code:
// Prepare some variables for use in the IAP checks
global.IAP_Enabled = false;
global.IAP_PurchaseID[1] = "goldpack_1";
global.IAP_PurchaseID[2] = "goldpack_2";
global.IAP_PurchaseID[3] = "goldpack_3";
global.IAP_PurchaseID[4] = "goldpack_4";
global.IAP_PurchaseID[5] = "goldpack_5";
global.IAP_PurchaseID[6] = "goldpack_6";

// Attempt to connect to the store
var _init = GPBilling_ConnectToStore();
if _init == gpb_error_unknown
    {
    show_debug_message("ERROR - Billing API Has Not Connected!");
    alarm[0] = room_speed * 10;
    }


ASYNC - In-App Purchase
Code:
var _eventId = async_load[? "id"];

switch (_eventId) {

case gpb_store_connect:
  // Store has connected so here you would generally add the products
  global.IAP_Enabled = true;
  GPBilling_AddProduct(global.IAP_PurchaseID[1]);
  GPBilling_AddProduct(global.IAP_PurchaseID[2]);
  GPBilling_AddProduct(global.IAP_PurchaseID[3]);
  GPBilling_AddProduct(global.IAP_PurchaseID[4]);
  GPBilling_AddProduct(global.IAP_PurchaseID[5]);
  GPBilling_AddProduct(global.IAP_PurchaseID[6]);
  // Etc… for all products
  GPBilling_QueryProducts();
  break;
 
  case gpb_store_connect_failed:
  // Store has failed to connect, so try again periodically
  alarm[0] = room_speed * 10;
  break;
}

After that as I understand it, he starts the store and adds all the data of his products that are configured in google play console (remembering that the product id must be the same as registered in google play console)

I created another object called ob_button_purchase, it just calls the purchase that is in alarm[1] of ob_shop_control object when it is created.

ob_button_purchase CREATE
Code:
with(ob_shop_control){alarm[1]=30;}
ob_shop_control alarm 1
Code:
if GPBilling_IsStoreConnected() {
  var _chk = GPBilling_PurchaseProduct(global.IAP_PurchaseID[1]);
 
  if _chk != gpb_no_error  {
    // Canceling purchase 
    instance_destroy();
  }
}


After that, the purchase window of the item I placed on google play appeared right.

After that, I can't proceed, so I can't pay the reward because I don't know if the player has canceled the google window or made the purchase.


I made a trial purchase and all purchase data is recorded perfectly.
 
Top