public function test_mechaBatch()
 {
     $batch = new BatchRequest($this->direct);
     $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('litleTxnId' => '1234567890', 'reportGroup' => 'Planets', 'amount' => '5000');
     $batch->addAuthReversal($hash_in);
     $hash_in = array('litleTxnId' => '12312312', 'amount' => '123');
     $batch->addCapture($hash_in);
     $hash_in = array('amount' => '123', 'orderId' => '12344', 'authInformation' => array('authDate' => '2002-10-09', 'authCode' => '543216', 'authAmount' => '12345'), 'orderSource' => 'ecommerce', 'card' => array('type' => 'VI', 'number' => '4100000000000001', 'expDate' => '1210'));
     $batch->addCaptureGivenAuth($hash_in);
     $hash_in = array('litleTxnId' => '12312312', 'reportGroup' => 'Planets', 'amount' => '123');
     $batch->addCredit($hash_in);
     $hash_in = array('litleTxnId' => '123123');
     $batch->addEcheckCredit($hash_in);
     $hash_in = array('litleTxnId' => '123123');
     $batch->addEcheckRedeposit($hash_in);
     $hash_in = array('amount' => '123456', 'verify' => 'true', 'orderId' => '12345', 'orderSource' => 'ecommerce', 'echeck' => array('accType' => 'Checking', 'accNum' => '12345657890', 'routingNum' => '123456789', 'checkNum' => '123455'), 'billToAddress' => array('name' => 'Bob', 'city' => 'lowell', 'state' => 'MA', 'email' => 'litle.com'));
     $batch->addEcheckSale($hash_in);
     $hash_in = array('amount' => '123456', 'verify' => 'true', 'orderId' => '12345', 'orderSource' => 'ecommerce', 'echeck' => array('accType' => 'Checking', 'accNum' => '12345657890', 'routingNum' => '123456789', 'checkNum' => '123455'), 'billToAddress' => array('name' => 'Bob', 'city' => 'lowell', 'state' => 'MA', 'email' => 'litle.com'));
     $batch->addEcheckVerification($hash_in);
     $hash_in = array('orderId' => '123', 'litleTxnId' => '123456', 'amount' => '106', 'orderSource' => 'ecommerce', 'token' => array('litleToken' => '123456789101112', 'expDate' => '1210', 'cardValidationNum' => '555', 'type' => 'VI'));
     $batch->addForceCapture($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);
     $hash_in = array('orderId' => '1', 'accountNumber' => '123456789101112');
     $batch->addRegisterToken($hash_in);
     $hash_in = array('orderId' => '1', 'litleToken' => '123456789101112', 'cardValidationNum' => '123');
     $batch->addUpdateCardValidationNumOnToken($hash_in);
     $this->assertEquals(13, $batch->total_txns);
     $cts = $batch->getCountsAndAmounts();
     $this->assertEquals(1, $cts['sale']['count']);
     $this->assertEquals(1, $cts['auth']['count']);
     $this->assertEquals(1, $cts['credit']['count']);
     $this->assertEquals(1, $cts['tokenRegistration']['count']);
     $this->assertEquals(1, $cts['capture']['count']);
     $this->assertEquals(1, $cts['forceCapture']['count']);
     $this->assertEquals(1, $cts['echeckRedeposit']['count']);
     $this->assertEquals(1, $cts['echeckSale']['count']);
     $this->assertEquals(1, $cts['echeckCredit']['count']);
     $this->assertEquals(1, $cts['echeckVerification']['count']);
     $this->assertEquals(1, $cts['updateCardValidationNumOnToken']['count']);
     $this->assertEquals(123, $cts['sale']['amount']);
     $this->assertEquals(123, $cts['auth']['amount']);
     $this->assertEquals(123, $cts['credit']['amount']);
     $this->assertEquals(123, $cts['capture']['amount']);
     $this->assertEquals(106, $cts['forceCapture']['amount']);
     $this->assertEquals(123456, $cts['echeckSale']['amount']);
     $this->assertEquals(123456, $cts['echeckVerification']['amount']);
 }
 public function test_processMecha()
 {
     $request = new LitleRequest($this->config);
     // first batch
     $batch = new BatchRequest($this->direct);
     $hash_in = array('id' => '1211', '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('id' => '1211', 'litleTxnId' => '1234567890', 'reportGroup' => 'Planets', 'amount' => '5000');
     $batch->addAuthReversal($hash_in);
     $hash_in = array('id' => '1211', 'litleTxnId' => '12312312', 'amount' => '123');
     $batch->addCapture($hash_in);
     $request->addBatchRequest($batch);
     // second batch
     $batch = new BatchRequest($this->direct);
     $hash_in = array('id' => '1211', 'amount' => '123', 'orderId' => '12344', 'authInformation' => array('authDate' => '2002-10-09', 'authCode' => '543216', 'authAmount' => '12345'), 'orderSource' => 'ecommerce', 'card' => array('type' => 'VI', 'number' => '4100000000000001', 'expDate' => '1210'));
     $batch->addCaptureGivenAuth($hash_in);
     $hash_in = array('id' => '1211', 'litleTxnId' => '12312312', 'reportGroup' => 'Planets', 'amount' => '123');
     $batch->addCredit($hash_in);
     $hash_in = array('id' => '1211', 'litleTxnId' => '123123');
     $batch->addEcheckCredit($hash_in);
     $request->addBatchRequest($batch);
     // third batch
     $batch = new BatchRequest($this->direct);
     $hash_in = array('id' => '1211', 'litleTxnId' => '123123');
     $batch->addEcheckRedeposit($hash_in);
     $hash_in = array('id' => '1211', 'amount' => '123456', 'verify' => 'true', 'orderId' => '12345', 'orderSource' => 'ecommerce', 'echeck' => array('accType' => 'Checking', 'accNum' => '12345657890', 'routingNum' => '123456789', 'checkNum' => '123455'), 'billToAddress' => array('name' => 'Bob', 'city' => 'lowell', 'state' => 'MA', 'email' => 'litle.com'));
     $batch->addEcheckSale($hash_in);
     $hash_in = array('id' => '1211', 'amount' => '123456', 'verify' => 'true', 'orderId' => '12345', 'orderSource' => 'ecommerce', 'echeck' => array('accType' => 'Checking', 'accNum' => '12345657890', 'routingNum' => '123456789', 'checkNum' => '123455'), 'billToAddress' => array('name' => 'Bob', 'city' => 'lowell', 'state' => 'MA', 'email' => 'litle.com'));
     $batch->addEcheckVerification($hash_in);
     $request->addBatchRequest($batch);
     // fourth batch
     $batch = new BatchRequest($this->direct);
     $hash_in = array('id' => '1211', 'orderId' => '123', 'litleTxnId' => '123456', 'amount' => '106', 'orderSource' => 'ecommerce', 'token' => array('litleToken' => '123456789101112', 'expDate' => '1210', 'cardValidationNum' => '555', 'type' => 'VI'));
     $batch->addForceCapture($hash_in);
     $hash_in = array('id' => '1211', 'card' => array('type' => 'VI', 'number' => '4100000000000001', 'expDate' => '1213', 'cardValidationNum' => '1213'), 'id' => '654', 'orderId' => '2111', 'orderSource' => 'ecommerce', 'amount' => '123');
     $batch->addSale($hash_in);
     $hash_in = array('id' => '1211', 'orderId' => '1', 'accountNumber' => '123456789101112');
     $batch->addRegisterToken($hash_in);
     $hash_in = array('id' => '1211', 'orderId' => '1', 'litleToken' => '123456789101112', 'cardValidationNum' => '123');
     $batch->addUpdateCardValidationNumOnToken($hash_in);
     $request->addBatchRequest($batch);
     // fifth batch - recurring
     $batch = new BatchRequest($this->direct);
     $hash_in = array('subscriptionId' => '1', 'planCode' => '2', 'billToAddress' => array('addressLine1' => '3'), 'card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'), 'billingDate' => '2013-12-17');
     $batch->addUpdateSubscription($hash_in);
     $hash_in = array('subscriptionId' => '2');
     $batch->addCancelSubscription($hash_in);
     $hash_in = array('planCode' => '1', 'name' => '2', 'intervalType' => 'MONTHLY', 'amount' => '1000');
     $batch->addCreatePlan($hash_in);
     $hash_in = array('planCode' => '1', 'active' => 'false');
     $batch->addUpdatePlan($hash_in);
     $request->addBatchRequest($batch);
     // sixth batch - au
     $batch = new BatchRequest($this->direct);
     $hash_in = array('id' => '1211', 'card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'), 'orderId' => '8675309');
     $batch->addAccountUpdate($hash_in);
     $request->addBatchRequest($batch);
     // seventh batch - gift card
     $batch = new BatchRequest($this->direct);
     $hash_in = array('id' => '1211', 'orderId' => '1', 'amount' => '2', 'orderSource' => 'ecommerce', 'card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'));
     $batch->addActivate($hash_in);
     $hash_in = array('id' => '1211', 'orderId' => '1', 'orderSource' => 'ecommerce', 'card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'));
     $batch->addDeactivate($hash_in);
     $hash_in = array('id' => '1211', 'orderId' => '1', 'amount' => '2', 'orderSource' => 'ecommerce', 'card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'));
     $batch->addLoad($hash_in);
     $hash_in = array('id' => '1211', 'orderId' => '1', 'amount' => '2', 'orderSource' => 'ecommerce', 'card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'));
     $batch->addUnload($hash_in);
     $hash_in = array('id' => '1211', 'orderId' => '1', 'orderSource' => 'ecommerce', 'card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'));
     $batch->addBalanceInquiry($hash_in);
     $request->addBatchRequest($batch);
     $resp = $request->sendToLitleStream();
     $respProcessor = new LitleResponseProcessor($resp);
     $txnResponse = $respProcessor->nextTransaction();
     $responses = array();
     while ($txnResponse != FALSE) {
         $txnResponseName = $txnResponse->getName();
         array_push($responses, $txnResponseName);
         $txnResponse = $respProcessor->nextTransaction();
     }
     $this->assertTrue(in_array("authorizationResponse", $responses));
     $this->assertTrue(in_array("captureResponse", $responses));
     $this->assertTrue(in_array("authReversalResponse", $responses));
     $this->assertTrue(in_array("captureGivenAuthResponse", $responses));
     $this->assertTrue(in_array("creditResponse", $responses));
     $this->assertTrue(in_array("echeckCreditResponse", $responses));
     $this->assertTrue(in_array("echeckRedepositResponse", $responses));
     $this->assertTrue(in_array("echeckSalesResponse", $responses));
     $this->assertTrue(in_array("echeckVerificationResponse", $responses));
     $this->assertTrue(in_array("forceCaptureResponse", $responses));
     $this->assertTrue(in_array("saleResponse", $responses));
     $this->assertTrue(in_array("registerTokenResponse", $responses));
     $this->assertTrue(in_array("updateCardValidationNumOnTokenResponse", $responses));
     $this->assertTrue(in_array("updateSubscriptionResponse", $responses));
     $this->assertTrue(in_array("cancelSubscriptionResponse", $responses));
     $this->assertTrue(in_array("createPlanResponse", $responses));
     $this->assertTrue(in_array("updatePlanResponse", $responses));
     $this->assertTrue(in_array("accountUpdateResponse", $responses));
     $this->assertTrue(in_array("activateResponse", $responses));
     $this->assertTrue(in_array("deactivateResponse", $responses));
     $this->assertTrue(in_array("loadResponse", $responses));
     $this->assertTrue(in_array("unloadResponse", $responses));
     $this->assertTrue(in_array("balanceInquiryResponse", $responses));
 }