Advertisement
Guest User

LuaPay API v0.1

a guest
Jun 13th, 2013
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. --
  2. -- LuaPay API
  3. -- Imque 2013
  4. --
  5.  
  6. local _tGeneric = {
  7.   _sVersion = "LuaPay API v0.1";
  8.   _sURL = "http://imque.koding.com/luapay/index.php";
  9. }
  10.  
  11. function version()
  12.   return _tGeneric._sVersion
  13. end
  14.  
  15. function login(user, pass)
  16.   http.request(_tGeneric._sURL .. "?function=login&username=" .. textutils.urlEncode(user) .. "&password=" ..
  17.  
  18. textutils.urlEncode(pass))
  19.   local _sEvent, _sUrl, _sResponse = os.pullEvent("http_success")
  20.   local _sResponse = _sResponse.readAll()
  21.   if _sResponse:find("deprecated") then
  22.     return true, user
  23.   end
  24.   return false, _sResponse
  25. end
  26.  
  27. function changepass(user, pass, newpass)
  28.   http.request(_tGeneric._sURL .. "?function=changepassword&username=" .. textutils.urlEncode(user) .. "&password=" ..
  29.  
  30. textutils.urlEncode(pass) .. "&newpassword=" .. textutils.urlEncode(newpass))
  31.   local _sEven, _sUrl, _sResponse = os.pullEvent("http_success")
  32.   local _sResponse = _sResponse.readAll()
  33.   if _sResponse:find("changed") then
  34.     return true, user
  35.   end
  36.   return false, _sResponse
  37. end
  38.  
  39. function pay(user, pass, touser, amount)
  40.   http.request(_tGeneric._sURL .. "?function=pay&username=" .. textutils.urlEncode(user) .. "&password=" ..
  41.  
  42. textutils.urlEncode(pass) .. "&toaccount=" .. textutils.urlEncode(touser) .. "&amount=" .. textutils.urlEncode(amount))
  43.   local _sEven, _sUrl, _sResponse = os.pullEvent("http_success")
  44.   local _sResponse = _sResponse.readAll()
  45.   if _sResponse:find(user) then
  46.     return true, user
  47.   end
  48.   return false, _sResponse
  49. end
  50.  
  51. function balance(user, pass)
  52.   http.request(_tGeneric._sURL .. "?function=balance&username=" .. textutils.urlEncode(user) .. "&password=" ..
  53.  
  54. textutils.urlEncode(pass))
  55.   local _sEvent, _sUrl, _sResponse = os.pullEvent("http_success")
  56.   local _sResponse = _sResponse.readAll()
  57.   if not _sResponse:find("Bad") then
  58.     return _sResponse, user
  59.   end
  60.   return false, _sResponse
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement