Premium Only Content
![#defold #iap In-App Purchases Walkthrough with Google Play Store](https://1a-1791.com/video/s8/1/-/2/k/u/-2kus.qR4e-small-defold-iap-In-App-Purchases.jpg)
#defold #iap In-App Purchases Walkthrough with Google Play Store
As promised, here is the walkthrough for getting In-App purchases set up for the Google Play Store.
PLEASE NOTE - On my test android phone, the 5 Gems product did work like the previous demo video.
HERE IS THE GUI_SCRIPT FROM THE VIDEO FOR COPYING AND PASTING MINUS THE COMMENTED LINES:
local GEMS_SM = "com.ia.purchases.gem.small"
local GEMS_MD = "com.ia.purchases.gem.medium"
local GEMS_LG = "com.ia.purchases.gem.large"
local function iap_listener(self, transaction, message_id, message, error)
if error == nil then
if transaction.state == iap.TRANS_STATE_PURCHASED then
iap.finish(transaction)
if transaction.ident == GEMS_SM then
msg.post(".", "gems_small")
elseif transaction.ident == GEMS_MD then
msg.post(".", "gems_medium")
elseif transaction.ident == GEMS_LG then
msg.post(".", "gems_large")
end
end
else
gui.set_text(gui.get_node("text"), error.error)
end
end
function init(self)
msg.post(".", "acquire_input_focus")
iap.set_listener(iap_listener)
self.gems = 0
end
function on_message(self, message_id, message, sender)
if message_id == hash("update_gems_small") then
iap.buy(GEMS_SM)
elseif message_id == hash("update_gems_medium") then
iap.buy(GEMS_MD)
elseif message_id == hash("update_gems_large") then
iap.buy(GEMS_LG)
end
if message_id == hash("gems_small") then
self.gems = self.gems + 5
elseif message_id == hash("gems_medium") then
self.gems = self.gems + 50
elseif message_id == hash("gems_large") then
self.gems = self.gems + 500
end
gui.set_text(gui.get_node("gem_inv"), self.gems)
end
function on_input(self, action_id, action)
if action_id == hash("touch") and action.pressed then
if gui.pick_node(gui.get_node("gems_small"), action.x, action.y) then
gui.set_enabled(gui.get_node("answer"), true)
elseif gui.pick_node(gui.get_node("gems_medium"), action.x, action.y) then
gui.set_enabled(gui.get_node("answer1"), true)
elseif gui.pick_node(gui.get_node("gems_large"), action.x, action.y) then
gui.set_enabled(gui.get_node("answer2"), true)
elseif gui.pick_node(gui.get_node("com.ia.purchases.gem.small"), action.x, action.y) then
gui.set_enabled(gui.get_node("answer"), false)
self.purchase = true
gui.set_text(gui.get_node("text"), "small gems bought")
if self.purchase == true then
msg.post(".", "update_gems_small")
end
elseif gui.pick_node(gui.get_node("com.ia.purchases.gem.medium"), action.x, action.y) then
gui.set_enabled(gui.get_node("answer1"), false)
self.purchase = true
gui.set_text(gui.get_node("text"), "medium gems bought")
if self.purchase == true then
msg.post(".", "update_gems_medium")
end
elseif gui.pick_node(gui.get_node("com.ia.purchases.gem.large"), action.x, action.y) then
gui.set_enabled(gui.get_node("answer2"), false)
self.purchase = true
gui.set_text(gui.get_node("text"), "large genm bought")
if self.purchase == true then
msg.post(".", "update_gems_large")
end
elseif gui.pick_node(gui.get_node("no"), action.x, action.y) then
gui.set_enabled(gui.get_node("answer"), false)
gui.set_text(gui.get_node("text"), "THANKS FOR CONSIDERING.")
elseif gui.pick_node(gui.get_node("no1"), action.x, action.y) then
gui.set_enabled(gui.get_node("answer1"), false)
print("NO")
gui.set_text(gui.get_node("text"), "THANKS FOR CONSIDERING.")
elseif gui.pick_node(gui.get_node("no2"), action.x, action.y) then
gui.set_enabled(gui.get_node("answer2"), false)
print("NO")
gui.set_text(gui.get_node("text"), "THANKS FOR CONSIDERING.")
elseif gui.pick_node(gui.get_node("power"), action.x, action.y) then
os.exit()
end
end
end
--
Subscribe to the Channel for more content, Like the video, Share the video, and Comment suggestions or to show your support!!!
Provide Thoughts on the channel and join the email list - https://bit.ly/3hG99wP
Check out my Social Media to reach out to me!
Twitter - https://twitter.com/vigmu2
Discord - https://discord.gg/AYEAK5RmFR
Use Humble Bundle Affiliate as another way to support
https://www.humblebundle.com/?partner=vigmu2games
To check out my Podcast - https://tinyurl.com/84k2zdct
Shows uploaded every other Friday at 8AM (until further notice)
If you would like to donate for my current work and for further content! You can donate here -- https://bit.ly/3ea8q3u
-
23:01
Mrgunsngear
1 day ago $4.41 earnedWolfpack Armory AW15 MK5 AR-15 Review 🇺🇸
72.5K12 -
25:59
TampaAerialMedia
1 day ago $2.26 earnedUpdate ANNA MARIA ISLAND 2025
44.2K4 -
59:31
Squaring The Circle, A Randall Carlson Podcast
13 hours ago#039: How Politics & War, Art & Science Shape Our World; A Cultural Commentary From Randall Carlson
34.1K2 -
13:21
Misha Petrov
13 hours agoThe CRINGIEST Thing I Have Ever Seen…
27K52 -
11:45
BIG NEM
9 hours agoWe Blind Taste Tested the Best Jollof in Toronto 🇳🇬🇬🇭
18.7K -
15:40
Fit'n Fire
13 hours ago $0.38 earnedArsenal SLR106f & LiteRaider AK Handguard from 1791 Industries
16.3K1 -
8:34
Mike Rowe
6 days agoWhat You Didn't Hear At Pete's Confirmation Hearing | The Way I Heard It with Mike Rowe
53.7K23 -
7:13:44
TonYGaMinG
14 hours ago🟢LATEST! KINGDOM COME DELIVERANCE 2 / NEW EMOTES / BLERPS #RumbleGaming
73.5K4 -
40:17
SLS - Street League Skateboarding
4 days agoEVERY 9 CLUB IN FLORIDA! Looking back at SLS Jacksonville 2021 & 2022 - Yuto, Jagger, Sora & more...
113K1 -
2:00:47
PaddysParlorGames
23 hours agoSunday Parlor Chill: GOBSTEIN
71.4K5