Topic: How to get Wellsfargo bank transcations
Greetings,
I want to download the transactions from wellsfargo bank account where i will supply all the credentials. can any one help me to connect the Wellsfargo Bank and download the transactions using OFX server. here is my code that i am trying to connect and get the response. Please do the needful.
public void OFXDownload(RequestType ofx_RequestType, string userName, string password, string AccountID, string BankID, string org, string FID)
{
_UserName = userName;
_Password = password;
CurrGuid = Guid.NewGuid().ToString();
string clientDate = null;
clientDate = DateTime.Now.ToString("yyyyMMddhhmmss");
DataBuffer.AppendLine("OFXHEADER:100");
DataBuffer.AppendLine("DATA:OFXSGML");
DataBuffer.AppendLine("VERSION:102");
DataBuffer.AppendLine("SECURITY:NONE");
DataBuffer.AppendLine("ENCODING:USASCII");
DataBuffer.AppendLine("CHARSET:1252");
DataBuffer.AppendLine("COMPRESSION:NONE");
DataBuffer.AppendLine("OLDFILEUID:NONE");
DataBuffer.AppendLine("NEWFILEUID:NONE");
DataBuffer.AppendLine();
DataBuffer.AppendLine("<OFX>");
DataBuffer.AppendLine("<SIGNONMSGSRQV1>");
DataBuffer.AppendLine("<SONRQ>");
DataBuffer.AppendLine("<DTCLIENT>" + clientDate);
DataBuffer.AppendLine("<USERID>" + userName);
DataBuffer.AppendLine("<USERPASS>" + password);
DataBuffer.AppendLine("<LANGUAGE>ENG");
DataBuffer.AppendLine("<FI>");
DataBuffer.AppendLine("<ORG>" + org);
DataBuffer.AppendLine("<FID>" + FID);
DataBuffer.AppendLine("</FI>");
DataBuffer.AppendLine("<APPID>QWIN");
DataBuffer.AppendLine("<APPVER>0900");
DataBuffer.AppendLine("</SONRQ>");
DataBuffer.AppendLine("</SIGNONMSGSRQV1>");
_RequestType = ofx_RequestType;
switch (ofx_RequestType)
{
case RequestType.AccountList:
DataBuffer.AppendLine("<SIGNUPMSGSRQV1>");
DataBuffer.AppendLine("<ACCTINFOTRNRQ>");
DataBuffer.AppendLine("<TRNUID>" + CurrGuid);
DataBuffer.AppendLine("<CLTCOOKIE>4");
DataBuffer.AppendLine("<ACCTINFORQ>");
DataBuffer.AppendLine("<DTACCTUP>19700101000000");
DataBuffer.AppendLine("</ACCTINFORQ>");
DataBuffer.AppendLine("</ACCTINFOTRNRQ>");
DataBuffer.AppendLine("</SIGNUPMSGSRQV1>");
DataBuffer.AppendLine("</OFX>");
break;
case RequestType.AccountActivity:
DataBuffer.Append("<BANKMSGSRQV1>");
DataBuffer.Append("<STMTTRNRQ>");
DataBuffer.Append("<TRNUID>" + CurrGuid);
DataBuffer.Append("<STMTRQ>");
DataBuffer.Append("<BANKACCTFROM>");
DataBuffer.Append("<BANKID>" + BankID);
DataBuffer.Append("<ACCTID>" + AccountID);
DataBuffer.Append("<ACCTTYPE>CHECKING");
DataBuffer.Append("</BANKACCTFROM>");
DataBuffer.Append("<INCTRAN>");
DataBuffer.Append("<INCLUDE>Y");
DataBuffer.Append("</INCTRAN>");
DataBuffer.Append("</STMTRQ>");
DataBuffer.Append("</STMTTRNRQ>");
DataBuffer.Append("</BANKMSGSRQV1>");
DataBuffer.Append("</OFX>");
break;
//later
}
}
public string Download(RequestType ofx_RequestType, string userName, string password, string AccountID, string BankID, string org, string FID)
{
OFXDownload(ofx_RequestType, userName, password, AccountID, BankID, org, FID);
byte[] byteBuffer = Encoding.ASCII.GetBytes(DataBuffer.ToString());
StreamReader responseReader = default(StreamReader);
//objReq = HttpWebRequest.Create(new Uri("https://ofx.chase.com")) as HttpWebRequest;
objReq = HttpWebRequest.Create(new Uri("https://ofx.wellsfargo.com")) as HttpWebRequest;
objReq.Method = "POST";
objReq.ContentType = "application/x-ofx";
objReq.Accept = "*/*, application/x-ofx";
objReq.ContentLength = byteBuffer.Length;
System.Net.ServicePointManager.Expect100Continue = false;
ReqStream = objReq.GetRequestStream();
ReqStream.Write(byteBuffer, 0, byteBuffer.Length);
ReqStream.Close();
//objResponse = objReq.GetResponse();
objResponse = (HttpWebResponse)objReq.GetResponse();
ResponseStream = objResponse.GetResponseStream();
responseReader = new StreamReader(ResponseStream);
_ResponseString = responseReader.ReadToEnd();
switch (_RequestType)
{
case RequestType.AccountActivity:
ParseBankItems();
break;
case RequestType.AccountList:
ParseAccountList();
break;
}
return _ResponseString;
}