How to use GUI for IAP

I can not seem to find an answer, anywhere for this, so i will make my question as detailed as possible.

I have a game in Google Play, already launched. In my game i use GUI in every scene, i do not use normal UI. I am new to learning about IAP in Unity and i have been through a lot of documentation from Unity and other sources. I want to know the process of how to do this through GUI.

Example: If i were to make a currency (in C#, int || float) and then make a button in GUI.

.

//Code

public static int Gems = 0;

void OnGUI(){

if (GUI.button(new rect(1, 1, 1, 1), “Purchase 50 Gems”)){

//What would i add here to activate the IAP?? so the user can then purchase the Gems?^^

}

}

I hope this makes sense to people and thank you to any one who tries to help.

Hi,

Unity IAP isn’t only about code, there are a few things to setup, the code is quite simple.

Here’s a 1 to the “code less IAP” documentation.

It’ll take you through the whole process.

Note it doesn’t use OnGUI, but rather use Unity UI features.

!!FOUND THE ANSWER MY SELF!!! For anyone who is having the same issue, here is a link to explain all the code easily. And will show how to activate it from anywhere in script. In-App Purchase (IAP) - Unity 3D[Tutorial][C#] - YouTube