我想将CCavene融入android应用程序

时间:2019-07-12 13:58:40

标签: c# android .net-core asp.net-core-webapi

我致力于将ccavenue集成到android应用程序中。当请求来自android应用程序时,我们需要处理该请求并给出响应RSA密钥。使用该密钥,交易将完成。但是ccavenue提供了ASP.net的示例代码。我不知道如何将api核心化为该请求处理。

我尝试了核心webapi 2.0

       public IActionResult GetRSA()
       {

        try
        {
            string queryUrl = "https://secure.ccavenue.com/transaction/getRSAKey";
            string vParams = "";
            foreach (string key in Request.Params.AllKeys)
            {
                vParams += key + "=" + Request[key] + "&";
            }
            // Url Connection
            String message = postPaymentRequestToGateway(queryUrl, vParams);
            Response.WriteAsync(message);
        }
        catch (Exception exp)
        {
            Response.WriteAsync("Exception " + exp);
        }

        return Ok();
       }

    private string postPaymentRequestToGateway(String queryUrl, String urlParam)
    {
        String message = "";
        try
        {
            StreamWriter myWriter = null;// it will open a http connection with provided url
            WebRequest objRequest = WebRequest.Create(queryUrl);//send data using objxmlhttp object
            objRequest.Method = "POST";
            //objRequest.ContentLength = TranRequest.Length;
            objRequest.ContentType = "application/x-www-form-urlencoded";//to set content type
            myWriter = new System.IO.StreamWriter(objRequest.GetRequestStream());
            myWriter.Write(urlParam);//send data
            myWriter.Close();//closed the myWriter object

            // Getting Response
            System.Net.HttpWebResponse objResponse = (System.Net.HttpWebResponse)objRequest.GetResponse();//receive the responce from objxmlhttp object 
            using (System.IO.StreamReader sr = new System.IO.StreamReader(objResponse.GetResponseStream()))
            {
                message = sr.ReadToEnd();
            }
        }
        catch (Exception exception)
        {
            Console.Write("Exception occured while connection." + exception);
        }
        return message;
    }

上面的代码将在点网框架上运行,而在Dotnet核心上将无法运行

0 个答案:

没有答案