I have a (probably stupid) question I hope someone can help me with.. So, I set a variaible beased on a form in put in the code behind, but then, a few lines down when I go to call it , it has a undefinded value. I don't understand.. Below is the code: The problem is that when i try to reference theamount on the line I marked "PROBLEM HERE" is that when I call the API, the value for theamount is undefinded.. even though it should have a value, and does above...
please help if you can... right now i have 5 if statements with the code in all, when i only need one and the amt value set above it... ERGH...
using System;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Net;
using System.IO;
public partial class SendMail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
Response.Write("<br>Page has been posted back.");
//send payment info to api, send them an email, go to thank you page
var ccex = Request.Form["ExpMon"] + Request.Form["ExpYear"];
var date1 = System.DateTime.Now.ToString();
var pt = Request.Form["plantype"];
Response.Write("<BR>ccex = " + ccex);
Response.Write("pt.ToString() = " + pt.ToString());
if (pt.ToString() == "Gold")
{
var theamount = "150.10";
}
else
{
var theamount = "205.08";
}
String post_url = "XXX/transact.dll";
Dictionary<string, string> post_values =
new Dictionary<string, string>();
post_values.Add("x_login", "XXX");
post_values.Add("x_tran_key", "XXX");
post_values.Add("x_delim_data", "TRUE");
post_values.Add("x_delim_char", "|");
post_values.Add("x_relay_response", "FALSE");
post_values.Add("x_type", "AUTH_CAPTURE");
post_values.Add("x_method", "CC");
post_values.Add("x_card_num", Request.Form["ccnum"]);
post_values.Add("x_exp_date", ccex);
PROBLEM HERE post_values.Add("x_amount", theamount);
post_values.Add("x_description", "Plan Purchase: " + Request.Form["plan"] + ": " + Request.Form["plantype"]);
post_values.Add("x_first_name", Request.Form["fname"]);
post_values.Add("x_last_name", Request.Form["lname"]);
post_values.Add("x_address", Request.Form["addr"]);
post_values.Add("x_email", Request.Form["emaila"]);
post_values.Add("x_state", Request.Form["state"]);
post_values.Add("x_zip", Request.Form["zip"]);
'etc code goes on.....
}
}