diff --git a/composer.json b/composer.json index 577affa..b15a0c0 100644 --- a/composer.json +++ b/composer.json @@ -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/" + } } - } } diff --git a/docs/adr/0001-sumup-sdk-hybrid.md b/docs/adr/0001-sumup-sdk-hybrid.md new file mode 100644 index 0000000..6ae6cc5 --- /dev/null +++ b/docs/adr/0001-sumup-sdk-hybrid.md @@ -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. diff --git a/includes/Gateway.php b/includes/Gateway.php index 33769cd..0626dae 100644 --- a/includes/Gateway.php +++ b/includes/Gateway.php @@ -10,6 +10,7 @@ use WCPOS\WooCommercePOS\SumUpTerminal\Services\ProfileService; use WCPOS\WooCommercePOS\SumUpTerminal\Services\ReaderService; +use WCPOS\WooCommercePOS\SumUpTerminal\Services\SdkAvailability; /** * Class SumUpTerminalGateway. @@ -150,6 +151,8 @@ public static function register_gateway( $methods ) { public function admin_options(): void { parent::admin_options(); + echo wp_kses_post( $this->get_sdk_status_html() ); + // Add Connection Status section outside of form fields ?>
| '; + $html .= ''; + $html .= ' | '; + $html .= ''; + $html .= $this->render_status_card( $type, __( 'Terminal API Client', 'sumup-terminal-for-woocommerce' ), SdkAvailability::get_status_message() ); + $html .= ' | '; + $html .= '
|---|