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 2 of 17 1 2 3 4 »
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

Yes exactly. Thats odd right? lol



[TOPIC: post.html]
#27

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Could you post your build.settings code and which build version of Corona you're using?



[TOPIC: post.html]
#28

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

build settings file: 

 

--
-- For more information on build.settings see the Corona SDK Build Guide at:
--
 
settings =
{
 
orientation =
{
-- Supported values for orientation:
-- portrait, portraitUpsideDown, landscapeLeft, landscapeRight
 
default = "portrait",
supported = { "portrait", }
},
 
excludeFiles =
{
-- Include only the necessary icon files on each platform
iphone = { "Icon-*dpi.png", },
android = { "Icon.png", "Icon-Small-*.png", "Icon*@2x.png", },
},
 
--
-- iOS Section
--
iphone =
{
plist =
{
UIStatusBarHidden = true,
UIPrerenderedIcon = true, -- set to false for "shine" overlay
--UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend
 
CFBundleIconFiles =
{
"Icon.png",
"Icon@2x.png",
"Icon-60.png",
"Icon-60@2x.png",
"Icon-60@3x.png",
"Icon-72.png",
"Icon-72@2x.png",
"Icon-76.png",
"Icon-76@2x.png",
"Icon-Small.png",
"Icon-Small@2x.png",
"Icon-Small@3x.png",
"Icon-Small-40.png",
"Icon-Small-40@2x.png",
"Icon-Small-50.png",
"Icon-Small-50@2x.png",
},
 
--[[
-- iOS app URL schemes:
CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
"fb862052867225723",  -- replace XXXXXXXXX with your Facebook appId
}
}
}
--]]
}
},
 
--
-- Android Section
--
android =
{
googlePlayGamesAppId = "994096497629", 
 
usesPermissions = {
"android.permission.INTERNET",
"android.permission.ACCESS_WIFI_STATE",
"com.android.vending.BILLING",
      "com.android.vending.CHECK_LICENSE",
},
},
plugins =
{
["plugin.google.play.services"] = 
publisherId = "com.coronalabs", 
supportedPlatforms = { android = true }
},
 
    ["CoronaProvider.gameNetwork.google"] = 
    {
    publisherId = "com.coronalabs"
    },
 
    ["plugin.toast"] = 
    {
    publisherId = "com.spiralcodestudio"
    },
 
    ["facebook"] = 
    {
    publisherId = "com.coronalabs"
    },
    
    ["plugin.google.play.services"] = 
    {
    publisherId = "com.coronalabs"
      },
 
        ["plugin.google.iap.v3"] =
        {
            -- required
            publisherId = "com.coronalabs",
            supportedPlatforms = { android = true },
        },  
},
}
 
 
corona build: 2015.2646


[TOPIC: post.html]
#29

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Do you get any system error messages in the device error log?

 

(If you're not sure how to do this, you need to use the adb logcat command - for more info, look at the Device Debbuging - Android section of this page.  adb logcat can generate a ton of message text, so it may be best to call a print statement with something like "Iniitalizing now" before calling iap.init, and "Making purchase now" before your call iap.purchase, so you can find the relevant output).

 

Also, try commenting out lines 1439 and 1440 from the init function in the iap_badger.lua module, so it looks as below:

elseif targetStore=="google" then
  -- store=require("plugin.google.iap.v3")
  -- store.init("google", storeTransactionCallback)
  storeAvailable = true
elseif targetStore=="amazon" then

...then run your app, making sure you initialise IAP Badger in debug mode.

 

If the above change works, it means that the module is trying to initialise the Google Play store before your app is ready for in app purchases in Google Play Console.  If this is the case, then I should be able to re-jig the code, so that in debug mode, no such initialisation is ever made.  (The above is only a temporary fix for running in debug mode on a device - it wouldn't work in production).

 

Let me know if this helps / what errors messages you get.



[TOPIC: post.html]
#30

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

for debugmode i am doing this initialization: 
 

local iapOptions = {
    --The catalogue generated above
    catalogue=catalogue,
    --The filename in which to save the inventory
    filename="SpacecraftsInventory.txt",
    --Salt for the hashing algorithm
    salt = "hey whats up",
 
      debugMode = true,
 
      debugStore = "google"
}
 
is that okay considering were taking out those lines?


[TOPIC: post.html]
#31

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Yes - keep everything else exactly the same.  Only comment out those two lines in iap_badger.lua and see what happens.



[TOPIC: post.html]
#32

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

how do i upload an image on here? lol



[TOPIC: post.html]
#33

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

I think you click on My Media and add it as an attachment.

 

No guarantees on that one though...



[TOPIC: post.html]
#34

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

alright i just uploaded them to imgur lol

 

so here's the logcat error before the changes:

http://imgur.com/2YY6EQy

 

here it is after the changes:

 

http://imgur.com/Dzgp0ng

 

let me know if those links work for you..



[TOPIC: post.html]
#35

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

so i guess there was no difference. I have no idea what I'm doing wrong lol



[TOPIC: post.html]
#36

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

sorry for all the trouble man, thanks for sticking around



[TOPIC: post.html]
#37

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Can you upload your catalogue and the code your using to call iap.purchase?

 

Blank out any stuff that shouldn't be shared in public (eg. identifiers for your products from Google Play or the App Store).  For example:

local catalogue = {

  --Information about the product on the app stores
  products = {

    --removeAds is the product identifier.
    removeAds = {

    --Hide your real product names here
    productNames = { apple="AAAAAAAA", google="BBBBBBB", amazon="CCCCCCC" },

    --The product type
    productType = "non-consumable",

    --Any other code that's safe to share in public about your purchase and refund listeners...

    }
  },

  --Then the code for your inventory items that's safe to share in public
  --...

}



[TOPIC: post.html]
#38

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

local catalogue = {
  
  products = {

    buyThis= {
      productNames = { apple ="something", google = "blrub", amazon = "derp"},
      onPurchase=function() iap.setInventoryValue("iBoughtThis", true) end,
      onRefund=function() iap.removeFromInventory("iBoughtThis", true) end,
      productType = "non-consumable",
  }
},
inventoryItems = {
        iBoughtThis = { productType="non-consumable" }
    }
}

iap.purchase("buyThis", purchaseListener)


ive changed up my variable names as well. hopefully this helps!



[TOPIC: post.html]
#39

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

local function purchaseListener(product, transaction)

    --Check the product name...
    if (product=="buyThis") then

        print("yo")

        --Tell the user the ads have been removed
        native.showAlert("Purchase complete", "The thing has been unlocked!", {"Okay"})
    end

end

sorry forgot this



[TOPIC: post.html]
#40

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

That looks perfect.

 

Baffled  :huh:

 

I'm on holiday with my family at the moment, so I don't have access to any of my development kit.  When I get home at the weekend, I'll download the same daily build of Corona as you're using and hopefully I'll be able to help you more.



[TOPIC: post.html]
#41

Michael W.

[GLOBAL: userInfoPane.html]
Michael W.
  • Contributor

  • 276 posts
  • Alumni

Can you update to the latest daily build and try to reproduce the console errors you got before? What line numbers from init.lua to you get reported back to you on the latest daily build?



[TOPIC: post.html]
#42

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

I'll do that when I get home, right now I'm out. It is really strange, I thought I was doing everything right Lol.
The thing is, I updated to the latest daily buildyesterday for this reason, hopefully things will be different in the next build...I'll update shortly..

[TOPIC: post.html]
#43

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

ah. interesting. looks like my error is coming from init.lua:222 now. any ideas?



[TOPIC: post.html]
#44

Michael W.

[GLOBAL: userInfoPane.html]
Michael W.
  • Contributor

  • 276 posts
  • Alumni

It's trying to dispatch a function listener in EventListener:dispatchEvent. Nevermind though, I failed at reading your console log. The error is in the dispatched function, not in the dispatcher.

 

The issue looks to be in the purchase function and the use of table.count, which isn't a thing in our version of Lua.



[TOPIC: post.html]
#45

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

so this is a bug in iap_badger? not my code?



[TOPIC: post.html]
#46

Michael W.

[GLOBAL: userInfoPane.html]
Michael W.
  • Contributor

  • 276 posts
  • Alumni

That was my guess from the log. Do you use someObject.count anywhere in your code?

 

I suppose you could test it by defining a custom table.count somewhere early on in main.



[TOPIC: post.html]
#47

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,585 posts
  • Corona SDK

I supply a table.count() function as part of SSK.  Here is the code:

-- ==
--    table.count( src ) - Counts all (first-level) entries in table
-- ==
function table.count( src )
	local count = 0
	if( not src ) then return count end
	for k,v in pairs(src) do 
		count = count + 1
	end
	return count
end

You can add this and see if that helps.



[TOPIC: post.html]
#48

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

Ah - table.count is indeed a helper function I've added in another file (crashes and burns...)



[TOPIC: post.html]
#49

happymongoose

[GLOBAL: userInfoPane.html]
happymongoose
  • Contributor

  • 351 posts
  • Corona SDK

I've just updated the github repository to include the above change (and one minor other bugfix) - let me know if the changes work for you.

 

You can find the file here.



[TOPIC: post.html]
#50

ciabucagames

[GLOBAL: userInfoPane.html]
ciabucagames
  • Observer

  • 27 posts
  • Corona SDK

wow i was just about to reply lmao. awesome give me a few minutes...




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

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