I have a problem with the Secure Pag API in the / pre-approvals method it always returns me missing parameters but I am sending the parameters that the documentation asks for. I followed the step by step documentation 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 retrieve the data sent from the form, the documentation is very confusing I found some with the sending of this form 'senderPhone' and others with the sending of this form 'sender.phone.number', I am sending the email and token, I am already able to make single payment via ticket and card, but recurring payment always returns me errors like:
InmyHTMLformI'msendingalltherequiredinformation,I'vedebuggedthecodeandI'mactuallysendingeverything:
Please, if you're confused, please excuse me, but I'm desperate!