Skip to content

CallbackHandler: capture optional headers in handleRaw(), add handleGlobals() - #17

Merged
loevgaard merged 1 commit into
1.xfrom
dx/handle-globals
Aug 17, 2026
Merged

CallbackHandler: capture optional headers in handleRaw(), add handleGlobals()#17
loevgaard merged 1 commit into
1.xfrom
dx/handle-globals

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Part of #10 (finding 8).

Why

handleRaw() is what most integrations actually use — Symfony and Laravel requests aren't PSR-7 without a bridge — but it could not populate Callback::$accountId / $apiVersion, and plain-PHP endpoints had to hand-roll the php://input + $_SERVER dance (which examples/e2e/listen.php did, line for line).

What

  • handleRaw(string $rawBody, string $checksum, string $resourceType, ?string $accountId = null, ?string $apiVersion = null) — additive optional params; empty strings normalize to null, consistent with handle().
  • handleGlobals(?string $rawBody = null, ?array $server = null): Callback — reads php://input and HTTP_QUICKPAY_* from $_SERVER (both injectable for tests; non-string superglobal values are cast). Same verification path as the other two entry points.
  • Class docblock now lists the three entry points (handle() PSR-7 / handleRaw() framework / handleGlobals() plain PHP); the e2e listener uses handleGlobals() and Callback::$accountId.
  • README: Symfony, Laravel and plain-PHP callback snippets in the Callbacks section (with the "keep the body raw" reminder — getContent() is raw in both frameworks).

Purely additive. Tests: handleRaw() with/without the optional headers, handleGlobals() happy path (incl. an int header value), bad/missing checksum, missing resource type, absent optional headers, and the real-superglobal default path.

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.06%. Comparing base (d94be92) to head (1300c19).

Additional details and impacted files
@@             Coverage Diff              @@
##                1.x      #17      +/-   ##
============================================
+ Coverage     99.03%   99.06%   +0.03%     
- Complexity      192      197       +5     
============================================
  Files            26       26              
  Lines           517      535      +18     
============================================
+ Hits            512      530      +18     
  Misses            5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…lobals()

handleRaw() is what most integrations actually use — Symfony and Laravel
requests aren't PSR-7 without a bridge — but it could not populate
Callback::$accountId / $apiVersion, and plain-PHP endpoints had to hand-roll
the php://input + $_SERVER dance (which examples/e2e/listen.php did).

- handleRaw($rawBody, $checksum, $resourceType, ?$accountId = null,
  ?$apiVersion = null) — additive optional params; empty strings → null,
  consistent with handle().
- handleGlobals(?$rawBody = null, ?array $server = null) — reads php://input
  and HTTP_QUICKPAY_* from $_SERVER (injectable for tests; non-string
  superglobal values are cast).
- Class docblock lists the three entry points; the e2e listener now uses
  handleGlobals() and Callback::$accountId.
- README: Symfony / Laravel / plain-PHP callback snippets.

Refs #10 (finding 8).
@loevgaard
loevgaard merged commit 862f98e into 1.x Aug 17, 2026
36 checks passed
@loevgaard
loevgaard deleted the dx/handle-globals branch August 17, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant