-
Notifications
You must be signed in to change notification settings - Fork 1
Use prefixed SumUp SDK on PHP 8.2+ #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8df97a2
chore: remove unused SumUp ecommerce SDK
kilbot 05d1e2c
build: add prefixed SumUp PHP SDK
kilbot 9349733
feat: guard activation and prefixed SDK autoloading
kilbot a354734
refactor: extract WordPress HTTP reader client
kilbot e2da379
feat: show SumUp SDK compatibility status
kilbot 0494c80
build: ensure SumUp SDK namespace prefix
kilbot f78abee
feat: use official SumUp SDK when available
kilbot 8383408
docs: document SumUp SDK hybrid strategy
kilbot 6f4032f
build: map prefixed SDK service classes
kilbot e51e4cc
chore: tidy SDK integration lint metadata
kilbot 0904aeb
Fix SDK status and checkout normalization
c37e9ba
fix: address sdk readiness audit feedback
codex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,64 +1,64 @@ | ||
| { | ||
| "name": "wcpos/sumup-terminal-for-woocommerce", | ||
| "description": "SumUp Terminal integration for WooCommerce POS.", | ||
| "type": "wordpress-plugin", | ||
| "license": "GPL-3.0+", | ||
| "authors": [ | ||
| { | ||
| "name": "kilbot", | ||
| "email": "paul@kilbot.com" | ||
| } | ||
| ], | ||
| "require-dev": { | ||
| "dealerdirect/phpcodesniffer-composer-installer": "^1.0", | ||
| "friendsofphp/php-cs-fixer": "^3.0", | ||
| "php-stubs/woocommerce-stubs": "^10.5", | ||
| "phpcompatibility/phpcompatibility-wp": "^2.0", | ||
| "sirbrillig/phpcs-variable-analysis": "^2.0", | ||
| "squizlabs/php_codesniffer": "^3.0", | ||
| "woocommerce/woocommerce-sniffs": "^1.0", | ||
| "wp-coding-standards/wpcs": "^3.0", | ||
| "wp-phpunit/wp-phpunit": "^7.0", | ||
| "yoast/phpunit-polyfills": "^4.0" | ||
| }, | ||
| "require": { | ||
| "php": ">=7.4", | ||
| "ext-json": "*", | ||
| "sumup/sumup-ecom-php-sdk": "^1.2.0" | ||
| }, | ||
| "config": { | ||
| "platform": { | ||
| "php": "7.4" | ||
| "name": "wcpos/sumup-terminal-for-woocommerce", | ||
| "description": "SumUp Terminal integration for WooCommerce POS.", | ||
| "type": "wordpress-plugin", | ||
| "license": "GPL-3.0+", | ||
| "authors": [ | ||
| { | ||
| "name": "kilbot", | ||
| "email": "paul@kilbot.com" | ||
| } | ||
| ], | ||
| "require-dev": { | ||
| "dealerdirect/phpcodesniffer-composer-installer": "^1.0", | ||
| "friendsofphp/php-cs-fixer": "^3.0", | ||
| "php-stubs/woocommerce-stubs": "^10.5", | ||
| "phpcompatibility/phpcompatibility-wp": "^2.0", | ||
| "sirbrillig/phpcs-variable-analysis": "^2.0", | ||
| "squizlabs/php_codesniffer": "^3.0", | ||
| "woocommerce/woocommerce-sniffs": "^1.0", | ||
| "wp-coding-standards/wpcs": "^3.0", | ||
| "wp-phpunit/wp-phpunit": "^7.0", | ||
| "yoast/phpunit-polyfills": "^4.0" | ||
| }, | ||
| "platform-check": false, | ||
| "process-timeout": 0, | ||
| "optimize-autoloader": true, | ||
| "vendor-dir": "vendor", | ||
| "sort-packages": true, | ||
| "allow-plugins": { | ||
| "dealerdirect/phpcodesniffer-composer-installer": true | ||
| } | ||
| }, | ||
| "scripts": { | ||
| "format": "phpcbf --standard=./.phpcs.xml.dist --report-summary --report-source", | ||
| "lint": "phpcs --standard=./.phpcs.xml.dist", | ||
| "lint-report": "phpcs --standard=./.phpcs.xml.dist --report=checkstyle", | ||
| "fix": "php-cs-fixer fix .", | ||
| "prefix-dependencies": [ | ||
| "composer --working-dir=php-scoper install", | ||
| "cd php-scoper && vendor/bin/php-scoper add-prefix --output-dir=../vendor_prefixed --force && cd ..", | ||
| "composer dump-autoload -o", | ||
| "php generate_autoload.php" | ||
| ] | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "WCPOS\\WooCommercePOS\\SumUpTerminal\\": "includes/" | ||
| } | ||
| }, | ||
| "autoload-dev": { | ||
| "psr-4": { | ||
| "WCPOS\\WooCommercePOS\\SumUpTerminal\\Tests\\": "tests/includes/" | ||
| "require": { | ||
| "php": ">=7.4", | ||
| "ext-json": "*" | ||
| }, | ||
| "config": { | ||
| "platform": { | ||
| "php": "7.4" | ||
| }, | ||
| "platform-check": false, | ||
| "process-timeout": 0, | ||
| "optimize-autoloader": true, | ||
| "vendor-dir": "vendor", | ||
| "sort-packages": true, | ||
| "allow-plugins": { | ||
| "dealerdirect/phpcodesniffer-composer-installer": true | ||
| } | ||
| }, | ||
| "scripts": { | ||
| "format": "phpcbf --standard=./.phpcs.xml.dist --report-summary --report-source", | ||
| "lint": "phpcs --standard=./.phpcs.xml.dist", | ||
| "lint-report": "phpcs --standard=./.phpcs.xml.dist --report=checkstyle", | ||
| "fix": "php-cs-fixer fix .", | ||
| "prefix-dependencies": [ | ||
| "composer --working-dir=php-scoper install --no-dev --optimize-autoloader", | ||
| "php php-scoper/vendor/bin/php-scoper add-prefix --config=php-scoper/scoper.inc.php --output-dir=vendor_prefixed/sumup-sdk --force", | ||
| "php tools/prefix-sumup-sdk-namespaces.php", | ||
| "php tools/generate-prefixed-sumup-autoload.php", | ||
| "composer dump-autoload -o" | ||
| ] | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "WCPOS\\WooCommercePOS\\SumUpTerminal\\": "includes/" | ||
| } | ||
| }, | ||
| "autoload-dev": { | ||
| "psr-4": { | ||
| "WCPOS\\WooCommercePOS\\SumUpTerminal\\Tests\\": "tests/includes/" | ||
| } | ||
| } | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # ADR 0001: Use prefixed SumUp SDK on PHP 8.2+ with WordPress HTTP compatibility fallback | ||
|
|
||
| ## Status | ||
|
|
||
| Accepted | ||
|
|
||
| ## Context | ||
|
|
||
| This plugin integrates SumUp Terminal reader operations for WooCommerce. The previous Composer dependency, `sumup/sumup-ecom-php-sdk`, was unused and did not provide first-class Terminal reader operations. | ||
|
|
||
| SumUp now publishes `sumup/sumup-php`, which includes reader support for listing, pairing, retrieving, deleting, checkout creation, checkout termination, and reader status. That SDK requires PHP 8.2+ and ext-curl, while this plugin continues to support WordPress sites running PHP 7.4+. | ||
|
|
||
| WordPress also provides its own HTTP API, `wp_remote_request()`, which handles WordPress-specific hosting concerns such as proxies, filters, and transport selection. The official SDK uses its own cURL client; this is an intentional trade-off on PHP 8.2+ unless a future WordPress-backed SDK HTTP client is added. | ||
|
|
||
| ## Decision | ||
|
|
||
| The plugin uses a prefixed copy of the official `sumup/sumup-php` SDK for supported Terminal reader operations when PHP 8.2+ is available and the prefixed SDK is bundled. | ||
|
|
||
| On PHP 7.4-8.1, or when the prefixed SDK is unavailable, the plugin uses its WordPress HTTP compatibility client. Payments can still work normally in compatibility mode. | ||
|
|
||
| The SDK is loaded through a PHP-version-guarded autoloader so older PHP runtimes do not parse PHP 8.2-only SDK files. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Users on PHP 8.2+ get the official SDK path for supported operations. | ||
| - Users on older PHP versions keep the existing direct HTTP behavior. | ||
| - The plugin maintains two reader API transports, so behavior must remain covered by shared service-level tests or regression checks. | ||
| - Operations not exposed by the SDK, such as connect and disconnect, remain on the WordPress HTTP client. | ||
| - The settings UI explains when the compatibility client is active because the server PHP version is below 8.2. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?php | ||
| /** | ||
| * Reader API client factory. | ||
| * | ||
| * @package SumUpTerminalForWooCommerce | ||
| */ | ||
|
|
||
| namespace WCPOS\WooCommercePOS\SumUpTerminal\Services; | ||
|
|
||
| // phpcs:disable Squiz.Commenting.FunctionComment.Missing, Squiz.Commenting.ClassComment.Missing, Squiz.Commenting.VariableComment.Missing, WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase | ||
|
|
||
| class ReaderApiClientFactory { | ||
| public static function create( $api_key ): ReaderApiClientInterface { | ||
| $fallback = new WordPressHttpReaderApiClient( $api_key ); | ||
|
|
||
| if ( SdkAvailability::is_sdk_available() ) { | ||
| return new SdkReaderApiClient( $api_key, $fallback ); | ||
| } | ||
|
|
||
| return $fallback; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?php | ||
| /** | ||
| * Reader API client contract. | ||
| * | ||
| * @package SumUpTerminalForWooCommerce | ||
| */ | ||
|
|
||
| namespace WCPOS\WooCommercePOS\SumUpTerminal\Services; | ||
|
|
||
| // phpcs:disable Squiz.Commenting.FunctionComment.Missing, Squiz.Commenting.ClassComment.Missing, Squiz.Commenting.VariableComment.Missing, WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase | ||
|
|
||
| interface ReaderApiClientInterface { | ||
| public function get_all(); | ||
| public function get_reader( $reader_id ); | ||
| public function create( array $data ); | ||
| public function destroy( $reader_id ); | ||
| public function checkout( $reader_id, $checkout_data ); | ||
| public function cancel_checkout( $reader_id ); | ||
| public function get_status( $reader_id ); | ||
| public function connect( $reader_id ); | ||
| public function disconnect( $reader_id ); | ||
| public function set_profile_service( ProfileService $profile_service ): void; | ||
| public function set_merchant_id( $merchant_id ): void; | ||
| public function get_merchant_id(); | ||
| public function has_api_key(); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.