cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with the card present C# testing example

I am attempting to create a test program that will submit a test transaction to authorize.net from a win forms c#  application.  The plan is to have a software solution that integrates with a card reader and submits the information to authorize.net for processing.  

 

The issue that I am having is that when I attempt to send the request over the gateway, the program hangs.  All lines of code, including the line that displays the response code do not get processed.  

 

I have setup a test account and logged into test.authorize.net, and received an API login Id and transaction id.  I am also using the sample credit card numbers that were provided in the test account confirmation email.

 

I am new to all of this so I am not too sure what I could be doing wrong.  I have pasted a code snippet below and would appreciate any feedback as to what I might be doing wrong,  thanks.

 

private void purchase(string track1, string track2, decimal amount)
{
Console.WriteLine("Purchasing....");

var request = new CardPresentAuthorizationRequest(10.0M, track1, track2);
string apiLoginId = "MY_API_ID"; //I use the real one in my code
string transactionKey = "MY_TRANSACTION_ID"; //I use the real one in my code

var gate = new CardPresentGateway(apiLoginId, transactionKey, true);

Console.WriteLine("Starting transaction");
var response = (CardPresentResponse)gate.Send(request, "Test request"); // This is the line of code my program never gets past
Console.WriteLine("Transaction complete");
Console.WriteLine("Purchased!: {0}: {1}", response.ResponseCode, response.Message);
}

adamR839
Member
10 REPLIES 10

Hi Adam,

 

I am also running into similiar issue.

Error: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host

 

I used AIM Integration integrate with an console application to test and I have also used the same cardnumber,test api,transactionkey as provided in AIM example.

developer26
Member

My guess is the problem with the Test_URL

 

public const string TEST_URL = "https://test.authorize.net/gateway/transact.dll";
public const string LIVE_URL = "https://secure.authorize.net/gateway/transact.dll";

 

when i tried  with the LIVE_URL atleast then I am getting response: 

(13) The merchant login ID or password is invalid or the account is inactive.

 

but the TEST_URL doesn't do anything it seems this URL doesn't exists anymore.

 

Any help will be really appreciated.

That URL does still work. To use it you must have a developer account. You use the live URL you must have an active live Authorize.Net and merchant account.


-------------------------------------------------------------------------------------------------------------------------------------------
John Conde :: Certified Authorize.Net Developer (Brainyminds) :: Official Authorize.Net Blogger

NEW! Handling Authorize.Net's Webhooks with PHP

Integrate Every Authorize.Net JSON API with One PHP Class (Sample code included)

Tutorials for integrating Authorize.Net with PHP: AIM, ARB, CIM, Silent Post
All About Authorize.Net's Silent Post

I am not getting any sort of error message, my program is simply running and not proceeding through the rest of the method.

Not sure what to tell you as I am not a C# developer so you'll have to wait until those guys come around and offer their advice. But you can be sure both of those servers are definitely up and running unless you see a message in the news and announcements forum stating otherwise.


-------------------------------------------------------------------------------------------------------------------------------------------
John Conde :: Certified Authorize.Net Developer (Brainyminds) :: Official Authorize.Net Blogger

NEW! Handling Authorize.Net's Webhooks with PHP

Integrate Every Authorize.Net JSON API with One PHP Class (Sample code included)

Tutorials for integrating Authorize.Net with PHP: AIM, ARB, CIM, Silent Post
All About Authorize.Net's Silent Post

Did it error timeout after like 90 second? can you access the test URL on the browser on the same pc?

I can pull up the test site,https://test.authorize.net/gateway/transact.dll, in the browser no problem.  I am not entirely certain where the program is getting hung at but, once I call gate.Send(request), this function never returns and I never see any output indicating there is a reponse.

I download the source and not seeing anything. But it did hard code the delimited char as the pipe '|'.  Did you try debug with the source?

I did not change anything but it appears to be working fine today.  I am not sure what is different.