Also they seriously need to rebuild the SDK with better documentation. Perhaps I will take it upon myself to push a better SDK out next post.
Here is the code I ended up using as you will see it was much easier once paypal turned on the gateway.
1: using System;
2: using PayPal.Payments.DataObjects;
3:
4: namespace eStoreFrontCS
5: { 6: /// <summary>
7: /// Summary description for Constants.
8: /// </summary>
9: public class Constants
10: { 11: private Constants()
12: { 13: }
14:
15: // Payflow Pro Host Name. This is the host name for the PayPal Payment Gateway.
16: // For testing: pilot-payflowpro.verisign.com
17: // For production: payflowpro.verisign.com
18:
19: // DO NOT use test-payflow.verisign.com or payflow.verisign.com.
20:
21: // The path "/transaction" must be included at this time, otherwise a result code -1
22: // will be returned.
23:
24: // If needed, set proxy like given example.
25: // internal static PayflowConnectionData Connection = new PayflowConnectionData("pilot-payflowpro.verisign.com/transaction",443,<ProxyAddress>,<ProxyPort>,<ProxyLogon>,<ProxyPassword>,@"C:\Program Files\Payflow SDK for .NET\certs"); 26: //public static PayflowConnectionData Connection = new PayflowConnectionData("pilot-payflowpro.verisign.com/transaction",443,@"C:\Program Files\Payflow SDK for .NET\certs"); 27: //This is Express Checkout User information
28: //,null,0,null,null
29: public static UserInfo PayflowECUser = new UserInfo("", "", "", ""); 30: //This is Buyer Auth User information
31: public static UserInfo PayflowBAUser = new UserInfo("", "", "", ""); 32: //You need to send "<user>", "<vendor>", "<partner>", "<password>" where USER and VENDOR are //your merchant Login ID, unless you created a Payflow Pro User(no need have not set one up.).
33:
34: //public static String LocalHostName = System.Configuration.ConfigurationSettings.AppSettings["hostName"];
35: }
36: }
1: using System;
2: using System.Data;
3: using System.Configuration;
4: using System.Collections;
5: using System.Web;
6: using System.Web.Security;
7: using System.Web.UI;
8: using System.Web.UI.WebControls;
9: using System.Web.UI.WebControls.WebParts;
10: using System.Web.UI.HtmlControls;
11: using System.Net;
12: using System.Text;
13: using System.IO;
14: using System.Text.RegularExpressions;
15:
16: public partial class vps_home : System.Web.UI.Page
17: { 18:
19: protected void Page_Load(object sender, EventArgs e)
20: { 21:
22: }
23: protected void Button1_Click(object sender, EventArgs e)
24: { 25: //PayPal offers an SDK for .net that can be downloaded here: http://www.pdncommunity.com/pdn/board/message?board.id=payflow&message.id=569
26: //this was created because the SDK can be somewhat confusing.
27:
28: //*************** Note ***********************
29: //before using this code change the following line below: wrWebRequest.Headers.Add("X-VPS-VIT-Client-Certification-Id:14"); 30: //you need to change the ID to something beside 14 that will be unique
31:
32: //1. Set the url to send the transaction to
33: //test
34: string postURL = "https://pilot-payflowpro.verisign.com/transaction";
35: //live
36: //string postURL = "https://payflowpro.verisign.com/transaction";
37:
38: //2. Set your user info. This is case sensitive
39: string PWD = "xxx";
40: string USER= "xxx";
41: string VENDOR="xxx";
42: string PARTNER = "xxx";
43:
44: //3. now create the name value pair string to send to the Payflow servers
45: //more variables can be found in the docs that can be downloaded from your payflow manager
46:
47: StringBuilder postData = new StringBuilder();
48:
49: //***************add the user info***************
50: postData.Append("PWD=" + PWD); 51: postData.Append("&USER=" + USER); 52: postData.Append("&VENDOR=" + VENDOR); 53: postData.Append("&PARTNER=" + PARTNER); 54:
55: //***************add some required info for testing***************
56: postData.Append("&CUSTIP=" + Request.UserHostAddress); 57: //S for Sale. A for Auth. More in the docs
58: postData.Append("&TRXTYPE=S"); 59: postData.Append("&AMT=1.00"); 60: //this is in the format MMYY
61: postData.Append("&EXPDATE=0109"); 62: postData.Append("&ACCT=5105105105105100"); 63: postData.Append("&CVV2=123"); 64: postData.Append("&FIRSTNAME=bob"); 65: postData.Append("&LASTNAME=smith"); 66: postData.Append("&STREET=155515 Q St"); 67: postData.Append("&STATE=NE"); 68: postData.Append("&CITY=Omaha"); 69: postData.Append("&ZIP=68137"); 70: postData.Append("&COUNTRY=US"); 71: //C is for credit card, P is for PayPal Express Checkout. More in the docs
72: postData.Append("&TENDER=C"); 73:
74: //*************add some optional feilds***************
75: postData.Append("&COMMENT1=ASP.NET Testing"); 76: //make sure that the "@" is not url encoded or you will get an error
77: postData.Append("&email=bob@domain.com"); 78: //this is if you want to have PayPal send an IPN post
79: //postData.Append("&NOTIFYURL=" + xxxx); 80:
81: //removed for now: INVNUM=12345678&
82:
83: //add the REQUEST_ID
84: postData.Append("&REQUEST_ID=" + System.Guid.NewGuid().ToString()); 85:
86: //write out the post data
87: Response.Write("PostData:<br> " + postData + "<br><br>"); 88:
89: byte[] requestBytes = Encoding.UTF8.GetBytes(postData.ToString());
90: HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(postURL);
91:
92: //Set WebRequest Properties
93: wrWebRequest.Method = "POST";
94: wrWebRequest.Accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
95: wrWebRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7";
96: wrWebRequest.ContentType = "text/namevalue";
97: wrWebRequest.ContentLength = requestBytes.Length;
98: wrWebRequest.AllowAutoRedirect = false;
99:
100: //add the custom headers
101: wrWebRequest.Headers.Add("X-VPS-Timeout:30"); 102: wrWebRequest.Headers.Add("X-VPS-VIT-Client-Architecture:x86"); 103: wrWebRequest.Headers.Add("X-VPS-VIT-Client-Certification-Id:14"); 104: wrWebRequest.Headers.Add("X-VPS-VIT-Client-Type:ASP.NET"); 105: wrWebRequest.Headers.Add("X-VPS-VIT-Client-Version:0.0.1"); 106: wrWebRequest.Headers.Add("X-VPS-VIT-Integration-Product:Homegrown"); 107: wrWebRequest.Headers.Add("X-VPS-VIT-Integration-Version:0.0.1"); 108: wrWebRequest.Headers.Add("X-VPS-VIT-OS-Name:windows"); 109: wrWebRequest.Headers.Add("X-VPS-VIT-OS-Version:2002_SP2"); 110:
111: // write the form values into the request message
112: Stream reqStream = wrWebRequest.GetRequestStream();
113: reqStream.Write(requestBytes, 0, requestBytes.Length);
114: // Get the response.
115: HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();
116: reqStream.Close();
117: StreamReader responseReader = new StreamReader(wrWebRequest.GetResponse().GetResponseStream());
118:
119: string responseData = responseReader.ReadToEnd();
120: responseReader.Close();
121: Response.Write("Response Data:<br>" + responseData); 122:
123:
124: }
125: }