 |
 |
 |
 |
 |
 |
 |
 |
|
|
|
|
|
|
|
|
This section contains example code for integrating and automating Retail @dvantage PC into your businesses own proprietary and non proprietary systems. The examples are written in 32-bit Visual Basic and Visual Basic for Applications. (VB5-6 compatible)
|
All code herein is unsupported by Encom Inc., and is provided as is, without warranty or claims of usability of any kind. This code is intended for example and reference purposes only! Its' use, as is or modified, negates any and all possible liability of Encom Inc. These terms are also stated in the Retail @dvantage PC licensing and service agreements which must be accepted prior to installation.
|
|
|
|
 |
Export Data From an Access Database using Visual Basic:
|
|
'==========================================================
' THE FOLLOWING EXAMPLE;
' - USES THE ACSAMPLE.M SAMPLE FILE. (Renamed from .Mdb)
' - MAKES KEYED(vs. swiped)SALE & CREDIT TRANSACTIONS ONLY.
' - ACCEPTS AVS, CV2, ECI, and PURCHASE CARD FIELDS.
' - DOES NOT THOROUGHLY VALIDATE ALL TRANSACTION DATA.
' - CORRECT FIELD VALUE FORMATS MUST BE PRESENT IN ACCESS.
' - INCLUDES SOME ERROR TRAPPING.
'==========================================================
Public Sub Export4_RetailPC()
'------------------------------------------------------
' This procedure exports all "rows" containing transaction.
' data to a *.txt file(Overwrites) importable by RetailPC
' 3.2 & up (Prev. versions exclude the last 4 fields.)
'------------------------------------------------------
Const DBName = "ACSample.m"
Const RsName = "Transactions"
Dim MDB As Database
Dim RS As Recordset
Dim File_err As Boolean ' not a valid file flag
'change the following to false if the field values are
'not present in the MDB file.
CVVFld = True '(CV2)
EcommerceFld = True '(ECI)
IssuerFld = False '(Issuer)
' Edit code below 2 check for correct file name, table,
' or what ever criteria to ensure this is processing the
' right data.
'If whatever = False Then
' MsgBox "Invalid Database or Table", vbExclamation '
' File_err = True
' GoTo exit_sub
'End If
Mousepointer = 11
' Open DB & Transaction Table and populate recodset.
On Error GoTo Error1
Set MDB = OpenDatabase(App.Path & "/" & DBName)
Set RS = MDB.OpenRecordset("Select * From " & RSName, _
dbOpenSnapshot)
On Error Resume Next
RS.MoveFirst
If Err Then
MsgBox "Empty Table - " & RSName, vbExclamation
File_err = True
GoTo exit_sub
End If
On Error GoTo Error1
Close
'Change the export file path/filename here.. or add code
'for a save as dialog.
Open App.path & "\AccExprt.txt" For Output As #1
'begin loop through Access rows until end of file
Do Until RS.EOF
IsAVS = False
'verify all required feilds have values or skip row
If Trim(RS!Card & "") = "" Or Trim(RS!Exp & "") = "" _
Or Trim(RS!Amount & "") = "" Then
GoTo skip_record
End If
Rec$ = ""
'Assemble the fields into records removing spaces etc...
'Is this a Sale or Credit.? Check type & amount. (+ or -)
If Val(Format((RS!Amount & ""), "#")) < 0 Or _
Trim(RS!TranCode & "") = "30" Then
Rec$ = "30$ ' Credit
Rec$ = Rec$ & "00000000"
Else
Rec$ = "10$" ' Sale
' Is this a Sale/AVS transaction
If (Trim(RS!Address & "") <> "" Or _
Trim(RS!Zip & "") <> "") And _
Trim(RS!Ticket & "") <> "" Then
Rec$ = Rec$ & "000000S0" ' Sale/AVS
IsAVS = True
Else
Rec$ = Rec$ & "00000000" ' Sale
End If
End If
' Add Date & Time
Rec$ = Rec$ & Format(Date$, "mm-dd-yyyy") & _
Format(Time$, "hh:mm:ss") & "|"
Rec$ = Rec$ & "|" ' close reserved field
' Card Label/Issuer - hold
Issuer$ = ""
If IssuerFld <> "" Then ' true/false use field in file
Issuer$ = Trim(RS!Issuer & "")
End If
' Card Number get numbers only
C1$ = Trim(RS!Card & "")
C2$ = ""
For c = 1 To Len(C1$)
If IsNumeric(Mid(C1$, c, 1)) Then
C2$ = C2$ & Mid(C1$, c, 1)
End If
Next
'Get issuer if null
If Issuer$ = "" Then Issuer$ = GetCardIssuer(C2$)
Rec$ = Rec$ & Issuer$ & "|" & C2$ & "|"
' Expires - numbers only - mmyy
E1$ = Trim(RS!xp & "")
E2$ = ""
For e = 1 To Len(E1$)
If IsNumeric(Mid(E1$, e, 1)) Then
E2$ = E2$ & Mid(E1$, e, 1)
End If
Next
Rec$ = Rec$ & E2$ & "|"
' Card holder name
Rec$ = Rec$ & Trim(RS!Name & "") & "|"
' Card holder address & Zip - if IsAVS
If IsAVS then
Rec$ = Rec$ & Trim(RS!Address & "") & "|"
Rec$ = Rec$ & Trim(RS!Zip & "") & "|"
Else
Rec$ = Rec$ & "||"
End if
' Total Amount
Rec$ = Rec$ & Format(Abs(RS!Amount & ""),"currency") & "|"
' Reserved field
Rec$ = Rec$ & "|"
' Purchase cards only - Tax amount
Rec$ = Rec$ & Format(RS!Tax & ""), "currency") & "|"
' Purchase cards only - Customer Code
Rec$ = Rec$ & Trim(RS!CustCode & "") & "|"
' Reserved
Rec$ = Rec$ & "|"
' Reserved
Rec$ = Rec$ & "|"
' Ref/approval # feild.. voids & post auths only
Rec$ = Rec$ & "|"
' Ticket/Invoice #
Rec$ = Rec$ & Trim(RS!Ticket & "") & "|"
' CVV2/CVC2 Data
If Left(Rec$, 2) = "10" Then
If CvvFld Then ' cvc field exists
Cvv$ = Trim(RS!CV2 & "")
If Len(Cvv$) = 3 And IsNumeric(Cvv$) Then
Rec$ = Rec$ & "1" & Cvv$ & "|"
Else
Rec$ = Rec$ & "0|"
End If
Else
Rec$ = Rec$ & "0|"
End If
' ecommerce indicator
If EcommerceFld Then ' eCommerce field exists
eC$ = Trim(RS!ECI & "")
If eC$ <> "7" Then
Rec$ = Rec$ & "|"
Else
Rec$ = Rec$ & "7|"
End If
Else
Rec$ = Rec$ & "|"
End If
Else ' not a sale
Rec$ = Rec$ & "||"
End If
' Reserved
Rec$ = Rec$ & "|"
' Reserved
Rec$ = Rec$ & "|"
Print #1, Trim(Rec$)
Debug.Print Trim(Rec$)
CT& = CT& + 1
skip_record: '
RS.MoveNext
Loop
exit_sub: '
If Not MDB Is Nothing Then MDB.Close
Close
Debug.Print "Count = " & CT&
MousePointer = 0
If CT& <> 0 Then
MsgBox "Export for Retail @dvantage PC Done!" & vbCrLf & _
vbCrLf & "Exported Record Count = " & CT&, vbExclamation
'Add Code here to initiate RetailPC command line import
'and/or processing.
Else
If Not File_err Then
MsgBox "No Data Exported", vbExclamation
End If
End If
Exit Sub
Error1: '
MsgBox "Database Error!" & vbCrLf & Err.Description, & _
vbOKCancel + vbExclamation
File_err = True
Resume exit_sub
End Sub
'==========================================================
|
|
|
|
|
|
|
|
|
 |
 |
 |
|
 |
 |
 |
 |
 |
 |
 |
 |
 |
|
 |
|
|
 |
 |
|
|
 |
10 Jan 2009 ::: News Update
Retail @dvantage PC Versions 4.0c and 4.0e:
Global Payments Inc. is in the process of certifying versions 4.0c and 4.0e. These new versions will support Microsoft Windows VISTA and also include new features such as a SSL connectivity option, Native support for USB card readers, and maintain compliance with new Payment Card Industry Data Security Standards. (PCI/DSS,PABP/CISP).
read more...
01 Jan 2009 ::: News Header
Build 12 for Versions 3.4c & 3.4e have been Released as of January 1, 2009.
This new build adresses the New Double Receipt Truncation requirements, mandated by some states and also contains a few other minor bug fixes.
All New and Replacement orders will automaticallly receive the new build.
Existing merchants are not required to obtain the new build unless it is mandated in that merchant's state.
|
 |
 |
Need An Extra Hand? |
Rent-A-Coder
If you' have a small project that does not require vast resources or staffing. We can provide you a referral for one our expert programmers. read more...
Rent-A-Tester
Developed your own product, web site, etc.. and need an independent tester? We can provide you a referral for one our expert technicians. read more...
Rent-A-Designer
Need a Graphical or Multimedia designer for a small project? We can provide you a referral for one our creative designers. read more...
|
|