Reembolsar Transação
curl --request POST \
--url https://garu.com.br/api/transactions/{id}/refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 123,
"reason": "<string>"
}
'import requests
url = "https://garu.com.br/api/transactions/{id}/refund"
payload = {
"amount": 123,
"reason": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount: 123, reason: '<string>'})
};
fetch('https://garu.com.br/api/transactions/{id}/refund', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://garu.com.br/api/transactions/{id}/refund",
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([
'amount' => 123,
'reason' => '<string>'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://garu.com.br/api/transactions/{id}/refund"
payload := strings.NewReader("{\n \"amount\": 123,\n \"reason\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://garu.com.br/api/transactions/{id}/refund")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 123,\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/transactions/{id}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 123,\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"status": "<string>",
"value": 123,
"refundedAmount": 123
}Transações
Reembolsar Transação
Emita reembolsos totais ou parciais para transações pagas
POST
/
api
/
transactions
/
{id}
/
refund
Reembolsar Transação
curl --request POST \
--url https://garu.com.br/api/transactions/{id}/refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 123,
"reason": "<string>"
}
'import requests
url = "https://garu.com.br/api/transactions/{id}/refund"
payload = {
"amount": 123,
"reason": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount: 123, reason: '<string>'})
};
fetch('https://garu.com.br/api/transactions/{id}/refund', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://garu.com.br/api/transactions/{id}/refund",
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([
'amount' => 123,
'reason' => '<string>'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://garu.com.br/api/transactions/{id}/refund"
payload := strings.NewReader("{\n \"amount\": 123,\n \"reason\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://garu.com.br/api/transactions/{id}/refund")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 123,\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/transactions/{id}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 123,\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"status": "<string>",
"value": 123,
"refundedAmount": 123
}Visão Geral
Emita um reembolso total ou parcial para uma transação que já foi paga. O valor será devolvido ao cliente através do mesmo método de pagamento utilizado na compra.Exemplo de Requisição
Reembolso Total
curl -X POST https://garu.com.br/api/transactions/12345/refund \
-H "Authorization: Bearer sk_test_sua_chave_api" \
-H "Content-Type: application/json" \
-d '{
"reason": "Cliente solicitou reembolso"
}'
const response = await fetch(
'https://garu.com.br/api/transactions/12345/refund',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.GARU_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
reason: 'Cliente solicitou reembolso'
})
}
);
const result = await response.json();
console.log(`Status: ${result.status}`); // "reversed"
import requests
import os
url = "https://garu.com.br/api/transactions/12345/refund"
headers = {
"Authorization": f"Bearer {os.environ['GARU_API_KEY']}",
"Content-Type": "application/json"
}
payload = {
"reason": "Cliente solicitou reembolso"
}
response = requests.post(url, json=payload, headers=headers)
result = response.json()
print(f"Status: {result['status']}") # "reversed"
Reembolso Parcial
curl -X POST https://garu.com.br/api/transactions/12345/refund \
-H "Authorization: Bearer sk_test_sua_chave_api" \
-H "Content-Type: application/json" \
-d '{
"amount": 100.00,
"reason": "Desconto por insatisfação parcial"
}'
const response = await fetch(
'https://garu.com.br/api/transactions/12345/refund',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.GARU_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
amount: 100.00,
reason: 'Desconto por insatisfação parcial'
})
}
);
const result = await response.json();
console.log(`Valor reembolsado: R$ ${result.refundedAmount}`);
import requests
import os
url = "https://garu.com.br/api/transactions/12345/refund"
headers = {
"Authorization": f"Bearer {os.environ['GARU_API_KEY']}",
"Content-Type": "application/json"
}
payload = {
"amount": 100.00,
"reason": "Desconto por insatisfação parcial"
}
response = requests.post(url, json=payload, headers=headers)
result = response.json()
print(f"Valor reembolsado: R$ {result['refundedAmount']}")
Parâmetros
number
Valor do reembolso em Reais. Se não especificado, o valor total da transação será reembolsado.
string
Motivo do reembolso (opcional, para registro interno).
Resposta de Sucesso (200 OK)
{
"id": 12345,
"status": "reversed",
"value": 297.00,
"refundedAmount": 100.00
}
number
ID da transação reembolsada.
string
Novo status da transação (
reversed).number
Valor original da transação.
number
Valor que foi reembolsado.
Considerações
Reembolsos podem levar alguns dias úteis para serem processados pelo gateway de pagamento e aparecerem na conta do cliente.
- Apenas transações com status
captured,payedBoletooupayedPixpodem ser reembolsadas - Reembolsos parciais podem ser feitos múltiplas vezes até atingir o valor total
- O valor do reembolso não pode exceder o valor original da transação
Erros Comuns
400 - Valor excede o disponível
400 - Valor excede o disponível
{
"statusCode": 400,
"message": "Refund amount exceeds transaction value"
}
400 - Transação não pode ser reembolsada
400 - Transação não pode ser reembolsada
{
"statusCode": 400,
"message": "Transaction cannot be refunded"
}
Próximos Passos
Cancelar Transação
Cancele transações pendentes
Webhooks
Receba notificações de reembolso
Was this page helpful?