Repository navigation
feat: estorno v3 (POST /v2/charges/{uuid}/refunds) - #44
Merged
Merged
Conversation
Adiciona create_refund com x-idempotency-key e refunds[] na cobrança. Os endpoints antigos de estorno ficam marcados como depreciados, sem remoção.
There was a problem hiding this comment.
🟡 Changes recommended
O novo campo obrigatório quebra a compatibilidade dos construtores públicos de Charge e PixCharge.
1 open finding
What changed in this PR
Adiciona ao SDK o novo fluxo assíncrono de estorno da Barte, mantendo os métodos legados durante a transição.
Alterações:
- Introduz
create_refundcom chave de idempotência por requisição. - Expõe estornos em
Charge.refundse exportaChargeRefund. - Adiciona avisos de depreciação e testes do novo fluxo.
| File | Description |
|---|---|
| tests/test_client.py | Testa estornos, validação, conflito e depreciação. |
| barte/models.py | Adiciona ChargeRefund e Charge.refunds. |
| barte/client.py | Implementa o endpoint e headers por requisição. |
| barte/__init__.py | Exporta ChargeRefund. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sem default, o campo virava obrigatório nos construtores de Charge e PixCharge. Com kw_only e default None, as chamadas antigas continuam valendo, inclusive por posição.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

A Barte vai descontinuar os endpoints atuais de estorno e substituí-los pelo novo fluxo: um endpoint só para estorno total e parcial, assíncrono e com idempotência.
O que muda
create_refund(charge_id, amount, idempotency_key): chamaPOST /v2/charges/{uuid}/refundscom o headerx-idempotency-key.ChargeRefund, normalmente emPROCESSING. O resultado final vem emCharge.refundsou no webhook do domínio CHARGE.Charge.refunds: a lista de estornos que oGET /v2/charges/{uuid}já devolvia e o SDK descartava.ChargeRefundsão opcionais, porque itens antigos vêm semuuide semidempotencyKey.kw_only=True, defaultNone), para não quebrar os construtores deChargeePixCharge, inclusive as chamadas por posição._requestaceitaheaderspor requisição. A chave de idempotência não pode ir para os headers da sessão, que é compartilhada entre chamadas.refund_charge,partial_refund_charge,get_refundeCharge.refundpassam a emitirDeprecationWarning, sem remoção. O estorno parcial feito pelo fluxo antigo só aparece noGET /v2/charges/partial-refund/{id}, então esses métodos ainda são necessários durante a transição.O status HTTP de um erro, por exemplo o 409 de conflito de idempotência, está em
BarteError.response.status_code.Testes
tests/test_client.py, com payloads reais do sandbox. Os testes antigos de estorno passam a conferir o aviso de depreciação.409 BAR-0466e400 BAR-0451.Depois do merge, a versão sai como
v0.16.0.