コード例 #1
0
 public function retorno()
 {
     require_once DIR_APPLICATION . 'model' . DIRECTORY_SEPARATOR . 'payment' . DIRECTORY_SEPARATOR . 'cobredireto' . DIRECTORY_SEPARATOR . 'pagamento.php';
     $order = new Retorno();
     $order->campainha();
     $order->probe();
 }
コード例 #2
0
 public function postRetorno()
 {
     $input = Input::all();
     if ($input) {
         $retorno = new Retorno();
         $retorno->serialize = serialize($input);
         $retorno->save();
     }
 }
コード例 #3
0
 /**
  * verifica
  *
  * Verifica o tipo de conexão aberta e envia os dados vindos
  * do post
  *
  * @access public
  *
  * @use RetornoPagSeguro::_tipoenvio()
  * @global string $_retPagSeguroErrNo   Numero de erro do pagseguro
  * @global string $_retPagSeguroErrStr  Texto descritivo do erro do pagseguro
  * @param array $post         Array contendo os posts do pagseguro
  * @param bool $tipoEnvio     (opcional) Verifica o tipo de envio do post
  * @return bool
  */
 function verifica($post, $tipoEnvio = false)
 {
     global $_retPagSeguroErrNo, $_retPagSeguroErrStr;
     if ('array' !== gettype($tipoEnvio)) {
         $tipoEnvio = RetornoPagSeguro::_tipoEnvio();
     }
     $spost = RetornoPagSeguro::_preparaDados($post);
     if (!in_array($tipoEnvio[0], array('curl', 'fsocket'))) {
         return false;
     }
     $confirma = false;
     if ($tipoEnvio[0] === 'curl') {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $tipoEnvio[1]);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $spost);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_HEADER, false);
         curl_setopt($ch, CURLOPT_TIMEOUT, 30);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
         $resp = curl_exec($ch);
         if (!RetornoPagSeguro::not_null($resp)) {
             curl_setopt($ch, CURLOPT_URL, $tipoEnvio[1]);
             $resp = curl_exec($ch);
         }
         curl_close($ch);
         $confirma = strcmp($resp, 'VERIFICADO') == 0;
     } elseif ($tipoEnvio[0] === 'fsocket') {
         if (!$tipoEnvio[2]) {
             die("{$_retPagSeguroErrStr} ({$_retPagSeguroErrNo})");
         } else {
             $cabecalho = "POST {$tipoEnvio[1]} HTTP/1.0\r\n";
             $cabecalho .= "Content-Type: application/x-www-form-urlencoded\r\n";
             $cabecalho .= "Content-Length: " . strlen($spost) . "\r\n\r\n";
             $resp = '';
             fwrite($tipoEnvio[2], "{$cabecalho}{$spost}");
             while (!feof($tipoEnvio[2])) {
                 $resp = fgets($tipoEnvio[2], 1024);
                 if (strcmp($resp, 'VERIFICADO') == 0) {
                     $confirma = strcmp($resp, 'VERIFICADO') == 0;
                     $confirma = true;
                     break;
                 }
             }
             fclose($tipoEnvio[2]);
         }
     }
     if ($confirma && method_exists('Retorno', 'retorno_automatico')) {
         $itens = array('VendedorEmail', 'TransacaoID', 'Referencia', 'TipoFrete', 'ValorFrete', 'Anotacao', 'DataTransacao', 'TipoPagamento', 'StatusTransacao', 'CliNome', 'CliEmail', 'CliEndereco', 'CliNumero', 'CliComplemento', 'CliBairro', 'CliCidade', 'CliEstado', 'CliCEP', 'CliTelefone', 'NumItens');
         foreach ($itens as $item) {
             if (!isset($post[$item])) {
                 $post[$item] = '';
             }
             if ($item == 'ValorFrete') {
                 $post[$item] = str_replace(',', '.', $post[$item]);
             }
         }
         $produtos = array();
         for ($i = 1; isset($post["ProdID_{$i}"]); $i++) {
             $produtos[] = array('ProdID' => $post["ProdID_{$i}"], 'ProdDescricao' => $post["ProdDescricao_{$i}"], 'ProdValor' => (double) str_replace(',', '.', $post["ProdValor_{$i}"]), 'ProdQuantidade' => $post["ProdQuantidade_{$i}"], 'ProdFrete' => (double) str_replace(',', '.', $post["ProdFrete_{$i}"]), 'ProdExtras' => (double) str_replace(',', '.', $post["ProdExtras_{$i}"]));
         }
         Retorno::retorno_automatico($post['VendedorEmail'], $post['TransacaoID'], $post['Referencia'], $post['TipoFrete'], $post['ValorFrete'], $post['Anotacao'], $post['DataTransacao'], $post['TipoPagamento'], $post['StatusTransacao'], $post['CliNome'], $post['CliEmail'], $post['CliEndereco'], $post['CliNumero'], $post['CliComplemento'], $post['CliBairro'], $post['CliCidade'], $post['CliEstado'], $post['CliCEP'], $post['CliTelefone'], $produtos, $post['NumItens']);
     }
     return $confirma;
 }