473,699 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in Payment gateway

i am using the link of metacharge.com for payment gateway, when i post data
throung IE it give the correct response, but when i use the .net code to post
data the response is not correct.message is some data is missing.
i use the following code:

public class httpClass

private string UserName;
private string UserPwd;
private string ProxyServer;
private int ProxyPort;
private string Request;

public httpClass(strin g HttpUserName,
string HttpUserPwd, string HttpProxyServer ,
int HttpProxyPort, string HttpRequest)
UserName = HttpUserName;
UserPwd = HttpUserPwd;
ProxyServer = HttpProxyServer ;
ProxyPort = HttpProxyPort;
Request = HttpRequest;

/// <summary>
/// This method creates secure/non secure web
/// request based on the parameters passed.
/// </summary>
/// <param name="uri"></param>
/// <param name="collHeade r">This parameter of type
/// NameValueCollec tion may contain any extra header
/// elements to be included in this request </param>
/// <param name="RequestMe thod">Value can POST OR GET</param>
/// <param name="NwCred">I n case of secure request this would be
/// <returns></returns>
public virtual HttpWebRequest CreateWebReques t(string uri,
NameValueCollec tion collHeader,
string RequestMethod, bool NwCred)
HttpWebRequest webrequest =
(HttpWebRequest ) WebRequest.Crea te(uri);
webrequest.Keep Alive = false;
webrequest.Meth od = RequestMethod;

int iCount = collHeader.Coun t;
string key;
string keyvalue;

for (int i=0; i < iCount; i++)
key = collHeader.Keys[i];
keyvalue = collHeader[i];
webrequest.Head ers.Add(key, keyvalue);

webrequest.Cont entType = "text/html";
//"applicatio n/x-www-form-urlencoded";

if (ProxyServer.Le ngth 0)
webrequest.Prox y = new
WebProxy(ProxyS erver,ProxyPort );
webrequest.Allo wAutoRedirect = false;

if (NwCred)
CredentialCache wrCache =
new CredentialCache ();
wrCache.Add(new Uri(uri),"Basic ",
new NetworkCredenti al(UserName,Use rPwd));
webrequest.Cred entials = wrCache;
//Remove collection elements
collHeader.Clea r();
return webrequest;
}//End of secure CreateWebReques t

/// <summary>
/// This method retreives redirected URL from
/// response header and also passes back
/// any cookie (if there is any)
/// </summary>
/// <param name="webrespon se"></param>
/// <param name="Cookie"></param>
/// <returns></returns>
public virtual string GetRedirectURL( HttpWebResponse
webresponse, ref string Cookie)
string uri="";

WebHeaderCollec tion headers = webresponse.Hea ders;

if ((webresponse.S tatusCode == HttpStatusCode. Found) ||
(webresponse.St atusCode == HttpStatusCode. Redirect) ||
(webresponse.St atusCode == HttpStatusCode. Moved) ||
(webresponse.St atusCode == HttpStatusCode. MovedPermanentl y))
// Get redirected uri
uri = headers["Location"] ;
uri = uri.Trim();

//Check for any cookies
if (headers["Set-Cookie"] != null)
Cookie = headers["Set-Cookie"];
// string StartURI = "http:/";
// if (uri.Length 0 && uri.StartsWith( StartURI)==fals e)
// {
// uri = StartURI + uri;
// }
return uri;
}//End of GetRedirectURL method
public virtual string GetFinalRespons e(string ReUri,
string Cookie, string RequestMethod, bool NwCred)
NameValueCollec tion collHeader =
new NameValueCollec tion();

if (Cookie.Length 0)
collHeader.Add( "Cookie",Cookie );

HttpWebRequest webrequest =
CreateWebReques t(ReUri,collHea der,
RequestMethod, NwCred);

BuildReqStream( ref webrequest);

HttpWebResponse webresponse;

webresponse = (HttpWebRespons e)webrequest.Ge tResponse();

Encoding enc = System.Text.Enc oding.GetEncodi ng(1252);
StreamReader loResponseStrea m = new
StreamReader(we bresponse.GetRe sponseStream(), enc);

string Response = loResponseStrea m.ReadToEnd();

loResponseStrea m.Close();
webresponse.Clo se();
return Response;

private void BuildReqStream( ref HttpWebRequest webrequest)
//This method build the request stream for WebRequest
Stream oStreamOut= webrequest.GetR equestStream();
byte[] byteArray = Encoding.UTF8.G etBytes(Request );
oStreamOut.Writ e(byteArray,0,R equest.Length);
oStreamOut.Clos e();

}//End of HttpBaseClass class
please help me.
Aug 29 '06 #1
0 1189

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: 11abacus | last post by:
Hi, Just wondering if any of you has thought about or is working on a payment gateway abstraction layer (PEAR-style)? I'm interested on developing that or at least start a discussion about it. The package would provide a framework for all types of online (and offline?) payment transactions.
by: Peter Afonin | last post by:
Hello, I'm struggling with the string conversion to MD5 which I've never user before. I have a string that I need to encode which looks approximately like this: "pva:0.05:101214:pa7735tH:inv_desc=205308:shp_Email=petera_gudzon.net:lang =ru:shp_PaymentNo=20040825205308:shp_UserID=pva:shp_Price=2.95:shp_HostPlan= BU:shp_Term=2"
by: Andy | last post by:
Hi, I'm currently developing my B2C application using ASP.NET. I have several questions regarding planning this application: In my application, I'll use my own shopping cart (developed totally in ASP.NET / MS SQL Server for the backend). I'm planning to accepting online payment using major credit cards (Visa/Mastercard), and for that matter I'm currently considering to use service from ikobo.com.
by: japslam japslam via DotNetMonster.com | last post by:
Hi all, I have problem when I use HttpWebRequest and take long time to call to my service server. If at that time there are many request comes in semultaneous, I will get this exception System.Net.WebException: The underlying connection was closed: The request was canceled. ---> System.IO.IOException: Unable to read data from the transport connection. ---> System.ObjectDisposedException: Cannot access a disposed object named...
by: Neven Klofutar | last post by:
Hi, I might need to implement shoping card with full support for Credit card payment. Can you recommend a secure payment gateway I could use for this ? thanx, Neven
by: shantibhushan | last post by:
Hi I am facing specific problem with firefox browser. I have integrated payment gateway in my website. it is working fine in internet explorer. But I am facing problem with firefox and opera browser. I have some values in session like client id, client name. when I redirect from payment gateway to own site(e.g. thankyou page) I want to access all session variable. It works fine in IE but in other browser session value destroy. it works in...
by: =?Utf-8?B?QXNoZmFx?= | last post by:
I wanank now how u enable a payment gateway for credit card confirmation from aspx page we make in shopping cart sites
by: sachindhake | last post by:
Hey Friends, I am developing a ASP.Net web application for one of our clients, which requires WorldPay payment integration. I have gone through the documentation, guides available on WorldPay support website, but still have some confusion, as how to integrate the payment gateway in my web application using C#. I have few question, any help would be appreciated:
by: vinodkus | last post by:
dear sir/madam Please tell me how to do payment gateway in asp . please provide me coding or refer me any site so that I can understood it easily. I have to do it with ICICI bank. I have been provided a link for it but i dont know how to implent it. Please help me Thanks in Advance
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.