Products » dgCharge User Guide

Method:  dgCharge::Credit()

Credit(amount, card_nbr, exp_date, customer_ID, customer_name, description, street_adr, postal_code, purchase_card_nbr, purchase_card_tax)

The Credit method processes a credit card credit transaction. A current merchant must be set before calling this method (see SetMerchant).

There are three required arguments:

Amount

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

Card_nbr

The full credit card number, with no spaces and no non-numeric characters.

Exp_date

The four-digit credit card expiration date, with no spaces and no non-numeric characters. For example, an expiration date of 03/02 would be entered as "0302".

There are seven optional arguments:

Customer_ID

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

Customer_name

Customer name as it appears on the credit card (maximum length 50 characters).

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.

Street_adr

The address (maximum length 100 characters) of the card holder. This can include the street, city, state, and/or country.

Postal_code

The zip code, or postal code, (maximum length 20 characters) of the card holder.

Purchase_card_nbr

Some credit cards are "purchase cards" that enable some purchases to be tax exempt. In this situation, a purchase card number must be provided as the Purchase_card_nbr parameter, along with the tax amount as the Purchase_card_tax parameter.

Purchase_card_tax

See description of Purchase_card_nbr parameter.

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
      If Not oChargeObject.Credit ("1000","9999999999999999","0304","Mickey Mouse","Cheese return.","100 Cheddar Lane","12345") Then
       Response.Write (oChargeObject.ErrorText)
      End If
    End If
%>