net.authorize.admc.authnet
Class AimTransaction

java.lang.Object
  extended by net.authorize.admc.authnet.AimTransaction

public class AimTransaction
extends java.lang.Object

Authorize.net client. N.b. It would be very easy for a scoundrel to modify this class to steal or use your credit card information. Therefore, only use a copy of this class from a source which you trust, and verify the checksums! N.b. the difference between "transaction key", my password; and "transaction ID", the identifier for a transaction. It seems that Authorize.net is trying to force AIM users into the hands of their own partners by no longer providing easy public access to the AIM API's, like they used to do. You can see the sample code at http://developer.authorize.net/samplecode/ but they leave a lot of questions unanswered, and the code is non-scalable and non-Object Oriented.


Nested Class Summary
static interface AimTransaction.Persistor
          An implementation of this interface may be passed to the postPurchase method to perform any custom post-purchase processing.
 
Field Summary
 java.lang.String[] data
          WRITEME
static java.lang.String LS
          TODO: document this field (brpocock, Oct 13, 2009) LS (AimTransaction)
 
Method Summary
 void checkMd5Hash()
           
 java.math.BigDecimal getAmount()
          TODO: document this method (brpocock, Sep 23, 2009)
 java.lang.String getApproval()
          TODO: document this method (brpocock, Sep 23, 2009)
 char getAVS()
          TODO: document this method (brpocock, Sep 23, 2009)
 int getRcode()
          TODO: document this method (brpocock, Sep 23, 2009)
 int getRRcode()
          TODO: document this method (brpocock, Sep 23, 2009)
 java.lang.String getRRtext()
          TODO: document this method (brpocock, Sep 23, 2009)
 boolean getTestMode()
          TODO: document this method (brpocock, Sep 23, 2009)
 java.math.BigDecimal getTransId()
          TODO: document this method (brpocock, Sep 23, 2009)
 java.lang.String getTransType()
          TODO: document this method (brpocock, Sep 23, 2009)
 boolean isTestMode()
          TODO: document this method (brpocock, Sep 23, 2009)
 void postPurchase()
           Perform post-purchase validation.
 void postPurchase(AimTransaction.Persistor persistor)
          Purchase-specific post-processing.
 void setAmount(java.math.BigDecimal inInt)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setAmount(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setAuthCode(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setBillAddress(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setBillCity(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setBillCountry(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setBillFax(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setBillFirstName(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setBillLastName(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setBillOrg(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setBillPhone(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setBillStateName(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setBillZip(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setCardCode(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setCardNum(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setCustId(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setDescription(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setEmail(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setExp(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setInvoiceNum(int i)
          Convenience data type conversion
 void setInvoiceNum(java.lang.String inString)
          Misnomer taken from the AIM documentation.
 void setPhone(java.lang.String phone1)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setShipAddress(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setShipCity(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setShipCountry(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setShipFirstName(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setShipLastName(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setShipOrg(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setShipStateName(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setShipZip(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setTestMode(boolean is_this_a_test_request_QQ)
          Set the test mode for this one transaction.
 void setTransId(int inInt)
          TODO: document this method (brpocock, Oct 13, 2009)
 void setType(java.lang.String inString)
          TODO: document this method (brpocock, Oct 13, 2009)
 void submit()
          TODO: document this method (brpocock, Oct 13, 2009)
static java.lang.String toHex(byte[] byteArray)
          Run with no parameters to see syntax, like:
 java.lang.String toString()
          Dumps entire response data array, except for empty elements, which are skipped.
static java.lang.String truncateIfLonger(java.lang.String inString, int maxLen)
          Public utility method.
 void validateInput(java.lang.String vehicle)
          Verify that input data is good to submit a payment request.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LS

public static final java.lang.String LS
TODO: document this field (brpocock, Oct 13, 2009) LS (AimTransaction)


data

public java.lang.String[] data
WRITEME

Method Detail

toHex

public static java.lang.String toHex(byte[] byteArray)
Run with no parameters to see syntax, like:
     java com.admc.authnet.AimTransaction
 
N.b. THIS IS FOR NON-SECURE TESTING! Make sure your computer (and your nework connection to it, if any) is secure before running this method, because the command-line parameters you give to this command can be observerd by others.

Parameters:
byteArray - WRITEME
Returns:
WRITEME

truncateIfLonger

public static java.lang.String truncateIfLonger(java.lang.String inString,
                                                int maxLen)
Public utility method. Returns the given String if lenth is less than or equal to the specified limit. Otherwise returns a newly constructed, truncated version of the given String.

Parameters:
inString - WRITEME
maxLen - WRITEME
Returns:
WRITEME

checkMd5Hash

public void checkMd5Hash()
                  throws AuthNetException
Throws:
AuthNetException - if received hash does not match calculated hash.

getAmount

public java.math.BigDecimal getAmount()
TODO: document this method (brpocock, Sep 23, 2009)

Returns:
WRITEME

getApproval

public java.lang.String getApproval()
TODO: document this method (brpocock, Sep 23, 2009)

Returns:
WRITEME

getAVS

public char getAVS()
TODO: document this method (brpocock, Sep 23, 2009)

Returns:
WRITEME

getRcode

public int getRcode()
TODO: document this method (brpocock, Sep 23, 2009)

Returns:
WRITEME

getRRcode

public int getRRcode()
TODO: document this method (brpocock, Sep 23, 2009)

Returns:
WRITEME

getRRtext

public java.lang.String getRRtext()
TODO: document this method (brpocock, Sep 23, 2009)

Returns:
WRITEME

getTestMode

public boolean getTestMode()
TODO: document this method (brpocock, Sep 23, 2009)

Returns:
WRITEME

getTransId

public java.math.BigDecimal getTransId()
TODO: document this method (brpocock, Sep 23, 2009)

Returns:
WRITEME

getTransType

public java.lang.String getTransType()
TODO: document this method (brpocock, Sep 23, 2009)

Returns:
WRITEME

isTestMode

public boolean isTestMode()
TODO: document this method (brpocock, Sep 23, 2009)

Returns:
WRITEME

postPurchase

public void postPurchase()
                  throws AuthNetException

Perform post-purchase validation.

User should call either postPurchase(Persistor) or postPurchase() after submitting a purchase transaction.

Throws:
AuthNetException - Your postPurchase call should handle these.

postPurchase

public void postPurchase(AimTransaction.Persistor persistor)
                  throws java.sql.SQLException,
                         AuthNetException
Purchase-specific post-processing.

User should call either postPurchase(Persistor) or postPurchase() after submitting a purchase transaction.

Does purchase-specific post-validation, and invokes the user-specified persist method.

Parameters:
persistor - WRITEME
Throws:
AuthNetException - It is very important that these critical exceptions be handled appropriately, because the customer has been charged but you may not have a record of it. You just need to set up a SMTP Appender or write these to a critical log file so you know to check the details with the Authorize.net console.
java.sql.SQLException - If you did not pass a Persistor which can throw a SQLException, then just catch SQLException and rethrow a RuntimeException, because you won't get it unless your app is messed up. If you may throw SQLException, same comment as for AuthNetException applies.

setAmount

public void setAmount(java.math.BigDecimal inInt)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inInt - WRITEME

setAmount

public void setAmount(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setAuthCode

public void setAuthCode(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setBillAddress

public void setBillAddress(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setBillCity

public void setBillCity(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setBillCountry

public void setBillCountry(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setBillFax

public void setBillFax(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setBillFirstName

public void setBillFirstName(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setBillLastName

public void setBillLastName(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setBillOrg

public void setBillOrg(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setBillPhone

public void setBillPhone(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setBillStateName

public void setBillStateName(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setBillZip

public void setBillZip(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setCardCode

public void setCardCode(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setCardNum

public void setCardNum(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setCustId

public void setCustId(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setDescription

public void setDescription(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setEmail

public void setEmail(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setExp

public void setExp(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setInvoiceNum

public void setInvoiceNum(int i)
Convenience data type conversion

Parameters:
i - WRITEME

setInvoiceNum

public void setInvoiceNum(java.lang.String inString)
Misnomer taken from the AIM documentation. This is an invoice identifier, not necessary a number.

Parameters:
inString - WRITEME

setPhone

public void setPhone(java.lang.String phone1)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
phone1 - WRITEME

setShipAddress

public void setShipAddress(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setShipCity

public void setShipCity(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setShipCountry

public void setShipCountry(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setShipFirstName

public void setShipFirstName(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setShipLastName

public void setShipLastName(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setShipOrg

public void setShipOrg(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setShipStateName

public void setShipStateName(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setShipZip

public void setShipZip(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

setTestMode

public void setTestMode(boolean is_this_a_test_request_QQ)
Set the test mode for this one transaction.

Parameters:
is_this_a_test_request_QQ - WRITEME

setTransId

public void setTransId(int inInt)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inInt - WRITEME

setType

public void setType(java.lang.String inString)
TODO: document this method (brpocock, Oct 13, 2009)

Parameters:
inString - WRITEME

submit

public void submit()
            throws java.io.IOException
TODO: document this method (brpocock, Oct 13, 2009)

Throws:
java.io.IOException - WRITEME

toString

public java.lang.String toString()
Dumps entire response data array, except for empty elements, which are skipped.

Overrides:
toString in class java.lang.Object
Returns:
WRITEME

validateInput

public void validateInput(java.lang.String vehicle)
                   throws AuthNetException
Verify that input data is good to submit a payment request. We assume that the addresses have already been validated.

Parameters:
vehicle - WRITEME
Throws:
AuthNetException - WRITEME