Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 60 additions & 60 deletions composer.json
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/"
}
}
}
}
29 changes: 29 additions & 0 deletions docs/adr/0001-sumup-sdk-hybrid.md
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.
25 changes: 25 additions & 0 deletions includes/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use WCPOS\WooCommercePOS\SumUpTerminal\Services\ProfileService;
use WCPOS\WooCommercePOS\SumUpTerminal\Services\ReaderService;
use WCPOS\WooCommercePOS\SumUpTerminal\Services\SdkAvailability;

/**
* Class SumUpTerminalGateway.
Expand Down Expand Up @@ -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() );
Comment thread
kilbot marked this conversation as resolved.

Comment thread
coderabbitai[bot] marked this conversation as resolved.
// Add Connection Status section outside of form fields
?>
<table class="form-table">
Expand Down Expand Up @@ -526,6 +529,28 @@ private function get_connection_status_html() {
return $html;
}

/**
* Get the SDK status HTML for display.
*
* @return string HTML for SDK status.
*/
private function get_sdk_status_html() {
$type = SdkAvailability::is_sdk_available() ? 'success' : 'info';

$html = '<table class="form-table">';
$html .= '<tr valign="top">';
$html .= '<th scope="row" class="titledesc">';
$html .= '<label>' . esc_html__( 'SumUp SDK Status', 'sumup-terminal-for-woocommerce' ) . '</label>';
$html .= '</th>';
$html .= '<td class="forminp">';
$html .= $this->render_status_card( $type, __( 'Terminal API Client', 'sumup-terminal-for-woocommerce' ), SdkAvailability::get_status_message() );
$html .= '</td>';
$html .= '</tr>';
$html .= '</table>';

return $html;
}

/**
* Render a status card.
*
Expand Down
22 changes: 22 additions & 0 deletions includes/Services/ReaderApiClientFactory.php
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;
}
}
26 changes: 26 additions & 0 deletions includes/Services/ReaderApiClientInterface.php
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();
}
Loading