Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
athi_joy
Level 7

product is not listing in channel store catalog

Hi There,

I have a public channel that contains 4 channel-in-product. in the dashboard it's cleared for sale is yes,  status is also approved. but  m.store.catalog count is 0. why? I also tried making ChannelStore node in XML rather than doing it programmatically, still not getting the product in the catalog.

0 Kudos
4 Replies
RokuJonathanD
Roku Employee
Roku Employee

Re: product is not listing in channel store catalog

Hi @athi_joy

Are you still getting not getting any products returned by the getCatalog ChannelStore command. If so, can you please provide your XML and BrightScript code so we can debug this.

0 Kudos
athi_joy
Level 7

Re: product is not listing in channel store catalog

subscriptionScreen.brs 

function init()
m.lblBestOffer= m.top.findNode("lblBestOffer")
m.lblTxtMsg= m.top.findNode("lblTxtMsg")
m.lblNoSubscriptionMsg = m.top.findNode("lblNoSubscriptionMsg")
m.productGrid = m.top.FindNode("productGrid")
m.top.ObserveField("visible", "onVisibleChange")
m.productGrid.ObserveField("itemSelected", "onProductSelected")
m.lblBestOffer.font = largeCustomAntonFont()
m.lblNoSubscriptionMsg.font = largeCustomAntonFont()
m.lblTxtMsg.font.size= 20
m.facedeScreen = m.top.findNode("facedeScreen")
m.customDialogBox = m.top.findNode("customDialogBox")
m.btnCancel = m.top.findNode("btnCancel")
m.msg = m.top.findNode("msg")
m.errorCode = m.top.findNode("errorCode")
m.btnOk = m.top.findNode("btnOk")
m.btnOk.ObserveField("buttonSelected","goToReletedScreen")
m.btnCancel.ObserveField("buttonSelected","fnCloseDialog")
end function

function onVisibleChange()
if m.top.visible then
showProgressDialog()
m.dataArray=[]
m.facedeScreen.visible=false
m.customDialogBox.visible=false
callStore()
getSubscriptionApi()
end if
end function

function callStore()
m.store = invalid
m.store = createObject("roSGNode", "ChannelStore")
m.store.ObserveField("catalog", "onGetCatalog")
m.store.ObserveField("purchases", "onGetPurchases")
m.store.observeField("orderStatus", "onOrderStatus")
m.store.ObserveField("userData", "onGetUserData")
end function

function onGetCatalog() as void
data = CreateObject("roSGNode", "ContentNode")
if (m.store.catalog <> invalid)
count = m.store.catalog.GetChildCount()
? "count Child : "count
index = 0
for each item in m.packDataArray
?"item"item
productData = data.CreateChild("ChannelStoreProductData")
if item.id <> invalid then
productData.productId = item.id
if m.global.packageInfo <> invalid then
productData.activatedPack = false
if checkForPackId(item.id) then
productData.activatedPack = true
end if
end if
end if
if item.rockuProductId <> invalid then productData.productCode = item.rockuProductId
if item.packName <> invalid then productData.productName = item.packName
if item.rockuPrice <> invalid then productData.productPrice= item.price
if item.rockuPrice <> invalid then productData.productRokuPrice= item.rockuPrice
end for
m.productGrid.numColumns = 3
m.productGrid.content = data
m.productGrid.setFocus(true)
else
showNoSubscriptionMsg()
end if
dismissProgressDialog()
end function

function checkForPackId(id)
flag = false
for each item in m.global.packageInfo
if item.id = id then
flag = true
exit for
end if
end for
? "flag "flag
return flag
end function

function showNoSubscriptionMsg()
msg = "Error Code : "+(m.global.code).tostr()+chr(10)+m.global.msg
m.lblNoSubscriptionMsg.text = msg
m.lblNoSubscriptionMsg.visible = true
end function

function onProductSelected() as void
showProgressDialog()
index = m.productGrid.itemSelected
m.item_to_purchase = m.productGrid.content.GetChild(index)
?" m.item_to_purchase" m.item_to_purchase
if m.item_to_purchase<> invalid and m.item_to_purchase.productId <> invalid then
if m.global.packageInfo <> invalid
if m.item_to_purchase.productId = m.global.packageInfo[0].id then
msg="Existing subscription package will be replaced"
showCustomDialog(msg,3)
else
msg="Existing subscription package will be replaced"
showCustomDialog(msg,3)
end if
else
msg="Do you want to activate this package?"
showCustomDialog(msg,3)
end if
end if
end function

function onGetUserData() as void
? "Hi i m Called Again onGetUserData"
if (m.store.userData <> invalid)
setUserDataGlobal()
dismissProgressDialog()
MakePurchase()
end if
end function

function setUserDataGlobal()
userSubData = m.store.userData
? "m.store.userData "userSubData
address = userSubData.street1 +", "+userSubData.street2
userSubData={
"emailId":userSubData.email,
"state":userSubData.state,
"zip":userSubData.zip,
"city":userSubData.city,
"country":userSubData.country,
"address": address,
"firstname":userSubData.firstname,
"lastname":userSubData.lastname
}
m.global.removeField("userSubscription")
m.global.addFields({"userSubscription":userSubData})
end function

'This field observer function checks the userData field value to determine if the user consented. If so,
'the purchase is initiated.

function MakePurchase() as void
showProgressDialog()
myOrder = CreateObject("roSGNode", "ContentNode")
product = myOrder.CreateChild("ContentNode")
product.addFields({"code" : m.item_to_purchase.productCode, "qty" : 1})
? "myOrder "product
m.store.order = myOrder
m.store.command = "doOrder"
end function

function onOrderStatus() as void
dismissProgressDialog()
? " onOrderStatus "
orderStatus = m.store.orderStatus
' dialog = CreateObject("roSGNode", "StatusDialog")
if (orderStatus <> invalid ) and (orderStatus.status = 1)
m.store.command = "getPurchases"
item = orderStatus.getChild(0)
else
item = orderStatus.getChild(0)
msg = "Purchase failed !!!"
showCustomDialog(msg,0)
end if
end function

function onGetPurchases() as void
data = CreateObject("roSGNode", "ContentNode")
if (m.store.purchases <> invalid)
count = m.store.purchases.GetChildCount()
for i = 0 to count - 1
m.item = m.store.purchases.GetChild(i)
end for
? item
? "Item Purchased and Now going to store on server DB"
saveRokuPurchaseTransactionID(m.item)
end if
end function

function saveRokuPurchaseTransactionID(item)
showProgressDialog()
baseUrl = getBaseUrl()
url = baseUrl+"packageActivationRequest"
param={}
param = {
"deviceType":"5"
"deviceId": m.global.userDetails.deviceId
"packId": m.item_to_purchase.productId
"userId":m.global.userDetails.userId
"amount": m.item_to_purchase.productPrice
"paymentDate":item.purchaseDate
"paymentCurrency":"USD"
"paymentTranscationId": item.purchaseId
"packOrMovieId":"1"
"paymentStatus": m.store.purchases.status
"country": m.global.userSubscription.country
"name":m.global.userSubscription.firstname
"address": m.global.userSubscription.address
"city": m.global.userSubscription.city
"postCode": m.global.userSubscription.zip
"lastName": m.global.userSubscription.lastname
"gatewayId": "5"
}
? "url : "url
? "param :" param
m.rokuTransactionIdTask = CreateObject("roSGNode", "GetRequestHandler")
m.rokuTransactionIdTask.setField("uri",url)
m.rokuTransactionIdTask.setField("requestType","POST")
m.rokuTransactionIdTask.setField("param",FormatJSON(param,0))
m.rokuTransactionIdTask.ObserveField("content","rokuTransactionIdCallback")
m.rokuTransactionIdTask.control="RUN"
end function

function rokuTransactionIdCallback()
dismissProgressDialog()
m.store = invalid
response = m.rokuTransactionIdTask.content
if response <> invalid then
? "m.global.subscribe "m.global.subscribe
if m.global.subscribe <> invalid and m.global.subscribe = "SignUp" or m.global.subscribe = "SignIn" then
m.global.removeField("doSignIn")
m.global.addFields({"doSignIn":"auto"})
m.top.goToSignIn = true
else
m.top.goToHome = true
end if
else
m.top.goToSignIn = true
end if
dismissProgressDialog()
end function

sub checkNetworkConnected()
isNetworkConnected = hasConnectivity()
if isNetworkConnected = false
showNetworkErrorDialog()
end if
while not isNetworkConnected
showNetworkErrorDialog()
isNetworkConnected = hasConnectivity()
end while
end sub

function onKeyEvent(key,press)
m.top.SetFocus(true)
if press
if key ="back"
m.facedeScreen.visible=false
m.customDialogBox.visible=false
m.btnOk.setFocus(false)
if m.global.subscribe = invalid then
? "m.global.lastScr "m.global.lastScr
if m.global.lastScr = "Account" then
m.global.removeField("lastScr")
m.store = invalid
m.top.goToAccount = true
else
m.store = invalid
m.top.goToHome = true
end if
else if m.global.subscribe = "SignUp" then
m.store = invalid
m.top.goToSignIn = true
else if m.global.subscribe = "SignIn" then
m.store = invalid
m.top.goToHome = true
end if
return true
else if key = "right" then
if m.btnOk.hasFocus() and m.btnOk.text = "Proceed" then
m.btnOk.setFocus(false)
m.btnCancel.setFocus(true)
end if
else if key = "left" then
if m.btnCancel.hasFocus() then
m.btnCancel.setFocus(false)
m.btnOk.setFocus(true)
end if
end if
end if
return false
end function

function getSubscriptionApi()
' showProgressDialog()
baseUrl = getBaseUrl()
url = baseUrl+"getPackageDetails"
param={}
param = {
"deviceType":"5"
"deviceId" : m.global.userDetails.deviceId
}
? "url : "url
? "param :" param
m.contentReader = CreateObject("roSGNode", "GetRequestHandler")
m.contentReader.setField("uri",url)
m.contentReader.setField("requestType","POST")
m.contentReader.setField("param",FormatJSON(param,0))
m.contentReader.ObserveField("content","subscriptionApiCallback")
m.contentReader.control="RUN"
end function

function subscriptionApiCallback()
res = m.contentReader.content
if res<>invalid and len(res) > 0 then
''? "type(res) : "type(res)
if type(res) <> "roAssociativeArray" then
setSubscriptionData(ParseJson(res))
else
setSubscriptionData(res)
end if
else
if m.global.code <> m.timeout then
showNoSubscriptionMsg()
else
handleTimeOut(m.top)
end if
end if
end function

function setSubscriptionData(feeds) as void
m.dataArray=[]
if feeds.packageDetails <> invalid and feeds.packageDetails.count()>0 then
m.packDataArray = feeds.packageDetails
?" m.packDataArray"formatJSON( m.packDataArray)
m.store.command="getCatalog"
else
showNoSubscriptionMsg()
end if
end function

function showCustomDialog(msg,redirectTo=0)
m.redirectTo = redirectTo
wordPosition = 0
if msg = invalid then
msg = "something went wrong"
else
wordPosition = Instr(1, msg, ".")
end if
if wordPosition > 0 then msg = left(msg,wordPosition)
m.msg.text = msg
if m.global.code <> invalid then m.errorCode.text = "Error Code : "+(m.global.code).tostr()
m.msg.font = smallBoldCustomFont()
m.errorCode.font = smallBoldCustomFont()
m.btnOk.focusedTextFont = smallCustomAntonFont()
m.btnOk.textFont = xSmallCustomFont()
if m.redirectTo = 3
m.btnOk.text = "Proceed"
m.btnOk.minWidth = 100
m.btnCancel.minWidth = 100
m.btnCancel.textFont = xSmallCustomFont()
m.btnCancel.focusedTextFont = xSmallCustomFont()
m.btnCancel.visible = true
else
m.btnOk.minWidth = 500
m.btnOk.text = "Ok"
m.btnCancel.visible = false
end if
m.facedeScreen.visible=true
m.customDialogBox.visible=true
m.btnOk.setFocus(true)
dismissProgressDialog()
end function

function goToReletedScreen()
? "Reached to related Screen"
m.productGrid.setfocus(true)
m.facedeScreen.visible=false
m.customDialogBox.visible=false
m.btnOk.setFocus(false)
if m.redirectTo = 0 then
m.top.showHome = true
else if m.redirectTo = 2 then
m.top.goToSignIn = true
else if m.redirectTo = 3 then
' call getDetails command
showProgressDialog()
m.store.requestedUserData="all"
m.store.command = "getUserData"
end if
end function

function fnCloseDialog()
m.facedeScreen.visible=false
m.customDialogBox.visible=false
m.btnOk.setFocus(false)
m.btnCancel.setFocus(false)
m.productGrid.setfocus(true)
end function

 

subscriptionScreen.xml

<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2016 Roku Corp. All Rights Reserved. **********-->


<component name="SubsciptionModule" extends="Group" >

<script type="text/brightscript" uri="pkg:/components/SubscriptionScreen/SubsciptionModule.brs" />
<script type="text/brightscript" uri="pkg:/fonts/fonts.brs" />
<script type="text/brightscript" uri="pkg:/source/utill.brs" />
<interface>
<field id="goToLandingPage" type = "Boolean" alwaysNotify="true"/>
<field id="goToHome" type = "Boolean" alwaysNotify="true"/>
<field id="goToSignIn" type = "Boolean" alwaysNotify="true"/>
<field id="goToAccount" type = "Boolean" alwaysNotify="true"/>
</interface>
<children>
<Group>
<Label
id="lblBestOffer"
horizAlign="center"
width="1900"
text="BEST OFFERS"
color="#d2d861"
font="font:LargeBoldSystemFont"
translation="[0,100]"
/>
<Label
id="lblTxtMsg"
horizAlign="center"
width="1900"
text="our packages are customized with your favourite channels!!!"
color="#eff2f7"
font="fontSmiley FrustratedmallestSystemFont"
translation="[0,165]"
/>
<Label
id="lblNoSubscriptionMsg"
horizAlign="center"
width="1920"
height="80"
text=""
color="#eff2f7"
visible="false"
translation="[0,650]"
/>

<MarkupGrid
id="productGrid"
itemComponentName="ChannelStoreProduct"
itemSize="[600,600]"
itemSpacing="[20, 20]"
rowHeights="[600, 600]"
columnWidths="[600,600,600,600]"
numColumns="3"
numRows="1"
horizFocusAnimationStyle="floatingFocus"
translation="[50, 300]" />

</Group>
<Rectangle id="facedeScreen" color="#000000" height="1080" width="1920" opacity="0.7" translation="[0,0]" visible="false"/>
<Group id="customDialogBox" translation="[610,450]" visible="false">
<Rectangle id="dialogBody" width="700" height="300" color="#4d4d4d" />
<Label id="errorCode" horizAlign="center" width="600" height="40" vertAlign="center" visible="true" translation="[50, 40]"/>
<Label id="msg" horizAlign="center" width="600" vertAlign="center" visible="true" translation="[50, 80]"/>
<Button id = "btnOk" text = "Ok" showFocusFootprint = "true" height="60" minWidth = "600" translation="[150,200]"/>
<Button id = "btnCancel" text = "Cancel" showFocusFootprint = "true" height="60" minWidth="80" translation="[375,200]" visible="false"/>
</Group>
</children>
</component>

0 Kudos
athi_joy
Level 7

Re: product is not listing in channel store catalog

Hi @RokuJonathanD 

My public channel has 4 channel in products.

The products are cleared for sale is YES and the status is ACTIVE.

the account is successfully registered in Roku partner payout. 

product is assigned to the channel which product is available for sale.

using a test account I'm able to purchase. when I use a customer account not able to purchase product showing order problem 6. while debugging I figured out when a customer tries to purchase channel catalog count is empty.  What is the reason behind this?

0 Kudos
RokuJonathanD
Roku Employee
Roku Employee

Re: product is not listing in channel store catalog

What's your channel? Can you share the vanity URL so I can install it and try?

0 Kudos