private static WebRequest GetWebRequest(string url, string method, string postData)
        {
            var request = HttpWebRequest.Create(url) as HttpWebRequest;

            request.Method      = method;
            request.ContentType = "application/x-www-form-urlencoded";
            request.UserAgent   = "C# API Wrapper v001";

            string apiKey = PinPaymentsConfig.GetApiKey();

            request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(apiKey + ":"));

            if (postData != "")
            {
                var paramBytes = Encoding.UTF8.GetBytes(postData);
                request.ContentLength = paramBytes.Length;

                var requestStream = request.GetRequestStream();
                requestStream.Write(paramBytes, 0, paramBytes.Length);
            }
            return(request);
        }
Exemplo n.º 2
0
        private static WebRequest GetWebRequest(string url, string method, string postData)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            var request = HttpWebRequest.Create(url) as HttpWebRequest;

            request.Method      = method;
            request.ContentType = "application/x-www-form-urlencoded";
            request.UserAgent   = "C# API Wrapper v001 - otron.com Fork";

            string apiKey = PinPaymentsConfig.GetApiKey();

            request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(apiKey + ":"));

            if (!string.IsNullOrEmpty(postData))
            {
                var paramBytes = Encoding.UTF8.GetBytes(postData);
                request.ContentLength = paramBytes.Length;

                var requestStream = request.GetRequestStream();
                requestStream.Write(paramBytes, 0, paramBytes.Length);
            }
            return(request);
        }
Exemplo n.º 3
0
 public PinService(string pinKey)
 {
     PinPaymentsConfig.SetApiKey(pinKey);
 }
Exemplo n.º 4
0
 public PinService(string pinKey)
 {
     PinPaymentsConfig.SetApiKey(pinKey);
     ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
 }