Criar um endpoint de webhook
curl --request POST \
--url https://api.valorapayments.com.br/v1/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://sualoja.com/webhooks/valora",
"events": [
"payment.succeeded",
"payment.failed"
],
"description": "Loja principal"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://sualoja.com/webhooks/valora',
events: ['payment.succeeded', 'payment.failed'],
description: 'Loja principal'
})
};
fetch('https://api.valorapayments.com.br/v1/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.valorapayments.com.br/v1/webhooks"
payload = {
"url": "https://sualoja.com/webhooks/valora",
"events": ["payment.succeeded", "payment.failed"],
"description": "Loja principal"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.valorapayments.com.br/v1/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://sualoja.com/webhooks/valora',
'events' => [
'payment.succeeded',
'payment.failed'
],
'description' => 'Loja principal'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "we_Xk2v9QeR7tLmN3bA",
"object": "webhook_endpoint",
"url": "<string>",
"description": "<string>",
"events": [
"payment.succeeded"
],
"status": "active",
"created_at": "2023-11-07T05:31:56Z",
"secret": "whsec_..."
}{
"error": {
"type": "invalid_api_key",
"message": "Chave de API inválida ou revogada."
}
}{
"error": {
"type": "missing_scope",
"message": "A chave não tem o escopo necessário."
}
}{
"error": {
"type": "limit_reached",
"message": "Limite de 10 endpoints atingido."
}
}{
"error": {
"type": "invalid_url",
"message": "A URL deve usar https."
}
}{
"error": {
"type": "rate_limited",
"message": "Muitas requisições. Tente novamente em instantes."
}
}{
"error": {
"type": "service_unavailable",
"message": "Serviço temporariamente indisponível."
}
}Webhooks
Criar um endpoint de webhook
Cadastra uma URL para receber eventos. O secret aparece só nesta resposta. Limite: 10 endpoints ativos.
Escopo: webhooks:write.
POST
/
v1
/
webhooks
Criar um endpoint de webhook
curl --request POST \
--url https://api.valorapayments.com.br/v1/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://sualoja.com/webhooks/valora",
"events": [
"payment.succeeded",
"payment.failed"
],
"description": "Loja principal"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://sualoja.com/webhooks/valora',
events: ['payment.succeeded', 'payment.failed'],
description: 'Loja principal'
})
};
fetch('https://api.valorapayments.com.br/v1/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.valorapayments.com.br/v1/webhooks"
payload = {
"url": "https://sualoja.com/webhooks/valora",
"events": ["payment.succeeded", "payment.failed"],
"description": "Loja principal"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.valorapayments.com.br/v1/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://sualoja.com/webhooks/valora',
'events' => [
'payment.succeeded',
'payment.failed'
],
'description' => 'Loja principal'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "we_Xk2v9QeR7tLmN3bA",
"object": "webhook_endpoint",
"url": "<string>",
"description": "<string>",
"events": [
"payment.succeeded"
],
"status": "active",
"created_at": "2023-11-07T05:31:56Z",
"secret": "whsec_..."
}{
"error": {
"type": "invalid_api_key",
"message": "Chave de API inválida ou revogada."
}
}{
"error": {
"type": "missing_scope",
"message": "A chave não tem o escopo necessário."
}
}{
"error": {
"type": "limit_reached",
"message": "Limite de 10 endpoints atingido."
}
}{
"error": {
"type": "invalid_url",
"message": "A URL deve usar https."
}
}{
"error": {
"type": "rate_limited",
"message": "Muitas requisições. Tente novamente em instantes."
}
}{
"error": {
"type": "service_unavailable",
"message": "Serviço temporariamente indisponível."
}
}Autorizações
Corpo
application/json
Resposta
Endpoint criado, com o segredo.