Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
bosborne
Visitor

Products not appearing

I'm getting started developing a channel w/ in app purchases. I have a demo private channel that has been published. I have 4 products associated with it, and the Roku UI indicates they have been approved.

The problem is when I go to retrieve the catalog in the app, it appears empty. When I test the channel as a side-loaded channel, the test products appear as expected, so I'm not sure there's an issue with the code.

Again, the channel is published, and all 4 products are also published and approved for sale.

I've attached the relevant code. Can anyone see any problems with it?


Function showDonateScreen()
port = CreateObject("roMessagePort")
screen = CreateObject("roParagraphScreen")
screen.setMessagePort(port)
screen.setTitle("Donate")
screen.addButton(0, "Select amount")
screen.addButton(1, "Cancel")
screen.setDefaultMenuItem(0)
screen.show()

while true
msg = wait(0, screen.getMessagePort())
if type(msg) = "roParagraphScreenEvent"
if msg.isButtonPressed()
if msg.getIndex() = 0
showDonationAmountScreen()
else
screen.close()
exit while
end if
else if msg.isScreenClosed() then
print "Poster Screen Closed!"
exit while
end if
end if
end while
End Function

Function showDonationAmountScreen()
port = CreateObject("roMessagePort")
screen = CreateObject("roListScreen")
screen.setMessagePort(port)
screen.setTitle("Select Donation Amount")

store = CreateObject("roChannelStore")
store.setMessagePort(port)

catalog = getCatalog(store)
if catalog = invalid
return -1
end if

items = createContentListFromProducts(catalog)
screen.SetContent(items)
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roListScreenEvent" then
if msg.isListItemSelected() then
index = msg.GetIndex()
if makePurchase(store, catalog[index]) = true
' Close screen if completed transaction
screen.Close()
exit while
end if

else if msg.isScreenClosed() then
print "Poster Screen Closed!"
exit while
end if
end If
end while
End Function

Function getCatalog(store)
print "***** Catalog *****"
waitMsg = ShowPleaseWait()
store.GetCatalog()
while true
msg = wait(0, store.getMessagePort())
waitMsg.close()
if (type(msg) = "roChannelStoreEvent")
if (msg.isRequestSucceeded())
dumpResponse(msg.GetResponse())
return msg.GetResponse()
exit while
else if (msg.isRequestFailed())
ShowDialog1Button("Connection Failure", "There was a problem connecting to the server. Please try again lister.", "Ok")
print "***** Failure: " + msg.GetStatusMessage() + " Status Code: " + stri(msg.GetStatus()) + " *****"
return invalid
end if
end if
end while
End Function

Function createContentListFromProducts(items)
i = 0
list = []
for each item in items
i = i+1
list_item = {
Title: item.name
ID: stri(i)
code: item.code
cost: item.cost
}
list.Push(list_item)
end for

return list
End Function

Function makePurchase(store, product)
order = [{
code: product.code
qty: 1
}]
print "***** Placing Order, item code: " + toStr(order[0].code) + " quantity: " + toStr(order[0].qty)
val = store.SetOrder(order)
waitMsg = ShowPleaseWait()
res = store.DoOrder()
waitMsg.close()
if res = true
ShowDialog1Button("Transaction Complete", "Thank you!", "Continue")
return true
else
ShowDialog1Button("Transaction Failed", "Unable to complete transaction.", "Continue")
return false
end if
End Function

Function dumpResponse(list as object)
for each obj in list
for each element in obj
print toStr(element) + " = " + toStr(obj.lookup(element))
end for
end for
End Function
0 Kudos
5 REPLIES 5
bosborne
Visitor

Re: Products not appearing

Gah, nevermind. I misunderstood the meaning of "Cleared for sale" vs "pending approval". They are all still pending approval.
0 Kudos

Re: Products not appearing

"bosborne" wrote:
Gah, nevermind. I misunderstood the meaning of "Cleared for sale" vs "pending approval". They are all still pending approval.

How long it took for the products to appear after approval for you? Mine is approved but still GetCatalog returns nothing.
0 Kudos

Re: Products not appearing

"scorpiontahir02" wrote:
How long it took for the products to appear after approval for you? Mine is approved but still GetCatalog returns nothing.


OK, got the products after a little while.
0 Kudos
EnTerr
Roku Guru

Re: Products not appearing

"scorpiontahir02" wrote:
How long it took for the products to appear after approval for you? Mine is approved but still GetCatalog returns nothing.

I am wondering the same, it's not documented or anything - so can someone give me ballpark idea of how long it takes for creation to spread - is it minutes or hours? Same thing for updates to existing product, i presume?
0 Kudos

Re: Products not appearing

I've been facing this problem.Waiting for some time to get updated count of products didn't worked for me. getCatalog command always returned 0 product count. But when I tried making ChannelStore node in XML rather than doing it programmatically,
 m.store = CreateObject("roSGNode", "ChannelStore")

It returned the correct count of products.
0 Kudos