How To: Credit Card/ACH Integration with ASP.NET / VB.NET

This is the third in a series of postings on how to integrate credit card and ACH/E-check transactions into various systems. This installment demonstrates code used for processing payments (credit card and/or ACH) within a VB.NET application.

This was taken from the NELiX TransaX FleXport toolkit documentation. Credit card integration examples can be downloaded on the NELiX TransaX FleXport page.

Assumptions:
- Using NELiX TransaX Payment Gateway
- Communicating using NELiX TransaX Webservice
Partial Public Class GatewayAPI_Demo
Inherits System.Web.UI.Page

Public connStr, vSQL, vID, vMode, vMSG

Protected Sub ContinueButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) _
Handles ContinueButton.Click

Dim ws As New RoXAPI.RoXAPI
Dim wsParams As New RoXAPI.Params
Dim wsResponse As New RoXAPI.Responses

wsParams.TransactionType = Me.TransactionType.SelectedValue
wsParams.GatewayUserName = Me.GatewayUserName.Text
wsParams.GatewayPassword = Me.GatewayPassword.Text
wsParams.IPAddress = HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")

wsParams.Merchant_Defined_Field_1 = Merchant_Defined_Field_1.Text
wsParams.Merchant_Defined_Field_2 = Merchant_Defined_Field_2.Text

If Me.TransactionType.SelectedValue = "void" Then
wsParams.TransactionID = Me.TransactionID.Text
wsParams.PaymentType = Me.PaymentType.SelectedValue
End If

If Me.TransactionType.SelectedValue = "refund" Then
wsParams.Amount = Me.Amount.Text
wsParams.TransactionID = Me.TransactionID.Text
wsParams.PaymentType = Me.PaymentType.SelectedValue
End If

If Me.TransactionType.SelectedValue = "capture" Then
wsParams.Amount = Me.Amount.Text
wsParams.TransactionID = Me.TransactionID.Text
wsParams.OrderID = Me.OrderID.Text
wsParams.Tracking_Number = Me.Tracking_Number.Text
wsParams.Shipping_Carrier = Me.Shipping_Carrier.Text
wsParams.PaymentType = Me.PaymentType.SelectedValue
End If

If Me.TransactionType.SelectedValue = "update" Then
wsParams.TransactionID = Me.TransactionID.Text
wsParams.Tracking_Number = Me.Tracking_Number.Text
wsParams.Shipping_Carrier = Me.Shipping_Carrier.Text
wsParams.PaymentType = Me.PaymentType.SelectedValue
End If

If Me.Customer_Vault_Action.SelectedValue = "delete_customer" Then
wsParams.Customer_Vault_Action = Me.Customer_Vault_Action.SelectedValue
wsParams.Customer_Vault_ID = Me.Customer_Vault_ID.Text
End If

If Me.TransactionType.SelectedValue = "sale" Or Me.TransactionType.SelectedValue = "auth" Or _
Me.Customer_Vault_Action.SelectedValue = "add_customer" Or _
Me.Customer_Vault_Action.SelectedValue = "update_customer" Then
wsParams.PaymentType = Me.PaymentType.SelectedValue

If Me.Customer_Vault_Action.SelectedValue = "add_customer" Or _
Me.Customer_Vault_Action.SelectedValue = "update_customer" Then
wsParams.Customer_Vault_Action = Me.Customer_Vault_Action.SelectedValue
End If
wsParams.Customer_Vault_ID = Me.Customer_Vault_ID.Text

If wsParams.PaymentType = "creditcard" Then
wsParams.CCNumber = Me.CCNumber.Text
wsParams.CCExpDate = Me.CCExpDate.Text
wsParams.CVV = Me.CVV.Text
End If
If wsParams.PaymentType = "check" Then
wsParams.CheckName = Me.CheckName.Text
wsParams.CheckABA = Me.CheckABA.Text
wsParams.CheckAccount = Me.CheckAccount.Text
wsParams.AccountHolderType = Me.AccountHolderType.SelectedValue
wsParams.AccountType = Me.AccountType.SelectedValue
wsParams.SecCode = Me.SecCode.SelectedValue
End If

wsParams.Payment_Plan_SKU = Me.Payment_Plan_SKU.Text

wsParams.Amount = Me.Amount.Text
wsParams.Tax = Me.Tax.Text
wsParams.Shipping = Me.Shipping.Text
wsParams.OrderDescription = Me.OrderDescription.Text
wsParams.OrderID = Me.OrderID.Text
wsParams.PONumber = Me.PONumber.Text

wsParams.FirstName = Me.FirstName.Text
wsParams.LastName = Me.LastName.Text
wsParams.Company = Me.Company.Text
wsParams.Address1 = Me.Address1.Text
wsParams.Address2 = Me.Address2.Text
wsParams.City = Me.City.Text
wsParams.State = Me.State.Text
wsParams.Zip = Me.Zip.Text
wsParams.Country = Me.Country.Text
wsParams.Phone = Me.Phone.Text
wsParams.Fax = Me.Fax.Text
wsParams.EMail = Me.EMail.Text
wsParams.Website = Me.Website.Text

wsParams.ShippingFirstName = Me.ShippingFirstName.Text
wsParams.ShippingLastName = Me.ShippingLastName.Text
wsParams.ShippingCompany = Me.ShippingCompany.Text
wsParams.ShippingAddress1 = Me.ShippingAddress1.Text
wsParams.ShippingAddress2 = Me.ShippingAddress2.Text
wsParams.ShippingCity = Me.ShippingCity.Text
wsParams.ShippingState = Me.ShippingState.Text
wsParams.ShippingZip = Me.ShippingZip.Text
wsParams.ShippingCountry = Me.ShippingCountry.Text
wsParams.ShippingEmail = Me.ShippingEmail.Text

wsParams.ProcessorID = Me.ProcessorID.Text
wsParams.Descriptor = Me.Descriptor.Text
wsParams.DescriptorPhone = Me.DescriptorPhone.Text
End If


wsResponse = ws.ProcessTransaction(wsParams)

MSG.Text = "STATUS_CODE: " & wsResponse.STATUS_CODE & "
"
MSG.Text += "STATUS_MSG: " & wsResponse.STATUS_MSG & "
"
MSG.Text += "TRANS_ID: " & wsResponse.TRANS_ID & "
"
MSG.Text += "AUTH_CODE: " & wsResponse.AUTH_CODE & "
"
MSG.Text += "AVS_CODE: " & wsResponse.AVS_CODE & "
"
MSG.Text += "AVS_MSG: " & wsResponse.AVS_MSG & "
"
MSG.Text += "CVV2_CODE: " & wsResponse.CVV2_CODE & "
"
MSG.Text += "CVV2_MSG: " & wsResponse.CVV2_MSG & "
"
MSG.Text += "ORDERID: " & wsResponse.ORDERID & "
"
MSG.Text += "CUSTOMER_VAULT_ID: " & wsResponse.CUSTOMER_VAULT_ID & "
"
MSG.Text += "FULLRESPONSE: " & wsResponse.FULLRESPONSE & "
"
MSG.Text += "POSTSTRING: " & wsResponse.POSTSTRING & "
"

If wsResponse.STATUS_CODE = "1" Then
MSG.Text = "SUCCESS!
" & MSG.Text
Else
If wsResponse.STATUS_CODE = "2" Then
MSG.Text = "DECLINE
" & MSG.Text
Else
MSG.Text = "ERROR
" & MSG.Text
End If
End If



End Sub
End Class


If you need any assistance with payment processing integration with your .NET system, we are here to help!

Download ASP.NET / VB.NET credit card and ACH (e-check) integration examples.

Comments

Popular posts from this blog

Virtual Terminal now supports EMV and NFC

Hosted Payment Pages: Customized, Mobilized, and QR Code'ized