Overview & Features System Requirements Screen Shots
Ordering Info Obtaining Support Sample Code Downloads

Sample Code

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 Directly From MS Excel - ToolBar Button Macro
'==========================================================
' THE FOLLOWING EXAMPLE;
' - USES THE XLSAMPLE.XLS SAMPLE FILE.
' - MAKES KEYED(vs. swiped)SALE & CREDIT TRANSACTIONS ONLY.
' - ACCEPTS AVS, CV2, ECI, and PURCHASE CARD FIELDS.
' - DOES NOT THOUROUGHLY VALIDATE ALL TRANSACTION DATA.
' - CORRECT FIELD VALUE FORMATS MUST BE PRESENT IN EXCEL
' - INCLUDES SOME ERROR TRAPPING.
'==========================================================
Public Sub Export4_RetailPC_Mapped()
'------------------------------------------------------
  ' This procedure exports all "rows" containing transaction
  ' data to a *.txt file Overwrites) importable by Retail
  ' @dvantage PC 3.2 and higher.(Versions previous 3.2
  ' – exclude the last 4 RetailPC fields)
  '------------------------------------------------------
  Dim WB As Workbook
  Dim WS As Worksheet ' active worksheet
  Dim File_err As Boolean ' not a valid file flag
  Set WB = ActiveWorkbook
  Set WS = WB.ActiveSheet  ' active worksheet in excel
  x = 0
  'Edit code below 2 check for correct file name, workbook,
  'worksheet, or what ever criteria to ensure this is
  'processing the right file

  If WS.Name <> "Sheet1" Then ' active worksheet name
   MsgBox "Invalid Worksheet", vbExclamation
   File_err = True
   GoTo exit_sub
  End If
  Mousepointer = 11

  'Field Mapping Setup ' change to reflect your fields
  'Field =  Column
  TranType$ = "A"
  IssuerFld$ = "G" '- uses getcardissuer procedure if ""
  CardFld$ = "H"
  ExpFld$ = "I"
  NameFld$ = "J"
  AddressFld$ = "K"
  ZipFld$ = "L"
  AmountFld$ = "M"
  PCTaxFld$ = "N"
  PCCustCodeFld$ = "O"
  InvoiceFld$ = "T"
  CVCFld$ = "U"
  eCommerceFld$ = "V"

  'Get range values - Adjust start row if header row exists
  GetWsRangeValues WS, StartCol$, StartRow&, EndCol$, EndRow&
  Close
  'change the export file path/filename here.. or add code
  'for a save as dialog...
  Open "C:\ExclExpr.txt" For Output As #1
  For x = StartRow& To EndRow&
    'verify all required fields have values or skip record
    If WS.Range(CardFld$ & x).Text = "" _
      Or WS.Range(ExpFld$ & x).Text = "" _
      Or WS.Range(AmountFld$ & x).Text = "" 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(WS.Range(AmountFld$ & x).Text, "#")) < 0 _
     Or Val(WS.Range(TranType$ & x).Text) = 30 Then
      Rec$ = "30$"  ' Credit
      Rec$ = Rec$ & "00000000"
    Else
      Rec$ = "10$"  ' Sale
      ' Is this a Sale/AVS transaction
      If (Trim(WS.Range(AddressFld$ & x).Text) <> "" Or _
        Trim(WS.Range(ZipFld$ & x).Text) <> "") And _
        Trim(WS.Range(InvoiceFld$ & x).Text) <> "" Then
          Rec$ = Rec$ & "000000S0" ‘Sale/AVS
      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
      Issuer$ = Trim(WS.Range(IssuerFld$ & x).Text)
    End If

    ' Card Number – get numbers only
   C1$ = Trim(WS.Range(CardFld$ & x).Text)
    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(WS.Range(ExpFld$ & x).Text)
    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(WS.Range(NameFld$ & x).Text) & "|"
    ' Card holder address
    Rec$ = Rec$ & Trim(WS.Range(AddressFld$ & x).Text) & "|"
   ' Card holder zip
    Rec$ = Rec$ & Trim(WS.Range(ZipFld$ & x).Text) & "|"
    ' Total Amount
    Rec$ = Rec$ & Format(Abs(WS.Range(AmountFld$ & x).Text), _
     "currency") & "|"
   ' Reserved field
    Rec$ = Rec$ & "|"
    ' Purchase cards only - Tax amount
    Rec$ = Rec$ & Format(WS.Range(PCTaxFld$ & x).Text, _
     "currency") & "|"
    ' Purchase cards only  - Customer Code
    Rec$ = Rec$ & Trim(WS.Range(PCCodeFld$ & x).Text) & "|"
    ' Reserved
    Rec$ = Rec$ & "|"
    ' Reserved
    Rec$ = Rec$ & "|"
    ' Ref/approval # feild.. voids & post auths only
    Rec$ = Rec$ & "|"
    ' Ticket/Invoice #
    Rec$ = Rec$ & Trim(WS.Range(InvoiceFld$ & x).Text) & "|"
    ' CVV2/CVC2/CID Data
    Cv$ = Trim(WS.Range(CVCFld$ & x).Text)
    If Len(Cv$) = 3 And IsNumeric(Cv$) Then
      Rec$ = Rec$ & "1" & Trim(WS.Range(CVCFld$ & x).Text) & "|"
    Else
      Rec$ = Rec$ & "0|"
    End If
    ' Ecommerce indicator
    eC$ = Trim(WS.Range(eCommerceFld$ & x).Text)
    If eC$ <> "7" Or eC$ <> "True" Then
      Rec$ = Rec$ & "|"
    Else
      Rec$ = Rec$ & "7|"
    End If
    ' Reserved
    Rec$ = Rec$ & "|"
    ' Reserved
    Rec$ = Rec$ & "|"
    Print #1, Trim(Rec$)
    Debug.Print Trim(Rec$)
    CT& = CT& + 1
skip_record: '
  Next
exit_sub: '
  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
End Sub

'==========================================================
Public Function GetCardIssuer(CardNum$) As String
 
 '-----------------------------------------------------
 
 ' Retrieves a Card Issuer based on Card Number
  ' Does not identify purchase cards. Add if desired
  ' This code must be maintained as Card Ranges and Issuers
  ' added/change every so often. The 'Global' Applications do
  ' not require the issuer field populated, but it does help
  ' when reports and searches are concerned.
 
'-----------------------------------------------------
  Dim CI(15, 2) As String
  GetCardIssuer = ""
  CI(1, 1) = "5"
  CI(1, 2) = "MasterCard"
  CI(2, 1) = "4"
  CI(2, 2) = "Visa"
  CI(3, 1) = "34"
  CI(3, 2) = "Amex"
  CI(4, 1) = "37"
  CI(4, 2) = "Amex"
  CI(5, 1) = "36"
  CI(5, 2) = "Diners"
  CI(6, 1) = "38"
  CI(6, 2) = "Diners"
  CI(7, 1) = "300"
  CI(7, 2) = "Diners/CB"
  CI(8, 1) = "301"
  CI(8, 2) = "Diners/CB"
  CI(9, 1) = "302"
  CI(9, 2) = "Diners/CB"
  CI(10, 1) = "303"
  CI(10, 2) = "Diners/CB"
  CI(11, 1) = "304"
  CI(11, 2) = "Diners/CB"
  CI(12, 1) = "305"
  CI(12, 2) = "Diners/CB"
  CI(13, 1) = "95"
  CI(13, 2) = "Diners/CB"
  CI(14, 1) = "6011"
  CI(15, 2) = "Diners/CB"
  CI(15, 1) = "3528"
  CI(15, 2) = "JCB"

  For x = 1 To 15
    Bin$ = CI(x, 1)
    L% = Len(Bin$)
    If Left(CardNum$, L%) = Bin$ Then
        GetCardIssuer = CI(x, 2)
        Exit For
    End If
  Next
End Function
 
'---------------------------------------------------------

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...







Home      Services      Products      Partners      About Us      Contact Us
Copyright © 2006-2010 Encom Inc. All rights reserved.