_constructXml("getSettledBatchListRequest"); ($includeStatistics ? $this->_xml->addChild("includeStatistics", $includeStatistics) : null); ($firstSettlementDate ? $this->_xml->addChild("firstSettlementDate", $firstSettlementDate . $utc) : null); ($lastSettlementDate ? $this->_xml->addChild("lastSettlementDate", $lastSettlementDate . $utc) : null); return $this->_sendRequest(); } /** * Return all settled batches for a certain month. * * @param int $month * @param int $year * * @return AuthorizeNetTD_Response */ public function getSettledBatchListForMonth($month = false, $year = false) { $month = ($month ? $month : date('m')); $year = ($year ? $year : date('Y')); $firstSettlementDate = substr(date('c',mktime(0, 0, 0, $month, 1, $year)),0,-6); $lastSettlementDate = substr(date('c',mktime(0, 0, 0, $month+1, 0, $year)),0,-6); return $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate); } /** * This function returns limited transaction details for a specified batch ID * * @param int $batchId * * @return AuthorizeNetTD_Response */ public function getTransactionList($batchId) { $this->_constructXml("getTransactionListRequest"); $this->_xml->addChild("batchId", $batchId); return $this->_sendRequest(); } /** * Return all transactions for a certain day. * * @param int $month * @param int $day * @param int $year * * @return array Array of SimpleXMLElments */ public function getTransactionsForDay($month = false, $day = false, $year = false) { $transactions = array(); $month = ($month ? $month : date('m')); $day = ($day ? $day : date('d')); $year = ($year ? $year : date('Y')); $firstSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6); $lastSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6); $response = $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate); $batches = $response->xpath("batchList/batch"); foreach ($batches as $batch) { $batch_id = (string)$batch->batchId; $request = new AuthorizeNetTD; $tran_list = $request->getTransactionList($batch_id); $transactions = array_merge($transactions, $tran_list->xpath("transactions/transaction")); } return $transactions; } /** * This function returns full transaction details for a specified transaction ID. * * @param int $transId * * @return AuthorizeNetTD_Response */ public function getTransactionDetails($transId) { $this->_constructXml("getTransactionDetailsRequest"); $this->_xml->addChild("transId", $transId); return $this->_sendRequest(); } /** * This function returns statistics about the settled batch specified by $batchId. * * @param int $batchId * * @return AuthorizeNetTD_Response */ public function getBatchStatistics($batchId) { $this->_constructXml("getBatchStatisticsRequest"); $this->_xml->addChild("batchId", $batchId); return $this->_sendRequest(); } /** * This function returns the last 1000 unsettled transactions. * * * @return AuthorizeNetTD_Response */ public function getUnsettledTransactionList() { $this->_constructXml("getUnsettledTransactionListRequest"); return $this->_sendRequest(); } /** * @return string */ protected function _getPostUrl() { return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL); } /** * * * @param string $response * * @return AuthorizeNetTransactionDetails_Response */ protected function _handleResponse($response) { return new AuthorizeNetTD_Response($response); } /** * Prepare the XML post string. */ protected function _setPostString() { $this->_post_string = $this->_xml->asXML(); } /** * Start the SimpleXMLElement that will be posted. * * @param string $request_type The action to be performed. */ private function _constructXml($request_type) { $string = '<'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">'; $this->_xml = @new SimpleXMLElement($string); $merchant = $this->_xml->addChild('merchantAuthentication'); $merchant->addChild('name',$this->_api_login); $merchant->addChild('transactionKey',$this->_transaction_key); } } /** * A class to parse a response from the Transaction Details XML API. * * @package AuthorizeNet * @subpackage AuthorizeNetTD */ class AuthorizeNetTD_Response extends AuthorizeNetXMLResponse { }