Products » dgCharge User Guide

Method:  dgCharge::MagSwipeSale()

MagSwipeSale(amount, track_data, customer_ID, description)

The MagSwipeSale method processes a credit card sale transaction using data read from a magnetic card reader. A current merchant must be set before calling this method (see SetMerchant).

There are two required arguments:

Amount

The amount of the transaction, in cents, expressed as a whole number. For example, $1.00 would be entered as "100".

Track_Data<

Track one of data read from a magnetic card reader. The stream of characters must be prefixed by a "%" character and suffixed by a "?" character.

Customer_ID

Customer identification (maximum length 50 characters). This can be a number or descriptive text that is used to identify the customer.

Description

A text description (maximum length 256 characters) of the transaction. This can be any information, or descriptive text, that is to be recorded in the dgCharge Professional Edition transaction database for this transaction.


Return Value

If the transaction request cannot be completed for any reason, the method returns a value of False and the ErrorText property contains a description of the error. If the transaction is completed, the method returns a value of True and the ApprovalCode, AuthResponse, AVSResponse, ErrorText, RecordNumber, TransDate, and TransTime properties are set. In addition, if the method succeeds, all information concerning the transaction is entered into the dgCharge Professional Edition transaction database.

Note that successful execution of the method does not imply approval of the transaction; the AuthResponse property indicates the status of the transaction.

Code:
<%
    ' create an instance of the object
    Set oChargeObject = Server.CreateObject("dgCharge.Charge")
    ' establish the merchant
    bSetOK = oChargeObject.SetMerchant ("999999999","999999")
    ' process the transaction
    If bSetOK Then
      strTrackData = "%9999999999999999^MICKEY^010300000000000000?"
      If Not oChargeObject.MagSwipeSale ("1000",strTrackData,"1551","Purchase cheese wheel.") Then
       Response.Write (oChargeObject.ErrorText)
      End If
    End If
%>