Skip to main content

📦 PyWSPix

O PyWSPix oferece um wrapper para as funcionalidades do WSPix da USP.

Python Poetry


🚀 Funcionalidades

  • ✅ Gera um novo Pix.
  • ✅ Consulta um Pix gerado.
  • ✅ Lista os Pix pagos dentre de um príodo.
  • ✅ Retorna a representação binária para um PFD contentdo os dados e o QrCode de um Pix gerado.
  • ✅ Retorna a representação binária para uma imagem contentdo o QrCode de um Pix gerado.
  • ✅ Configura o webhook da aplicação

📦 Instalação

pip install pywspix

Requisitos

  • Python >= 3.8

Exemplos

Gerar um Pix

from pywspix.gera import WSPixGera
from pywspix.headers import Headers

url = "https://api-dev.portalservicos.usp.br"
user = "usuario_do_servico"
password = "senha_do_servico"

payload = {
    "tipoPessoa": "PF",
    "codPesOrg": 3333333,
    "valor": 10.02,
    "infoCobranca": "Cobrança teste",
    "expiracao": 3600,
    "codigoFonteRecurso": 423,
    "codigoUnidadeDespesa": 1,
    "estruturaHierarquica": r"\DISTRIBUIDOR"
}

headers = Headers(user=user, password=password)
gera = WSPixGera(headers=headers, url=url)
gera.set_payload(**payload)
resp = gera.gerar_pix()

Consultar um Pix

from pywspix.consulta import WSPixConsulta
from pywspix.headers import Headers

url = "https://api-dev.portalservicos.usp.br"
user = "usuario_do_servico"
password = "senha_do_servico"
headers = Headers(user=user, password=password)

consulta = WSPixConsulta(headers=headers, url=url)
resp = consulta.consultar("kjhasd98a9s8d7khd")

Listar Concluídos

from pywspix.consulta import WSPixConsulta
from pywspix.headers import Headers

url = "https://api-dev.portalservicos.usp.br"
user = "usuario_do_servico"
password = "senha_do_servico"
headers = Headers(user=user, password=password)

search = {
    "dtaini": "2025-01-01 10:10:00",
    "dtaini": "2025-02-01 10:10:00"
}

lista = WSPixLista(headers=headers, url=url)
lista.set_search_params(**busca)
resp = lista.listar()

Gerar QRcode ou PDF

from pywspix.file import WSPixFile
from pywspix.headers import Headers

url = "https://api-dev.portalservicos.usp.br"
user = "usuario_do_servico"
password = "senha_do_servico"
headers = Headers(user=user, password=password)

file = WSPixFile(headers=headers, url=url, idfpix="lkjasdpasopid")
qrcode = file.get_qrcode()
pdf = file.get_pdf()

Configuração do Webhook

from pywspix.file import WSPixFile
from pywspix.headers import Headers

url = "https://api-dev.portalservicos.usp.br"
user = "usuario_do_servico"
password = "senha_do_servico"
headers = Headers(user=user, password=password)

config = {
    "url": "https://my.app.br/webhook",
    "token": "kljoiasuy0987hjkas"
}

webhook = WSPixwebhook(headers=headers, baseurl=url)
webhook.set_config(**config)
webhook.config()

Contribuição

Clone o repositório:

git clone https://github.com/iagsti/pywspix.git

Instale as dependências:

cd pywspix
poetry install

Testando:

poetry run pytest

Para fazer o build do pacote

poetry build

Release files for pywspix 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pywspix 0.1.1
File Size Uploaded
pywspix-0.1.1.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pywspix 0.1.1
File Interpreter ABI Platform
pywspix-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.1 kB

Release files / pywspix-0.1.1.tar.gz

Download URL pywspix-0.1.1.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
06229d879cc8ff2e2d3e4787e3c98d372bd82b1f1708e4c88c72e0e05caf6262
BLAKE2b-256 checksum
How to use checksums
4b53a055d997f798ba459239f60c3ac523dd5bc74182e4ca2afb789f27b6d0bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Zorin OS","version":"18","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pywspix-0.1.1-py3-none-any.whl

Download URL pywspix-0.1.1-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
066b4bef2c8697eb86d434fd2f42d4907e59ed5f0afe6b61aa871d623fff0e5b
BLAKE2b-256 checksum
How to use checksums
f847a9c383fdadae8a55e1948eee5a6ca2e131fed26daa5cffcdbf5e3e4ba8b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Zorin OS","version":"18","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page