Example Code?

Jun 20, 2008 at 2:47 AM
Is there any way someone could post a few short pieces of example code to do a charge (auth-capture) and refund (credit) using the class?

this is awesome btw I just want to make sure I understand how to use it.
Aug 8, 2008 at 10:44 PM
Edited Aug 10, 2008 at 8:32 PM
The code below is a console application, and we are actually using that code for testing transactions. Enjoy!

Rick
Aug 9, 2008 at 12:29 AM

 

Sub Main()

 

 

Dim T As New AuthorizeNET.Transaction()

 

 

Dim tr As AuthorizeNET.TransactionResponse = Nothing

 

T.TransactionDetails =

New AuthorizeNET.CreditCardTransactionDetails(12, "USD", AuthorizeNET.TransactionType.AuthCapture, AuthorizeNET.TestCards.VisaErrorTestCard, New Date(2008, 12, 1), "123", "", "", "", "")

 

T.GatewayConfiguration.DelimitResponseData =

True

 

T.MerchantAccount =

New AuthorizeNET.MerchantAccountInformation(ApiLoginCNP, TransactionKeyCNP, AuthorizeNET.ResponseVersion.Version3_1, True)

 

T.Customer =

New AuthorizeNET.Customer("Test", "Customer", "Acme Company", "1234 Main St", "Las Vegas", "NV", "89031", "USA", "702-555-0000", "", "1", "192.168.1.1", "")

 

 

 

Dim response As String = AuthorizeNET.GatewayCommunicator.SendTransactionRequest(T, True)

 

tr =

New AuthorizeNET.TransactionResponse(response)

 

Console.WriteLine(

"ApprovalCode: " + tr.ApprovalCode)

 

Console.WriteLine(

"AVSResultCode: " + tr.AVSResultCode)

 

Console.WriteLine(

"Description: " + tr.Description)

 

Console.WriteLine(

"ResponseCode: " + tr.ResponseCode)

 

Console.WriteLine(

"ResponseReasonCode: " + tr.ResponseReasonCode)

 

Console.WriteLine(

"ResponseReasonText: " + tr.ResponseReasonText)

 

Console.WriteLine(

"ResponseSubcode: " + tr.ResponseSubcode)

 

Console.WriteLine(

"TransactionID: " + tr.TransactionID)

 

Console.WriteLine(

"")

 

Console.WriteLine(

"Press any key...")

 

Console.ReadKey()

 

End Sub

 

Coordinator
Aug 10, 2008 at 5:50 PM
I'll create three flavors of sample code using this library: C#, VB.NET, and JScript.NET.  As soon as I have those ready, I'll get them posted on the wiki.  Thanks again for your patience and sorry about any delays.