com.ibm.etill.ldbcardcassette
Class LdbCardBatch

com.ibm.etill.ldbcardcassette.LdbCardBatch

public final class LdbCardBatch
implements LdbCardConstants

The cassette batch object is responsible for performing all the cassette's batch requests (BatchOpen, BatchClose) and to manage the state of the framework batch object.


Inner Class Summary
 class LdbCardBatch.AutoCloseWorkItem
          The AutoCloseWorkItem object is used to automatically close an open batch as soon as possible.
 class LdbCardBatch.TimeOfDayWorkItem
          The TimeOfDayWorkItem object is used to automatically close an open batch at a particular time of day (specified in minutes after midnight).
 
Field Summary
private static java.lang.String COPYRIGHT
           
private  java.lang.String objApprovalCode
          This cassette batch attribute contains the approval code.
private  LdbCardBatch.AutoCloseWorkItem objAutoCloseWorkItem
          This cassette batch attribute is contains a reference to a CassetteWorkItem that is used to schedule an automatic batch close.
private  LdbCardCassette objCassette
          This cassette batch attribute contains the reference back to the cassette that owns the batch.
private  LdbCardAccount objCassetteAccount
          This cassette batch attribute contains the reference to the cassette account object that will be used to perform transactions for this batch.
private  java.lang.Integer objClosedToTrans
          This cassette batch attribute contains an indicator used to determine if the batch can be used for new transactions.
private  java.lang.String objDeclineReason
          This cassette batch attribute contains the decline reason.
private  com.ibm.etill.framework.payapi.Batch objFrameworkBatch
          This cassette batch attribute contains the reference back to the associated framework batch object.
private  LdbCardBatch.TimeOfDayWorkItem objTimerWorkItem
          This cassette batch attribute is contains a reference to a CassetteWorkItem that is used to schedule an automatic batch close at a particular time of day.
 
Fields inherited from interface com.ibm.etill.ldbcardcassette.LdbCardConstants
ACC_ACCOUNT, ACC_CLOSE_TIME, ACC_CURRENCY, ACC_LDBCARD_ID, ACC_MAX_BATCH_SIZE, ACC_MERCHANT, ACC_MIN_BATCH_TOTAL, ACC_PASSWORD, ACC_URL, ACC_USER, BAT_APPROVAL, BAT_BATCH, BAT_CLOSED_TO_TRANS, BAT_MERCHANT, BAT_REASON, CASSETTE_NAME, COL_ACCOUNT, COL_ADDRESS, COL_AMOUNT, COL_APPROVAL, COL_BATCH, COL_BRAND, COL_CLOSE_TIME, COL_CLOSED_TO_TRANS, COL_CREDIT, COL_CURRENCY, COL_EXPIRY, COL_LDBCARD_ID, COL_MAX_BATCH_SIZE, COL_MERCHANT, COL_MERCHANT_NAME, COL_MIN_BATCH_TOTAL, COL_ORDER, COL_PAN, COL_PASSWORD, COL_PAYMENT, COL_POSTAL_CODE, COL_REASON, COL_URL, COL_USER, CRE_APPROVAL, CRE_CREDIT, CRE_MERCHANT, CRE_ORDER, CRE_REASON, MSG_ACCOUNT_CREATE_ROW_FAILURE, MSG_ACCOUNT_CREATE_SQL_FAILURE, MSG_ACCOUNT_DELETE_ROW_FAILURE, MSG_ACCOUNT_DELETE_SQL_FAILURE, MSG_ACCOUNT_ICV_CMD_FAILURE, MSG_ACCOUNT_ICV_FAILURE, MSG_ACCOUNT_MORE_THAN_ONE_BATCH, MSG_ACCOUNT_MULTIPLE_ACCOUNTS, MSG_ACCOUNT_NULL_BATCH_CLOSE_TIME, MSG_ACCOUNT_NULL_BATCH_NUMBER, MSG_ACCOUNT_NULL_MAX_BATCH_SIZE, MSG_ACCOUNT_NULL_MIN_BATCH_TOTAL, MSG_ACCOUNT_SELECT_CLOSE_FAILURE, MSG_ACCOUNT_SELECT_SQL_FAILURE, MSG_ACCOUNT_UPDATE_ROW_FAILURE, MSG_ACCOUNT_UPDATE_SQL_FAILURE, MSG_BATCH_AUTO_CLOSE_FAILURE, MSG_BATCH_BAD_ADD_CREDIT_STATE, MSG_BATCH_BAD_ADD_PAYMENT_STATE, MSG_BATCH_BAD_BATCH_IN_CREDIT, MSG_BATCH_BAD_BATCH_IN_PAYMENT, MSG_BATCH_CLOSE_WORK_ITEM_FAILURE, MSG_BATCH_CREATE_ROW_FAILURE, MSG_BATCH_CREATE_SQL_FAILURE, MSG_BATCH_CREDIT_RETRIEVAL_FAILURE, MSG_BATCH_DELETE_ROW_FAILURE, MSG_BATCH_DELETE_SQL_FAILURE, MSG_BATCH_DEPOSIT_REVERSAL_FAILURE, MSG_BATCH_NULL_CREDIT, MSG_BATCH_NULL_ORDER_FOR_CREDIT, MSG_BATCH_NULL_ORDER_FOR_PAYMENT, MSG_BATCH_NULL_PAYMENT, MSG_BATCH_PAYMENT_RETRIEVAL_FAILURE, MSG_BATCH_REFUND_REVERSAL_FAILURE, MSG_BATCH_SELECT_BATCH_MISSING, MSG_BATCH_SELECT_CLOSE_FAILURE, MSG_BATCH_SELECT_ROW_FAILURE, MSG_BATCH_SELECT_SQL_FAILURE, MSG_BATCH_TIMER_WORK_ITEM_FAILURE, MSG_BATCH_UPDATE_ROW_FAILURE, MSG_BATCH_UPDATE_SQL_FAILURE, MSG_CASSETTE_BUNDLE_ID_MISMATCH, MSG_CASSETTE_HAS_STARTED, MSG_CASSETTE_HAS_STOPPED, MSG_CASSETTE_METHOD_NOT_IMPLEMENTED, MSG_CREDIT_CLOSE_STATE_ERROR, MSG_CREDIT_CREATE_ROW_FAILURE, MSG_CREDIT_CREATE_SQL_FAILURE, MSG_CREDIT_DELETE_ROW_FAILURE, MSG_CREDIT_DELETE_SQL_FAILURE, MSG_CREDIT_SELECT_CLOSE_FAILURE, MSG_CREDIT_SELECT_CREDIT_MISSING, MSG_CREDIT_SELECT_ROW_FAILURE, MSG_CREDIT_SELECT_SQL_FAILURE, MSG_CREDIT_UPDATE_ROW_FAILURE, MSG_CREDIT_UPDATE_SQL_FAILURE, MSG_ORDER_CLOSE_CREDIT_STATE_ERROR, MSG_ORDER_CLOSE_PAYMENT_STATE_ERROR, MSG_ORDER_CREATE_ROW_FAILURE, MSG_ORDER_CREATE_SQL_FAILURE, MSG_ORDER_DELETE_ROW_FAILURE, MSG_ORDER_DELETE_SQL_FAILURE, MSG_ORDER_SELECT_CLOSE_FAILURE, MSG_ORDER_SELECT_ORDER_MISSING, MSG_ORDER_SELECT_ROW_FAILURE, MSG_ORDER_SELECT_SQL_FAILURE, MSG_ORDER_UPDATE_ROW_FAILURE, MSG_ORDER_UPDATE_SQL_FAILURE, MSG_PAYMENT_CLOSE_STATE_ERROR, MSG_PAYMENT_CREATE_ROW_FAILURE, MSG_PAYMENT_CREATE_SQL_FAILURE, MSG_PAYMENT_DELETE_ROW_FAILURE, MSG_PAYMENT_DELETE_SQL_FAILURE, MSG_PAYMENT_SELECT_CLOSE_FAILURE, MSG_PAYMENT_SELECT_PAYMENT_MISSING, MSG_PAYMENT_SELECT_ROW_FAILURE, MSG_PAYMENT_SELECT_SQL_FAILURE, MSG_PAYMENT_UPDATE_ROW_FAILURE, MSG_PAYMENT_UPDATE_SQL_FAILURE, MSG_QUERY_ACC_SELECT_SQL_FAILURE, MSG_QUERY_BAT_SELECT_SQL_FAILURE, MSG_QUERY_CRE_SELECT_SQL_FAILURE, MSG_QUERY_ORD_SELECT_SQL_FAILURE, MSG_QUERY_PAY_SELECT_SQL_FAILURE, ORD_ACCOUNT, ORD_ADDRESS, ORD_AMOUNT, ORD_BRAND, ORD_EXPIRY, ORD_MERCHANT, ORD_ORDER, ORD_PAN, ORD_POSTAL_CODE, PAY_APPROVAL, PAY_MERCHANT, PAY_ORDER, PAY_PAYMENT, PAY_REASON, PAYMENT_TYPE, PD_ACC_BATCH_CLOSE_TIME, PD_ACC_CURRENCY, PD_ACC_LDBCARDID, PD_ACC_MAX_BATCH_SIZE, PD_ACC_MIN_BATCH_TOTAL, PD_ACC_PASSWORD, PD_ACC_URL, PD_ACC_USER, PD_PAY_B_CITY, PD_PAY_B_COUNTRYCOD, PD_PAY_B_COUNTRYCODE, PD_PAY_B_POSTALCODE, PD_PAY_B_STATEPROV, PD_PAY_B_STATEPROVINCE, PD_PAY_B_STREETADDR, PD_PAY_B_STREETADDRESS, PD_PAY_BRAND, PD_PAY_CARDHOLDERNAME, PD_PAY_CITY, PD_PAY_COUNTRYCODE, PD_PAY_EXPIRY, PD_PAY_PAN, PD_PAY_POSTALCODE, PD_PAY_STATEPROV, PD_PAY_STATEPROVINCE, PD_PAY_STREETADDR, PD_PAY_STREETADDRESS, RB_ID, SRC_ACCOUNT_CREATE_ROW_FAILURE, SRC_ACCOUNT_CREATE_SQL_FAILURE, SRC_ACCOUNT_DELETE_ROW_FAILURE, SRC_ACCOUNT_DELETE_SQL_FAILURE, SRC_ACCOUNT_ICV_FAILURE, SRC_ACCOUNT_MORE_THAN_ONE_BATCH, SRC_ACCOUNT_NULL_BATCH_CLOSE_TIME, SRC_ACCOUNT_NULL_BATCH_NUMBER, SRC_ACCOUNT_NULL_MAX_BATCH_SIZE, SRC_ACCOUNT_NULL_MIN_BATCH_TOTAL, SRC_ACCOUNT_SELECT_CLOSE_FAILURE, SRC_ACCOUNT_SELECT_SQL_FAILURE, SRC_ACCOUNT_UPDATE_ROW_FAILURE, SRC_ACCOUNT_UPDATE_SQL_FAILURE, SRC_BATCH_BAD_ADD_CREDIT_STATE, SRC_BATCH_BAD_ADD_PAYMENT_STATE, SRC_BATCH_BAD_BATCH_IN_CREDIT, SRC_BATCH_BAD_BATCH_IN_PAYMENT, SRC_BATCH_CLOSE_WORK_ITEM_FAILURE, SRC_BATCH_CREATE_ROW_FAILURE, SRC_BATCH_CREATE_SQL_FAILURE, SRC_BATCH_DELETE_ROW_FAILURE, SRC_BATCH_DELETE_SQL_FAILURE, SRC_BATCH_NULL_CREDIT, SRC_BATCH_NULL_ORDER_FOR_CREDIT, SRC_BATCH_NULL_ORDER_FOR_PAYMENT, SRC_BATCH_NULL_PAYMENT, SRC_BATCH_PURGE_INCOMPLETE, SRC_BATCH_SELECT_BATCH_MISSING, SRC_BATCH_SELECT_CLOSE_FAILURE, SRC_BATCH_SELECT_ROW_FAILURE, SRC_BATCH_SELECT_SQL_FAILURE, SRC_BATCH_TIMER_WORK_ITEM_FAILURE, SRC_BATCH_UPDATE_ROW_FAILURE, SRC_BATCH_UPDATE_SQL_FAILURE, SRC_CASSETTE_BATCH_CLOSE_TIME, SRC_CASSETTE_BUNDLE_ID_MISMATCH, SRC_CASSETTE_CARDHOLDERNAME, SRC_CASSETTE_CURRENCY, SRC_CASSETTE_LDBCARDID, SRC_CASSETTE_LDBCARDRMIURL, SRC_CASSETTE_MAX_BATCH_SIZE, SRC_CASSETTE_MIN_BATCH_TOTAL, SRC_CASSETTE_PASSWORD, SRC_CASSETTE_USER, SRC_CREDIT_CREATE_ROW_FAILURE, SRC_CREDIT_CREATE_SQL_FAILURE, SRC_CREDIT_DELETE_ROW_FAILURE, SRC_CREDIT_DELETE_SQL_FAILURE, SRC_CREDIT_SELECT_CLOSE_FAILURE, SRC_CREDIT_SELECT_CREDIT_MISSING, SRC_CREDIT_SELECT_ROW_FAILURE, SRC_CREDIT_SELECT_SQL_FAILURE, SRC_CREDIT_UPDATE_ROW_FAILURE, SRC_CREDIT_UPDATE_SQL_FAILURE, SRC_METHOD_NOT_IMPLEMENTED, SRC_ORDER_CREATE_ROW_FAILURE, SRC_ORDER_CREATE_SQL_FAILURE, SRC_ORDER_DELETE_ROW_FAILURE, SRC_ORDER_DELETE_SQL_FAILURE, SRC_ORDER_SELECT_CLOSE_FAILURE, SRC_ORDER_SELECT_ORDER_MISSING, SRC_ORDER_SELECT_ROW_FAILURE, SRC_ORDER_SELECT_SQL_FAILURE, SRC_ORDER_UPDATE_ROW_FAILURE, SRC_ORDER_UPDATE_SQL_FAILURE, SRC_PAYMENT_CREATE_ROW_FAILURE, SRC_PAYMENT_CREATE_SQL_FAILURE, SRC_PAYMENT_DELETE_ROW_FAILURE, SRC_PAYMENT_DELETE_SQL_FAILURE, SRC_PAYMENT_SELECT_CLOSE_FAILURE, SRC_PAYMENT_SELECT_PAYMENT_MISSING, SRC_PAYMENT_SELECT_ROW_FAILURE, SRC_PAYMENT_SELECT_SQL_FAILURE, SRC_PAYMENT_UPDATE_ROW_FAILURE, SRC_PAYMENT_UPDATE_SQL_FAILURE, SRC_QUERY_ACC_SELECT_SQL_FAILURE, SRC_QUERY_BAT_SELECT_SQL_FAILURE, SRC_QUERY_CRE_SELECT_SQL_FAILURE, SRC_QUERY_ORD_SELECT_SQL_FAILURE, SRC_QUERY_PAY_SELECT_SQL_FAILURE, TBL_ACCOUNT, TBL_BATCH, TBL_CREDIT, TBL_ORDER, TBL_PAYMENT, TRACE_ID, VIEW_ACCOUNT, VIEW_ACCOUNTS, VIEW_ADDRESS, VIEW_AMOUNT, VIEW_APPROVAL, VIEW_BATCH, VIEW_BATCH_CREDITS, VIEW_BATCH_PAYMENTS, VIEW_BATCHES, VIEW_BRAND, VIEW_CLOSE_TIME, VIEW_CLOSED_TO_TRANS, VIEW_CREDIT, VIEW_CREDITS, VIEW_CURRENCY, VIEW_EXPIRY, VIEW_LDBCARD_ID, VIEW_MAX_BATCH_SIZE, VIEW_MERCHANT, VIEW_MERCHANT_NAME, VIEW_MIN_BATCH_TOTAL, VIEW_ORDER, VIEW_ORDERS, VIEW_PAN, VIEW_PASSWORD, VIEW_PAYMENT, VIEW_PAYMENTS, VIEW_POSTAL_CODE, VIEW_REASON, VIEW_URL, VIEW_USER, XDM_ACCOUNT, XDM_ADDRESS, XDM_AMOUNT, XDM_APPROVAL, XDM_BRAND, XDM_CLOSE_TIME, XDM_CLOSED_TO_TRANS, XDM_CURRENCY, XDM_EXPIRY, XDM_LDBCARD_ID, XDM_MAX_BATCH_SIZE, XDM_MIN_BATCH_TOTAL, XDM_PAN, XDM_PASSWORD, XDM_POSTAL_CODE, XDM_REASON, XDM_URL, XDM_USER
 
Constructor Summary
LdbCardBatch(LdbCardCassette argCassette, com.ibm.etill.framework.payapi.Batch argFrameworkBatch)
          This constructor initializes an existing cassette batch object.
LdbCardBatch(LdbCardCassette argCassette, com.ibm.etill.framework.payapi.Batch argFrameworkBatch, com.ibm.etill.framework.payapi.ParameterTable argProtocolData)
          This constructor initializes a new cassette batch object.
 
Method Summary
 void addCredit(com.ibm.etill.framework.payapi.Credit argFrameworkCredit)
          This method is used to add a credit to a batch.
 void addPayment(com.ibm.etill.framework.payapi.Payment argFrameworkPayment)
          This method is used to add a payment to a batch.
 void batchClose(com.ibm.etill.framework.cassette.BatchCloseRequest argRequest, com.ibm.etill.framework.cassette.APIResponse argResponse)
          This method is used by the cassette when it is asked to service an BatchClose request.
 void batchDelete(com.ibm.etill.framework.cassette.DeleteBatchRequest argRequest, com.ibm.etill.framework.cassette.APIResponse argResponse)
          This method is used by the cassette when it is asked to service an DeleteBatch request.
 void batchOpen(com.ibm.etill.framework.cassette.BatchOpenRequest argRequest, com.ibm.etill.framework.cassette.APIResponse argResponse)
          This method is used by the cassette when it is asked to service a BatchOpen request.
 void batchPurge(com.ibm.etill.framework.cassette.BatchPurgeRequest argRequest, com.ibm.etill.framework.cassette.APIResponse argResponse)
          This method is used by the cassette when it is asked to service a BatchPurge request.
private  com.ibm.etill.framework.cassette.BatchCloseRequest buildBatchCloseRequest()
          This method is used to manufacture an internal batch close request.
 com.ibm.etill.framework.cassette.Cassette cassette()
          This method is used by the framework to obtain the cassette object for the cassette that owns this batch.
private  void closeBatchForAutomaticClose()
          This method is used to set the value that indicates whether or not this batch is closed due to a pending automatic batch close.
private  void closeBatchToNewTrans()
          This method is used to set the value that indicates whether or not this batch is closed to new transactions.
private  void closeCredits()
          This method is used to close all the credits in a closing batch.
private  void closePayments()
          This method is used to close all the payments in a closing batch.
 void createRecord(java.sql.Connection argConnection)
          This method is used by the framework order (a commitable object) when its commit() method discovers the cassette batch object on the framework order's create list.
 void deleteRecord(java.sql.Connection argConnection)
          This method is used by the framework order (a commitable object) when its commit() method discovers the cassette batch object on the framework order's delete list.
 LdbCardAccount getAccount()
          This method is used to obtain the cassette account object used to service this batch;
 java.lang.String getApproval()
          This method is used to obtain the approval code returned by the payment engine.
private  java.lang.Integer getClosedToTrans()
          This method is used to obtain an Integer object that indicates whether or not this batch is closed to new transactions.
 java.lang.String getReason()
          This method is used to obtain the decline reason returned by the payment engine.
 void initializeServiceThreadsIfNecessary()
          This method is used in two cases.
 boolean isBatchClosedForAutomaticClose()
          This method is used to test whether or not this batch is closed to new transactions due to a pending automatic batch close.
 boolean isBatchClosedToNewTransactions()
          This method is used to test whether or not this batch is closed to new transactions.
private  boolean isDeleteBatchAllowed()
          This method is used to determine if it is safe to delete a batch.
private  boolean purgeCredits(com.ibm.etill.framework.cassette.BatchPurgeRequest argRequest, com.ibm.etill.framework.cassette.APIResponse argResponse)
          This method is used to purge all the credits in an open batch.
private  boolean purgePayments(com.ibm.etill.framework.cassette.BatchPurgeRequest argRequest, com.ibm.etill.framework.cassette.APIResponse argResponse)
          This method is used to purge all the payments in an open batch.
 void removeCredit(com.ibm.etill.framework.payapi.Credit argFrameworkCredit)
          This method is used to remove a credit from a batch.
 void removePayment(com.ibm.etill.framework.payapi.Payment argFrameworkPayment)
          This method is used to remove a payment from a batch.
private  void resurrectBatch()
          This method is used by the cassette object to resurrect an existing cassette batch from the cassette batch database table.
 com.ibm.etill.framework.payapi.Credit retrieveBatchCredit(com.ibm.etill.framework.payapi.TransactionKey argKey)
          This method is used by the batch object to retrieve a credit and its order into the cache.
 com.ibm.etill.framework.payapi.Payment retrieveBatchPayment(com.ibm.etill.framework.payapi.TransactionKey argKey)
          This method is used by the batch object to retrieve a payment and its order into the cache.
 void scheduleAutoClose()
          This method is used to automatically close this batch.
private  void scheduleAutoCloseIfRequired()
          This method is used to determine if an automatic batch close should be scheduled and, if so, to schedule the automatic close.
private  void scheduleTimeOfDayCloseIfRequired()
          This method is used to determine if an automatic time of day batch close should be scheduled and, if so, to schedule the automatic close.
 void setApproval(java.lang.String argApprovalCode)
          This method is used to set the approval code.
private  void setClosedToTrans(java.lang.Integer argClosedToTrans)
          This method is used to set the Integer object that indicates whether or not this batch is closed to new transactions.
 void setReason(java.lang.String argDeclineReason)
          This method is used to set the decline reason.
 void updateRecord(java.sql.Connection argConnection)
          This method is used by the framework order (a commitable object) when its commit() method discovers the cassette batch object on the framework order's update list.
 

Field Detail

COPYRIGHT

private static final java.lang.String COPYRIGHT

objCassette

private LdbCardCassette objCassette
This cassette batch attribute contains the reference back to the cassette that owns the batch.

objFrameworkBatch

private com.ibm.etill.framework.payapi.Batch objFrameworkBatch
This cassette batch attribute contains the reference back to the associated framework batch object.

objCassetteAccount

private LdbCardAccount objCassetteAccount
This cassette batch attribute contains the reference to the cassette account object that will be used to perform transactions for this batch.

objApprovalCode

private java.lang.String objApprovalCode
This cassette batch attribute contains the approval code. The approval code is supplied by the payment engine when a batch transaction is successfully performed.

objDeclineReason

private java.lang.String objDeclineReason
This cassette batch attribute contains the decline reason. The decline reason, originally small and therefore cryptic, was designed to be displayed on a card swipe terminal at a point of sale terminal. In this cassette, it provides detailed information about the cause of the failure. (Since the text is provided by the financial network, different for each network, and not standardized in any way, it is impossible to translate these text strings into return codes.)

objClosedToTrans

private java.lang.Integer objClosedToTrans
This cassette batch attribute contains an indicator used to determine if the batch can be used for new transactions. For example, if the batch failed to close (for example, because the batch did not balance) the batch is returned to the BATCH_OPEN state but should not be used for future deposits or refunds. (Adding new transactions to a batch that is out of balance will not help and may harm the batch.) This indicator is set to 1 (true) whenever an automatic batch close is attempted or whenever the merchant explicitly issues a BatchClose request for this batch.

objAutoCloseWorkItem

private LdbCardBatch.AutoCloseWorkItem objAutoCloseWorkItem
This cassette batch attribute is contains a reference to a CassetteWorkItem that is used to schedule an automatic batch close. If this value is null, there is no automatic bach close in progress.

objTimerWorkItem

private LdbCardBatch.TimeOfDayWorkItem objTimerWorkItem
This cassette batch attribute is contains a reference to a CassetteWorkItem that is used to schedule an automatic batch close at a particular time of day. If this value is null, no time of day close has been scheduled.
Constructor Detail

LdbCardBatch

public LdbCardBatch(LdbCardCassette argCassette,
                    com.ibm.etill.framework.payapi.Batch argFrameworkBatch,
                    com.ibm.etill.framework.payapi.ParameterTable argProtocolData)
             throws com.ibm.etill.framework.payapi.ETillAbortOperation
This constructor initializes a new cassette batch object. A reference to the cassette that owns this batch and a reference to associated framework's batch object is set.
Parameters:
argCassette - - The cassette that owns this batch.
argFrameworkBatch - - The framework's batch object.
argProtocolData - - The protocol data parameter values provided by the merchant system.
Throws:
ETillAbortOperation - - any failure results in this exception.

LdbCardBatch

public LdbCardBatch(LdbCardCassette argCassette,
                    com.ibm.etill.framework.payapi.Batch argFrameworkBatch)
             throws com.ibm.etill.framework.payapi.ETillAbortOperation
This constructor initializes an existing cassette batch object. A reference to the associated framework's batch object is set and the remaining attributes are resurrected from the cassette's batch database table.
Parameters:
argCassette - - The cassette that owns this batch.
argFrameworkBatch - - The framework's batch object.
Throws:
ETillAbortOperation - - any failure results in this exception.
Method Detail

initializeServiceThreadsIfNecessary

public void initializeServiceThreadsIfNecessary()
This method is used in two cases.
  1. The cassette account object calls this method after creating a new batch.
  2. The cassette object calls this method when it receives an administration request with the START_CASSETTE token.

In either case, this method will start the cassette batch's service threads if necessary.

NOTE: This method must be called whenever a cassette batch object is constructed. Unfortunately, it cannot be called by the constructors. The cassette batch object is constructed before the framework batch object is completely initialized and the framework batch object must be completely initialized before this method is called. In order to start a service thread, a BatchCloseRequest must be constructed. This will fail if the read and write locks in the framework batch object have not been initialized.


cassette

public com.ibm.etill.framework.cassette.Cassette cassette()
This method is used by the framework to obtain the cassette object for the cassette that owns this batch.
Returns:
- The cassette object for the cassette that owns this batch

resurrectBatch

private void resurrectBatch()
                     throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used by the cassette object to resurrect an existing cassette batch from the cassette batch database table.

This method is not part of the Archivable interface. The methods for the Archivable interface are passed a JDBC database connection for the operation. In this case, an ETillArchive object is constructed to provide a JDBC databaes connection.

Throws:
ETillAbortOperation - - any failure results in this exception.

createRecord

public void createRecord(java.sql.Connection argConnection)
                  throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used by the framework order (a commitable object) when its commit() method discovers the cassette batch object on the framework order's create list.
Parameters:
argConnection - - The JDBC database connection to be used for this operation.
Throws:
ETillAbortOperation - - any failure results in this exception.

updateRecord

public void updateRecord(java.sql.Connection argConnection)
                  throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used by the framework order (a commitable object) when its commit() method discovers the cassette batch object on the framework order's update list.
Parameters:
argConnection - - The JDBC database connection to be used for this operation.
Throws:
ETillAbortOperation - - any failure results in this exception.

deleteRecord

public void deleteRecord(java.sql.Connection argConnection)
                  throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used by the framework order (a commitable object) when its commit() method discovers the cassette batch object on the framework order's delete list.
Parameters:
argConnection - - The JDBC database connection to be used for this operation.
Throws:
ETillAbortOperation - - any failure results in this exception.

batchOpen

public void batchOpen(com.ibm.etill.framework.cassette.BatchOpenRequest argRequest,
                      com.ibm.etill.framework.cassette.APIResponse argResponse)
               throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used by the cassette when it is asked to service a BatchOpen request.

For this cassette, the payment engine does not allow a merchant to open a batch. Batches are always implictly opened as needed. The operation is always aborted.

Parameters:
argRequest - - A BatchOpen batch request.
argResponse - - The response object to hold the result.
Throws:
ETillAbortOperation - - any failure results in this exception.

batchClose

public void batchClose(com.ibm.etill.framework.cassette.BatchCloseRequest argRequest,
                       com.ibm.etill.framework.cassette.APIResponse argResponse)
                throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used by the cassette when it is asked to service an BatchClose request.

For this cassette, the account object is used to settle the batch. If successful, the batch will be closed with a status of balanced. Otherwise, the batch will remain open with a status of "out of balance".

Parameters:
argRequest - - A BatchClose batch request.
argResponse - - The response object to hold the result.
Throws:
ETillAbortOperation - - any failure results in this exception.

closePayments

private void closePayments()
                    throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used to close all the payments in a closing batch.
Throws:
ETillAbortOperation - - any failure results in this exception.

closeCredits

private void closeCredits()
                   throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used to close all the credits in a closing batch.
Throws:
ETillAbortOperation - - any failure results in this exception.

batchPurge

public void batchPurge(com.ibm.etill.framework.cassette.BatchPurgeRequest argRequest,
                       com.ibm.etill.framework.cassette.APIResponse argResponse)
                throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used by the cassette when it is asked to service a BatchPurge request.

For this cassette, the method attempts to reverse every deposit and every refund in the open batch. Note that an exception thrown by either case is not considered fatal. A purge operation, by definition, does the best it can to empty the batch both locally and in the financial network. If any payment or credit cannot be removed, the purge operation continues. If this type of error occurs, human intervention may be required to synchronize the Payment Manager with the financial network.

Parameters:
argRequest - - A BatchPurge batch request.
argResponse - - The response object to hold the result.
Throws:
ETillAbortOperation - - any failure results in this exception.

purgePayments

private boolean purgePayments(com.ibm.etill.framework.cassette.BatchPurgeRequest argRequest,
                              com.ibm.etill.framework.cassette.APIResponse argResponse)
This method is used to purge all the payments in an open batch.
Parameters:
argRequest - - A BatchPurge batch request.
argResponse - - The response object to hold the result.
Returns:
- An incomplete indicator: true if some payments could not be removed from the batch, false otherwise.

purgeCredits

private boolean purgeCredits(com.ibm.etill.framework.cassette.BatchPurgeRequest argRequest,
                             com.ibm.etill.framework.cassette.APIResponse argResponse)
This method is used to purge all the credits in an open batch.
Parameters:
argRequest - - A BatchPurge batch request.
argResponse - - The response object to hold the result.
Returns:
- An incomplete indicator: true if some credits could not be removed from the batch, false otherwise.

retrieveBatchPayment

public com.ibm.etill.framework.payapi.Payment retrieveBatchPayment(com.ibm.etill.framework.payapi.TransactionKey argKey)
                                                            throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used by the batch object to retrieve a payment and its order into the cache. Any retrieved objects will be released from the cache automatically when the current commit point is committed or rejected.
Parameters:
argKey - - The transaction key taken from the framework batch payment list.
Returns:
- A framework payment object for the specified key.
Throws:
ETillAbortOperation - - any error will result in this exception.

retrieveBatchCredit

public com.ibm.etill.framework.payapi.Credit retrieveBatchCredit(com.ibm.etill.framework.payapi.TransactionKey argKey)
                                                          throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used by the batch object to retrieve a credit and its order into the cache. Any retrieved objects will be released from the cache automatically when the current commit point is committed or rejected.
Parameters:
argKey - - The transaction key taken from the framework batch credit list.
Returns:
- A framework credit object for the specified key.
Throws:
ETillAbortOperation - - any error will result in this exception.

batchDelete

public void batchDelete(com.ibm.etill.framework.cassette.DeleteBatchRequest argRequest,
                        com.ibm.etill.framework.cassette.APIResponse argResponse)
                 throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used by the cassette when it is asked to service an DeleteBatch request.

Parameters:
argRequest - - A DeleteBatch batch request.
argResponse - - The response object to hold the result.
Throws:
ETillAbortOperation - - any failure results in this exception.

isDeleteBatchAllowed

private boolean isDeleteBatchAllowed()
This method is used to determine if it is safe to delete a batch.
Returns:
True if the payment and credit list is empty, false otherwise.

addPayment

public void addPayment(com.ibm.etill.framework.payapi.Payment argFrameworkPayment)
This method is used to add a payment to a batch.

The method must be synchronized because framework API locks do not prevent race conditions between automatic batch close requests and API requests that affect the contents of the batch (Deposit, DepositReversal, Refund and RefundReversal). Synchronizing on the cassette batch object prevents one thread from changing the contents of the batch a micro-moment after some other thread has triggered an automatic batch close.

Parameters:
argFrameworkPayment - - the framework payment object to be removed from the batch.

removePayment

public void removePayment(com.ibm.etill.framework.payapi.Payment argFrameworkPayment)
                   throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used to remove a payment from a batch.

The method must be synchronized because framework API locks do not prevent race conditions between automatic batch close requests and API requests that affect the contents of the batch (Deposit, DepositReversal, Refund and RefundReversal). Synchronizing on the cassette batch object prevents one thread from changing the contents of the batch a micro-moment after some other thread has triggered an automatic batch close.

Parameters:
argFrameworkPayment - - the framework payment object to be removed from the batch.
Throws:
ETillAbortOperation - - any error results in this exception.

addCredit

public void addCredit(com.ibm.etill.framework.payapi.Credit argFrameworkCredit)
This method is used to add a credit to a batch.

The method must be synchronized because framework API locks do not prevent race conditions between automatic batch close requests and API requests that affect the contents of the batch (Deposit, DepositReversal, Refund and RefundReversal). Synchronizing on the cassette batch object prevents one thread from changing the contents of the batch a micro-moment after some other thread has triggered an automatic batch close.

Parameters:
argFrameworkCredit - - the framework payment credit to be removed from the batch.

removeCredit

public void removeCredit(com.ibm.etill.framework.payapi.Credit argFrameworkCredit)
                  throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used to remove a credit from a batch.

The method must be synchronized because framework API locks do not prevent race conditions between automatic batch close requests and API requests that affect the contents of the batch (Deposit, DepositReversal, Refund and RefundReversal). Synchronizing on the cassette batch object prevents one thread from changing the contents of the batch a micro-moment after some other thread has triggered an automatic batch close.

Parameters:
argFrameworkCredit - - the framework credit object to be removed from the batch.
Throws:
ETillAbortOperation - - any error results in this exception.

scheduleTimeOfDayCloseIfRequired

private void scheduleTimeOfDayCloseIfRequired()
This method is used to determine if an automatic time of day batch close should be scheduled and, if so, to schedule the automatic close.

scheduleAutoCloseIfRequired

private void scheduleAutoCloseIfRequired()
This method is used to determine if an automatic batch close should be scheduled and, if so, to schedule the automatic close.

scheduleAutoClose

public void scheduleAutoClose()
This method is used to automatically close this batch. It constructs a work item that will be processed asynchronously by a service thread. A service thread is required because the current thread does not hold the locks required to close the batch in a thread safe manner. The service thread will get the correct locks (as specified by a BatchCloseRequest object constructed here) before calling the work item's doYourWork() method.

This method may be used by methods in this object when they discover that the maximum batch size has been reached or by methods in a TimeOfDayWorkItem when an automatic time-of-day batch close is to be performed.


buildBatchCloseRequest

private com.ibm.etill.framework.cassette.BatchCloseRequest buildBatchCloseRequest()
                                                                           throws com.ibm.etill.framework.payapi.ETillAbortOperation
This method is used to manufacture an internal batch close request.
Returns:
- A BatchCloseRequest
Throws:
ETillAbortOperation - - any failure results in this exception.

getAccount

public LdbCardAccount getAccount()
This method is used to obtain the cassette account object used to service this batch;
Returns:
- The cassette account object used by this batch.

getApproval

public java.lang.String getApproval()
This method is used to obtain the approval code returned by the payment engine.
Returns:
- The approval code returned by the payment engine.

getReason

public java.lang.String getReason()
This method is used to obtain the decline reason returned by the payment engine.
Returns:
- The decline reason returned by the payment engine.

getClosedToTrans

private java.lang.Integer getClosedToTrans()
This method is used to obtain an Integer object that indicates whether or not this batch is closed to new transactions. This is a private method; it is to be used exclusively for getting an object used to update the data base.
Returns:
- An Integer object that indicates whether or not this batch is closed to new transactions.

isBatchClosedToNewTransactions

public boolean isBatchClosedToNewTransactions()
This method is used to test whether or not this batch is closed to new transactions.
Returns:
- False if the batch can be used for new transactions, true otherwise.

isBatchClosedForAutomaticClose

public boolean isBatchClosedForAutomaticClose()
This method is used to test whether or not this batch is closed to new transactions due to a pending automatic batch close.
Returns:
- False if the batch can be used for new transactions, true otherwise.

setApproval

public void setApproval(java.lang.String argApprovalCode)
This method is used to set the approval code.
Parameters:
argApprovalCode - - The new approval code returned by the payment engine.

setReason

public void setReason(java.lang.String argDeclineReason)
This method is used to set the decline reason.
Parameters:
argDeclineReason - - The new decline reason returned by the payment engine.

setClosedToTrans

private void setClosedToTrans(java.lang.Integer argClosedToTrans)
This method is used to set the Integer object that indicates whether or not this batch is closed to new transactions. This is a private method; it is to be used exclusively for processing an object returned from a database query.
Parameters:
argClosedToTrans - - The Integer object that indicates whether or not this batch is closed to new transactions.

closeBatchToNewTrans

private void closeBatchToNewTrans()
This method is used to set the value that indicates whether or not this batch is closed to new transactions.

closeBatchForAutomaticClose

private void closeBatchForAutomaticClose()
This method is used to set the value that indicates whether or not this batch is closed due to a pending automatic batch close.