0
I have a problem with the Secure Pag API in the /pre-approvals method it always returns to me that parameters are missing but I am sending yes the parameters that the documentation asks for. I followed the documentation step by step and still nothing.
$data['plan'] = 'CEC9F172-DDDD-DACD-D408-EF866A920B11';
$data['sender.name'] = $dados['nome'];
$data['sender.email'] = $dados['email'];
$data['sender.hash'] = $dados['hash_comprador'];
$data['sender.phone.number'] = str_replace("-", "", substr($dados["telefone"], 5));
$data['senderPhone'] = str_replace("-", "", substr($dados["telefone"], 5));
$data['sender.phone.areaCode'] = substr($dados["telefone"], 1, 2);
$data['senderAreaCode'] = (int) substr($dados["telefone"], 1, 2);
$data['sender.address.street'] = $dados['rua'];
$data['sender.address.number'] = $dados['numero'];
// $data['senderAddressComplement'] = $dados['nome'];
$data['sender.address.district'] = $dados['bairro'];
$data['sender.address.city'] = $dados['cidade'];
$data['sender.address.state'] = $dados['uf'];
$data['sender.address.country'] = 'BRA';
$data['sender.address.postalCode'] = str_replace("-", "", $dados["cep"]);
// $data['senderDocumentsType'] = $dados['nome'];
// $data['senderDocumentsValue'] = $dados['nome'];
$data['paymentMethod.type'] = 'creditCard';
$data['paymentMethod.creditCard.token'] = $dados['card_token'];
$data['paymentMethod.creditCard.holder.name'] = $dados['nome'];
$data['paymentMethod.creditCard.holder.birthDate'] = $dados['nascimento'];
$data = http_build_query($data);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-type: application/x-www-form-urlencoded;charset=ISO-8859-1',
'Accept: application/vnd.pagseguro.com.br.v3+xml;charset=ISO-8859-1'
));
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$xml = curl_exec($curl);
In the code above, I recover the sending data from the form, the documentation is very confusing I found some with sending this way 'senderPhone' and others with sending this way 'Sender.phone.number', I am sending the e-mail and token, I am already managing to make single payment via billet and card, but the recurring payment always returns me errors like:
In my HTML form I am sending all the required information, I will debug the code and I am actually sending everything:
Please, if you’re confused, I’m sorry, but I’m desperate!
I suggest you take a look at Pagseguro-PHP-SDK, provided by Pagseguro on the link https://github.com/pagseguro/pagseguro-php-sdk. They provide a complete sdk for integration, I think it helps a lot in integration.
– Celso Marigo Jr