1
0

Add README and schema

This commit is contained in:
hueso 2025-04-04 18:49:04 -03:00
parent 6092541f5d
commit 2acc72f2db
2 changed files with 201 additions and 0 deletions

78
README.md Normal file
View File

@ -0,0 +1,78 @@
# P2Pix ITP oracle backend
## Variáveis de ambiente necessárias no arquivo `.env`:
- `BB_CLIENT_ID`,
`BB_CLIENT_SECRET`, e
`DEV_APP_KEY`: Fornecidas pelo Bando do Brasil
- `PRIVATE_KEY`:
Chave privada Ethereum (em formato hexadecimal com prefixo '0x')
que vai assinar as liberações de pagamento)
# Endpoints
## POST /register
### Registra um participante.
Chamado pelo vendedor antes de fazer `deposit` no smart contract.
#### Parametros requeridos:
- `nomeParticipante`
- `tipoDocumento`
- `numeroDocumento`
- `numeroConta`
- `tipoConta`
``` exemplo
curl --request POST \
--url http://localhost:5000/register \
--header 'content-type: application/json' \
--data '{
"nomeParticipante": "João Silva",
"tipoDocumento": 1,
"numeroDocumento": 12345678900,
"numeroConta": 1234567890123456,
"numeroAgencia": 123,
"tipoConta": 1
}'
```
#### Retorna em formato JSON:
- `numeroParticipante` (usado no `deposit` do SC como `pixTarget`)
## POST /request
### Solicitação de Pagamento
Chamado pelo comprador após o `lock` no smart contract.
#### Parametros requeridos:
- `amount`
- `pixTarget`
```
curl -X POST http://localhost:5000/request \
-H "Content-Type: application/json" \
-d '{
"amount": 100.00,
"pixTarget": 123
}'
```
#### Retorna em formato JSON:
- `numeroSolicitacao`: usado para chamar `/release` depois
- `textoQrCode`: usado para gerar o QR PIX
## GET /release/{numeroSolicitacao}
### Liberação de Pagamento
Chamado pelo comprador após pagar o Pix
``` exemplo
curl http://localhost:5000/release/123
```
#### Retorna em formato JSON:
- `pixTarget`
- `amount`: valor em wei
- `pixTimestamp`
- `signature`: assinatura ethereum compatível
# Observações
- O ambiente de produção requer autenticação mTLS
- Para ambiente de desenvolvimento use `DEBUG=true`
- Em produção, o servidor usa Waitress como servidor WSGI
- Para mais informações, consulte a documentação oficial: https://developers.bb.com.br/

123
helpix.json Normal file
View File

@ -0,0 +1,123 @@
{
"info": {
"name": "Helpix",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "register",
"event": [],
"request": {
"method": "POST",
"header": [],
"auth": {
"type": "noauth"
},
"description": "",
"url": {
"raw": "{{baseUrl}}/register",
"protocol": "",
"host": [
"{{baseUrl}}"
],
"path": [
"register"
],
"query": [],
"variable": []
},
"body": {
"mode": "raw",
"raw": "{\n \"nomeParticipante\": \"Participante Teste\",\n \"tipoDocumento\": 1,\n \"numeroDocumento\": 64655215801,\n \"numeroConta\": 10331,\n \"numeroAgencia\": 551,\n \"tipoConta\": 1\n}",
"options": {
"raw": {
"language": "json"
}
}
}
}
},
{
"name": "release",
"event": [],
"request": {
"method": "GET",
"header": [],
"auth": {
"type": "noauth"
},
"description": "",
"url": {
"raw": "{{baseUrl}}/release/:requestID",
"protocol": "",
"host": [
"{{baseUrl}}"
],
"path": [
"release",
":requestID"
],
"query": [],
"variable": [
{
"key": "requestID",
"value": "1259843"
}
]
},
"body": {
"mode": "raw",
"options": {
"raw": {
"language": "json"
}
}
}
}
},
{
"name": "request",
"event": [],
"request": {
"method": "POST",
"header": [],
"auth": {
"type": "noauth"
},
"description": "",
"url": {
"raw": "{{baseUrl}}/request",
"protocol": "",
"host": [
"{{baseUrl}}"
],
"path": [
"request"
],
"query": [],
"variable": []
},
"body": {
"mode": "raw",
"raw": "{\n \"amount\": \"100\",\n \"pixTarget\": 145\n}",
"options": {
"raw": {
"language": "json"
}
}
}
}
},
{
"name": "bruno",
"event": []
}
],
"variable": [
{
"key": "baseUrl",
"value": "",
"type": "default"
}
]
}