This is an old revision of the document!

XCharge Access Examples


This document describes two example Access databases that use the USA ePay XCharge component with Access forms to perform transactions in the USA ePay gateway.

One example database uses the Active-X Com component (.dll), and the other uses the Active-X control (.ocx) version of the XCharge component.

The examples provided demonstrate only two ways to implement XCharge's functionality in Access. Some developers prefer not to use forms at all or even use other Office applications. How you implement XCharge's functionality in your project is entirely up to you.

System Requirements

Before running the Access examples, you must first make sure that your system meets the requirements of the USA ePay XCharge component, and install the latest version of the XCharge component (with documentation) by clicking here.

The example databases require Microsoft Access 2000 or newer. Even though the example file requires Access 2000, you can use the XCharge control in any Office product that supports Active-X.

The Examples


Running the Examples

Follow these steps to run the Access example forms:

  1. From the Access examples folder open either:
    • controlexample.mdb” if you wish to run the Active-X (.ocx) control example.
    • OR
    • comexample.mdb” if you wish to run the Active-X (.dll) example.
  2. Go to the “Forms” section and double click on the “frmMain” form.
  3. When you double click on “frmMain” a form similar to the following should open:
  4. Enter the appropriate details for your desired transaction and click on the “Process” button to see the results of the transaction.

Viewing the Code

Follow these steps to view the code that runs when the form is executed:

  1. Go to the “Forms” section and then right click on the “frmMain” object and choose “Design View” from the pop-up menu.

  1. The “frmMain” form should now be open in design view. Right click on the “Process” button and choose “Properties”.

  1. In the “Properties” dialog choose the “Event” tab and then click on the word “[Event Procedure]” which is on the “On Click” line. Finally, click on the ellipsis (three dots) button to open the VBA code editor.

  1. With the VBA code editor open, you can examine all the code used in this project.

Using XCharge in Your Own Database

Syntax and descriptions of the various properties and methods available in the XCharge component can be found in the “XCharge Component Documentation” shortcut on your start menu and here.

To use the XCharge component in your own database you must first add a reference to the XCharge component.

COM (.dll) Version

Follow these steps to add the COM (.dll) version of the XCharge component to your database:

  1. In the VBA code editor choose the “Tools” menu and click on the “References” menu item.
  2. Find and check “USAePay XCharge Component Version 2” on the list.
  3. Click the “OK” button.
  4. Create a new instance of the XCharge object with code similar to the following:
    • Dim XCharge1 As XChargeCom2
    • Set XCharge1 = New XChargeCom2

Control (.ocx) Version

Follow these steps to add the control (.ocx) version of the XCharge component to your database:

  1. Open a form, report, or data access page in design view.
  2. Choose the “Insert” menu and click on “Active-X Control.”
  3. From the list, choose “USAePayXCharge2.XCharge2.”
  4. Click the “OK” button.
  5. You should now see an icon (this is the control) with the USA ePay logo on your form, report, or data access page.
  6. Right click the control and choose the “Properties” menu item.
  7. Set the properties you want.

The Enums Module

Just like ASP, VBA does not recognize Active-X enumerations. So if you want to use named values (XCharge1.Command=CommandType.cvoid), instead of numbers (XCharge1.Command=2), you must include a module in your project that contains the following enumeration values:

  Public Enum CommandType
      sale = 0
      credit = 1
      cvoid = 2
      authonly = 3
      capture = 4
      postauth = 5
      check = 6
      checkcredit = 7
  End Enum
  Public Enum ScheduleType
      daily = 0
      weekly = 1
      biweekly = 2
      monthly = 3
      bimonthly = 4
      quarterly = 5
      annually = 6
      biannually = 7
  End Enum
  Public Enum StatusType
      Approved = 0
      Declined = 1
      Verification = 2
      Error = 3
  End Enum
  Public Enum CptTermTypeType
      pos = 0
      StandAlone = 1
      Unattended = 2
      TermTypeUnknown = 3
  End Enum
  Public Enum CptMagSupportType
      MagSupportYes = 0
      MagSupportNo = 1
      MagSupportUnknown = 2
  End Enum
developer/accessdb.1239036339.txt.gz · Last modified: 2009/04/06 09:45 by hmcgowan

Page Tools