예제 #1
0
        public static String QueryStringForTR(Request trParams, Request req, String postURL, BraintreeService service)
        {
            String trData = TrUtil.BuildTrData(trParams, "http://example.com", service);
            String postData = "tr_data=" + HttpUtility.UrlEncode(trData, Encoding.UTF8) + "&";
            postData += req.ToQueryString();

            var request = WebRequest.Create(postURL) as HttpWebRequest;

            request.Method = "POST";
            request.KeepAlive = false;

            byte[] buffer = Encoding.UTF8.GetBytes(postData);
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = buffer.Length;
            Stream requestStream = request.GetRequestStream();
            requestStream.Write(buffer, 0, buffer.Length);
            requestStream.Close();

            var response = request.GetResponse() as HttpWebResponse;
            String query = response.ResponseUri.Query;

            response.Close();

            return query;
        }