Safe Submission

2

help with Pag Seguro

I created an account at Pag Seguro do UOL for the site.

I have the form below

    <form method="post" target="pagseguro" 
action="https://www.pagseguro.uol.com.br/v2/checkout/payment.html">

      <!-- Campos obrigatórios -->
      <input name="receiverEmail" type="hidden" value="[email protected]">
      <input name="currency" type="hidden" value="BRL">

      <!-- Itens do pagamento (ao menos um item é obrigatório) -->
      <input type="hidden" name="itemId1" value="70">
      <input type="hidden" name="itemDescription1" value="Publica">
      <input type="hidden" name="itemAmount1" value="55.77">
      <input type="hidden" name="itemQuantity1" value="1">
      <!-- Itens do pagamento (ao menos um item é obrigatório) --> 

      <!-- Código de referência do pagamento no seu sistema (opcional) -->
      <input name="reference" type="hidden" value="42">

      <!-- Informações de frete (opcionais) -->
      <input name="shippingType" type="hidden" value="1">
      <input name="shippingAddressPostalCode" type="hidden" value="36880000">
      <input name="shippingAddressStreet" type="hidden" value="Rua JB">
      <input name="shippingAddressNumber" type="hidden" value="0">
      <input name="shippingAddressComplement" type="hidden" value="Lote 06">
      <input name="shippingAddressDistrict" type="hidden" value="São Francisco">
      <input name="shippingAddressCity" type="hidden" value="Muriaé">
      <input name="shippingAddressState" type="hidden" value="MG">
      <input name="shippingAddressCountry" type="hidden" value="BRA">

      <!-- Dados do comprador (opcionais) -->
      <input name="senderName" type="hidden" value="Carlos Rocha">
      <input name="senderAreaCode" type="hidden" value="32">
      <input name="senderPhone" type="hidden" value="22222222">
      <input name="senderEmail" type="hidden" value="[email protected]">

      <!-- submit do form (obrigatório) -->
      <input class="formularios" type="image" name="submit" src="https://p.simg.uol.com.br/out/pagseguro/i/botoes/pagamentos/120x53-pagar.gif"alt="Pague com PagSeguro">
    </form>

When I submit the form, it gives timeout error.

Are there any errors?

Is anything missing?

I know you can send via cUrl . But you understand that in this way the Website Client will have to enter their data on the store's own site and not on the Pague Seguro website, which may generate mistrust.

    
asked by anonymous 21.05.2016 / 14:44

1 answer

0

Download the Pagseguro Library and point your action from your form to this script that I posted below, put your key, and your seven variables as you like. I just tested with your form and it ran perfectly

<?php 
 require_once "../pagseguro/ps/PagSeguroLibrary/PagSeguroLibrary.php";
 class CreatePaymentRequest 
 {
 public static function main()
 {

 $id_finan1 = 200;

 $nome = $_POST['senderName'];
 define("NOMER", $nome);
 $email = $_POST['senderEmail'];
 define("EMAIL", $email);
 $cpf = $_POST['rg'];
 define("CPF", $cpf);
 $tel1 = $_POST['senderPhone'];
 define("TEL1", $tel1);
 $cep = $_POST['cep'];
 define("CEP", $cep);
 $rua = $_POST['valor'];
 $rua = $_POST['endereco'];
 $num = $_POST['num'];
 $cmple = $_POST['cmple'];
 $cidade = $_POST['cidade'];
 $estado = $_POST['uf'];
 $pais = 'BRA';
 $ddd = $_POST['senderAreaCode'];
 define("DDD", $ddd);
 $des = 'ola';

    $paymentRequest = new PagSeguroPaymentRequest();
    $paymentRequest->setCurrency("BRL");  
    $paymentRequest->addItem('12', 'Seu nome', 1, 20.00);
    $paymentRequest->setReference($id_finan1);
    $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX');
    $paymentRequest->setShippingType($sedexCode);

    $nomee = NOMER;    $email = EMAIL;   $cpf = CPF;
    $tel1 = TEL1;      $cep = CEP;     
    $num = NUM;        $cmple = CMPLE; $ddd = DDD;  

     $des->description;
       $paymentRequest->setShippingAddress(
        $cep,
        $rua,
        $num,
        $id_solicitante,
        $bairro,
        $cidade,
        $estado,
        'BRA'
    );
        $nomer = $nomee;  
        $cpfr = $cpf; 
        $emailr = $email; 

        $paymentRequest->setSender(
        $nomer,
        $emailr,
        $ddd,
        $tel1,
        $cpfr,
        $cpfr
    );

    try {
  $credentials = new PagSeguroAccountCredentials("[email protected]","sua   chave");
        $url = $paymentRequest->register($credentials);
        self::printPaymentUrl($url);
    } catch (PagSeguroServiceException $e) {
        die($e->getMessage());
    }
   }
   public static function printPaymentUrl($url)
   { 
    if ($url) {
        echo "<h2>Criando requisi&ccedil;&atilde;o de pagamento</h2>";
        echo "<p>URL do pagamento: <strong>$url</strong></p>";
        echo "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL=$url'>";
        //echo "<p><a title=\"URL do pagamento\" href=\"$url\">Ir para URL do pagamento.</a></p>";
    }
   } 
  }
   CreatePaymentRequest::main();
    
22.05.2016 / 05:22