/* PAGE DESCRIPTION:
This is the form handler for the "settle.html" form. It sets up
all of the necessary parameters and calls the necessary functions
before the call to settle the batch, SettleBatch(), is made.
*/
// Assumption:
// 1 slip per purchase
// 1 terminal/merchant pair specified in system.ini
// If this is changed in the middle, things will go wrong.
// /////////////////////// BEGIN MAIN ////////////////////////
/* *** CONSTANTS *** */
var NOARG = null; // use as an indicator that no relevant argument need be passed.
// Used as a place-holder in a function call.
/* *** VARIABLES *** */
var merchantReference = null;
/* Merchants may want to assign their own meaningful values to
the merchantReference variable here. It is used in the transaction
processing and is stored in the database. If left as null, the
program will generate a value for it at the time of the transaction
process. However, some merchants may want to insert some more
meaningful data into this field.
Please see "MakeValidMerchantReference()" for
length restrictions on the "merchantReference" variable.
*/
registerLivePayment();
merchant = new Merchant();
terminal = new Terminal();
processor = new Processor(project.acquirer);
if (processor.bad())
{
PrintFmtError("Failed to construct processor object.",
processor.getStatusMessage());
}
/* If database type is INFORMIX, Set database server to wait 20 seconds if
table/row is locked.
*** THIS COMMAND IS SPECIFIC TO INFORMIX *** */
if (project.dbType.toUpperCase() == "INFORMIX")
database.execute("SET LOCK MODE TO WAIT 20");
// Get the current batch object.
//
batch = GetCurrentBatch(merchant, terminal, processor);
// If an Autocapture was requested before settling the batch,
// peform that first.
//
if ((batch.status == "OPENED") && (request.type == "autocapture"))
{
AuthToCapturing(batch, NOARG, true);
Capture(NOARG, batch, merchant, terminal, processor, merchantReference, true);
}
// Update batch status to SETTLING. MUST be called before SettleBatch()
//
PrepareToSettle(batch, merchant, terminal, processor, merchantReference);
// Currently, the currency type is set in "start.html"
//
batch.currency = project.currency;
// Actually settle the batch
//
SettleBatch(batch, merchant, terminal, processor, merchantReference);