PM> Install-Package AuthorizeNet
Requires .NET 3.5 or later and Microsoft® Visual Studio 2008 or 2010; Nunit 2.6.3;
To install AuthorizeNet, run the following command in the Package Manager Console:
PM> Install-Package AuthorizeNet
Apart from this README, you can find details and examples of using the SDK in the following places:
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = ApiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = ApiTransactionKey,
};
var creditCard = new creditCardType
{
cardNumber = "4111111111111111",
expirationDate = "0718"
};
var paymentType = new paymentType { Item = creditCard };
var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),
amount = 133.45m,
payment = paymentType
};
var request = new createTransactionRequest { transactionRequest = transactionRequest };
var controller = new createTransactionController(request);
controller.Execute();
var response = controller.GetApiResponse();
if (response.messages.resultCode == messageTypeEnum.Ok)
{
if (response.transactionResponse != null)
{
Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);
}
}
else
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
}
Set the appropriate environment constant using the ApiOperationBase RunEnvironment. For example, in the method above, to switch to production environment use:
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.PRODUCTION;
All the tests can be run against a stub backend using the USELOCAL run configuration.
Get a sandbox account at https://developer.authorize.net/sandbox/ Update app.config in the AuthorizeNetTest folder to run all the tests against your sandbox account
For reporting tests, go to https://sandbox.authorize.net/ under Account tab->Transaction Details API and enable it.
For your reference, you can use the following test credit card numbers. The expiration date must be set to the present date or later. Use 123 for the CCV code.
Card | Test Numbers |
---|---|
American Express | 370000000000002 |
Discover | 6011000000000012 |
Visa | 4007000000027 |
MasterCard | 5555555555554444 |
JCB | 3088000000000017 |
Diners Club/ Carte Blanche | 38000000000006 |
Visa (Card Present Track 1) | %B4111111111111111^DOE/JOHN^1803101000000000020000831000000? |