hi guys,
i have a function written in VB.NET … this function calls a payment gateway … it is working perfectly
i want to run the same code using corona … but i’m not sure how to do it exactly
this is the VB.NET code … all you need is a windows form and a button inside the form … it will run smoothly
Imports System.Net Imports System.Text Imports System.IO Imports System.Web Public Class Form1 Private Sub Button1\_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim responseData responseData = Request()("result")("description") MsgBox(responseData) End Sub Public Function Request() As Dictionary(Of String, Object) Dim url As String = "https://test.oppwa.com/v1/checkouts" Dim data As String = "" + "authentication.userId=8a8294174d0595bb014d05d829e701d1" + "&authentication.password=9TnJPc2n9h" + "&authentication.entityId=8a8294174d0595bb014d05d82e5b01d2" + "&amount=92.00" + "¤cy=EUR" + "&paymentType=DB" Dim req As WebRequest = WebRequest.Create(url) req.Method = "POST" req.ContentType = "application/x-www-form-urlencoded" Dim byteArray As Byte() = Encoding.UTF8.GetBytes(data) req.ContentLength = byteArray.Length Dim dataStream As Stream = req.GetRequestStream() dataStream.Write(byteArray, 0, byteArray.Length) dataStream.Close() Dim res As WebResponse = req.GetResponse() Dim resStream = res.GetResponseStream() Dim reader As New StreamReader(resStream) Dim response As String = reader.ReadToEnd() reader.Close() resStream.Close() res.Close() Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer() Dim dict As Dictionary(Of String, Object) = jss.Deserialize(Of Dictionary(Of String, Object))(response) Return dict End Function End Class
this is the code in lua but still not complete and not working … i’m not sure what is the equivalent to bytes array and where to put data variable in body or where …etc.
local headers = {} headers["accept"] = "application/json"; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept-Language"] = "en-US"; local data1="\n".."authentication.userId=8a8294174d0595bb014d05d829e701d1".."\n".."&authentication.password=9TnJPc2n9h".."\n".."&authentication.entityId=8a8294174d0595bb014d05d82e5b01d2".."\n".."&amount=92.00".."\n".."¤cy=EUR".."\n".."&paymentType=DB" local function networkListener( event ) -- local function that connects to webservice and get next available prize, for this game, for current Prize\_Val\_ID Reached which is between 1 and X... if ( event.isError ) or event.response==nil then else print(event.response) end end local body = "" local params = {} params.headers = headers params.body = body network.request( "https://test.oppwa.com/v1/checkouts", "POST", networkListener, params )