Reply
Contributor
Posts: 18
Registered: ‎01-09-2014
Accepted Solution

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);
            Console.Read();

        }
    }

 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.

 


Thanks!

 


Accepted Solutions
Solution
Accepted by topic author gloria10
‎08-21-2015 01:58 AM
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Different results for console application and AIM example code

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


All Replies
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Different results for console application and AIM example code

There are 2 different request

 var request = new AuthorizationRequest(post_values);

CaptureRequest

 

Contributor
Posts: 18
Registered: ‎01-09-2014

Re: Different results for console application and AIM example code

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?

 

Thanks.

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Different results for console application and AIM example code

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

 

Contributor
Posts: 18
Registered: ‎01-09-2014

Re: Different results for console application and AIM example code

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

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

 

 

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Different results for console application and AIM example code

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

Contributor
Posts: 18
Registered: ‎01-09-2014

Re: Different results for console application and AIM example code

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?

 

Thanks.

 

 

 

Solution
Accepted by topic author gloria10
‎08-21-2015 01:58 AM
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Different results for console application and AIM example code

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");

 

Contributor
Posts: 18
Registered: ‎01-09-2014

Re: Different results for console application and AIM example code

Thanks!

That did it!