Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not fs.exists("/.pay_card") then
- print("Let me guide you through first time setup now...")
- if not fs.exists("/paym.lua") then
- print("Downloading PAYM")
- shell.run("pastebin get JQALyCL6 paym")
- os.loadAPI("paym")
- end
- print("Card number")
- local cardnum = read()
- print("CVV?")
- local cvv = read("*")
- print("PIN?")
- local pin = read("#")
- print("Verifying details...")
- local info = paym.verify(cardnum, cvv, pin)
- for i, v in pairs(info) do
- if v == false then
- error(i .. " invalid.")
- end
- end
- local data = {
- num = cardnum,
- cvv = cvv,
- pin = pin
- }
- local handle = fs.open("/.pay_card","w")
- handle.write(textutils.serialise(data))
- handle.close()
- end
- os.loadAPI("paym")
- local handle = fs.open("/.pay_card","r")
- local pdata = textutils.unserialise(handle.readAll())
- handle.close()
- function mm()
- term.clear()
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setTextColor(colors.blue)
- local w,h = term.getSize()
- term.setCursorPos((w - 7) / 2,1)
- term.write("QuikPay")
- term.setCursorPos(1,3)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.green)
- term.write(" Get paid ")
- term.setCursorPos(1,5)
- term.setBackgroundColor(colors.orange)
- term.write(" Pay someone ")
- term.setCursorPos(1,7)
- term.setBackgroundColor(colors.red)
- term.write(" Exit ")
- while true do
- local _, _, _, y = os.pullEvent("mouse_click")
- if y == 3 then
- return 0
- end
- if y == 5 then
- return 1
- end
- if y == 7 then
- error("Terminated",2)
- end
- end
- end
- function dr()
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.black)
- print("Amount?")
- local amount = tonumber(read())
- if not amount then
- error("Invalid amount")
- end
- print("Reason?")
- local reason = read()
- local ok, id = paym.initContactless(amount, pdata.num, reason)
- if ok == false then
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- error(id)
- end
- while true do
- print("ID: " .. id)
- print("Press any key to verify")
- os.pullEvent("char")
- local ok, data = paym.checkContactless(id)
- if data.paid == true then
- print("Paid!")
- break
- else
- print("Not yet paid")
- end
- end
- end
- function pay()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos(1,1)
- term.clear()
- print("Payment ID")
- local id = read()
- print("Contacting API")
- local ok, data = paym.checkContactless(id)
- if ok == false then
- error(data)
- end
- for i,v in pairs(data) do
- print(i .. ":" .. tostring(v))
- end
- print("To pay, press \"Y\", else press any key")
- local _,c = os.pullEvent("char")
- if c == "y" or c == "Y" then
- print("Paying")
- local ok, data = paym.payContactless(pdata.num, pdata.cvv, pdata.pin, id)
- if ok == false then
- error(data)
- end
- print("Paid")
- end
- end
- while true do
- x = mm()
- if x == 0 then
- dr()
- else
- pay()
- end
- end
Add Comment
Please, Sign In to add comment