public static function printResult(PagSeguroTransactionSearchResult $result, $initialDate, $finalDate)
 {
     $transactions = $result->getTransactions();
     if (is_array($transactions) && count($transactions) > 0) {
         foreach ($transactions as $key => $transactionSummary) {
             return $transactionSummary;
         }
     }
 }
 public static function printResult(PagSeguroTransactionSearchResult $result, $initialDate, $finalDate)
 {
     $finalDate = $finalDate ? $finalDate : 'now';
     echo "<h2>Search transactions by date</h2>";
     echo "<h3>{$initialDate} to {$finalDate}</h3>";
     $transactions = $result->getTransactions();
     if (is_array($transactions) && count($transactions) > 0) {
         foreach ($transactions as $key => $transactionSummary) {
             echo "Code: " . $transactionSummary->getCode() . "<br>";
             echo "Reference: " . $transactionSummary->getReference() . "<br>";
             echo "amount: " . $transactionSummary->getGrossAmount() . "<br>";
             echo "<hr>";
         }
     }
 }
 /**
  * @param $str_xml
  * @return PagSeguroTransactionSearchResult
  */
 public static function readSearchResult($str_xml)
 {
     $parser = new PagSeguroXmlParser($str_xml);
     $data = $parser->getResult('transactionSearchResult');
     $searchResutlt = new PagSeguroTransactionSearchResult();
     if (isset($data['totalPages'])) {
         $searchResutlt->setTotalPages($data['totalPages']);
     }
     if (isset($data['date'])) {
         $searchResutlt->setDate($data['date']);
     }
     if (isset($data['resultsInThisPage'])) {
         $searchResutlt->setResultsInThisPage($data['resultsInThisPage']);
     }
     if (isset($data['currentPage'])) {
         $searchResutlt->setCurrentPage($data['currentPage']);
     }
     if (isset($data['transactions']) && is_array($data['transactions'])) {
         $transactions = array();
         if (isset($data['transactions']['transaction'][0])) {
             $i = 0;
             foreach ($data['transactions']['transaction'] as $key => $value) {
                 $transactions[$i++] = self::parseTransactionSummary($value);
             }
         } else {
             $transactions[0] = self::parseTransactionSummary($data['transactions']['transaction']);
         }
         $searchResutlt->setTransactions($transactions);
     }
     return $searchResutlt;
 }
Пример #4
0
 public static function printResult(PagSeguroTransactionSearchResult $result, $initialDate, $finalDate)
 {
     $finalDate = $finalDate ? $finalDate : 'now';
     echo "<h2>Search transactions by date</h2>";
     echo "<h3>{$initialDate} to {$finalDate}</h3>";
     $transactions = $result->getTransactions();
     $inseridas = 0;
     if (is_array($transactions) && count($transactions) > 0) {
         foreach ($transactions as $key => $transactionSummary) {
             if (Order::existsInDatabase($transactionSummary->getCode(), "orders")) {
                 $id_order = $transactionSummary->getReference();
                 $id_transaction = $transactionSummary->getCode();
                 if (!Db::getInstance()->getValue("SELECT `id_pagseguro_order` FROM `" . _DB_PREFIX_ . "pagseguro_order` WHERE\n\t\t\t\t\t`id_order` = '{$id_order}' AND `id_transaction` = '{$id_transaction}' ")) {
                     Db::getInstance()->Execute("INSERT INTO `" . _DB_PREFIX_ . "pagseguro_order` \n\t\t\t\t\t\t(`id_pagseguro_order`, `id_order`, `id_transaction` )\n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t(NULL, '{$id_order}', '{$id_transaction}');");
                     $inseridas++;
                 }
             }
         }
     }
     echo count($transactions) . " Transação(ões) encontradas. <br />";
     echo $inseridas . " Transação(ões) atualizadas. <br />";
 }
 private function montarDetalhesTransacoesAbandonadas(PagSeguroTransactionSearchResult $result)
 {
     $dadosTransacao = array();
     foreach ($result->getTransactions() as $transacoes) {
         $dadosTransacao[] = array('idTransacao' => $transacoes->getCode(), 'referencia' => $transacoes->getReference(), 'valorTotal' => $transacoes->getGrossAmount(), 'desconto' => $transacoes->getDiscountAmount(), 'valorExtra' => $transacoes->getExtraAmount(), 'dataIso' => $transacoes->getDate(), 'dataPtBR' => date('d/m/Y H:i:s', strtotime($transacoes->getDate())), 'ultimaTentativaIso' => $transacoes->getLastEventDate(), 'ultimaTentativaPtBR' => date('d/m/Y H:i:s', strtotime($transacoes->getLastEventDate())));
     }
     return $dadosTransacao;
 }
 private function pushTransactionSummary(array &$transactionList, PagSeguroTransactionSearchResult $search)
 {
     $transactions = $search->getTransactions();
     foreach ($transactions as $transaction) {
         array_push($transactionList, $transaction);
     }
 }