Tring to pass variables to payflow pro. I found a script already written but how do I pass the variable from textbox? Where post.append is I need the value of my textbox's
-----------------------------------------
.aspx
<asp:TextBox ID="balanceTextBox" runat="server" Columns="20" Rows="4"
Text='<% #Bind("cardacct")%>' ValidationGroup="add"></asp:TextBox>
-----------------------------------
.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.IsAuthenticated)
{
Label2.Text = "";
CustSearch.Focus();
}
else
{
Response.Redirect("./Login.aspx");
}
}
protected void Search_Click(object sender, EventArgs e)
{
string sqlCmd = "Select * From customer Where cust_no = '" + CustSearch + "'";
}
protected void CustSearch_TextChanged(object sender, EventArgs e)
{
}
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
{
}
protected void CCButton_Click(object sender, EventArgs e)
{
{
//PayPal offers an SDK for .net that can be downloaded here: [url]http://www.pdncommunity.com/pdn/board/message?board.id=payflow&message.id=569[/url]
//this was created because the SDK can be somewhat confusing.
//*************** Note ***********************
//before using this code change the following line below:
//wrWebRequest.Headers.Add("X-VPS-VIT-Client-Certification-Id:10");
//you need to change the ID to something beside 14 that will be unique
//1. Set the url to send the transaction to
//test pilot-payflowpro.paypal.com
string postURL = "https://pilot-payflowpro.paypal.com";
//live
//string postURL = "https://payflowpro.verisign.com/transaction";
//2. Set your user info. This is case sensitive
string PWD = "xxx";
string USER = "xxx";
string VENDOR = "xxx";
string PARTNER = "xxx";
//3. now create the name value pair string to send to the Payflow servers
//more variables can be found in the docs that can be downloaded from your payflow manager
StringBuilder postData = new StringBuilder();
//***************add the user info***************
postData.Append("PWD=" + PWD);
postData.Append("&USER=" + USER);
postData.Append("&PARTNER=" + PARTNER);
postData.Append("&VENDOR=" + VENDOR);
//***************add some required info for testing***************
postData.Append("&CUSTIP=" + Request.UserHostAddress);
//S for Sale. A for Auth. More in the docs
postData.Append("&TRXTYPE=S");
// postData.Append("&AMT=1.00");
GetDataItem(%# Eval("balance") %;
//this is in the format MMYY
postData.Append("&EXPDATE=0109");
postData.Append("&ACCT=5105105105105100");
postData.Append("&CVV2=123");
postData.Append("&FIRSTNAME=bob");
postData.Append("&LASTNAME=smith");
postData.Append("&STREET=155515 Q St");
postData.Append("&STATE=NE");
postData.Append("&CITY=Omaha");
postData.Append("&ZIP=68137");
postData.Append("&COUNTRY=US");
//C is for credit card, P is for PayPal Express Checkout. More in the docs
postData.Append("&TENDER=C");
//*************add some optional feilds***************
postData.Append("&COMMENT1=ASP.NET Testing");
//make sure that the "@" is not url encoded or you will get an error
postData.Append("&email=ryan.fitz@vortexamerica.com");
//this is if you want to have PayPal send an IPN post
//postData.Append("&NOTIFYURL=" + xxxx);
//removed for now: INVNUM=12345678&
//add the REQUEST_ID
postData.Append("&REQUEST_ID=" + System.Guid.NewGuid().ToString());
//write out the post data
Response.Write("PostData:<br> " + postData + "<br><br>");
byte[] requestBytes = Encoding.UTF8.GetBytes(postData.ToString());
HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(postURL);
//Set WebRequest Properties
wrWebRequest.Method = "POST";
wrWebRequest.Accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
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";
wrWebRequest.ContentType = "text/namevalue";
wrWebRequest.ContentLength = requestBytes.Length;
wrWebRequest.AllowAutoRedirect = false;
//add the custom headers
wrWebRequest.Headers.Add("X-VPS-Timeout:30");
wrWebRequest.Headers.Add("X-VPS-VIT-Client-Architecture:x86");
wrWebRequest.Headers.Add("X-VPS-VIT-Client-Certification-Id:14");
wrWebRequest.Headers.Add("X-VPS-VIT-Client-Type:ASP.NET");
wrWebRequest.Headers.Add("X-VPS-VIT-Client-Version:0.0.1");
wrWebRequest.Headers.Add("X-VPS-VIT-Integration-Product:Homegrown");
wrWebRequest.Headers.Add("X-VPS-VIT-Integration-Version:0.0.1");
wrWebRequest.Headers.Add("X-VPS-VIT-OS-Name:windows");
wrWebRequest.Headers.Add("X-VPS-VIT-OS-Version:2002_SP2");
// write the form values into the request message
Stream reqStream = wrWebRequest.GetRequestStream();
reqStream.Write(requestBytes, 0, requestBytes.Length);
// Get the response.
HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();
reqStream.Close();
StreamReader responseReader = new StreamReader(wrWebRequest.GetResponse().GetResponseStream());
string responseData = responseReader.ReadToEnd();
responseReader.Close();
//Response.Write("Response Data:<br>" + responseData);
Label2.Text = ("Response Data:<br>" + responseData);
}
}
}