In App Purchases

We can’t see those images.  You’ll need to host the image somewhere and link to it. 

That code doesn’t look like you’re using IAP badger to me.

  1. Have you run the examples:

http://github.com/happymongoose/iap_badger

http://happymongoosegames.co.uk/iapbadger.php?page=purchase.markdown

  1. Have you read the docs:

http://happymongoosegames.co.uk/iapbadger.php 

http://happymongoosegames.co.uk/iapbadger.php?page=tutorial.markdown

Please format your code snippets when posting too.

formatyourcode.jpg

https://twitter.com/Visualinception

I just twitter the screenshots. 

  1. Have you run the examples:

http://github.com/happymongoose/iap_badger

[http://happymongoosegames.co.uk/iapbadger.php?page=purchase.markdown

I h](http://happymongoosegames.co.uk/iapbadger.php?page=purchase.markdown “External link”)ave run exactly the code from

iap_badger-master/example 2/main.lua

in main.lua 
i just put

local store = require( "store" )

because I guess it’s necessary… 
I Thought it’s a native lib and corona sdk says native libs are avaidable at enterprise. … but this is not true… 
Am I right… 

here is the entire code which I am running [ iap_badger-master ]…

put as I said to test 

local store = require( “store” )

I hope this is more detailed as the old post… 

Thanks for the advice…
 

--Example2.lua -- --Simple example of using IAP Badger to purchase an IAP for buying coins. --------------------------------- -- -- IAP Badger initialisation -- --------------------------------- --Load IAP Badger local store = require( "store" ) local iap = require("iap\_badger") --Progress spinner local spinner=nil --Text object indicating how many coins the user is currently holding local coinText=nil --Forward declaration local buyCoins10=nil --Create the catalogue local catalogue = { --Information about the product on the app stores products = { --buy50coins is the product identifier. --Always use this identifier to talk to IAP Badger about the purchase. buy50coins = { --A list of product names or identifiers specific to apple's App Store or Google Play. productNames = { apple="buy50coins", google="50\_coins", amazon="COINSx50"}, --The product type productType = "consumable", --This function is called when a purchase is complete. onPurchase=function() iap.addToInventory("coins", 50) end, --The function is called when a refund is made onRefund=function() iap.removeFromInventory("coins", 50) end, }, --buy100coins is the product identifier. --Always use this identifier to talk to IAP Badger about the purchase. buy100coins = { --A list of product names or identifiers specific to apple's App Store or Google Play. productNames = { apple="buy100coins", google="100\_coins", amazon="COINSx100"}, --The product type productType = "consumable", --This function is called when a purchase is complete. onPurchase=function() iap.addToInventory("coins", 100) end, --The function is called when a refund is made onRefund=function() iap.removeFromInventory("coins", 100) end, }, }, --Information about how to handle the inventory item inventoryItems = { coins = { productType="consumable" } } } --Called when a purchase fails local function failedListener() --If the spinner is on screen, remove it if (spinner) then spinner:removeSelf() spinner=nil end end local iapOptions = { --The catalogue generated above catalogue=catalogue, --The filename in which to save the inventory filename="example2.txt", --Salt for the hashing algorithm salt = "something tr1cky to gue55!", --Listeners for failed and cancelled transactions will just remove the spinner from the screen failedListener=failedListener, cancelledListener=failedListener, --Once the product has been purchased, it will remain in the inventory. Uncomment the following line --to test the purchase functions again in future. --doNotLoadInventory=true, debugMode=true, } --Initialise IAP badger iap.init(iapOptions) local function purchaseListener(product) --Remove the spinner spinner:removeSelf() spinner=nil --Any changes to the value in 'coins' in the inventory has been taken care of. --Update the text object to reflect how many coins are now in the user's inventory coinText.text = iap.getInventoryValue("coins") .. " coins" --Save the inventory change iap.saveInventory() --Tell user their purchase was successful native.showAlert("Info", "Your purchase was successful", {"Okay"}) end --Purchase function buyCoins=function(event) --Place a progress spinner on screen and tell the user the app is contating the store local spinnerBackground = display.newRect(160,240,360,600) spinnerBackground:setFillColor(1,1,1,0.75) --Spinner consumes all taps so the user cannot tap the purchase button twice spinnerBackground:addEventListener("tap", function() return true end) local spinnerText = display.newText("Contacting " .. iap.getStoreName() .. "...", 160,180, native.systemFont, 18) spinnerText:setFillColor(0,0,0) --Add a little spinning rectangle local spinnerRect = display.newRect(160,260,35,35) spinnerRect:setFillColor(0.25,0.25,0.25) transition.to(spinnerRect, { time=4000, rotation=360, iterations=999999, transition=easing.inOutQuad}) --Create a group and add all these objects to it spinner=display.newGroup() spinner:insert(spinnerBackground) spinner:insert(spinnerText) spinner:insert(spinnerRect) --Tell IAP to initiate a purchase - the product name will be stored in target.product iap.purchase(event.target.product, purchaseListener) end --------------------------------- -- -- Main game code -- --------------------------------- --Remove status bar display.setStatusBar( display.HiddenStatusBar ) --Background local background = display.newRect(160,240,360,600) background:setFillColor({type="gradient", color1={ 0,0,0 }, color2={ 0,0,0.4 }, direction="down"}) --Draw "buy 50 coins" button --Create button background local buy50Background = display.newRect(240, 400, 150, 50) -- buy50Background.stroke = { 0.5, 0.5, 0.5 } -- buy50Background.strokeWidth = 2 --Create "buy IAP" text object local buy50Text = display.newText("Buy 50 coins", buy50Background.x, buy50Background.y, native.systemFont, 18) buy50Text:setFillColor(0,0,0) --Store the name of the product this button relates to buy50Background.product="buy50coins" --Create tap listener buy50Background:addEventListener("tap", buyCoins) --Draw "buy 100 coins" button --Create button background local buy100Background = display.newRect(80, 400, 150, 50) --buy100Background.stroke = { 0.5, 0.5, 0.5 } --buy100Background.strokeWidth = 2 --Create "buy IAP" text object local buy100Text = display.newText("Buy 100 coins", buy100Background.x, buy100Background.y, native.systemFont, 18) buy100Text:setFillColor(0,0,0) --Store the name of the product this button relates to buy100Background.product="buy100coins" --Create tap listener buy100Background:addEventListener("tap", buyCoins) --Text indicating how many coins the player currently holds --Get how many coins are currently being held by the player local coinsHeld = iap.getInventoryValue("coins") --If no coins are held in the inventory, nil will be returned - this equates to no coins if (not coinsHeld) then coinsHeld=0 end coinText = display.newText(coinsHeld .. " coins", 160, 20, native.systemFont, 18) coinText:setFillColor(1,1,0)

No… I mean did you download and run the full unmodified example? 

Run Unmodified Example First

You need to:

  1. Download the entire example.

  2. Run it.

  3. Play with values and see what changes do.

  4. Learn to debug when you break things in the example.

  5. Once you have an understanding of things, then and only then add IAP code to your game.

If you can’t get the unmodified example to run, then you’ve got an issue that can  be addressed.  

Otherwise, you’re just mashing code together and hoping it will work.  I can’t help you with that.  You’ve got to take baby steps and work your way up.

Use Latest Corona

Also, what version of Corona are you using.

For example, I’m running: 2016.2903 right now.

If you are using the public release, I’d suggest getting the latest daily build instead: https://developer.coronalabs.com/downloads/daily-builds/

Re Screenshots

Sorry, but Twitter isn’t gonna do it.  Use dropbox, github, or some other way of hosting your images and post links to the hosted images here.  

For completeness sake, I downloaded and ran example 2.

https://www.youtube.com/watch?v=I4ryuV9TQ_A&feature=youtu.be

re your screenshots…

That is exactly right.  You’re running in debug mode.

main.lua ~line 88

 debugMode=true,

You need to read the docs as I said before.  You’re just trying to jump in and hope it does what you expect.  I’m afraid it does not work that way. You have to learn it first.  Sorry.

I saw a sub-question embedded your recent long post…

because I guess it’s necessary… 
I Thought it’s a native lib and corona sdk says native libs are avaidable at enterprise. … but this is not true… 
Am I right… 

IAP badger is not native code.  It is pure Lua.

If you’re new to Corona you really should learn the basics before jumping into Enterprise.  Enterprise is for folks who want to extend the functionality of Corona by adding their own custom native code/libraries/etc.

PS - I’m done for the day, so if you post again and I don’t post back…I’m away from my desk.

Thank you very much. Ok. Yes I’m working on my App almost 4-5 months and its working good, without almost any bugs.  
I thought i would be now at the end and everything else like IAP can be done very quick. But now I know I need to do more then expected. Like everything else in life.

I won’t buy enterprise… So no need to worry. I will read the docs again very carefully. I will learn how these things are working. 
Thanks also for answering me the question.  Didn’t know for example that IAP works also with only lua.
Last post thank you. My doubts are removed. Thanks im gongt to close this then. 
When I have further questions, I will write again if this is ok. *

Thanks. Blogs are working very good!
Can learn a lot of from you guys. 

Bes Regs, 
Hüseyin : ) 

Hi Hüseyin,

Are you using the plug-in or Github version of IAP Badger?

Simon

Hi Simon, 

yes,I reading the Docs and will after this implent IAP Badger in my game app. 
I would like to use a “non-Consumable” to expand the levels in my game app. 

I thought I can use “Remove ads” in the example and Change this in my game
to extend more levels. How I’m going to do this i still don’t know. 
I thought maybe just with a simple 
true and false 
or with putting a key into my gameapp. 

I still don’t know it yet. Haven’t started with this. 
But why are you asking? 

Best regs,
Hüseyin 

From what you’ve written above, I’m guessing you are using the plug-in version.

If I’m right, then you have to activate the plug-in for your Corona account before IAP Badger will work (see the button at the bottom of this page).

From then on in, as Roaming Gamer said, it’s all about taking your time and following the tutorials (both for IAP Badger and for setting up your products in the consoles for iOS and Google Play).  IAP is one of those processes you just can’t rush - you have to painstakingly work through every detail to get it to work (unfortunately!)

Simon 

PS - You should not need to include the store library manually to make IAP Badger work correctly - it automatically requires its own copy of the store library anyway.

PPS - the sample code for the documentation on the Happy Mongoose website is probably more up to date than the sample code on Github.

@Hüseyin,

Question:  You’ve been working on your game for 4…5 months, but this is your first forums post?  I also see you’ve been a member since ‘25 Sep 2013’.

I ask because that tells me something interesting.  I sometimes see people pop in and ask a small set of questions about advanced topics.  I usually think they are just starting too fast, but in this case I could be wrong.

I guess I have more questions too:

  1. Is this the first time you found you needed help and couldn’t figure things out on your own?

  2. If you’ve needed help before, where did you get it if not by asking questions here.

  3. Have you been actively using Corona since 2013 or are you just coming back recently?

  4. Why have you never used the forums before?  

  5. What is your method for ‘figuring things out’.

Sorry to play 20 questions, but this is just fascinating to me.  I sometimes feel there is a disconnect between users and the forums/docs, but I can’t figure out why.

Thanks,

Ed

What version of Corona SDK are you using?

Have you done a “Deauthorize and Quit” and login in again?

Corona SDK has been free for over a year. Our current public build is 2830 (and we are really close to another public build).  The message that the store API’s are restricted could come from either or both an old build or having not logged out and back in since we made the product free and Corona thinks you’re still on a restricted account.

Please note, if you’re on a very old build and  you jump to say today’s daily build (which you now have access to) 2906 you are likely going to find a bunch of other things that we’ve fixed/changed.  Depending on how far back you are, you will likely need to update to a  more modern version. Both Apple and Google have forced changes that require newer builds.

Rob

Hey There, 

it’s me again Hüseyin. I just downloaded Corona SDK with another email from me. 
And now the peace of code the line

local store = require( "store" )

works without any troubles. and also I’ve received Corona Ads… Haven’t seen this at all…
Also the interface has changed…Deam. I was using the latest Corona SDK but i was authorize as 2013…
very annoying, not amuzed… ^^thank you Rob thats brilliant. 

Didnt expected this…that a issue can depend on something like this… 

@roaminggamer
The reason why I havent use Blogs etc. I guess it was just to comlex the entire steps… 
if you google your issues… You can also find a way to solve problems or with YouTube… i was watching Tutorials 
and thoaught me this corona sdk. I had 2 beginnings … I Stopped, because i couldn’T do anything with it…
But now I’m very focused and i want to learn this. Stopped Web dev and I focus on Apps. 

thank you all. Now i guess i can start.