Shipping to the Insurance Company

Asked

Viewed 125 times

2

a help with Pag Seguro

I created an account on Pag Seguro do UOL to the website.

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 time out error.

Is there a mistake?

Something is missing?

I know you can send via cUrl. But understand that in this way the Customer of the site will have to enter his data in the very site of the store and not in the site of Pague Seguro which may generate distrust.

  • value="[email protected]" this has to be the email of your account in the pagseguro neh

  • this. Only here I posted different data. The question here is whether any field or assignment is missing in the wrong way.

  • The pagseguro is right, but why not use an ajax code they have? I’ll post it here for you

  • Good. Could use Curl and Ajax or Jquery. But then the client would not be redirected to the Secure Page. Or serea?

  • Hmm, this one of mine has to have a pay token, it’s a catalog of products you’re making or just an online purchase?

  • But send the token already in the first request? what is the name of the input? Because in this form I am not sending the token!

  • Online Store I am developing!

Show 3 more comments

1 answer

0

Download the Pagseguro Library and point your action from your form to this script I posted below, put your key, and seven variables as you like. I just tested with your form and 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();
  • How to set the action for a class? Anyway? action="Createpaymentrequestphp"?

  • no. just putting the file name with this action="above.php file script"

  • Gave in the same Createpaymentrequest.php or.php file. No? Createpaymentrequest.php contains this code. But I will be sending data via post to a class without the call to methods. What I don’t understand.

  • Sorry.. in 1°comment you put together php and thought you wanted to call the function over there

  • Yes. Voce can send the data via POST/GET without calling the function it will already work.

  • That’s where the problem lies: it didn’t work!

  • What mistake are you making there?

  • Now I arrived at their page. Failed to send Pagseguro email.

  • Now I have another question: In the case of shipping the freight value, how do you do? Do you calculate the freight on the site itself and display to the customer or send measurements of each product to the paysure itself calculate the freight? The doubt is because to calculate the freight of each product (item) separately, the mail api will also consider a box for each item of the cart! Does it have way to send the total amount of freight of the whole order instead of sending item by item?

  • Carlos I here do not use insurance pay for sales of products and yes for service so do not use freight, but the right would calculate on the site before shipping, I think.

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.