Receber webhook de pagamento
curl --request POST \
--url https://api.example.com/v1/payments/{paymentId}/webhook \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.example.com/v1/payments/{paymentId}/webhook"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.example.com/v1/payments/{paymentId}/webhook', 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://api.example.com/v1/payments/{paymentId}/webhook",
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 <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/payments/{paymentId}/webhook"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/payments/{paymentId}/webhook")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/payments/{paymentId}/webhook")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": {
"orderId": "89f02752-acc9-4a1d-84c7-cdedd61a7a6c",
"merchant": {
"title": "Pedir Gás",
"name": "Pedir Gás",
"categoryCode": "5172",
"url": "https://www.supergasbras.com.br",
"id": "4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2",
"attributes": {
"externalId": "123456"
}
},
"merchantProvider": {
"provider": {
"id": "e71f2762-e4c4-4ef6-8764-02b97f347ec4",
"name": "Getnet SEP",
"code": "getnetSep",
"type": "Gateway",
"environment": "Digital",
"resolutionKey": "<string>"
},
"name": "Getnet SEP",
"id": "13ef8495-8815-49c8-84fc-382e2cf7a441"
},
"methodResolved": {
"name": "Dinheiro",
"type": "Cash",
"environment": "Physical"
},
"amount": {
"value": 1000,
"currency": "BRL"
},
"descriptor": "SUPER",
"note": "Pagamento do pedido 123456",
"capture": {
"type": "Automatic"
},
"state": "Created",
"status": "Pending",
"method": {
"type": "Credit"
},
"operations": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "Authorization",
"amount": {
"value": 1000,
"currency": "BRL"
},
"idempotencyKey": "f8347c15-57b7-4213-9c96-00942597b72b",
"status": "Created",
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
},
"reason": {
"code": "invalidCredentials",
"message": "Credenciais inválidas"
},
"attributes": {
"externalId": "123456"
},
"createdAt": "2023-11-07T05:31:56Z",
"modifiedAt": "2023-11-07T05:31:56Z"
}
],
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
],
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer": {
"name": "João Silva",
"phoneNumber": "+5511999999999",
"id": "71ddf226-fd85-4256-b91e-c9419777e4b9",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
},
"attributes": {
"externalId": "123456"
}
},
"environment": "Digital",
"expiryAt": "2030-06-05T23:59:59-03:00",
"link": {
"url": "https://pagseguro.com.br/v2/checkout/payment.html?code=123456789",
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
}
},
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
},
"items": [
{
"name": "Botijão P13",
"description": "Botijão GLP P13",
"quantity": 3,
"price": {
"value": 1000,
"currency": "BRL"
}
}
],
"source": {
"type": "customer",
"customerId": "71ddf226-fd85-4256-b91e-c9419777e4b9"
},
"attributes": {
"externalId": "123456"
},
"createdAt": "2023-11-07T05:31:56Z",
"modifiedAt": "2023-11-07T05:31:56Z"
}
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}Payments
Receber webhook de pagamento
Recebe um webhook do pagamento e processa o evento.
POST
/
v1
/
payments
/
{paymentId}
/
webhook
Receber webhook de pagamento
curl --request POST \
--url https://api.example.com/v1/payments/{paymentId}/webhook \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.example.com/v1/payments/{paymentId}/webhook"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.example.com/v1/payments/{paymentId}/webhook', 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://api.example.com/v1/payments/{paymentId}/webhook",
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 <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/payments/{paymentId}/webhook"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/payments/{paymentId}/webhook")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/payments/{paymentId}/webhook")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": {
"orderId": "89f02752-acc9-4a1d-84c7-cdedd61a7a6c",
"merchant": {
"title": "Pedir Gás",
"name": "Pedir Gás",
"categoryCode": "5172",
"url": "https://www.supergasbras.com.br",
"id": "4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2",
"attributes": {
"externalId": "123456"
}
},
"merchantProvider": {
"provider": {
"id": "e71f2762-e4c4-4ef6-8764-02b97f347ec4",
"name": "Getnet SEP",
"code": "getnetSep",
"type": "Gateway",
"environment": "Digital",
"resolutionKey": "<string>"
},
"name": "Getnet SEP",
"id": "13ef8495-8815-49c8-84fc-382e2cf7a441"
},
"methodResolved": {
"name": "Dinheiro",
"type": "Cash",
"environment": "Physical"
},
"amount": {
"value": 1000,
"currency": "BRL"
},
"descriptor": "SUPER",
"note": "Pagamento do pedido 123456",
"capture": {
"type": "Automatic"
},
"state": "Created",
"status": "Pending",
"method": {
"type": "Credit"
},
"operations": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "Authorization",
"amount": {
"value": 1000,
"currency": "BRL"
},
"idempotencyKey": "f8347c15-57b7-4213-9c96-00942597b72b",
"status": "Created",
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
},
"reason": {
"code": "invalidCredentials",
"message": "Credenciais inválidas"
},
"attributes": {
"externalId": "123456"
},
"createdAt": "2023-11-07T05:31:56Z",
"modifiedAt": "2023-11-07T05:31:56Z"
}
],
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
],
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer": {
"name": "João Silva",
"phoneNumber": "+5511999999999",
"id": "71ddf226-fd85-4256-b91e-c9419777e4b9",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
},
"attributes": {
"externalId": "123456"
}
},
"environment": "Digital",
"expiryAt": "2030-06-05T23:59:59-03:00",
"link": {
"url": "https://pagseguro.com.br/v2/checkout/payment.html?code=123456789",
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
}
},
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
},
"items": [
{
"name": "Botijão P13",
"description": "Botijão GLP P13",
"quantity": 3,
"price": {
"value": 1000,
"currency": "BRL"
}
}
],
"source": {
"type": "customer",
"customerId": "71ddf226-fd85-4256-b91e-c9419777e4b9"
},
"attributes": {
"externalId": "123456"
},
"createdAt": "2023-11-07T05:31:56Z",
"modifiedAt": "2023-11-07T05:31:56Z"
}
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}Esta página foi útil?
⌘I