Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ install.test:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ bb-wrapper==$(V)

config.certs.fake:
-mkdir certs
Comment thread
brenomfviana marked this conversation as resolved.
openssl req -subj '/CN=imobanco.com.br/O=Imobanco Pagamentos S.A./C=BR' -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout certs/key.pem -out certs/cert.pem
7 changes: 4 additions & 3 deletions bb_wrapper/models/pagamentos.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ def _set_data(cls, values):

class TransferenciaTED(BaseModel):
numeroCOMPE: int
agenciaCredito: int
contaCorrenteCredito: int
digitoVerificadorContaCorrente: str
cpfBeneficiario: Optional[int]
cnpjBeneficiario: Optional[int]
dataTransferencia: str
valorTransferencia: float
contaPagamentoCredito: Optional[str]
agenciaCredito: Optional[int]
contaCorrenteCredito: Optional[int]
digitoVerificadorContaCorrente: Optional[str]
codigoFinalidadeTED: Optional[FinalidadeTED]


Expand Down
50 changes: 35 additions & 15 deletions bb_wrapper/wrapper/pagamento_lote.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ def _criar_dados_transferencia(
conta,
dv_conta,
codigo_banco,
agencia_destino,
conta_destino,
dv_conta_destino,
documento,
data_transferencia,
valor_transferencia,
descricao,
conta_pagamento_destino=None,
agencia_destino=None,
conta_destino=None,
dv_conta_destino=None,
finalidade_ted=1,
tipo_pagamento=128,
convenio=None,
Expand Down Expand Up @@ -178,17 +179,29 @@ def _criar_dados_transferencia(

pagamento_data = {
"numeroCOMPE": codigo_banco,
"agenciaCredito": agencia_destino,
"contaCorrenteCredito": conta_destino,
"digitoVerificadorContaCorrente": dv_conta_destino,
"dataTransferencia": data_transferencia,
"valorTransferencia": valor_transferencia,
"descricaoTransferencia": descricao,
}
if documento_tipo == 1:
pagamento_data["cpfBeneficiario"] = documento

if conta_pagamento_destino is not None:
pagamento_data = {
**pagamento_data,
"contaPagamentoCredito": conta_pagamento_destino,
}
elif None not in [agencia_destino, conta_destino, dv_conta_destino]:
pagamento_data = {
**pagamento_data,
"agenciaCredito": agencia_destino,
Comment thread
brenomfviana marked this conversation as resolved.
"contaCorrenteCredito": conta_destino,
"digitoVerificadorContaCorrente": dv_conta_destino,
}
Comment thread
rodrigondec marked this conversation as resolved.

else:
pagamento_data["cnpjBeneficiario"] = documento
raise ValueError(
Comment thread
brenomfviana marked this conversation as resolved.
"Conta de Pagamento OU dados de Conta Corrente precisam ser informados!"
)

if int(codigo_banco) != 1:
"""
Só é utilizado finalidade TED para outros bancos
Expand All @@ -198,6 +211,11 @@ def _criar_dados_transferencia(
"""
pagamento_data["codigoFinalidadeTED"] = finalidade_ted

if documento_tipo == 1:
pagamento_data["cpfBeneficiario"] = documento
else:
pagamento_data["cnpjBeneficiario"] = documento

TransferenciaTED(**pagamento_data)

return {**lote_data, "listaTransferencias": [{**pagamento_data}]}
Expand All @@ -209,13 +227,14 @@ def cadastrar_transferencia(
conta,
dv_conta,
codigo_banco,
agencia_destino,
conta_destino,
dv_conta_destino,
documento,
data_transferencia,
valor_transferencia,
descricao,
conta_pagamento_destino=None,
agencia_destino=None,
conta_destino=None,
dv_conta_destino=None,
finalidade_ted=1,
tipo_pagamento=128,
convenio=None,
Expand Down Expand Up @@ -246,13 +265,14 @@ def cadastrar_transferencia(
conta,
dv_conta,
codigo_banco,
agencia_destino,
conta_destino,
dv_conta_destino,
documento,
data_transferencia,
valor_transferencia,
descricao,
conta_pagamento_destino,
agencia_destino,
conta_destino,
dv_conta_destino,
finalidade_ted,
tipo_pagamento,
convenio,
Expand Down
2 changes: 2 additions & 0 deletions examples/auth/access_token.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from bb_wrapper.wrapper.bb import BaseBBWrapper
import logging

logging.basicConfig(level=logging.DEBUG)

wrapper = BaseBBWrapper()
response = wrapper._BaseBBWrapper__authenticate()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
import logging
from datetime import date

from examples.utils import dump_response

from bb_wrapper.wrapper import PagamentoLoteBBWrapper

c = PagamentoLoteBBWrapper(cert=("./certs/cert.pem", "./certs/key.pem"))

logging.basicConfig(level=logging.DEBUG)

today = date.today()
bb_fmt = "%d%m%Y"

lote_data = {
"n_requisicao": 579497,
"agencia": 1607,
"conta": 99738672,
"dv_conta": "X",
}
transferencia_data = {
"codigo_banco": 290,
"conta_pagamento_destino": 3066,
"documento": "99391916180",
"data_transferencia": today.strftime(bb_fmt),
"valor_transferencia": 15.50,
"descricao": "string",
}


response = c.cadastrar_transferencia(**lote_data, **transferencia_data)

dump_response(response, os.path.realpath(__file__))
3 changes: 3 additions & 0 deletions examples/lotes_pagamento/consultar_transferencia.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import logging
import os

from examples.utils import dump_response

from bb_wrapper.wrapper import PagamentoLoteBBWrapper

logging.basicConfig(level=logging.DEBUG)

c = PagamentoLoteBBWrapper(cert=("./certs/cert.pem", "./certs/key.pem"))

_id = "90579174731030001"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os

from examples.utils import dump_response

from bb_wrapper.wrapper import PagamentoLoteBBWrapper

c = PagamentoLoteBBWrapper(cert=("./certs/cert.pem", "./certs/key.pem"))

_id = "90580000731030001"


response = c.consultar_transferencia(
_id,
)

dump_response(response, os.path.realpath(__file__))
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"estadoRequisicao": 1,
"quantidadeTransferencias": 1,
"totalTransferencias": 15.5,
"quantidadeTransferenciasValidas": 1,
"totalTransferenciasValidas": 15.5,
"transferencias": [
{
"identificadorTransferencia": "90579497731030001",
"numeroCOMPE": 290,
"numeroISPB": 0,
"agenciaCredito": 0,
"contaCorrenteCredito": 0,
"digitoVerificadorContaCorrente": "X",
"contaPagamentoCredito": "3066",
"cpfBeneficiario": 99391916180,
"dataTransferencia": 30112023,
"valorTransferencia": 15.5,
"documentoDebito": 0,
"documentoCredito": 0,
"tipoCredito": 3,
"codigoFinalidadeDOC": "",
"codigoFinalidadeTED": "1",
"numeroDepositoJudicial": "",
"descricaoTransferencia": "string",
"indicadorAceite": "S",
"erros": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"id": 90580000731030000,
"estadoPagamento": "INCONSISTENTE",
"tipoCredito": 1,
"agenciaDebito": 1607,
"contaCorrenteDebito": 99738672,
"digitoVerificadorContaCorrenteDebito": "X",
"inicioCartaoCredito": 0,
"fimCartaoCredito": 0,
"dataPagamento": 30112023,
"valorPagamento": 15.5,
"documentoDebito": 0,
"codigoAutenticacaoPagamento": "",
"numeroDepositoJudicial": "",
"codigoFinalidadeDOC": "",
"codigoFinalidadeTED": "",
"listaPagamentos": [
{
"numeroCOMPE": 1,
"numeroISPB": 0,
"agenciaCredito": 0,
"contaCorrenteCredito": 0,
"digitoVerificadorContaCorrenteCredito": "",
"numeroContaCredito": "3066",
"tipoBeneficiario": 1,
"cpfCnpjBeneficiario": 99391916180,
"nomeBeneficiario": "LUIZ NILO REIS",
"documentoCredito": 0,
"texto": ""
}
],
"listaDevolucao": [
{
"codigoMotivo": 23,
"dataDevolucao": 0,
"valorDevolucao": 0
}
]
}
3 changes: 3 additions & 0 deletions examples/lotes_pagamento/listar_pagamentos.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import logging
import os
from datetime import date

from examples.utils import dump_response

from bb_wrapper.wrapper import PagamentoLoteBBWrapper

logging.basicConfig(level=logging.DEBUG)

c = PagamentoLoteBBWrapper(cert=("./certs/cert.pem", "./certs/key.pem"))

inicio = date(2022, 2, 8)
Expand Down
Loading