Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

IAP Badger: a unified approach to in-app purchases
Started by happymongoose Sep 13 2015 09:59 AM

400 replies to this topic
release lua plugin iap in app purchases monetization inventory
[TOPIC CONTROLS]
Page 3 of 17 1 2 3 4 5 »
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#51

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

MY GOD IT FREAKING WORKED!!! UGHH such a big setback lmao. THANK YOU EVERYONE FOR THE HELP! and thank you roaming gamer for the solution. 



[TOPIC: post.html]
#52

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,586 posts
  • Corona SDK

You're welcome, but I want to turn that back @happymongoose for such an awesome module.  It makes my life easier and that rocks.



[TOPIC: post.html]
#53

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

I'm glad it works for you  :)



[TOPIC: post.html]
#54

Guest_lgalcott_*

[GLOBAL: userInfoPane.html]
Guest_lgalcott_*
  • Guests

I am using Iap badger for my in app purchases and it works for making the purchases.   But I just noticed one issue.  I have some moving parts in my game and the transitions are halted when badger is used and then then are not restarted at the end of the purchase.  I haven't been able to locate the code in badger that would cause the transitions to stop.

 

I have 150 levels and many would have transitions that need to restart after an IAP.

 

I would appreciate any help on how to restart these transitions.

 

Thanks

Lori



[TOPIC: post.html]
#55

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Hi Lori,

 

I think your problem may lie somewhere else.

 

You're right when you say that IAP Badger doesn't use the transition library at all - the only (vaguely) related calls it makes are to timer.performWithDelay, which wouldn't cancel any transitions you've set up.  If it helps, I don't think that the standard Corona store libraries affect transitions either (although you may see some juddering when a live device contacts the App Store).

 

I think something else must be going on with your code - maybe you're moving between scenes in composer, and one of your listeners is causing the transitions to pause?

 

 

Simon



[TOPIC: post.html]
#56

azhar

[GLOBAL: userInfoPane.html]
azhar
  • Enthusiast

  • 54 posts
  • Corona SDK

to turn off the debug mode, I just need to comment this: 

debugMode=true,

?

Or make it 'false'?



[TOPIC: post.html]
#57

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Hi there,

 

You can just comment it out.

 

 

Simon



[TOPIC: post.html]
#58

azhar

[GLOBAL: userInfoPane.html]
azhar
  • Enthusiast

  • 54 posts
  • Corona SDK

Hi there,

 

You can just comment it out.

 

 

Simon

0o0....

Just try it and it works!!!!

Love it! Love it! Love it! Love it! Love it! Love it! Love it! Love it! 

 

Great! Thank you sir for making such a beautiful code! XD... hehe...



[TOPIC: post.html]
#59

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Thanks Azhar  :)



[TOPIC: post.html]
#60

azhar

[GLOBAL: userInfoPane.html]
azhar
  • Enthusiast

  • 54 posts
  • Corona SDK

simple question, how to (code) consume a product after purchase coins?



[TOPIC: post.html]
#61

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

You don't need to - IAP Badger notices that you're connected to Google Play and handles this automatically.



[TOPIC: post.html]
#62

azhar

[GLOBAL: userInfoPane.html]
azhar
  • Enthusiast

  • 54 posts
  • Corona SDK

You don't need to - IAP Badger notices that you're connected to Google Play and handles this automatically.

 

so, when if I make an upgrade system (e.g. Weapon Upgrades) using 100 coins, I just need to use this code?:

iap.removeFromInventory("coins", 100)

Is this correct?



[TOPIC: post.html]
#63

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

That's correct - when the user spends coins, you just remove them from the inventory.



[TOPIC: post.html]
#64

azhar

[GLOBAL: userInfoPane.html]
azhar
  • Enthusiast

  • 54 posts
  • Corona SDK

sir, I'm new in android game development.. however in corona sdk I can see project sandbox, and inside "Document" folder I could see my inventory with clear value and identity of the item, is it secure?

 

for example I have this item:

--Information about how to handle the inventory item
    inventoryItems = {
        food = { productType="consumable" },

in inventory file, I could see these things:

"food":{"value":74001}

I don't know where is this file when user install the game, however is it secure?



[TOPIC: post.html]
#65

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Hi there,

 

The file should be secure.  When it is written, a hash (based on the salt you provide) is prepended to the JSON file.  This file is not accessible to users with 'normal' devices; if they have a jailbroken/rooted phone, and the user tampers with its contents, the hash will no longer match the values contained inside the JSON, and IAP Badger will reject the file (effectively emptying the inventory).

 

As an added precaution, IAP Badger offers the facility to automatically rename/disguise both the names and the values contained inside the file.  For more information, check out the security section at the bottom of the IAP Badger tutorial.  You can also add other fake, randomised quantities to the inventory, so the values held in the files become even less obvious.



[TOPIC: post.html]
#66

azhar

[GLOBAL: userInfoPane.html]
azhar
  • Enthusiast

  • 54 posts
  • Corona SDK

Hi there,

 

The file should be secure.  When it is written, a hash (based on the salt you provide) is prepended to the JSON file.  This file is not accessible to users with 'normal' devices; if they have a jailbroken/rooted phone, and the user tampers with its contents, the hash will no longer match the values contained inside the JSON, and IAP Badger will reject the file (effectively emptying the inventory).

 

As an added precaution, IAP Badger offers the facility to automatically rename/disguise both the names and the values contained inside the file.  For more information, check out the security section at the bottom of the IAP Badger tutorial.  You can also add other fake, randomised quantities to the inventory, so the values held in the files become even less obvious.

 

I try to disguise coins useng the second method, however this is what I get:

iap_badger.lua:570: attempt to index local 'value' (a function value) stack traceback:....


[TOPIC: post.html]
#67

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Could you post the code for your product catalogue?  It might be a good idea to remove any real Google / Apple product ID's with AAAA or something similar.



[TOPIC: post.html]
#68

azhar

[GLOBAL: userInfoPane.html]
azhar
  • Enthusiast

  • 54 posts
  • Corona SDK

Could you post the code for your product catalogue?  It might be a good idea to remove any real Google / Apple product ID's with AAAA or something similar.

buy25coins = {
                --A list of product names or identifiers specific to apple's App Store or Google Play.
                productNames = { apple="koin25", google="koin25", amazon="koin25"},
                --The product type
                productType = "consumable",
                --This function is called when a purchase is complete.
                onPurchase=function() iap.addToInventory("coins", 4000) end,
                --The function is called when a refund is made
                onRefund=function() iap.removeFromInventory("coins", 4000) end,
        },

this happen when I try to purchase koin25 in simulator.. the other also the same, since I just publish my game to Play Store, I just put the same name for Apple and Amazon product ID.. Is this should be different?



[TOPIC: post.html]
#69

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

In IAP Badger, you never use the identifier you give to Apple, Google etc.  You always use the key in the product catalogue - IAP Badger will take care of the rest.

 

So the correct code would be: 

iap.purchase("buy25coins", your_listener)


[TOPIC: post.html]
#70

azhar

[GLOBAL: userInfoPane.html]
azhar
  • Enthusiast

  • 54 posts
  • Corona SDK

 

In IAP Badger, you never use the identifier you give to Apple, Google etc.  You always use the key in the product catalogue - IAP Badger will take care of the rest.

 

So the correct code would be: 

iap.purchase("buy25coins", your_listener)

 

yes I know, the problem is not about purchasing, but inventory sir. the reason why I said "koin25" not "buy25coins" in the previous post is because you were asking me to show the product catalogue.. so, I show one of my product which is "buy25coins", I thought that I have a typo in produc ID (such as "koin25")..

 

summary, why I have an error?

iap_badger.lua:570: attempt to index local 'value' (a function value) stack traceback:....

when I applying refactoreTable, that error appear..

 

this is one of my disguise :

--Table for the inventory item 'coins'
--     {   name="coins",--The name of the inventory item         
--         refactoredName="reloadTime",--The name to save/load the item in the inventory data file
--         --The properties table explains how to save the value associated with this inventory item.
--         properties = {                      
--             name="value",--Do not change!  This line must always be present.            
--             refactoredName="sec",--The name to use in the save file            
--             refactorFunction=function(value) --The function used to hide the property's true value
--                 return value*-71
--             end,           
--             defactorFunction=function(value) --The function retrieve's the property's true value
--                 return value/-71
--             end        }},

Is my disguise code wrong? (I put a comment in the above code because of that error :(..



[TOPIC: post.html]
#71

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Hi again,

 

Sorry - I misunderstood the problem.  Here's how some refactoring code should look:

 

--Create the catalogue
local catalogue = {


    --Information about the product on the app stores
    products = { 
    
        buy25coins = {
                --A list of product names or identifiers specific to apple's App Store or Google Play.
                productNames = { apple="koin25", google="koin25", amazon="koin25"},
                --The product type
                productType = "consumable",
                --This function is called when a purchase is complete.
                onPurchase=function() iap.addToInventory("coins", 4000) end,
                --The function is called when a refund is made
                onRefund=function() iap.removeFromInventory("coins", 4000) end,
        }
    },


    --Information about how to handle the inventory item
    inventoryItems = {        
        coins = { productType="consumable"}
    }
}

--Refactoring information is held separately
local refactorTable = {
    --Information about how to handle the inventory item
     {
         name="coins",--The name of the inventory item         
         refactoredName="reloadTime",--The name to save/load the item in the inventory data file
         --The properties table explains how to save the value associated with this inventory item.
         properties = {                      
             name="value",--Do not change!  This line must always be present.            
             refactoredName="sec",--The name to use in the save file            
             refactorFunction=function(value) --The function used to hide the property's true value
                 return value*-71
             end,           
             defactorFunction=function(value) --The function retrieve's the property's true value
                 return value/-71
             end        }
        },
}


--This table contains all of the options we need to specify in this example program.
local iapOptions = {
    --The catalogue generated above
    catalogue=catalogue,
    --The filename in which to save the inventory
    filename="example1.txt",
    --Salt for the hashing algorithm
    salt = "something tr1cky to gue55!",


    --Refactor table gets passed in iapOptions
    refactorTable=refactorTable,    
}


iap.init(iapOptions)


I can see from the tutorial that I haven't made that part explicit.  I'll update the documentation to be more precise.



[TOPIC: post.html]
#72

azhar

[GLOBAL: userInfoPane.html]
azhar
  • Enthusiast

  • 54 posts
  • Corona SDK

 

Hi again,

 

Sorry - I misunderstood the problem.  Here's how some refactoring code should look:

 

--Create the catalogue
local catalogue = {


    --Information about the product on the app stores
    products = { 
    
        buy25coins = {
                --A list of product names or identifiers specific to apple's App Store or Google Play.
                productNames = { apple="koin25", google="koin25", amazon="koin25"},
                --The product type
                productType = "consumable",
                --This function is called when a purchase is complete.
                onPurchase=function() iap.addToInventory("coins", 4000) end,
                --The function is called when a refund is made
                onRefund=function() iap.removeFromInventory("coins", 4000) end,
        }
    },


    --Information about how to handle the inventory item
    inventoryItems = {        
        coins = { productType="consumable"}
    }
}

--Refactoring information is held separately
local refactorTable = {
    --Information about how to handle the inventory item
     {
         name="coins",--The name of the inventory item         
         refactoredName="reloadTime",--The name to save/load the item in the inventory data file
         --The properties table explains how to save the value associated with this inventory item.
         properties = {                      
             name="value",--Do not change!  This line must always be present.            
             refactoredName="sec",--The name to use in the save file            
             refactorFunction=function(value) --The function used to hide the property's true value
                 return value*-71
             end,           
             defactorFunction=function(value) --The function retrieve's the property's true value
                 return value/-71
             end        }
        },
}


--This table contains all of the options we need to specify in this example program.
local iapOptions = {
    --The catalogue generated above
    catalogue=catalogue,
    --The filename in which to save the inventory
    filename="example1.txt",
    --Salt for the hashing algorithm
    salt = "something tr1cky to gue55!",


    --Refactor table gets passed in iapOptions
    refactorTable=refactorTable,    
}


iap.init(iapOptions)


I can see from the tutorial that I haven't made that part explicit.  I'll update the documentation to be more precise.

 

 

hmm.. I think I did that sir.. after that the error appear in iap_badger.lua, the plugin file :

iap_badger.lua:570: attempt to index local 'value' (a function value) stack traceback:...


[TOPIC: post.html]
#73

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Sorry, I made a typo error - there was a set of braces missing from the refactor table in the documentation (the dangers of copying and pasting sections of code, and then tidying them up in another editor):

 

local refactorTable = {

    --Information about how to handle the inventory item
    {
         name="coins",       
         refactoredName="reloadTime",
         properties = {   

            --Missing open brace for this property ("value")
            {
                name="value",--Do not change!  This line must always be present.            
                refactoredName="sec",--The name to use in the save file            
                refactorFunction=function(value) --The function used to hide the property's true value
                    return value*-71
                end,           
                defactorFunction=function(value) --The function retrieve's the property's true value
                    return value/-71
                end        
            } -- Missing closing brace - denoting end of this property

        }, --End of properties table

    } --End of inventory item
    
} --End of refactor table

 

The extra braces may look pointless at the moment, but in the future, if I add the facility to handle subscriptions etc., this is where the additional properties will be stored.  I'll update the tutorial documentation ASAP.

 


  • azhar likes this

[TOPIC: post.html]
#74

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

The code in the documentation has been updated now.



[TOPIC: post.html]
#75

azhar

[GLOBAL: userInfoPane.html]
azhar
  • Enthusiast

  • 54 posts
  • Corona SDK

The code in the documentation has been updated now.

 

woah.. I see.. thank you very much sir! Now it is work perfectly! :D


  • happymongoose likes this


[topic_controls]
Page 3 of 17 1 2 3 4 5 »
 
[/topic_controls]

Also tagged with one or more of these keywords: release, lua plugin, iap, in app purchases, monetization, inventory