RequestNVP createNVP() { RequestNVP nvp = new RequestNVP(); nvp.Version = version; nvp.User = user; nvp.Password = pswd; nvp.Signature = signature; return nvp; }
ResponseNVP execute(RequestNVP requestNvp) { StringBuilder spec = new StringBuilder("https://"); spec.Append(_sandbox ? PAYPAL_SANDBOX : PAYPAL_HOST); spec.Append("/nvp"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(spec.ToString()); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; using (Stream stream = request.GetRequestStream()) { UTF8Encoding encoding = new UTF8Encoding(); byte[] bytes = encoding.GetBytes(requestNvp.ToString()); stream.Write(bytes, 0, bytes.Length); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); ResponseNVP responseNvp; using (Stream stream = response.GetResponseStream()) { using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) { string result = reader.ReadToEnd(); responseNvp = (ResponseNVP)result.ToString(); } } return responseNvp; }
public Operation(ExpressCheckoutApi ec) { this.ec = ec; requestNVP = ec.createNVP(); }