In app purchases, help needed

put in print(‘i am here-1’),print(‘i am here-2’) throughout your code to see if you can trace back which code is being executed.

better example insert into correct functions

 print('@ restorePurchases')  
 print('@ setupMyStore')  
 print('@ startStore')  

also make sure you are logged out of your itunes account goto/settings/store/logout.

run the app and see if you get a log-in box when the restorePurchases executes.
http://developer.anscamobile.com/forum/2012/02/11/storeinit-transactioncallback-never-invoked

“I had mistakenly (from a previous test) redefined the init callback further down in the code, and that one got invoked instead of the one I was looking at. cheez… :S”
[import]uid: 89663 topic_id: 16336 reply_id: 109791[/import]

Ok, I’ll do that, right now is super late for me and I need to get some sleep but I’ll try that and also as the link you posted suggests, try to get the inapp purchase demo running first with my own products to make sure there’s not anything bad on iTunes Connect.

Just wanted to say THANK YOU again for putting some of your time into this, really appreciated!

I’ll let you know how it goes tomorrow. [import]uid: 13811 topic_id: 16336 reply_id: 109792[/import]

no worries, you caught me at a good time i needed to add iap to my new app. I also really know what is like when you can’t get something to work that is suppose to, it is UBER Frustrating:)

  1. Deleted iTunes U
  2. Updated to iOS 5.1
  3. Installed iTunes U

Client itunesstored is background application

https://discussions.apple.com/thread/3783457?start=0&tstart=0
[import]uid: 89663 topic_id: 16336 reply_id: 109793[/import]

your code works for me! we will be able to figure it out:)

first make sure you have this in the top line of your code

 io.output():setvbuf('no')  

then view all your output in xcode/organizer/console

then make sure the store is unpacking properly

  
local unpackValidProducts = function()  
  
 for i=1, #validProducts do  
   
 print("validProducts = "..i..": ".. tostring(validProducts))  
 print("validProducts"..i..".title = " .. tostring(validProducts[i].title))  
 print("validProducts"..i..".description = " .. tostring(validProducts[i].description))  
 print("validProducts"..i..".price = " .. tostring(validProducts[i].price))  
 print("validProducts"..i..".productIdentifier = " .. tostring(validProducts[i].productIdentifier))  
 print("---------------------------")  
   
 end  
  
end  

then fix this code to match the listproducts

  
 if (transaction.productIdentifier == "product1") then  
  

beware if you test bought something 50 times, on store.restore the transaction callback will fire 50 times, which might crash your app

here is the buy button code

  
local function iap\_buyItem( item )  
  
 if store.canMakePurchases then  
  
 store.purchase( {item} )  
  
 else  
  
 native.showAlert("Store purchases are not available, please try again later", { "OK" } )  
 --F.func\_msg(" @ Store purchases are not available, please try again later", { "OK" } )  
  
 end  
  
end--end function  
  
 --\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
--testBuy // button  
  
local function touch\_buy (event)  
  
 if event.phase=="ended" then  
  
 print('buy item')  
 iap\_buyItem (listOfProducts[1])  
 end--end phase  
  
end  
--\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
--button for test buy  
  
local btnRelease = display.newRect( 0, 0, 320, 90 )  
btnRelease:setReferencePoint(display.TopLeftReferencePoint)  
btnRelease.x = 0  
btnRelease.y = 100  
btnRelease:setFillColor(255,0,0)  
btnRelease.alpha = 0.4  
  
btnRelease.isVisible = true  
btnRelease:addEventListener( "touch", touch\_buy )  
  
  

and i start the store every time when the app loads with this

  
 timer.performWithDelay(1000, startStore)  
 timer.performWithDelay(2000, setupMyStore)  
 timer.performWithDelay(3000, restorePurchases)  
  

[import]uid: 89663 topic_id: 16336 reply_id: 109769[/import]

Ok… back in the work again, I had a complicated day yesterday and wasn’t able to get back into the app, sorry U_U

I’ve been putting print(“whatever”) messages almost everywhere and I can assure the button works and fires the purchase, but the callback doesn’t fire at all.

I can’t try Corona’s test project as it just crashes right on the start so I’ll have to work with my app only…

What I can show is all console messages fired since the app starts to where i try to make a purchase, also notice that I don’t have iTunes U installed and I’m using iOS 5.1.1

I’ve changed the app name to COM.MYDOMAIN.MYAPP, it’s ok in my console and fits my true app.

APP START

>
Jun 3 14:56:24 unknown COM.MYDOMAIN.MYAPP[1186] : libMobileGestalt computeUniqueDeviceID: total time for bb to return imei: 0
Jun 3 14:56:24 unknown COM.MYDOMAIN.MYAPP[1186] : libMobileGestalt computeUniqueDeviceID: total time for bb to return imei: 0
Jun 3 14:56:24 unknown UIKitApplication:COM.MYDOMAIN.MYAPP[0x6dc8][1186] : AudioStreamBasicDescription: 2 ch, 44100 Hz, ‘lpcm’ (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved
Jun 3 14:56:24 unknown kernel[0] : launchd[1186] Builtin profile: container (sandbox)
Jun 3 14:56:24 unknown kernel[0] : launchd[1186] Container: /private/var/mobile/Applications/EC499FEB-5D2F-4637-8147-F99BD038DB77 [69] (sandbox)
>
Jun 3 14:56:35 unknown CommCenter[57] : kDataAttachStatusNotification sent, wasAttached: 1 isAttached: 1
> >

PUSHING BUY BUTTON

Jun 3 14:56:41 unknown wifid[13] : WiFi:[360421001.020933]: Client itunesstored is background application
> >
Jun 3 14:57:08 unknown UIKitApplication:COM.MYDOMAIN.MYAPP[0x6dc8][1186] : AudioStreamBasicDescription: 2 ch, 44100 Hz, ‘lpcm’ (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved
> >
Jun 3 14:57:41 unknown UIKitApplication:COM.MYDOMAIN.MYAPP[0x6dc8][1186] : AudioStreamBasicDescription: 2 ch, 44100 Hz, ‘lpcm’ (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved
> [import]uid: 13811 topic_id: 16336 reply_id: 109986[/import]

Hell yeah!!! I found it!!! I missed one place to put the print message in… wow this is so dumb…

NEVER EVER use store.canMakePurchases to check wether to call store.init() or not!!! That was my problem. It looks like it’s false until you call store.init() so THANKS AGAIN for your help, now my UBER frustration just went away :wink:

Oh, and one more thing, if you want to get some healthy UBER frustration get a ride into ChocoRun! hahaha :smiley: [import]uid: 13811 topic_id: 16336 reply_id: 109995[/import]