public function test_PFIF_instruction_txn()
 {
     $request = new LitleRequest($this->config);
     // first batch
     $batch_request = new BatchRequest($this->direct);
     $submerchantCreditHash = array('id' => '1211', 'fundingSubmerchantId' => '2111', 'submerchantName' => '001', 'fundsTransferId' => '12345678', 'amount' => '13', 'accountInfo' => array('accType' => 'Checking', 'accNum' => '1092969901', 'routingNum' => '011075150', 'checkNum' => '123455'));
     $batch_request->addSubmerchantCredit($submerchantCreditHash);
     $payFacCreditHash = array('id' => '1211', 'fundingSubmerchantId' => '2111', 'fundsTransferId' => '12345678', 'amount' => '13');
     $batch_request->addPayFacCredit($payFacCreditHash);
     $vendorCreditHash = array('id' => '1211', 'fundingSubmerchantId' => '2111', 'vendorName' => '001', 'fundsTransferId' => '12345678', 'amount' => '13', 'accountInfo' => array('accType' => 'Checking', 'accNum' => '1092969901', 'routingNum' => '011075150', 'checkNum' => '123455'));
     $batch_request->addVendorCredit($vendorCreditHash);
     $reserveCreditHash = array('id' => '1211', 'fundingSubmerchantId' => '2111', 'fundsTransferId' => '12345678', 'amount' => '13');
     $batch_request->addReserveCredit($reserveCreditHash);
     $physicalCheckCreditHash = array('id' => '1211', 'fundingSubmerchantId' => '2111', 'fundsTransferId' => '12345678', 'amount' => '13');
     $batch_request->addPhysicalCheckCredit($physicalCheckCreditHash);
     $submerchantDebitHash = array('id' => '1211', 'fundingSubmerchantId' => '2111', 'submerchantName' => '001', 'fundsTransferId' => '12345678', 'amount' => '13', 'accountInfo' => array('accType' => 'Checking', 'accNum' => '1092969901', 'routingNum' => '011075150', 'checkNum' => '123455'));
     $batch_request->addSubmerchantDebit($submerchantDebitHash);
     $payFacDebitHash = array('id' => '1211', 'fundingSubmerchantId' => '2111', 'fundsTransferId' => '12345678', 'amount' => '13');
     $batch_request->addPayFacDebit($payFacDebitHash);
     $vendorDebitHash = array('id' => '1211', 'fundingSubmerchantId' => '2111', 'vendorName' => '001', 'fundsTransferId' => '12345678', 'amount' => '13', 'accountInfo' => array('accType' => 'Checking', 'accNum' => '1092969901', 'routingNum' => '011075150', 'checkNum' => '123455'));
     $batch_request->addVendorDebit($vendorDebitHash);
     $reserveDebitHash = array('id' => '1211', 'fundingSubmerchantId' => '2111', 'fundsTransferId' => '12345678', 'amount' => '13');
     $batch_request->addReserveDebit($reserveDebitHash);
     $physicalCheckDebitHash = array('id' => '1211', 'fundingSubmerchantId' => '2111', 'fundsTransferId' => '12345678', 'amount' => '13');
     $batch_request->addPhysicalCheckDebit($physicalCheckDebitHash);
     $request->addBatchRequest($batch_request);
     $response = $request->sendToLitleStream();
     $respProcessor = new LitleResponseProcessor($response);
     $txnResponse = $respProcessor->nextTransaction();
     $txnCount = 0;
     while ($txnResponse != FALSE) {
         $this->assertEquals($txnResponse->response, '000');
         $txnCount++;
         $txnResponse = $respProcessor->nextTransaction();
     }
     $this->assertEquals($txnCount, 10);
 }
 public function test_sendToLitleStream()
 {
     $request = new LitleRequest($this->config);
     $batch = new BatchRequest($this->direct);
     $sale_hash = array('orderId' => '1864', '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' => '4457010000000009', 'expDate' => '0112', 'cardValidationNum' => '349', 'type' => 'VI'), 'reportGroup' => 'Planets');
     $batch->addSale($sale_hash);
     $request->addBatchRequest($batch);
     $response = $request->sendToLitleStream();
     $this->assertTrue(file_exists($response));
     $this->assertEquals($response, $request->response_file);
     $proc = new LitleResponseProcessor($response);
     $resp = $proc->nextTransaction();
     $this->assertEquals('saleResponse', $resp->getName());
     $this->assertEquals('Planets', $resp->attributes()->reportGroup);
     $this->assertEquals('1864', $resp->orderId);
 }
 public function test_processMecha()
 {
     $request = new LitleRequest($this->config);
     # first batch
     $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);
     $request->addBatchRequest($batch);
     # second batch
     $batch = new BatchRequest($this->direct);
     $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);
     $request->addBatchRequest($batch);
     # third batch
     $batch = new BatchRequest($this->direct);
     $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);
     $request->addBatchRequest($batch);
     # fourth batch
     $batch = new BatchRequest($this->direct);
     $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);
     $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('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('orderId' => '1', 'amount' => '2', 'orderSource' => 'ecommerce', 'card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'));
     $batch->addActivate($hash_in);
     $hash_in = array('orderId' => '1', 'orderSource' => 'ecommerce', 'card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'));
     $batch->addDeactivate($hash_in);
     $hash_in = array('orderId' => '1', 'amount' => '2', 'orderSource' => 'ecommerce', 'card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'));
     $batch->addLoad($hash_in);
     $hash_in = array('orderId' => '1', 'amount' => '2', 'orderSource' => 'ecommerce', 'card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'));
     $batch->addUnload($hash_in);
     $hash_in = array('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));
 }