Hello,
I have developed a e commerce website and the gateway is integrated with Paypal Direct Payment API. So i am using a code which is working fine, but some time the system will give the Timeout error. So i tried to catch the error but it is not possible me to remove the error. So i have pasted my code below. So please any one can help me regarding the timeout error? Please if possible please try to change the code and give me the solution.
using System.IO;
using System.Net;
using System.Text;
public string DoDirectPayment()
{
string strUsername = "API USERNAME";
string strPassword = "API PASSWORD";
string strSignature = "API SIGNATURE";
string strCredentials = "USER=" + strUsername + "&PWD=" + strPassword + "&SIGNATURE=" + strSignature;
string strNVPSandboxServer = "https://api-3t.sandbox.paypal.com/nvp";
string strNVPLiveServer = "https://api-3t.paypal.com/nvp";
string strAPIVersion = "2.3";
string strNVP = strCredentials + "&METHOD=DoDirectPayment&CREDITCARDTYPE=VISA&ACCT=4683075410516684&EXPDATE=102008&CVV2=684&AMT=1.00&FIRSTNAME=ABC&LASTNAME=XYZ&IPADDRESS=255.55.167.002&STREET=1234+Easy+Street&CITY=San+Jose&STATE=CA&COUNTRY=United+States&ZIP=95110&COUNTRYCODE=US&PAYMENTACTION=Sale&VERSION="+ strAPIVersion;
//Create web request and web response objects, make sure you using the correct server (sandbox/live)
HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(strNVPSandboxServer);
//Set WebRequest Properties
wrWebRequest.Method = "POST";
// write the form values into the request message
StreamWriter requestWriter = new StreamWriter(wrWebRequest.GetRequestStream());
requestWriter.Write(strNVP);
requestWriter.Close();
string responseData = "";
try
{
HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();
}
catch (TimeoutException Ex)
{
HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();
}
finally
{
HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();
}
StreamReader responseReader = new StreamReader(wrWebRequest.GetResponse().GetResponseStream());
// and read the response
responseData = responseReader.ReadToEnd();
responseReader.Close();
return responseData;
}
Please help,
thanks and Regards,
Sudheendra
Please don't forget to mark the post as Answer, that helps you.
Thank you.
