Repository navigation
PHPAY-161: corrigir — o Inter não acrescenta /pix à URL do webhook - #162
Merged
Merged
Conversation
The gateway documentation claimed Inter delivers to <webhookUrl>/pix instead
of the URL you registered. It does not.
The claim came from the expression Redoc shows in the webhookPut callback
section: POST {$request.body#/webhookUrl/pix}. Read as a JSON Pointer, which
is what #/ introduces, that is malformed — it would point at a `pix` property
inside a string. What actually happened is that the callback is named `pix` in
the spec and Redoc joined the name to the expression. Inter's own text
describes a POST to the registered webhookUrl, and its example carries no
suffix.
The /pix suffix is real, but it is a documented quirk of Itaú, which
implements the same specification. That is where the confusion came from.
The code was never wrong: nothing rewrites the URL, which is correct either
way, and the test that fixes that property still holds — only its name and
its rationale change. The replacement text records why the claim looked true,
because anyone checking the reference will meet that expression again.
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.
Closes #161.
A documentação do gateway do Inter, entregue no #156, afirmava que ele entrega a
notificação em
<webhookUrl>/pixem vez da URL cadastrada. Está errado, e aafirmação é minha.
De onde saiu
Da expressão que o Redoc mostra na seção de callback do
webhookPut:Li o
/pixcomo caminho acrescentado. Lida como JSON Pointer — que é o que#/introduz — essa expressão é malformada: aponta para uma propriedadepixdentro de
webhookUrl, que é string. A explicação é outra: no OpenAPI umcallback tem nome, ali o nome é
pix, e o Redoc juntou o nome à expressão.A documentação do Inter descreve o callback como
POSTnawebhookUrlcadastrada, e o exemplo dela —
https://pix.example.com/api/webhook/— não temsufixo.
O sufixo
/pixexiste: é quirk documentado do Itaú(bacen/pix-api#313), que
implementa a mesma especificação. Foi daí que a confusão veio.
O código nunca esteve errado
Nada no
Resources/Webhook/Webhook.phpreescreve a URL — manda o que o chamadorpassou, que é o correto nos dois cenários. O teste que fixa essa propriedade
continua valendo; mudaram o nome dele e o motivo no comentário.
Então isto é correção de seis textos, não de comportamento: o PHPDoc da
classe,
docs/gateways/inter.md, a seção de notas doCHANGELOG.md, asparticularidades do
CLAUDE.md, o teste e o exemplo.O texto novo diz por que a afirmação parecia verdadeira
De propósito. Quem for conferir a referência do Inter vai topar com a mesma
expressão, e um aviso dizendo apenas "não acrescenta
/pix" convidaria a"consertar" o Resource de volta. O
CLAUDE.mdganhou a frase explícita: nãoacrescente o sufixo.
Fora destes arquivos, as notas da release v2.8.0 e um comentário no #156
carregam a mesma afirmação; corrijo os dois à mão, já que não são versionados.
Verificação
composer test: lint, 743 testes, PHPStan nível 9, 113 links. Smoke com 97verificações. Nada mudou de comportamento, como esperado.