In-app purchase - getting nowhere please help!

Ok - I have read almost every topic, tutorial and documentation I can find and I can't see what I'm doing wrong :-/

I have:

- Set up my app on ITC, submitted a binary and rejected it.
- Set up my IAP on ITC, currently at 'waiting for screenshot' status
- Built and installed to device using an adhoc provisioning profile

Here is my code. The loadProducts function doesn't seem to be firing at all - I have debug text fields that aren't getting up updated. How do I know if store.init() is being called or not?

I'm aware the IAP can take a while to filter through the system, but surely I should be getting some dialog boxes telling me I have invalid products?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
store = require("store")
 
local listOfProducts = { 
       "KP0001",
}
 
local price = {"£0.69"}
local desc = {"Test Description"}
   
 
    local validProducts, invalidProducts = {}, {}
    
    function unpackValidProducts()
    myText[9].text  = "Unpack fired"
        print ("Loading product list")
        if not validProducts then
            native.showAlert( "In-App features not available", "initStore() failed", { "OK" } )        
        else
            for i=1, #invalidProducts do
                native.showAlert( "Item " .. invalidProducts[i] .. " is invalid.",{ "OK" } )
            end
 
        end
    end
    
    function loadProductsCallback( event )
        validProducts = event.products
        price[1] = validProducts[1].price
        desc[1] = validProducts[1].description
 
        myText[5].text = price[1]
        myText[6].text = desc[1]
        myText[7].text = "Load products fired"
 
        invalidProducts = event.invalidProducts    
        unpackValidProducts ()
    
        end
        
        function savePurchase(product)
                --function on what should be save when user buy a product
        end
 
        function transactionCallback( event )
        if event.transaction.state == "purchased" then 
           savePurchase("product") --you should enter here the product being purchased
        elseif event.transcation.state == "restored" then  
           savePurchase("product") --you should enter here the product being purchased
        elseif event.transaction.state == "cancelled" then
        elseif event.transaction.state == "failed" then        
            infoString = "Transaction failed, type: ", event.transaction.errorType, event.transaction.errorString
            local alert = native.showAlert("Failed ", infoString,{ "OK" })
        else
            infoString = "Unknown event"
            local alert = native.showAlert("Unknown ", infoString,{ "OK" })
        end
        store.finishTransaction( event.transaction )
        end
 
        function setupMyStore (event)
                store.loadProducts( listOfProducts, loadProductsCallback )
        end
 
    store.init(transactionCallback)
   timer.performWithDelay (1000, setupMyStore)

Just tried building the InAppDemo example....it just hangs on the title screen, building with both 591 and 732.

In the xCode console, it says 'waiting for callback'.

Hey, @nick_sherman, I'm wondering if your listOfProducts matches with what you have created in iTunes Connect. Mine looks more like: "com.mycompany.mygamename.myproductforsale" (This may not be your problem at all, but I thought I'd mention.)

You might also want to add bunch of print statements. When I was debugging my IAP, I added print statements everywhere. Almost every line of code had print statement in front of it for me to see how far my code executes. In my case, my code simply didn't execute far enough to even receive invalid product warning. It turned out that all I needed to do was to build the app using AdHoc certificate. All went smooth once I build my app with a valid AdHoc certificate.

If you have products properly made in iTunes Connect, building your app using AdHoc certificate and testing on a device (which is not a jail broken device), you should be able to see some lines of print statements (on Xcode console) to let you know which line of code is causing you grief.

I hope you'll make a good progress soon. Gook luck!

Naomi

@nick_sherman: The InAppDemo works great for me and I'm also using build 732--did you try replacing the product IDs with yours? My suggestion is to use something like "com.companyname.itemname" like what Naomi suggested.

views:1287 update:2012/2/9 11:37:26
corona forums © 2003-2011