Comunidade

Ask a Question
Back to All

Erro ao Criar Checkout

No link https://developer.pagbank.com.br/reference/criar-checkout peguei o exemplo


$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.api.pagseguro.com/checkouts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer xxxx",
"Content-type: application/json",
"accept: /"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

Nesse código alertei para meu tokken e testei, o eguinte erro esta aprecendo : {"error_messages":[{"error":"invalid_request_body","description":"There are some syntax errors in the request payload. Please check the documentation."}]} ?>


Olhei a documentação e não vi nenhuma discrepância e acho estranho por ser exatamente o exemplo na documentação.

Quem puder me ajudar, eu agradeço desde já.

Olá Igor, peguei esse payload na documentação e deu certo por aqui. Tenta usar esse Payload:

curl --request POST
--url https://sandbox.api.pagseguro.com/checkouts
--header 'Authorization: Bearer '
--header 'Content-type: application/json'
--header 'accept: /'
--data '
{
"customer": {
"phone": {
"country": "+55",
"area": "27",
"number": "999999999"
},
"Name": "Teste 123",
"email": "joao@teste.com",
"tax_id": "12345678909"
},
"shipping": {
"address": {
"street": "Faria Lima",
"number": "1384",
"complement": "5 andar",
"locality": "Pinheiros",
"city": "São Paulo",
"region_code": "SP",
"country": "BRA",
"postal_code": "01452002"
},
"box": {
"dimensions": {
"length": 15,
"width": 10,
"height": 14
},
"weight": 300
},
"type": "FREE",
"service_type": "PAC",
"address_modifiable": true
},
"reference_id": "123",
"customer_modifiable": true,
"items": [
{
"reference_id": "REFERÊNCIA DO PRODUTO",
"name": "Nome do Produto",
"quantity": 1,
"unit_amount": 500,
"image_url": "https://www.petz.com.br/blog//wp-content/upload/2018/09/tamanho-de-cachorro-pet-1.jpg"
}
],
"payment_methods_configs": [
{
"config_options": [
{
"value": "1",
"option": "INSTALLMENTS_LIMIT"
}
],
"type": "CREDIT_CARD"
}
],
"soft_descriptor": "xxxx",
"redirect_url": "https://pagseguro.uol.com.br",
"notification_urls": [
"https://pagseguro.uol.com.br"
],
"payment_notification_urls": [
"https://pagseguro.uol.com.br"
],
"additional_amount": 0,
"discount_amount": 0,
"payment_methods": [
{
"type": "CREDIT_CARD"
},
{
"type": "PIX"
},
{
"type": "BOLETO"
},
{
"type": "DEBIT_CARD"
}
]
}
'



© 1996- Todos os direitos reservados.

PAGSEGURO INTERNET INSTITUIÇÃO DE PAGAMENTO S/A - CNPJ/MF 08.561.701/0001-01

Av. Brigadeiro Faria Lima, 1.384, São Paulo - SP - CEP 01451-001

English
Powered by Localize
Português (Brasil)