Working on some asp.net credit card processing code. Scary, eh? I'm actually more of an SQL server guy than an asp.net guy.
The processing company says to just put this html on the page and let the user click the button:
This brings up the form where the user enters their credit card info and the transaction takes place and the money goes to the account and everybody's happy.
This has me shaking in my boots! Somebody could just view source, copy/paste this into any editor and do all sorts of mischief. I asked the company, and their response was "You can use our sample code that I provided using PHP with Java Script. Otherwise you can develop it however you would like if you do not want to use our sample php code."
So, can I have .net code actually submit this form and send the user there to enter his info so I never expose all the gory details?

Upendra Pratap ShahiPosted Aug 7, 2015, 12:44 AM
Tom RubyPosted Aug 6, 2015, 10:34 AM
Upendra Pratap ShahiPosted Aug 6, 2015, 1:18 AM
Create a asp button
<asp: button ID="btnSubmit" runat="server" OnClick="button_click"
Text="Pay With credit Card" />
In Code behind
Protected void button_click(..)
{
var request = (HttpWebRequest)WebRequest.Create("https://Imnotgoingtoshowyouthis.com");
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "This is a test that posts this string to a Web server.";
byte[] byteArray = Encoding.UTF8.GetBytes (postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream ();
// Write the data to the request stream.
dataStream.Write (byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close ();
var response = (HttpWebResponse)request.GetResponse();
var responseString = newStreamReader(response.GetResponseStream()).ReadToEnd();
//Returns TURE if the Status code == 200
bool result = response.StatusCode == HttpStatusCode.OK;
// Also read the response from responseString
responseString.Close();
response.Close ();
}
Manas MohapatraPosted Aug 6, 2015, 12:59 AM