Showing results for 
Search instead for 
Did you mean: 

Different results for console application and AIM example code

I can successfully run the AIM example code which posts transactions using ASP.NET.

When I change the transaction types from Auth_Capture and Capture_Only and add the x_auth_code, it is also successfully.  When I remove the x_auth_code, it responds as expected, reporting that it needs the auth. code.


When I try to do these changes in the console application, it always completes the transaction.  When I do not include the x_auth_code for a Capture_Only, the transaction completes successfully.  This is the code of the console application that I added or changed to get the above results:


class Program
        static void Main(string[] args)
          NameValueCollection post_values = new NameValueCollection();
           post_values.Add("x_version", "3.1");
            post_values.Add("x_delim_data", "TRUE");
            post_values.Add("x_delim_char", "|");
            post_values.Add("x_relay_response", "FALSE");

            post_values.Add("x_type", "CAPTURE_ONLY");
            post_values.Add("x_method", "CC");
            post_values.Add("x_card_num", "6011000000000012");
            post_values.Add("x_exp_date", "1015");

            post_values.Add("x_amount", "50.00");
            post_values.Add("x_description", "No auth code for Capture only");
             var request = new AuthorizationRequest(post_values);
            //step 2 - create the gateway, sending in your credentials
            //I use my correct login and transaction key but do not want to post it.
            var gate = new Gateway("I use correct login", 
                                   "I use correct transaction key");
            //step 3 - make some money
            var response = gate.Send(request);
            Console.WriteLine("ResponseCode-{0}: ResponseMessage-{1} AuthorizationCode-{2} TransactionID-{3} ", 
                response.ResponseCode, response.Message, response.AuthorizationCode, response.TransactionID);


 This example should report an error because there is not x_auth_code set.  However, the transaction completes successfully and I can view it as an unsettled transaction.  Its status is listed as 'Captured/Pending Settlement' like all of the others.


Shouldn't it throw an error like the AIM Example does?


I believe I will want to use the console version when I am updating my web service to use Authorize.Net.  So I need to understand how these requests are different from the ASP.NET example.





Accepted Solutions

If you going to use CaptureRequest you can add the cc# and expired date like

request.Queue(ApiFields.CreditCardNumber, "4111111111111111");
request.Queue(ApiFields.CreditCardExpiration, "0615");


View solution in original post


There are 2 different request

 var request = new AuthorizationRequest(post_values);




If I want to have an option for a voice authorization transaction, do I have to do 2 separate requests?

First an Authorization Only request, then a Capture Request?



No. I mean to change your program, so instead of

 post_values.Add("x_type", "CAPTURE_ONLY");

to override the x_type on the request


use either the AuthorizationRequest or CaptureRequest


But to create a CaptureRequest object, you need a transactionID.

To get a transactionID, don't you need to create an authorization only request?



I think you just pass in 0 for that. Not sure why is there a transactionID field.

Whether I use the transactionID of 0 or the response.TransactionID

I get the error that I need a credit card number.

There is not CaptureRequest constructor that allows for the credit card number and expiration date.


The CaptureRequest constructor parameters are only:

    decimal (I assume this is the amount of the charge)

    transactionID - "0"

    authorization code - This would be the voice authorization code


I need to be able to complete a Voice Authorization transaction.

The documentation says I need to use CaptureRequest method. 

What other methods do I need?






If you going to use CaptureRequest you can add the cc# and expired date like

request.Queue(ApiFields.CreditCardNumber, "4111111111111111");
request.Queue(ApiFields.CreditCardExpiration, "0615");



That did it!