 So it's finally time to see how we can earn some money. In this video we are going to see how we can use Google building plugin a first-party plugin and loot locker to see how we can allow players to purchase our assets. So for instance I'm going to use the mobile because this only works on the play store at the moment and I'm going to purchase an asset. Let's see this areas one here this areas cloth golden cloth and Google will ask me to confirm the purchase I will confirm the purchase Google will confirm the purchase and the inventory will update and there we have it so let's test this out yeah everything is working so let's get started so in this video we are going to approach it as if we are targeting Android platforms okay so something that I have to say beforehand is that we are not going through all the process of setting up a game in the play store using the google play services no we're not going to that because this will go way beyond the scope of this video but let me know in the comments if you guys would like a course a whole a complete course a crash course about how you can develop and implement a all the features that we need to implement in order to have a complete game a mobile game that we are going to publish on play store so it will have advertising it will have purchase and billing services we are going to use a loot locker the google play services plugin the google billing services plugin as well and everything that we need to make some money with mobile games let me know in the comments if this is of your interest but let's go back to the video so the first thing that we need to do in order to hook loot locker to the google billing platform to the google play store platform is to get a service api private key so how we can do that I have here the loot locker dashboard but we have to go to the api access uh on our play store console and we can find that on the setup api access we have to find the services the service accounts and we can view this in google cloud platform with the services accounts available we can click on the first one or whatever service account want to to work with click on the email or create a new one and you go to keys add a new key create new key and we generate a json file okay and then we can go back to our loot locker dashboard and then we go to the settings and we have your platform the platforms option here we are going to select the android platform we have the steam enable as well so if you have a steam publisher publisher key you can pass it right here as well but we are going to android and we can paste the content of the json file that we created on the google uh the google console platform you paste the content right here on this service account field and of course you add the package name on this field as well enable the android platform and save this so everything is hooked up uh the next thing that we need to do is to take the google play store uh asset id and link it in the loot locker asset id as well so how we can do that we go to content the content option we select the asset and let's see this iris sand here edit and then we remember that i think that on the assets video we have this platform properties option right so we click on that and right below here we have google play store properties so we paste the the product id here and you can find this product id on the google play store console then we have here products in app products and when you will create a new product you have to add an app in app a product id so you just copy this or in this case the iris one so it's this one you just have to copy this into the loot locker api into the loot locker asset console so you have to paste it on this field here then you can save it and with that we have everything set up everything ready so you can use good enough to hook loot locker with the game with the play store api okay so let's see how all these three things work together so to actually file a purchase request it's quite simple with the loot locker api the most troublesome part is actually setting up everything on the google play services console this is the most troublesome part but after this is ready the call the loot locker call is very simple we just have to make a post call to this url with the content type that we already using the accession token as well and with the the content of the request with the request body being a dictionary actually an array of dictionaries that has a key an asset id that is the asset id that we are requesting the loot locker to to unlock for our player and a purchase token key that has a purchase token supplied by google play store how do we obtain that how do we get this token godot engine has a first part plugin so this is maintained through the the very godot develops themselves and this is the google the godot google play billing plugin and this is what he used to actually file the billing uh procedures so that the player can confirm that they are trying to to purchase an asset and google will call make some calls on the play services platform so that they will build the play they will send the billing for the player and once everything is ready so you can see that we have all of these instructions here showing us how we can configure and setting and set up this plugin on our product the most important part is here purchase an item we have to make a call to this method the purchase method with my in app item this is a stream that actually uses the play store id as the the value right so there is not there is no documentation for that but this is the the play store asset id that we just add to the loot locker platform and another very important part of this process is actually acknowledge the purchase this is what will make google actually build the player and see if they have enough money to pay for this asset etc and if everything goes well we'll get a signal that will tell us that the purchase went okay it will retrieve us with the token and we will use this token on the loot locker api call that we just saw to so loot locker will take everything and unlock this asset on the player inventory seems complex but let's see this in work on grud engine so here we are on the skin selection screen and i have here the skin shop which have the the google play billing uh node this can be a singleton but i decided that since i only needed here i is just a simple node let's open this so i can show you how this works so i have a signal that is the purchase token retrieved so when everything goes well when everything is done correctly if the player has bad has the credit to purchase the asset the final thing the thing that we are trying to to reach with everything that i'm going to show is this the token so when everything goes well and if everything works we are going to retrieve a token and admit it to the the skin shop school container that i'm going to show you later following all the instructions that we have on the documentation i connected some signals to some methods here but the important part is this method this is a custom method that i created which takes the play store id it asks for the network state label to show the purchasing animation and then it query for the details of this play store id so this is one of the most important parts because before any purchase we have to query for the sql details okay so we use the the play store id here and we have to say that it is an in-app purchase this can be a consumable or this can be a recurring payment service so a subscription and we yield for this payment which is the singleton that we try to retrieve here so if the engine gets singleton a good old google play billing is uh if we have the singleton uh this payment variable becomes a pointer to that single we yield for it to finish gathering the the sql details and then we ask for the payment singleton to make to start the purchase the purchase process the first thing that we do when the when we have the connection when the the singleton emits the connected signal is that we carry for the purchase for purchases right so if the player already has some already has some purchase we want to prevent it from trying to purchase it again because remember the play store asks for it demands us that we do that so what why not do it uh right at the beginning right i have some other signals but basically these are just uh error handling the the second most important part here is that we have just this unpurchase updated which has some purchase here that once we carry for some purchase it will try to update this and we'll omit the signal here so for every purchase in purchases we acknowledge this purchase and this is the most important part because when we when we have let me fold this as well because this is not very important but when we actually acknowledge the purchase is when we are going to retrieve to get the token that we want this is the nugget that we want from all this process so we have this token here which is the purchase token that we are going to retrieve from the the purchase singleton and then we omit a signal a signal telling that the purchase token was retrieved and we send the the token with that and then we change the the network to state label to purchase acknowledge this is how we actually retrieve the token that we want now that we have that going to the skin shop screw container let's see what goes a bit before this is how all this process uh begins so when the player remember that we have this this asset this skin buttons right that they have some uh verbals one of them uh two of them are the asset idea and the play store idea if you are not aware of what i'm talking about you can see the assets and inventory uh videos of this series and then we go to this google billing which is what we just saw this note the google billing note and we call this custom method that i just uh talking about that receives as an argument the play store id then we yield for the google billing purchase token retrieved signal which is the one that we just saw and we access the first key of the first index of this signal as the token value and then we we start the actual purchase part on the loot locker side of all of this relationship here and for that we pass the asset id and this is the asset id that we have on loot locker and not on the play store okay so these are different ideas here we pass the loot locker id and the token that we just retrieved from all the google billing procedures so the purses part goes here we have the url that we saw on the api on the locker api the header with the accession token the method method post the request data which is basically a dictionary with the asset id and the purses token that we just gathered so we make the the request then we yield for the response we get the response body but we actually don't even need that but in any way we emit the signal this asset pushes signal which sends a signal to the skin selection screen that tells the inventory to clear all the current skins that it has and load the the new ones so this is an update on the inventory and that's how it goes sounds a bit complex because it is i had quite a time trying to set this up but if everything goes well this is what is going to happen i will put some footage of the purses process uh in the screen right now and with that we wrap up this series guys thank you so much i want to thank the loot locker uh guys for reaching me out for making this series for them uh it's a very very powerful uh apis they they have like we just saw i think that six services but they have i think that more than 20 services available for all types of features that we want on wood player online games so definitely check this out uh i really hope you enjoy it thank you so much for watching keep developing and until next time don't forget to leave the comments below if you want the if you want a course about how you can make uh how you can monetize mobile casual games okay so that's it thank you so much for watching keep developing and until next time