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

Welcome to the world of computing.


-------------------------------------------------------------------------------------------------------------------------------------------
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