<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
# standalone credit
$credit_info = array('id' => '456', 'card' => array('type' => 'VI', 'number' => '4100000000000001', 'expDate' => '1213', 'cardValidationNum' => '1213'), 'orderSource' => 'ecommerce', 'orderId' => '12321', 'amount' => '123');
$initilaize =& new LitleOnlineRequest();
$creditResponse = $initilaize->creditRequest($credit_info);
#display results
echo "Response: " . XmlParser::getNode($creditResponse, 'response') . "<br>";
echo "Message: " . XmlParser::getNode($creditResponse, 'message') . "<br>";
echo "Litle Transaction ID: " . XmlParser::getNode($creditResponse, 'litleTxnId');
if (XmlParser::getNode($creditResponse, 'message') != 'Approved') {
    throw new \Exception('LitleRefundTransaction does not get the right response');
}
<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
#Re authorization using the litleTxnId of a previous auth
$auth_info = array('litleTxnId' => '1234567891234567891', 'id' => '456');
$initilaize =& new LitleOnlineRequest();
$authResponse = $initilaize->authorizationRequest($auth_info);
#display results
echo "Response: " . XmlParser::getNode($authResponse, 'response') . "<br>";
echo "Message: " . XmlParser::getNode($authResponse, 'message') . "<br>";
echo "Litle Transaction ID: " . XmlParser::getNode($authResponse, 'litleTxnId');
if (XmlParser::getNode($authResponse, 'message') != 'Approved') {
    throw new \Exception('LitleReAuthorizationTransaction does not get the right response');
}
 /**
  * void method
  *
  * @returns message, voidMessage, Response and litleTxnId to database
  */
 public function void($id = null)
 {
     $this->Auth->id = $id;
     if (!$this->Auth->exists()) {
         throw new NotFoundException(__('Invalid auth'));
     }
     if ($this->request->is('post') || $this->request->is('put')) {
         $hash_in = array('litleTxnId' => $this->Auth->field('litleTxnId'));
         $initilaize =& new LitleOnlineRequest();
         @($voidResponse = $initilaize->voidRequest($hash_in));
         $voidMessage = XmlParser::getNode($voidResponse, 'message');
         $voidLitleTxnId = XmlParser::getNode($voidResponse, 'litleTxnId');
         $message = XmlParser::getAttribute($voidResponse, 'litleOnlineResponse', 'message');
         $response = XmlParser::getNode($voidResponse, 'response');
         $this->request->data['Auth']['voidResponse'] = $response;
         $this->request->data['Auth']['message'] = NULL;
         $this->request->data['Auth']['litleTxnId'] = NULL;
         $this->request->data['Auth']['transactionStatus'] = NULL;
         $this->request->data['Auth']['message'] = $message;
         $this->request->data['Auth']['litleTxnId'] = $voidLitleTxnId;
         $this->request->data['Auth']['voidMessage'] = $voidMessage;
         $this->request->data['Auth']['transactionStatus'] = $voidMessage;
         $this->request->data['Auth']['voidLitleTxnId'] = $voidLitleTxnId;
         if ($this->Auth->save($this->request->data)) {
             $this->Session->setFlash(__($voidMessage));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The auth could not be saved. Please, try again.'));
         }
     } else {
         $this->request->data = $this->Auth->read(null, $id);
     }
 }
<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
#Partial Capture
#litleTxnId contains the Litle Transaction Id returned as part of the authorization
#submit the amount to capture which is less than the authorization amount
#to generate a partial capture
$capture_in = array('partial' => 'true', 'id' => '456', 'litleTxnId' => '320000000000000001', 'amount' => '5005');
$initilaize = new LitleOnlineRequest();
$captureResponse = $initilaize->captureRequest($capture_in);
#display results
echo "Response: " . XmlParser::getNode($captureResponse, 'response') . "<br>";
echo "Message: " . XmlParser::getNode($captureResponse, 'message') . "<br>";
echo "Litle Transaction ID: " . XmlParser::getNode($captureResponse, 'litleTxnId');
if (XmlParser::getNode($captureResponse, 'message') != 'Approved') {
    throw new \Exception('LitlePartialCapture does not get the right response');
}
<?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'));
$initilaize =& new LitleOnlineRequest();
$saleResponse = $initilaize->saleRequest($sale_info);
#display results
echo "Response: " . XmlParser::getNode($saleResponse, 'response') . "<br>";
echo "Message: " . XmlParser::getNode($saleResponse, 'message') . "<br>";
echo "Litle Transaction ID: " . XmlParser::getNode($saleResponse, 'litleTxnId');
echo "All Response :" . XmlParser::getAttribute($saleResponse, 'litleOnlineResponse', 'version');
<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
#Partial Auth Reversal
#litleTxnId contains the Litle Transaction Id returned on the authorization
$authRev_info = array('litleTxnId' => '350000000000000001', 'amount' => '20020');
$initilaize =& new LitleOnlineRequest();
$reversalResponse = $initilaize->authReversalRequest($authRev_info);
#display results
echo "Response: " . XmlParser::getNode($reversalResponse, 'response') . "<br>";
echo "Message: " . XmlParser::getNode($reversalResponse, 'message') . "<br>";
echo "Litle Transaction ID: " . XmlParser::getNode($reversalResponse, 'litleTxnId');
if (XmlParser::getNode($reversalResponse, 'message') != 'Approved') {
    throw new \Exception('LitlePartialAuthReversalTranasaction does not get the right response');
}
<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
#Register an account number to receive a Litle Token
$token_info = array('orderId' => '12344', 'id' => '456', 'accountNumber' => '1233456789103801');
$initilaize =& new LitleOnlineRequest();
$tokenResponse = $initilaize->registerTokenRequest($token_info);
#display results
echo "Response: " . XmlParser::getNode($tokenResponse, 'response') . "<br>";
echo "Message: " . XmlParser::getNode($tokenResponse, 'message') . "<br>";
echo "Litle Transaction ID: " . XmlParser::getNode($tokenResponse, 'litleTxnId') . "<br>";
echo "Litle Token: " . XmlParser::getNode($tokenResponse, 'litleToken');
if (XmlParser::getNode($tokenResponse, 'message') != 'Account number was successfully registered') {
    throw new \Exception('LitleRegisterTokenTransaction does not get the right response');
}