Add a doctor command verifying the gateway configuration end to end - #140
Merged
Conversation
setono:sylius-quickpay:doctor machine-checks what the README's Troubleshooting section documents, per configured Quickpay gateway: - api key: ping, falling back to a /payments read because Quickpay answers 401 on /ping both for an invalid key and for a valid key whose api user lacks the /ping permission (verified live against the API) - private key: HMAC checksum self-test through the SDK's CallbackValidator - agreement id: existence on the account when configured (failing open when the api user lacks the /agreements permission) - order prefix: length limit, plus a cross-gateway warning when two gateways share a prefix - notify route registration (the routes import installation step) --live additionally creates a money-less test payment and attempts the payment link PUT the checkout depends on, surfacing the "Not authorized to PUT /payments/:id/link" permission case before a customer does; the created link is cleaned up best effort and the leftover test payment is disclosed. Exits non-zero when any check fails; warnings do not fail, matching the plugin's fail-open posture. Verified live against the Quickpay API, both modes. Closes #131
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #140 +/- ##
============================================
+ Coverage 94.27% 95.12% +0.84%
- Complexity 226 272 +46
============================================
Files 27 28 +1
Lines 839 985 +146
============================================
+ Hits 791 937 +146
Misses 48 48 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Also drops the private key self-test's failure branch: a sign-then-verify roundtrip with the same key cannot report false, so the branch was unreachable - the self-test's failure mode is an exception.
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 #131.
(actual output of the live verification run against the real Quickpay API)
Checks
Per configured Quickpay gateway:
ping(), falling back to a one-item/paymentsread. The fallback exists because of a live discovery: Quickpay answers 401 on/pingboth for an invalid key and for a valid key whose api user lacks the/pingpermission (the real test account does exactly this — its key 401s on/pingand 200s on/payments). A 401/403 on both is reported as a rejected key with the API-user-vs-Payment-Window hint.CallbackValidator(sign + verify roundtrip); the output is honest that only a real callback proves the key matches the account.GET /agreements/{id}when configured; missing agreement fails, a missing/agreementspermission only warns (fail open). Unconfigured reports the account-default behavior.--liveadditionally creates a money-less test payment and attempts the payment linkPUTthe checkout depends on — surfacing the classicNot authorized to PUT /payments/:id/linkpermission case before a customer does. The link is cleaned up best effort; the leftover test payment is disclosed in the output.Exit code is non-zero when any check fails (CI/cron-friendly); warnings don't fail, matching the plugin's fail-open posture.
Out of scope
The issue's optional callback-loop check is deliberately not included: without a real card transaction Quickpay sends no callback, so any synthetic "loop" would only prove routing, not verification — and the routing half is covered by the route check plus the reconcile command operationally. Can be revisited if you disagree.
The
/pingdiscovery also meansQuickpayCredentialsValidator(form save) can reject a valid key whose api user lacks the/pingpermission — filed separately as a follow-up.Tests
13 command tests. The SDK endpoint classes are final, so multi-request flows (the
--liveprobe, the/pingfallback) run the real SDK client against a new FIFOQueuedResponsesHttpClienttest double; single-call checks useClientInterfaceprophecies. Both modes verified live against the real Quickpay API.