Thabk you for the quick response everyone. I already put a lot of prints for testing, even at thr beggining of the callback function and it is only called when I cancel the purchase. Whenever I finish a purchase or try ti restore, nothing happens… I’m using a simple code, with a local transactionCallback function
I think it will be a good idea if you paste your code here, like Nischal said. If you do not want to expose anything, you can just make a copy then replace what names you may have there with dummies and paste here, so we can see what is going on there.
Ok, so when I press the button I call the purchase
if(store.isActive) then store.purchase("product id") end
I have called this
local store = require("plugin.google.iap.v3")
And the callback:
local function transactionCallback( event ) print("In transactionCallback\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*", event.transaction.state) local transaction = event.transaction local tstate = event.transaction.state -- --Google does not return a "restored" state when you call store.restore() --You're only going to get "purchased" with Google. This is a work around --to the problem. -- --The assumption here is that any real purchase should happen reasonably --quick while restores will have a transaction date sometime in the past. --5 minutes seems sufficient to separate a purchase from a restore. -- if store.availableStores.google and tstate == "purchased" then local tdate = math.floor( transaction.date /1000 ) local timeStamp = utility.makeTimeStamp(transaction.date,"ctime") if timeStamp + 360 \< os.time() then -- if the time stamp is older than 5 minutes, we will assume a restore. print("map this purchase to a restore") tstate = "restored" print("I think tstate is ", tstate) restoring = false end end if tstate == "purchased" then print("Transaction successful!") myData.unlockVids(transaction.productIdentifier) native.showAlert("Thank you!", "Your support is greatly appreciated!", {"Okay"}) store.finishTransaction( transaction ) elseif tstate == "restored" then print("Transaction restored (from previous session)") myData.unlockVids(transaction.productIdentifier) utility.saveTable(mySettings, "settings.json") store.finishTransaction( transaction ) elseif tstate == "refunded" then print("User requested a refund -- locking app back") myData.lockVids(transaction.productIdentifier) store.finishTransaction( transaction ) elseif tstate == "revoked" then -- Amazon feature print ("The user who has a revoked purchase is", transaction.userId) --Revoke this SKU here: myData.lockVids(transaction.productIdentifier) elseif tstate == "cancelled" then print("User cancelled transaction") store.finishTransaction( transaction ) elseif tstate == "failed" then print("Transaction failed, type:", transaction.errorType, transaction.errorString) store.finishTransaction( transaction ) else print("unknown event") store.finishTransaction( transaction ) end goToMenu() print("done with store business for now") end
And that’s it. I only get the “transactionCallback****…” print when I touch the button, and cancel the purchase interface (tap outside the box, or use the back button). It maybe important to note that I’m requiring the store in two different composer scenes. The callback is in the scene:create and I already removed the “local” from it and nothing changes. Thanks.
Yep everyone, this is the only way to test your app properly. Only the app that you put in beta in the app store will work with the Test account you made. Don’t pull your hair out lol. This whole inApp process is very frustrating
That’s what I decided to do – but in putting up the beta I discovered I was over the 50MB limit and so had to use an expansion file. I could never get the 2-part app to install on my device, so I just gave up on the idea of doing an Android build.
Yesterday (months later) I decided to take a different tack and yanked out some audio (and changed the code referencing them) and got the APK size to under 50MB. Uploaded it as a beta and a few hours later it installed on my device and I was able to make a test IAP purchase with no problem.
Jay
You can change your account on the google play store, The google app itself (google Now), your email, and everwhere else and it may still fail. The only way to test in app purchases is to remove the developer account completely from your test device. I suggest getting another devices if you only own one. P.S. In-app purchasing on google is a complete nightmare
Thanks, but I knew that already. I tried many things and I manage to track the problem.
Stupidly from my side, I did not even realize I entered under the ‘In-app Products’ a short name like ‘myproduct’ and when trying to access it through the code, I called for the whole package name with that name: ‘com.mysite.myapp.myproduct’. and that made the error occur .
i has the very same problem but once i published app as alpha everything worked fine. Even with my publisher mail id i was not having any problems.
When i try to purchase with publisher mail id i was getting “Publisher cannot make purchases” and with other tester accounts i was able to make purchases.
That is how it is suppose to work. I mean when you get “authentication required…” it is not because you are connected with your publisher account.
I’m having the same problem, I tried making the purchase with every account I have and on different devices and I always get that error. Here’s the log:
I/Corona (25676): PURCHASE \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* D/Finsky (24174): [14769] InAppBillingUtils.getPreferredAccount: (myapp name): Account from first account - [ieJC9jZQt-43Mx7723-cXNCET8U] E/Parcel ( 679): Class not found when unmarshalling: com.google.android.finsky .billing.lightpurchase.PurchaseParams, e: java.lang.ClassNotFoundException: com. google.android.finsky.billing.lightpurchase.PurchaseParams I/CustomFrequencyManager( 679): newFrequencyRequest - mFrequency = 1350000, mT imeoutMs = -1, mPkgName = ACTIVITY\_RESUME\_BOOSTER@4 I/CustomFrequencyManager( 679): Boost Request from package = ACTIVITY\_RESUME\_BO OSTER@4 frequency : 1350000type = 6 I/CustomFrequencyManager( 679): !! pkgName = ACTIVITY\_RESUME\_BOOSTER@4 I/CustomFrequencyManager( 679): Request from package name pkgName = ACTIVITY\_RE SUME\_BOOSTER@4 I/CustomFrequencyManager( 679): mContext is Not Null mContext.pkgName = androi d I/CustomFrequencyManager( 679): 2 Old token will be reused! I/CustomFrequencyManager( 679): CPUDVFSControlRequest : doFrequencyRequest:: = 1350000 Timeout : -1 I/power ( 679): \*\*\* acquire\_dvfs\_lock : lockType : 1 freq : 1350000 D/qdmemalloc( 245): ion: Mapped buffer base:0x48f3f000 size:1835008 fd:75 D/CustomFrequencyManagerService( 679): acquireDVFSLockLocked : type : DVFS\_MIN\_ LIMIT frequency : 1350000 uid : 1000 pid : 679 pkgName : ACTIVITY\_RESUME\_BOO STER@4 W/ActivityManager( 679): mDVFSHelper.acquire() W/ContextImpl( 679): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1336 com.android.server.am.Activity Stack.startActivityUncheckedLocked:4452 com.android.server.am.ActivityStack.star tActivityLocked:3936 com.android.server.am.ActivityStack.startActivityMayWait:46 16 com.android.server.am.ActivityManagerService.startActivityInPackage:3135 D/qdmemalloc( 245): ion: Mapped buffer base:0x40057000 size:4096 fd:90 D/qdmemalloc( 245): ion: unmap\_buffer base:0x0 size:1835008 offset:0 fd:75 D/qdmemalloc( 245): ion: unmap\_buffer base:0x0 size:4096 offset:0 fd:90 E/MP-Decision( 1509): num online cores: 1 reqd : 2 available : 4 rq\_depth:1.4000 00 hotplug\_avg\_load\_dw: 72 E/MP-Decision( 1509): UP cpu:1 core\_idx:1 Nw:1.900000 Tw:140 total\_time\_up:0.000 000 D/dalvikvm( 679): GC\_FOR\_ALLOC freed 1432K, 20% free 85121K/105812K, paused 191 ms, total 191ms D/SensorManager(25676): unregisterListener:: D/Sensors (25676): Remain listener = Sending .. normal delay 200ms I/Sensors (25676): sendDelay --- 200000000 I/SensorService( 679): info.selectDelay() ns=20000000 D/SensorService( 679): SensorDevice::setDelay, Return(true 1, false 0) = 1 D/SensorManager(25676): JNI - sendDelay I/SensorManager(25676): Set normal delay = true D/SensorService( 679): SensorDevice::activating sensor handle=0 ns=20000000 W/ContextImpl( 679): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1336 com.android.server.am.Activity Stack.startPausingLocked:1315 com.android.server.am.ActivityStack.resumeTopActiv ityLocked:2377 com.android.server.am.ActivityStack.resumeTopActivityLocked:2163 com.android.server.am.ActivityStack.resumeTopActivityLocked:2149
Hi Jose,
Did you publish your app?, i was facing similar issue, but once i published my app (as alpha) everything worked fine.
Hey, Jose
Look it might be confusing. There are a lot of reasons why this error can happen. The log is not helpful as it may seem to many people.
Most errors shown if not all has nothing to do with your problem or your app at all.
I kind of struggled with it until I solved my problem, which was actually very simple and ediotic mistake by my part.
What I learned that may cause this error:
1- Make sure you have published your app in beta or alpha version. don’t just upload it. press the publish button.
2- Make sure you ‘Activate’ your in-app purchases Items.
3- The names of your items in the shop must!!! match the names of your items when you call for ‘purchase’. (e.g. “com.mycompany.myapp.item_a”. that was my mistake.)
4- maybe this has nothing to do with that but make sure to publish and build under different app name than your other apps, and use a new keystore for it. (just create one with ‘keytool’, it is pretty easy).
As far as I can remember those where some of the problems I managed to look up while trying to solve mine. good luck.
thanks nischal.srinivas and thanks smithsun00 for the detailed reply.
I already have my app published for beta.
How do I activate the in-app purchase items? I already have a list of them but I can’t find where to activate, or maybe I already did.
In the code I’m calling the “purchase” item with “com.mycompany.myapp.item_a”, but I inserted my products in the console with only the name “item_a”. Is that a problem? Do I really need to give every item the name “com.mycompany.myapp.item_a”?
And I’m pretty sure my app is not making conflict with the others, they are very different.
Thanks again everyone.
Yes Jose.
you need to give your items the exact same name. on both side with full “com.company.game.item_a”.
I think that is your problem. try it out.
Ok, so all the items added to the console must have a product id like “com.company.game.item_a”? Or is that the title?
All my products have id like “item_a”, but I’m calling purchases operation like “com.company.game.item_a”. If I call the purchase operation with “item_a” will it work? Or do I really need the id like “com.company.game.item_a”? If it is, it will take me some hours to test it after adding them.
I think both ways should work. Try this: make a dummy/fake item, which is just a regular item on the store but only for testing porpuses.
make two of them. one with only the name of the item, the other with the full “com.company.game.item_a”. Inside your code
when calling for purchase - insert the exact name you used in the store. Test them after the are being created (that should take normally a couple of hours, maybe less until store is updated with your items and updates). In your code, just comment out a normal item you are selling and place the test items’ name. After you are done testing, just remove the test items from the store and use what worked best for you.
Thank you so much smithsun00, it worked! The product id needed to be the full app id and name.
No problem. I had the same problem, and went crazy while trying to figure out what I did wrong. It was just when I was about to release my game and took me like 3 weeks to find out that little mistake that got away under my nose.
Good luck.
Ok, I have another problem now. The transaction callback is only acessed when I cancel a purchase, it is never called when I buy or restore…
I have been there!
Ok first things first,
When you try to restore you will get a call back only if you have already purchased the item, otherwise you will not get a call back.
And i dont see why you will not get a callback for purchase, perhaps can you put your code here, so that we can actually see what are you doing wrong