Adopt setono/quickpay-php-sdk and harden the gateway (2.x)#44
Open
loevgaard wants to merge 4 commits into
Open
Adopt setono/quickpay-php-sdk and harden the gateway (2.x)#44loevgaard wants to merge 4 commits into
loevgaard wants to merge 4 commits into
Conversation
Adopt the setono/quickpay-php-sdk package as the QuickPay API client and rebuild the gateway around it (2.x): - Api is now a final, immutable value object wrapping the SDK ClientInterface and the gateway options; it performs no HTTP itself (Basic auth, Accept-Version: v10, error mapping and (de)serialization all live in the SDK). - Delete the custom src/Model/* DTOs in favour of the SDK response DTOs/enums; move the surviving state logic into the stateless Operations helper. - Rewrite every action to the SDK's typed endpoints/DTOs. ConvertPaymentAction now persists only scalars (quickpayPaymentId is the source of truth), and NotifyAction verifies the QuickPay-Checksum-Sha256 HMAC (timing-safe) before acting, rejecting invalid/unsigned callbacks with a 400. - Gateway options: drop the unused 'merchant'; require only apikey + privatekey; add 'synchronized' and 'branding_id'; map 'agreement' to the link agreement id; allow injecting a prebuilt SDK client via 'quickpay.client'. - Rebuild the test suite offline on a PSR-18 Http\Mock\Client with request-shape assertions; add OperationsTest, ConvertPaymentActionTest and ConfirmPaymentActionTest. - Keep php-http/message-factory (payum/core gateway wiring needs it) and document the carve-out in composer-dependency-analyser.php.
Add minMsi 65 / minCoveredMsi 70 gates to infection.json.dist and a dedicated mutation-tests CI job (PHP 8.3, highest, pcov) running composer infection.
Rewrite the stale CLAUDE.md sections (the suite is mocked, not live; Api is an SDK wrapper; models replaced by SDK DTOs + Operations helper; PHP 8.1-8.5 matrix), document the PSR-18/17 requirement and gateway options in the README, and add docs/UPGRADE-2.0.md.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 2.x #44 +/- ##
============================================
+ Coverage 89.50% 97.15% +7.65%
+ Complexity 122 89 -33
============================================
Files 16 12 -4
Lines 362 246 -116
============================================
- Hits 324 239 -85
+ Misses 38 7 -31 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Rename the \Setono\Payum\Quickpay namespace, the QuickpayGatewayFactory class (and its file), the 'Quickpay' factory title, and all prose to match the SDK's \Setono\Quickpay convention. The 'QuickPay-Checksum-Sha256' callback header is left as-is — it is QuickPay's actual wire header name (held by the SDK's CallbackValidator::CHECKSUM_HEADER). Also drop the now-obsolete rector.php ReadOnlyPropertyRector skip that referenced the deleted dynamically-hydrated models.
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.
Summary
Replaces the library's hand-rolled QuickPay API client with the external
setono/quickpay-php-sdkpackage and makes the gatewaysignificantly more robust and better tested. Targets 2.x (breaking changes allowed).
What changed
SDK adoption
Apiis now afinal, immutable value object wrapping the SDKClientInterface+ gatewayoptions. It does no HTTP itself — Basic auth, the
Accept-Version: v10header, status→exceptionmapping and (de)serialization all live in the SDK.
src/Model/*in favour of the SDK's readonly response DTOs andPaymentState/OperationTypeenums. The surviving state logic moved into a statelessOperationshelper.create,createLink,capture,refund,cancel,getById).Robustness
NotifyActionvalidates theQuickPay-Checksum-Sha256signature(timing-safe, via the SDK
CallbackValidator) and rejects invalid/unsigned callbacks with a400before acting — previously the callback was processed with no verification.
ConvertPaymentActionpersists only scalars (quickpayPaymentIdis the source of truth); it nolonger serializes a hydrated payment object into the Payum details.
merchant; onlyapikey+privatekeyrequired; addedsynchronizedandbranding_id;agreementnow maps to the linkagreement_id; a prebuilt SDKclient can be injected via
quickpay.client.Testing
Http\Mock\Client(was previously live HTTP /flaky). Tests assert both Payum marks and the exact requests sent (method, path, auth, version).
OperationsTest,ConvertPaymentActionTest,ConfirmPaymentActionTest;try/catch-without-failanti-patterns replaced with
expectException; notify valid/invalid/missing-checksum coverage.minMsi 65/minCoveredMsi 70, currently 76% MSI / 77% covered) with adedicated CI job.
Docs
CLAUDE.md(mocked suite, SDK-basedApi,8.1–8.5matrix), documented thePSR-18/17 requirement and options in the README, and added
docs/UPGRADE-2.0.md.Notes
1.0.0-alpha.1, pinned as^1.0@alpha. A stable SDK tag should land before2.0.0is released.php-http/message-factoryis kept becausepayum/core's gateway wiring still needs it at constructiontime; the dependency-analyser carve-out is documented in
composer-dependency-analyser.php.Verification
Locally green on PHP 8.1 (and lowest/highest resolutions):
composer all(PHPStan level 8 + ECS +PHPUnit 159 tests),
composer normalize --dry-run,composer-dependency-analyser,composer infection.