post form data to worldpay using c#

A

Anthony

Hi all,

I am just trying to set up a form post to worldppay and finding it
surprisingly difficult.. What i would like is to gather all of the
variables needed in c# codebehind and then send them along to worldpay
along with the user.. Basically i dont want the user to have to submit
a button it will do it automatically..

I have followed this code and i think it posts the data but wont take
the user to the worldpay page as well

Please help as this is really annoying me

Cheers
Anr
.................................................

string lcUrl = "https://select.worldpay.com/wcc/purchase";

HttpWebRequest loHttp =
(HttpWebRequest) WebRequest.Create(lcUrl);

// *** Send any POST data

string lcPostData =

"instId=" + HttpUtility.UrlEncode("1") +
"&cartId=" + HttpUtility.UrlEncode("Mytester") +
"&amount=" + HttpUtility.UrlEncode("1000") +
"&currency=" + HttpUtility.UrlEncode("GBP") +
"&desc=" + HttpUtility.UrlEncode("Mytester Products")+
"&testMode=" + HttpUtility.UrlEncode("100")
;



loHttp.Method="POST";
byte [] lbPostBuffer = System.Text.
Encoding.GetEncoding(1252).GetBytes(lcPostData);
loHttp.ContentLength = lbPostBuffer.Length;
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);
loPostData.Close();

HttpWebResponse loWebResponse = (HttpWebResponse)
loHttp.GetResponse();
StreamReader loResponseStream =
new StreamReader(loWebResponse.GetResponseStream());

string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top