<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
#Sale
$sale_info = array('orderId' => '1', 'amount' => '10010', 'orderSource' => 'ecommerce', 'billToAddress' => array('name' => 'John Smith', 'addressLine1' => '1 Main St.', 'city' => 'Burlington', 'state' => 'MA', 'zip' => '01803-3747', 'country' => 'US'), 'card' => array('number' => '5112010000000003', 'expDate' => '0112', 'cardValidationNum' => '349', 'type' => 'MC'));
$config_hash = array('user' => 'BATCHSDKA', 'password' => 'certpass', 'merchantId' => '101', 'sftp_username' => 'sdk', 'sftp_password' => 'Zj8I8Ly5', 'batch_url' => 'prelive.litle.com', 'batch_requests_path' => '/usr/local/litle-home/twang/git/batches', 'litle_requests_path' => '/usr/local/litle-home/twang/git/batches');
$batch_dir = '/usr/local/litle-home/twang/git/batches';
$litle_request = new LitleRequest($config_hash);
$batch_request = new BatchRequest($batch_dir);
# add a sale to the batch
$batch_request->addSale($sale_info);
# close the batch, indicating that we intend to add no more sales
$batch_request->closeRequest();
# add the batch to the litle request
$litle_request->addBatchRequest($batch_request);
# close the litle request, indicating that we intend to add no more batches
$litle_request->closeRequest();
# send the batch to litle via SFTP
$response_file = $litle_request->sendToLitleStream();
# process the response file
$processor = new LitleResponseProcessor($response_file);
while ($txn = $processor->nextTransaction()) {
    echo "Transaction Type : " . $txn->getName() . "\n";
    echo "Transaction Id: " . $txn->litleTxnId . " \n";
    if ($txn->message != 'Approved') {
        throw new \Exception('ConfiguredLitleBatchRequestsMaually does not get the right response');
    }
}
<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
$request = new LitleRequest();
$batch = new BatchRequest();
$sale_info = array('orderId' => '1', 'amount' => '10010', 'orderSource' => 'ecommerce', 'billToAddress' => array('name' => 'John Smith', 'addressLine1' => '1 Main St.', 'city' => 'Burlington', 'state' => 'MA', 'zip' => '01803-3747', 'country' => 'US'), 'card' => array('number' => '5112010000000003', 'expDate' => '0112', 'cardValidationNum' => '349', 'type' => 'MC'));
$batch->addSale($sale_info);
$request->addBatchRequest($batch);
$response_file = $request->sendToLitleStream();
$proc = new LitleResponseProcessor($response_file);
$raw_response = $proc->nextTransaction(true);
$sxe = new \SimpleXMLElement($raw_response);
echo "name:" . $sxe->message[0] . "\n";
echo "Response Raw XML: " . $raw_response;
if ($sxe->message[0] != 'Approved') {
    throw new \Exception('RawProcessing does not get the right response');
}
<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
# this is a really big request
$request = new LitleRequest();
$batch = new BatchRequest();
$hash_in = array('card' => array('type' => 'VI', 'number' => '4100000000000001', 'expDate' => '1213', 'cardValidationNum' => '1213'), 'orderId' => '2111', 'orderSource' => 'ecommerce', 'id' => '654', 'amount' => '123');
$batch->addAuth($hash_in);
$hash_in = array('card' => array('type' => 'VI', 'number' => '4100000000000001', 'expDate' => '1213', 'cardValidationNum' => '1213'), 'id' => '654', 'orderId' => '2111', 'orderSource' => 'ecommerce', 'amount' => '123');
$batch->addSale($hash_in);
$request->addBatchRequest($batch);
$resp = new LitleResponseProcessor($request->sendToLitle());
while ($txn = $resp->nextTransaction()) {
    echo "Transaction Type : " . $txn->getName() . "\n";
    echo "Transaction Id: " . $txn->litleTxnId . " \n";
    echo "Message: " . $txn->message . " \n";
    if ($txn->message != 'Approved') {
        throw new \Exception('MechaBatch does not get the right response');
    }
}
<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
# use Auth batch to get the session Id
$request = new LitleRequest();
$batch = new BatchRequest();
$hash_in = array('card' => array('type' => 'VI', 'number' => '4100000000000001', 'expDate' => '1213', 'cardValidationNum' => '1213'), 'orderId' => '2111', 'orderSource' => 'ecommerce', 'id' => '654', 'amount' => '123');
$batch->addAuth($hash_in);
$request->addBatchRequest($batch);
$responseFileLoc = $request->sendToLitleStream();
$resp = new LitleResponseProcessor($responseFileLoc);
$xmlReader = $resp->getXmlReader();
$sessionId = $xmlReader->getAttribute("litleSessionId");
echo "sessionId:" + $sessionId;
#Process RFR request
$request = new LitleRequest();
$request->createRFRRequest(array('litleSessionId' => $sessionId));
$response_file = $request->sendToLitleStream();
$processor = new LitleResponseProcessor($response_file);
$res = $processor->nextTransaction(true);
echo $res;
$xml = simplexml_load_string($res);
if ($xml->message[0] != 'Approved') {
    throw new \Exception('RfrRequest does not get the right response');
}
// if($xmlReader->getAttribute("message")!='Approved')
// throw new \Exception('RfrRequest does not get the right response');
//