Home > Developers: Integration Overview > Transparent Database Engine > ASP.Net: Transparent Database Engine

Use of this integration template requires intermediate- to advanced-level programming capability. eProcessing Network offers support for this template via email only at devutils@eprocessingnetwork.com.

eProcessing Network offers the following sample ASP.Net 2.0 source code to assist developers in integrating the eProcessing Network Transparent Database Engine Template for payment processing.

Please note the following:

  • The sample source code shown below uses hard-coded values. You, as a programmer, must replace these hard-coded values with the values you prompt customers for.
  • The hard-coded test account number can be used if you do not yet have an eProcessing Network account. A test transaction can be run at anytime by simply using the merchant's eProcessing Network account number as the credit card number, regardless of whether you are using a test account number or a live account number.
  • ExpMonth and ExpYear must both be in two-digit format or you will very definitely achieve unexpected results because of the different ways issuing banks process transactions.

The required format of the variable names to pass to the eProcessing Network Transparent Database Engine Template is as follows:

ePNAccount, CardNo, ExpMonth, ExpYear, Total, Address, Zip

It is assumed here that the programmer will populate these variables from values obtained from customers visiting a merchants' web site.

VB.Net 2.0 Sample Code:

  <%@ Page Language="vb" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Threading" %>

<script language="vb" runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim sPostString As String
sPostString = New String("")

' Standard but minimal TDBE transaction

sPostString = BuildPost(sPostString, "ePNAccount", "05971")
sPostString = BuildPost(sPostString, "CardNo", "05971")
sPostString = BuildPost(sPostString, "ExpMonth", "12")
sPostString = BuildPost(sPostString, "ExpYear", "10")
sPostString = BuildPost(sPostString, "Total", "12.00")
sPostString = BuildPost(sPostString, "Address", "123 Main Street")
sPostString = BuildPost(sPostString, "Zip", "12345")
sPostString = BuildPost(sPostString, "HTML", "No")

Log("Post String :" & sPostString & ":") Dim sResultString As String ' Now post it. sResultString = subXMLPostProcess("https://www.eprocessingnetwork.com/cgi-bin/tdbe/transact.pl", sPostString) ' An Approval looks like this ' "YAUTH/TKT 027193","Address and Zip Code Do Not Match (N)" ' Sometimes the lead quote is not there depending on the reason ' for a decline Dim cApproved As Char Dim bApproved As Boolean bApproved = False cApproved = sResultString.Chars(0) If cApproved = ControlChars.Quote Then cApproved = sResultString.Chars(1) End If If cApproved = "Y" Then bApproved = True End If If bApproved Then Log("Do something if Approved") Else Log("Do something if Declined") End If Log("Result :" & sResultString & ":") End Sub ' This function will build assist you in building a post string one ' field and value at a time. ' ' A post string looks like this ' ' ePNAccount=05971&Total=12.99 ' ' If any of the values have illegal url characters in it, the url ' encode function will properly handle it ' Function BuildPost(ByVal sPrevPost As String, ByVal sField As String, ByVal sValue As String) If sPrevPost Is Nothing Then BuildPost = New String("") Else BuildPost = sPrevPost + "&" End If BuildPost = BuildPost + sField BuildPost = BuildPost + "=" BuildPost = BuildPost + HttpUtility.UrlEncode(sValue) End Function ' ' All output is done by this Log function, you can redirect it ' to a file if you want, here it goes to HTML ' Sub Log(ByVal sMsg As String) myOutput.Text += "<p>" + sMsg + "</p>" End Sub ' ' this function actually performs the cgi post, give it a url and a ' post string and voila ' Function subXMLPostProcess(ByVal sURL As String, ByVal sRequestString As String) As String Log("subXMLPostProcess: A") Dim ResultString As String = New String("") Dim myWebRequest As HttpWebRequest ' ' Set up the Web request, with the url time out and that ' we want to "POST" ' myWebRequest = WebRequest.Create(sURL) myWebRequest.Method = "POST" myWebRequest.ContentType = "application/x-www-form-urlencoded" myWebRequest.Timeout = 180000 ' i.e. 3 minutes myWebRequest.KeepAlive = False Dim myOutputStream As Stream Try myOutputStream = myWebRequest.GetRequestStream() Catch e As Exception Return e.Message End Try Dim myBytes As Byte() ' Force ASCII encoding myBytes = System.Text.Encoding.ASCII.GetBytes(sRequestString) myOutputStream.Write(myBytes, 0, myBytes.Length) myOutputStream.Close() Dim myWebResponse As WebResponse = myWebRequest.GetResponse() ' Call method 'GetResponseStream' to obtain stream associated with the response object Dim ReceiveStream As Stream = myWebResponse.GetResponseStream() Dim encode As System.Text.Encoding = System.Text.Encoding.GetEncoding("utf-8") Try Log("subXMLPostProcess: B") ' Pipe the stream to a higher level stream reader with the required encoding format. Dim readStream As New StreamReader(ReceiveStream, encode) Log(ControlChars.Cr + "Response stream received") Dim read(256) As [Char] ' Read 256 charcters at a time . Dim count As Integer = readStream.Read(read, 0, 256) Log("HTML..." + ControlChars.Lf + ControlChars.Cr) While count > 0 ' Dump the 256 characters on a string and display the string onto the console. ResultString = ResultString + New [String](read, 0, count) 'Debug.Write(ResultString) count = readStream.Read(read, 0, 256) End While ' Release the resources of stream object. readStream.Close() ' Release the resources of response object. myWebResponse.Close() Catch ex As Exception Log("XMLPostProcess: Exception (" & ex.Message & ")") Log(ex.StackTrace) End Try subXMLPostProcess = ResultString Log("subXMLPostProcess: OUT") End Function </script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>eProcessing Network ASP.Net TDBE Test</title> </head> <body> <div> <asp:Literal ID="myOutput" runat="server" /> </div> </body> </html>

By default, the eProcessing Network Transparent Database Engine Template outputs its' response in HTML format, i.e. wrapped in <html> and <body> tags, which can often aid in testing. Sending the additional variable HTML set to No causes the template to output the response without the HTML tags.

After the transaction has been processed, the banks' response to the transaction, as well as the Address Verification System response, are output as follows:

With HTML:

<html><body>"YAUTH/TKT 019829","Address and Zip Code Do Not Match"</body></html>

Without HTML:

"YAUTH/TKT 019829","Address and Zip Code Do Not Match"

The response is essentially two quoted, comma-delimited strings. The first string always starts with a Y (Yes, approved), an N (No, declined) or a U (No, unable), and is followed by up to 16 characters describing the response. The second string is the Address Verification Systems' response to the street address and Zip code supplied.

 

For questions, suggestions or special requests, email us at devutils@eprocessingnetwork.com.

Facebook   LinkedIn   YouTube
Copyright 2014 eProcessing Network, LLC. All Rights Reserved.