Using Playduration for payment

I tried doing the following … but not quite right I do not think … anyone have some input on what I should do ??


'Set Default screen values for items not in feed
        item.HDBranded = false
        item.IsHD = false
        item.StarRating = "90"
        item.ContentType = "episode"
        item.cost = "0"
        
        
        if item.cost = 0 then
            item.PlayDuration = "60"
        else
            funds = tokenValidation()
        
            if funds = 1 then 
                item.PlayDuration = item.PlayDuration
                chargeCustomer() 
            else
                item.PlayDuration = "0"
            end if
        end if
        
        'media may be at multiple bitrates, so parse an build arrays
        for idx = 0 to 4
            e = curShow.media[idx]
            if e  <> invalid then
                item.StreamBitrates.Push(strtoi(validstr(e.streamBitrate.GetText())))
                item.StreamQualities.Push(validstr(e.streamQuality.GetText()))
                item.StreamUrls.Push(validstr(e.streamUrl.GetText()))
            endif
        next idx
        
        showCount = showCount + 1
        feed.Push(item)

        skipitem:

    next

End Function

function tokenValidation() As Integer  
  sn = GetDeviceESN()
  xfer = CreateObject("roURLTransfer")
  xfer.SetURL("http://allbabestv.com/roku/getCredits.php?deviceID=" + sn)
  response = xfer.GetToString()
  xml = CreateObject("roXMLElement")
  if xml.Parse(response)
    if (xml.tokens > item.cost)
      return 0
    end if
  end if
    return 1
end function

function chargeCustomer()
  sn = GetDeviceESN()
  cost = item.cost
  model = item.ContentId
  xfer = CreateObject("roURLTransfer")
  xfer.SetURL("http://allbabestv.com/roku/chargeCustomer.php?deviceID=" + sn + "&cost=" + cost + "&model=" + model)
  response = xfer.GetToString()
end function