//private bool Swipe(CreditCard cc) //{ // return (true); //***EAC This routine is no longer necessary // if (this.cc.Cost > 0.0) // { // string APPROVED = "<ssl_result_message>APPROV"; // // string xmldata = "xmldata=<txn><ssl_merchant_ID>502928</ssl_merchant_ID><ssl_user_id>webform</ssl_user_id><ssl_pin>PK0GAL</ssl_pin><ssl_transaction_type>ccsale</ssl_transaction_type><ssl_card_number>5000300020003003</ssl_card_number><ssl_exp_date>1209</ssl_exp_date><ssl_amount>12.3</ssl_amount><ssl_salestax>0.00</ssl_salestax><ssl_cvv2cvc2_indicator>Present</ssl_cvv2cvc2_indicator><ssl_cvv2cvc2>123</ssl_cvv2cvc2><ssl_invoice_number></ssl_invoice_number><ssl_customer_code>0</ssl_customer_code><ssl_first_name></ssl_first_name><ssl_last_name></ssl_last_name><ssl_avs_address>123 mystreet</ssl_avs_address><ssl_address2></ssl_address2><ssl_city></ssl_city><ssl_state></ssl_state><ssl_avs_zip>90210</ssl_avs_zip><ssl_phone></ssl_phone><ssl_email></ssl_email></txn>"; // ASCIIEncoding encoding = new ASCIIEncoding(); // //***EAC had to do this next 2 lines because of a bug in billto.Addr1.Substring(0,20) // string temp = billto.Addr1; // if (temp.Length > 20) temp = temp.Substring(0, 20); // string postData = "xmldata=<txn><ssl_merchant_ID>502928</ssl_merchant_ID><ssl_user_id>webform</ssl_user_id><ssl_pin>PK0GAL</ssl_pin><ssl_transaction_type>ccsale</ssl_transaction_type><ssl_card_number>" + this.cc.CCnum + "</ssl_card_number><ssl_exp_date>" + this.cc.ExpMon + this.cc.ExpYr + "</ssl_exp_date><ssl_amount>" + this.cc.Cost + "</ssl_amount><ssl_salestax>0.00</ssl_salestax><ssl_cvv2cvc2_indicator>Present</ssl_cvv2cvc2_indicator><ssl_cvv2cvc2>" + this.cc.CVV2 + "</ssl_cvv2cvc2><ssl_invoice_number></ssl_invoice_number><ssl_customer_code>0</ssl_customer_code><ssl_first_name></ssl_first_name><ssl_last_name></ssl_last_name><ssl_avs_address>" + temp + "</ssl_avs_address><ssl_address2></ssl_address2><ssl_city></ssl_city><ssl_state></ssl_state><ssl_avs_zip>" + billto.Zip5 + "</ssl_avs_zip><ssl_phone></ssl_phone><ssl_email></ssl_email></txn>"; // byte[] data = encoding.GetBytes(postData); // // Prepare web request... // HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("https://www.myvirtualmerchant.com/VirtualMerchant/processxml.do"); // myRequest.Method = "POST"; // myRequest.ContentType = "application/x-www-form-urlencoded"; // myRequest.ContentLength = data.Length; // Stream newStream = myRequest.GetRequestStream(); // // Send the data. // newStream.Write(data, 0, data.Length); // newStream.Close(); // HttpWebResponse resp = (HttpWebResponse)myRequest.GetResponse(); // Encoding enc = System.Text.Encoding.GetEncoding(1252); // StreamReader respstr = new StreamReader(resp.GetResponseStream(), enc); // string RESP = respstr.ReadToEnd(); // resp.Close(); // respstr.Close(); // PubEnt.DAL.DAL.SaveCCResponse(RESP); // if (RESP.Contains(APPROVED)) // { // //***EAC get CC Transaction ID // int i = RESP.IndexOf("<ssl_txn_id>"); // int j = RESP.IndexOf("</ssl_txn_id>"); // this.cc.TransID = RESP.Substring(i + 12, j - i - 12); // //***EAC get CC Transaction ID // i = RESP.IndexOf("<ssl_approval_code>"); // j = RESP.IndexOf("</ssl_approval_code>"); // this.cc.ApprovalCode = RESP.Substring(i + 19, j - i - 19); // return (true); // } // else // { // return (false); // } // } // else return (true); //free transaction //} #endregion public void USPS(Person p) { string returnValue, XmlString; WebClient instance = new WebClient(); XmlString = "<AddressValidateRequest USERID=\"USER\"><Address ID=\"0\"> <Address1>" + p.Addr2 + "</Address1> <Address2>" + p.Addr1 + "</Address2> <City>" + p.City + "</City> <State>" + p.State + "</State> <Zip5></Zip5> <Zip4></Zip4></Address> </AddressValidateRequest>"; Uri siteUri = new Uri("http://production.shippingapis.com/ShippingAPI.dll?API=Verify&XML=" + XmlString.Replace("&", "%20")); WebRequest wr = WebRequest.Create(siteUri); //returnValue = instance.DownloadString(siteUri); btn2Submit.Enabled = true; lblAVS_Shipping.Visible = false; try { returnValue = instance.DownloadString(siteUri); XmlDocument XmlDoc = new XmlDocument(); XmlDoc.LoadXml(returnValue); if (returnValue.Contains("Error")) //***EAC HITT 8227 overrode all previous tickets. { lblAVS_Shipping.Text = "We did not find this shipping address in the U.S. Postal Service’s database. To ensure proper delivery, please review the address carefully before submitting your order."; // node.InnerText; lblAVS_Shipping.Visible = true; } } catch (Exception ex) { //***EAC ignore problems w/ AVS //Write to log Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEnt = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry(); logEnt.Message = "\r\n" + "USPS Address Verification error." + "\r\n" + "Source: " + ex.Source + "\r\n" + "Description: " + ex.Message + "\r\n" + "Stack Trace: " + ex.StackTrace; Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEnt, "Logs"); } }
public void USPS(Person p) { string returnValue, XmlString; WebClient instance = new WebClient(); XmlString = "<AddressValidateRequest USERID=\"USER\"><Address ID=\"0\"> <Address1>" + p.Addr2 + "</Address1> <Address2>" + p.Addr1 + "</Address2> <City>" + p.City + "</City> <State>" + p.State + "</State> <Zip5></Zip5> <Zip4></Zip4></Address> </AddressValidateRequest>"; Uri siteUri = new Uri("http://production.shippingapis.com/ShippingAPI.dll?API=Verify&XML=" + XmlString.Replace("&", "%20")); WebRequest wr = WebRequest.Create(siteUri); returnValue = instance.DownloadString(siteUri); //btn2Submit.Enabled = true; lblAVS_Shipping.Visible = false; try { XmlDocument XmlDoc = new XmlDocument(); XmlDoc.LoadXml(returnValue); if (returnValue.Contains("Error"))//***EAC HITT 8227 overrode all previous tickets. { //lblAVS_Shipping.Text = "We did not find this shipping address in the U.S. Postal Service’s database. To ensure proper delivery, please review the address carefully before submitting your order."; // node.InnerText; lblAVS_Shipping.Text = "Please review: We did not find this address in the U.S. Postal Service database."; lblAVS_Shipping.Visible = true; this.divVerifyErrDisplay.Visible = true; } } catch (Exception ex) { //***EAC ignore problems w/ AVS } }