<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>/* it daveworks */</title>
	<atom:link href="http://drp.itdevworks.com/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://drp.itdevworks.com</link>
	<description>Authorize.Net and other geek wisdom</description>
	<lastBuildDate>Mon, 22 Feb 2010 21:19:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>C# AutoCleanup class – Leverage IDisposable and lamda expressions to get rid of clumsy try/finally blocks.</title>
		<link>http://drp.itdevworks.com/index.php/2010/02/195/</link>
		<comments>http://drp.itdevworks.com/index.php/2010/02/195/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 21:18:39 +0000</pubDate>
		<dc:creator>davep</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://drp.itdevworks.com/?p=195</guid>
		<description><![CDATA[Here is a common pattern of code:

// set some temporary state for the following block
try
{
    // do some stuff
}
finally
{
    // un-set the temporary state set above
}

A perfect example is showing the wait cursor during an operation in a Windows Forms application:

this.UseWaitCursor = true;
try
{
    // do some [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Here is a common pattern of code:</p>
<pre class="brush: csharp;">
// set some temporary state for the following block
try
{
    // do some stuff
}
finally
{
    // un-set the temporary state set above
}
</pre>
<p>A perfect example is showing the wait cursor during an operation in a Windows Forms application:</p>
<pre class="brush: csharp;">
this.UseWaitCursor = true;
try
{
    // do some stuff
}
finally
{
    this.UseWaitCursor = false;
}
</pre>
<p>Every time I write one of these, I think there must be a better way to do this, something more akin to the old CAutoPtr template class in C++/ATL. The CAutoPtr class worked because C++ (regular C++, not the managed version) has deterministic calling of destructors. This is to say, that when an object is freed, its destructor is called immediately. This is in contrast with managed code which is garbage collected.</p>
<p>In managed code (C#, VB.NET, etc.) when the last reference to an object is release, via setting the reference to null or when the reference variable goes out of scope, the object&#8217;s memory is not actually released right away, and the destructor is not called either. Instead, the object sits on the heap in the same state it was when that last reference was released until the .NET runtime decides it is running out of memory and needs to garbage collect. In today&#8217;s systems with 4 GB of RAM or more, this often does not happen until the application&#8217;s process ends.</p>
<p>To compensate for this and allow developers to explicitly force an object&#8217;s destructor to be called immediately, the creators of the .NET Framework provided the IDisposable interface. This article is not about IDisposable so I won&#8217;t go in to a long explanation about it. Instead, you should know these basic facts about IDisposable:</p>
<ul>
<li>IDisposable is an interface that should (must?) be implemented by any class which manages critical, particularly unmanaged, resources.</li>
<li>IDisposable has one method, Dispose(), which should clean up any critical resources.</li>
<li>Unlike most interfaces, both C# and Visual Basic.NET have built-in knowledge and support of the IDisposable interface via the using statement (Using in Visual Basic.NET). When an object that implements IDisposable is wrapped in a using statement, its Dispose() method is called immediately when the using statement goes out of scope. Example:</li>
</ul>
<pre class="brush: csharp;">
        string text;
        // The StreamReader class implements IDisposable
        using (StreamReader reader =
                    new StreamReader(&quot;c:\\tmp\\foo.txt&quot;))
        {
            text = reader.ReadToEnd();
        }
        // At this point, the using statement goes out of
        // scope, which causes the StreamReader's Dispose
        // method to be called, which closes the file's
        // handle.
</pre>
<p>Based on this, I knew any CAutoPtr like class would need to use the IDisposable interface in order to take advantage of the using statement, but I never took the time to actually figure out the details. That is, until now. As I have become more proficient at LINQ and lambda expressions, it became clear that the combination of IDisposable and lambda expressions was the answer. Interestingly, my AutoCleanup class itself does not leverage lambda expressions itself anywhere, rather it is the ability to use anonymous functions when constructing the AutoCleanup class that makes this so useful.<br />
Here is the complete AutoCleanup class:</p>
<pre class="brush: csharp;">
using System;

namespace ITDevWorks.Utility
{
    /// &lt;summary&gt;
    /// Guarantees automatic execution of delegate functions
    /// when an instance of this class is constructed and/or
    /// when it is disposed.
    /// &lt;/summary&gt;
    /// &lt;remarks&gt;
    /// The &lt;b&gt;AutoCleanup&lt;/b&gt; class is used in cases where
    /// you would normally use a try/finally to ensure that
    /// your cleanup code is executed, regardless of
    /// whether an exception was thrown or not.  With the
    /// &lt;b&gt;AutoCleanup&lt;/b&gt; class, instead of all of the
    /// try/catch lines which can make code less readable,
    /// you can leverage the &lt;see langword=&quot;using&quot;/&gt;
    /// statement, instantiating an instance of this class,
    /// and pass either just the cleanup code or both the
    /// constructor code and cleanup code to execute.
    /// &lt;/remarks&gt;
    public class AutoCleanup : IDisposable
    {
        public delegate void ExecuteAction();

        private bool disposed = false;
        private ExecuteAction executeOnDispose;

        /// &lt;summary&gt;
        /// Constructs an &lt;see cref=&quot;AutoCleanup&quot;/&gt; object,
        /// immediately executing a delegate function, and
        /// the guaranteeing the execution of a second
        /// deletate function when disposed.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;executeOnConstruct&quot;&gt;
        /// The delegate function to execute during
        /// construction.
        /// &lt;/param&gt;
        /// &lt;param name=&quot;executeOnDispose&quot;&gt;
        /// The delegate function to execute when disposed.
        /// &lt;/param&gt;
        public AutoCleanup(ExecuteAction executeOnConstruct,
                           ExecuteAction executeOnDispose)
        {
            if (null != executeOnConstruct)
            {
                executeOnConstruct();
            }
            this.executeOnDispose = executeOnDispose;
        }

        /// &lt;summary&gt;
        /// Constructs an &lt;see cref=&quot;AutoCleanup&quot;/&gt; object,
        /// guaranteeing the execution of a provided delegate
        /// function when disposed.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;executeOnDispose&quot;&gt;
        /// The delegate function to execute when disposed.
        /// &lt;/param&gt;
        public AutoCleanup(ExecuteAction executeOnDispose)
        {
            this.executeOnDispose = executeOnDispose;
        }

        #region IDisposable Members
        /// &lt;summary&gt;
        /// Disposes the &lt;see cref=&quot;AutoCleanup&quot;/&gt; object,
        /// executing the delegate function provided in the
        /// constructor.
        /// &lt;/summary&gt;
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        //
        // Internal implementation of the Dispose() method.
        // See the MSDN documentation on the IDisposable
        // interface for a detailed explanation of this
        // pattern.
        //
        private void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                //
                // When disposing is true, release all
                // managed resources.
                //
                if (disposing)
                {
                    if (null != this.executeOnDispose)
                    {
                        this.executeOnDispose();
                    }
                }
                disposed = true;
            }
        }
        #endregion
    }
}
</pre>
<p>To use this class, you construct a new instance of it inside of a using statement, and pass in two parameter-less, anonymous functions. Note that when an anonymous function has not parameters you must provide the open and close parenthesis with nothing between them where the parameter list would normally go.</p>
<pre class="brush: csharp;">
private void Form1_Shown(object sender, EventArgs e)
{
    using (new AutoCleanup(() =&gt; this.UseWaitCursor = true,
                           () =&gt; this.UseWaitCursor = false))
    {
        // do form initialization
    }
}
</pre>
<p>Furthermore, I was able to use AutoCleanup as a base to create specialized derivations of for common use cases. Below is an example that implements the UseWaitCursor logic.</p>
<pre class="brush: csharp;">
using System;
using System.Windows.Forms;

namespace ITDevWorks.Utility
{
    /// &lt;summary&gt;
    /// Automatically enables the wait cursor for a Windows
    /// Forms control and disables it when the class is
    /// disposed.
    /// &lt;/summary&gt;
    public class AutoWaitCursor : AutoCleanup
    {
        public AutoWaitCursor(Control control)
            : base(() =&gt; { control.UseWaitCursor = true;
                           Application.DoEvents(); },
                   () =&gt; { control.UseWaitCursor = false; })
        {
            // Do Nothing
        }
    }
}
</pre>
<p>Like the XML comment shows above, to use this class all you need to do is:</p>
<pre class="brush: csharp;">
private void Form1_Shown(object sender, EventArgs e)
{
    using (new AutoWaitCursor(this))
    {
        // do form initialization
    }
}
</pre>
<p>This is far simpler and easier to read than the whole try/finally clumsiness.</p>
]]></content:encoded>
			<wfw:commentRss>http://drp.itdevworks.com/index.php/2010/02/195/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solving the bogus extra post-back issue in ASP.NET</title>
		<link>http://drp.itdevworks.com/index.php/2010/01/solving-the-bogus-extra-post-back-issue-in-asp-net/</link>
		<comments>http://drp.itdevworks.com/index.php/2010/01/solving-the-bogus-extra-post-back-issue-in-asp-net/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 04:18:35 +0000</pubDate>
		<dc:creator>davep</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://drp.itdevworks.com/?p=182</guid>
		<description><![CDATA[I don&#8217;t know if any of you have experienced this, but it has been causing me grief for some time, but I finally solved it.
The Background
I have a web page that is part of the admin area of a client&#8217;s website.  The page has a GridView with a list of the website&#8217;s members.  The GridView is contained [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I don&#8217;t know if any of you have experienced this, but it has been causing me grief for some time, but I finally solved it.</p>
<p><strong>The Background</strong><br />
I have a web page that is part of the admin area of a client&#8217;s website.  The page has a GridView with a list of the website&#8217;s members.  The GridView is contained inside of an UpdatePanel control. </p>
<p><strong>The Problem</strong><br />
When you click the &#8220;Edit&#8221; button for a row, <em>and</em> your browser is some version of Internet Explorer (this does not happen with Firefox), your Page_Load() method is called twice. The first time <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.ispostback.aspx" target="_blank">IsPostBack</a> == false, and none of your ViewState variables are available, so as far as your code is concerned, it looks like a first time page load and any &#8220;!IsPostBack&#8221; logic you have is executed.  The second call to Page_Load() is the normal one where .IsPostBack is true and your event handlers are called.</p>
<p>Since the ViewState variables are not present, you cannot set any sort of flag indicating the page has already been loaded.  Setting Trace=&#8221;true&#8221; on the @Page directive in the .aspx file yields nothing because the page is loaded twice so the first one is overwritten by the second.  I even tried setting an onunload handler in the client script to raise a server event (via <a href="http://msdn.microsoft.com/en-us/library/ms153106.aspx" target="_blank">Page.ClientScript.GetCallbackEventReference</a>), but for some reason the onunload handler was never called, regardless of whether I set it on the window, document or body element.</p>
<p><strong>The Solution</strong><br />
After trying all sorts of ways to reliably identify when a Page_Load() call was bogus, I finally came across <a href="http://forums.asp.net/p/1079528/3172367.aspx" target="_blank">this thread</a> in the ASP.NET forums.  Basically, the solution is very simple and easy &#8211; <strong><em>you check the Page.Request.RequestType property</em></strong>.  If the RequestType is &#8220;GET&#8221;, it is the real first time page load.  If it is &#8220;POST&#8221;, then it is a postback.  So, I created the following property:</p>
<pre>protected bool IsFalseFirstPageLoad
{
    get { return (!this.IsPostBack &amp;&amp;
            0 == String.Compare(this.Request.RequestType, "POST", true)); }
}</pre>
<p>Then, at the top of my Page_Load() method, I have the following code:</p>
<pre>if (this.IsFalseFirstPageLoad)
{
    return;
}</pre>
<p>As simple as that. Problem solved.</p>
]]></content:encoded>
			<wfw:commentRss>http://drp.itdevworks.com/index.php/2010/01/solving-the-bogus-extra-post-back-issue-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What to do when Visual Studio is responding very slowly for certain projects</title>
		<link>http://drp.itdevworks.com/index.php/2009/12/what-to-do-when-visual-studio-is-responding-very-slowly-for-certain-projects/</link>
		<comments>http://drp.itdevworks.com/index.php/2009/12/what-to-do-when-visual-studio-is-responding-very-slowly-for-certain-projects/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 19:56:41 +0000</pubDate>
		<dc:creator>davep</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://drp.itdevworks.com/?p=180</guid>
		<description><![CDATA[When I was at Microsoft I worked on two different teams that were part of the larger Developer Division &#8211; Visual Studio Tools for Office (VSTO) and Visual Studio Team System (VSTS).  While neither of these was the core VS team, we were close enough to get occasional wisdom from them.  One such piece of wisdom [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>When I was at Microsoft I worked on two different teams that were part of the larger Developer Division &#8211; Visual Studio Tools for Office (VSTO) and Visual Studio Team System (VSTS).  While neither of these was the core VS team, we were close enough to get occasional wisdom from them.  One such piece of wisdom dealt with cases when Visual Studio slows down dramatically, especially when debugging.  The solution was simple, just exit VS altogether, navigate to the folder where your .sln file is located and delete the .suo file there.  I don&#8217;t recall exactly why this works, but apparently the information in this aut0-generated file can get into a state where it causes VS to work way too hard to resolve otherwise simple problems.  Note that when you re-open the project in Visual Studio, all of your breakpoints, open files and similar session state information will be lost, but hopefully your slowness problems will be resolved.</p>
<p>If this does not solve your Visual Studio performance woes, here are a couple of other links which may be useful:</p>
<ul>
<li><a href="http://support.microsoft.com/kb/920805" target="_blank">Microsoft KB 920805</a>:  Describes a slow response time in Visual Basic 2005 projects and a link to a hotfix to install.</li>
<li><a href="http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/bc778e26-9156-4924-a9ca-a57ef8ff6bcc/" target="_blank">Visual Studio 2008 PAINFULLY SLOW!!</a>: A thread on social.msdn.microsoft.com about performance issues in VS.  The primary answer in this thread has to do with changing an option in Internet Explorer which causes VS to check on the internet for certificate revocations by third-party control/library providers.</li>
</ul>
<p>Hope this helps someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://drp.itdevworks.com/index.php/2009/12/what-to-do-when-visual-studio-is-responding-very-slowly-for-certain-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Which Authorize.net API to use?</title>
		<link>http://drp.itdevworks.com/index.php/2009/12/which-authorize-net-api-to-use/</link>
		<comments>http://drp.itdevworks.com/index.php/2009/12/which-authorize-net-api-to-use/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 01:53:57 +0000</pubDate>
		<dc:creator>davep</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://drp.itdevworks.com/?p=170</guid>
		<description><![CDATA[I recently answered a question on the Authorize.net forum. The questioner wanted to know which API to use for a single, one-time transaction. Below is my answer. You may find it helpful in determining which Authorize.net API to use for your purposes.

Use AIM to make a single payment in real-time while the customer is using [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I recently answered a question on the Authorize.net forum. The questioner wanted to know which API to use for a single, one-time transaction. Below is my answer. You may find it helpful in determining which Authorize.net API to use for your purposes.</p>
<ul>
<li><strong>Use AIM to make a single payment in real-time </strong>while the customer is using your application/website and has their credit card in-hand, and (if your application is a website) your site has an SSL certificate installed such that all senstive credit card information is entered via a from over an https:// connection.</li>
<li><strong>Use SIM if the above is true but you do not have an SSL certificate installed</strong> (and do not plan to install one).</li>
<li><strong>Use CIM if you want to support storing the customer&#8217;s credit card </strong>(or bank account, if you support it) information so the customer does not have to re-enter it if they return to your site *or* you have a recurring billing situation where either the amount or frequency of billing fluctuates.In either case, you will need the SSL certificate / https:// connection for when the customer enters their payment information.</li>
</ul>
<p><strong>The other common factor which causes people to choose AIM over SIM is they want to maintain the branding of their site</strong> when the customer pays. When you use SIM, the customer is sent to a form hosted by Authorize.net to enter their payment information. You can customize the header and footer somewhat, and change the background color and a couple other things, but you cannot do anything like add links back to your site or add your normal menus, etc.</p>
<p>This is just a quick summary of the key differences between and uses for the different Authorize.net APIs. I plan to write an Authorize.net 101 post one of these days, which provides a high-level overview of their primary payment gateway APIs.  In the meantime, if you need more information, you should refer to Authorize.net&#8217;s own <a href="http://developer.authorize.net/api/" target="_blank">documentation</a>, or check out their <a href="http://community.developer.authorize.net/" target="_blank">developer community forums</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://drp.itdevworks.com/index.php/2009/12/which-authorize-net-api-to-use/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Coding and Development Standards: 15 Do&#8217;s and Don&#8217;ts for My Subcontractors</title>
		<link>http://drp.itdevworks.com/index.php/2009/11/coding-and-development-standards-15-dos-and-donts-for-my-subcontractors/</link>
		<comments>http://drp.itdevworks.com/index.php/2009/11/coding-and-development-standards-15-dos-and-donts-for-my-subcontractors/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 18:25:11 +0000</pubDate>
		<dc:creator>davep</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://drp.itdevworks.com/?p=146</guid>
		<description><![CDATA[I am an independent software development consultant. By independent, I mean I generally work directly with my clients, rather than going through a contract agency or other firm. When I have more work than I can take on myself, I sometimes hire subcontractors to help out.
To help get new subs up to speed on projects and [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I am an independent software development consultant. By independent, I mean I generally work directly with my clients, rather than going through a contract agency or other firm. When I have more work than I can take on myself, I sometimes hire subcontractors to help out.</p>
<p>To help get new subs up to speed on projects and my development environment, I created documents addressing various things they need to know. For instance, one document explains how to connect to my <a href="http://subversion.tigris.org/">Subversion </a>server, while another one lists various required or otherwise useful tools. There is, however, another less obvious problem – actually a myriad of small problems – with taking on a new developer.</p>
<p>When I review a subcontractor&#8217;s check-in or observe some aspect of their work, I frequently encounter things that are not done &#8220;right.&#8221; I put &#8220;right&#8221; in quotes because I fully recognize that some, perhaps most, of these issues are just preferences. Some are actually best practices, but  many simply reflect the way I like things done. So I finally put together a set of guidelines to inform subcontractors of how to do things &#8220;my way.&#8221;</p>
<h2>Do&#8217;s and Don&#8217;ts</h2>
<p>As I started to write my guidelines, I had to figure out how to present them in an easy-to-read list, using consistent language. I settled upon making each item a <strong>Do</strong> or <strong>Don&#8217;t</strong>. This format works because some things are behaviors I want the subcontractors to adopt and others are practices that I want them to stop.</p>
<p>Before anyone comments telling me why my way is wrong, let me re-iterate that these are my preferences, and not a list of absolutes I expect everyone to follow. The only reason I post this in the first place is in to offer some advice for anyone wanting to get another perspective on these areas. Also if you find my preferences fairly similar to your own ideas, you can use this as a starting point for writing a document for your own employees or subcontractors. Lastly, this is as good a place as any to keep this list and I can just refer my subs to it.</p>
<p>The list has two main sections (at least for now).  These are <strong>Source Code Control</strong> and <strong>Coding Standards</strong>.  I may add more in the future but all of my issues so far were able fit in to these two categories. I should also note that I predominantly work in .NET, so some of the coding standards are specific to that environment.</p>
<h2>Source Code Control</h2>
<ul>
<li><strong>DO make sure the checked-in source will always build.  </strong>Before checking in you should always synch to the latest source and perform a clean build to make sure nothing is broken.[<em><strong>Note:</strong></em> There are some rare exceptions to this rule. For example, certain kinds of changes, like file moves/renames and other restructuring tasks, require a series of check-ins to complete.  In these cases you inform everyone else beforehand what change is taking place and when.  Then, when you make the changes, include clear comments indicating that a given check-in is part of a multi-phase check-in.  Also, if for this or any other reason, you are knowingly checking in a set of changes which will break the build, add something like "!!! Broken Build !!!" to the first line of your check-in comment so it is clear to any reviewing the change logs not to sync with this revision.]</li>
<li><strong>DO add comments to every single check-in.</strong> Try to make the first line summarize the check-in as that is the only line which shows in the Show log dialog, but add more details as well.</li>
<li><strong>DO review all changes before check-in.</strong>  Every time I check-in changes, I bring up the <strong>Commit…</strong> dialog, review the list of files to make sure I am not checking in anything I don&#8217;t want to, nor missing anything I need to add.  Next, I systematically double-click on each and every file that I touched to make sure the changes include only the changes that should be checked in.  Using this process I frequently encounter small sections of code that I added for testing or debug purposes that should not be checked in.  I occasionally see outright problems that would break the build if did check it in.</li>
<li><strong>DO check for new files to add to the repository</strong>.  This is one of the most common mistakes made when checking in changes, forgetting to add important new files that you added to the project.  Everything will still build fine on your machine but you will break everyone else that syncs to your changes.</li>
<li><strong>DON&#8217;T check-in built binary files.</strong>  I have seen way too many projects that have all of the .dll, .exe, and .pdb files for a project checked in to source code control.  I have even seen projects with all of the files in the <em>obj</em> folders checked-in.  These files are all built every single time you build the solution on your machine and should not be stored in source code control.  Period.</li>
<li><strong>DON&#8217;T check-in machine/user-local configuration files.</strong>  In particular, don&#8217;t ever check-in any .suo or .user files.  Similarly, don&#8217;t check in *.Publish.xml, *.FileList.txt or *.FileListAbsolute.txt files.</li>
<li><strong><strong>DON&#8217;T</strong> check anything in to the project or solution folder(s) not required to build and run the solution.</strong>  Don&#8217;t check-in any files used to create graphics (.psd, .pdn, .fla, etc.), any log files, temp files, or anything else that is not required to build the solution.  There should be a separate folder outside of the solution&#8217;s folder tree for checking in graphics sources, design documents and other project collateral, but these should not be in the actual solution folder hierarchy.</li>
</ul>
<h2>Coding Standards</h2>
<ul>
<li><strong><strong>DON&#8217;T</strong> check-in code with build warnings.  </strong>Don&#8217;t ever check-in build warnings you have created.  The problem with build warnings is they sometimes are actually problems you need to deal with, and if you have a bunch of build warnings already, then you don&#8217;t notice when new ones are introduced.  If you are working on a project with legacy code that produces many build warnings, then know how many are reported when you check-out/update, and keep track of that number so you can prevent adding more.  If you can, clean some up some legacy warnings with each check-in so over time the number is reduced to zero.</li>
<li><strong><strong>DON&#8217;T</strong> use exceptions for normal code flow.</strong>  Having exceptions thrown during normal operation of the code creates &#8220;false positives&#8221; when you are trying to debug real exceptions.  Very annoying.  Exceptions are also expensive, so it is generally a bad practice to rely on them.  It is important to catch exceptions in many cases to handle possible failure conditions (like making web service calls, doing file i/o, and such), but for things like converting strings to numeric or other values, there is always a non-exception producing way. </li>
<li><strong>DO use String.IsNullOrEmpty() rather than stringVal == &#8220;&#8221;.</strong>  There are some very rare cases where you need to check if a string is null separate from if it has any data in it, but in the vast majority of cases you can use String.IsNullOrEmpty(), even if you already know it is not null. </li>
<li><strong>DO use String.Empty instead of &#8220;&#8221;.</strong>  My code pretty much does not use &#8220;&#8221; anywhere.  It is always String.Empty.  If the value of String.Empty ever changes (unlikely, but possible), then all of my code will consistently change with it.</li>
<li><strong><strong>DON&#8217;T</strong> use string concatenation, instead always use String.Format().</strong>  It pays to be consistent, String.Format() supports fairly rich formatting capabilities. It is way easier to re-arrange the contents of text using String.Format() than mucking with concatenated strings, and if there is ever any chance of code being globalized/localized, you will need to switch all string concatenation to String.Format() anyway.</li>
<li><strong>IDisposable (despite being last on the list, this is <span style="color: #ff0000;">very important</span>!)</strong>
<ul>
<li><strong>DO understand IDisposable and be aware of when it is used.</strong>  There are many classes in the .NET framework which implement IDisposable and therefore must be disposed.  The #1 best way for doing this is with the &#8220;using&#8221; (in C#) or &#8220;Using&#8221; (in VB.Net) statement.  If you can at all avoid it, don&#8217;t hang on to disposable objects, instantiate them with &#8220;using&#8221;, make use of them, and then let them be disposed when the &#8220;using&#8221; statement falls out of scope.  The next best way to ensure disposal is via try/finally.  If you have to hold on to a disposable object as a member variable, the next bullet point applies.The most common place that IDisposable requirements are abused is in ADO.NET objects.  Many of the data access objects implement IDisposable and therefore invoke the two rules above.   Read an MSDN article titled <a href="http://msdn.microsoft.com/en-us/library/fs2xkftw.aspx">Implementing a Dispose Method</a> for some explanation of IDisposable.  There is also an MSDN Magazine article, <a href="http://msdn.microsoft.com/en-us/magazine/cc163392.aspx">Digging into IDisposable</a>.</li>
<li><strong>DO know the IDisposable interface implementation pattern and requirements.</strong>  If you encapsulate (have as a member variable) any object which implements IDisposable, then your class needs to also implement IDisposable, and any code calling your class must dispose your object which will, in turn, dispose the object it is holding on to.</li>
<li><strong>DO use the <em>using</em> statement to ensure an object is disposed.</strong>  Both C# and VB.NET support the using statement for ensuring IDisposable.Dispose is called.  Always prefer <em>using</em> to try/catch if at all possible.  </li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://drp.itdevworks.com/index.php/2009/11/coding-and-development-standards-15-dos-and-donts-for-my-subcontractors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CIM User Interface &#8211; Somebody has to announce it</title>
		<link>http://drp.itdevworks.com/index.php/2009/11/cim-user-interface-somebody-has-to-announce-it/</link>
		<comments>http://drp.itdevworks.com/index.php/2009/11/cim-user-interface-somebody-has-to-announce-it/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 20:28:39 +0000</pubDate>
		<dc:creator>davep</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Authorize.net]]></category>
		<category><![CDATA[CIM]]></category>

		<guid isPermaLink="false">http://drp.itdevworks.com/?p=128</guid>
		<description><![CDATA[[Update: 2009-11-10 @ 2:30 PM PST: It seems that as soon as I put this out Michelle C. from Authorize.net officially announced this feature on the Developer Community Forums.  It also notes that this is phase one of a two-phase rollout, so there is more functionality to come.]
Those folks over at Authorize.net are so [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><em>[Update: 2009-11-10 @ 2:30 PM PST: It seems that as soon as I put this out Michelle C. from Authorize.net <a href="http://community.developer.authorize.net/t5/News-and-Announcements/Manage-Customer-Profiles-in-the-Merchant-Interface/td-p/813">officially announced</a> this feature on the Developer Community Forums.  It also notes that this is phase one of a two-phase rollout, so there is more functionality to come.]</em></p>
<p>Those folks over at Authorize.net are so humble.  Whenever they come out with something new, they don’t make a big splash and boast to the world what a great thing they have done.  Instead they just put it out there and let us discover the fruits of their labor on our own. </p>
<p><img class="alignright" title="Click to view full-sized image" src="http://drp.itdevworks.com/wp-content/uploads/2009/11/CIM_Page_Small3.png" alt="CIM Page Screen-Shot" width="227" height="228" /></p>
<p>For example, when the <a href="http://www.authorize.net/solutions/merchantsolutions/merchantservices/cim/" target="_blank">Customer Information Manager</a> (CIM) service was first released, there was no method to discover all of the customer profiles you created on the service.  The only way to retrieve a customer profile was to use the <em>customerProfileId</em> field assigned when you created the profile.  This was a major problem in the API since, if you were to lose the customerProfileId, you could not retrieve the profile record for that id. Yet if you tried to recreate it, you might get a “Duplicate profile” error. Then, in January of this year (2009), they silently released an update to the CIM service that not only included the new <em>getCustomerProfileIdsRequest</em> method, but also modified the &#8220;duplicate profile&#8221; error response XML to include the id of the duplicate it found.  I never saw any announcement of this anywhere.  I only found it because I regularly download the <a href="http://www.authorize.net/support/CIM_XML_guide.pdf" target="_blank">CIM XML Implementation Guide</a> to see if the documentation has been updated.</p>
<h3>CIM User Interface</h3>
<p>Now they have done it again (those wascally wabbits!), only this time they released something much bigger.  One of the biggest problems CIM has faced? When merchants call up Authorize.net to sign up for CIM, they discover they cannot do <em>anything</em> with it until they hire a programmer and pay hundreds, perhaps thousands, of dollars to integrate CIM with their website or application.  This is clearly a show-stopper for many potential customers. </p>
<p>Like me, anyone that has used CIM much at all has likely been expecting Authorize.net to build a user interface over CIM, much like they have for their <a href="http://www.authorize.net/solutions/merchantsolutions/merchantservices/automatedrecurringbilling/" target="_blank">Automated Recurring Billing</a>  (ARB) service.  I actually recently had this confirmed by inside sources at Authorize.net. But didn&#8217;t know when it would come out, and I expected them to make a big splash out of it.</p>
<h3>Just a Little Hint</h3>
<p>Instead, as I was reading the <a href="http://community.developer.authorize.net/" target="_blank">Authorize.net developer community forums</a> yesterday, I came across <a href="http://community.developer.authorize.net/t5/Integration-and-Testing/Weird-question-CIM-Profile-from-test-to-live/m-p/799#M662" target="_blank">this post</a> where one of the forum moderators casually said:</p>
<blockquote><p>“[…]which you can now do by clicking <strong>Customer Information Manager</strong> from within the Merchant Interface. From the main CIM page, you can click Add Profile and enter the customer&#8217;s payment and shipping information.”</p></blockquote>
<p>I did a double-take.  Did she just casually mention that there is major new functionality added to the merchant interface for Authorize.net accounts with CIM enabled?  I read it again.  Yes, indeed she did. So I immediately logged in to my Test account (since my live account has no need for CIM) and, lo and behold, there it was (note that, being my test account, the data in the image does not reflect what a live account would look like, with real IDs and emails).</p>
<p align="center"><a href="http://drp.itdevworks.com/wp-content/uploads/2009/11/CIM_Page_Full.png" target="_blank"><img class="size-full wp-image-130" title="Click to view full-sized image" src="http://drp.itdevworks.com/wp-content/uploads/2009/11/CIM_Page_Small3.png" alt="CIM Page Screen-Shot" width="473" height="480" /></a> </p>
<p align="center">(click image for full-sized picture)</p>
<p>I find the implementation as I expected it to be.  It allows you to perform pretty much all of the actions that the CIM API supports, <em>except,</em> interestingly enough, actually submit a payment transaction request.  That seems like a pretty major hole that will be a common request heard over at Authorize.net.  Otherwise, it looks pretty good on a first glance.</p>
<h3>Congrats Are In Order</h3>
<p>But I am still befuddled by their silence on this release.  I can kind of understand (although I don’t necessarily agree with) not announcing the addition of the <em>getCustomerProfileIdsRequest</em> method, but this is pretty major, and there isn’t even a blurb in the “Announcements” section when you log in to your live Authorize.net account.  The most recent addition there is from 10/13/09 titled, “Fraudulent Sites and Phishing Scams”.  Not a peep about the brand spanking new CIM user interface pages.</p>
<p>Still, many will be happy to discover this new feature.  In fact, until they add the ability to submit transactions, it is possible that those who stand to gain the most benefit are the developers themselves because we finally have a way of verifying what information is in CIM without having to write a bunch of code to do it.  I know I certainly will.</p>
<p>Most of all, though, I want to congragulate Authorize.net on this release, and also thank them for listening to their customers and responding, thus making our lives easier.</p>
]]></content:encoded>
			<wfw:commentRss>http://drp.itdevworks.com/index.php/2009/11/cim-user-interface-somebody-has-to-announce-it/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>InitializableDictionary: Why is this not in System.Collections.Generic?</title>
		<link>http://drp.itdevworks.com/index.php/2009/10/initializabledictionary-why-is-this-not-in-system-collections-generic/</link>
		<comments>http://drp.itdevworks.com/index.php/2009/10/initializabledictionary-why-is-this-not-in-system-collections-generic/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 18:18:13 +0000</pubDate>
		<dc:creator>davep</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://drp.itdevworks.com/?p=72</guid>
		<description><![CDATA[I am a total neat freak when it comes to code (my desk, though, is another matter). Whenever I find myself writing the same or very similar code within an application, I immediately want to factor out to a common, shared method. When something is repeated many times (say, 10-15 or more), my desire is [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I am a total neat freak when it comes to code (my desk, though, is another matter). Whenever I find myself writing the same or very similar code within an application, I immediately want to factor out to a common, shared method. When something is repeated many times (say, 10-15 or more), my desire is to move the differences into some statically intialized data that can be used to provide the parameters necessary to drive the factored out code. In the case of a .NET application you can use the generic <em>Dictionary&lt;TKey, TValue&gt;</em> as a lookup table. The problem is that, unlike <em>List&lt;T&gt;</em>, generic <em>Dictionary</em> has no constructor which allows you to initialize it with data. Necessity being the mother of invention, I created the <em>InitializeableDictionary&lt;TKey, TValue&gt;</em> class.</p>
<p>I am actually a little surprised this is not part of the standard <em>Dictionary</em> class. They would just need to add a few constructors like with <em>List</em>, but, alas, this is not so. However, I understand there are all kinds of reasons for why features do or do not make it in to a product (heck, I used to work on the Visual Studio team as part of Team System, so I ought to understand). So I created <em>InitializableDictionary</em> a couple years ago to fill this gap and have ended up copying it over to just about every .NET project I have worked on since then. So, I thought I would share it here for anyone that could benefit from it. It is very simple. It just adds a constructor that takes in an array of <em>KeyValuePair</em>. The code is here:</p>
<div style="background-color: #eee;"><code><br />
using System.Collections.Generic;<br />
<br />
namespace ITDevWorks.Internal.Website.Classes<br />
{<br />
    /// &lt;summary&gt;<br />
    /// Summary description for InitializableDictionary<br />
    /// &lt;/summary&gt;<br />
    public class InitializableDictionary&lt;TKey, TValue&gt;<br />
        : Dictionary&lt;TKey, TValue&gt;<br />
    {<br />
        public InitializableDictionary(KeyValuePair&lt;TKey, TValue&gt;[] values)<br />
            : this(null, values)<br />
        {<br />
        }<br />
<br />
        public InitializableDictionary(IEqualityComparer&lt;TKey&gt; comparer,<br />
                                       KeyValuePair&lt;TKey, TValue&gt;[] values)<br />
            : base(comparer)<br />
        {<br />
            if (null != values &amp;&amp; 0 &lt; values.Length)<br />
            {<br />
                foreach (KeyValuePair&lt;TKey, TValue&gt; pair in values)<br />
                {<br />
                    this.Add(pair.Key, pair.Value);<br />
                }<br />
            }<br />
        }<br />
    }<br />
}<br />
<br />
</code></div>
<p>The constructor with the IEqualityComparer&lt;&gt; is for cases when I need a dictionary with a case insensitive key. Note that you only need to use the InitializableDictionary constructor, there is no need to make your actual object of that class. Here is some example code that uses it (note that it does get a little wordy, but once you get the first line out of the way, up to the open curly brace, then the data lines are not so bad):</p>
<div style="background-color: #eee;"><code><br />
private static readonly Dictionary&lt;string, string&gt; urlMap =<br />
    new InitializableDictionary&lt;string, string&gt;(<br />
            StringComparer.InvariantCultureIgnoreCase,<br />
            new KeyValuePair&lt;string, string&gt;[] {<br />
    new KeyValuePair&lt;string, IntraSiteUrlConstants&gt;("key1", "value1"),<br />
    new KeyValuePair&lt;string, IntraSiteUrlConstants&gt;("key2", "value2"),<br />
});<br />
<br />
</code></div>
<p>Of course, this example just uses a simple string to string mapping, but in a real application the key or the value could be of just about any type.</p>
<p>I hope you find this useful. If you do, let me know by posting a comment below.</p>
<p>Thanks,<br />
Dave</p>
]]></content:encoded>
			<wfw:commentRss>http://drp.itdevworks.com/index.php/2009/10/initializabledictionary-why-is-this-not-in-system-collections-generic/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Authorize.net Terminology Overload: Test vs. Live</title>
		<link>http://drp.itdevworks.com/index.php/2009/10/authorize-net-terminology-overload-test-vs-live/</link>
		<comments>http://drp.itdevworks.com/index.php/2009/10/authorize-net-terminology-overload-test-vs-live/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 20:42:51 +0000</pubDate>
		<dc:creator>davep</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://drp.itdevworks.com/?p=3</guid>
		<description><![CDATA[Authorize.net is one of the service providers that allows you to process payments by taking credit card and/or electronic check payments on your website. Integrating with Authorize.net requires testing, first. So, when you create an account with Authorize.net, it is placed in Test Mode, and you must manually put the account in Live Mode before you can actually [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.authorize.net" target="_blank">Authorize.net</a> is one of the service providers that allows you to process payments by taking credit card and/or electronic check payments on your website. Integrating with Authorize.net requires testing, first. So, when you create an account with Authorize.net, it is placed in Test Mode, and you must manually put the account in Live Mode before you can actually charge customers. </p>
<p>This is fairly straightforward to understand and do, but the terms &#8220;test &#8221; and &#8220;live&#8221; actually can be used in three different contexts when dealing with Authorize.net, and this often makes it difficult to communicate with clients. Having explained this enough times, I thought I would write up a permanent explanation so I can point people here instead of going through it, myself, every time.  I also hope that anyone needing to understand these differences will find this explanation helpful.</p>
<h2><strong>Summary</strong></h2>
<p>There are three meanings for the terms “Test” and “Live” when discussing Authorize.net accounts and transactions. These are:</p>
<ul>
<li style="margin-bottom:1em;"><strong>Server Level:</strong> <strong>Test vs. Live </strong>=&gt; Authorize.net has their normal Live Servers (presumably more than one) and a Test Server. You can <a href="http://developer.authorize.net/testaccount/">request a Test Account</a> (which is an account on the Test Server) for free and they do not require a merchant account.</li>
<li style="margin-bottom:1em;"><strong>Account Level:</strong> <strong>Test vs. Live </strong>=&gt; You can set your whole account in Test Mode and any transactions submitted will be validated but not processed (thus they will not be added to the Unsettled Transactions list or leave any other trace in your account).</li>
<li style="margin-bottom:1em;"><strong>Transaction Level:</strong> <strong>Test vs. Live</strong> =&gt; Each payment transaction submitted can indicate that it is a Test Transaction. If your account is in Test Mode, this has no effect since all transactions will be treated as test transactions. If your account is in Live Mode, then this treats the transaction request the same as if your whole account was in Test Mode.</li>
</ul>
<h2><strong>Detailed Explanation</strong></h2>
<p>Here is a more detailed explanation of these terms, along with a chart showing all combinations.</p>
<p><strong>Server Level: </strong>Authorize.net’s normal accounts run on their Live server(s). However, they also have a complete, exact copy of their live system on a different server which does everything the live servers do except communicate with the back-end merchant accounts to actually transfer funds. Anyone integrating with Authorize.net can <a href="http://developer.authorize.net/testaccount/">request an account</a> on this Test server for free and submit all the transactions they want and no money will ever be charged against any accounts nor will any emails be sent. An account on the Test Server is referred to as a Test Account.</p>
<p><strong>Account Level: </strong>To confuse things, you can also have your Live Authorize.net account in Test Mode. This is an option you can set in the account settings section of your account on Authorize.net. All new Live accounts are automatically placed in Test Mode and must be put in to Live Mode before they can be used to perform real transactions. When a Live Account is in Test Mode, it basically only performs the first level of processing to verify that the transaction submitted was well formed. </p>
<p>Also, Test Mode supports a feature where if you submit transactions with special credit card numbers, then the dollar amount of the transaction is returned as the Response Reason Code for the transaction. Therefore, if you submit a payment request for $1.00, it gives you a Success response. If the amount is for $2.00, you get a failed transaction with the Reason Code being 2 (“This transaction has been declined” – you can look up Response Reason Codes <a href="http://developer.authorize.net/tools/responsereasoncode/">here</a>). </p>
<p>However, transactions submitted while an account is in Test Mode never write anything to your transaction history, so there is no evidence of your tests if you log in to your account at Authorize.net (which is not true for Test Accounts, since the Test Server acts like a real live server and does all of the processing internal to Authorize.net and writes the transactions to the history for your Test Account). Note that, for what it’s worth, you can also place your Test Account (on the Test Server) in Test Mode or Live Mode, since it has the same features as a normal Live Account.</p>
<p><strong>Transaction Level: </strong>Lastly, you can submit a transaction to a Live Account in Live Mode, but set a value in the data submitted with the transaction which says to submit just this one transaction in Test Mode, and it will behave as if you are submitting a transaction to an account in Test Mode.</p>
<p>Therefore, you can submit:</p>
<div>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td><strong>Server</strong></td>
<td style="text-align: center;"><strong>Account Mode</strong></td>
<td style="text-align: center;"><strong>Transaction Mode</strong></td>
<td><strong>Action</strong></td>
</tr>
<tr>
<td style="text-align: center;">Test</td>
<td style="text-align: center;">Test</td>
<td style="text-align: center;">Test</td>
<td>Basic validation of transaction</td>
</tr>
<tr>
<td style="text-align: center;">Test</td>
<td style="text-align: center;">Test</td>
<td style="text-align: center;">Live</td>
<td>Basic validation of transaction</td>
</tr>
<tr>
<td style="text-align: center;">Test</td>
<td style="text-align: center;">Live</td>
<td style="text-align: center;">Test</td>
<td>Basic validation of transaction</td>
</tr>
<tr>
<td style="text-align: center;">Test</td>
<td style="text-align: center;">Live</td>
<td style="text-align: center;">Live</td>
<td>Acts like a real transaction, but does not settle with the payment processor</td>
</tr>
<tr>
<td style="text-align: center;">Live</td>
<td style="text-align: center;">Test</td>
<td style="text-align: center;">Test</td>
<td>Basic validation of transaction</td>
</tr>
<tr>
<td style="text-align: center;">Live</td>
<td style="text-align: center;">Test</td>
<td style="text-align: center;">Live</td>
<td>Basic validation of transaction</td>
</tr>
<tr>
<td style="text-align: center;">Live</td>
<td style="text-align: center;">Live</td>
<td style="text-align: center;">Test</td>
<td>Basic validation of transaction</td>
</tr>
<tr>
<td style="text-align: center;">Live</td>
<td style="text-align: center;">Live</td>
<td style="text-align: center;">Live</td>
<td>Submits a real/live transaction</td>
</tr>
</tbody>
</table>
</div>
<div style="margin: 1em 0 1em 0;">A simpler and more readable distillation of the table above comes out as:</div>
<ul>
<li style="margin-bottom:1em;">If either the account is in Test Mode or the transaction is marked as a Test Transaction, then only basic validation of the request is performed.</li>
<li style="margin-bottom:1em;">If the account is in Live Mode and the transaction is not marked as a Test Transaction, then&#8230;
<ul>
<li style="margin-bottom:1em;">If submitting against the Test Server it acts like a normal transaction but no money changes hands</li>
<li style="margin-bottom:1em;">If submitting agains the Live Server then, assuming everything is okay, money will change hands.</li>
</ul>
</li>
</ul>
<p>I hope this helps those of you who are trying to integrate with Authorize.net and implement payment processing on your website. Let me know if you have any questions!</p>
]]></content:encoded>
			<wfw:commentRss>http://drp.itdevworks.com/index.php/2009/10/authorize-net-terminology-overload-test-vs-live/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Did you know?: Authorize.net per-transaction charge on validating CIM PaymentProfile</title>
		<link>http://drp.itdevworks.com/index.php/2009/10/authorize-net-per-transaction-charge-on-validating-cim-paymentprofile/</link>
		<comments>http://drp.itdevworks.com/index.php/2009/10/authorize-net-per-transaction-charge-on-validating-cim-paymentprofile/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 05:17:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://drp.itdevworks.com/?p=18</guid>
		<description><![CDATA[Update 2009-10-18:  Authorize.net has posted an announcement on their forums regarding support of Visa Mandates surrouding validation charges.  In short, if you submit a transaction for $0.01 (or something similar) but do not &#8220;fully reverse&#8221; the charge, you could be subject to a &#8220;Misuse of Authorization&#8221; fee.  Instead, Visa will allow you to submit a [...]]]></description>
			<content:encoded><![CDATA[<p></p><div style="border: solid 1px red;"><span style="color: #ff0000;"><strong>Update 2009-10-18:</strong><span style="color: #000000;"><strong>  </strong>Authorize.net has posted an announcement on their forums regarding support of Visa Mandates surrouding validation charges.  In short, if you submit a transaction for $0.01 (or something similar) but do not &#8220;fully reverse&#8221; the charge, you could be subject to a &#8220;Misuse of Authorization&#8221; fee.  Instead, Visa will allow you to submit a charge for $0.00 for account verification (for which you will, naturally, be charged an &#8220;Account Verification Fee&#8221;, which is presumably lower than the &#8220;Misuse of Authorization&#8221; fee).  However, not all payment processors will be implementing the Visa mandates at the same time, and some payment processors may only implement part of the mandates or even not at all.  Fortunately, if you use the CIM <em>validateCustomerPaymentProfileRequest</em> call (or any request that supports the <em>validationMode</em> member), Authorize.net will do the right thing behind the scenes depending upon which payment processor your merchant account uses.  </span></span><br />
<span style="color: #ff0000;"><span style="color: #000000;"><br />
The full announcement can be seen <a href="http://community.developer.authorize.net/t5/News-and-Announcements/Authorize-Net-Support-of-Visa-Mandates/td-p/518" target="_blank">here</a>.</span></span></div>
<p> </p>
<p>I was working on a project for a client recently that involved <a href="http://www.authorize.net/solutions/merchantsolutions/merchantservices/cim/" target="_blank">Authorize.net CIM</a> integration. The client is a member organization and they bill all of their members once-per-year on the same day.  With approximately 4,000 members, this means they needed to make sure that credit cards and bank accounts had not expired, been closed, or anything else which would prevent successful billing since the previous billing cycle the year before.  To accomplish this, they planned to use the <em>validateCustomerPaymentProfileRequest </em>feature of the CIM service.  They asked me how the validation worked and if it would actually charge anything against the cards. I had pondered this question in the past, but I had never actually done the legwork to figure it out. Now I had a client paying me for it, so I used what for me has been the quickest method of getting to Authorize.net support, the Live Chat feature available from the link at the top of the page when you log in to your Authorize.net account.  What follows is the transcript of that chat:</p>
<div style="margin-left: 1em; margin-right:1em;">
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="color: #0066cc;">Welcome to the ANET chat forum. For your security, account updates can’t be processed through chat. Please don’t send any bank, credit card, or SSN information. For further help, please visit our Knowledge Base: </span><a href="http://www.authorize.net/help"><span style="color: #0066cc;">http://www.authorize.net/help</span></a></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="color: #0066cc;">You have been connected to Travis A.</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #0066cc;">Travis A:</span><span style="color: #0066cc;"> Hello David! How can I help you today?</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt; color: #333333;"><span style="font-weight: bold;">Me:</span> Wow. that was fast.</p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #333333;">Me:</span><span style="color: #333333;"> I have (hopefully) a quick question regarding the Customer Information Manager (CIM) service&#8230;</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #333333;"><span style="font-weight: bold; color: #333333;">Me</span>:</span><span style="color: #333333;"> Is this something you can help with?</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #0066cc;">Travis A:</span><span style="color: #0066cc;"> of course</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #333333;"><span style="font-weight: bold; color: #333333;">Me</span>:</span><span style="color: #333333;"> When making a validateCustomerPaymentProfileRequest, as I understand it, the PaymentProfile (be it credit card or bank account) is charged $.01 to validate that the account info is valid, and then the charge is removed. How is this accomplished? Does it Authorize but not Capture, Authorize and Capture, but then Void it, or something else?</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #0066cc;">Travis A:</span><span style="color: #0066cc;"> It is an Authorize Only transaction, and then it voids the transactions.</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #333333;"><span style="font-weight: bold; color: #333333;">Me</span>:</span><span style="color: #333333;"> Therefore I presume that there is no transaction fees incurred, correct?</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #0066cc;">Travis A:</span><span style="color: #0066cc;"> There is the basic transaction fee for the auth only, which is $0.10</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt; color: #333333;"><span style="font-weight: bold;"><span style="font-weight: bold; color: #333333;">Me</span>:</span> Hmmm&#8230; so it will cost $100 for every 1000 payment profiles validated.</p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #0066cc;">Travis A:</span><span style="color: #0066cc;"> Correct.</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #333333;"><span style="font-weight: bold; color: #333333;">Me</span>:</span><span style="color: #333333;"> Okay. that&#8217;s what I needed to know. Thank you for your assistance.</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #0066cc;">Travis A:</span><span style="color: #0066cc;"> Thanks for dropping by, David! Please feel free to contact us again with further questions. If you would like a copy of this session for reference, please click on the &#8220;Print&#8221; icon.</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="font-weight: bold; color: #333333;"><span style="font-weight: bold; color: #333333;">Me</span>:</span><span style="color: #333333;"> Okay. thanks. [signing-off]</span></p>
<p style="margin: 0in; font-family: arial; font-size: 10pt;"><span style="color: #333333;"><br />
</span></p>
</div>
<p>Yowza! So it is going to cost my client roughly $400 just to validate that the payment profiles they have are valid. This was a bit of a surprise to me.  In the end, the client just submitted the payments and dealt with the rejections afterwards since it was cheaper than paying the 10-cents for all of the valid payment profiles (which was, of course, the vast majority of them).</p>
<p>So if you find yourself batch validating a large number of payment profiles on Authorize.net&#8217;s CIM service, you should know that you pay a per-transaction charge for each PaymentProfile validated via the validateCustomerPaymentProfileRequest method or if the validationMode element is set to liveMode for createCustomerProfileRequest or createCustomerPaymentProfileRequest.</p>
]]></content:encoded>
			<wfw:commentRss>http://drp.itdevworks.com/index.php/2009/10/authorize-net-per-transaction-charge-on-validating-cim-paymentprofile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
