com.jcommercesql.gateway.authorizenet
Class AuthorizeNetCC

java.lang.Object
  |
  +--com.jcommercesql.gateway.authorizenet.AuthorizeNet
        |
        +--com.jcommercesql.gateway.authorizenet.AuthorizeNetCC

public final class AuthorizeNetCC
extends AuthorizeNet

AuthorizeNetCC can be used to perform credit card authorizations through Authorize.net.

Basic Example 1:


  AuthorizeNetCC anetcc = new AuthorizeNetCC();
  anetcc.setURL("secure.authorize.net",443,"/gateway/transact.dll");
  anetcc.setMerchantInfo("loginid","transactionkey");
  anetcc.addOptionalField("x_Address","123 Main St.");	// if needed for AVS
  anetcc.addOptionalField("x_Zip","10101");			// if needed for AVS
  anetcc.addMerchantDefinedField("m_Comment", "Basic Example 1");
  anetcc.setTransaction("1234123412341234","11/09","100.00","AUTH_CAPTURE");
  try {
    anetcc.submit();
    if (anetcc.getResponseCode().equals("1")) {
	System.out.println("Your transaction was approved!");
    } else {
	System.out.println("Your transaction was declined! " + anetcc.getResponseReasonText());
    }
  } catch(Exception e) {
      System.out.println("System Error! " + e);
  }  
 

Basic Example 2:


  AuthorizeNetCC anetcc = new AuthorizeNetCC("/path/to/config.prop");
  anetcc.addOptionalField("x_Address","123 Main St.");	// if needed for AVS
  anetcc.addOptionalField("x_Zip","10101");			// if needed for AVS
  anetcc.addMerchantDefinedField("m_Comment", "Basic Example 2");
  anetcc.setTransaction("1234123412341234","11/09","100.00","AUTH_CAPTURE");
  try {
    anetcc.submit();
    if (anetcc.getResponseCode().equals("1")) {
	System.out.println("Your transaction was approved!");
    } else {
	System.out.println("Your transaction was declined! " + anetcc.getResponseReasonText());
    }
  } catch(Exception e) {
      System.out.println("System Error! " + e);
  }  
 
This class was designed using the Authorize.net Advanced Integration Method Implementation Guide v1.0. It is recommended that you download a copy of this guide to fully understand what gateway methods should be used for your particular situation.


Field Summary
protected  java.lang.String x_Card_Num
           
protected  java.lang.String x_Exp_Date
           
protected  java.lang.String x_Type
           
 
Fields inherited from class com.jcommercesql.gateway.authorizenet.AuthorizeNet
host, merchantMD5HashValue, path, port, postData, rawResponse, x_Amount, x_Delim_Char, x_Delim_Data, x_Login, x_Tran_Key, x_Version
 
Constructor Summary
AuthorizeNetCC()
          Initializing Constructor
AuthorizeNetCC(java.lang.String filename)
          Initializing Constructor.
 
Method Summary
 java.lang.String getCardNum()
          Returns the Credit Card Number the was set by the setCreditCard() method.
 java.lang.String getExpDate()
          Returns Credit Card Expiration Date as set by the setExpDate() method.
 java.lang.String getPostData()
          Show Post Data.
 java.lang.String getType()
          Returns the Credit Card Transaction Type as set by the setType() method.
 void setCardNum(java.lang.String cardNum)
          Set Credit Card Number
 void setExpDate(java.lang.String expDate)
          Set Credit Card Expiration Date.
 void setTransaction(java.lang.String cardNum, java.lang.String expDate, java.lang.String amount, java.lang.String transType)
          Set Transaction Information.
 void setType(java.lang.String transType)
          Set the Credit Card Transaction Type.
 void submit()
          Submit Credit Card Transaction For Approval.
 
Methods inherited from class com.jcommercesql.gateway.authorizenet.AuthorizeNet
addMerchantDefinedField, addOptionalField, calcMD5Hash, getAmount, getDelimChar, getDelimData, getHost, getLogin, getPath, getPort, getResponseApprovalCode, getResponseAVSResultCode, getResponseBytes, getResponseCode, getResponseReasonCode, getResponseReasonText, getResponseSubCode, getResponseTransactionID, getResponseValue, getTranKey, getVersion, loadPropFile, parseANetResponse, reloadProperties, reloadProperties, removeOptionalField, removeTestMode, setAmount, setDelimChar, setDelimData, setHost, setLogin, setMerchantInfo, setPath, setPort, setTestMode, setTranKey, setURL, setVersion, submitANetGet, submitANetPost, submitANetPost, validateProperties, verifyMD5Hash, verifyMD5Hash, verifyMinimumFieldsSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x_Card_Num

protected java.lang.String x_Card_Num

x_Exp_Date

protected java.lang.String x_Exp_Date

x_Type

protected java.lang.String x_Type
Constructor Detail

AuthorizeNetCC

public AuthorizeNetCC()
Initializing Constructor


AuthorizeNetCC

public AuthorizeNetCC(java.lang.String filename)
               throws java.io.IOException,
                      InvalidPropException
Initializing Constructor.

Parameters:
filename - Name of properties file containing Authorize.Net host, port, path, login ID and transaction key
Method Detail

setCardNum

public void setCardNum(java.lang.String cardNum)
Set Credit Card Number

Parameters:
cardNum - Credit Card Number

getCardNum

public java.lang.String getCardNum()
Returns the Credit Card Number the was set by the setCreditCard() method.


setExpDate

public void setExpDate(java.lang.String expDate)
Set Credit Card Expiration Date.

Parameters:
expDate - Credit Card Expiration Date
See Also:
setTransaction()

getExpDate

public java.lang.String getExpDate()
Returns Credit Card Expiration Date as set by the setExpDate() method.


setType

public void setType(java.lang.String transType)
Set the Credit Card Transaction Type. Example Types are: AUTH_CAPTURE, AUTH_ONLY, CAPTURE_ONLY, CREDIT, VOID, PRIOR_AUTH_CAPTURE.

See the Authorize.net Advanced Implementation Guide for the correct values for your transaction.

Parameters:
transType - Credit Card Transaction Type
See Also:
Authorize.net

getType

public java.lang.String getType()
Returns the Credit Card Transaction Type as set by the setType() method.


setTransaction

public void setTransaction(java.lang.String cardNum,
                           java.lang.String expDate,
                           java.lang.String amount,
                           java.lang.String transType)
Set Transaction Information. This method is provided as an alternative to setting the items with individual calls.

Parameters:
cardNum - Credit Card Number
expDate - Credit Card Expiration Date
amount - Amount of Transaction
transType - Transaction Type
See Also:
setType

getPostData

public java.lang.String getPostData()
Show Post Data. The Authorize.net transaction gateway expects a list of parameters and values to be posted to their site. Use this function to print out the the list for troubleshooting purposes. Note: this will only return data once the submit function has been called.

Overrides:
getPostData in class AuthorizeNet

submit

public void submit()
            throws RequiredFieldException,
                   java.lang.Exception
Submit Credit Card Transaction For Approval. A RequiredFieldException is thrown if the following fields are not set: credit card number, expiration date, amount, transaction type authorize.net server name, port, path, merchant account login and transaction key.

Specified by:
submit in class AuthorizeNet
RequiredFieldException
java.lang.Exception