diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index fdad6386..effa892b 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,3 +1,7 @@ +# 6.5.9 +* Update: Unzer PHP SDK 4.0.1 +* Entfernung von individuellem Plugin-php Requirement in composer.json + # 6.5.8 * Der Express-Checkout funktioniert unter Shopware 6.6 wieder zuverlässig, einschließlich PayPal und Apple Pay * Beim Express-Checkout wird nun eine verständliche Fehlermeldung angezeigt, wenn die Erstellung der Zahlung fehlschlägt, anstatt den Kunden kommentarlos weiterzuleiten diff --git a/CHANGELOG_en-GB.md b/CHANGELOG_en-GB.md index 80c33524..6f0fd8d5 100644 --- a/CHANGELOG_en-GB.md +++ b/CHANGELOG_en-GB.md @@ -1,3 +1,7 @@ +# 6.5.9 +* Update: Unzer PHP SDK 4.0.1 +* Removed individual php requirement in composer.json + # 6.5.8 * Express checkout no longer fails in Shopware 6.6, including PayPal and Apple Pay * Express checkout now shows a clear error message when payment creation fails, instead of silently redirecting diff --git a/composer.json b/composer.json index d974f22e..751e4b55 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "unzerdev/shopware6", "description": "Unzer payment integration for Shopware 6", - "version": "6.5.8", + "version": "6.5.9", "type": "shopware-platform-plugin", "license": "Apache-2.0", "minimum-stability": "dev", @@ -20,8 +20,7 @@ } }, "require": { - "php": ">=8.2 || <=8.3", - "unzerdev/php-sdk": "~3.13.0", + "unzerdev/php-sdk": "~4.0.0", "shopware/core": "~6.6.0", "shopware/administration": "~6.6.0", "shopware/storefront": "~6.6.0" diff --git a/composer.lock b/composer.lock index c3878207..abd8ada9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,29 +4,29 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "77faa31f3f2fcd92913239eaa2b9f06d", + "content-hash": "1e39f897b51ce95492ef8ab6ccc46258", "packages": [ { "name": "unzerdev/php-sdk", - "version": "3.11.0", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/unzerdev/php-sdk.git", - "reference": "274650b6120b8665c8867627210cd8adab65406b" + "reference": "a9344b823fbf5374cd49e07ab6352d385578299e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/unzerdev/php-sdk/zipball/274650b6120b8665c8867627210cd8adab65406b", - "reference": "274650b6120b8665c8867627210cd8adab65406b", + "url": "https://api.github.com/repos/unzerdev/php-sdk/zipball/a9344b823fbf5374cd49e07ab6352d385578299e", + "reference": "a9344b823fbf5374cd49e07ab6352d385578299e", "shasum": "" }, "require": { "ext-json": "*", - "php": "~7.4.0|~8.0.0|~8.1.0|~8.2.0|~8.3.0|~8.4.0" + "php": "~8.1.0|~8.2.0|~8.3.0|~8.4.0|~8.5.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", - "phpunit/phpunit": ">6.5 <10.0" + "phpunit/phpunit": "^9.6" }, "suggest": { "ext-curl": "*" @@ -45,9 +45,9 @@ "description": "This is the php sdk to connect to the Unzer rest API.", "support": { "email": "support@unzer.com", - "source": "https://github.com/unzerdev/php-sdk/tree/3.11.0" + "source": "https://github.com/unzerdev/php-sdk/tree/4.0.1" }, - "time": "2024-12-04T08:14:47+00:00" + "time": "2026-05-15T13:48:06+00:00" } ], "packages-dev": [ @@ -99,16 +99,11 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.17", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "7027b3b0270bf392de0cfba12825979768d728bf" - }, + "version": "1.12.34", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7027b3b0270bf392de0cfba12825979768d728bf", - "reference": "7027b3b0270bf392de0cfba12825979768d728bf", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4dd89ca7aa30fdc6760be21550d583bcc32e8476", + "reference": "4dd89ca7aa30fdc6760be21550d583bcc32e8476", "shasum": "" }, "require": { @@ -153,17 +148,15 @@ "type": "github" } ], - "time": "2025-02-07T15:01:57+00:00" + "time": "2026-07-28T10:04:39+00:00" } ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, - "platform": { - "php": ">=8.2 || <=8.3" - }, - "platform-dev": [], - "plugin-api-version": "2.6.0" + "platform": {}, + "platform-dev": {}, + "plugin-api-version": "2.9.0" } diff --git a/src/Components/ResourceHydrator/CustomerResourceHydrator/CustomerResourceHydrator.php b/src/Components/ResourceHydrator/CustomerResourceHydrator/CustomerResourceHydrator.php index c9df20a2..304bc36f 100755 --- a/src/Components/ResourceHydrator/CustomerResourceHydrator/CustomerResourceHydrator.php +++ b/src/Components/ResourceHydrator/CustomerResourceHydrator/CustomerResourceHydrator.php @@ -79,6 +79,9 @@ public function hydrateObject( throw new \RuntimeException(\sprintf('Could not determine the address for customer with number %s', $customer->getCustomerNumber())); } + $billingAddress = $this->prepareAddress($billingAddress); + $shippingAddress = $this->prepareAddress($shippingAddress); + if (empty($billingAddress->getCompany()) || !\in_array($paymentMethodId, self::B2B_CUSTOMERS_ALLOWED, true)) { $unzerCustomer = CustomerFactory::createCustomer( $billingAddress->getFirstName(), @@ -127,6 +130,8 @@ public function hydrateExistingCustomer( throw new \RuntimeException(\sprintf('Could not determine the address for customer with number %s', $customer->getCustomerNumber())); } + $billingAddress = $this->prepareAddress($billingAddress); + return $this->updateAdditionalDataToCustomer($unzerCustomer, $customer, $billingAddress, $orderTransaction); } @@ -306,4 +311,23 @@ private function updateShippingAddress(Customer $unzerCustomer, OrderAddressEnti $unzerCustomer->setShippingAddress($unzerShippingAddress); } -} + + protected function prepareAddress(OrderAddressEntity|CustomerAddressEntity|null $address):OrderAddressEntity|CustomerAddressEntity|null{ + if($address === null){ + return null; + } + + $address = clone $address; + + $address->setFirstName(trim($address->getFirstName())); + $address->setLastName(trim($address->getLastName())); + $address->setStreet(trim($address->getStreet())); + $address->setZipcode(trim($address->getZipcode())); + $address->setCity(trim($address->getCity())); + if(!empty($address->getCompany())){ + $address->setCompany(trim($address->getCompany())); + } + + return $address; + } +} \ No newline at end of file diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 1fb5f435..af362d9d 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -7,7 +7,7 @@ class ComposerStaticInitf95eb65f29edce7a2336b2687d62b002 { public static $prefixLengthsPsr4 = array ( - 'U' => + 'U' => array ( 'UnzerSDK\\examples\\' => 18, 'UnzerSDK\\' => 9, @@ -16,15 +16,15 @@ class ComposerStaticInitf95eb65f29edce7a2336b2687d62b002 ); public static $prefixDirsPsr4 = array ( - 'UnzerSDK\\examples\\' => + 'UnzerSDK\\examples\\' => array ( 0 => __DIR__ . '/..' . '/unzerdev/php-sdk/examples', ), - 'UnzerSDK\\' => + 'UnzerSDK\\' => array ( 0 => __DIR__ . '/..' . '/unzerdev/php-sdk/src', ), - 'UnzerPayment6\\' => + 'UnzerPayment6\\' => array ( 0 => __DIR__ . '/../..' . '/src', ), diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 9d5b7188..f98be23f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -2,31 +2,31 @@ "packages": [ { "name": "unzerdev/php-sdk", - "version": "3.13.1", - "version_normalized": "3.13.1.0", + "version": "4.0.1", + "version_normalized": "4.0.1.0", "source": { "type": "git", "url": "https://github.com/unzerdev/php-sdk.git", - "reference": "0a26d70b33185d52e49b06cb500a6e01bb6f1087" + "reference": "a9344b823fbf5374cd49e07ab6352d385578299e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/unzerdev/php-sdk/zipball/0a26d70b33185d52e49b06cb500a6e01bb6f1087", - "reference": "0a26d70b33185d52e49b06cb500a6e01bb6f1087", + "url": "https://api.github.com/repos/unzerdev/php-sdk/zipball/a9344b823fbf5374cd49e07ab6352d385578299e", + "reference": "a9344b823fbf5374cd49e07ab6352d385578299e", "shasum": "" }, "require": { "ext-json": "*", - "php": "~7.4.0|~8.0.0|~8.1.0|~8.2.0|~8.3.0|~8.4.0" + "php": "~8.1.0|~8.2.0|~8.3.0|~8.4.0|~8.5.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", - "phpunit/phpunit": ">6.5 <10.0" + "phpunit/phpunit": "^9.6" }, "suggest": { "ext-curl": "*" }, - "time": "2025-09-23T14:21:50+00:00", + "time": "2026-05-15T13:48:06+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -42,7 +42,7 @@ "description": "This is the php sdk to connect to the Unzer rest API.", "support": { "email": "support@unzer.com", - "source": "https://github.com/unzerdev/php-sdk/tree/3.13.1" + "source": "https://github.com/unzerdev/php-sdk/tree/4.0.1" }, "install-path": "../unzerdev/php-sdk" } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 076835b0..1d9a01df 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,8 +1,8 @@ array( 'name' => 'unzerdev/shopware6', - 'pretty_version' => '6.99.2', - 'version' => '6.99.2.0', + 'pretty_version' => '6.5.8', + 'version' => '6.5.8.0', 'reference' => null, 'type' => 'shopware-platform-plugin', 'install_path' => __DIR__ . '/../../', @@ -17,17 +17,17 @@ ), ), 'unzerdev/php-sdk' => array( - 'pretty_version' => '3.13.1', - 'version' => '3.13.1.0', - 'reference' => '0a26d70b33185d52e49b06cb500a6e01bb6f1087', + 'pretty_version' => '4.0.1', + 'version' => '4.0.1.0', + 'reference' => 'a9344b823fbf5374cd49e07ab6352d385578299e', 'type' => 'library', 'install_path' => __DIR__ . '/../unzerdev/php-sdk', 'aliases' => array(), 'dev_requirement' => false, ), 'unzerdev/shopware6' => array( - 'pretty_version' => '6.99.2', - 'version' => '6.99.2.0', + 'pretty_version' => '6.5.8', + 'version' => '6.5.8.0', 'reference' => null, 'type' => 'shopware-platform-plugin', 'install_path' => __DIR__ . '/../../', diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php index 580fa960..2beb1491 100644 --- a/vendor/composer/platform_check.php +++ b/vendor/composer/platform_check.php @@ -4,8 +4,8 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 70400)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.'; +if (!(PHP_VERSION_ID >= 80100)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.'; } if ($issues) { @@ -19,8 +19,7 @@ echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; } } - trigger_error( - 'Composer detected issues in your platform: ' . implode(' ', $issues), - E_USER_ERROR + throw new \RuntimeException( + 'Composer detected issues in your platform: ' . implode(' ', $issues) ); } diff --git a/vendor/unzerdev/php-sdk/.github/workflows/integration-tests.yml b/vendor/unzerdev/php-sdk/.github/workflows/integration-tests.yml index 3e597070..d1643e6c 100644 --- a/vendor/unzerdev/php-sdk/.github/workflows/integration-tests.yml +++ b/vendor/unzerdev/php-sdk/.github/workflows/integration-tests.yml @@ -5,10 +5,19 @@ on: branches: - 'main' workflow_dispatch: + inputs: + php-version: + description: 'PHP version to run tests on' + required: false + default: '8.1' + type: string jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + checks: write name: integration tests env: UNZER_PAPI_TEST_PRIVATE_KEY_DEFAULT: ${{ secrets.PAPI_PRIVATE_KEY_DEFAULT }} @@ -24,7 +33,8 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: ${{ inputs.php-version || '8.1' }} + ini-values: error_reporting=E_ALL, display_errors=On, display_startup_errors=On - name: Setup Apple Pay test certificate run: mkdir certs - run: echo "$APPLE_PAY_MERCHANT_ID_CERT" > certs/merchant_id.pem @@ -33,4 +43,12 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-progress - name: Run integration tests - run: php ./vendor/bin/phpunit test/integration + run: php ./vendor/bin/phpunit --log-junit test-results/junit.xml test/integration + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: always() + with: + report_paths: 'test-results/junit.xml' + check_name: 'Integration Test Report' + detailed_summary: true + fail_on_failure: true diff --git a/vendor/unzerdev/php-sdk/.github/workflows/unit-tests.yml b/vendor/unzerdev/php-sdk/.github/workflows/unit-tests.yml index 9dc6dbb9..90b28cec 100644 --- a/vendor/unzerdev/php-sdk/.github/workflows/unit-tests.yml +++ b/vendor/unzerdev/php-sdk/.github/workflows/unit-tests.yml @@ -8,9 +8,12 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + checks: write strategy: matrix: - php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] + php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ] name: PHP ${{ matrix.php }} unit tests steps: - uses: actions/checkout@v3 @@ -18,7 +21,16 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + ini-values: error_reporting=E_ALL, display_errors=On, display_startup_errors=On - name: Install dependencies run: composer install --prefer-dist --no-progress - name: Run unit tests - run: php ./vendor/bin/phpunit test/unit + run: php ./vendor/bin/phpunit --log-junit test-results/junit-${{ matrix.php }}.xml test/unit + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: failure() + with: + report_paths: 'test-results/junit-${{ matrix.php }}.xml' + check_name: 'Unit Test Report (PHP ${{ matrix.php }})' + detailed_summary: true + fail_on_failure: true diff --git a/vendor/unzerdev/php-sdk/CHANGELOG.md b/vendor/unzerdev/php-sdk/CHANGELOG.md index 468e50cd..1e63b313 100755 --- a/vendor/unzerdev/php-sdk/CHANGELOG.md +++ b/vendor/unzerdev/php-sdk/CHANGELOG.md @@ -5,6 +5,60 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [4.0.1](https://github.com/unzerdev/php-sdk/compare/4.0.0..4.0.1) + +### Changed + +* `\UnzerSDK\Unzer` can now be initialised with a public key (`s-pub-*` / `p-pub-*`), enabling `fetchConfig()` to be called without a private key. + +## [4.0.0](https://github.com/unzerdev/php-sdk/compare/3.15.0..4.0.0) + +### Added + +* Add `company` field to `\UnzerSDK\Resources\EmbeddedResources\Address` class. +* Add PHP 8.5 to supported versions in `composer.json`. + +### Changed + +* Allow `null` return for `getCompany()` in `\UnzerSDK\Resources\EmbeddedResources\Address`. +* Remove deprecated `curl_close` and `\ReflectionMethod::setAccessible` calls to address PHP 8.5 deprecation warnings. +* Drop support for PHP 7.4 and PHP 8.0. + +### Deprecated + +* Mark `\UnzerSDK\Resources\PaymentTypes\Giropay` as deprecated. + +## [3.15.0](https://github.com/unzerdev/php-sdk/compare/3.14.0..3.15.0) + +### Added + +* Add the SCA (Strong Customer Authentication) transaction type. + * Add class `\UnzerSDK\Resources\TransactionTypes\Sca`. + * Add methods in `\UnzerSDK\Unzer` class: + * `performSca(Sca $sca, $paymentType, $customer = null, ?Metadata $metadata = null, ?Basket $basket = null): Sca` - + Perform an SCA transaction. + * `fetchSca(Sca $sca): Sca` - Fetch an SCA transaction. + * `fetchScaById($payment, string $scaId): Sca` - Fetch an SCA transaction by ID. + * `chargeScaTransaction($payment, Charge $charge, $customer = null, ?Metadata $metadata = null, ?Basket $basket = null): Charge` - + Charge an SCA transaction. + * `authorizeScaTransaction($payment, Authorization $authorization, $customer = null, ?Metadata $metadata = null, ?Basket $basket = null): Authorization` - + Authorize an SCA transaction. + * Add methods in `\UnzerSDK\Resources\Payment` class: + * `getSca(bool $lazy = false): ?Sca` - Get the SCA transaction. + * `setSca(Sca $sca): self` - Set the SCA transaction. + +## [3.14.0](https://github.com/unzerdev/php-sdk/compare/3.13.2..3.14.0) + +### Changed + +* Add `subscriptionAgreement` property for v2 Paypage creation to `\UnzerSDK\Resources\EmbeddedResources\Paypage\Urls` + +## [3.13.2](https://github.com/unzerdev/php-sdk/compare/3.13.1..3.13.2) + +### Changed + +* Added chargeback handling for `fetchResourceFromEvent()` method. + ## [3.13.1](https://github.com/unzerdev/php-sdk/compare/3.13.0..3.13.1) ### Added diff --git a/vendor/unzerdev/php-sdk/composer.json b/vendor/unzerdev/php-sdk/composer.json index 91dee327..7a6a2a7b 100644 --- a/vendor/unzerdev/php-sdk/composer.json +++ b/vendor/unzerdev/php-sdk/composer.json @@ -4,11 +4,11 @@ "minimum-stability": "stable", "license": "Apache-2.0", "require": { - "php": "~7.4.0|~8.0.0|~8.1.0|~8.2.0|~8.3.0|~8.4.0", + "php": "~8.1.0|~8.2.0|~8.3.0|~8.4.0|~8.5.0", "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": ">6.5 <10.0", + "phpunit/phpunit": "^9.6", "friendsofphp/php-cs-fixer": "^3.0" }, "suggest": { diff --git a/vendor/unzerdev/php-sdk/phpunit.xml b/vendor/unzerdev/php-sdk/phpunit.xml index df900576..b89b9dd1 100755 --- a/vendor/unzerdev/php-sdk/phpunit.xml +++ b/vendor/unzerdev/php-sdk/phpunit.xml @@ -7,6 +7,7 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="false" convertWarningsToExceptions="false" + convertDeprecationsToExceptions="true" processIsolation="false" stopOnFailure="false" verbose="true" diff --git a/vendor/unzerdev/php-sdk/src/Adapter/ApplepayAdapter.php b/vendor/unzerdev/php-sdk/src/Adapter/ApplepayAdapter.php index b23a4636..820655cf 100644 --- a/vendor/unzerdev/php-sdk/src/Adapter/ApplepayAdapter.php +++ b/vendor/unzerdev/php-sdk/src/Adapter/ApplepayAdapter.php @@ -42,7 +42,6 @@ public function validateApplePayMerchant( $this->setOption(CURLOPT_POSTFIELDS, $payload); $sessionResponse = $this->execute(); - $this->close(); return $sessionResponse; } @@ -131,14 +130,6 @@ public function execute(): ?string throw new ApplepayMerchantValidationException($errorMessage); } - /** - * @inheritDoc - */ - public function close(): void - { - curl_close($this->request); - } - /** * @inheritDoc */ diff --git a/vendor/unzerdev/php-sdk/src/Adapter/CurlAdapter.php b/vendor/unzerdev/php-sdk/src/Adapter/CurlAdapter.php index 5535eb40..43a781ee 100755 --- a/vendor/unzerdev/php-sdk/src/Adapter/CurlAdapter.php +++ b/vendor/unzerdev/php-sdk/src/Adapter/CurlAdapter.php @@ -95,14 +95,6 @@ public function getResponseCode(): string return curl_getinfo($this->request, CURLINFO_HTTP_CODE); } - /** - * {@inheritDoc} - */ - public function close(): void - { - curl_close($this->request); - } - /** * {@inheritDoc} */ diff --git a/vendor/unzerdev/php-sdk/src/Adapter/HttpAdapterInterface.php b/vendor/unzerdev/php-sdk/src/Adapter/HttpAdapterInterface.php index 2e2bd0a6..be80576c 100755 --- a/vendor/unzerdev/php-sdk/src/Adapter/HttpAdapterInterface.php +++ b/vendor/unzerdev/php-sdk/src/Adapter/HttpAdapterInterface.php @@ -43,11 +43,6 @@ public function execute(): ?string; */ public function getResponseCode(): string; - /** - * Closes the connection of the request. - */ - public function close(): void; - /** * Sets the headers for the request. * Expects an associative array with $key being the header name and $value being the header value. diff --git a/vendor/unzerdev/php-sdk/src/Constants/ApiResponseCodes.php b/vendor/unzerdev/php-sdk/src/Constants/ApiResponseCodes.php index 38c943ff..c25d8aa2 100755 --- a/vendor/unzerdev/php-sdk/src/Constants/ApiResponseCodes.php +++ b/vendor/unzerdev/php-sdk/src/Constants/ApiResponseCodes.php @@ -41,6 +41,7 @@ class ApiResponseCodes public const API_ERROR_CUSTOMER_DOES_NOT_EXIST = 'API.410.100.100'; public const API_ERROR_CUSTOMER_ID_ALREADY_EXISTS = 'API.410.200.010'; public const API_ERROR_ADDRESS_NAME_TO_LONG = 'API.410.200.031'; + public const API_CANNOT_CHARGE_UNSUCCESSFUL_SCA_TRANSACTION = 'API.500.100.060'; public const API_ERROR_CUSTOMER_CAN_NOT_BE_FOUND = 'API.500.100.100'; public const API_ERROR_REQUEST_DATA_IS_INVALID = 'API.500.300.999'; public const API_ERROR_RECURRING_PAYMENT_NOT_SUPPORTED = 'API.500.550.004'; diff --git a/vendor/unzerdev/php-sdk/src/Constants/IdStrings.php b/vendor/unzerdev/php-sdk/src/Constants/IdStrings.php index 662c9ea9..4634335b 100755 --- a/vendor/unzerdev/php-sdk/src/Constants/IdStrings.php +++ b/vendor/unzerdev/php-sdk/src/Constants/IdStrings.php @@ -16,6 +16,7 @@ class IdStrings public const CHARGEBACK = 'cbk'; public const PAYOUT = 'out'; public const PREAUTHORIZE = 'preaut'; + public const SCA = 'sca'; public const SHIPMENT = 'shp'; // Payment Types diff --git a/vendor/unzerdev/php-sdk/src/Constants/TransactionTypes.php b/vendor/unzerdev/php-sdk/src/Constants/TransactionTypes.php index 3a4721b1..e2ce38a0 100755 --- a/vendor/unzerdev/php-sdk/src/Constants/TransactionTypes.php +++ b/vendor/unzerdev/php-sdk/src/Constants/TransactionTypes.php @@ -18,4 +18,5 @@ class TransactionTypes public const SHIPMENT = 'shipment'; public const PAYOUT = 'payout'; public const CHARGEBACK = 'chargeback'; + public const SCA = 'strong_customer_authentication'; } diff --git a/vendor/unzerdev/php-sdk/src/Interfaces/PaymentServiceInterface.php b/vendor/unzerdev/php-sdk/src/Interfaces/PaymentServiceInterface.php index d4613979..ad05a505 100644 --- a/vendor/unzerdev/php-sdk/src/Interfaces/PaymentServiceInterface.php +++ b/vendor/unzerdev/php-sdk/src/Interfaces/PaymentServiceInterface.php @@ -24,6 +24,7 @@ use UnzerSDK\Resources\TransactionTypes\Authorization; use UnzerSDK\Resources\TransactionTypes\Charge; use UnzerSDK\Resources\TransactionTypes\Payout; +use UnzerSDK\Resources\TransactionTypes\Sca; use UnzerSDK\Resources\TransactionTypes\Shipment; interface PaymentServiceInterface @@ -389,4 +390,20 @@ public function fetchInstallmentPlans( * @return PaylaterInstallmentPlans */ public function fetchPaylaterInstallmentPlans(InstallmentPlansQuery $plansRequest): PaylaterInstallmentPlans; + + /** + * Perform an SCA transaction. + * + * @param Sca $sca The SCA object. + * @param BasePaymentType|string $paymentType The payment type object or ID. + * @param Customer|string|null $customer The customer object or ID. + * @param Metadata|null $metadata The metadata object. + * @param Basket|null $basket The basket object. + * + * @return Sca The resulting SCA object. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + public function performSca(Sca $sca, $paymentType, $customer = null, ?Metadata $metadata = null, ?Basket $basket = null): Sca; } diff --git a/vendor/unzerdev/php-sdk/src/Interfaces/ResourceServiceInterface.php b/vendor/unzerdev/php-sdk/src/Interfaces/ResourceServiceInterface.php index 6f26b0ad..22c752c3 100644 --- a/vendor/unzerdev/php-sdk/src/Interfaces/ResourceServiceInterface.php +++ b/vendor/unzerdev/php-sdk/src/Interfaces/ResourceServiceInterface.php @@ -25,6 +25,7 @@ use UnzerSDK\Resources\TransactionTypes\Charge; use UnzerSDK\Resources\TransactionTypes\Chargeback; use UnzerSDK\Resources\TransactionTypes\Payout; +use UnzerSDK\Resources\TransactionTypes\Sca; use UnzerSDK\Resources\TransactionTypes\Shipment; interface ResourceServiceInterface @@ -452,4 +453,29 @@ public function fetchShipment($payment, string $shipmentId): Shipment; * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function fetchConfig(BasePaymentType $paymentType, ?Config $config = null): Config; + + /** + * Fetches an SCA transaction. + * + * @param Sca $sca The SCA object to fetch. + * + * @return Sca The fetched SCA object. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + public function fetchSca(Sca $sca): Sca; + + /** + * Fetches an SCA transaction by payment ID and SCA ID. + * + * @param Payment|string $payment The payment object or payment ID. + * @param string $scaId The SCA transaction ID. + * + * @return Sca The fetched SCA object. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + public function fetchScaById($payment, string $scaId): Sca; } diff --git a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Address.php b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Address.php index 48e3b6f5..a86a76eb 100755 --- a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Address.php +++ b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Address.php @@ -30,6 +30,9 @@ class Address extends AbstractUnzerResource /** @var string country */ protected $country; + /** @var string company */ + protected $company; + /** @var string|null shippingType */ protected $shippingType; @@ -165,4 +168,15 @@ public function setShippingType(?string $shippingType): Address $this->shippingType = $shippingType; return $this; } + + public function getCompany(): ?string + { + return $this->company; + } + + public function setCompany(?string $company): Address + { + $this->company = $company; + return $this; + } } diff --git a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/Urls.php b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/Urls.php index 5437d33d..5796b00b 100644 --- a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/Urls.php +++ b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/Urls.php @@ -11,11 +11,15 @@ class Urls extends AbstractUnzerResource protected ?string $imprint = null; protected ?string $help = null; protected ?string $contact = null; + /** @deprecated Use Style::$favicon instead. + * @see Style::$favicon + */ protected ?string $favicon = null; protected ?string $returnSuccess = null; protected ?string $returnPending = null; protected ?string $returnFailure = null; protected ?string $returnCancel = null; + protected ?string $subscriptionAgreement = null; public function getTermsAndCondition(): ?string { @@ -126,4 +130,15 @@ public function setReturnCancel(?string $returnCancel): Urls $this->returnCancel = $returnCancel; return $this; } + + public function getSubscriptionAgreement(): ?string + { + return $this->subscriptionAgreement; + } + + public function setSubscriptionAgreement(?string $subscriptionAgreement): Urls + { + $this->subscriptionAgreement = $subscriptionAgreement; + return $this; + } } \ No newline at end of file diff --git a/vendor/unzerdev/php-sdk/src/Resources/Payment.php b/vendor/unzerdev/php-sdk/src/Resources/Payment.php index 4a75656b..80c49a1f 100755 --- a/vendor/unzerdev/php-sdk/src/Resources/Payment.php +++ b/vendor/unzerdev/php-sdk/src/Resources/Payment.php @@ -19,6 +19,7 @@ use UnzerSDK\Resources\TransactionTypes\Chargeback; use UnzerSDK\Resources\TransactionTypes\Payout; use UnzerSDK\Resources\TransactionTypes\PreAuthorization; +use UnzerSDK\Resources\TransactionTypes\Sca; use UnzerSDK\Resources\TransactionTypes\Shipment; use UnzerSDK\Services\IdService; use UnzerSDK\Traits\HasInvoiceId; @@ -58,6 +59,9 @@ class Payment extends AbstractUnzerResource /** @var Chargeback[] $chargebacks */ private $chargebacks = []; + /** @var Sca|null $sca */ + private $sca; + /** * Associative array using the ID of the cancellations as the key. @@ -337,6 +341,33 @@ public function getChargeByIndex(int $index, bool $lazy = false) return $resource; } + /** + * Returns the SCA transaction of this Payment. + */ + public function getSca(bool $lazy = false): ?Sca + { + $sca = $this->sca; + if (!$lazy && $sca !== null) { + /** @var Sca */ + return $this->getResource($sca); + } + return $sca; + } + + /** + * Adds an SCA object to this Payment. + * + * @param Sca $sca + * + * @return $this + */ + public function setSca(Sca $sca): self + { + $sca->setPayment($this); + $this->sca = $sca; + return $this; + } + /** * Reference this payment object to the passed Customer resource. * The Customer resource can be passed as Customer object or the Id of a Customer resource. @@ -924,6 +955,9 @@ private function updateResponseTransactions(array $transactions = []): void case TransactionTypes::CHARGEBACK: $this->updateChargebackTransaction($transaction); break; + case TransactionTypes::SCA: + $this->updateScaTransaction($transaction); + break; default: // skip break; @@ -1191,4 +1225,25 @@ private function updateChargebackTransaction(stdClass $transaction): void $chargeback->handleResponse($transaction); } + + /** + * This updates the local SCA object referenced by this Payment with the given SCA transaction + * from the Payment response. + * + * @param stdClass $transaction The transaction from the Payment response containing the SCA data. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + private function updateScaTransaction(stdClass $transaction): void + { + $transactionId = IdService::getResourceIdFromUrl($transaction->url, IdStrings::SCA); + $sca = $this->sca; + if (!$sca instanceof Sca) { + $sca = (new Sca())->setPayment($this)->setId($transactionId); + $this->setSca($sca); + } + + $sca->handleResponse($transaction); + } } diff --git a/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/Giropay.php b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/Giropay.php index 9d2a6f26..975fea63 100755 --- a/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/Giropay.php +++ b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/Giropay.php @@ -4,6 +4,7 @@ use UnzerSDK\Traits\CanDirectCharge; +/** @deprecated Giropay payment type is no longer supported and will be removed in a future version. */ class Giropay extends BasePaymentType { use CanDirectCharge; diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/AbstractTransactionType.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/AbstractTransactionType.php index 70bd0802..c15adfec 100755 --- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/AbstractTransactionType.php +++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/AbstractTransactionType.php @@ -39,6 +39,9 @@ abstract class AbstractTransactionType extends AbstractUnzerResource use HasAdditionalTransactionData; use HasDate; + /** @var float $amount */ + protected $amount; + /** @var Payment $payment */ private $payment; @@ -242,4 +245,23 @@ protected function handleWeroTransactionData(stdClass $additionalTransactionData $this->setWeroTransactionData($weroTransactionData); } } + + /** + * @param float|null $amount + * + * @return self + */ + public function setAmount(?float $amount): self + { + $this->amount = $amount !== null ? round($amount, 4) : null; + return $this; + } + + /** + * @return float|null + */ + public function getAmount(): ?float + { + return $this->amount; + } } diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Authorization.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Authorization.php index 6936b8b8..4df8d113 100755 --- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Authorization.php +++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Authorization.php @@ -62,25 +62,6 @@ public function __construct(?float $amount = null, ?string $currency = null, ?st $this->setReturnUrl($returnUrl); } - /** - * @return float|null - */ - public function getAmount(): ?float - { - return $this->amount; - } - - /** - * @param float|null $amount - * - * @return self - */ - public function setAmount(?float $amount): self - { - $this->amount = $amount !== null ? round($amount, 4) : null; - return $this; - } - /** * @return float|null */ diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Cancellation.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Cancellation.php index ad41d1c2..51f0d86e 100755 --- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Cancellation.php +++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Cancellation.php @@ -16,13 +16,6 @@ */ class Cancellation extends AbstractTransactionType { - /** - * The cancellation amount will be transferred as grossAmount in case of Installment Secured payment type. - * - * @var float $amount - */ - protected $amount; - /** @var string $reasonCode */ protected $reasonCode; @@ -53,29 +46,6 @@ public function __construct(?float $amount = null) $this->setAmount($amount); } - /** - * Returns the cancellationAmount (equals grossAmount in case of Installment Secured). - * - * @return float|null - */ - public function getAmount(): ?float - { - return $this->amount; - } - - /** - * Sets the cancellationAmount (equals grossAmount in case of Installment Secured). - * - * @param float|null $amount - * - * @return Cancellation - */ - public function setAmount(?float $amount): self - { - $this->amount = $amount !== null ? round($amount, 4) : null; - return $this; - } - /** * Returns the reason code of the cancellation if set. * diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Charge.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Charge.php index 278cc9c3..338bca79 100755 --- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Charge.php +++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Charge.php @@ -25,9 +25,6 @@ class Charge extends AbstractTransactionType use HasDescriptor; use HasChargebacks; - /** @var float $amount */ - protected $amount; - /** @var string $currency */ protected $currency; @@ -54,25 +51,6 @@ public function __construct(?float $amount = null, ?string $currency = null, ?st $this->setReturnUrl($returnUrl); } - /** - * @return float|null - */ - public function getAmount(): ?float - { - return $this->amount; - } - - /** - * @param float|null $amount - * - * @return self - */ - public function setAmount(?float $amount): self - { - $this->amount = $amount !== null ? round($amount, 4) : null; - return $this; - } - /** * @return float|null */ diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Chargeback.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Chargeback.php index 2ef22d03..607ebe7a 100644 --- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Chargeback.php +++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Chargeback.php @@ -12,9 +12,6 @@ */ class Chargeback extends AbstractTransactionType { - /** @var float $amount */ - protected $amount; - /** @var string $currency */ protected $currency; @@ -29,27 +26,6 @@ public function __construct(?float $amount = null) $this->setAmount($amount); } - /** - * @return float|null - */ - public function getAmount(): ?float - { - return $this->amount; - } - - /** - * Sets the cancellationAmount (equals grossAmount in case of Installment Secured). - * - * @param float|null $amount - * - * @return Cancellation - */ - public function setAmount(?float $amount): self - { - $this->amount = $amount !== null ? round($amount, 4) : null; - return $this; - } - /** * @return string */ diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Payout.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Payout.php index 15f0767c..2f39d5a0 100644 --- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Payout.php +++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Payout.php @@ -12,9 +12,6 @@ */ class Payout extends AbstractTransactionType { - /** @var float|null $amount */ - protected $amount; - /** @var string|null $currency */ protected $currency; @@ -31,25 +28,6 @@ public function __construct(?float $amount = null, ?string $currency = null, $re $this->setReturnUrl($returnUrl); } - /** - * @return float|null - */ - public function getAmount(): ?float - { - return $this->amount; - } - - /** - * @param float|null $amount - * - * @return self - */ - public function setAmount(?float $amount): self - { - $this->amount = $amount !== null ? round($amount, 4) : null; - return $this; - } - /** * @return string|null */ diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Sca.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Sca.php new file mode 100644 index 00000000..b9119d7b --- /dev/null +++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Sca.php @@ -0,0 +1,107 @@ +setAmount($amount); + $this->setCurrency($currency); + $this->setReturnUrl($returnUrl); + } + + /** + * @return string|null + */ + public function getCurrency(): ?string + { + return $this->currency; + } + + /** + * @param string|null $currency + * + * @return self + */ + public function setCurrency(?string $currency): self + { + $this->currency = $currency; + return $this; + } + + /** + * @return string|null + */ + public function getReturnUrl(): ?string + { + return $this->returnUrl; + } + + /** + * @param string|null $returnUrl + * + * @return self + */ + public function setReturnUrl(?string $returnUrl): self + { + $this->returnUrl = $returnUrl; + return $this; + } + + /** + * @return string|null + */ + public function getPaymentReference(): ?string + { + return $this->paymentReference; + } + + /** + * @param string|null $referenceText + * + * @return Sca + */ + public function setPaymentReference(?string $referenceText): Sca + { + $this->paymentReference = $referenceText; + return $this; + } + + /** + * {@inheritDoc} + */ + protected function getResourcePath(string $httpMethod = HttpAdapterInterface::REQUEST_GET): string + { + return 'sca'; + } +} diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Shipment.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Shipment.php index 55dfbc7d..d29e09cc 100755 --- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Shipment.php +++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Shipment.php @@ -12,28 +12,6 @@ */ class Shipment extends AbstractTransactionType { - /** @var float|null $amount */ - protected $amount; - - /** - * @return float|null - */ - public function getAmount(): ?float - { - return $this->amount; - } - - /** - * @param float|null $amount - * - * @return Shipment - */ - public function setAmount(?float $amount): self - { - $this->amount = $amount !== null ? round($amount, 4) : null; - return $this; - } - /** * {@inheritDoc} */ diff --git a/vendor/unzerdev/php-sdk/src/Services/HttpService.php b/vendor/unzerdev/php-sdk/src/Services/HttpService.php index cce644cb..68bcdc0c 100755 --- a/vendor/unzerdev/php-sdk/src/Services/HttpService.php +++ b/vendor/unzerdev/php-sdk/src/Services/HttpService.php @@ -135,7 +135,6 @@ public function sendRequest(ApiRequest $request): string $httpAdapter = $this->getAdapter(); $response = $httpAdapter->execute(); $responseCode = $httpAdapter->getResponseCode(); - $httpAdapter->close(); // handle response try { diff --git a/vendor/unzerdev/php-sdk/src/Services/PaymentService.php b/vendor/unzerdev/php-sdk/src/Services/PaymentService.php index 8eefc359..e05dd4cc 100755 --- a/vendor/unzerdev/php-sdk/src/Services/PaymentService.php +++ b/vendor/unzerdev/php-sdk/src/Services/PaymentService.php @@ -22,6 +22,7 @@ use UnzerSDK\Resources\TransactionTypes\Authorization; use UnzerSDK\Resources\TransactionTypes\Charge; use UnzerSDK\Resources\TransactionTypes\Payout; +use UnzerSDK\Resources\TransactionTypes\Sca; use UnzerSDK\Resources\TransactionTypes\Shipment; use UnzerSDK\Unzer; @@ -87,7 +88,10 @@ public function performAuthorization( $paymentType = $payment->getPaymentType(); $authorization->setSpecialParams($paymentType !== null ? $paymentType->getTransactionParams() : []); - $payment->setAuthorization($authorization)->setCustomer($customer)->setMetadata($metadata)->setBasket($basket); + $payment->setAuthorization($authorization) + ->setCustomer($customer) + ->setMetadata($metadata) + ->setBasket($basket); $this->getResourceService()->createResource($authorization); return $authorization; @@ -392,4 +396,32 @@ private function createPayment($paymentType): AbstractUnzerResource { return (new Payment($this->unzer))->setPaymentType($paymentType); } + + /** + * Perform an SCA transaction. + * + * @param Sca $sca The SCA object to be executed. + * @param BasePaymentType|string $paymentType The payment type object or its ID. + * @param Customer|string|null $customer The customer object or ID. + * @param Metadata|null $metadata The metadata object. + * @param Basket|null $basket The basket object. + * + * @return Sca The resulting SCA object. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + public function performSca(Sca $sca, $paymentType, $customer = null, ?Metadata $metadata = null, ?Basket $basket = null): Sca + { + $payment = $this->createPayment($paymentType); + $paymentType = $payment->getPaymentType(); + + /** @var Sca $sca */ + $sca->setSpecialParams($paymentType->getTransactionParams() ?? []); + $payment->setSca($sca)->setCustomer($customer)->setMetadata($metadata)->setBasket($basket); + + $this->getResourceService()->createResource($sca); + + return $sca; + } } diff --git a/vendor/unzerdev/php-sdk/src/Services/ResourceService.php b/vendor/unzerdev/php-sdk/src/Services/ResourceService.php index b4bedfe1..90b09578 100755 --- a/vendor/unzerdev/php-sdk/src/Services/ResourceService.php +++ b/vendor/unzerdev/php-sdk/src/Services/ResourceService.php @@ -59,6 +59,7 @@ use UnzerSDK\Resources\TransactionTypes\Charge; use UnzerSDK\Resources\TransactionTypes\Chargeback; use UnzerSDK\Resources\TransactionTypes\Payout; +use UnzerSDK\Resources\TransactionTypes\Sca; use UnzerSDK\Resources\TransactionTypes\Shipment; use UnzerSDK\Resources\V2\Customer as CustomerV2; use UnzerSDK\Resources\V2\Paypage as PaypageV2; @@ -209,9 +210,25 @@ public function fetchResourceByUrl($url) } $resource = $unzer->fetchReversal($paymentId, $resourceId); break; + case $resourceType === IdStrings::CHARGEBACK: + $paymentId = IdService::getResourceIdFromUrl($url, IdStrings::PAYMENT); + $chargeId = IdService::getResourceIdOrNullFromUrl($url, IdStrings::CHARGE); + + $resource = $this->fetchChargebackById( + $paymentId, + $resourceId, + $chargeId + ); + break; case $resourceType === IdStrings::PAYOUT: $resource = $unzer->fetchPayout(IdService::getResourceIdFromUrl($url, IdStrings::PAYMENT)); break; + case $resourceType === IdStrings::SCA: + $resource = $unzer->fetchScaById( + IdService::getResourceIdFromUrl($url, IdStrings::PAYMENT), + $resourceId + ); + break; case $resourceType === IdStrings::PAYMENT: $resource = $unzer->fetchPayment($resourceId); break; @@ -970,4 +987,44 @@ public static function getTypeInstanceFromIdString($typeId): BasePaymentType } return $paymentType; } + + /** + * Fetches an SCA transaction. + * + * @param Sca $sca The SCA object to fetch. + * + * @return Sca The fetched SCA object. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + public function fetchSca(Sca $sca): Sca + { + $this->fetchResource($sca); + return $sca; + } + + /** + * Fetches an SCA transaction by payment ID and SCA ID. + * + * @param Payment|string $payment The payment object or payment ID. + * @param string $scaId The SCA transaction ID. + * + * @return Sca The fetched SCA object. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + public function fetchScaById($payment, string $scaId): Sca + { + $paymentObject = $this->fetchPayment($payment); + $sca = $paymentObject->getSca($scaId, true); + + if (!$sca instanceof Sca) { + throw new RuntimeException('The SCA object could not be found.'); + } + + $this->fetchResource($sca); + return $sca; + } } diff --git a/vendor/unzerdev/php-sdk/src/Unzer.php b/vendor/unzerdev/php-sdk/src/Unzer.php index b4dc186e..b34caf17 100644 --- a/vendor/unzerdev/php-sdk/src/Unzer.php +++ b/vendor/unzerdev/php-sdk/src/Unzer.php @@ -33,6 +33,7 @@ use UnzerSDK\Resources\TransactionTypes\Charge; use UnzerSDK\Resources\TransactionTypes\Chargeback; use UnzerSDK\Resources\TransactionTypes\Payout; +use UnzerSDK\Resources\TransactionTypes\Sca; use UnzerSDK\Resources\TransactionTypes\Shipment; use UnzerSDK\Resources\V2\Paypage as PaypageV2; use UnzerSDK\Resources\Webhook; @@ -43,6 +44,7 @@ use UnzerSDK\Services\ResourceService; use UnzerSDK\Services\WebhookService; use UnzerSDK\Validators\PrivateKeyValidator; +use UnzerSDK\Validators\PublicKeyValidator; /** * This is the Unzer object which is the base object providing all functionalities needed to @@ -58,7 +60,7 @@ class Unzer implements public const BASE_URL = 'api.unzer.com'; public const API_VERSION = ApiVersions::V1; public const SDK_TYPE = 'UnzerPHP'; - public const SDK_VERSION = '3.13.1'; + public const SDK_VERSION = '4.0.1'; /** @var string $key */ private $key; @@ -94,10 +96,10 @@ class Unzer implements /** * Construct a new Unzer object. * - * @param string $key The private key your received from your Unzer contact person. + * @param string $key The private or public key your received from your Unzer contact person. * @param string|null $locale The locale of the customer defining defining the translation (e.g. 'en-GB' or 'de-DE'). * - * @throws RuntimeException A RuntimeException will be thrown if the key is not of type private. + * @throws RuntimeException A RuntimeException will be thrown if the key is not a valid private or public key. * * @link https://docs.unzer.com/integrate/web-integration/#section-localization-and-languages * @@ -115,7 +117,7 @@ public function __construct(string $key, ?string $locale = '') } /** - * Returns the set private key used to connect to the API. + * Returns the set key used to connect to the API. * * @return string The key that is currently set. */ @@ -125,9 +127,9 @@ public function getKey(): string } /** - * Sets your private key used to connect to the API. + * Sets your private or public key used to connect to the API. * - * @param string $key The private key. + * @param string $key The private or public key. * * @return Unzer This Unzer object. * @@ -137,8 +139,8 @@ public function getKey(): string */ public function setKey(string $key): Unzer { - if (!PrivateKeyValidator::validate($key)) { - throw new RuntimeException('Illegal key: Use a valid private key with this SDK!'); + if (!PrivateKeyValidator::validate($key) && !PublicKeyValidator::validate($key)) { + throw new RuntimeException('Illegal key: Use a valid private or public key with this SDK!'); } $this->key = $key; @@ -812,6 +814,146 @@ public function performChargeOnPayment($payment, Charge $charge): Charge return $this->paymentService->performChargeOnPayment($payment, $charge); } + /** + * Perform an SCA transaction. + * + * @param Sca $sca The SCA object. + * @param BasePaymentType|string $paymentType The payment type object or ID. + * @param Customer|string|null $customer The customer object or ID. + * @param Metadata|null $metadata The metadata object. + * @param Basket|null $basket The basket object. + * + * @return Sca The resulting SCA object. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + public function performSca(Sca $sca, $paymentType, $customer = null, ?Metadata $metadata = null, ?Basket $basket = null): Sca + { + return $this->paymentService->performSca($sca, $paymentType, $customer, $metadata, $basket); + } + + /** + * Fetch an SCA transaction. + * + * @param Sca $sca The SCA object to fetch. + * + * @return Sca The fetched SCA object. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + public function fetchSca(Sca $sca): Sca + { + return $this->resourceService->fetchSca($sca); + } + + /** + * Fetch an SCA transaction by payment ID and SCA ID. + * + * @param Payment|string $payment The payment object or payment ID. + * @param string $scaId The SCA transaction ID. + * + * @return Sca The fetched SCA object. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + public function fetchScaById($payment, string $scaId): Sca + { + return $this->resourceService->fetchScaById($payment, $scaId); + } + + /** + * Charge an SCA transaction. + * + * @param Payment|string $payment The payment object or payment ID. + * @param Charge $charge The Charge object to process. + * @param Customer|string|null $customer The customer object or customer ID. + * @param Metadata|null $metadata The metadata object. + * @param Basket|null $basket The basket object. + * + * @return Charge The resulting Charge object. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + public function chargeScaTransaction( + $payment, + Charge $charge, + $customer = null, + ?Metadata $metadata = null, + ?Basket $basket = null): Charge + { + $paymentObject = $this->resourceService->getPaymentResource($payment); + $sca = $paymentObject->getSca(true); + + if (!$sca instanceof Sca) { + throw new RuntimeException('SCA transaction not found.'); + } + + // Set Sca object without id as a parent to match the URI path. + $scaParent = new Sca(); + $scaParent->setParentResource($paymentObject); + + $paymentObject->addCharge($charge) + ->setCustomer($customer) + ->setMetadata($metadata) + ->setBasket($basket); + + $charge->setPayment($paymentObject); + $charge->setParentResource($scaParent); + + $this->resourceService->createResource($charge); + + return $charge; + } + + /** + * Authorize an SCA transaction. + * + * @param Payment|string $payment The payment object or payment ID. + * @param Authorization $authorization The Authorization object to process. + * @param Customer|string|null $customer The customer object or customer ID. + * @param Metadata|null $metadata The metadata object. + * @param Basket|null $basket The basket object. + * + * @return Authorization The resulting Authorization object. + * + * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. + * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + */ + public function authorizeScaTransaction( + $payment, + Authorization $authorization, + $customer = null, + ?Metadata $metadata = null, + ?Basket $basket = null): Authorization + { + $paymentObject = $this->resourceService->getPaymentResource($payment); + $sca = $paymentObject->getSca(true); + + if (!$sca instanceof Sca) { + throw new RuntimeException('SCA transaction not found.'); + } + + // Set Sca object without id as a parent to match the URI path. + $scaParent = new Sca(); + $scaParent->setParentResource($paymentObject); + + $paymentObject->setAuthorization($authorization) + ->setCustomer($customer) + ->setMetadata($metadata) + ->setBasket($basket); + + $authorization->setPayment($paymentObject); + $authorization->setParentResource($scaParent); + + $this->resourceService->createResource($authorization); + + return $authorization; + } + /** * {@inheritDoc} */ diff --git a/vendor/unzerdev/php-sdk/test/Fixtures/CustomerFixtureTrait.php b/vendor/unzerdev/php-sdk/test/Fixtures/CustomerFixtureTrait.php index 6055e81b..5fe4ca2c 100755 --- a/vendor/unzerdev/php-sdk/test/Fixtures/CustomerFixtureTrait.php +++ b/vendor/unzerdev/php-sdk/test/Fixtures/CustomerFixtureTrait.php @@ -153,6 +153,7 @@ public function getBillingAddress(): Address ->setZip('60386') ->setCity('Frankfurt am Main') ->setCountry('DE') + ->setCompany('Your Company Name') ->setState('DE-BO'); } @@ -170,6 +171,7 @@ public function getShippingAddress(): Address ->setCity('Frankfurt am Main') ->setCountry('DE') ->setState('DE-BO') + ->setCompany('Your Company Name') ->setShippingType(ShippingTypes::EQUALS_BILLING); } } diff --git a/vendor/unzerdev/php-sdk/test/Fixtures/jsonData/scaPaymentResponse.json b/vendor/unzerdev/php-sdk/test/Fixtures/jsonData/scaPaymentResponse.json new file mode 100644 index 00000000..f897f5a6 --- /dev/null +++ b/vendor/unzerdev/php-sdk/test/Fixtures/jsonData/scaPaymentResponse.json @@ -0,0 +1,33 @@ +{ + "id": "s-sca-1", + "isSuccess": true, + "isPending": false, + "isResumed": false, + "isError": false, + "card3ds": true, + "redirectUrl": "", + "message": { + "code": "COR.000.100.200", + "merchant": "Transaction succeeded", + "customer": "Your payments have been successfully processed." + }, + "amount": "119.0000", + "currency": "EUR", + "date": "2023-02-28 08:00:00", + "resources": { + "customerId": "", + "paymentId": "s-pay-123", + "basketId": "", + "metadataId": "", + "payPageId": "", + "traceId": "trace-123", + "typeId": "s-crd-123" + }, + "paymentReference": "", + "processing": { + "uniqueId": "31HA0xyz", + "shortId": "1234.1234.1234", + "3dsEci": "3DS_SUCCESS", + "traceId": "trace-123" + } +} \ No newline at end of file diff --git a/vendor/unzerdev/php-sdk/test/Fixtures/jsonData/scaResponse.json b/vendor/unzerdev/php-sdk/test/Fixtures/jsonData/scaResponse.json new file mode 100644 index 00000000..f897f5a6 --- /dev/null +++ b/vendor/unzerdev/php-sdk/test/Fixtures/jsonData/scaResponse.json @@ -0,0 +1,33 @@ +{ + "id": "s-sca-1", + "isSuccess": true, + "isPending": false, + "isResumed": false, + "isError": false, + "card3ds": true, + "redirectUrl": "", + "message": { + "code": "COR.000.100.200", + "merchant": "Transaction succeeded", + "customer": "Your payments have been successfully processed." + }, + "amount": "119.0000", + "currency": "EUR", + "date": "2023-02-28 08:00:00", + "resources": { + "customerId": "", + "paymentId": "s-pay-123", + "basketId": "", + "metadataId": "", + "payPageId": "", + "traceId": "trace-123", + "typeId": "s-crd-123" + }, + "paymentReference": "", + "processing": { + "uniqueId": "31HA0xyz", + "shortId": "1234.1234.1234", + "3dsEci": "3DS_SUCCESS", + "traceId": "trace-123" + } +} \ No newline at end of file diff --git a/vendor/unzerdev/php-sdk/test/Helper/TestEnvironmentService.php b/vendor/unzerdev/php-sdk/test/Helper/TestEnvironmentService.php index 755eaa54..52674756 100644 --- a/vendor/unzerdev/php-sdk/test/Helper/TestEnvironmentService.php +++ b/vendor/unzerdev/php-sdk/test/Helper/TestEnvironmentService.php @@ -16,6 +16,10 @@ class TestEnvironmentService extends EnvironmentService public const ENV_VAR_TEST_PRIVATE_KEY_DEFAULT = 'UNZER_PAPI_TEST_PRIVATE_KEY_DEFAULT'; public const ENV_VAR_TEST_PUBLIC_KEY_DEFAULT = 'UNZER_PAPI_TEST_PUBLIC_KEY_DEFAULT'; + /** Primary testing Keypair used as default for most payment types. */ + public const ENV_VAR_TEST_PRIVATE_KEY_UNZER_ONE = 'UNZER_PAPI_TEST_PRIVATE_KEY_UNZER_ONE'; + public const ENV_VAR_TEST_PUBLIC_KEY_UNZER_ONE = 'UNZER_PAPI_TEST_PUBLIC_KEY_UNZER_ONE'; + /** Secondary keypair mainly used for payment methods that need a second configuration to be tested. */ public const ENV_VAR_TEST_PRIVATE_KEY_ALTERNATIVE = 'UNZER_PAPI_TEST_PRIVATE_KEY_ALTERNATIVE'; public const ENV_VAR_TEST_PUBLIC_KEY_ALTERNATIVE = 'UNZER_PAPI_TEST_PUBLIC_KEY_ALTERNATIVE'; @@ -106,4 +110,9 @@ public static function getLegacyTestPrivateKey(): string { return stripslashes($_SERVER[self::ENV_VAR_TEST_PRIVATE_KEY_LEGACY] ?? ''); } + + public static function getUnzerOneTestPrivateKey(): string + { + return stripslashes($_SERVER[self::ENV_VAR_TEST_PRIVATE_KEY_UNZER_ONE] ?? ''); + } } diff --git a/vendor/unzerdev/php-sdk/test/integration/PaymentTypes/GiropayTest.php b/vendor/unzerdev/php-sdk/test/integration/PaymentTypes/GiropayTest.php deleted file mode 100755 index c6b53510..00000000 --- a/vendor/unzerdev/php-sdk/test/integration/PaymentTypes/GiropayTest.php +++ /dev/null @@ -1,79 +0,0 @@ -unzer->createPaymentType($giropay); - $this->assertInstanceOf(Giropay::class, $giropay); - $this->assertNotNull($giropay->getId()); - } - - /** - * Verify that an exception is thrown when giropay authorize is called. - * - * @test - */ - public function giroPayShouldThrowExceptionOnAuthorize(): void - { - $this->expectException(UnzerApiException::class); - $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); - - $giropay = $this->unzer->createPaymentType(new Giropay()); - $this->unzer->authorize(1.0, 'EUR', $giropay, self::RETURN_URL); - } - - /** - * Verify that GiroPay is chargeable. - * - * @test - */ - public function giroPayShouldBeChargeable(): void - { - /** @var Giropay $giropay */ - $giropay = $this->unzer->createPaymentType(new Giropay()); - $charge = $giropay->charge(1.0, 'EUR', self::RETURN_URL); - $this->assertNotNull($charge); - $this->assertNotNull($charge->getId()); - $this->assertNotEmpty($charge->getRedirectUrl()); - - $fetchCharge = $this->unzer->fetchChargeById($charge->getPayment()->getId(), $charge->getId()); - $this->assertEquals($charge->setCard3ds(false)->expose(), $fetchCharge->expose()); - } - - /** - * Verify a GiroPay object can be fetched from the api. - * - * @test - */ - public function giroPayCanBeFetched(): void - { - $giropay = $this->unzer->createPaymentType(new Giropay()); - $fetchedGiropay = $this->unzer->fetchPaymentType($giropay->getId()); - $this->assertInstanceOf(Giropay::class, $fetchedGiropay); - $this->assertEquals($giropay->getId(), $fetchedGiropay->getId()); - } -} diff --git a/vendor/unzerdev/php-sdk/test/integration/Resources/PaypageV2Test.php b/vendor/unzerdev/php-sdk/test/integration/Resources/PaypageV2Test.php index 18ca4ac6..73c4fd0e 100644 --- a/vendor/unzerdev/php-sdk/test/integration/Resources/PaypageV2Test.php +++ b/vendor/unzerdev/php-sdk/test/integration/Resources/PaypageV2Test.php @@ -146,7 +146,6 @@ public function createPaypageWithOptionalStringProperties() /** * @test - * @group skip */ public function createPaypageWithUrls() { @@ -156,11 +155,11 @@ public function createPaypageWithUrls() $urls->setImprint('https://imprint.com'); $urls->setHelp('https://help.com'); $urls->setContact('https://contact.com'); - $urls->setFavicon('https://favicon.com'); $urls->setReturnSuccess('https://returnsuccess.com'); $urls->setReturnPending('https://returnpending.com'); $urls->setReturnFailure('https://returnfailure.com'); $urls->setReturnCancel('https://returncancel.com'); + $urls->setSubscriptionAgreement('https://subscriptionagreement.com'); $paypage = new Paypage(9.99, 'EUR', 'charge'); $paypage->setUrls($urls); diff --git a/vendor/unzerdev/php-sdk/test/integration/TransactionTypes/ScaTest.php b/vendor/unzerdev/php-sdk/test/integration/TransactionTypes/ScaTest.php new file mode 100644 index 00000000..1e76cc40 --- /dev/null +++ b/vendor/unzerdev/php-sdk/test/integration/TransactionTypes/ScaTest.php @@ -0,0 +1,191 @@ +getUnzerObject(TestEnvironmentService::getUnzerOneTestPrivateKey()); + } + /** + * Verify SCA transaction can be performed using the id of a payment type. + * + * @test + */ + public function scaShouldWorkWithTypeId(): Sca + { + /** @var Card $paymentType */ + $paymentType = $this->unzer->createPaymentType($this->createCardObject()); + $sca = new Sca(100.0, 'EUR', self::RETURN_URL); + $sca = $this->unzer->performSca($sca, $paymentType->getId()); + + $this->assertTransactionResourceHasBeenCreated($sca); + $this->assertInstanceOf(Payment::class, $sca->getPayment()); + $this->assertNotEmpty($sca->getPayment()->getId()); + $this->assertEquals(self::RETURN_URL, $sca->getReturnUrl()); + + return $sca; + } + + /** + * Verify SCA transaction can be performed with payment type object. + * + * @test + */ + public function scaShouldWorkWithTypeObject(): Sca + { + /** @var Card $paymentType */ + $paymentType = $this->unzer->createPaymentType($this->createCardObject()); + $sca = new Sca(100.0, 'EUR', self::RETURN_URL); + $sca = $this->unzer->performSca($sca, $paymentType); + + $this->assertTransactionResourceHasBeenCreated($sca); + $this->assertInstanceOf(Payment::class, $sca->getPayment()); + $this->assertNotEmpty($sca->getPayment()->getId()); + $this->assertEquals(self::RETURN_URL, $sca->getReturnUrl()); + + return $sca; + } + + /** + * Verify SCA transaction accepts all parameters. + * + * @test + */ + public function scaShouldAcceptAllParameters(): Sca + { + // prepare test data + /** @var Card $paymentType */ + $paymentType = $this->unzer->createPaymentType($this->createCardObject()); + $customer = $this->getMinimalCustomer(); + $metadata = (new Metadata())->addMetadata('key', 'value'); + $basket = $this->createBasket(); + $paymentReference = 'scaPaymentReference'; + + // perform request + $sca = new Sca(119.0, 'EUR', self::RETURN_URL); + $sca->setPaymentReference($paymentReference); + + $sca = $this->unzer->performSca($sca, $paymentType, $customer, $metadata, $basket); + + // verify the data sent and received match + $payment = $sca->getPayment(); + $this->assertSame($paymentType, $payment->getPaymentType()); + $this->assertEquals(119.0, $sca->getAmount()); + $this->assertEquals('EUR', $sca->getCurrency()); + $this->assertEquals(self::RETURN_URL, $sca->getReturnUrl()); + $this->assertSame($customer, $payment->getCustomer()); + $this->assertSame($metadata, $payment->getMetadata()); + $this->assertSame($basket, $payment->getBasket()); + $this->assertEquals($paymentReference, $sca->getPaymentReference()); + + return $sca; + } + + /** + * Verify SCA transaction can be fetched. + * + * @test + * @depends scaShouldWorkWithTypeId + */ + public function scaTransactionCanBeFetched($sca): void + { + $this->assertTransactionResourceHasBeenCreated($sca); + + // Fetch the SCA transaction + $fetchedSca = $this->unzer->fetchScaById($sca->getPaymentId(), $sca->getId()); + + // Verify the fetched transaction matches the initial transaction + $this->assertEquals($sca->getId(), $fetchedSca->getId()); + $this->assertEquals($sca->getPaymentId(), $fetchedSca->getPaymentId()); + $this->assertEquals($sca->getAmount(), $fetchedSca->getAmount()); + $this->assertEquals($sca->getCurrency(), $fetchedSca->getCurrency()); + } + + /** + * Verify SCA transaction can be fetched using Sca object. + * + * @test + * + * @depends scaShouldWorkWithTypeId + */ + public function scaTransactionCanBeFetchedUsingSca($sca): void + { + $this->assertTransactionResourceHasBeenCreated($sca); + + // Fetch the SCA transaction using the Sca object + $fetchedSca = $this->unzer->fetchSca($sca); + + // Verify the fetched transaction matches the initial transaction + $this->assertEquals($sca->getId(), $fetchedSca->getId()); + $this->assertEquals($sca->getAmount(), $fetchedSca->getAmount()); + $this->assertEquals($sca->getCurrency(), $fetchedSca->getCurrency()); + } + + /** + * Verify charge can be performed on SCA transaction. + * + * @test + * + * @depends scaShouldWorkWithTypeId + */ + public function chargeFailsOnPendingSCATransactionWithErrorCode($sca): void + { + $charge = new Charge(100, "EUR"); + + // Expect charge to fail on pending transaction with error code + $this->expectException(UnzerApiException::class); + $this->expectExceptionCode(ApiResponseCodes::API_CANNOT_CHARGE_UNSUCCESSFUL_SCA_TRANSACTION); + $this->expectExceptionMessage('Cannot perform payment on an unsuccessful strong customer authentication.'); + + $this->unzer->chargeScaTransaction($sca->getPayment(), $charge); + } + + /** + * Verify authorize can be performed on SCA transaction. + * + * @test + * + * @depends scaShouldWorkWithTypeObject + */ + public function authorizeCanBePerformedOnScaTransaction($sca): void + { + $authorization = new Authorization(100, "EUR"); + + // Expect authorization to fail on pending transaction with error code + $this->expectException(UnzerApiException::class); + $this->expectExceptionCode(ApiResponseCodes::API_CANNOT_CHARGE_UNSUCCESSFUL_SCA_TRANSACTION); + $this->expectExceptionMessage('Cannot perform payment on an unsuccessful strong customer authentication.'); + + // Perform an authorize on SCA transaction + $authorization = $this->unzer->authorizeScaTransaction($sca->getPayment(), $authorization); + } +} diff --git a/vendor/unzerdev/php-sdk/test/integration/WebhookTest.php b/vendor/unzerdev/php-sdk/test/integration/WebhookTest.php index beeb0f52..bdae8add 100755 --- a/vendor/unzerdev/php-sdk/test/integration/WebhookTest.php +++ b/vendor/unzerdev/php-sdk/test/integration/WebhookTest.php @@ -14,6 +14,7 @@ use UnzerSDK\Constants\ApiResponseCodes; use UnzerSDK\Constants\WebhookEvents; use UnzerSDK\Exceptions\UnzerApiException; +use UnzerSDK\Resources\TransactionTypes\Chargeback; use UnzerSDK\Resources\Webhook; use UnzerSDK\test\BaseIntegrationTest; use function count; @@ -22,6 +23,7 @@ class WebhookTest extends BaseIntegrationTest { // + const CHARGEDBACK_PAYMENT_ID = 's-pay-341196'; /** * Verify Webhook resource can be registered and fetched. @@ -221,6 +223,27 @@ public function bulkSettingOnlyOneWebhookShouldBePossible(): void $this->assertEquals($url, $webhook->getUrl()); } + /** + * @test + */ + public function testFetchResourceFromEvent(): void + { + $webhookNotification = [ + 'event' => 'chargebacks', + 'publicKey' => 's-pub-xyz', + 'retrieveUrl' => 'https://sbx-api.unzer.com/v1/payments/' . self::CHARGEDBACK_PAYMENT_ID . '/charges/s-chg-1/chargebacks/s-cbk-1', + 'paymentId' => self::CHARGEDBACK_PAYMENT_ID + ]; + + // when + $chargeback = $this->unzer->fetchResourceFromEvent(json_encode($webhookNotification)); + + // then + $this->assertInstanceOf(Chargeback::class, $chargeback); + $this->assertNotNull($chargeback); + $this->assertEquals('s-cbk-1', $chargeback->getId()); + } + // // diff --git a/vendor/unzerdev/php-sdk/test/unit/Resources/CustomerTest.php b/vendor/unzerdev/php-sdk/test/unit/Resources/CustomerTest.php index 0f11b1fb..7b17d3c6 100755 --- a/vendor/unzerdev/php-sdk/test/unit/Resources/CustomerTest.php +++ b/vendor/unzerdev/php-sdk/test/unit/Resources/CustomerTest.php @@ -14,15 +14,15 @@ use UnzerSDK\Constants\CompanyCommercialSectorItems; use UnzerSDK\Constants\CompanyRegistrationTypes; use UnzerSDK\Constants\Salutations; -use UnzerSDK\Resources\EmbeddedResources\CompanyOwner; -use UnzerSDK\Unzer; use UnzerSDK\Interfaces\ResourceServiceInterface; use UnzerSDK\Resources\Customer; use UnzerSDK\Resources\EmbeddedResources\Address; use UnzerSDK\Resources\EmbeddedResources\CompanyInfo; +use UnzerSDK\Resources\EmbeddedResources\CompanyOwner; use UnzerSDK\Resources\EmbeddedResources\GeoLocation; use UnzerSDK\Services\ResourceService; use UnzerSDK\test\BasePaymentTest; +use UnzerSDK\Unzer; class CustomerTest extends BasePaymentTest { @@ -121,6 +121,7 @@ public function settersAndGettersOfShippingAddressShouldWork(): void ->setCity('shipping_city') ->setZip('shipping_zip') ->setStreet('shipping_street') + ->setCompany('shipping_company') ->setShippingType('shipping_type'); $customer = new Customer(); @@ -132,6 +133,7 @@ public function settersAndGettersOfShippingAddressShouldWork(): void $this->assertNull($shippingAddress->getZip()); $this->assertNull($shippingAddress->getStreet()); $this->assertNull($shippingAddress->getShippingType()); + $this->assertNull($shippingAddress->getCompany()); $customer->setShippingAddress($address); $shippingAddress = $customer->getShippingAddress(); @@ -142,6 +144,7 @@ public function settersAndGettersOfShippingAddressShouldWork(): void $this->assertEquals('shipping_zip', $shippingAddress->getZip()); $this->assertEquals('shipping_street', $shippingAddress->getStreet()); $this->assertEquals('shipping_type', $shippingAddress->getShippingType()); + $this->assertEquals('shipping_company', $shippingAddress->getCompany()); } /** diff --git a/vendor/unzerdev/php-sdk/test/unit/Resources/TransactionTypes/ScaTest.php b/vendor/unzerdev/php-sdk/test/unit/Resources/TransactionTypes/ScaTest.php new file mode 100644 index 00000000..40ee6e59 --- /dev/null +++ b/vendor/unzerdev/php-sdk/test/unit/Resources/TransactionTypes/ScaTest.php @@ -0,0 +1,42 @@ +assertEquals(99.99, $sca->getAmount()); + $this->assertEquals("EUR", $sca->getCurrency()); + $this->assertEquals("https://return-url.com", $sca->getReturnUrl()); + } + + /** + * @test + */ + public function getterSetterTest() + { + $sca = new Sca(99.99, "EUR", "https://return-url.com"); + $sca->setPaymentReference('reference'); + $this->assertEquals(99.99, $sca->getAmount()); + $this->assertEquals("EUR", $sca->getCurrency()); + $this->assertEquals("reference", $sca->getPaymentReference()); + $this->assertEquals("https://return-url.com", $sca->getReturnUrl()); + } +} diff --git a/vendor/unzerdev/php-sdk/test/unit/Services/CancelServiceTest.php b/vendor/unzerdev/php-sdk/test/unit/Services/CancelServiceTest.php index 8b56bfd2..a2a6ab60 100644 --- a/vendor/unzerdev/php-sdk/test/unit/Services/CancelServiceTest.php +++ b/vendor/unzerdev/php-sdk/test/unit/Services/CancelServiceTest.php @@ -11,6 +11,7 @@ namespace UnzerSDK\test\unit\Services; +use PHPUnit\Framework\MockObject\MockObject; use UnzerSDK\Constants\ApiResponseCodes; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Resources\EmbeddedResources\Amount; @@ -24,7 +25,6 @@ use UnzerSDK\Services\CancelService; use UnzerSDK\Services\ResourceService; use UnzerSDK\test\BasePaymentTest; -use PHPUnit\Framework\MockObject\MockObject; class CancelServiceTest extends BasePaymentTest { @@ -119,7 +119,6 @@ public function maxCancelAmountShouldBeRoundedCorrectly(): void $cancelSrvMock = new CancelService($this->unzer); $reflection = new \ReflectionClass(get_class($cancelSrvMock)); $method = $reflection->getMethod('calculateMaxReversalAmount'); - $method->setAccessible(true); $chargeAmount = 12.3; $receiptAmount = 10.0; diff --git a/vendor/unzerdev/php-sdk/test/unit/Services/DummyAdapter.php b/vendor/unzerdev/php-sdk/test/unit/Services/DummyAdapter.php index a3778708..7ed18f26 100755 --- a/vendor/unzerdev/php-sdk/test/unit/Services/DummyAdapter.php +++ b/vendor/unzerdev/php-sdk/test/unit/Services/DummyAdapter.php @@ -39,14 +39,6 @@ public function getResponseCode(): string return 'responseCode'; } - /** - * {@inheritDoc} - */ - public function close(): void - { - // do nothing - } - /** * {@inheritDoc} */ diff --git a/vendor/unzerdev/php-sdk/test/unit/Services/HttpServiceTest.php b/vendor/unzerdev/php-sdk/test/unit/Services/HttpServiceTest.php index 8892f32e..816b43fe 100755 --- a/vendor/unzerdev/php-sdk/test/unit/Services/HttpServiceTest.php +++ b/vendor/unzerdev/php-sdk/test/unit/Services/HttpServiceTest.php @@ -112,7 +112,6 @@ static function ($url) { $adapterMock->expects($this->once())->method('setHeaders')->with($headers); $adapterMock->expects($this->once())->method('execute')->willReturn('myResponseString'); $adapterMock->expects($this->once())->method('getResponseCode')->willReturn('399'); - $adapterMock->expects($this->once())->method('close'); $httpServiceMock->method('getAdapter')->willReturn($adapterMock); diff --git a/vendor/unzerdev/php-sdk/test/unit/Services/ResourceServiceTest.php b/vendor/unzerdev/php-sdk/test/unit/Services/ResourceServiceTest.php index 1bcc7086..6cb6de5c 100755 --- a/vendor/unzerdev/php-sdk/test/unit/Services/ResourceServiceTest.php +++ b/vendor/unzerdev/php-sdk/test/unit/Services/ResourceServiceTest.php @@ -1391,7 +1391,8 @@ public function fetchResourceByUrlShouldFetchTheDesiredResourceDP(): array 'v2Customer' => ['fetchCustomer', ['s-cst-123e4567-e89b-12d3-a456-426614174000'], 'https://api.unzer.com/v2/customers/s-cst-123e4567-e89b-12d3-a456-426614174000'], 'v1Basket' => ['fetchBasket', ['s-bsk-1254'], 'https://api.unzer.com/v1/baskets/s-bsk-1254/'], 'v2Basket' => ['fetchBasket', ['s-bsk-1254'], 'https://api.unzer.com/v2/baskets/s-bsk-1254/'], - 'Payout' => ['fetchPayout', ['s-pay-100746'], 'https://api.unzer.com/v1/payments/s-pay-100746/payout/s-out-1/'] + 'Payout' => ['fetchPayout', ['s-pay-100746'], 'https://api.unzer.com/v1/payments/s-pay-100746/payout/s-out-1/'], + 'Sca' => ['fetchScaById', ['s-pay-100746', 's-sca-1'], 'https://api.unzer.com/v1/payments/s-pay-100746/sca/s-sca-1/'] ]; } diff --git a/vendor/unzerdev/php-sdk/test/unit/Services/WebhooksServiceTest.php b/vendor/unzerdev/php-sdk/test/unit/Services/WebhooksServiceTest.php index b21f9404..df5519c6 100755 --- a/vendor/unzerdev/php-sdk/test/unit/Services/WebhooksServiceTest.php +++ b/vendor/unzerdev/php-sdk/test/unit/Services/WebhooksServiceTest.php @@ -11,16 +11,18 @@ namespace UnzerSDK\test\unit\Services; -use UnzerSDK\Unzer; +use RuntimeException; +use stdClass; use UnzerSDK\Interfaces\ResourceServiceInterface; +use UnzerSDK\Resources\TransactionTypes\Charge; +use UnzerSDK\Resources\TransactionTypes\Chargeback; use UnzerSDK\Resources\Webhook; use UnzerSDK\Resources\Webhooks; use UnzerSDK\Services\ResourceService; use UnzerSDK\Services\WebhookService; use UnzerSDK\test\BasePaymentTest; use UnzerSDK\test\unit\DummyResource; -use RuntimeException; -use stdClass; +use UnzerSDK\Unzer; class WebhooksServiceTest extends BasePaymentTest { @@ -328,6 +330,54 @@ public function fetchResourceByEventWithEmptyRetrieveUrlShouldThrowException(): $webhookService->fetchResourceFromEvent(); } + /** + * Verify that a chargeback is returned from a webhook event. + * + * @test + */ + public function fetchChargebackByEventShouldReturnChargeback(): void + { + // given + $unzer = new Unzer('s-priv-1234'); + $webhookService = new WebhookService($unzer); + + $paymentId = 's-pay-42'; + $chargeId = 's-chg-1'; + $chargebackId = 's-cbk-1'; + $retrieveUrl = "https://api.unzer.com/v1/payments/{$paymentId}/charges/{$chargeId}/chargebacks/{$chargebackId}"; + + // Partial mock: keep original behavior except fetchChargebackById which we want to intercept + $resourceServiceMock = $this->getMockBuilder(ResourceService::class) + ->setConstructorArgs([$unzer]) + ->setMethods(['fetchChargebackById']) + ->getMock(); + + $chargeback = (new Chargeback(10.0)) + ->setId($chargebackId) + ->setParentResource((new Charge())->setId($chargeId)); + + $resourceServiceMock->expects($this->once()) + ->method('fetchChargebackById') + ->with($paymentId, $chargebackId, $chargeId) + ->willReturn($chargeback); + + $webhookService->setResourceService($resourceServiceMock); + + $eventJson = json_encode([ + 'event' => 'chargeback', + 'publicKey' => 's-pub-xyz', + 'retrieveUrl' => $retrieveUrl, + 'paymentId' => $paymentId + ]); + + // when + $fetchedChargeback = $webhookService->fetchResourceFromEvent($eventJson); + + // then + $this->assertSame($chargeback, $fetchedChargeback); + $this->assertNotNull($fetchedChargeback); + } + /** * Verify exception is thrown if the retrieveURL is empty. * diff --git a/vendor/unzerdev/php-sdk/test/unit/UnzerTest.php b/vendor/unzerdev/php-sdk/test/unit/UnzerTest.php index 771196bc..c9c22488 100644 --- a/vendor/unzerdev/php-sdk/test/unit/UnzerTest.php +++ b/vendor/unzerdev/php-sdk/test/unit/UnzerTest.php @@ -12,7 +12,8 @@ namespace UnzerSDK\test\unit; use DateTime; -use UnzerSDK\Unzer; +use PHPUnit\Framework\MockObject\MockObject; +use RuntimeException; use UnzerSDK\Resources\Basket; use UnzerSDK\Resources\Customer; use UnzerSDK\Resources\Metadata; @@ -30,8 +31,7 @@ use UnzerSDK\Services\WebhookService; use UnzerSDK\test\BasePaymentTest; use UnzerSDK\test\unit\Services\DummyDebugHandler; -use PHPUnit\Framework\MockObject\MockObject; -use RuntimeException; +use UnzerSDK\Unzer; class UnzerTest extends BasePaymentTest { @@ -56,6 +56,12 @@ public function constructorShouldInitPropertiesProperly(): void $unzerGerman = new Unzer('s-priv-1234', 'de-DE'); $this->assertEquals('de-DE', $unzerGerman->getLocale()); + + $unzerPub = new Unzer('s-pub-1234'); + $this->assertEquals('s-pub-1234', $unzerPub->getKey()); + + $unzerProdPub = new Unzer('p-pub-1234'); + $this->assertEquals('p-pub-1234', $unzerProdPub->getKey()); } /** @@ -75,9 +81,14 @@ public function gettersAndSettersShouldWorkProperly(): void $unzer->setKey('this is not a valid key'); $this->assertTrue(false, 'This exception should have been thrown'); } catch (RuntimeException $e) { - $this->assertEquals('Illegal key: Use a valid private key with this SDK!', $e->getMessage()); + $this->assertEquals('Illegal key: Use a valid private or public key with this SDK!', $e->getMessage()); } + $unzer->setKey('s-pub-1234'); + $this->assertEquals('s-pub-1234', $unzer->getKey()); + $unzer->setKey('p-pub-1234'); + $this->assertEquals('p-pub-1234', $unzer->getKey()); + $httpService = new HttpService(); $this->assertNotSame($httpService, $unzer->getHttpService()); $unzer->setHttpService($httpService);