Android IAP testing your own product ID's

Hello everyone,
Hoping that someone who has already seen this issue can help me find a solution. I followed the guide of “introduction to android in app billing” from the corona blog. Here is where I am at…

I have included “com.android.vending.BILLING” in my build file
I have uploaded a signed version of my APK
I have set my app to “Active” in google play dashboard
I have created an IAP item and published it in the google play dashboard
I have added a few test users in google play to test my own IAP products

Here is my code:
[lua]–Here is my config file

settings =
{
orientation =
{
default = “landscapeRight”,
supported =
{
“landscapeLeft”, “landscapeRight”
},
},
–[[
iphone =
{
plist =
{
CFBundleIconFile = “Icon.png”,
CFBundleIconFiles = {
“Icon.png” ,
“Icon@2x.png” ,
“Icon-72.png” ,
},

UIAppFonts =
{
“Chantelli Antiqua.ttf”
},
}
}
–]]
android =
{
usesPermissions =
{

“com.android.vending.BILLING”,

},

}

}
– Here is my store code for Android

local M = {}

local store = require(“store”)
local function transactionCallback( event )
local transaction = event.transaction

if transaction.state == “purchased” then
native.showAlert( “IAP TEST”, “Purchased!”, {“OK”})
– Transaction was successful; unlock/download content now

elseif transaction.state == “restored” then
native.showAlert( “IAP TEST”, “Restored!”, {“OK”})
– You’ll never reach this transaction state on Android.
elseif transaction.state == “refunded” then

– Android-only; user refunded their purchase
local productId = transaction.productIdentifier
native.showAlert( “IAP TEST”, “Refunded”, {“OK”})
– Restrict/remove content associated with above productId now

elseif transaction.state == “cancelled” then
native.showAlert( “IAP TEST”, “It Purchased!”, {“OK”})
– Transaction was cancelled; tell you app to react accordingly here
elseif transaction.state == “failed” then
native.showAlert( “IAP TEST”, “Transaction Failed”, {“OK”})
– Transaction failed; tell you app to react accordingly here

end

– The following must be called after transaction is complete.
– If your In-app product needs to download, do not call the following
– function until AFTER the download is complete:

store.finishTransaction( event.transaction )
end

store.init( “google”, transactionCallback )

M.purchaseVolume = function()

– single product purchase
store.purchase( { “android.test.purchased” } )

end

return M[/lua]
When I use the code as is with the “android.test.purchased” then I and all other test users are able to get a transaction completed callback. When I insert my product ID into store.purchase, my test users are returned with: “Item unavailable:
the item you requested is not available for purchase”

For me when I try it pulls up the purchase screen in google play and gives me an error when I try to purchase but it still gives me a transaction complete call back.
Any thoughts about what I am missing here? Do you need to wait a day for google play to update IAP products and push them live?

Also as you can see in my build code, I have the iphone area commented out because I can’t get that and the android code to play together well, if anyone knows the proper coding of this it would be appreciated. Thanks so much [import]uid: 19620 topic_id: 29347 reply_id: 329347[/import]

Hi,

I’m not really familiar with Google In App Billing as I haven’t reached that point with my App yet.

This might be stating the obvious, but in the iPhone code that you’ve commented out, you’re missing a trailing ‘,’.

It should be:
[lua]settings =
{
orientation =
{
default = “landscapeRight”,
supported =
{
“landscapeLeft”, “landscapeRight”
},
},
iphone =
{
plist =
{
CFBundleIconFile = “Icon.png”,
CFBundleIconFiles = {
“Icon.png” ,
“Icon@2x.png” ,
“Icon-72.png” ,
},

UIAppFonts =
{
“Chantelli Antiqua.ttf”
},
}
},
android =
{
usesPermissions =
{

“com.android.vending.BILLING”,

},

}
}[/lua]

Not sure if that’s just a typo from posting here or not.

Ali [import]uid: 10499 topic_id: 29347 reply_id: 117977[/import]

Just bumping this thread, I really am not sure what to do, I have been stuck on this for a good while now, any thoughts would be appreciated [import]uid: 19620 topic_id: 29347 reply_id: 118711[/import]

Thank you very much for the help with the build code, I always have had a hard time understanding where commas should go and so forth. [import]uid: 19620 topic_id: 29347 reply_id: 118032[/import]

I noticed in the android developer dashboard under the in app purchase I am working with it says: “An in-app product will appear UNPUBLISHED until the owning application is PUBLISHED, at which point the in-app product’s publishing state applies. Please use the application editor to modify the application’s publishing state.”

I have read that you don’t need to publish the app to be able to test IAP, you only need your app “Active” and the IAP Item set to published, thats how I have it. Should the above statement be disregarded? [import]uid: 19620 topic_id: 29347 reply_id: 118712[/import]

@rxmarccall, unfortunately, I never tried using test user or test purchase with Android In-App Billing. That said, I was able to test for real (meaning, actually charging credit card) when my game was not published but had my app Active and IAP Items set to published.

Naomi [import]uid: 67217 topic_id: 29347 reply_id: 118736[/import]

@Naomi

thanks for the reply. That is really all I am trying to do is what you said. I don’t mind if it charges my card, I just can’t get it to work. How did you get it to work if you didn’t use a different gmail account other than your own developer account? [import]uid: 19620 topic_id: 29347 reply_id: 118737[/import]

@rxmarccall, I don’t remember exactly what I did when testing the Android In-App Billing, but… hmmm… I guess the Android phone I used isn’t signed in with Google Play Developer log in email address, and that’s why it works? I have personal email address(es), and I have company email address, and the phone is signed in with one of the personal email address and the Google Play Developer account is set up with company email address…

Naomi [import]uid: 67217 topic_id: 29347 reply_id: 118742[/import]

Ok I understand, there must just be some simple silly mistake that I am making. From what you can tell does everything in my above code look correct for doing a simple Android IAP? [import]uid: 19620 topic_id: 29347 reply_id: 118744[/import]

@rxmarccall, I’m not sure if this would make any difference, but my build.settings include INTERNET permission:

android =  
{  
 usesPermissions =  
 {  
 "com.android.vending.BILLING",  
 "android.permission.INTERNET",  
 },  
},  

Naomi

Edit: By the way, I use single code base for Android, Kindle, Nook and iOS versions, so it’s a bit hard to see what might be missing on yours, but do you check to make sure your IAP routine knows the valid product’s productIdentifier somewhere?
[import]uid: 67217 topic_id: 29347 reply_id: 118756[/import]

Umm… what you see above is everything I am doing concerning IAP. Do I need to be doing “store.loadProducts”? I thought I read that is only for IOS? I was just doing exactly what you see up above. [import]uid: 19620 topic_id: 29347 reply_id: 118759[/import]

@rxmarccall, it sounds like you haven’t included a valid product for sale in your In-App Billing routine. You need at least one valid product for sale before you can make any purchase… (The way it is, I don’t think there’s anything for sale…)

Naomi [import]uid: 67217 topic_id: 29347 reply_id: 118760[/import]

Could you provide any code for what you are referring too? I actually plan to support IAP for ios as well, if there was any way possible for you to share your code I would greatly appreciate it. In the meanwhile im going to research what you said… [import]uid: 19620 topic_id: 29347 reply_id: 118766[/import]

What is strange is that when i go to purchase, it pulls up the google play marketplace and it has the name of my IAP item as well as its price and everything. then the error message appears [import]uid: 19620 topic_id: 29347 reply_id: 118767[/import]

Okay, then I don’t know what to think. The best IAP code (especially after you become a little more familiar with how IAP works) is actually the sample code that comes bundled with Corona. I couldn’t make out much from it the first time I looked at it (and at the time, I was only a few months into learning how to code at all), but after I sorted out the basics, I found it to be a great reference material. It shows how to implement both Google and Apple versions of IAP.

CoronaSDK > SampleCode > Networking > InAppPurchase

Naomi

[import]uid: 67217 topic_id: 29347 reply_id: 118769[/import]

Ill just have to figure it out with that sample code, thanks for the help Naomi [import]uid: 19620 topic_id: 29347 reply_id: 118770[/import]

So, I decided to just push my app live until it appeared in the google play marketplace. with it fully published my IAP worked just fine… I have no idea why I couldn’t get it to work in a testing phase, at least I know it WILL work. time to take it back down. [import]uid: 19620 topic_id: 29347 reply_id: 118784[/import]

Hey, @rxmarccall, glad to hear it worked! What a pain you had to go through, but all is well that ends well, eh?

Naomi
[import]uid: 67217 topic_id: 29347 reply_id: 118788[/import]

@Naomi,

Hopefully so! all I can do is get my app ready for launch and hope it works as it should! thanks for your help. [import]uid: 19620 topic_id: 29347 reply_id: 118881[/import]

  • rxmarccall - Did you ever get this resolved? I am having the exact same problem but I don’t want to release it live just to see if it works. It launches google play - I can see the title of my in-app purchase but it still gives a item not available for purchase error. I did a factory reset on my phone and am using a test account (big pain).

[import]uid: 128282 topic_id: 29347 reply_id: 121661[/import]