Skip to content

v1: framework-agnostic Selcom client - #1

Merged
alphaolomi merged 9 commits into
mainfrom
feat/v1
Nov 21, 2026
Merged

alphaolomi merged 9 commits into
mainfrom
feat/v1

Conversation

@alphaolomi

@alphaolomi alphaolomi commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

First v1 of the framework-agnostic PHP client for the Selcom API gateway (0.1.0, unreleased, not yet on Packagist).

Not affiliated with Selcom Paytech Ltd. Written clean-room against selcom-spec v0.2.1 (recorded in SPEC_VERSION; refresh with scripts/refresh-spec.sh, verify with scripts/check-spec.sh).

v1 checklist

  • Config: explicit environment (no default), credentials, per-profile timeouts, optional checkout credentials
  • Signer: pure (no I/O, no clock), pluggable digest signer, HS256, both timestamp offset forms accepted, colon form generated
  • Transport: replaceable interface, PSR-18 default, per-profile timeouts, NOT_SENT / UNKNOWN_OUTCOME classification; no retry of payments or writes
  • Operations: 16 typed methods with typed requests and results
  • Results: SUCCESS, PENDING, AMBIGUOUS, FAILED, NOT_FOUND plus raw HTTP status and body
  • Webhooks: verify(headers, rawBody), spec v0.2.1 rules, configurable window and replay store, payload parsing
  • Redactor
  • Tests: 20 signing cases, 11 rejects, 120 response scenarios (classifier and client), 15 webhook samples, unit tests; opt-in sandbox test
  • Docs: README, CHANGELOG, CONTRIBUTING, SECURITY
  • CI on PHP 8.2 to 8.5: composer validate --strict, composer audit, vectors match spec, PHPStan (max, strict rules), tests, build; actions pinned to commit SHAs

Decisions where the spec or PHP left room

  • Timeouts and PSR-18. PSR-18 cannot carry a timeout, so Psr18Transport needs a per-profile client factory (the default builds a Guzzle client per profile) or clientManagesTimeouts: true for a ready client. The payment profile uses a fresh connection per request.
  • Failure classification. NOT_SENT only for connect-phase failures (name lookup, refused connection, handshake or certificate failure, a connect timeout with no later-phase evidence); everything else is UNKNOWN_OUTCOME.
  • Failed-send cause. TransportException carries a short summary (classes and cURL errno), not the client's own exception.
  • Amounts. Request classes take an int, a digit string or an integral float and refuse anything else.
  • Status name. The spec calls the in-progress status PENDING.
  • PHP decoding. {} and [] decode alike, so order-status data shape is checked on the decoded object form; data: {} is AMBIGUOUS.
  • Printed output. Secrets live outside the objects that use them; secret parameters are marked #[\SensitiveParameter]; the API key prints its last 4 characters.

Gaps

  • RS256 is not implemented (the spec says it is unconfirmed); DigestSigner is the extension point.
  • No local simulator; the fake transport in the tests covers the scenarios.
  • Not run against the real sandbox; the sandbox test is opt-in.

@alphaolomi
alphaolomi marked this pull request as ready for review November 21, 2026 08:26
@alphaolomi
alphaolomi merged commit 975aec2 into main Nov 21, 2026
4 checks passed
@alphaolomi
alphaolomi deleted the feat/v1 branch November 21, 2026 09:17
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