<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic C# SDK, CIM - Exposing ReasonCode in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/C-SDK-CIM-Exposing-ReasonCode/m-p/29084#M15290</link>
    <description>&lt;P&gt;I recently discovered that the ReasonCode was not properly exposed on in the C# SDK's version of a transaction response. &amp;nbsp;The fix ended up being a palm to forehead moment for me. &amp;nbsp;Here it is!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's take an overly simplified transaction request...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;private void GetResponse(string profileID, string paymentProfileID, string shippingAddressID)
        {
            Order order = new Order(profileID, paymentProfileID, shippingAddressID);
            //Build the order

            var response = AuthAndCapture(order);&lt;BR /&gt;            string reasonCode = response.ReasonCode;  &amp;lt;&amp;lt;  IMPOSSIBLE!  :(
        }  

private IGatewayResponse AuthAndCapture(Order order)
        {
            var req = new createCustomerProfileTransactionRequest();
            var trans = new profileTransAuthCaptureType();
            //Build the request

            var response = (createCustomerProfileTransactionResponse)_gateway.Send(req);
            
            return new GatewayResponse(response.directResponse.Split(','));
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The response in GetResponse() will not contain contain the result code and result text, but not the reason code. &amp;nbsp;This works just fine if the transaction is successful, but quite a hassle if it is not. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Open the GatewayResponse.cs class in the AIM &amp;gt; Responses directory of the SDK and insert the follwing property into the existing list:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public string ReasonCode {
            get {
                return ParseResponse(2);
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next open the IGatewayResponse.cs interface in the same directory and add the following property: &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;string ReasonCode { get; }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now the GetResponse() method has access to the ReasonCode! &amp;nbsp;Huzzah!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;private void GetResponse(string profileID, string paymentProfileID, string shippingAddressID)
        {
            Order order = new Order(profileID, paymentProfileID, shippingAddressID);
            //Build the order

            var response = AuthAndCapture(order);&lt;BR /&gt;            string reasonCode = response.ReasonCode;
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Aug 2012 19:14:56 GMT</pubDate>
    <dc:creator>crmGuy</dc:creator>
    <dc:date>2012-08-24T19:14:56Z</dc:date>
    <item>
      <title>C# SDK, CIM - Exposing ReasonCode</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/C-SDK-CIM-Exposing-ReasonCode/m-p/29084#M15290</link>
      <description>&lt;P&gt;I recently discovered that the ReasonCode was not properly exposed on in the C# SDK's version of a transaction response. &amp;nbsp;The fix ended up being a palm to forehead moment for me. &amp;nbsp;Here it is!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's take an overly simplified transaction request...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;private void GetResponse(string profileID, string paymentProfileID, string shippingAddressID)
        {
            Order order = new Order(profileID, paymentProfileID, shippingAddressID);
            //Build the order

            var response = AuthAndCapture(order);&lt;BR /&gt;            string reasonCode = response.ReasonCode;  &amp;lt;&amp;lt;  IMPOSSIBLE!  :(
        }  

private IGatewayResponse AuthAndCapture(Order order)
        {
            var req = new createCustomerProfileTransactionRequest();
            var trans = new profileTransAuthCaptureType();
            //Build the request

            var response = (createCustomerProfileTransactionResponse)_gateway.Send(req);
            
            return new GatewayResponse(response.directResponse.Split(','));
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The response in GetResponse() will not contain contain the result code and result text, but not the reason code. &amp;nbsp;This works just fine if the transaction is successful, but quite a hassle if it is not. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Open the GatewayResponse.cs class in the AIM &amp;gt; Responses directory of the SDK and insert the follwing property into the existing list:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public string ReasonCode {
            get {
                return ParseResponse(2);
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next open the IGatewayResponse.cs interface in the same directory and add the following property: &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;string ReasonCode { get; }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now the GetResponse() method has access to the ReasonCode! &amp;nbsp;Huzzah!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;private void GetResponse(string profileID, string paymentProfileID, string shippingAddressID)
        {
            Order order = new Order(profileID, paymentProfileID, shippingAddressID);
            //Build the order

            var response = AuthAndCapture(order);&lt;BR /&gt;            string reasonCode = response.ReasonCode;
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2012 19:14:56 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/C-SDK-CIM-Exposing-ReasonCode/m-p/29084#M15290</guid>
      <dc:creator>crmGuy</dc:creator>
      <dc:date>2012-08-24T19:14:56Z</dc:date>
    </item>
  </channel>
</rss>

