コード例 #1
0
        // Given a token and routing information, complete the transaction
        // by transferring the funds and debiting the account
        public EFTConfirmation TransferFunds(string token, EFTRoutingInfo routingInfo)
        {
            // Parse out amount and transactionID from token
            // Convert token string to bytes[] to create MemoryStream
            System.Text.ASCIIEncoding a  = new System.Text.ASCIIEncoding();
            System.IO.MemoryStream    ms = new System.IO.MemoryStream(a.GetBytes(token));

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(ms);

            //Get transactionID, acctID and amount
            System.Xml.XmlNode node = doc.SelectSingleNode("eft/transactionID");
            if (node == null)
            {
                throw new Exception("Invalid token.");
            }

            string s       = node.InnerText;
            Guid   transID = new Guid(s);

            node = doc.SelectSingleNode("eft/acct");
            if (node == null)
            {
                throw new Exception("Invalid token.");
            }

            int acctID = Int32.Parse(node.InnerText);

            node = doc.SelectSingleNode("eft/amt");
            if (node == null)
            {
                throw new Exception("Invalid token.");
            }

            decimal amt = Decimal.Parse(node.InnerText);

            System.Data.SqlClient.SqlDataAdapter adapter;
            System.Data.SqlClient.SqlCommand     cmd;
            System.Data.SqlClient.SqlConnection  conn;
            string connString = (string)ConfigurationSettings.AppSettings["connectStringWoodgrove"];

            conn    = new System.Data.SqlClient.SqlConnection();
            adapter = new System.Data.SqlClient.SqlDataAdapter();
            cmd     = new System.Data.SqlClient.SqlCommand();

            //
            // cmd
            //
            // _EFTComplete(@acctID as int, @amt as money, @EFTTransactionID as uniqueidentifier, @confirmID as nvarchar(50) output)
            cmd.CommandText = "_EFTComplete";
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Connection  = conn;
            cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, true, ((System.Byte)(10)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
            cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@acctID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, true, ((System.Byte)(10)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, acctID));
            cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@amt", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, amt));
            cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EFTTransactionID", System.Data.SqlDbType.UniqueIdentifier, 16, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, transID));
            cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@confirmID", System.Data.SqlDbType.NVarChar, 50, System.Data.ParameterDirection.Output, true, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));

            //
            // conn
            //
            conn.ConnectionString = connString;

            try
            {
                // Open connection, execute, close connection
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();

                EFTConfirmation eftConfirm = new EFTConfirmation();
                eftConfirm.confirmationNumber = cmd.Parameters["@confirmID"].Value.ToString();
                eftConfirm.amt           = amt;
                eftConfirm.transactionID = transID.ToString();
                Context.Trace.Write(string.Format("TransferFunds Acct:{0} Amt:{1}", acctID, amt));
                return(eftConfirm);
            }
            catch (Exception se)
            {
                Trace.WriteLine(se.Message);
                throw new SoapException(se.Message, null);
            }
        }
コード例 #2
0
		// Given a token and routing information, complete the transaction
		// by transferring the funds and debiting the account
		public EFTConfirmation TransferFunds(string token, EFTRoutingInfo routingInfo)
		{
			// Parse out amount and transactionID from token
				// Convert token string to bytes[] to create MemoryStream
			System.Text.ASCIIEncoding a = new System.Text.ASCIIEncoding();
			System.IO.MemoryStream ms = new System.IO.MemoryStream(a.GetBytes(token));

			System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
			doc.Load(ms);
			
			//Get transactionID, acctID and amount
			System.Xml.XmlNode node = doc.SelectSingleNode("eft/transactionID");
			if (node == null)
				throw new Exception("Invalid token.");
			
			string s = node.InnerText;
			Guid transID = new Guid(s);

			node = doc.SelectSingleNode("eft/acct");
			if (node == null)
				throw new Exception("Invalid token.");

			int acctID = Int32.Parse(node.InnerText);
			
			node = doc.SelectSingleNode("eft/amt");
			if (node == null)
				throw new Exception("Invalid token.");

			decimal amt = Decimal.Parse(node.InnerText);

			System.Data.SqlClient.SqlDataAdapter adapter;
			System.Data.SqlClient.SqlCommand cmd;
			System.Data.SqlClient.SqlConnection conn;
			string connString = (string)ConfigurationSettings.AppSettings["connectStringWoodgrove"];

			conn = new System.Data.SqlClient.SqlConnection();
			adapter = new System.Data.SqlClient.SqlDataAdapter();
			cmd = new System.Data.SqlClient.SqlCommand();

			// 
			// cmd
			// 
			// _EFTComplete(@acctID as int, @amt as money, @EFTTransactionID as uniqueidentifier, @confirmID as nvarchar(50) output)
			cmd.CommandText = "_EFTComplete";
			cmd.CommandType = System.Data.CommandType.StoredProcedure;
			cmd.Connection = conn;
			cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, true, ((System.Byte)(10)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
			cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@acctID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, true, ((System.Byte)(10)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, acctID));
			cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@amt", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, amt));
			cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EFTTransactionID", System.Data.SqlDbType.UniqueIdentifier, 16, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, transID));
			cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@confirmID", System.Data.SqlDbType.NVarChar, 50, System.Data.ParameterDirection.Output, true, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));

			// 
			// conn
			// 
			conn.ConnectionString = connString;
		
			try
			{
				// Open connection, execute, close connection
				conn.Open();
				cmd.ExecuteNonQuery();
				conn.Close();

				EFTConfirmation eftConfirm = new EFTConfirmation();
				eftConfirm.confirmationNumber = cmd.Parameters["@confirmID"].Value.ToString();
				eftConfirm.amt = amt;
				eftConfirm.transactionID = transID.ToString();
				Context.Trace.Write(string.Format("TransferFunds Acct:{0} Amt:{1}",acctID,amt));
				return eftConfirm;
			}
			catch (Exception se)
			{
				Trace.WriteLine(se.Message);
				throw new SoapException(se.Message, null);
			}
		}