feat(payments): add the inbound webhook http endpoint - #230
Merged
Conversation
Expose the inbound payment webhook over HTTP: a thin controller reads the raw request body (so the HMAC is verified over the exact bytes), parses it, and delegates to the existing webhook handler, returning 200 for any handled outcome. An invalid signature maps to 401 and a malformed body to 400 through a scoped exception, leaving the global advice free of a broad json handler. The path is already permitted in the security config; the signature is the gate. Closes #228
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.
What
Completes the #214/#216 split: the HTTP endpoint for the inbound payment webhook over the existing
PaymentWebhookHandler.PaymentWebhookController(POST /v1/payments/webhooks, thin):@RequestBody String rawBody(the exact bytes, so HMAC verifies against what the provider signed) +@RequestHeader X-Webhook-Signature-> parse toWebhookRequest(manualObjectMapper, wrapped so a parse failure becomes a scopedMalformedWebhookException) ->handler.handle(rawBody, signature, notification)->200for anyWebhookResult.WebhookSignatureException-> 401 (INVALID_SIGNATURE),MalformedWebhookException-> 400, missing signature header -> 400. The handler is scoped (controller-leveltry/catch), so the global advice does not register a broadJsonProcessingExceptionhandler that could mask server-side 500s (critic fix).SecurityConfigchange:/v1/payments/webhooksis already permitAll (F-02.9 Payments REST API + OpenAPI #216); HMAC is the gate, and the handler verifies the signature before any side effect.@WebMvcTest: valid (no token) -> 200 with the parsed notification asserted, bad signature -> 401, malformed body -> 400 (handler not called), missing header -> 400.Gates
Local (
-x integrationTest)::services:payments:{test,detekt,detektTest,spotlessCheck,assemble,compileIntegrationTestKotlin}green. critic GO (scoped exception applied), security-auditor PASS (HMAC-gated fail-closed before side effect, raw-body exact, §5.3 clean, 5/5 ACs), evaluator 0.91. No security-config change -> no csrf alert expected.Closes #228