Introdução
Documentação da API Middleware para Pix da SSG
Documentação em desenvolvimento. Não siga fielmente os exemplos.
Autenticando Requests
Para autenticar requests, inclua o cabeçalho Authorization
com o valor "Bearer {ACCESS_TOKEN}"
.
Todos os endpoints protegidos com autenticação são marcados com um selo requer autenticação
na documentação abaixo.
Obtenha o token de acesso através do endpoint POST /oauth/token
Requests
Pix Status
requires authentication
Endpoint para obter o status de um pix
Exemplo de request:
curl --request POST \
"http://smartsafe.dyndns.tv:81/api/qrcode/status" \
--header "Authorization: Bearer {ACCESS_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"qrcode_id\": \"aspernatur\"
}"
const url = new URL(
"http://smartsafe.dyndns.tv:81/api/qrcode/status"
);
const headers = {
"Authorization": "Bearer {ACCESS_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"qrcode_id": "aspernatur"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'http://smartsafe.dyndns.tv:81/api/qrcode/status';
$response = $client->post(
$url,
[
'headers' => [
'Authorization' => 'Bearer {ACCESS_TOKEN}',
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'json' => [
'qrcode_id' => 'aspernatur',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'http://smartsafe.dyndns.tv:81/api/qrcode/status'
payload = {
"qrcode_id": "aspernatur"
}
headers = {
'Authorization': 'Bearer {ACCESS_TOKEN}',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
response = requests.request('POST', url, headers=headers, json=payload)
response.json()
Exemplo de response (200, Status retornado):
{
"data": {
"qrcode_id": "61e61d4a-811...",
"status": "PENDENTE"
}
}
Exemplo de response (404, Não encontrado):
{
"codigo_erro": 543235,
"mensagem": "ID não encontrado"
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Gerar QR Code
requires authentication
Endpoint para gerar um QR Code
Exemplo de request:
curl --request POST \
"http://smartsafe.dyndns.tv:81/api/generate-qrcode" \
--header "Authorization: Bearer {ACCESS_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"valor\": \"107080452L31\",
\"chave\": \"aspernatur\",
\"data_expiracao\": \"2024-06-21T16:15:59\",
\"nome_pagador\": \"cmlz\",
\"email_pagador\": \"wjsq\",
\"documento_pagador\": \"u\",
\"cep_pagador\": \"srqhlbbz\",
\"endereco_pagador\": \"qczp\",
\"cidade_pagador\": \"hgoz\",
\"uf_pagador\": \"wf\",
\"account_id\": \"06919b2b-4274-357a-84b0-4cf4de1405fb\"
}"
const url = new URL(
"http://smartsafe.dyndns.tv:81/api/generate-qrcode"
);
const headers = {
"Authorization": "Bearer {ACCESS_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"valor": "107080452L31",
"chave": "aspernatur",
"data_expiracao": "2024-06-21T16:15:59",
"nome_pagador": "cmlz",
"email_pagador": "wjsq",
"documento_pagador": "u",
"cep_pagador": "srqhlbbz",
"endereco_pagador": "qczp",
"cidade_pagador": "hgoz",
"uf_pagador": "wf",
"account_id": "06919b2b-4274-357a-84b0-4cf4de1405fb"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'http://smartsafe.dyndns.tv:81/api/generate-qrcode';
$response = $client->post(
$url,
[
'headers' => [
'Authorization' => 'Bearer {ACCESS_TOKEN}',
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'json' => [
'valor' => '107080452L31',
'chave' => 'aspernatur',
'data_expiracao' => '2024-06-21T16:15:59',
'nome_pagador' => 'cmlz',
'email_pagador' => 'wjsq',
'documento_pagador' => 'u',
'cep_pagador' => 'srqhlbbz',
'endereco_pagador' => 'qczp',
'cidade_pagador' => 'hgoz',
'uf_pagador' => 'wf',
'account_id' => '06919b2b-4274-357a-84b0-4cf4de1405fb',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'http://smartsafe.dyndns.tv:81/api/generate-qrcode'
payload = {
"valor": "107080452L31",
"chave": "aspernatur",
"data_expiracao": "2024-06-21T16:15:59",
"nome_pagador": "cmlz",
"email_pagador": "wjsq",
"documento_pagador": "u",
"cep_pagador": "srqhlbbz",
"endereco_pagador": "qczp",
"cidade_pagador": "hgoz",
"uf_pagador": "wf",
"account_id": "06919b2b-4274-357a-84b0-4cf4de1405fb"
}
headers = {
'Authorization': 'Bearer {ACCESS_TOKEN}',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
response = requests.request('POST', url, headers=headers, json=payload)
response.json()
Exemplo de response (201, QR Code gerado):
{
"data": {
"id": "61e61d4a-811...",
"qrcode": "00020126570014br.gov.bcb.pix011181..."
}
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Atualizar o status de um pix
requires authentication
Este endpoint tem sua utilização exclusiva de APIs externas
Exemplo de request:
curl --request PATCH \
"http://smartsafe.dyndns.tv:81/api/pix/aspernatur" \
--header "Authorization: Bearer {ACCESS_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"status\": \"PAGO\"
}"
const url = new URL(
"http://smartsafe.dyndns.tv:81/api/pix/aspernatur"
);
const headers = {
"Authorization": "Bearer {ACCESS_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"status": "PAGO"
};
fetch(url, {
method: "PATCH",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'http://smartsafe.dyndns.tv:81/api/pix/aspernatur';
$response = $client->patch(
$url,
[
'headers' => [
'Authorization' => 'Bearer {ACCESS_TOKEN}',
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'json' => [
'status' => 'PAGO',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'http://smartsafe.dyndns.tv:81/api/pix/aspernatur'
payload = {
"status": "PAGO"
}
headers = {
'Authorization': 'Bearer {ACCESS_TOKEN}',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
response = requests.request('PATCH', url, headers=headers, json=payload)
response.json()
Exemplo de response (204, Status atualizado):
Resposta em branco
Exemplo de response (404, Pix não encontrado):
{
"codigo_erro": 123,
"mensagem": "Pix não encontrado"
}
Exemplo de response (500, Erro interno):
{
"codigo_erro": 13123123123,
"mensagem": "Erro interno"
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Token de Acesso
Utilizamos o framework OAuth2 para auth
Obter token de acesso
Endpoint para obter access_token
Exemplo de request:
curl --request POST \
"http://smartsafe.dyndns.tv:81/oauth/token" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"grant_type\": \"client_credentials\",
\"client_id\": \"{CLIENT_ID}\",
\"client_secret\": \"{CLIENT_SECRET}\"
}"
const url = new URL(
"http://smartsafe.dyndns.tv:81/oauth/token"
);
const headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"grant_type": "client_credentials",
"client_id": "{CLIENT_ID}",
"client_secret": "{CLIENT_SECRET}"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'http://smartsafe.dyndns.tv:81/oauth/token';
$response = $client->post(
$url,
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'json' => [
'grant_type' => 'client_credentials',
'client_id' => '{CLIENT_ID}',
'client_secret' => '{CLIENT_SECRET}',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'http://smartsafe.dyndns.tv:81//oauth/token'
payload = {
"grant_type": "client_credentials",
"client_id": "{CLIENT_ID}",
"client_secret": "{CLIENT_SECRET}"
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
response = requests.request('POST', url, headers=headers, json=payload)
response.json()
Exemplo de response (200, access_token gerado):
{
"token_type": "Bearer",
"expires_in": 31536000,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciO..."
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Response
Campos da response
token_type
string
Tipo do token. Padrão: Bearer
expires_in
integer
Segundos restantes para o token expirar
access_token
string
Token de acesso