Payment Technology Blog

Explore our modern gateway designed to help you sell more, make more and keep more.

Thursday, May 20, 2010

How To: Integrate Credit Card and ACH (e-check) processing with Classic ASP

This is the fifth part 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 Classic ASP 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
<%  Function BuildXML()   Dim vString    vString = ""         vString = vString & "" & request("TransactionType") & ""
vString = vString & "" & request("GatewayUserName") & ""
vString = vString & "" & request("GatewayPassword") & ""
vString = vString & "" & Request.Servervariables("REMOTE_HOST") & ""


vString = vString & "" & request("Merchant_Defined_Field_1") & ""
vString = vString & "" & request("Merchant_Defined_Field_2") & ""

If request("TransactionType") = "void" Then
vString = vString & "" & request("TransactionID") & ""

if request("PaymentType")="check" then
vString = vString & "" & request("PaymentType") & ""
end if
End If

If request("TransactionType") = "refund" Then
vString = vString & "" & request("Amount") & ""
vString = vString & "" & request("TransactionID") & ""

if request("PaymentType")="check" then
vString = vString & "" & request("PaymentType") & ""
end if

End If

If request("TransactionType") = "capture" Then
vString = vString & "" & request("Amount") & ""
vString = vString & "" & request("TransactionID") & ""
vString = vString & "" & request("OrderID") & ""
vString = vString & "" & request("Tracking_Number") & ""
vString = vString & "" & request("Shipping_Carrier") & ""

if request("PaymentType")="check" then
vString = vString & "" & request("PaymentType") & ""
end if
End If

If request("TransactionType") = "update" Then
vString = vString & "" & request("TransactionID") & ""
vString = vString & "" & request("Tracking_Number") & ""
vString = vString & "" & request("Shipping_Carrier") & ""

if request("PaymentType")="check" then
vString = vString & "" & request("PaymentType") & ""
end if
End If

If request("Customer_Vault_Action") = "delete_customer" Then
vString = vString & "" & request("Customer_Vault_Action") & ""
vString = vString & "" & request("Customer_Vault_ID") & ""
End If

If request("TransactionType") = "sale" Or request("TransactionType") = "auth" Or request("Customer_Vault_Action")
= "add_customer" Or request("Customer_Vault_Action") = "update_customer" Then
vString = vString & "" & request("PaymentType") & ""


If request("Customer_Vault_Action") = "add_customer" Or request("Customer_Vault_Action") = "update_customer" Then
vString = vString & "" & request("Customer_Vault_Action") & ""
End If
vString = vString & "" & request("Customer_Vault_ID") & ""

If request("PaymentType") = "creditcard" Then
vString = vString & "" & request("CCNumber") & ""
vString = vString & "" & request("CCExpDate") & ""
vString = vString & "" & request("CVV") & ""
End If
If request("PaymentType") = "check" Then
vString = vString & "" & request("CheckName") & ""
vString = vString & "" & request("CheckABA") & ""
vString = vString & "" & request("CheckAccount") & ""
vString = vString & "" & request("AccountHolderType") & ""
vString = vString & "" & request("AccountType") & ""
vString = vString & "" & request("SecCode") & ""
End If

vString = vString & "" & request("Payment_Plan_SKU") & ""

vString = vString & "" & request("Amount") & ""
vString = vString & "" & request("Tax") & ""
vString = vString & "" & request("Shipping") & ""
vString = vString & "" & request("OrderDescription") & ""
vString = vString & "" & request("OrderID") & ""
vString = vString & "" & request("PONumber") & ""

vString = vString & "" & request("FirstName") & ""
vString = vString & "" & request("LastName") & ""
vString = vString & "" & request("Company") & ""
vString = vString & "" & request("Address1") & ""
vString = vString & "" & request("Address2") & ""
vString = vString & "" & request("City") & ""
vString = vString & "" & request("State") & ""
vString = vString & "" & request("Zip") & ""
vString = vString & "" & request("Country") & ""
vString = vString & "" & request("Phone") & ""
vString = vString & "" & request("Fax") & ""
vString = vString & "" & request("EMail") & ""
vString = vString & "" & request("Website") & ""

vString = vString & "" & request("ShippingFirstName") & ""
vString = vString & "" & request("ShippingLastName") & ""
vString = vString & "" & request("ShippingCompany") & ""
vString = vString & "" & request("ShippingAddress1") & ""
vString = vString & "" & request("ShippingAddress2") & ""
vString = vString & "" & request("ShippingCity") & ""
vString = vString & "" & request("ShippingState") & ""
vString = vString & "" & request("ShippingZip") & ""
vString = vString & "" & request("ShippingCountry") & ""
vString = vString & "" & request("ShippingEmail") & ""

vString = vString & "" & request("ProcessorID") & ""
vString = vString & "" & request("Descriptor") & ""
vString = vString & "" & request("DescriptorPhone") & ""
End If


BuildXML = vString

End Function

Function SoapWrapper(vXML)
Dim S

S = ""
S = S & ""
S = S & ""
S = S & "" & vXML & "
"

SoapWrapper = S
End Function


Dim webServiceUrl, httpReq, vXML, oNode

Set httpReq = Server.CreateObject("Microsoft.XMLHTTP")

webServiceUrl = "https://www.nelixtransax.com/roxapi/rox.asmx"
vXML = SoapWrapper(BuildXML())

httpReq.Open "POST", webServiceUrl, False
httpReq.setRequestHeader "Content-Type", "text/xml"
httpReq.setRequestHeader "Connection", "close"
httpReq.setRequestHeader "SOAPAction", "https://www.nelixtransax.com/roxapi/ProcessTransaction"
httpReq.Send vXML

'Results = httpReq.responseText

Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
xmlDoc.loadXML (httpReq.responseXML.XML)
Set oNode = xmlDoc.childNodes(1).childNodes(0).childNodes(0).childNodes(0)

Results = ""
Results = Results & "STATUS_CODE: " & oNode.selectSingleNode("STATUS_CODE").Text & ""
Results = Results & "STATUS_MSG: " & oNode.selectSingleNode("STATUS_MSG").Text & ""
Results = Results & "TRANS_ID: " & oNode.selectSingleNode("TRANS_ID").Text & ""
Results = Results & "AUTH_CODE: " & oNode.selectSingleNode("AUTH_CODE").Text & ""
Results = Results & "AVS_CODE: " & oNode.selectSingleNode("AVS_CODE").Text & ""
Results = Results & "AVS_MSG: " & oNode.selectSingleNode("AVS_MSG").Text & ""
Results = Results & "CVV2_CODE: " & oNode.selectSingleNode("CVV2_CODE").Text & ""
Results = Results & "CVV2_MSG: " & oNode.selectSingleNode("CVV2_MSG").Text & ""
Results = Results & "ORDERID: " & oNode.selectSingleNode("ORDERID").Text & ""
Results = Results & "CUSTOMER_VAULT_ID: " & oNode.selectSingleNode("CUSTOMER_VAULT_ID").Text & ""
Results = Results & "FULLRESPONSE: " & Replace(oNode.selectSingleNode("FULLRESPONSE").Text, "&", "&") & ""

Set httpReq = Nothing

response.write "RESULTS:

" & Results
%>



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

Download Classic ASP credit card and ACH (e-check) integration examples.


No comments:

The biggest advantage of our gateway comes from power that it puts in the hands of your developers. Easily integrate with your application and take advantage of features to enhance your system.

We invite you to a live demo and the opportunity to build a partnership. Our promise to partners is, through innovation, today's products will be relentlessly enhanced into tomorrow's solutions.

1921-A Rohlwing Road
Rolling Meadows IL 60008-4800
P) 866-513-1547
F) 866-513-1548
info@transaxgateway.com