diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9377aafaf..e30c6ba53 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,113 +1,147 @@ name: Tests on: - push: - branches: - - master - pull_request: - branches: - - master - workflow_dispatch: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: env: - MODULE_NAME: PayonePayment - COMPOSER_NAME: payone-gmbh/shopware-6 - TEST_DATABASE_URL: "mysql://root:root@127.0.0.1:3306/shopware" + MODULE_NAME: PayonePayment + MODULE_DIR: custom/plugins/PayonePayment + COMPOSER_NAME: payone-gmbh/shopware-6 + TEST_DATABASE_URL: "mysql://root:root@127.0.0.1:3306/shopware" -jobs: - ci-current: - name: SW ${{ matrix.shopware-versions }}, PHP ${{ matrix.php-versions }}, MySQL ${{ matrix.mysql-versions }} - runs-on: ubuntu-latest - strategy: - max-parallel: 15 - fail-fast: false - matrix: - php-versions: [ '8.1', '8.2' ] - mysql-versions: [ '5.7', '8.0' ] - shopware-versions: [ 'v6.5.0.0', 'v6.5.1.0', 'v6.5.2.0', 'v6.5.3.0', 'v6.5.4.0', 'v6.5.5.0', 'v6.5.6.0', 'v6.5.7.3' ] - services: - mysql: - image: mysql:${{ matrix.mysql-versions }} - env: - MYSQL_DATABASE: shopware - MYSQL_ROOT_PASSWORD: root - ports: - - 3306:3306 - - steps: - - name: Install PHP - uses: shivammathur/setup-php@master - with: - php-version: ${{ matrix.php-versions }} - extensions: mbstring, xdebug, curl, dom, fileinfo, gd, iconv, intl, json, xml, mbstring, pdo, phar, zip, sodium, pdo_mysql - tools: composer:2.2 - - - name: "Check PHP Version" - run: php -v - - - name: "Check Composer Version" - run: composer -V - - - name: "Check PHP Extensions" - run: php -m - - - name: "checkout Shopware" - uses: actions/checkout@v3 - with: - repository: shopware/production - ref: 'flex' - - - name: "Checkout ${{ env.COMPOSER_NAME }}" - uses: actions/checkout@v3 - with: - path: custom/plugins/${{ env.MODULE_NAME }} - - - name: "Get composer cache directory" - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: "Cache Composer dependencies" - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ matrix.operating-system }}-${{ matrix.php-versions }}-${{ matrix.shopware-versions }}-${{ hashFiles('**/composer.lock') }} - - - name: "Install Shopware dependencies" - # Install Shopware with --no-dev to prevent that dev-tools of the module got in conflict with the tools of shopware - run: | - composer req shopware/administration:${{ matrix.shopware-versions }} shopware/core:${{ matrix.shopware-versions }} shopware/elasticsearch:${{ matrix.shopware-versions }} shopware/storefront:${{ matrix.shopware-versions }} --no-update - composer install --no-dev - - - name: "Install ${{ env.COMPOSER_NAME }}" - run: composer req ${{ env.COMPOSER_NAME }} - - - name: "Install DEV-Tools" - working-directory: custom/plugins/${{ env.MODULE_NAME }} - run: | - composer remove shopware/* --no-update - composer install - - - name: "Run PHPStan" - working-directory: custom/plugins/${{ env.MODULE_NAME }} - run: ./vendor/bin/phpstan - - - name: "Check Code style (easy-coding-style)" - working-directory: custom/plugins/${{ env.MODULE_NAME }} - run: ./vendor/bin/ecs - - - name: "Check Code style (rector)" - working-directory: custom/plugins/${{ env.MODULE_NAME }} - run: ./vendor/bin/rector --dry-run - - - name: "Install Shopware" - run: | - echo APP_ENV=dev >> .env - echo APP_URL=http://localhost >> .env - echo DATABASE_URL=${{ env.TEST_DATABASE_URL }} >> .env - echo APP_SECRET=secretf0rt3st >> .env - bin/console system:install --basic-setup - - - name: "Run PHPUnit Tests" - working-directory: custom/plugins/${{ env.MODULE_NAME }} - run: ./vendor/bin/phpunit --testdox +permissions: + contents: read +jobs: + ci-current: + name: SW ${{ matrix.shopware-version }}, PHP ${{ matrix.php-version }}, MySQL ${{ matrix.mysql-version }} + runs-on: ubuntu-latest + strategy: + matrix: + php-version: [ '8.1', '8.2' ] + mysql-version: [ '5.7', '8.0' ] + shopware-version: [ 'v6.5.0.0', 'v6.5.1.0', 'v6.5.2.0', 'v6.5.3.0', 'v6.5.4.0', 'v6.5.5.0', 'v6.5.6.0', 'v6.5.7.3', 'v6.6.0.0', 'v6.6.1.0' ] + include: + - php-version: "8.3" + mysql-version: "8.0" + shopware-version: "v6.6.0.0" + - php-version: "8.3" + mysql-version: "8.0" + shopware-version: "v6.6.1.0" + exclude: + - php-version: "8.1" + shopware-version: "v6.6.0.0" + - mysql-version: "5.7" + shopware-version: "v6.6.0.0" + - php-version: "8.1" + shopware-version: "v6.6.1.0" + - mysql-version: "5.7" + shopware-version: "v6.6.1.0" + fail-fast: false + max-parallel: 10 + services: + mysql: + image: mysql:${{ matrix.mysql-version }} + env: + MYSQL_DATABASE: shopware + MYSQL_ROOT_PASSWORD: root + ports: + - 3306:3306 + steps: + + - name: Install PHP + uses: shivammathur/setup-php@master + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, curl, dom, fileinfo, gd, iconv, intl, json, xml, mbstring, pdo, phar, zip, sodium, pdo_mysql + tools: composer:2.2 + coverage: none # we should implement code-coverage-report in the future if we have more tests for everything + + - name: "Check PHP Version" + run: php -v + + - name: "Check Composer Version" + run: composer -V + + - name: "Check PHP Extensions" + run: php -m + + - name: "checkout Shopware" + uses: actions/checkout@v3 + with: + repository: shopware/production + ref: ${{ matrix.shopware-version }} + + - name: "Checkout ${{ env.COMPOSER_NAME }}" + uses: actions/checkout@v3 + with: + path: ${{ env.MODULE_DIR }} + + - name: "Get composer cache directory" + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: "Cache Composer dependencies" + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ matrix.operating-system }}-${{ matrix.php-version }}-${{ matrix.shopware-version }}-${{ hashFiles('**/composer.lock') }} + + - name: "Install Shopware dependencies" + # Install Shopware with --no-dev to prevent that dev-tools of the module got in conflict with the tools of shopware + run: | + composer req shopware/core:${{ matrix.shopware-version }} shopware/administration:* shopware/storefront:* --no-update + composer remove shopware/elasticsearch --no-update + composer install + + - name: "Install ${{ env.COMPOSER_NAME }}" + run: | + composer config prefer-stable true + composer config minimum-stability dev + composer config repositories.local-plugins '{ "type": "path", "url": "custom/plugins/*", "options": { "symlink": true } }' + composer req ${{ env.COMPOSER_NAME }} --no-scripts + + - name: "Install DEV-Tools" + working-directory: ${{ env.MODULE_DIR }} + run: | + composer remove shopware/* --no-update + composer install + + - name: "Run PHPStan" + working-directory: ${{ env.MODULE_DIR }} + run: ./vendor/bin/phpstan + + - name: "Check Code style (easy-coding-style)" + working-directory: ${{ env.MODULE_DIR }} + run: ./vendor/bin/ecs + + - name: "Check Code style (rector)" + working-directory: ${{ env.MODULE_DIR }} + run: ./vendor/bin/rector --dry-run + + # Workaround. The variables are required for shopware to work properly during unit-testing + - name: "Install Shopware for unit-testing" + run: | + echo DATABASE_URL=${{ env.TEST_DATABASE_URL }} >> .env + echo MAILER_DSN=null://null >> .env + echo OPENSEARCH_URL=http://localhost:9200 >> .env + echo LOCK_DSN=flock >> .env + echo MAILER_DSN=null://null >> .env + echo APP_SECRET=se$cr$t >> .env + echo REDIS_CACHE_HOST=127.0.0.1 >> .env + echo REDIS_CACHE_PORT=123 >> .env + echo REDIS_SESSION_HOST=127.0.0.1 >> .env + echo REDIS_SESSION_PORT=123 >> .env + echo SHOPWARE_HTTP_CACHE_ENABLED=0 >> .env + echo STOREFRONT_PROXY_URL=http://localhost:80 >> .env + bin/console system:install --basic-setup + + - name: "Run PHPUnit Tests" + working-directory: custom/plugins/${{ env.MODULE_NAME }} + run: SYMFONY_DEPRECATIONS_HELPER=disabled ./vendor/bin/phpunit --testdox diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index f08e305b7..000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,156 +0,0 @@ -stages: - - style - - quality - - test - - package - - validate - -cache: - key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" - -variables: - DOCKER_DRIVER: overlay2 - BASE_SW_VERSION: '6.4.0.0' - COMPOSER_COMMAND: "/var/www/html/composer install --prefer-dist --no-ansi --no-interaction --no-progress --optimize-autoloader" - - -include: '/.gitlab/ci-legacy.yml' - -codestyle: - stage: style - image: "dockware/play:${BASE_SW_VERSION}" - needs: [ ] - except: - variables: [ $DISABLE_PHP_CS == "1" ] - before_script: - - curl https://getcomposer.org/download/1.10.19/composer.phar -o /var/www/html/composer - - chmod +x /var/www/html/composer - - /var/www/html/composer self-update --2 - - ${COMPOSER_COMMAND} - - cp -r ${CI_PROJECT_DIR} /var/www/html/custom/plugins/${CI_PROJECT_NAME} - script: - - cd /var/www/html/custom/plugins/${CI_PROJECT_NAME} && vendor/bin/php-cs-fixer fix -v --dry-run - cache: - key: global - paths: - - .php_cs.cache - - vendor - -k10r-phpstan: - stage: quality - image: "dockware/play:${SW_VERSION}" - parallel: - matrix: - - PHP_VERSION: [ "7.4" ] - SW_VERSION: [ "6.4.0.0", "6.4.1.0", "6.4.2.1", "6.4.3.0" ] - needs: [ ] - except: - variables: [ $DISABLE_PHPSTAN_K10R == "1" ] - before_script: - - curl https://getcomposer.org/download/1.10.19/composer.phar -o /var/www/html/composer - - chmod +x /var/www/html/composer - - /var/www/html/composer self-update --2 - - ${COMPOSER_COMMAND} - - cp -r ${CI_PROJECT_DIR} /var/www/html/custom/plugins/${CI_PROJECT_NAME} - script: - - cd /var/www/html/custom/plugins/${CI_PROJECT_NAME} && vendor/bin/phpstan analyse -c phpstan.neon -a vendor/autoload.php -a ../../../vendor/autoload.php src tests - cache: - key: global - paths: - - vendor - -sw-phpstan: - stage: quality - image: "dockware/play:${SW_VERSION}" - parallel: - matrix: - - PHP_VERSION: [ "7.4" ] - SW_VERSION: [ "6.4.0.0", "6.4.1.0", "6.4.2.1", "6.4.3.0" ] - needs: [ ] - except: - variables: [ $DISABLE_PHPSTAN_SW == "1" ] - before_script: - - curl https://getcomposer.org/download/1.10.19/composer.phar -o /var/www/html/composer - - chmod +x /var/www/html/composer - - if [ $SW_VERSION == '6.4.0.0' ]; then /var/www/html/composer self-update --2; else /var/www/html/composer self-update --2; fi - - ${COMPOSER_COMMAND} - - cp -r ${CI_PROJECT_DIR} /var/www/html/custom/plugins/${CI_PROJECT_NAME} - - cd /tmp && git clone https://github.com/shopwareLabs/store-plugin-codereview.git - - cp -r /tmp/store-plugin-codereview/configs/phpstan/phpstan.neon.sw6 /var/www/html/custom/plugins/${CI_PROJECT_NAME}/phpstan_sw.neon - script: - - cd /var/www/html/custom/plugins/${CI_PROJECT_NAME} && vendor/bin/phpstan analyse -c phpstan_sw.neon -a vendor/autoload.php -a ../../../vendor/autoload.php src tests - cache: - key: global - paths: - - vendor - -phpunit: - stage: test - image: "dockware/play:${SW_VERSION}" - parallel: - matrix: - - PHP_VERSION: [ "7.4" ] - SW_VERSION: [ "6.4.0.0", "6.4.1.0", "6.4.2.1", "6.4.3.0" ] - needs: [ ] - except: - variables: [ $DISABLE_PHPUNIT == "1" ] - before_script: - - curl https://getcomposer.org/download/1.10.19/composer.phar -o /var/www/html/composer - - chmod +x /var/www/html/composer - - /var/www/html/composer self-update --2 - - ${COMPOSER_COMMAND} - - cp -r ${CI_PROJECT_DIR} /var/www/html/custom/plugins/${CI_PROJECT_NAME} - - sudo rm -rf /var/run/mysqld/mysqld.sock.lock - - sudo chown -R mysql:mysql /var/lib/mysql /var/run/mysqld - - sudo service mysql start - - cd /var/www/html/ && rm -rf vendor && ${COMPOSER_COMMAND} --no-scripts - script: - - cd /var/www/html/ && php bin/console plugin:refresh -nq && php bin/console plugin:install --activate -c PayonePayment -nq - - cd /var/www/html/ && /var/www/html/composer dump-autoload -d custom/plugins/${CI_PROJECT_NAME} - - cd /var/www/html/ && php -d pcov.enabled=1 -d pcov.directory=/var/www/html/ - vendor/bin/phpunit - --configuration custom/plugins/${CI_PROJECT_NAME}/phpunit-dockware.xml.dist - cache: - key: global - paths: - - vendor - -package: - stage: package - image: - name: ghcr.io/friendsofshopware/platform-plugin-dev:v6.3.1 - entrypoint: [ "" ] - only: - - tags - - master - - develop - - /^integration.*$/ - - /^fix.*$/ - except: - variables: [ $DISABLE_PACKAGE == "1" ] - script: - - start-mysql - - ln -s "$(pwd)" "/plugins/PayonePayment" - - plugin-uploader ext:prepare "/plugins/PayonePayment" - - rm -rf $( cat .sw-zip-blocklist ) && rm -rf .sw-zip-blocklist - - pack-plugin PayonePayment - artifacts: - paths: - - "*.zip" - -shopware-validate: - stage: validate - image: - name: friendsofshopware/plugin-uploader:0.3.5 - entrypoint: [ "/bin/sh", "-c" ] - needs: - - package - only: - - tags - - master - - /^integration.*$/ - - /^fix.*$/ - except: - variables: [ $DISABLE_VALIDATION == "1" ] - script: - - php /app/bin/pluginupload ext:validate ${CI_PROJECT_NAME}.zip diff --git a/.gitlab/ci-legacy.yml b/.gitlab/ci-legacy.yml deleted file mode 100644 index d02b62236..000000000 --- a/.gitlab/ci-legacy.yml +++ /dev/null @@ -1,79 +0,0 @@ -k10r-phpstan-legacy: - stage: quality - image: "dockware/play:${SW_VERSION}" - parallel: - matrix: - - PHP_VERSION: [ "7.2", "7.3", "7.4" ] - SW_VERSION: [ "6.3.0.1", "6.3.1.1", "6.3.2.1", "6.3.3.1" ] - needs: [ ] - except: - variables: [ $DISABLE_PHPSTAN_K10R == "1" ] - before_script: - - curl https://getcomposer.org/download/1.10.19/composer.phar -o /var/www/html/composer - - chmod +x /var/www/html/composer - - /var/www/html/composer global require hirak/prestissimo - - cp -r ${CI_PROJECT_DIR} /var/www/html/custom/plugins/${CI_PROJECT_NAME} - - cd /var/www/html/ && php -d memory_limit=3G /var/www/html/composer require phpstan/phpstan:"^0.12" --no-scripts - - cd /var/www/html/ && php -d memory_limit=3G /var/www/html/composer require phpstan/phpstan-phpunit:"^0.12" --no-scripts - - cd /var/www/html/ && php -d memory_limit=3G /var/www/html/composer require dms/phpunit-arraysubset-asserts:"^0.3.0" --no-scripts - - cd /var/www/html/ && php -d memory_limit=3G /var/www/html/composer require psr/event-dispatcher --no-scripts - - cd /var/www/html/ && php -d memory_limit=3G /var/www/html/composer require sinergi/browser-detector:"^6.1" --no-scripts - - cd /var/www/html/custom/plugins/${CI_PROJECT_NAME} && /var/www/html/composer dumpautoload - - cd /var/www/html/ && /var/www/html/composer dumpautoload - script: - - cd /var/www/html && vendor/bin/phpstan analyse -c custom/plugins/${CI_PROJECT_NAME}/.gitlab/phpstan-legacy.neon -a custom/plugins/${CI_PROJECT_NAME}/vendor/autoload.php -a vendor/autoload.php custom/plugins/${CI_PROJECT_NAME}/src - -sw-phpstan-legacy: - stage: quality - image: "dockware/play:${SW_VERSION}" - parallel: - matrix: - - PHP_VERSION: [ "7.2", "7.3", "7.4" ] - SW_VERSION: [ "6.3.0.1", "6.3.1.1", "6.3.2.1", "6.3.3.1" ] - needs: [ ] - except: - variables: [ $DISABLE_PHPSTAN_SW == "1" ] - before_script: - - curl https://getcomposer.org/download/1.10.19/composer.phar -o /var/www/html/composer - - chmod +x /var/www/html/composer - - /var/www/html/composer global require hirak/prestissimo - - cp -r ${CI_PROJECT_DIR} /var/www/html/custom/plugins/${CI_PROJECT_NAME} - - cd /tmp && git clone https://github.com/shopwareLabs/store-plugin-codereview.git - - cp -r /tmp/store-plugin-codereview/configs/phpstan/phpstan.neon.sw6 /var/www/html/custom/plugins/${CI_PROJECT_NAME}/phpstan_sw.neon - - cd /var/www/html/ && php -d memory_limit=3G /var/www/html/composer require phpstan/phpstan:"^0.12" --no-scripts - - cd /var/www/html/ && php -d memory_limit=3G /var/www/html/composer require phpstan/phpstan-phpunit:"^0.12" --no-scripts - - cd /var/www/html/ && php -d memory_limit=3G /var/www/html/composer require dms/phpunit-arraysubset-asserts:"^0.3.0" --no-scripts - - cd /var/www/html/ && php -d memory_limit=3G /var/www/html/composer require psr/event-dispatcher --no-scripts - - cd /var/www/html/ && php -d memory_limit=3G /var/www/html/composer require sinergi/browser-detector:"^6.1" --no-scripts - - cd /var/www/html/custom/plugins/${CI_PROJECT_NAME} && /var/www/html/composer dumpautoload - - cd /var/www/html/ && /var/www/html/composer dumpautoload - script: - - cd /var/www/html && vendor/bin/phpstan analyse -c custom/plugins/${CI_PROJECT_NAME}/phpstan_sw.neon -a custom/plugins/${CI_PROJECT_NAME}/vendor/autoload.php -a vendor/autoload.php custom/plugins/${CI_PROJECT_NAME}/src - -phpunit-legacy: - stage: test - image: "dockware/play:${SW_VERSION}" - parallel: - matrix: - - PHP_VERSION: [ "7.2", "7.3", "7.4" ] - SW_VERSION: [ "6.3.0.1", "6.3.1.1", "6.3.2.1", "6.3.3.1" ] - needs: [ ] - except: - variables: [ $DISABLE_PHPUNIT == "1" ] - before_script: - - curl https://getcomposer.org/download/1.10.19/composer.phar -o /var/www/html/composer - - chmod +x /var/www/html/composer - - /var/www/html/composer global require hirak/prestissimo - - cp -r ${CI_PROJECT_DIR} /var/www/html/custom/plugins/${CI_PROJECT_NAME} - - sudo rm -rf /var/run/mysqld/mysqld.sock.lock - - sudo chown -R mysql:mysql /var/lib/mysql /var/run/mysqld - - sudo service mysql start - - cd /var/www/html/ && rm -rf vendor && ${COMPOSER_COMMAND} --no-scripts - - cd /var/www/html/ && php -d memory_limit=3G /var/www/html/composer require dms/phpunit-arraysubset-asserts:"^0.3.0" --no-scripts - - cd /var/www/html/custom/plugins/${CI_PROJECT_NAME} && /var/www/html/composer dumpautoload - script: - - cd /var/www/html/ && php bin/console plugin:refresh -nq && php bin/console plugin:install --activate -c PayonePayment -nq - - cd /var/www/html/ && /var/www/html/composer dump-autoload -d custom/plugins/${CI_PROJECT_NAME} - - cd /var/www/html/ && php -d pcov.enabled=1 -d pcov.directory=/var/www/html/ - vendor/bin/phpunit - --configuration custom/plugins/${CI_PROJECT_NAME}/phpunit-dockware.xml.dist diff --git a/.gitlab/phpstan-legacy.neon b/.gitlab/phpstan-legacy.neon deleted file mode 100644 index 6436febfa..000000000 --- a/.gitlab/phpstan-legacy.neon +++ /dev/null @@ -1,14 +0,0 @@ -includes: - - ../../../../vendor/phpstan/phpstan-phpunit/extension.neon - -parameters: - level: 5 - reportUnmatchedIgnoredErrors: false - inferPrivatePropertyTypeFromConstructor: true - checkMissingIterableValueType: false - treatPhpDocTypesAsCertain: false - ignoreErrors: - - '#Access to constant CUSTOMIZED_PRODUCTS_TEMPLATE_LINE_ITEM_TYPE(.*)#' - - '#Shopware\\Core\\Framework\\DataAbstractionLayer\\Field\\Flag\\ApiAware given#' - excludes_analyse: - - tests/* diff --git a/.shopware-extension.yml b/.shopware-extension.yml new file mode 100644 index 000000000..112b95080 --- /dev/null +++ b/.shopware-extension.yml @@ -0,0 +1,24 @@ +build: + zip: + composer: + enabled: false + assets: + enabled: true + enable_es_build_for_admin: true + enable_es_build_for_storefront: false + pack: + excludes: + paths: + - __COMPOSER_HOME__ + - bin + - tests + - var + - .eslintignore + - .gitignore + - .shopware-extension.yml + - .phpunit.result.cache + - ecs.php + - phpstan.neon + - phpstan-ignore.neon + - phpunit.xml.dist + - rector.php diff --git a/__COMPOSER_HOME__/.htaccess b/__COMPOSER_HOME__/.htaccess deleted file mode 100644 index 14249c50b..000000000 --- a/__COMPOSER_HOME__/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all \ No newline at end of file diff --git a/bin/phpstan.sh b/bin/phpstan.sh deleted file mode 100755 index 0da693c29..000000000 --- a/bin/phpstan.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -vendor/bin/phpstan analyse -c phpstan.neon --autoload-file=../../../vendor/autoload.php tests src diff --git a/bin/phpunit-coverage.sh b/bin/phpunit-coverage.sh deleted file mode 100755 index f0a3644a7..000000000 --- a/bin/phpunit-coverage.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -php -d pcov.enabled=1 -d pcov.directory=../../../ vendor/bin/phpunit --configuration phpunit.xml.dist --log-junit phpunit.junit.xml --colors=never --coverage-clover phpunit.clover.xml --coverage-html phpunit-coverage-html --coverage-text diff --git a/bin/phpunit.sh b/bin/phpunit.sh deleted file mode 100755 index 6ef9fba29..000000000 --- a/bin/phpunit.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -./../../../vendor/bin/phpunit diff --git a/composer.json b/composer.json index ebaa57584..3991947c3 100644 --- a/composer.json +++ b/composer.json @@ -78,6 +78,7 @@ "phpstan": "./vendor/bin/phpstan analyse -n --no-progress", "phpunit": "./../../../vendor/bin/phpunit", "ecs": "ecs check src tests", - "ecs-fix": "ecs check --fix src tests" + "ecs-fix": "ecs check --fix src tests", + "build": "shopware-cli extension build ." } } diff --git a/cypress.json.dist b/cypress.json.dist deleted file mode 100644 index 56c570087..000000000 --- a/cypress.json.dist +++ /dev/null @@ -1,12 +0,0 @@ -{ - "baseUrl": "http://payone.local", - "integrationFolder": "tests/cypress/integration", - "fixturesFolder": "tests/cypress/fixtures", - "componentFolder": "tests/cypress/component", - "pluginsFile": "tests/cypress/plugins", - "supportFile": "tests/cypress/support", - "videosFolder": "cypress/videos", - "screenshotsFolder": "cypress/screenshots", - "chromeWebSecurity": false, - "watchForFileChanges": false -} diff --git a/package.json b/package.json deleted file mode 100644 index 508cec37f..000000000 --- a/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "scripts": { - "cypress:open": "./node_modules/.bin/cypress open", - "cypress:run": "./node_modules/.bin/cypress run --record false --config video=false" - }, - "devDependencies": { - "cypress": "^4.7.0", - "cypress-pipe": "^1.7.0" - } -} diff --git a/phpunit-dockware.xml.dist b/phpunit-dockware.xml.dist deleted file mode 100644 index 7b0d1b535..000000000 --- a/phpunit-dockware.xml.dist +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - tests - - - - - - ./ - - - diff --git a/rector.php b/rector.php index a96d18857..c04eec752 100644 --- a/rector.php +++ b/rector.php @@ -13,6 +13,12 @@ __DIR__ . '/tests', ]); + $rectorConfig->bootstrapFiles([ + __DIR__ . '/../../../vendor/autoload.php' + ]); + + $rectorConfig->removeUnusedImports(); + // define sets of rules $rectorConfig->sets([ LevelSetList::UP_TO_PHP_81 diff --git a/src/Components/AmazonPay/EventListener/CheckoutCartEventListener.php b/src/Components/AmazonPay/EventListener/CheckoutCartEventListener.php index a0b3c861a..f6ecf1cfe 100644 --- a/src/Components/AmazonPay/EventListener/CheckoutCartEventListener.php +++ b/src/Components/AmazonPay/EventListener/CheckoutCartEventListener.php @@ -102,9 +102,10 @@ public function onCartLoaded(CheckoutCartPageLoadedEvent|OffcanvasCartPageLoaded if ($response['status'] === 'OK') { $this->setInitializedPaymentResponse($event->getSalesChannelContext(), $event->getPage()->getCart(), $requestData, $response); - $this->cartExtensionService->addCartExtension( + $this->cartExtensionService->addCartExtensionForExpressCheckout( $event->getPage()->getCart(), $event->getSalesChannelContext(), + PayoneAmazonPayExpress::UUID, $response['workorderid'] ); diff --git a/src/Components/CartHasher/CartHasherInterface.php b/src/Components/CartHasher/CartHasherInterface.php index 2ff695037..d4397a0d9 100644 --- a/src/Components/CartHasher/CartHasherInterface.php +++ b/src/Components/CartHasher/CartHasherInterface.php @@ -8,8 +8,6 @@ use Shopware\Core\Checkout\Order\OrderEntity; use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; use Shopware\Core\Checkout\Payment\Cart\SyncPaymentTransactionStruct; -use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentProcessException; -use Shopware\Core\Checkout\Payment\Exception\SyncPaymentProcessException; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; @@ -20,9 +18,6 @@ public function generate(Cart|OrderEntity $entity, SalesChannelContext $context) public function validate(Cart|OrderEntity $entity, string $cartHash, SalesChannelContext $context): bool; - /** - * @throws AsyncPaymentProcessException|SyncPaymentProcessException - */ public function validateRequest( RequestDataBag $requestDataBag, AsyncPaymentTransactionStruct|SyncPaymentTransactionStruct $paymentTransaction, diff --git a/src/Components/CustomerDataPersistor/CustomerDataPersistor.php b/src/Components/CustomerDataPersistor/CustomerDataPersistor.php new file mode 100644 index 000000000..5b2502f88 --- /dev/null +++ b/src/Components/CustomerDataPersistor/CustomerDataPersistor.php @@ -0,0 +1,128 @@ +saveOrderData($order, $dataBag, $context); + + if ($this->configService->getBool('PayonePayment.settings.saveUserEnteredDataToCustomer')) { + $customer = $this->getCustomer($order, $context); + if ($customer instanceof CustomerEntity) { + $this->saveCustomerData($customer, $dataBag, $context); + $customerAddress = $this->getCustomerAddress($customer, $context); + if ($customerAddress instanceof CustomerAddressEntity) { + $this->saveCustomerAddressData($customerAddress, $dataBag, $context); + } + } + } + } + + protected function saveCustomerData(CustomerEntity $customer, RequestDataBag $dataBag, Context $context): void + { + $birthday = $dataBag->get(RequestConstants::BIRTHDAY); + $birthday = \is_string($birthday) ? (\DateTime::createFromFormat('Y-m-d', $birthday) ?: null) : null; + + if ($birthday instanceof \DateTime && $birthday->getTimestamp() !== $customer->getBirthday()?->getTimestamp()) { + $this->customerRepository->update( + [ + [ + 'id' => $customer->getId(), + 'birthday' => $birthday, + ], + ], + $context + ); + } + } + + protected function saveCustomerAddressData(CustomerAddressEntity $customerAddress, RequestDataBag $dataBag, Context $context): void + { + $phoneNumber = $dataBag->get(RequestConstants::PHONE); + + if ($phoneNumber !== $customerAddress->getPhoneNumber()) { + $this->customerAddressRepository->update( + [ + [ + 'id' => $customerAddress->getId(), + 'phoneNumber' => $phoneNumber, + ], + ], + $context + ); + } + } + + protected function saveOrderData(OrderEntity $orderEntity, RequestDataBag $dataBag, Context $context): void + { + $phoneNumber = $dataBag->get(RequestConstants::PHONE); + + $this->orderAddressRepository->update( + [ + [ + 'id' => $orderEntity->getBillingAddressId(), + 'phoneNumber' => $phoneNumber, + ], + ], + $context + ); + } + + private function getCustomer(OrderEntity $order, Context $context): ?CustomerEntity + { + $customer = $order->getOrderCustomer()?->getCustomer(); + if ($customer instanceof CustomerEntity) { + return $customer; + } + $customerId = $order->getOrderCustomer()?->getCustomerId(); + if (empty($customerId)) { + return null; + } + + $criteria = new Criteria([$customerId]); + $criteria->addAssociation('defaultBillingAddress'); + + /** @var CustomerEntity|null $customer */ + $customer = $this->customerRepository->search($criteria, $context)->first(); + + return $customer; + } + + private function getCustomerAddress(CustomerEntity $customer, Context $context): ?CustomerAddressEntity + { + $customerAddress = $customer->getDefaultBillingAddress(); + if ($customerAddress instanceof CustomerAddressEntity) { + return $customerAddress; + } + + /** @var CustomerAddressEntity|null $customerAddress */ + $customerAddress = $this->customerAddressRepository->search( + new Criteria([$customer->getDefaultBillingAddressId()]), + $context + )->first(); + + return $customerAddress; + } +} diff --git a/src/Components/GenericExpressCheckout/CartExtensionService.php b/src/Components/GenericExpressCheckout/CartExtensionService.php index 8fffc87d0..757820442 100644 --- a/src/Components/GenericExpressCheckout/CartExtensionService.php +++ b/src/Components/GenericExpressCheckout/CartExtensionService.php @@ -8,7 +8,6 @@ use PayonePayment\Storefront\Struct\CheckoutCartPaymentData; use Shopware\Core\Checkout\Cart\Cart; use Shopware\Core\Checkout\Cart\SalesChannel\CartService; -use Shopware\Core\Framework\Struct\ArrayStruct; use Shopware\Core\System\SalesChannel\SalesChannelContext; class CartExtensionService @@ -36,10 +35,58 @@ public function addCartExtension( $this->cartService->recalculate($cart, $context); } + public function addCartExtensionForExpressCheckout( + Cart $cart, + SalesChannelContext $context, + string $paymentMethodId, + string $workOrderId + ): void { + $cartData = new CheckoutCartPaymentData(); + + $cartData->assign(array_filter([ + CheckoutCartPaymentData::DATA_WORK_ORDER_ID => $workOrderId, + CheckoutCartPaymentData::DATA_CART_HASH => $this->cartHasher->generate($cart, $context), + ])); + + $this->removeExtensionData($context, $cart, true); // make sure there is no checkout-data of PAYONE + $cart->addExtension($this->getExtensionNameForExpressCheckout($paymentMethodId), $cartData); + + $this->cartService->recalculate($cart, $context); + } + public function getCartExtension(Cart $cart): ?CheckoutCartPaymentData { $extension = $cart->getExtension(CheckoutCartPaymentData::EXTENSION_NAME); return $extension instanceof CheckoutCartPaymentData ? $extension : null; } + + public function getCartExtensionForExpressCheckout(Cart $cart, string $paymentMethodId): ?CheckoutCartPaymentData + { + $extension = $cart->getExtension($this->getExtensionNameForExpressCheckout($paymentMethodId)); + + return $extension instanceof CheckoutCartPaymentData ? $extension : null; + } + + public function removeExtensionData(SalesChannelContext $context, ?Cart $cart = null, bool $skipRecalculate = false): void + { + if ($cart === null) { + $cart = $this->cartService->getCart($context->getToken(), $context); + } + + foreach ($cart->getExtensions() as $key => $extension) { + if ($extension instanceof CheckoutCartPaymentData) { + $cart->removeExtension($key); + } + } + + if (!$skipRecalculate) { + $this->cartService->recalculate($cart, $context); + } + } + + private function getExtensionNameForExpressCheckout(string $paymentMethodId): string + { + return CheckoutCartPaymentData::EXTENSION_NAME . $paymentMethodId . '_express'; + } } diff --git a/src/Components/GenericExpressCheckout/PaymentHandler/AbstractGenericExpressCheckoutPaymentHandler.php b/src/Components/GenericExpressCheckout/PaymentHandler/AbstractGenericExpressCheckoutPaymentHandler.php index 04448d314..862dd02ac 100644 --- a/src/Components/GenericExpressCheckout/PaymentHandler/AbstractGenericExpressCheckoutPaymentHandler.php +++ b/src/Components/GenericExpressCheckout/PaymentHandler/AbstractGenericExpressCheckoutPaymentHandler.php @@ -5,13 +5,15 @@ namespace PayonePayment\Components\GenericExpressCheckout\PaymentHandler; use PayonePayment\PaymentHandler\AbstractAsynchronousPayonePaymentHandler; -use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\RequestConstants; use PayonePayment\Struct\PaymentTransaction; use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentProcessException; +use Shopware\Core\Checkout\Payment\PaymentException; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\Validator\Constraints\NotBlank; abstract class AbstractGenericExpressCheckoutPaymentHandler extends AbstractAsynchronousPayonePaymentHandler { @@ -24,6 +26,14 @@ public static function isCapturable(array $transactionData, array $payoneTransAc return static::isTransactionAppointedAndCompleted($transactionData) || static::matchesIsCapturableDefaults($transactionData); } + public function getValidationDefinitions(SalesChannelContext $salesChannelContext): array + { + return array_merge(parent::getValidationDefinitions($salesChannelContext), [ + RequestConstants::WORK_ORDER_ID => [new NotBlank()], + RequestConstants::CART_HASH => [new NotBlank()], + ]); + } + public static function isRefundable(array $transactionData): bool { if (static::isNeverRefundable($transactionData)) { @@ -42,15 +52,25 @@ protected function handleResponse( SalesChannelContext $salesChannelContext ): void { if (empty($response['status']) || $response['status'] === 'ERROR') { - throw new AsyncPaymentProcessException( - $transaction->getOrderTransaction()->getId(), - $this->translator->trans('PayonePayment.errorMessages.genericError') - ); + if (class_exists(PaymentException::class)) { + throw PaymentException::asyncProcessInterrupted( + $transaction->getOrderTransaction()->getId(), + $this->translator->trans('PayonePayment.errorMessages.genericError') + ); + } elseif (class_exists(AsyncPaymentProcessException::class)) { + // required for shopware version <= 6.5.3 + // @phpstan-ignore-next-line + throw new AsyncPaymentProcessException( + $transaction->getOrderTransaction()->getId(), + $this->translator->trans('PayonePayment.errorMessages.genericError') + ); + } + + // should never occur. Just to be safe. + throw new \RuntimeException('payment process interrupted.'); } - $data = $this->preparePayoneOrderTransactionData($request, $response, [ - 'workOrderId' => $dataBag->get('workorder'), - ]); + $data = $this->preparePayoneOrderTransactionData($request, $response); $this->transactionDataHandler->saveTransactionData($paymentTransaction, $salesChannelContext->getContext(), $data); } diff --git a/src/Components/GenericExpressCheckout/RequestParameterBuilder/CreateCheckoutSessionParameterBuilder.php b/src/Components/GenericExpressCheckout/RequestParameterBuilder/CreateCheckoutSessionParameterBuilder.php index 831d058a5..36f3bec4b 100644 --- a/src/Components/GenericExpressCheckout/RequestParameterBuilder/CreateCheckoutSessionParameterBuilder.php +++ b/src/Components/GenericExpressCheckout/RequestParameterBuilder/CreateCheckoutSessionParameterBuilder.php @@ -4,11 +4,11 @@ namespace PayonePayment\Components\GenericExpressCheckout\RequestParameterBuilder; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; use PayonePayment\Components\GenericExpressCheckout\Struct\CreateExpressCheckoutSessionStruct; use PayonePayment\Components\RedirectHandler\RedirectHandler; use PayonePayment\PaymentHandler\PaymentHandlerGroups; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Storefront\Controller\GenericExpressController; use Shopware\Core\Checkout\Cart\SalesChannel\CartService; @@ -17,11 +17,12 @@ class CreateCheckoutSessionParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( - private readonly CurrencyPrecisionInterface $currencyPrecision, + RequestBuilderServiceAccessor $serviceAccessor, private readonly RouterInterface $router, private readonly RedirectHandler $redirectHandler, private readonly CartService $cartService ) { + parent::__construct($serviceAccessor); } /** @@ -35,7 +36,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): return [ 'request' => self::REQUEST_ACTION_GENERIC_PAYMENT, - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), 'currency' => $currency->getIsoCode(), 'successurl' => $this->getReturnUrl(GenericExpressController::STATE_SUCCESS, $arguments->getPaymentMethod()), 'errorurl' => $this->getReturnUrl(GenericExpressController::STATE_ERROR, $arguments->getPaymentMethod()), diff --git a/src/Components/GenericExpressCheckout/RequestParameterBuilder/GetCheckoutSessionParameterBuilder.php b/src/Components/GenericExpressCheckout/RequestParameterBuilder/GetCheckoutSessionParameterBuilder.php index 6850aceee..25860fa07 100644 --- a/src/Components/GenericExpressCheckout/RequestParameterBuilder/GetCheckoutSessionParameterBuilder.php +++ b/src/Components/GenericExpressCheckout/RequestParameterBuilder/GetCheckoutSessionParameterBuilder.php @@ -4,19 +4,20 @@ namespace PayonePayment\Components\GenericExpressCheckout\RequestParameterBuilder; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; use PayonePayment\Components\GenericExpressCheckout\Struct\GetCheckoutSessionStruct; use PayonePayment\PaymentHandler\PaymentHandlerGroups; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use Shopware\Core\Checkout\Cart\SalesChannel\CartService; class GetCheckoutSessionParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( - private readonly CurrencyPrecisionInterface $currencyPrecision, + RequestBuilderServiceAccessor $serviceAccessor, private readonly CartService $cartService ) { + parent::__construct($serviceAccessor); } /** @@ -30,7 +31,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): return [ 'request' => self::REQUEST_ACTION_GENERIC_PAYMENT, 'workorderid' => $arguments->getWorkorderId(), - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), 'currency' => $currency->getIsoCode(), ]; } diff --git a/src/Components/PaymentFilter/PayolutionPaymentMethodFilter.php b/src/Components/PaymentFilter/PayolutionPaymentMethodFilter.php index 9f31d3054..a284ea441 100644 --- a/src/Components/PaymentFilter/PayolutionPaymentMethodFilter.php +++ b/src/Components/PaymentFilter/PayolutionPaymentMethodFilter.php @@ -15,13 +15,17 @@ class PayolutionPaymentMethodFilter extends DefaultPaymentFilterService protected function additionalChecks(PaymentMethodCollection $methodCollection, PaymentFilterContext $filterContext): void { if (empty($this->getPaymentHandlerConfiguration($filterContext->getSalesChannelContext(), 'CompanyName'))) { - throw new PaymentMethodNotAllowedException('Payolution: missing merchant-company name.'); + throw new PaymentMethodNotAllowedException('Unzer: missing configuration: merchant-company name.'); } - if ($this->paymentHandlerClass === PayonePayolutionInvoicingPaymentHandler::class - && !($this->getPaymentHandlerConfiguration($filterContext->getSalesChannelContext(), 'TransferCompanyData')) - ) { - throw new PaymentMethodNotAllowedException('Payolution Invoicing: Missing configuration.'); + if (!empty($filterContext->getBillingAddress()?->getCompany())) { + if ($this->paymentHandlerClass === PayonePayolutionInvoicingPaymentHandler::class) { + if (!($this->getPaymentHandlerConfiguration($filterContext->getSalesChannelContext(), 'TransferCompanyData'))) { + throw new PaymentMethodNotAllowedException('Unzer Invoice: B2B is not allowed by configuration.'); + } + } else { + throw new PaymentMethodNotAllowedException('Unzer: B2B is only allowed for invoice (if enabled).'); + } } } diff --git a/src/Components/PaymentFilter/TotalPriceFilter.php b/src/Components/PaymentFilter/TotalPriceFilter.php new file mode 100644 index 000000000..2cd26957d --- /dev/null +++ b/src/Components/PaymentFilter/TotalPriceFilter.php @@ -0,0 +1,29 @@ +getOrder()) { + $price = $filterContext->getOrder()->getPrice()->getTotalPrice(); + } elseif ($filterContext->getCart()) { + $price = $filterContext->getCart()->getPrice()->getTotalPrice(); + } else { + return $methodCollection; + } + + if ($price <= 0) { + return $methodCollection->filter(static fn (PaymentMethodEntity $entity) => !is_subclass_of($entity->getHandlerIdentifier(), AbstractPayonePaymentHandler::class)); + } + + return $methodCollection; + } +} diff --git a/src/Components/PaymentStateHandler/PaymentStateHandler.php b/src/Components/PaymentStateHandler/PaymentStateHandler.php index 62b8c59d1..be1e3466a 100644 --- a/src/Components/PaymentStateHandler/PaymentStateHandler.php +++ b/src/Components/PaymentStateHandler/PaymentStateHandler.php @@ -7,6 +7,7 @@ use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentFinalizeException; use Shopware\Core\Checkout\Payment\Exception\CustomerCanceledAsyncPaymentException; +use Shopware\Core\Checkout\Payment\PaymentException; use Symfony\Contracts\Translation\TranslatorInterface; class PaymentStateHandler implements PaymentStateHandlerInterface @@ -15,27 +16,30 @@ public function __construct(private readonly TranslatorInterface $translator) { } - public function handleStateResponse(AsyncPaymentTransactionStruct $transaction, string $state): void + public function handleStateResponse(AsyncPaymentTransactionStruct $transaction, string|null $state): void { - if (empty($state)) { - throw new AsyncPaymentFinalizeException( - $transaction->getOrderTransaction()->getId(), - $this->translator->trans('PayonePayment.errorMessages.genericError') - ); + if (empty($state) || $state === 'error') { + if (class_exists(PaymentException::class)) { + throw PaymentException::asyncFinalizeInterrupted($transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError')); + } elseif (class_exists(AsyncPaymentFinalizeException::class)) { + // required for shopware version <= 6.5.3 + throw new AsyncPaymentFinalizeException($transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError')); // @phpstan-ignore-line + } + + // should never occur, just to be safe. - this will lead into a fatal error. The user can not keep going with processing the order. + throw new \RuntimeException('payment finalize was interrupted ' . $transaction->getOrderTransaction()->getId()); } if ($state === 'cancel') { - throw new CustomerCanceledAsyncPaymentException( - $transaction->getOrderTransaction()->getId(), - '' - ); - } + if (class_exists(PaymentException::class)) { + throw PaymentException::customerCanceled($transaction->getOrderTransaction()->getId(), ''); + } elseif (class_exists(CustomerCanceledAsyncPaymentException::class)) { + // required for shopware version <= 6.5.3 + throw new CustomerCanceledAsyncPaymentException($transaction->getOrderTransaction()->getId(), ''); // @phpstan-ignore-line + } - if ($state === 'error') { - throw new AsyncPaymentFinalizeException( - $transaction->getOrderTransaction()->getId(), - $this->translator->trans('PayonePayment.errorMessages.genericError') - ); + // should never occur, just to be safe. - this will lead into a fatal error. The user can not keep going with processing the order. + throw new \RuntimeException('payment was canceled by the customer ' . $transaction->getOrderTransaction()->getId()); } } } diff --git a/src/Components/PaymentStateHandler/PaymentStateHandlerInterface.php b/src/Components/PaymentStateHandler/PaymentStateHandlerInterface.php index 0722663bd..a78af6f66 100644 --- a/src/Components/PaymentStateHandler/PaymentStateHandlerInterface.php +++ b/src/Components/PaymentStateHandler/PaymentStateHandlerInterface.php @@ -8,5 +8,5 @@ interface PaymentStateHandlerInterface { - public function handleStateResponse(AsyncPaymentTransactionStruct $transaction, string $state): void; + public function handleStateResponse(AsyncPaymentTransactionStruct $transaction, string|null $state): void; } diff --git a/src/Components/Validator/Birthday.php b/src/Components/Validator/Birthday.php index 26b3f12ca..d0b4a4461 100644 --- a/src/Components/Validator/Birthday.php +++ b/src/Components/Validator/Birthday.php @@ -4,22 +4,42 @@ namespace PayonePayment\Components\Validator; -use Symfony\Component\Validator\Constraints\AbstractComparison; +use Symfony\Component\Validator\Constraints\LessThanOrEqual; -/** - * @Annotation - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) - */ -class Birthday extends AbstractComparison +class Birthday extends LessThanOrEqual { - final public const TOO_HIGH_ERROR = 'ac2f93c6-f906-47c9-8b09-6f7cf41f4f49'; + /** + * @var int + */ + final public const LEGAL_AGE = 18; + + /** + * @var string + */ + final public const INVALID_AGE = 'PAYONE_BIRTHDAY_NOT_VALID'; + /** + * @var array + */ protected const ERROR_NAMES = [ - self::TOO_HIGH_ERROR => 'PAYONE_BIRTHDAY_NOT_VALID', + self::TOO_HIGH_ERROR => self::INVALID_AGE, ]; /** - * @phpstan-ignore-next-line + * @var string[] + * @deprecated since Symfony 6.1, use const ERROR_NAMES instead */ - public $message = 'This value should be less than or equal to {{ compared_value }}.'; + protected static $errorNames = self::ERROR_NAMES; + + public function __construct(mixed $options = null) + { + $options ??= []; + $options['value'] = sprintf('-%d years', self::LEGAL_AGE); + parent::__construct($options); + } + + public function validatedBy(): string + { + return BirthdayValidator::class; + } } diff --git a/src/Components/Validator/BirthdayValidator.php b/src/Components/Validator/BirthdayValidator.php index 878fbbd07..e2d1b2829 100644 --- a/src/Components/Validator/BirthdayValidator.php +++ b/src/Components/Validator/BirthdayValidator.php @@ -4,32 +4,26 @@ namespace PayonePayment\Components\Validator; -use Symfony\Component\Validator\Constraints\AbstractComparisonValidator; +use DateTime; +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\LessThanOrEqualValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; -class BirthdayValidator extends AbstractComparisonValidator +class BirthdayValidator extends LessThanOrEqualValidator { - /** - * @param string $value1 - * @param \DateTimeInterface $value2 - * - * @return bool true if value1 is lower than value2, false otherwise - */ - protected function compareValues($value1, $value2): bool + public function validate(mixed $value, Constraint $constraint): void { - if (empty($value1)) { - return false; + if (!$constraint instanceof Birthday) { + throw new UnexpectedTypeException($constraint, Birthday::class); } - $birthday = \DateTime::createFromFormat('Y-m-d', $value1); + $value = ($value ? DateTime::createFromFormat('Y-m-d', $value) : null) ?: null; - return $birthday < $value2; - } + if (!$value instanceof DateTime) { + // if value is null the comparison `null < DateTime` will be result into true. + $value = new DateTime(); // `now` is not allowed by constraint + } - /** - * {@inheritdoc} - */ - protected function getErrorCode(): ?string - { - return Birthday::TOO_HIGH_ERROR; + parent::validate($value, $constraint); } } diff --git a/src/Components/Validator/Iban.php b/src/Components/Validator/Iban.php index b52460db2..fac1e30da 100644 --- a/src/Components/Validator/Iban.php +++ b/src/Components/Validator/Iban.php @@ -12,10 +12,7 @@ */ class Iban extends \Symfony\Component\Validator\Constraints\Iban { - /** - * @phpstan-ignore-next-line - */ - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::INVALID_COUNTRY_CODE_ERROR => 'PAYONE_INVALID_COUNTRY_CODE_ERROR', self::INVALID_CHARACTERS_ERROR => 'PAYONE_INVALID_CHARACTERS_ERROR', self::CHECKSUM_FAILED_ERROR => 'PAYONE_CHECKSUM_FAILED_ERROR', @@ -23,6 +20,11 @@ class Iban extends \Symfony\Component\Validator\Constraints\Iban self::NOT_SUPPORTED_COUNTRY_CODE_ERROR => 'PAYONE_NOT_SUPPORTED_COUNTRY_CODE_ERROR', ]; + /** + * @phpstan-ignore-next-line + */ + protected static $errorNames = self::ERROR_NAMES; + public function validatedBy(): string { return IbanValidator::class; diff --git a/src/Components/Validator/PaymentMethod.php b/src/Components/Validator/PaymentMethod.php deleted file mode 100644 index 0d72879f8..000000000 --- a/src/Components/Validator/PaymentMethod.php +++ /dev/null @@ -1,25 +0,0 @@ - 'PAYONE_INVALID_PAYMENT_METHOD', - ]; - - /** - * @phpstan-ignore-next-line - */ - public $message = 'The selected payment method {{ compared_value }} is not available.'; -} diff --git a/src/Components/Validator/PaymentMethodValidator.php b/src/Components/Validator/PaymentMethodValidator.php deleted file mode 100644 index 601fbe631..000000000 --- a/src/Components/Validator/PaymentMethodValidator.php +++ /dev/null @@ -1,26 +0,0 @@ -authorizationType; } - public function getWorkOrderId(): ?string - { - return $this->workOrderId; - } - public function getClearingReference(): ?string { return $this->clearingReference; diff --git a/src/DependencyInjection/controllers.xml b/src/DependencyInjection/controllers.xml index b646b8ffb..a6341c296 100644 --- a/src/DependencyInjection/controllers.xml +++ b/src/DependencyInjection/controllers.xml @@ -40,7 +40,7 @@ - + %kernel.project_dir% @@ -104,7 +104,9 @@ - + + + diff --git a/src/DependencyInjection/handler/global_handlers.xml b/src/DependencyInjection/handler/global_handlers.xml index ff87363ac..266f8ab15 100644 --- a/src/DependencyInjection/handler/global_handlers.xml +++ b/src/DependencyInjection/handler/global_handlers.xml @@ -41,13 +41,13 @@ - + - + diff --git a/src/DependencyInjection/handler/payment_handler.xml b/src/DependencyInjection/handler/payment_handler.xml index b0698abb6..7b98d1d30 100644 --- a/src/DependencyInjection/handler/payment_handler.xml +++ b/src/DependencyInjection/handler/payment_handler.xml @@ -19,6 +19,7 @@ + + - @@ -114,7 +113,7 @@ - + diff --git a/src/DependencyInjection/payment_method_filter.xml b/src/DependencyInjection/payment_method_filter.xml index cb86dc8d0..58c61aade 100644 --- a/src/DependencyInjection/payment_method_filter.xml +++ b/src/DependencyInjection/payment_method_filter.xml @@ -32,6 +32,10 @@ + + + + diff --git a/src/DependencyInjection/requestParameter/builder.xml b/src/DependencyInjection/requestParameter/builder.xml index 90d3263dd..f9f1e05f8 100644 --- a/src/DependencyInjection/requestParameter/builder.xml +++ b/src/DependencyInjection/requestParameter/builder.xml @@ -4,15 +4,28 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> + + + + + + + + + + + + + + + + + - - - - @@ -31,49 +44,45 @@ - + - - %kernel.shopware_version% - + + %kernel.shopware_version% - - - - + + + + - - - + - - - - + @@ -196,20 +205,12 @@ - - - - - - - - @@ -217,26 +218,19 @@ - - + - - - - - - @@ -309,23 +303,18 @@ - - - - - @@ -333,35 +322,29 @@ - - - - - - - - - + + + - - - - - + + + @@ -369,11 +352,8 @@ - - - - - + + @@ -393,17 +373,12 @@ - - - - - + parent="PayonePayment\Payone\RequestParameter\Builder\GeneralTransactionRequestParameterBuilder"> @@ -440,18 +415,21 @@ - - - - - + + - - + + + - + + + @@ -463,7 +441,9 @@ - + + @@ -489,22 +469,13 @@ - - - - - + - - - - - @@ -512,22 +483,13 @@ - - - - - + - - - - - @@ -535,31 +497,19 @@ - - - - - + - - - - - - - - - - + @@ -577,9 +527,10 @@ - - - + + + @@ -587,12 +538,10 @@ - - @@ -607,8 +556,6 @@ - - @@ -616,7 +563,6 @@ - @@ -624,7 +570,6 @@ - @@ -632,12 +577,14 @@ + + diff --git a/src/DependencyInjection/scheduled_tasks.xml b/src/DependencyInjection/scheduled_tasks.xml index 18a524c9c..587ae8ac6 100644 --- a/src/DependencyInjection/scheduled_tasks.xml +++ b/src/DependencyInjection/scheduled_tasks.xml @@ -11,7 +11,7 @@ - + diff --git a/src/DependencyInjection/services.xml b/src/DependencyInjection/services.xml index 47febd145..c8b810ad0 100644 --- a/src/DependencyInjection/services.xml +++ b/src/DependencyInjection/services.xml @@ -49,7 +49,7 @@ - + @@ -62,16 +62,10 @@ - + - - - - payone_payment - - @@ -115,7 +109,7 @@ - + @@ -135,5 +129,11 @@ + + + + + + diff --git a/src/DependencyInjection/store_api.xml b/src/DependencyInjection/store_api.xml index ab9fa5342..400df753f 100644 --- a/src/DependencyInjection/store_api.xml +++ b/src/DependencyInjection/store_api.xml @@ -16,7 +16,7 @@ - + diff --git a/src/DependencyInjection/webhooks.xml b/src/DependencyInjection/webhooks.xml index b2bdba051..846bcec4e 100644 --- a/src/DependencyInjection/webhooks.xml +++ b/src/DependencyInjection/webhooks.xml @@ -7,13 +7,13 @@ - + - + @@ -22,7 +22,7 @@ - + diff --git a/src/EventListener/CheckoutConfirmCartDataEventListener.php b/src/EventListener/CheckoutConfirmCartDataEventListener.php index bb4f29b0f..062cd7230 100644 --- a/src/EventListener/CheckoutConfirmCartDataEventListener.php +++ b/src/EventListener/CheckoutConfirmCartDataEventListener.php @@ -4,20 +4,15 @@ namespace PayonePayment\EventListener; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; use PayonePayment\Components\Helper\OrderFetcherInterface; -use PayonePayment\Installer\PaymentMethodInstaller; use PayonePayment\Storefront\Struct\CheckoutCartPaymentData; use PayonePayment\Storefront\Struct\CheckoutConfirmPaymentData; use Shopware\Core\Checkout\Cart\Cart; use Shopware\Core\Checkout\Cart\Order\OrderConverter; use Shopware\Core\Checkout\Order\OrderEntity; -use Shopware\Core\Checkout\Payment\PaymentMethodEntity; use Shopware\Core\Framework\Context; use Shopware\Core\System\SalesChannel\SalesChannelContext; -use Shopware\Storefront\Page\Account\Order\AccountEditOrderPage; use Shopware\Storefront\Page\Account\Order\AccountEditOrderPageLoadedEvent; -use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPage; use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Process\Exception\LogicException; @@ -26,8 +21,7 @@ class CheckoutConfirmCartDataEventListener implements EventSubscriberInterface { public function __construct( private readonly OrderConverter $orderConverter, - private readonly OrderFetcherInterface $orderFetcher, - private readonly CurrencyPrecisionInterface $currencyPrecision + private readonly OrderFetcherInterface $orderFetcher ) { } @@ -50,8 +44,6 @@ public function addCartData(AccountEditOrderPageLoadedEvent|CheckoutConfirmPageL $cart = $this->convertCartFromOrder($order, $event->getContext()); } - $this->hidePayonePaymentMethodsOnZeroAmountCart($page, $cart, $event->getSalesChannelContext()); - if ($cart->hasExtension(CheckoutCartPaymentData::EXTENSION_NAME)) { $payoneData = $cart->getExtension(CheckoutCartPaymentData::EXTENSION_NAME); } else { @@ -64,34 +56,14 @@ public function addCartData(AccountEditOrderPageLoadedEvent|CheckoutConfirmPageL if ($extension !== null) { $payoneData->assign([ - 'workOrderId' => $extension->getWorkorderId(), - 'cartHash' => $extension->getCartHash(), + CheckoutCartPaymentData::DATA_WORK_ORDER_ID => $extension->getWorkorderId(), + CheckoutCartPaymentData::DATA_CART_HASH => $extension->getCartHash(), ]); } $page->addExtension(CheckoutConfirmPaymentData::EXTENSION_NAME, $payoneData); } } - private function hidePayonePaymentMethodsOnZeroAmountCart( - AccountEditOrderPage|CheckoutConfirmPage $page, - Cart $cart, - SalesChannelContext $salesChannelContext - ): void { - $totalAmount = $this->currencyPrecision->getRoundedItemAmount($cart->getPrice()->getTotalPrice(), $salesChannelContext->getCurrency()); - - if ($totalAmount > 0) { - return; - } - - $page->setPaymentMethods( - $page->getPaymentMethods()->filter( - static fn (PaymentMethodEntity $paymentMethod) => !str_contains($paymentMethod->getHandlerIdentifier(), PaymentMethodInstaller::HANDLER_IDENTIFIER_ROOT_NAMESPACE) - ) - ); - - $salesChannelContext->assign(['paymentMethods' => $page->getPaymentMethods()]); - } - private function convertCartFromOrder(OrderEntity $orderEntity, Context $context): Cart { $order = $this->orderFetcher->getOrderById($orderEntity->getId(), $context); diff --git a/src/EventListener/CheckoutConfirmKlarnaPaymentEventListener.php b/src/EventListener/CheckoutConfirmKlarnaPaymentEventListener.php index 5caed219a..a7b64c437 100644 --- a/src/EventListener/CheckoutConfirmKlarnaPaymentEventListener.php +++ b/src/EventListener/CheckoutConfirmKlarnaPaymentEventListener.php @@ -7,6 +7,7 @@ use PayonePayment\Components\KlarnaSessionService\KlarnaSessionServiceInterface; use PayonePayment\PaymentHandler\AbstractKlarnaPaymentHandler; use PayonePayment\Payone\Client\Exception\PayoneRequestException; +use PayonePayment\RequestConstants; use PayonePayment\Storefront\Struct\CheckoutCartPaymentData; use Shopware\Core\Checkout\Payment\PaymentMethodEntity; use Shopware\Storefront\Event\RouteRequest\HandlePaymentMethodRouteRequestEvent; @@ -79,7 +80,7 @@ public function onHandlePaymentMethodRouteRequest(HandlePaymentMethodRouteReques // when user is changing the payment method, no custom params will be sent to the payment handler. // so we need to transfer the parameters, which are required for the payment handler from the storefront-request to the api-request in the background. - $paramsToTransfer = ['workorder', 'carthash', 'payoneKlarnaAuthorizationToken']; + $paramsToTransfer = [RequestConstants::WORK_ORDER_ID, RequestConstants::CART_HASH, 'payoneKlarnaAuthorizationToken']; foreach ($paramsToTransfer as $key) { if ($event->getStorefrontRequest()->request->has($key)) { $event->getStoreApiRequest()->request->set($key, $event->getStorefrontRequest()->request->get($key)); diff --git a/src/EventListener/KernelEventListener.php b/src/EventListener/KernelEventListener.php index 5f2a17ff4..ee592df12 100644 --- a/src/EventListener/KernelEventListener.php +++ b/src/EventListener/KernelEventListener.php @@ -30,7 +30,9 @@ public function onKernelResponse(ResponseEvent $event): void $route = $event->getRequest()->get('_route'); $response = $event->getResponse(); - if ($route === 'api.action.core.save.system-config.batch') { + if ($route === 'api.action.core.save.system-config.batch' + && ($response->getStatusCode() === Response::HTTP_OK || $response->getStatusCode() === Response::HTTP_NO_CONTENT) + ) { $results = []; $configurations = $event->getRequest()->request->all(); @@ -81,6 +83,5 @@ protected function setResponseData(JsonResponse $response, array $updateResults) } $response->setData($data); - $response->setStatusCode(Response::HTTP_OK); } } diff --git a/src/Installer/CustomFieldInstaller.php b/src/Installer/CustomFieldInstaller.php index 67641a8a0..d5b184ba0 100644 --- a/src/Installer/CustomFieldInstaller.php +++ b/src/Installer/CustomFieldInstaller.php @@ -17,13 +17,10 @@ class CustomFieldInstaller implements InstallerInterface { final public const CAPTURED_QUANTITY = 'payone_captured_quantity'; final public const REFUNDED_QUANTITY = 'payone_refunded_quantity'; - final public const CUSTOMER_PHONE_NUMBER = 'payone_customer_phone_number'; - final public const CUSTOMER_BIRTHDAY = 'payone_customer_birthday'; final public const FIELDSET_ID_ORDER_TRANSACTION = 'aacbcf9bedfb4827853b75c5fd278d3f'; final public const FIELDSET_ID_ORDER_LINE_ITEM = '12f3f06c895e11eabc550242ac130003'; final public const FIELDSET_ID_PAYMENT_METHOD = 'ed39626e94fd4dfe9d81976fdbcdb06c'; - final public const FIELDSET_ID_CUSTOMER = '8e4a0b8f7eb04272ad874f3b22cf4935'; private readonly array $customFields; @@ -62,21 +59,6 @@ public function __construct( 'entityName' => 'order_line_item', ], ], - [ - 'id' => self::FIELDSET_ID_CUSTOMER, - 'name' => 'customer_payone_payment', - 'config' => [ - 'label' => [ - 'en-GB' => 'PAYONE', - 'de-DE' => 'PAYONE', - ], - 'translated' => true, - ], - 'relation' => [ - 'id' => '4b23593512f848d8ba360985de234a1b', - 'entityName' => 'customer', - ], - ], ]; $this->customFields = [ @@ -92,25 +74,6 @@ public function __construct( 'type' => CustomFieldTypes::INT, 'customFieldSetId' => self::FIELDSET_ID_ORDER_LINE_ITEM, ], - [ - 'id' => 'e56cc871e9784c3b91dd755511dc0221', - 'name' => self::CUSTOMER_PHONE_NUMBER, - 'type' => CustomFieldTypes::TEXT, - 'customFieldSetId' => self::FIELDSET_ID_CUSTOMER, - 'config' => [ - 'componentName' => 'sw-field', - 'customFieldType' => CustomFieldTypes::TEXT, - 'type' => CustomFieldTypes::TEXT, - 'label' => [ - 'en-GB' => 'Phone Number', - 'de-DE' => 'Telefonnummer', - ], - 'helpText' => [ - 'en-GB' => 'Will be asked for some PAYONE payment methods in the checkout and stored in this field after the first time. After that, the saved phone number is always used and it is no longer requested.', - 'de-DE' => 'Wird bei manchen PAYONE Zahlungsarten im Checkout abgefragt und nach dem ersten mal in diesem Feld gespeichert. Danach wird immer die gespeicherte Telefonnummer verwendet und sie wird nicht mehr abgefragt.', - ], - ], - ], ]; } diff --git a/src/Installer/PaymentMethodInstaller.php b/src/Installer/PaymentMethodInstaller.php index 0a8234088..d2cc55fc0 100644 --- a/src/Installer/PaymentMethodInstaller.php +++ b/src/Installer/PaymentMethodInstaller.php @@ -40,9 +40,11 @@ use PayonePayment\PaymentMethod\PayoneTrustly; use PayonePayment\PaymentMethod\PayoneWeChatPay; use PayonePayment\PayonePayment; +use Shopware\Core\Checkout\Payment\PaymentMethodDefinition; use Shopware\Core\Checkout\Payment\PaymentMethodEntity; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; +use Shopware\Core\Framework\DataAbstractionLayer\Field\Field; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; use Shopware\Core\Framework\Plugin\Context\ActivateContext; @@ -158,7 +160,8 @@ public function __construct( private readonly EntityRepository $paymentMethodRepository, private readonly EntityRepository $salesChannelRepository, private readonly EntityRepository $paymentMethodSalesChannelRepository, - private readonly Connection $connection + private readonly Connection $connection, + private readonly PaymentMethodDefinition $paymentMethodDefinition ) { } @@ -238,6 +241,10 @@ private function upsertPaymentMethod(PaymentMethodInterface $paymentMethod, Cont 'afterOrderEnabled' => \in_array($paymentMethod::class, self::AFTER_ORDER_PAYMENT_METHODS, true), ]; + if ($this->paymentMethodDefinition->getField('technicalName') instanceof Field) { + $data['technicalName'] = $paymentMethod->getTechnicalName(); + } + // Find existing payment method by ID for update / install decision $paymentMethodEntity = $this->findPaymentMethodEntity($paymentMethod->getId(), $context); diff --git a/src/Migration/Migration1638289341AddOrderTransActionDataTable.php b/src/Migration/Migration1638289341AddOrderTransActionDataTable.php index e70e6e71c..4855ea02a 100644 --- a/src/Migration/Migration1638289341AddOrderTransActionDataTable.php +++ b/src/Migration/Migration1638289341AddOrderTransActionDataTable.php @@ -35,7 +35,6 @@ public function update(Connection $connection): void `refunded_amount` INT(11) NULL DEFAULT \'0\', `mandate_identification` VARCHAR(255) NULL, `authorization_type` VARCHAR(255) NULL, - `work_order_id` VARCHAR(255) NULL, `clearing_reference` VARCHAR(255) NULL, `clearing_type` VARCHAR(255) NULL, `financing_type` VARCHAR(255) NULL, diff --git a/src/Migration/Migration1639050658MigrateOrderTransactionDataFromCustomFields.php b/src/Migration/Migration1639050658MigrateOrderTransactionDataFromCustomFields.php index 6d5dd994c..17f8c0faa 100644 --- a/src/Migration/Migration1639050658MigrateOrderTransactionDataFromCustomFields.php +++ b/src/Migration/Migration1639050658MigrateOrderTransactionDataFromCustomFields.php @@ -18,7 +18,7 @@ public function update(Connection $connection): void { $sql = 'INSERT INTO `payone_payment_order_transaction_data` (id, order_transaction_id, order_transaction_version_id, transaction_id, transaction_data, sequence_number, transaction_state, user_id, last_request, - allow_capture, allow_refund, captured_amount, refunded_amount, mandate_identification, authorization_type, work_order_id, + allow_capture, allow_refund, captured_amount, refunded_amount, mandate_identification, authorization_type, clearing_reference, clearing_type, financing_type, capture_mode, clearing_bank_account, additional_data, created_at) SELECT UNHEX(LOWER(CONCAT( LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, \'0\'), @@ -45,7 +45,6 @@ public function update(Connection $connection): void IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT(custom_fields, \'$.payone_refunded_amount\')) as SIGNED), 0) as refunded_amount, JSON_UNQUOTE(JSON_EXTRACT(custom_fields, \'$.payone_mandate_identification\')) as mandate_identification, JSON_UNQUOTE(JSON_EXTRACT(custom_fields, \'$.payone_authorization_type\')) as authorization_type, - NULLIF(JSON_UNQUOTE(JSON_EXTRACT(custom_fields, \'$.payone_work_order_id\')), \'null\') as work_order_id, JSON_UNQUOTE(JSON_EXTRACT(custom_fields, \'$.payone_clearing_reference\')) as clearing_reference, JSON_UNQUOTE(JSON_EXTRACT(custom_fields, \'$.payone_clearing_type\')) as clearing_type, JSON_UNQUOTE(JSON_EXTRACT(custom_fields, \'$.payone_financing_type\')) as financing_type, diff --git a/src/Migration/Migration1712917428TransactionDataRemoveWorkorderId.php b/src/Migration/Migration1712917428TransactionDataRemoveWorkorderId.php new file mode 100644 index 000000000..c84f114ad --- /dev/null +++ b/src/Migration/Migration1712917428TransactionDataRemoveWorkorderId.php @@ -0,0 +1,30 @@ +columnExists($connection, 'payone_payment_order_transaction_data', 'work_order_id')) { + $connection->executeStatement('ALTER TABLE payone_payment_order_transaction_data DROP COLUMN work_order_id'); + } + } +} diff --git a/src/Migration/Migration1713390333DeleteCustomFieldPhone.php b/src/Migration/Migration1713390333DeleteCustomFieldPhone.php new file mode 100644 index 000000000..f24bc272b --- /dev/null +++ b/src/Migration/Migration1713390333DeleteCustomFieldPhone.php @@ -0,0 +1,26 @@ +executeStatement('DELETE FROM custom_field WHERE name = "payone_customer_phone_number";'); + $connection->executeStatement('DELETE FROM custom_field_set WHERE name = "customer_payone_payment";'); + } +} diff --git a/src/PaymentHandler/AbstractAsynchronousPayonePaymentHandler.php b/src/PaymentHandler/AbstractAsynchronousPayonePaymentHandler.php index 3d8af01da..b88c4b7c2 100644 --- a/src/PaymentHandler/AbstractAsynchronousPayonePaymentHandler.php +++ b/src/PaymentHandler/AbstractAsynchronousPayonePaymentHandler.php @@ -5,6 +5,7 @@ namespace PayonePayment\PaymentHandler; use PayonePayment\Components\ConfigReader\ConfigReaderInterface; +use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor; use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface; use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface; use PayonePayment\Components\DeviceFingerprint\AbstractDeviceFingerprintService; @@ -17,6 +18,7 @@ use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; use Shopware\Core\Checkout\Payment\Cart\PaymentHandler\AsynchronousPaymentHandlerInterface; use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentProcessException; +use Shopware\Core\Checkout\Payment\PaymentException; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; @@ -37,6 +39,7 @@ public function __construct( protected readonly OrderActionLogDataHandlerInterface $orderActionLogDataHandler, protected readonly PaymentStateHandlerInterface $stateHandler, protected readonly RequestParameterFactory $requestParameterFactory, + protected readonly CustomerDataPersistor $customerDataPersistor, protected readonly ?AbstractDeviceFingerprintService $deviceFingerprintService = null ) { parent::__construct($configReader, $lineItemRepository, $requestStack); @@ -52,12 +55,14 @@ public function pay( } catch (PayoneRequestException) { $this->beforeException(); - throw new AsyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError') ); } + $this->customerDataPersistor->save($transaction->getOrder(), $dataBag, $salesChannelContext->getContext()); + $paymentTransaction = PaymentTransaction::fromAsyncPaymentTransactionStruct($transaction, $transaction->getOrder()); $authorizationMethod = $this->getAuthorizationMethod( @@ -81,14 +86,14 @@ public function pay( } catch (PayoneRequestException $exception) { $this->beforeException(); - throw new AsyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $exception->getResponse()['error']['CustomerMessage'] ); } catch (\Throwable) { $this->beforeException(); - throw new AsyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError') ); @@ -141,7 +146,7 @@ protected function handleResponse( SalesChannelContext $salesChannelContext ): void { if (empty($response['status']) || $response['status'] !== 'REDIRECT') { - throw new AsyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError') ); @@ -160,4 +165,17 @@ protected function getRedirectResponse(SalesChannelContext $context, array $requ { return new RedirectResponse($response['redirecturl']); } + + protected function createPaymentException(string $orderTransactionId, string $errorMessage, ?\Throwable $e = null): \Throwable + { + if (class_exists(PaymentException::class)) { + return PaymentException::asyncProcessInterrupted($orderTransactionId, $errorMessage, $e); + } elseif (class_exists(AsyncPaymentProcessException::class)) { + // required for shopware version <= 6.5.3 + throw new AsyncPaymentProcessException($orderTransactionId, $errorMessage, $e); // @phpstan-ignore-line + } + + // should never occur, just to be safe. + throw new \RuntimeException('payment process was interrupted ' . $orderTransactionId); + } } diff --git a/src/PaymentHandler/AbstractKlarnaPaymentHandler.php b/src/PaymentHandler/AbstractKlarnaPaymentHandler.php index 192307288..b0c0214b6 100644 --- a/src/PaymentHandler/AbstractKlarnaPaymentHandler.php +++ b/src/PaymentHandler/AbstractKlarnaPaymentHandler.php @@ -6,19 +6,21 @@ use PayonePayment\Components\CartHasher\CartHasherInterface; use PayonePayment\Components\ConfigReader\ConfigReaderInterface; +use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor; use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface; use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface; use PayonePayment\Components\PaymentStateHandler\PaymentStateHandlerInterface; use PayonePayment\Payone\Client\PayoneClientInterface; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\RequestParameterFactory; +use PayonePayment\RequestConstants; use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; -use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentProcessException; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Contracts\Translation\TranslatorInterface; abstract class AbstractKlarnaPaymentHandler extends AbstractAsynchronousPayonePaymentHandler @@ -33,6 +35,7 @@ public function __construct( OrderActionLogDataHandlerInterface $orderActionLogDataHandler, PaymentStateHandlerInterface $stateHandler, RequestParameterFactory $requestParameterFactory, + CustomerDataPersistor $customerDataPersistor, protected CartHasherInterface $cartHasher ) { parent::__construct( @@ -44,10 +47,19 @@ public function __construct( $transactionDataHandler, $orderActionLogDataHandler, $stateHandler, - $requestParameterFactory + $requestParameterFactory, + $customerDataPersistor ); } + public function getValidationDefinitions(SalesChannelContext $salesChannelContext): array + { + return array_merge(parent::getValidationDefinitions($salesChannelContext), [ + RequestConstants::WORK_ORDER_ID => [new NotBlank()], + RequestConstants::CART_HASH => [new NotBlank()], + ]); + } + public function pay( AsyncPaymentTransactionStruct $transaction, RequestDataBag $dataBag, @@ -58,7 +70,7 @@ public function pay( $authToken = $dataBag->get('payoneKlarnaAuthorizationToken'); if (!$authToken) { - throw new AsyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError') ); @@ -101,10 +113,10 @@ private function filterRequestDataBag(RequestDataBag $dataBag): RequestDataBag { $dataBag = clone $dataBag; // prevent modifying the original object $allowedParameters = [ - 'workorder', + RequestConstants::WORK_ORDER_ID, 'payonePaymentMethod', 'payoneKlarnaAuthorizationToken', - 'carthash', + RequestConstants::CART_HASH, ]; foreach ($dataBag->keys() as $key) { if (!\in_array($key, $allowedParameters, true)) { diff --git a/src/PaymentHandler/AbstractPayonePaymentHandler.php b/src/PaymentHandler/AbstractPayonePaymentHandler.php index b60aed6e5..8d7ee2392 100644 --- a/src/PaymentHandler/AbstractPayonePaymentHandler.php +++ b/src/PaymentHandler/AbstractPayonePaymentHandler.php @@ -8,12 +8,14 @@ use PayonePayment\Components\TransactionStatus\TransactionStatusService; use PayonePayment\Configuration\ConfigurationPrefixes; use PayonePayment\Installer\CustomFieldInstaller; +use PayonePayment\RequestConstants; use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemCollection; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\Validator\Constraints\Blank; /** * A base class for payment handlers which implements common processing @@ -49,7 +51,10 @@ public function __construct( public function getValidationDefinitions(SalesChannelContext $salesChannelContext): array { - return []; + return [ + RequestConstants::WORK_ORDER_ID => [new Blank()], // workorder-id is mostly not required. + RequestConstants::CART_HASH => [new Blank()], // cart-hash is mostly not required. + ]; } /** @@ -204,11 +209,6 @@ protected function setLineItemCustomFields(OrderLineItemCollection $lineItem, Co $this->lineItemRepository->update($saveData, $context); } - protected function getMinimumDate(): \DateTimeInterface - { - return (new \DateTime())->modify('-18 years')->setTime(0, 0); - } - protected function customerHasCompanyAddress(SalesChannelContext $salesChannelContext): bool { $customer = $salesChannelContext->getCustomer(); @@ -253,4 +253,6 @@ protected function getAdditionalTransactionData(RequestDataBag $dataBag, array $ { return []; } + + abstract protected function createPaymentException(string $orderTransactionId, string $errorMessage, ?\Throwable $e): \Throwable; } diff --git a/src/PaymentHandler/AbstractSynchronousPayonePaymentHandler.php b/src/PaymentHandler/AbstractSynchronousPayonePaymentHandler.php index 65e19aa54..acece7d1f 100644 --- a/src/PaymentHandler/AbstractSynchronousPayonePaymentHandler.php +++ b/src/PaymentHandler/AbstractSynchronousPayonePaymentHandler.php @@ -5,6 +5,7 @@ namespace PayonePayment\PaymentHandler; use PayonePayment\Components\ConfigReader\ConfigReaderInterface; +use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor; use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface; use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface; use PayonePayment\Components\DeviceFingerprint\AbstractDeviceFingerprintService; @@ -16,6 +17,7 @@ use Shopware\Core\Checkout\Payment\Cart\PaymentHandler\SynchronousPaymentHandlerInterface; use Shopware\Core\Checkout\Payment\Cart\SyncPaymentTransactionStruct; use Shopware\Core\Checkout\Payment\Exception\SyncPaymentProcessException; +use Shopware\Core\Checkout\Payment\PaymentException; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; @@ -33,6 +35,7 @@ public function __construct( protected readonly TransactionDataHandlerInterface $transactionDataHandler, protected readonly OrderActionLogDataHandlerInterface $orderActionLogDataHandler, protected readonly RequestParameterFactory $requestParameterFactory, + protected readonly CustomerDataPersistor $customerDataPersistor, protected readonly ?AbstractDeviceFingerprintService $deviceFingerprintService = null ) { parent::__construct($configReader, $lineItemRepository, $requestStack); @@ -48,12 +51,14 @@ public function pay( } catch (PayoneRequestException) { $this->beforeException(); - throw new SyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError') ); } + $this->customerDataPersistor->save($transaction->getOrder(), $dataBag, $salesChannelContext->getContext()); + $paymentTransaction = PaymentTransaction::fromSyncPaymentTransactionStruct($transaction, $transaction->getOrder()); $authorizationMethod = $this->getAuthorizationMethod( @@ -77,14 +82,14 @@ public function pay( } catch (PayoneRequestException $exception) { $this->beforeException(); - throw new SyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $exception->getResponse()['error']['CustomerMessage'] ); } catch (\Throwable) { $this->beforeException(); - throw new SyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError') ); @@ -127,7 +132,7 @@ protected function handleResponse( SalesChannelContext $salesChannelContext ): void { if (empty($response['status']) || $response['status'] === 'ERROR') { - throw new SyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError') ); @@ -141,4 +146,17 @@ protected function handleResponse( $this->transactionDataHandler->saveTransactionData($paymentTransaction, $salesChannelContext->getContext(), $data); } + + protected function createPaymentException(string $orderTransactionId, string $errorMessage, ?\Throwable $e = null): \Throwable + { + if (class_exists(PaymentException::class)) { + return PaymentException::asyncProcessInterrupted($orderTransactionId, $errorMessage, $e); + } elseif (class_exists(SyncPaymentProcessException::class)) { + // required for shopware version <= 6.5.3 + throw new SyncPaymentProcessException($orderTransactionId, $errorMessage, $e); // @phpstan-ignore-line + } + + // should never occur, just to be safe. + throw new \RuntimeException('payment process was interrupted ' . $orderTransactionId); + } } diff --git a/src/PaymentHandler/PayoneAmazonPayPaymentHandler.php b/src/PaymentHandler/PayoneAmazonPayPaymentHandler.php index cf6955ce5..4fa4fbd84 100644 --- a/src/PaymentHandler/PayoneAmazonPayPaymentHandler.php +++ b/src/PaymentHandler/PayoneAmazonPayPaymentHandler.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Connection; use PayonePayment\Components\AmazonPay\ButtonConfiguration; use PayonePayment\Components\ConfigReader\ConfigReaderInterface; +use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor; use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface; use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface; use PayonePayment\Components\DeviceFingerprint\AbstractDeviceFingerprintService; @@ -15,6 +16,7 @@ use PayonePayment\Payone\Client\PayoneClientInterface; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\RequestParameterFactory; +use PayonePayment\RequestConstants; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Uuid\Uuid; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; @@ -24,6 +26,7 @@ use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Serializer\Encoder\EncoderInterface; use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Contracts\Translation\TranslatorInterface; class PayoneAmazonPayPaymentHandler extends AbstractAsynchronousPayonePaymentHandler @@ -38,13 +41,14 @@ public function __construct( OrderActionLogDataHandlerInterface $orderActionLogDataHandler, PaymentStateHandlerInterface $stateHandler, RequestParameterFactory $requestParameterFactory, + CustomerDataPersistor $customerDataPersistor, private readonly RouterInterface $router, private readonly Connection $connection, private readonly ButtonConfiguration $buttonConfiguration, private readonly EncoderInterface $encoder, ?AbstractDeviceFingerprintService $deviceFingerprintService = null ) { - parent::__construct($configReader, $lineItemRepository, $requestStack, $client, $translator, $transactionDataHandler, $orderActionLogDataHandler, $stateHandler, $requestParameterFactory, $deviceFingerprintService); + parent::__construct($configReader, $lineItemRepository, $requestStack, $client, $translator, $transactionDataHandler, $orderActionLogDataHandler, $stateHandler, $requestParameterFactory, $customerDataPersistor, $deviceFingerprintService); } public static function isCapturable(array $transactionData, array $payoneTransActionData): bool @@ -56,6 +60,17 @@ public static function isCapturable(array $transactionData, array $payoneTransAc return strtolower((string)$transactionData['txaction']) === TransactionStatusService::ACTION_PAID; } + public function getValidationDefinitions(SalesChannelContext $salesChannelContext): array + { + $definitions = parent::getValidationDefinitions($salesChannelContext); + + if (empty($salesChannelContext->getCustomer()?->getActiveBillingAddress()?->getPhoneNumber())) { + $definitions[RequestConstants::PHONE] = [new NotBlank()]; + } + + return $definitions; + } + public static function isRefundable(array $transactionData): bool { if ((float)$transactionData['receivable'] !== 0.0 && strtolower((string)$transactionData['txaction']) === TransactionStatusService::ACTION_CAPTURE) { diff --git a/src/PaymentHandler/PayoneApplePayPaymentHandler.php b/src/PaymentHandler/PayoneApplePayPaymentHandler.php index 2beabe1c4..c8cb0e9f9 100644 --- a/src/PaymentHandler/PayoneApplePayPaymentHandler.php +++ b/src/PaymentHandler/PayoneApplePayPaymentHandler.php @@ -7,7 +7,6 @@ use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; use PayonePayment\Struct\PaymentTransaction; use Shopware\Core\Checkout\Payment\Cart\SyncPaymentTransactionStruct; -use Shopware\Core\Checkout\Payment\Exception\SyncPaymentProcessException; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; @@ -21,14 +20,14 @@ public function pay( $response = json_decode((string) $dataBag->get('response', '{}'), true, 512, \JSON_THROW_ON_ERROR); if ($response === null || !\array_key_exists('status', $response) || !\array_key_exists('txid', $response)) { - throw new SyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError') ); } if ($response['status'] !== 'APPROVED' && $response['status'] !== 'PENDING') { - throw new SyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError') ); diff --git a/src/PaymentHandler/PayoneCreditCardPaymentHandler.php b/src/PaymentHandler/PayoneCreditCardPaymentHandler.php index a6f7882a0..75270fdf5 100644 --- a/src/PaymentHandler/PayoneCreditCardPaymentHandler.php +++ b/src/PaymentHandler/PayoneCreditCardPaymentHandler.php @@ -6,6 +6,7 @@ use PayonePayment\Components\CardRepository\CardRepositoryInterface; use PayonePayment\Components\ConfigReader\ConfigReaderInterface; +use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor; use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface; use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface; use PayonePayment\Components\PaymentStateHandler\PaymentStateHandlerInterface; @@ -15,7 +16,6 @@ use PayonePayment\Payone\RequestParameter\RequestParameterFactory; use PayonePayment\Struct\PaymentTransaction; use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; -use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentProcessException; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; @@ -42,6 +42,7 @@ public function __construct( OrderActionLogDataHandlerInterface $orderActionLogDataHandler, PaymentStateHandlerInterface $stateHandler, RequestParameterFactory $requestParameterFactory, + CustomerDataPersistor $customerDataPersistor, protected CardRepositoryInterface $cardRepository ) { parent::__construct( @@ -53,7 +54,8 @@ public function __construct( $transactionDataHandler, $orderActionLogDataHandler, $stateHandler, - $requestParameterFactory + $requestParameterFactory, + $customerDataPersistor ); } @@ -95,7 +97,7 @@ protected function handleResponse( SalesChannelContext $salesChannelContext ): void { if (empty($response['status']) || $response['status'] === 'ERROR') { - throw new AsyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError') ); diff --git a/src/PaymentHandler/PayoneDebitPaymentHandler.php b/src/PaymentHandler/PayoneDebitPaymentHandler.php index e485d425c..442e926ae 100644 --- a/src/PaymentHandler/PayoneDebitPaymentHandler.php +++ b/src/PaymentHandler/PayoneDebitPaymentHandler.php @@ -5,6 +5,7 @@ namespace PayonePayment\PaymentHandler; use PayonePayment\Components\ConfigReader\ConfigReaderInterface; +use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor; use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface; use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface; use PayonePayment\Components\MandateService\MandateServiceInterface; @@ -33,6 +34,7 @@ public function __construct( TransactionDataHandlerInterface $transactionDataHandler, OrderActionLogDataHandlerInterface $orderActionLogDataHandler, RequestParameterFactory $requestParameterFactory, + CustomerDataPersistor $customerDataPersistor, protected MandateServiceInterface $mandateService ) { parent::__construct( @@ -43,7 +45,8 @@ public function __construct( $translator, $transactionDataHandler, $orderActionLogDataHandler, - $requestParameterFactory + $requestParameterFactory, + $customerDataPersistor ); } diff --git a/src/PaymentHandler/PayonePayolutionDebitPaymentHandler.php b/src/PaymentHandler/PayonePayolutionDebitPaymentHandler.php index 95198a7ba..b3b2e94f9 100644 --- a/src/PaymentHandler/PayonePayolutionDebitPaymentHandler.php +++ b/src/PaymentHandler/PayonePayolutionDebitPaymentHandler.php @@ -4,12 +4,23 @@ namespace PayonePayment\PaymentHandler; -use PayonePayment\Payone\Client\Exception\PayoneRequestException; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; +use Shopware\Core\System\SalesChannel\SalesChannelContext; +use Symfony\Component\Validator\Constraints\NotBlank; class PayonePayolutionDebitPaymentHandler extends AbstractSynchronousPayonePaymentHandler { + public function getValidationDefinitions(SalesChannelContext $salesChannelContext): array + { + $definitions = parent::getValidationDefinitions($salesChannelContext); + + $definitions['payolutionConsent'] = [new NotBlank()]; + $definitions['payolutionMandate'] = [new NotBlank()]; + + return $definitions; + } + public static function isCapturable(array $transactionData, array $payoneTransActionData): bool { if (static::isNeverCapturable($payoneTransActionData)) { @@ -28,17 +39,6 @@ public static function isRefundable(array $transactionData): bool return static::matchesIsRefundableDefaults($transactionData); } - protected function validateRequestData(RequestDataBag $dataBag): void - { - if ($dataBag->get('payolutionConsent') !== 'on') { - throw new PayoneRequestException('No payolutionConsent'); - } - - if ($dataBag->get('payolutionMandate') !== 'on') { - throw new PayoneRequestException('No payolutionMandate'); - } - } - protected function getDefaultAuthorizationMethod(): string { return AbstractRequestParameterBuilder::REQUEST_ACTION_PREAUTHORIZE; @@ -47,7 +47,6 @@ protected function getDefaultAuthorizationMethod(): string protected function getAdditionalTransactionData(RequestDataBag $dataBag, array $request, array $response): array { return [ - 'workOrderId' => $dataBag->get('workorder'), 'clearingReference' => $response['addpaydata']['clearing_reference'], 'captureMode' => AbstractPayonePaymentHandler::PAYONE_STATE_COMPLETED, 'clearingType' => AbstractPayonePaymentHandler::PAYONE_CLEARING_FNC, diff --git a/src/PaymentHandler/PayonePayolutionInstallmentPaymentHandler.php b/src/PaymentHandler/PayonePayolutionInstallmentPaymentHandler.php index 1099b6437..89e3f3f0c 100644 --- a/src/PaymentHandler/PayonePayolutionInstallmentPaymentHandler.php +++ b/src/PaymentHandler/PayonePayolutionInstallmentPaymentHandler.php @@ -6,13 +6,15 @@ use PayonePayment\Components\CartHasher\CartHasherInterface; use PayonePayment\Components\ConfigReader\ConfigReaderInterface; +use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor; use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface; use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface; use PayonePayment\Components\Validator\Birthday; -use PayonePayment\Components\Validator\PaymentMethod; +use PayonePayment\Components\Validator\Iban; use PayonePayment\Payone\Client\PayoneClientInterface; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\RequestParameterFactory; +use PayonePayment\RequestConstants; use Shopware\Core\Checkout\Payment\Cart\SyncPaymentTransactionStruct; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; @@ -32,6 +34,7 @@ public function __construct( TransactionDataHandlerInterface $transactionDataHandler, OrderActionLogDataHandlerInterface $orderActionLogDataHandler, RequestParameterFactory $requestParameterFactory, + CustomerDataPersistor $customerDataPersistor, protected CartHasherInterface $cartHasher ) { parent::__construct( @@ -42,7 +45,8 @@ public function __construct( $translator, $transactionDataHandler, $orderActionLogDataHandler, - $requestParameterFactory + $requestParameterFactory, + $customerDataPersistor ); } @@ -60,12 +64,16 @@ public function getValidationDefinitions(SalesChannelContext $salesChannelContex { $definitions = parent::getValidationDefinitions($salesChannelContext); + $definitions[RequestConstants::WORK_ORDER_ID] = [new NotBlank()]; + $definitions[RequestConstants::CART_HASH] = [new NotBlank()]; + $definitions['payolutionConsent'] = [new NotBlank()]; - $definitions['payolutionBirthday'] = [new NotBlank(), new Birthday(['value' => $this->getMinimumDate()])]; + $definitions[RequestConstants::BIRTHDAY] = [new NotBlank(), new Birthday()]; - if ($this->customerHasCompanyAddress($salesChannelContext)) { - $definitions['payonePaymentMethod'] = [new PaymentMethod(['value' => $salesChannelContext->getPaymentMethod()])]; - } + $definitions['payolutionInstallmentDuration'] = [new NotBlank()]; + $definitions['payolutionAccountOwner'] = [new NotBlank()]; + $definitions['payolutionIban'] = [new NotBlank(), new Iban()]; + $definitions['payolutionBic'] = [new NotBlank()]; return $definitions; } @@ -96,7 +104,6 @@ protected function getDefaultAuthorizationMethod(): string protected function getAdditionalTransactionData(RequestDataBag $dataBag, array $request, array $response): array { return [ - 'workOrderId' => $dataBag->get('workorder'), 'clearingReference' => $response['clearing']['Reference'], 'captureMode' => AbstractPayonePaymentHandler::PAYONE_STATE_COMPLETED, 'clearingType' => AbstractPayonePaymentHandler::PAYONE_CLEARING_FNC, diff --git a/src/PaymentHandler/PayonePayolutionInvoicingPaymentHandler.php b/src/PaymentHandler/PayonePayolutionInvoicingPaymentHandler.php index 084b5b7c0..c42064c1c 100644 --- a/src/PaymentHandler/PayonePayolutionInvoicingPaymentHandler.php +++ b/src/PaymentHandler/PayonePayolutionInvoicingPaymentHandler.php @@ -5,8 +5,8 @@ namespace PayonePayment\PaymentHandler; use PayonePayment\Components\Validator\Birthday; -use PayonePayment\Components\Validator\PaymentMethod; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\RequestConstants; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\Validator\Constraints\NotBlank; @@ -17,17 +17,13 @@ public function getValidationDefinitions(SalesChannelContext $salesChannelContex { $definitions = parent::getValidationDefinitions($salesChannelContext); + $definitions[RequestConstants::WORK_ORDER_ID] = [new NotBlank()]; + $definitions['payolutionConsent'] = [new NotBlank()]; // if the customer has a company address, the birthday is not required if ($salesChannelContext->getCustomer()?->getDefaultBillingAddress()?->getCompany() === null) { - $definitions['payolutionBirthday'] = [new NotBlank(), new Birthday(['value' => $this->getMinimumDate()])]; - } - - $configuration = $this->configReader->read($salesChannelContext->getSalesChannel()->getId()); - - if (!$configuration->get('payolutionInvoicingTransferCompanyData') && $this->customerHasCompanyAddress($salesChannelContext)) { - $definitions['payonePaymentMethod'] = [new PaymentMethod(['value' => $salesChannelContext->getPaymentMethod()])]; + $definitions[RequestConstants::BIRTHDAY] = [new NotBlank(), new Birthday()]; } return $definitions; @@ -59,7 +55,6 @@ protected function getDefaultAuthorizationMethod(): string protected function getAdditionalTransactionData(RequestDataBag $dataBag, array $request, array $response): array { return [ - 'workOrderId' => $dataBag->get('workorder'), 'clearingReference' => $response['addpaydata']['clearing_reference'], 'captureMode' => AbstractPayonePaymentHandler::PAYONE_STATE_COMPLETED, 'clearingType' => AbstractPayonePaymentHandler::PAYONE_CLEARING_FNC, diff --git a/src/PaymentHandler/PayonePaypalPaymentHandler.php b/src/PaymentHandler/PayonePaypalPaymentHandler.php index 65e1701eb..797a75966 100644 --- a/src/PaymentHandler/PayonePaypalPaymentHandler.php +++ b/src/PaymentHandler/PayonePaypalPaymentHandler.php @@ -7,7 +7,6 @@ use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; use PayonePayment\Struct\PaymentTransaction; use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; -use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentProcessException; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -46,7 +45,7 @@ protected function handleResponse( SalesChannelContext $salesChannelContext ): void { if (empty($response['status']) || $response['status'] === 'ERROR') { - throw new AsyncPaymentProcessException( + throw $this->createPaymentException( $transaction->getOrderTransaction()->getId(), $this->translator->trans('PayonePayment.errorMessages.genericError') ); diff --git a/src/PaymentHandler/PayonePrepaymentPaymentHandler.php b/src/PaymentHandler/PayonePrepaymentPaymentHandler.php index 64296691c..a1dda9f59 100644 --- a/src/PaymentHandler/PayonePrepaymentPaymentHandler.php +++ b/src/PaymentHandler/PayonePrepaymentPaymentHandler.php @@ -46,7 +46,6 @@ protected function getDefaultAuthorizationMethod(): string protected function getAdditionalTransactionData(RequestDataBag $dataBag, array $request, array $response): array { return [ - 'workOrderId' => $dataBag->get('workorder'), 'clearingType' => self::PAYONE_CLEARING_VOR, // Store clearing bank account information as custom field of the transaction in order to // use this data for payment instructions of an invoice or similar. diff --git a/src/PaymentHandler/PayoneRatepayDebitPaymentHandler.php b/src/PaymentHandler/PayoneRatepayDebitPaymentHandler.php index 4e4bb64a8..5fc63f297 100644 --- a/src/PaymentHandler/PayoneRatepayDebitPaymentHandler.php +++ b/src/PaymentHandler/PayoneRatepayDebitPaymentHandler.php @@ -7,6 +7,7 @@ use PayonePayment\Components\Validator\Birthday; use PayonePayment\Components\Validator\Iban; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\RequestConstants; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\Validator\Constraints\NotBlank; @@ -18,7 +19,7 @@ public function getValidationDefinitions(SalesChannelContext $salesChannelContex $definitions = parent::getValidationDefinitions($salesChannelContext); $definitions['ratepayIban'] = [new NotBlank(), new Iban()]; - $definitions['ratepayBirthday'] = [new NotBlank(), new Birthday(['value' => $this->getMinimumDate()])]; + $definitions[RequestConstants::BIRTHDAY] = [new NotBlank(), new Birthday()]; return $definitions; } @@ -52,7 +53,6 @@ protected function getAdditionalTransactionData(RequestDataBag $dataBag, array $ $clearingReference = $response['addpaydata']['clearing_reference'] ?? $response['clearing']['Reference']; return [ - 'workOrderId' => $dataBag->get('workorder'), 'clearingReference' => $clearingReference, 'captureMode' => AbstractPayonePaymentHandler::PAYONE_STATE_COMPLETED, 'clearingType' => AbstractPayonePaymentHandler::PAYONE_CLEARING_FNC, diff --git a/src/PaymentHandler/PayoneRatepayInstallmentPaymentHandler.php b/src/PaymentHandler/PayoneRatepayInstallmentPaymentHandler.php index 7be261430..7ea34c43d 100644 --- a/src/PaymentHandler/PayoneRatepayInstallmentPaymentHandler.php +++ b/src/PaymentHandler/PayoneRatepayInstallmentPaymentHandler.php @@ -7,6 +7,7 @@ use PayonePayment\Components\Validator\Birthday; use PayonePayment\Components\Validator\Iban; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\RequestConstants; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\Validator\Constraints\NotBlank; @@ -17,9 +18,18 @@ public function getValidationDefinitions(SalesChannelContext $salesChannelContex { $definitions = parent::getValidationDefinitions($salesChannelContext); - $definitions['ratepayBirthday'] = [new NotBlank(), new Birthday(['value' => $this->getMinimumDate()])]; + if (empty($salesChannelContext->getCustomer()?->getActiveBillingAddress()?->getPhoneNumber())) { + $definitions[RequestConstants::PHONE] = [new NotBlank()]; + } + $definitions[RequestConstants::BIRTHDAY] = [new NotBlank(), new Birthday()]; $definitions['ratepayIban'] = [new Iban()]; + $definitions['ratepayInstallmentAmount'] = [new NotBlank()]; + $definitions['ratepayInstallmentNumber'] = [new NotBlank()]; + $definitions['ratepayLastInstallmentAmount'] = [new NotBlank()]; + $definitions['ratepayInterestRate'] = [new NotBlank()]; + $definitions['ratepayTotalAmount'] = [new NotBlank()]; + return $definitions; } @@ -52,7 +62,6 @@ protected function getAdditionalTransactionData(RequestDataBag $dataBag, array $ $clearingReference = $response['addpaydata']['clearing_reference'] ?? $response['clearing']['Reference']; return [ - 'workOrderId' => $dataBag->get('workorder'), 'clearingReference' => $clearingReference, 'captureMode' => AbstractPayonePaymentHandler::PAYONE_STATE_COMPLETED, 'clearingType' => AbstractPayonePaymentHandler::PAYONE_CLEARING_FNC, diff --git a/src/PaymentHandler/PayoneRatepayInvoicingPaymentHandler.php b/src/PaymentHandler/PayoneRatepayInvoicingPaymentHandler.php index 1d26696fb..9a730ad16 100644 --- a/src/PaymentHandler/PayoneRatepayInvoicingPaymentHandler.php +++ b/src/PaymentHandler/PayoneRatepayInvoicingPaymentHandler.php @@ -6,6 +6,7 @@ use PayonePayment\Components\Validator\Birthday; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\RequestConstants; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\Validator\Constraints\NotBlank; @@ -16,7 +17,7 @@ public function getValidationDefinitions(SalesChannelContext $salesChannelContex { $definitions = parent::getValidationDefinitions($salesChannelContext); - $definitions['ratepayBirthday'] = [new NotBlank(), new Birthday(['value' => $this->getMinimumDate()])]; + $definitions[RequestConstants::BIRTHDAY] = [new NotBlank(), new Birthday()]; return $definitions; } @@ -50,7 +51,6 @@ protected function getAdditionalTransactionData(RequestDataBag $dataBag, array $ $clearingReference = $response['addpaydata']['clearing_reference'] ?? $response['clearing']['Reference']; return [ - 'workOrderId' => $dataBag->get('workorder'), 'clearingReference' => $clearingReference, 'captureMode' => AbstractPayonePaymentHandler::PAYONE_STATE_COMPLETED, 'clearingType' => AbstractPayonePaymentHandler::PAYONE_CLEARING_FNC, diff --git a/src/PaymentHandler/PayoneSecureInvoicePaymentHandler.php b/src/PaymentHandler/PayoneSecureInvoicePaymentHandler.php index 90f2b7313..70a46e3e1 100644 --- a/src/PaymentHandler/PayoneSecureInvoicePaymentHandler.php +++ b/src/PaymentHandler/PayoneSecureInvoicePaymentHandler.php @@ -5,6 +5,7 @@ namespace PayonePayment\PaymentHandler; use PayonePayment\Components\Validator\Birthday; +use PayonePayment\RequestConstants; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\Validator\Constraints\NotBlank; @@ -15,7 +16,7 @@ public function getValidationDefinitions(SalesChannelContext $salesChannelContex $definitions = parent::getValidationDefinitions($salesChannelContext); if (!$this->customerHasCompanyAddress($salesChannelContext)) { - $definitions['payoneInvoiceBirthday'] = [new NotBlank(), new Birthday(['value' => $this->getMinimumDate()])]; + $definitions[RequestConstants::BIRTHDAY] = [new NotBlank(), new Birthday()]; } return $definitions; diff --git a/src/PaymentHandler/PayoneSecuredDirectDebitPaymentHandler.php b/src/PaymentHandler/PayoneSecuredDirectDebitPaymentHandler.php index 1da0f9be3..e6b3dd0de 100644 --- a/src/PaymentHandler/PayoneSecuredDirectDebitPaymentHandler.php +++ b/src/PaymentHandler/PayoneSecuredDirectDebitPaymentHandler.php @@ -4,8 +4,10 @@ namespace PayonePayment\PaymentHandler; +use PayonePayment\Components\Validator\Birthday; use PayonePayment\Components\Validator\Iban; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\RequestConstants; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\Validator\Constraints\NotBlank; @@ -34,7 +36,12 @@ public function getValidationDefinitions(SalesChannelContext $salesChannelContex { $definitions = parent::getValidationDefinitions($salesChannelContext); + if (empty($salesChannelContext->getCustomer()?->getActiveBillingAddress()?->getPhoneNumber())) { + $definitions[RequestConstants::PHONE] = [new NotBlank()]; + } + $definitions['securedDirectDebitIban'] = [new NotBlank(), new Iban()]; + $definitions[RequestConstants::BIRTHDAY] = [new NotBlank(), new Birthday()]; return $definitions; } diff --git a/src/PaymentHandler/PayoneSecuredInstallmentPaymentHandler.php b/src/PaymentHandler/PayoneSecuredInstallmentPaymentHandler.php index 0dc7ea1ef..15c7a1ba0 100644 --- a/src/PaymentHandler/PayoneSecuredInstallmentPaymentHandler.php +++ b/src/PaymentHandler/PayoneSecuredInstallmentPaymentHandler.php @@ -4,8 +4,10 @@ namespace PayonePayment\PaymentHandler; +use PayonePayment\Components\Validator\Birthday; use PayonePayment\Components\Validator\Iban; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\RequestConstants; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\Validator\Constraints\NotBlank; @@ -16,7 +18,12 @@ public function getValidationDefinitions(SalesChannelContext $salesChannelContex { $definitions = parent::getValidationDefinitions($salesChannelContext); + if (empty($salesChannelContext->getCustomer()?->getActiveBillingAddress()?->getPhoneNumber())) { + $definitions[RequestConstants::PHONE] = [new NotBlank()]; + } $definitions['securedInstallmentIban'] = [new NotBlank(), new Iban()]; + $definitions[RequestConstants::BIRTHDAY] = [new NotBlank(), new Birthday()]; + $definitions['securedInstallmentOptionId'] = [new NotBlank()]; return $definitions; } diff --git a/src/PaymentHandler/PayoneSecuredInvoicePaymentHandler.php b/src/PaymentHandler/PayoneSecuredInvoicePaymentHandler.php index 1a36821a4..97bea5f15 100644 --- a/src/PaymentHandler/PayoneSecuredInvoicePaymentHandler.php +++ b/src/PaymentHandler/PayoneSecuredInvoicePaymentHandler.php @@ -4,8 +4,12 @@ namespace PayonePayment\PaymentHandler; +use PayonePayment\Components\Validator\Birthday; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\RequestConstants; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; +use Shopware\Core\System\SalesChannel\SalesChannelContext; +use Symfony\Component\Validator\Constraints\NotBlank; class PayoneSecuredInvoicePaymentHandler extends AbstractSynchronousPayonePaymentHandler { @@ -27,6 +31,18 @@ public static function isRefundable(array $transactionData): bool return static::matchesIsRefundableDefaults($transactionData); } + public function getValidationDefinitions(SalesChannelContext $salesChannelContext): array + { + $definitions = parent::getValidationDefinitions($salesChannelContext); + + if (empty($salesChannelContext->getCustomer()?->getActiveBillingAddress()?->getPhoneNumber())) { + $definitions[RequestConstants::PHONE] = [new NotBlank()]; + } + $definitions[RequestConstants::BIRTHDAY] = [new NotBlank(), new Birthday()]; + + return $definitions; + } + protected function getDefaultAuthorizationMethod(): string { return AbstractRequestParameterBuilder::REQUEST_ACTION_PREAUTHORIZE; diff --git a/src/PaymentHandler/PayoneTrustlyPaymentHandler.php b/src/PaymentHandler/PayoneTrustlyPaymentHandler.php index 56c8fa067..f4c75a743 100644 --- a/src/PaymentHandler/PayoneTrustlyPaymentHandler.php +++ b/src/PaymentHandler/PayoneTrustlyPaymentHandler.php @@ -5,10 +5,22 @@ namespace PayonePayment\PaymentHandler; use PayonePayment\Components\TransactionStatus\TransactionStatusService; +use PayonePayment\Components\Validator\Iban; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use Shopware\Core\System\SalesChannel\SalesChannelContext; +use Symfony\Component\Validator\Constraints\NotBlank; class PayoneTrustlyPaymentHandler extends AbstractAsynchronousPayonePaymentHandler { + public function getValidationDefinitions(SalesChannelContext $salesChannelContext): array + { + $definitions = parent::getValidationDefinitions($salesChannelContext); + + $definitions['iban'] = [new NotBlank(), new Iban()]; + + return $definitions; + } + public static function isCapturable(array $transactionData, array $payoneTransActionData): bool { if ($payoneTransActionData['authorizationType'] !== TransactionStatusService::AUTHORIZATION_TYPE_PREAUTHORIZATION) { diff --git a/src/PaymentMethod/AbstractPaymentMethod.php b/src/PaymentMethod/AbstractPaymentMethod.php index 5ca76cf90..800ce197e 100644 --- a/src/PaymentMethod/AbstractPaymentMethod.php +++ b/src/PaymentMethod/AbstractPaymentMethod.php @@ -54,4 +54,9 @@ public function getPosition(): int { return $this->position; } + + final public function getTechnicalName(): string + { + return \constant(static::class . '::TECHNICAL_NAME'); + } } diff --git a/src/PaymentMethod/PaymentMethodInterface.php b/src/PaymentMethod/PaymentMethodInterface.php index 83bd1fa23..8d452dff3 100644 --- a/src/PaymentMethod/PaymentMethodInterface.php +++ b/src/PaymentMethod/PaymentMethodInterface.php @@ -19,4 +19,6 @@ public function getTemplate(): ?string; public function getTranslations(): array; public function getPosition(): int; + + public function getTechnicalName(): string; } diff --git a/src/PaymentMethod/PayoneAlipay.php b/src/PaymentMethod/PayoneAlipay.php index 95a2befc2..4ef19a450 100644 --- a/src/PaymentMethod/PayoneAlipay.php +++ b/src/PaymentMethod/PayoneAlipay.php @@ -11,6 +11,8 @@ class PayoneAlipay extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_alipay'; + protected string $id = self::UUID; protected string $name = 'PAYONE Alipay'; diff --git a/src/PaymentMethod/PayoneAmazonPay.php b/src/PaymentMethod/PayoneAmazonPay.php index ca585ed0a..984b4a033 100644 --- a/src/PaymentMethod/PayoneAmazonPay.php +++ b/src/PaymentMethod/PayoneAmazonPay.php @@ -11,6 +11,8 @@ class PayoneAmazonPay extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_amazon_pay'; + protected string $id = self::UUID; protected string $name = 'PAYONE Amazon Pay'; diff --git a/src/PaymentMethod/PayoneAmazonPayExpress.php b/src/PaymentMethod/PayoneAmazonPayExpress.php index 5a461765b..c8beff495 100644 --- a/src/PaymentMethod/PayoneAmazonPayExpress.php +++ b/src/PaymentMethod/PayoneAmazonPayExpress.php @@ -6,12 +6,13 @@ use PayonePayment\Installer\PaymentMethodInstaller; use PayonePayment\PaymentHandler\PayoneAmazonPayExpressPaymentHandler; -use PayonePayment\PaymentHandler\PayoneWeChatPayPaymentHandler; class PayoneAmazonPayExpress extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_amazon_pay_express'; + protected string $id = self::UUID; protected string $name = 'PAYONE Amazon Pay Express'; diff --git a/src/PaymentMethod/PayoneApplePay.php b/src/PaymentMethod/PayoneApplePay.php index afbc4d519..b328d5823 100644 --- a/src/PaymentMethod/PayoneApplePay.php +++ b/src/PaymentMethod/PayoneApplePay.php @@ -11,6 +11,8 @@ class PayoneApplePay extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_apple_pay'; + protected string $id = self::UUID; protected string $name = 'PAYONE Apple Pay'; diff --git a/src/PaymentMethod/PayoneBancontact.php b/src/PaymentMethod/PayoneBancontact.php index 255eef1d9..7b62ff05d 100644 --- a/src/PaymentMethod/PayoneBancontact.php +++ b/src/PaymentMethod/PayoneBancontact.php @@ -11,6 +11,8 @@ class PayoneBancontact extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_bancontact'; + protected string $id = self::UUID; protected string $name = 'PAYONE Bancontact'; diff --git a/src/PaymentMethod/PayoneCreditCard.php b/src/PaymentMethod/PayoneCreditCard.php index 3f2600a64..747dd9c6d 100644 --- a/src/PaymentMethod/PayoneCreditCard.php +++ b/src/PaymentMethod/PayoneCreditCard.php @@ -11,6 +11,8 @@ class PayoneCreditCard extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_creditcard'; + protected string $id = self::UUID; protected string $name = 'PAYONE Credit Card'; diff --git a/src/PaymentMethod/PayoneDebit.php b/src/PaymentMethod/PayoneDebit.php index 16a9deb0f..dd0559302 100644 --- a/src/PaymentMethod/PayoneDebit.php +++ b/src/PaymentMethod/PayoneDebit.php @@ -11,6 +11,8 @@ class PayoneDebit extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_debit'; + protected string $id = self::UUID; protected string $name = 'PAYONE Lastschrift'; diff --git a/src/PaymentMethod/PayoneEps.php b/src/PaymentMethod/PayoneEps.php index 661680816..cdd375ceb 100644 --- a/src/PaymentMethod/PayoneEps.php +++ b/src/PaymentMethod/PayoneEps.php @@ -11,6 +11,8 @@ class PayoneEps extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_eps'; + protected string $id = self::UUID; protected string $name = 'PAYONE eps'; diff --git a/src/PaymentMethod/PayoneIDeal.php b/src/PaymentMethod/PayoneIDeal.php index fe725c9ea..d8a205855 100644 --- a/src/PaymentMethod/PayoneIDeal.php +++ b/src/PaymentMethod/PayoneIDeal.php @@ -11,6 +11,8 @@ class PayoneIDeal extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_ideal'; + protected string $id = self::UUID; protected string $name = 'PAYONE iDEAL'; diff --git a/src/PaymentMethod/PayoneKlarnaDirectDebit.php b/src/PaymentMethod/PayoneKlarnaDirectDebit.php index 9a29893ac..f6c2efca1 100644 --- a/src/PaymentMethod/PayoneKlarnaDirectDebit.php +++ b/src/PaymentMethod/PayoneKlarnaDirectDebit.php @@ -11,6 +11,8 @@ class PayoneKlarnaDirectDebit extends AbstractPayoneKlarna { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_klarna_direct_debit'; + protected string $id = self::UUID; protected string $name = 'PAYONE Klarna Sofort bezahlen'; // do not replace this by an english wording. (this is the product name) diff --git a/src/PaymentMethod/PayoneKlarnaInstallment.php b/src/PaymentMethod/PayoneKlarnaInstallment.php index cdf5cf894..40bb148b6 100644 --- a/src/PaymentMethod/PayoneKlarnaInstallment.php +++ b/src/PaymentMethod/PayoneKlarnaInstallment.php @@ -11,6 +11,8 @@ class PayoneKlarnaInstallment extends AbstractPayoneKlarna { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_klarna_installment'; + protected string $id = self::UUID; protected string $name = 'PAYONE Klarna Ratenkauf'; // do not replace this by an english wording. (this is the product name) diff --git a/src/PaymentMethod/PayoneKlarnaInvoice.php b/src/PaymentMethod/PayoneKlarnaInvoice.php index 3c5c1286c..c07db10d2 100644 --- a/src/PaymentMethod/PayoneKlarnaInvoice.php +++ b/src/PaymentMethod/PayoneKlarnaInvoice.php @@ -11,6 +11,8 @@ class PayoneKlarnaInvoice extends AbstractPayoneKlarna { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_klarna_invoice'; + protected string $id = self::UUID; protected string $name = 'PAYONE Klarna Rechnung'; // do not replace this by an english wording. (this is the product name) diff --git a/src/PaymentMethod/PayoneOpenInvoice.php b/src/PaymentMethod/PayoneOpenInvoice.php index e3c4f956c..7a7334588 100644 --- a/src/PaymentMethod/PayoneOpenInvoice.php +++ b/src/PaymentMethod/PayoneOpenInvoice.php @@ -11,6 +11,8 @@ class PayoneOpenInvoice extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_open_invoice'; + protected string $id = self::UUID; protected string $name = 'PAYONE Invoice'; diff --git a/src/PaymentMethod/PayonePaydirekt.php b/src/PaymentMethod/PayonePaydirekt.php index 82ecc7cba..3ae6a3a2d 100644 --- a/src/PaymentMethod/PayonePaydirekt.php +++ b/src/PaymentMethod/PayonePaydirekt.php @@ -11,6 +11,8 @@ class PayonePaydirekt extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_paydirekt'; + protected string $id = self::UUID; protected string $name = 'PAYONE paydirekt'; diff --git a/src/PaymentMethod/PayonePayolutionDebit.php b/src/PaymentMethod/PayonePayolutionDebit.php index 40f2c663a..c9e99c45f 100644 --- a/src/PaymentMethod/PayonePayolutionDebit.php +++ b/src/PaymentMethod/PayonePayolutionDebit.php @@ -11,6 +11,8 @@ class PayonePayolutionDebit extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_unzer_debit'; + protected string $id = self::UUID; protected string $name = 'PAYONE Unzer Lastschrift'; diff --git a/src/PaymentMethod/PayonePayolutionInstallment.php b/src/PaymentMethod/PayonePayolutionInstallment.php index c57bd9f58..bf0746005 100644 --- a/src/PaymentMethod/PayonePayolutionInstallment.php +++ b/src/PaymentMethod/PayonePayolutionInstallment.php @@ -11,6 +11,8 @@ class PayonePayolutionInstallment extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_unzer_installment'; + protected string $id = self::UUID; protected string $name = 'PAYONE Unzer Ratenkauf'; diff --git a/src/PaymentMethod/PayonePayolutionInvoicing.php b/src/PaymentMethod/PayonePayolutionInvoicing.php index 57f5713f3..1652d8e95 100644 --- a/src/PaymentMethod/PayonePayolutionInvoicing.php +++ b/src/PaymentMethod/PayonePayolutionInvoicing.php @@ -11,6 +11,8 @@ class PayonePayolutionInvoicing extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_unzer_invoice'; + protected string $id = self::UUID; protected string $name = 'PAYONE Unzer Rechnungskauf'; diff --git a/src/PaymentMethod/PayonePaypal.php b/src/PaymentMethod/PayonePaypal.php index be0a70788..bd5bf9ff2 100644 --- a/src/PaymentMethod/PayonePaypal.php +++ b/src/PaymentMethod/PayonePaypal.php @@ -11,6 +11,8 @@ class PayonePaypal extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_paypal'; + protected string $id = self::UUID; protected string $name = 'PAYONE PayPal'; diff --git a/src/PaymentMethod/PayonePaypalExpress.php b/src/PaymentMethod/PayonePaypalExpress.php index 73188b16d..9d19d5491 100644 --- a/src/PaymentMethod/PayonePaypalExpress.php +++ b/src/PaymentMethod/PayonePaypalExpress.php @@ -11,6 +11,8 @@ class PayonePaypalExpress extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_paypal_express'; + protected string $id = self::UUID; protected string $name = 'PAYONE Paypal Express'; diff --git a/src/PaymentMethod/PayonePostfinanceCard.php b/src/PaymentMethod/PayonePostfinanceCard.php index 0cb0ed7b4..1facc6d28 100644 --- a/src/PaymentMethod/PayonePostfinanceCard.php +++ b/src/PaymentMethod/PayonePostfinanceCard.php @@ -11,6 +11,8 @@ class PayonePostfinanceCard extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_postfinance_card'; + protected string $id = self::UUID; protected string $name = 'PAYONE Postfinance (Card)'; diff --git a/src/PaymentMethod/PayonePostfinanceWallet.php b/src/PaymentMethod/PayonePostfinanceWallet.php index 321171cdd..e4282ff81 100644 --- a/src/PaymentMethod/PayonePostfinanceWallet.php +++ b/src/PaymentMethod/PayonePostfinanceWallet.php @@ -11,6 +11,8 @@ class PayonePostfinanceWallet extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_postfinance_wallet'; + protected string $id = self::UUID; protected string $name = 'PAYONE Postfinance (Wallet)'; diff --git a/src/PaymentMethod/PayonePrepayment.php b/src/PaymentMethod/PayonePrepayment.php index 2889ecc32..f16c67c6b 100644 --- a/src/PaymentMethod/PayonePrepayment.php +++ b/src/PaymentMethod/PayonePrepayment.php @@ -11,6 +11,8 @@ class PayonePrepayment extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_prepayment'; + protected string $id = self::UUID; protected string $name = 'PAYONE Prepayment'; diff --git a/src/PaymentMethod/PayonePrzelewy24.php b/src/PaymentMethod/PayonePrzelewy24.php index 1d384aa94..e7206eb8b 100644 --- a/src/PaymentMethod/PayonePrzelewy24.php +++ b/src/PaymentMethod/PayonePrzelewy24.php @@ -11,6 +11,8 @@ class PayonePrzelewy24 extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_przelewy24'; + protected string $id = self::UUID; protected string $name = 'PAYONE Przelewy24'; diff --git a/src/PaymentMethod/PayoneRatepayDebit.php b/src/PaymentMethod/PayoneRatepayDebit.php index c1f401e80..d3a0d35ab 100644 --- a/src/PaymentMethod/PayoneRatepayDebit.php +++ b/src/PaymentMethod/PayoneRatepayDebit.php @@ -11,6 +11,8 @@ class PayoneRatepayDebit extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_ratepay_debit'; + protected string $id = self::UUID; protected string $name = 'PAYONE Ratepay Direct Debit'; diff --git a/src/PaymentMethod/PayoneRatepayInstallment.php b/src/PaymentMethod/PayoneRatepayInstallment.php index a67ce67ff..b5bd60f48 100644 --- a/src/PaymentMethod/PayoneRatepayInstallment.php +++ b/src/PaymentMethod/PayoneRatepayInstallment.php @@ -11,6 +11,8 @@ class PayoneRatepayInstallment extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_ratepay_installment'; + protected string $id = self::UUID; protected string $name = 'PAYONE Ratepay Installments'; diff --git a/src/PaymentMethod/PayoneRatepayInvoicing.php b/src/PaymentMethod/PayoneRatepayInvoicing.php index 8eb063c78..fc6d03242 100644 --- a/src/PaymentMethod/PayoneRatepayInvoicing.php +++ b/src/PaymentMethod/PayoneRatepayInvoicing.php @@ -11,6 +11,8 @@ class PayoneRatepayInvoicing extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_ratepay_invoice'; + protected string $id = self::UUID; protected string $name = 'PAYONE Ratepay Open Invoice'; diff --git a/src/PaymentMethod/PayoneSecureInvoice.php b/src/PaymentMethod/PayoneSecureInvoice.php index 7dbf3eace..1dc3d8b5d 100644 --- a/src/PaymentMethod/PayoneSecureInvoice.php +++ b/src/PaymentMethod/PayoneSecureInvoice.php @@ -10,6 +10,9 @@ class PayoneSecureInvoice extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + + final public const TECHNICAL_NAME = 'payone_secure_invoice'; + final public const BUSINESSRELATION_B2B = 'b2b'; final public const BUSINESSRELATION_B2C = 'b2c'; diff --git a/src/PaymentMethod/PayoneSecuredDirectDebit.php b/src/PaymentMethod/PayoneSecuredDirectDebit.php index 4c72fe097..46090b889 100644 --- a/src/PaymentMethod/PayoneSecuredDirectDebit.php +++ b/src/PaymentMethod/PayoneSecuredDirectDebit.php @@ -11,6 +11,8 @@ class PayoneSecuredDirectDebit extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_secured_direct_debit'; + protected string $id = self::UUID; protected string $name = 'PAYONE Secured Direct Debit'; diff --git a/src/PaymentMethod/PayoneSecuredInstallment.php b/src/PaymentMethod/PayoneSecuredInstallment.php index beb2265fc..6a0cb7c29 100644 --- a/src/PaymentMethod/PayoneSecuredInstallment.php +++ b/src/PaymentMethod/PayoneSecuredInstallment.php @@ -11,6 +11,8 @@ class PayoneSecuredInstallment extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_secured_installment'; + protected string $id = self::UUID; protected string $name = 'PAYONE Secured Installment'; diff --git a/src/PaymentMethod/PayoneSecuredInvoice.php b/src/PaymentMethod/PayoneSecuredInvoice.php index 297b21b6a..81387d26e 100644 --- a/src/PaymentMethod/PayoneSecuredInvoice.php +++ b/src/PaymentMethod/PayoneSecuredInvoice.php @@ -11,6 +11,8 @@ class PayoneSecuredInvoice extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_secured_invoice'; + protected string $id = self::UUID; protected string $name = 'PAYONE Secured Invoice'; diff --git a/src/PaymentMethod/PayoneSofortBanking.php b/src/PaymentMethod/PayoneSofortBanking.php index b9918879d..59fe4c133 100644 --- a/src/PaymentMethod/PayoneSofortBanking.php +++ b/src/PaymentMethod/PayoneSofortBanking.php @@ -14,6 +14,8 @@ class PayoneSofortBanking extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_sofort'; + protected string $id = self::UUID; protected string $name = 'PAYONE Sofort'; diff --git a/src/PaymentMethod/PayoneTrustly.php b/src/PaymentMethod/PayoneTrustly.php index f0648506f..5610438f0 100644 --- a/src/PaymentMethod/PayoneTrustly.php +++ b/src/PaymentMethod/PayoneTrustly.php @@ -11,6 +11,8 @@ class PayoneTrustly extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_trustly'; + protected string $id = self::UUID; protected string $name = 'PAYONE Trustly'; diff --git a/src/PaymentMethod/PayoneWeChatPay.php b/src/PaymentMethod/PayoneWeChatPay.php index 2eaf9b3e9..5cc17a594 100644 --- a/src/PaymentMethod/PayoneWeChatPay.php +++ b/src/PaymentMethod/PayoneWeChatPay.php @@ -11,6 +11,8 @@ class PayoneWeChatPay extends AbstractPaymentMethod { final public const UUID = PaymentMethodInstaller::PAYMENT_METHOD_IDS[self::class]; + final public const TECHNICAL_NAME = 'payone_wechat'; + protected string $id = self::UUID; protected string $name = 'PAYONE WeChat Pay'; diff --git a/src/Payone/RequestParameter/Builder/AbstractRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/AbstractRequestParameterBuilder.php index 09d80594a..e1d684cb6 100644 --- a/src/Payone/RequestParameter/Builder/AbstractRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/AbstractRequestParameterBuilder.php @@ -4,12 +4,14 @@ namespace PayonePayment\Payone\RequestParameter\Builder; -use PayonePayment\Installer\CustomFieldInstaller; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; +use PayonePayment\RequestConstants; +use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressEntity; use Shopware\Core\Checkout\Order\OrderEntity; +use Shopware\Core\Checkout\Payment\Exception\InvalidOrderException; +use Shopware\Core\Checkout\Payment\PaymentException; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; -use Shopware\Core\Framework\Validation\DataBag\DataBag; use Shopware\Core\System\Currency\CurrencyEntity; use Symfony\Component\HttpFoundation\ParameterBag; @@ -41,6 +43,11 @@ abstract class AbstractRequestParameterBuilder final public const CLEARING_TYPE_ONLINE_BANK_TRANSFER = 'sb'; final public const CLEARING_TYPE_INVOICE = 'rec'; + public function __construct( + protected readonly RequestBuilderServiceAccessor $serviceAccessor + ) { + } + abstract public function getRequestParameter(AbstractRequestParameterStruct $arguments): array; /** @@ -54,10 +61,6 @@ protected function getOrderCurrency(?OrderEntity $order, Context $context): Curr return $order->getCurrency(); } - if (property_exists($this, 'currencyRepository') === false) { - throw new \RuntimeException('currency repository injection missing'); - } - $currencyId = $context->getCurrencyId(); if ($order !== null) { @@ -67,7 +70,7 @@ protected function getOrderCurrency(?OrderEntity $order, Context $context): Curr $criteria = new Criteria([$currencyId]); /** @var CurrencyEntity|null $currency */ - $currency = $this->currencyRepository->search($criteria, $context)->first(); + $currency = $this->serviceAccessor->currencyRepository->search($criteria, $context)->first(); if ($currency === null) { throw new \RuntimeException('missing order currency entity'); @@ -87,90 +90,58 @@ protected function validateMethod(object $object, string $method): void } } - protected function applyPhoneParameter(OrderEntity $order, array &$parameters, ParameterBag $dataBag, Context $context): void + protected function applyPhoneParameter(OrderEntity $order, array &$parameters, ParameterBag $dataBag, Context $context, bool $isOptional = false): void { - $submittedPhoneNumber = $dataBag->get('payonePhone'); - - if (property_exists($this, 'customerRepository') === false) { - throw new \RuntimeException('customer repository injection missing'); - } - - if (!$order->getOrderCustomer()) { - throw new \RuntimeException('missing order customer'); - } + $phoneNumber = $dataBag->get(RequestConstants::PHONE); - $customer = $order->getOrderCustomer()->getCustomer(); - - if (!$customer) { - throw new \RuntimeException('missing customer'); + if (empty($phoneNumber)) { + $orderAddress = $order->getBillingAddress(); + if ($orderAddress === null) { + /** @var OrderAddressEntity|null $orderAddress */ + $orderAddress = $this->serviceAccessor->orderAddressRepository->search(new Criteria([$order->getBillingAddressId()]), $context)->first(); + } + $phoneNumber = $orderAddress?->getPhoneNumber(); } - $customerCustomFields = $customer->getCustomFields() ?? []; - $customFieldPhoneNumber = $customerCustomFields[CustomFieldInstaller::CUSTOMER_PHONE_NUMBER] ?? null; - - if (!empty($submittedPhoneNumber) && $submittedPhoneNumber !== $customFieldPhoneNumber) { - // Update the phone number that is stored at the customer - $customFieldPhoneNumber = $submittedPhoneNumber; - $customerCustomFields[CustomFieldInstaller::CUSTOMER_PHONE_NUMBER] = $customFieldPhoneNumber; - $this->customerRepository->update( - [ - [ - 'id' => $customer->getId(), - 'customFields' => $customerCustomFields, - ], - ], - $context - ); - } + if (empty($phoneNumber)) { + if (!$isOptional) { + throw new \RuntimeException('missing phone number'); + } - if (!$customFieldPhoneNumber) { - throw new \RuntimeException('missing phone number'); + return; } - $parameters['telephonenumber'] = $customerCustomFields[CustomFieldInstaller::CUSTOMER_PHONE_NUMBER]; + $parameters['telephonenumber'] = $phoneNumber; } - protected function applyBirthdayParameter(OrderEntity $order, array &$parameters, string $submittedBirthday, Context $context): void + protected function applyBirthdayParameter(OrderEntity $order, array &$parameters, ParameterBag $dataBag, Context $context, bool $isOptional = false): void { - if (property_exists($this, 'customerRepository') === false) { - throw new \RuntimeException('customer repository injection missing'); - } + $birthday = $dataBag->get(RequestConstants::BIRTHDAY); + $birthday = \is_string($birthday) ? \DateTime::createFromFormat('Y-m-d', $birthday) ?: null : null; - if (!$order->getOrderCustomer()) { - throw new \RuntimeException('missing order customer'); - } + $birthday = $birthday instanceof \DateTimeInterface ? $birthday : $order->getOrderCustomer()?->getCustomer()?->getBirthday(); - $customer = $order->getOrderCustomer()->getCustomer(); + if (!$birthday instanceof \DateTimeInterface) { + if (!$isOptional) { + throw new \RuntimeException('missing birthday'); + } - if (!$customer) { - throw new \RuntimeException('missing customer'); + return; } - $customerCustomFields = $customer->getCustomFields() ?? []; - $customFieldBirthday = $customerCustomFields[CustomFieldInstaller::CUSTOMER_BIRTHDAY] ?? null; - - if (!empty($submittedBirthday) && $submittedBirthday !== $customFieldBirthday) { - // Update the birthday that is stored at the customer - $customFieldBirthday = $submittedBirthday; - $customerCustomFields[CustomFieldInstaller::CUSTOMER_BIRTHDAY] = $customFieldBirthday; - $this->customerRepository->update( - [ - [ - 'id' => $customer->getId(), - 'customFields' => $customerCustomFields, - ], - ], - $context - ); - } + $parameters['birthday'] = $birthday->format('Ymd'); + } - if (!$customFieldBirthday) { - throw new \RuntimeException('missing birthday'); + protected function orderNotFoundException(string $orderId): \Throwable + { + if (class_exists(PaymentException::class)) { + return PaymentException::invalidOrder($orderId); + } elseif (class_exists(InvalidOrderException::class)) { + // required for shopware version <= 6.5.3 + throw new InvalidOrderException($orderId); // @phpstan-ignore-line } - $birthday = \DateTime::createFromFormat('Y-m-d', $customFieldBirthday); - if ($birthday instanceof \DateTimeInterface) { - $parameters['birthday'] = $birthday->format('Ymd'); - } + // should never occur, just to be safe. + throw new \RuntimeException('invalid order ' . $orderId); } } diff --git a/src/Payone/RequestParameter/Builder/Amazon/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/Amazon/AuthorizeRequestParameterBuilder.php index ee587dce5..7c80ea5d8 100644 --- a/src/Payone/RequestParameter/Builder/Amazon/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/Amazon/AuthorizeRequestParameterBuilder.php @@ -7,17 +7,18 @@ use PayonePayment\Components\ConfigReader\ConfigReader; use PayonePayment\Components\ConfigReader\ConfigReaderInterface; use PayonePayment\PaymentHandler\PayoneAmazonPayPaymentHandler; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\System\SalesChannel\SalesChannelContext; class AuthorizeRequestParameterBuilder extends AbstractAmazonRequestParameterBuilder { public function __construct( - private readonly ConfigReaderInterface $configReader, - protected readonly EntityRepository $customerRepository + RequestBuilderServiceAccessor $serviceAccessor, + private readonly ConfigReaderInterface $configReader ) { + parent::__construct($serviceAccessor); } /** diff --git a/src/Payone/RequestParameter/Builder/AmazonPayExpress/CreateCheckoutSessionRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/AmazonPayExpress/CreateCheckoutSessionRequestParameterBuilder.php index 3432da9b3..15bef8503 100644 --- a/src/Payone/RequestParameter/Builder/AmazonPayExpress/CreateCheckoutSessionRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/AmazonPayExpress/CreateCheckoutSessionRequestParameterBuilder.php @@ -7,6 +7,7 @@ use PayonePayment\Components\ConfigReader\ConfigReaderInterface; use PayonePayment\Components\GenericExpressCheckout\Struct\CreateExpressCheckoutSessionStruct; use PayonePayment\Configuration\ConfigurationPrefixes; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; @@ -17,9 +18,11 @@ class CreateCheckoutSessionRequestParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( + RequestBuilderServiceAccessor $serviceAccessor, private readonly EntityRepository $salesChannelRepository, private readonly ConfigReaderInterface $configReader ) { + parent::__construct($serviceAccessor); } /** diff --git a/src/Payone/RequestParameter/Builder/AmazonPayExpress/UpdateCheckoutSessionParameterBuilder.php b/src/Payone/RequestParameter/Builder/AmazonPayExpress/UpdateCheckoutSessionParameterBuilder.php index 6c7519414..c55387176 100644 --- a/src/Payone/RequestParameter/Builder/AmazonPayExpress/UpdateCheckoutSessionParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/AmazonPayExpress/UpdateCheckoutSessionParameterBuilder.php @@ -4,7 +4,7 @@ namespace PayonePayment\Payone\RequestParameter\Builder\AmazonPayExpress; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\AmazonPayExpressUpdateCheckoutSessionStruct; use Shopware\Core\Checkout\Cart\SalesChannel\CartService; @@ -12,9 +12,10 @@ class UpdateCheckoutSessionParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( - private readonly CurrencyPrecisionInterface $currencyPrecision, + RequestBuilderServiceAccessor $serviceAccessor, private readonly CartService $cartService ) { + parent::__construct($serviceAccessor); } /** @@ -29,7 +30,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): return array_merge(parent::getRequestParameter($arguments), [ 'request' => self::REQUEST_ACTION_GENERIC_PAYMENT, 'add_paydata[action]' => 'updateCheckoutSession', - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), 'currency' => $currency->getIsoCode(), 'workorderid' => $arguments->getWorkorderId(), ]); diff --git a/src/Payone/RequestParameter/Builder/ApplePay/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/ApplePay/AuthorizeRequestParameterBuilder.php index e86dab5d1..dcd56e382 100644 --- a/src/Payone/RequestParameter/Builder/ApplePay/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/ApplePay/AuthorizeRequestParameterBuilder.php @@ -4,8 +4,8 @@ namespace PayonePayment\Payone\RequestParameter\Builder\ApplePay; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\ApplePayTransactionStruct; use Shopware\Core\Checkout\Cart\Cart; @@ -27,11 +27,12 @@ class AuthorizeRequestParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( + RequestBuilderServiceAccessor $serviceAccessor, protected CartService $cartService, - protected CurrencyPrecisionInterface $currencyPrecision, protected NumberRangeValueGeneratorInterface $numberRangeValueGenerator, protected EntityRepository $orderRepository ) { + parent::__construct($serviceAccessor); } /** @@ -84,7 +85,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'currency' => $currency->getIsoCode(), 'cardtype' => $this->getCardType($arguments->getRequestData()), - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($amount, $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($amount, $currency), 'reference' => substr($this->getReferenceNumber($arguments, $cart, $order), 0, 20), diff --git a/src/Payone/RequestParameter/Builder/Capture/CaptureRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/Capture/CaptureRequestParameterBuilder.php index 7bc8b7a1d..54b0e7844 100644 --- a/src/Payone/RequestParameter/Builder/Capture/CaptureRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/Capture/CaptureRequestParameterBuilder.php @@ -4,7 +4,6 @@ namespace PayonePayment\Payone\RequestParameter\Builder\Capture; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; use PayonePayment\DataAbstractionLayer\Aggregate\PayonePaymentOrderTransactionDataEntity; use PayonePayment\DataAbstractionLayer\Extension\PayonePaymentOrderTransactionExtension; use PayonePayment\PaymentHandler\PaymentHandlerGroups; @@ -18,7 +17,6 @@ use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\FinancialTransactionStruct; -use Shopware\Core\Checkout\Payment\Exception\InvalidOrderException; use Shopware\Core\System\Currency\CurrencyEntity; class CaptureRequestParameterBuilder extends AbstractRequestParameterBuilder @@ -29,10 +27,6 @@ class CaptureRequestParameterBuilder extends AbstractRequestParameterBuilder final public const SETTLEACCOUNT_AUTO = 'auto'; final public const SETTLEACCOUNT_NO = 'no'; - public function __construct(private readonly CurrencyPrecisionInterface $currencyPrecision) - { - } - /** * @param FinancialTransactionStruct $arguments */ @@ -49,15 +43,15 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): } if ($transactionData === null) { - throw new InvalidOrderException($order->getId()); + throw $this->orderNotFoundException($order->getId()); } if ($transactionData->getSequenceNumber() === null) { - throw new InvalidOrderException($order->getId()); + throw $this->orderNotFoundException($order->getId()); } if ($transactionData->getSequenceNumber() < 0) { - throw new InvalidOrderException($order->getId()); + throw $this->orderNotFoundException($order->getId()); } /** @var CurrencyEntity $currency */ @@ -67,15 +61,11 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'request' => self::REQUEST_ACTION_CAPTURE, 'txid' => $transactionData->getTransactionId(), 'sequencenumber' => $transactionData->getSequenceNumber() + 1, - 'amount' => $this->currencyPrecision->getRoundedTotalAmount((float) $totalAmount, $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount((float) $totalAmount, $currency), 'currency' => $currency->getIsoCode(), 'capturemode' => $this->getCaptureMode($arguments), ]; - if ($transactionData->getWorkOrderId() !== null) { - $parameters['workorderid'] = $transactionData->getWorkOrderId(); - } - if (!empty($transactionData->getCaptureMode())) { $parameters['capturemode'] = $transactionData->getCaptureMode(); } diff --git a/src/Payone/RequestParameter/Builder/CustomerInformationRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/CustomerInformationRequestParameterBuilder.php index 615feed1b..f1552e81e 100644 --- a/src/Payone/RequestParameter/Builder/CustomerInformationRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/CustomerInformationRequestParameterBuilder.php @@ -12,18 +12,14 @@ use PayonePayment\PaymentMethod\PayoneSecureInvoice; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; +use PayonePayment\RequestConstants; use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressEntity; use Shopware\Core\Checkout\Order\OrderEntity; use Shopware\Core\Framework\Context; -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; class CustomerInformationRequestParameterBuilder extends AbstractRequestParameterBuilder { - public function __construct(private readonly EntityRepository $orderAddressRepository) - { - } - /** * @param PaymentTransactionStruct $arguments */ @@ -50,8 +46,8 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): return $parameters; } - if (!empty($dataBag->get('payoneInvoiceBirthday'))) { - $birthday = \DateTime::createFromFormat('Y-m-d', $dataBag->get('payoneInvoiceBirthday')); + if (!empty($dataBag->get(RequestConstants::BIRTHDAY))) { + $birthday = \DateTime::createFromFormat('Y-m-d', $dataBag->get(RequestConstants::BIRTHDAY)); if (!empty($birthday)) { $parameters['birthday'] = $birthday->format('Ymd'); @@ -81,7 +77,7 @@ private function getBillingAddress(OrderEntity $order, Context $context): OrderA $criteria = new Criteria([$order->getBillingAddressId()]); /** @var OrderAddressEntity|null $address */ - $address = $this->orderAddressRepository->search($criteria, $context)->first(); + $address = $this->serviceAccessor->orderAddressRepository->search($criteria, $context)->first(); if ($address === null) { throw new \RuntimeException('missing order customer billing address'); diff --git a/src/Payone/RequestParameter/Builder/CustomerRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/CustomerRequestParameterBuilder.php index 024e8d491..96bf5af4e 100644 --- a/src/Payone/RequestParameter/Builder/CustomerRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/CustomerRequestParameterBuilder.php @@ -51,11 +51,13 @@ class CustomerRequestParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( + RequestBuilderServiceAccessor $serviceAccessor, private readonly EntityRepository $languageRepository, private readonly EntityRepository $salutationRepository, private readonly EntityRepository $countryRepository, private readonly RequestStack $requestStack ) { + parent::__construct($serviceAccessor); } /** diff --git a/src/Payone/RequestParameter/Builder/GeneralTransactionRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/GeneralTransactionRequestParameterBuilder.php index 3c36383ec..c4491ea98 100644 --- a/src/Payone/RequestParameter/Builder/GeneralTransactionRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/GeneralTransactionRequestParameterBuilder.php @@ -6,29 +6,28 @@ use PayonePayment\Components\CartHasher\CartHasherInterface; use PayonePayment\Components\ConfigReader\ConfigReaderInterface; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; use PayonePayment\Configuration\ConfigurationPrefixes; use PayonePayment\DataAbstractionLayer\Aggregate\PayonePaymentOrderTransactionDataEntity; use PayonePayment\DataAbstractionLayer\Extension\PayonePaymentOrderTransactionExtension; use PayonePayment\Installer\PaymentMethodInstaller; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; +use PayonePayment\RequestConstants; use PayonePayment\Struct\PaymentTransaction; use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionCollection; use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity; use Shopware\Core\Checkout\Order\OrderEntity; -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\HttpFoundation\ParameterBag; class GeneralTransactionRequestParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( + RequestBuilderServiceAccessor $serviceAccessor, protected CartHasherInterface $cartHasher, - protected ConfigReaderInterface $configReader, - protected EntityRepository $currencyRepository, - protected CurrencyPrecisionInterface $currencyPrecision + protected ConfigReaderInterface $configReader ) { + parent::__construct($serviceAccessor); } public function getRequestParameter(AbstractRequestParameterStruct $arguments): array @@ -41,7 +40,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): $currency = $this->getOrderCurrency($paymentTransaction->getOrder(), $salesChannelContext->getContext()); $parameters = [ - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($paymentTransaction->getOrder()->getAmountTotal(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($paymentTransaction->getOrder()->getAmountTotal(), $currency), 'currency' => $currency->getIsoCode(), 'reference' => $this->getReferenceNumber($paymentTransaction, true), 'workorderid' => $this->getWorkOrderId($paymentTransaction, $requestData, $salesChannelContext), @@ -97,7 +96,7 @@ private function getWorkOrderId( ParameterBag $dataBag, SalesChannelContext $context ): ?string { - $cartHash = $dataBag->get('carthash'); + $cartHash = $dataBag->get(RequestConstants::CART_HASH); if ($cartHash === null) { return null; @@ -107,7 +106,7 @@ private function getWorkOrderId( return null; } - return $dataBag->get('workorder'); + return $dataBag->get(RequestConstants::WORK_ORDER_ID); } private function getLatestReferenceNumber(PaymentTransaction $transaction): ?string diff --git a/src/Payone/RequestParameter/Builder/Klarna/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/Klarna/AuthorizeRequestParameterBuilder.php index c44affd67..09a0ab59b 100644 --- a/src/Payone/RequestParameter/Builder/Klarna/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/Klarna/AuthorizeRequestParameterBuilder.php @@ -4,16 +4,11 @@ namespace PayonePayment\Payone\RequestParameter\Builder\Klarna; -use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydratorInterface; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; class AuthorizeRequestParameterBuilder extends AbstractKlarnaParameterBuilder { - public function __construct(private readonly LineItemHydratorInterface $lineItemHydrator) - { - } - /** * @param PaymentTransactionStruct $arguments */ @@ -30,7 +25,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): $context = $arguments->getSalesChannelContext()->getContext(); $order = $arguments->getPaymentTransaction()->getOrder(); $currency = $this->getOrderCurrency($order, $context); - $lineItems = $this->lineItemHydrator->mapOrderLines($currency, $order, $context); + $lineItems = $this->serviceAccessor->lineItemHydrator->mapOrderLines($currency, $order, $context); return array_merge($parameter, $lineItems); } diff --git a/src/Payone/RequestParameter/Builder/Klarna/CreateSessionRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/Klarna/CreateSessionRequestParameterBuilder.php index 036cbd1c4..96a0a9531 100644 --- a/src/Payone/RequestParameter/Builder/Klarna/CreateSessionRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/Klarna/CreateSessionRequestParameterBuilder.php @@ -4,9 +4,8 @@ namespace PayonePayment\Payone\RequestParameter\Builder\Klarna; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; use PayonePayment\Components\Helper\OrderFetcherInterface; -use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydratorInterface; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\KlarnaCreateSessionStruct; use Shopware\Core\Checkout\Cart\SalesChannel\CartService; @@ -16,11 +15,11 @@ class CreateSessionRequestParameterBuilder extends AbstractKlarnaParameterBuilder { public function __construct( + RequestBuilderServiceAccessor $serviceAccessor, private readonly CartService $cartService, - private readonly LineItemHydratorInterface $lineItemHydrator, - private readonly CurrencyPrecisionInterface $currencyPrecision, private readonly OrderFetcherInterface $orderFetcher ) { + parent::__construct($serviceAccessor); } /** @@ -35,19 +34,19 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): $order = $this->getOrder($order->getId(), $context); // make sure, all required associations are loaded $totalAmount = $order->getPrice()->getTotalPrice(); $currency = $this->getOrderCurrency($order, $context); - $lineItems = $this->lineItemHydrator->mapOrderLines($currency, $order, $context); + $lineItems = $this->serviceAccessor->lineItemHydrator->mapOrderLines($currency, $order, $context); } else { $cart = $this->cartService->getCart($salesChannelContext->getToken(), $salesChannelContext); $totalAmount = $cart->getPrice()->getTotalPrice(); $currency = $salesChannelContext->getCurrency(); - $lineItems = $this->lineItemHydrator->mapCartLines($cart, $salesChannelContext); + $lineItems = $this->serviceAccessor->lineItemHydrator->mapCartLines($cart, $salesChannelContext); } $parameters = [ 'request' => self::REQUEST_ACTION_GENERIC_PAYMENT, 'add_paydata[action]' => 'start_session', 'clearingtype' => self::CLEARING_TYPE_FINANCING, - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($totalAmount, $salesChannelContext->getCurrency()), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($totalAmount, $salesChannelContext->getCurrency()), 'currency' => $currency->getIsoCode(), ]; diff --git a/src/Payone/RequestParameter/Builder/OpenInvoice/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/OpenInvoice/AuthorizeRequestParameterBuilder.php index 6434d0eeb..c7cde25c5 100644 --- a/src/Payone/RequestParameter/Builder/OpenInvoice/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/OpenInvoice/AuthorizeRequestParameterBuilder.php @@ -4,21 +4,13 @@ namespace PayonePayment\Payone\RequestParameter\Builder\OpenInvoice; -use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydratorInterface; use PayonePayment\PaymentHandler\PayoneOpenInvoicePaymentHandler; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; class AuthorizeRequestParameterBuilder extends AbstractRequestParameterBuilder { - public function __construct( - protected LineItemHydratorInterface $lineItemHydrator, - protected EntityRepository $currencyRepository - ) { - } - /** * @param PaymentTransactionStruct $arguments */ @@ -36,7 +28,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): ]; if ($order->getLineItems() !== null) { - $parameters = array_merge($parameters, $this->lineItemHydrator->mapOrderLines($currency, $order, $context)); + $parameters = array_merge($parameters, $this->serviceAccessor->lineItemHydrator->mapOrderLines($currency, $order, $context)); } return $parameters; diff --git a/src/Payone/RequestParameter/Builder/OrderLinesRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/OrderLinesRequestParameterBuilder.php index 238df3288..6ad0e5959 100644 --- a/src/Payone/RequestParameter/Builder/OrderLinesRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/OrderLinesRequestParameterBuilder.php @@ -4,7 +4,6 @@ namespace PayonePayment\Payone\RequestParameter\Builder; -use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydratorInterface; use PayonePayment\PaymentHandler\AbstractPostfinancePaymentHandler; use PayonePayment\PaymentHandler\PayoneAlipayPaymentHandler; use PayonePayment\PaymentHandler\PayoneBancontactPaymentHandler; @@ -26,10 +25,6 @@ class OrderLinesRequestParameterBuilder extends AbstractRequestParameterBuilder { - public function __construct(private readonly LineItemHydratorInterface $lineItemHydrator) - { - } - /** * @param FinancialTransactionStruct $arguments */ @@ -46,7 +41,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): return []; } - $parameters = $this->lineItemHydrator->mapPayoneOrderLinesByRequest( + $parameters = $this->serviceAccessor->lineItemHydrator->mapPayoneOrderLinesByRequest( $currency, $paymentTransaction->getOrder(), $orderLines, diff --git a/src/Payone/RequestParameter/Builder/PayolutionDebit/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/PayolutionDebit/AuthorizeRequestParameterBuilder.php index 619bbeee1..271a223e3 100644 --- a/src/Payone/RequestParameter/Builder/PayolutionDebit/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/PayolutionDebit/AuthorizeRequestParameterBuilder.php @@ -8,7 +8,6 @@ use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; -use Symfony\Component\HttpFoundation\ParameterBag; class AuthorizeRequestParameterBuilder extends AbstractRequestParameterBuilder { @@ -27,7 +26,12 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'bic' => $dataBag->get('payolutionBic'), ]; - $this->applyBirthdayParameterWithoutCustomField($parameters, $dataBag); + $this->applyBirthdayParameter( + $arguments->getPaymentTransaction()->getOrder(), + $parameters, + $dataBag, + $arguments->getSalesChannelContext()->getContext() + ); return $parameters; } @@ -43,15 +47,4 @@ public function supports(AbstractRequestParameterStruct $arguments): bool return $paymentMethod === PayonePayolutionDebitPaymentHandler::class && $action === self::REQUEST_ACTION_AUTHORIZE; } - - protected function applyBirthdayParameterWithoutCustomField(array &$parameters, ParameterBag $dataBag): void - { - if (!empty($dataBag->get('payolutionBirthday'))) { - $birthday = \DateTime::createFromFormat('Y-m-d', $dataBag->get('payolutionBirthday')); - - if (!empty($birthday)) { - $parameters['birthday'] = $birthday->format('Ymd'); - } - } - } } diff --git a/src/Payone/RequestParameter/Builder/PayolutionInstallment/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/PayolutionInstallment/AuthorizeRequestParameterBuilder.php index 20a40c7b6..18b02baa1 100644 --- a/src/Payone/RequestParameter/Builder/PayolutionInstallment/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/PayolutionInstallment/AuthorizeRequestParameterBuilder.php @@ -28,7 +28,12 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'bankaccountholder' => $dataBag->get('payolutionAccountOwner'), ]; - $this->applyBirthdayParameterWithoutCustomField($parameters, $dataBag); + $this->applyBirthdayParameter( + $arguments->getPaymentTransaction()->getOrder(), + $parameters, + $dataBag, + $arguments->getSalesChannelContext()->getContext() + ); return $parameters; } diff --git a/src/Payone/RequestParameter/Builder/PayolutionInstallment/CalculationRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/PayolutionInstallment/CalculationRequestParameterBuilder.php index 0f7e7a107..dae9b3eb8 100644 --- a/src/Payone/RequestParameter/Builder/PayolutionInstallment/CalculationRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/PayolutionInstallment/CalculationRequestParameterBuilder.php @@ -8,6 +8,7 @@ use PayonePayment\Payone\RequestParameter\Builder\GeneralTransactionRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PayolutionAdditionalActionStruct; +use PayonePayment\RequestConstants; class CalculationRequestParameterBuilder extends GeneralTransactionRequestParameterBuilder { @@ -25,13 +26,13 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'add_paydata[action]' => 'calculation', 'clearingtype' => self::CLEARING_TYPE_FINANCING, 'financingtype' => 'PYS', - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), 'currency' => $currency->getIsoCode(), 'workorderid' => $arguments->getWorkorderId(), ]; - if (!empty($dataBag->get('payolutionBirthday'))) { - $birthday = \DateTime::createFromFormat('Y-m-d', $dataBag->get('payolutionBirthday')); + if (!empty($dataBag->get(RequestConstants::BIRTHDAY))) { + $birthday = \DateTime::createFromFormat('Y-m-d', $dataBag->get(RequestConstants::BIRTHDAY)); if (!empty($birthday)) { $parameters['birthday'] = $birthday->format('Ymd'); diff --git a/src/Payone/RequestParameter/Builder/PayolutionInstallment/PreCheckRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/PayolutionInstallment/PreCheckRequestParameterBuilder.php index e928fc40c..f818572b7 100644 --- a/src/Payone/RequestParameter/Builder/PayolutionInstallment/PreCheckRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/PayolutionInstallment/PreCheckRequestParameterBuilder.php @@ -8,7 +8,7 @@ use PayonePayment\Payone\RequestParameter\Builder\GeneralTransactionRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PayolutionAdditionalActionStruct; -use Symfony\Component\HttpFoundation\ParameterBag; +use PayonePayment\RequestConstants; class PreCheckRequestParameterBuilder extends GeneralTransactionRequestParameterBuilder { @@ -27,12 +27,18 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'add_paydata[payment_type]' => 'Payolution-Installment', 'clearingtype' => self::CLEARING_TYPE_FINANCING, 'financingtype' => 'PYS', - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), 'currency' => $currency->getIsoCode(), 'workorderid' => $arguments->getWorkorderId(), ]; - $this->applyBirthdayParameterWithoutCustomField($parameters, $dataBag); + if (!empty($dataBag->get(RequestConstants::BIRTHDAY))) { + $birthday = \DateTime::createFromFormat('Y-m-d', $dataBag->get(RequestConstants::BIRTHDAY)); + + if (!empty($birthday)) { + $parameters['birthday'] = $birthday->format('Ymd'); + } + } return $parameters; } @@ -48,15 +54,4 @@ public function supports(AbstractRequestParameterStruct $arguments): bool return $paymentMethod === PayonePayolutionInstallmentPaymentHandler::class && $action === self::REQUEST_ACTION_PAYOLUTION_PRE_CHECK; } - - protected function applyBirthdayParameterWithoutCustomField(array &$parameters, ParameterBag $dataBag): void - { - if (!empty($dataBag->get('payolutionBirthday'))) { - $birthday = \DateTime::createFromFormat('Y-m-d', $dataBag->get('payolutionBirthday')); - - if (!empty($birthday)) { - $parameters['birthday'] = $birthday->format('Ymd'); - } - } - } } diff --git a/src/Payone/RequestParameter/Builder/PayolutionInvoicing/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/PayolutionInvoicing/AuthorizeRequestParameterBuilder.php index 024d66eab..b5b1af3f2 100644 --- a/src/Payone/RequestParameter/Builder/PayolutionInvoicing/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/PayolutionInvoicing/AuthorizeRequestParameterBuilder.php @@ -9,6 +9,7 @@ use PayonePayment\Installer\ConfigInstaller; use PayonePayment\PaymentHandler\PayonePayolutionInvoicingPaymentHandler; use PayonePayment\Payone\RequestParameter\Builder\PayolutionDebit\AuthorizeRequestParameterBuilder as PayolutionDebitAuthorizeRequestParameterBuilder; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressEntity; @@ -19,9 +20,11 @@ class AuthorizeRequestParameterBuilder extends PayolutionDebitAuthorizeRequestParameterBuilder { public function __construct( + RequestBuilderServiceAccessor $serviceAccessor, protected ConfigReaderInterface $configReader, protected OrderFetcherInterface $orderFetcher ) { + parent::__construct($serviceAccessor); } /** @@ -39,7 +42,12 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'request' => self::REQUEST_ACTION_AUTHORIZE, ]; - $this->applyBirthdayParameterWithoutCustomField($parameters, $dataBag); + $this->applyBirthdayParameter( + $arguments->getPaymentTransaction()->getOrder(), + $parameters, + $dataBag, + $arguments->getSalesChannelContext()->getContext() + ); if ($this->transferCompanyData($salesChannelContext)) { $this->provideCompanyParams($paymentTransaction->getOrder()->getId(), $parameters, $salesChannelContext->getContext()); diff --git a/src/Payone/RequestParameter/Builder/PayolutionInvoicing/PreCheckRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/PayolutionInvoicing/PreCheckRequestParameterBuilder.php index ca12bba56..d04412740 100644 --- a/src/Payone/RequestParameter/Builder/PayolutionInvoicing/PreCheckRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/PayolutionInvoicing/PreCheckRequestParameterBuilder.php @@ -9,8 +9,8 @@ use PayonePayment\Payone\RequestParameter\Builder\GeneralTransactionRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PayolutionAdditionalActionStruct; +use PayonePayment\RequestConstants; use Shopware\Core\System\SalesChannel\SalesChannelContext; -use Symfony\Component\HttpFoundation\ParameterBag; class PreCheckRequestParameterBuilder extends GeneralTransactionRequestParameterBuilder { @@ -30,12 +30,18 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'add_paydata[payment_type]' => 'Payolution-Invoicing', 'clearingtype' => self::CLEARING_TYPE_FINANCING, 'financingtype' => 'PYV', - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), 'currency' => $currency->getIsoCode(), 'workorderid' => $arguments->getWorkorderId(), ]; - $this->applyBirthdayParameterWithoutCustomField($parameters, $dataBag); + if (!empty($dataBag->get(RequestConstants::BIRTHDAY))) { + $birthday = \DateTime::createFromFormat('Y-m-d', $dataBag->get(RequestConstants::BIRTHDAY)); + + if (!empty($birthday)) { + $parameters['birthday'] = $birthday->format('Ymd'); + } + } if ($this->transferCompanyData($salesChannelContext)) { $this->provideCompanyParams($parameters, $salesChannelContext); @@ -56,17 +62,6 @@ public function supports(AbstractRequestParameterStruct $arguments): bool return $paymentMethod === PayonePayolutionInvoicingPaymentHandler::class && $action === self::REQUEST_ACTION_PAYOLUTION_PRE_CHECK; } - protected function applyBirthdayParameterWithoutCustomField(array &$parameters, ParameterBag $dataBag): void - { - if (!empty($dataBag->get('payolutionBirthday'))) { - $birthday = \DateTime::createFromFormat('Y-m-d', $dataBag->get('payolutionBirthday')); - - if (!empty($birthday)) { - $parameters['birthday'] = $birthday->format('Ymd'); - } - } - } - protected function transferCompanyData(SalesChannelContext $context): bool { $configuration = $this->configReader->read($context->getSalesChannel()->getId()); diff --git a/src/Payone/RequestParameter/Builder/PaypalExpress/CreateCheckoutSessionParameterBuilder.php b/src/Payone/RequestParameter/Builder/PaypalExpress/CreateCheckoutSessionParameterBuilder.php index b0fa4310b..1e7a0ec2d 100644 --- a/src/Payone/RequestParameter/Builder/PaypalExpress/CreateCheckoutSessionParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/PaypalExpress/CreateCheckoutSessionParameterBuilder.php @@ -7,7 +7,6 @@ use PayonePayment\Components\GenericExpressCheckout\Struct\CreateExpressCheckoutSessionStruct; use PayonePayment\PaymentHandler\PayonePaypalExpressPaymentHandler; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; -use PayonePayment\Payone\RequestParameter\Builder\Amazon\AbstractAmazonRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; class CreateCheckoutSessionParameterBuilder extends AbstractRequestParameterBuilder diff --git a/src/Payone/RequestParameter/Builder/RatepayDebit/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/RatepayDebit/AuthorizeRequestParameterBuilder.php index 51bd3273a..178041053 100644 --- a/src/Payone/RequestParameter/Builder/RatepayDebit/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/RatepayDebit/AuthorizeRequestParameterBuilder.php @@ -6,28 +6,26 @@ use PayonePayment\Components\DeviceFingerprint\AbstractDeviceFingerprintService; use PayonePayment\Components\Helper\OrderFetcherInterface; -use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydratorInterface; use PayonePayment\Components\Ratepay\Profile\Profile; use PayonePayment\Components\Ratepay\Profile\ProfileServiceInterface; use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler; use PayonePayment\PaymentHandler\PayoneRatepayDebitPaymentHandler; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; use Shopware\Core\Checkout\Order\OrderEntity; use Shopware\Core\Framework\Context; -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; -use Symfony\Component\HttpFoundation\ParameterBag; class AuthorizeRequestParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( + RequestBuilderServiceAccessor $serviceAccessor, protected OrderFetcherInterface $orderFetcher, protected ProfileServiceInterface $profileService, - protected AbstractDeviceFingerprintService $deviceFingerprintService, - protected EntityRepository $customerRepository, - protected LineItemHydratorInterface $lineItemHydrator + protected AbstractDeviceFingerprintService $deviceFingerprintService ) { + parent::__construct($serviceAccessor); } /** @@ -54,10 +52,10 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): ]; $this->applyPhoneParameter($order, $parameters, $dataBag, $context); - $this->applyBirthdayParameterWithoutCustomField($parameters, $dataBag); + $this->applyBirthdayParameter($order, $parameters, $dataBag, $context); if ($order->getLineItems() !== null) { - $parameters = array_merge($parameters, $this->lineItemHydrator->mapOrderLines($currency, $order, $context)); + $parameters = array_merge($parameters, $this->serviceAccessor->lineItemHydrator->mapOrderLines($currency, $order, $context)); } return $parameters; @@ -97,15 +95,4 @@ protected function getProfile(OrderEntity $order, string $paymentHandler): Profi return $profile; } - - protected function applyBirthdayParameterWithoutCustomField(array &$parameters, ParameterBag $dataBag): void - { - if (!empty($dataBag->get('ratepayBirthday'))) { - $birthday = \DateTime::createFromFormat('Y-m-d', $dataBag->get('ratepayBirthday')); - - if (!empty($birthday)) { - $parameters['birthday'] = $birthday->format('Ymd'); - } - } - } } diff --git a/src/Payone/RequestParameter/Builder/RatepayInstallment/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/RatepayInstallment/AuthorizeRequestParameterBuilder.php index fc4f4d7ce..5266fb784 100644 --- a/src/Payone/RequestParameter/Builder/RatepayInstallment/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/RatepayInstallment/AuthorizeRequestParameterBuilder.php @@ -4,37 +4,14 @@ namespace PayonePayment\Payone\RequestParameter\Builder\RatepayInstallment; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; -use PayonePayment\Components\DeviceFingerprint\AbstractDeviceFingerprintService; -use PayonePayment\Components\Helper\OrderFetcherInterface; -use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydratorInterface; -use PayonePayment\Components\Ratepay\Profile\ProfileServiceInterface; use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler; use PayonePayment\PaymentHandler\PayoneRatepayInstallmentPaymentHandler; use PayonePayment\Payone\RequestParameter\Builder\RatepayDebit\AuthorizeRequestParameterBuilder as RatepayDebitAuthorizeRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; class AuthorizeRequestParameterBuilder extends RatepayDebitAuthorizeRequestParameterBuilder { - public function __construct( - OrderFetcherInterface $orderFetcher, - ProfileServiceInterface $profileService, - AbstractDeviceFingerprintService $deviceFingerprintService, - EntityRepository $customerRepository, - LineItemHydratorInterface $lineItemHydrator, - protected CurrencyPrecisionInterface $currencyPrecision - ) { - parent::__construct( - $orderFetcher, - $profileService, - $deviceFingerprintService, - $customerRepository, - $lineItemHydrator - ); - } - /** * @param PaymentTransactionStruct $arguments */ @@ -53,11 +30,11 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'clearingtype' => self::CLEARING_TYPE_FINANCING, 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_RPS, 'add_paydata[customer_allow_credit_inquiry]' => 'yes', - 'add_paydata[installment_amount]' => $this->currencyPrecision->getRoundedTotalAmount((float) $dataBag->get('ratepayInstallmentAmount'), $currency), + 'add_paydata[installment_amount]' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount((float) $dataBag->get('ratepayInstallmentAmount'), $currency), 'add_paydata[installment_number]' => (int) $dataBag->get('ratepayInstallmentNumber'), - 'add_paydata[last_installment_amount]' => $this->currencyPrecision->getRoundedTotalAmount((float) $dataBag->get('ratepayLastInstallmentAmount'), $currency), - 'add_paydata[interest_rate]' => $this->currencyPrecision->getRoundedTotalAmount((float) $dataBag->get('ratepayInterestRate'), $currency), - 'add_paydata[amount]' => $this->currencyPrecision->getRoundedTotalAmount((float) $dataBag->get('ratepayTotalAmount'), $currency), + 'add_paydata[last_installment_amount]' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount((float) $dataBag->get('ratepayLastInstallmentAmount'), $currency), + 'add_paydata[interest_rate]' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount((float) $dataBag->get('ratepayInterestRate'), $currency), + 'add_paydata[amount]' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount((float) $dataBag->get('ratepayTotalAmount'), $currency), 'add_paydata[shop_id]' => $profile->getShopId(), 'add_paydata[device_token]' => $this->deviceFingerprintService->getDeviceIdentToken($salesChannelContext), ]; @@ -70,10 +47,10 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): } $this->applyPhoneParameter($order, $parameters, $dataBag, $context); - $this->applyBirthdayParameterWithoutCustomField($parameters, $dataBag); + $this->applyBirthdayParameter($order, $parameters, $dataBag, $context); if ($order->getLineItems() !== null) { - $parameters = array_merge($parameters, $this->lineItemHydrator->mapOrderLines($currency, $order, $context)); + $parameters = array_merge($parameters, $this->serviceAccessor->lineItemHydrator->mapOrderLines($currency, $order, $context)); } return $parameters; diff --git a/src/Payone/RequestParameter/Builder/RatepayInstallment/CalculationRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/RatepayInstallment/CalculationRequestParameterBuilder.php index 6494dc6a7..a0f6e4edb 100644 --- a/src/Payone/RequestParameter/Builder/RatepayInstallment/CalculationRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/RatepayInstallment/CalculationRequestParameterBuilder.php @@ -31,7 +31,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'add_paydata[action]' => 'calculation', 'clearingtype' => self::CLEARING_TYPE_FINANCING, 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_RPS, - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), 'currency' => $currency->getIsoCode(), 'add_paydata[shop_id]' => $profile->getShopId(), 'add_paydata[customer_allow_credit_inquiry]' => 'yes', @@ -39,7 +39,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): if ($installmentType === self::INSTALLMENT_TYPE_RATE) { $parameters['add_paydata[calculation_type]'] = 'calculation-by-rate'; - $parameters['add_paydata[rate]'] = $this->currencyPrecision->getRoundedTotalAmount( + $parameters['add_paydata[rate]'] = $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount( (float) $dataBag->get('ratepayInstallmentValue'), $currency ); diff --git a/src/Payone/RequestParameter/Builder/RatepayInvoicing/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/RatepayInvoicing/AuthorizeRequestParameterBuilder.php index 9507b3a5f..a7dd61de9 100644 --- a/src/Payone/RequestParameter/Builder/RatepayInvoicing/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/RatepayInvoicing/AuthorizeRequestParameterBuilder.php @@ -35,10 +35,10 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): ]; $this->applyPhoneParameter($order, $parameters, $dataBag, $context); - $this->applyBirthdayParameterWithoutCustomField($parameters, $dataBag); + $this->applyBirthdayParameter($order, $parameters, $dataBag, $context); if ($order->getLineItems() !== null) { - $parameters = array_merge($parameters, $this->lineItemHydrator->mapOrderLines($currency, $order, $context)); + $parameters = array_merge($parameters, $this->serviceAccessor->lineItemHydrator->mapOrderLines($currency, $order, $context)); } return $parameters; diff --git a/src/Payone/RequestParameter/Builder/Refund/RefundRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/Refund/RefundRequestParameterBuilder.php index fec4ff4ba..7844ecfae 100644 --- a/src/Payone/RequestParameter/Builder/Refund/RefundRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/Refund/RefundRequestParameterBuilder.php @@ -4,7 +4,6 @@ namespace PayonePayment\Payone\RequestParameter\Builder\Refund; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; use PayonePayment\DataAbstractionLayer\Aggregate\PayonePaymentOrderTransactionDataEntity; use PayonePayment\DataAbstractionLayer\Extension\PayonePaymentOrderTransactionExtension; use PayonePayment\PaymentHandler\PaymentHandlerGroups; @@ -12,15 +11,10 @@ use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\FinancialTransactionStruct; -use Shopware\Core\Checkout\Payment\Exception\InvalidOrderException; use Shopware\Core\System\Currency\CurrencyEntity; class RefundRequestParameterBuilder extends AbstractRequestParameterBuilder { - public function __construct(private readonly CurrencyPrecisionInterface $currencyPrecision) - { - } - /** * @param FinancialTransactionStruct $arguments */ @@ -32,7 +26,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): $transactionData = $arguments->getPaymentTransaction()->getOrderTransaction()->getExtension(PayonePaymentOrderTransactionExtension::NAME); if ($transactionData === null) { - throw new InvalidOrderException($order->getId()); + throw $this->orderNotFoundException($order->getId()); } if ($totalAmount === null) { @@ -40,15 +34,15 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): } if (empty($transactionData->getTransactionId())) { - throw new InvalidOrderException($order->getId()); + throw $this->orderNotFoundException($order->getId()); } if ($transactionData->getSequenceNumber() === null) { - throw new InvalidOrderException($order->getId()); + throw $this->orderNotFoundException($order->getId()); } if ($transactionData->getSequenceNumber() < 0) { - throw new InvalidOrderException($order->getId()); + throw $this->orderNotFoundException($order->getId()); } //TODO: fix set refunded amount @@ -60,7 +54,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'request' => self::REQUEST_ACTION_DEBIT, 'txid' => $transactionData->getTransactionId(), 'sequencenumber' => $transactionData->getSequenceNumber() + 1, - 'amount' => -1 * $this->currencyPrecision->getRoundedTotalAmount((float) $totalAmount, $currency), + 'amount' => -1 * $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount((float) $totalAmount, $currency), 'currency' => $currency->getIsoCode(), ]; diff --git a/src/Payone/RequestParameter/Builder/RequestBuilderServiceAccessor.php b/src/Payone/RequestParameter/Builder/RequestBuilderServiceAccessor.php new file mode 100644 index 000000000..b1579486b --- /dev/null +++ b/src/Payone/RequestParameter/Builder/RequestBuilderServiceAccessor.php @@ -0,0 +1,22 @@ +getLineItems() !== null) { - $parameters = array_merge($parameters, $this->lineItemHydrator->mapOrderLines($currency, $order, $context)); + $parameters = array_merge($parameters, $this->serviceAccessor->lineItemHydrator->mapOrderLines($currency, $order, $context)); } return $parameters; diff --git a/src/Payone/RequestParameter/Builder/SecuredDirectDebit/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/SecuredDirectDebit/AuthorizeRequestParameterBuilder.php index 979886685..ff3e0a4ee 100644 --- a/src/Payone/RequestParameter/Builder/SecuredDirectDebit/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/SecuredDirectDebit/AuthorizeRequestParameterBuilder.php @@ -4,28 +4,25 @@ namespace PayonePayment\Payone\RequestParameter\Builder\SecuredDirectDebit; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; use PayonePayment\Components\DeviceFingerprint\AbstractDeviceFingerprintService; use PayonePayment\Components\Helper\OrderFetcherInterface; -use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydratorInterface; use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler; use PayonePayment\PaymentHandler\PayoneSecuredDirectDebitPaymentHandler; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; use Shopware\Core\Checkout\Order\OrderEntity; use Shopware\Core\Framework\Context; -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; class AuthorizeRequestParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( + RequestBuilderServiceAccessor $serviceAccessor, protected OrderFetcherInterface $orderFetcher, - protected AbstractDeviceFingerprintService $deviceFingerprintService, - protected CurrencyPrecisionInterface $currencyPrecision, - protected LineItemHydratorInterface $lineItemHydrator, - protected EntityRepository $customerRepository + protected AbstractDeviceFingerprintService $deviceFingerprintService ) { + parent::__construct($serviceAccessor); } /** @@ -50,18 +47,18 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PDD, 'request' => self::REQUEST_ACTION_AUTHORIZE, 'add_paydata[device_token]' => $this->deviceFingerprintService->getDeviceIdentToken($salesChannelContext), - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($order->getAmountTotal(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($order->getAmountTotal(), $currency), 'currency' => $currency->getIsoCode(), 'bankaccountholder' => $customer->getFirstName() . ' ' . $customer->getLastName(), 'iban' => $dataBag->get('securedDirectDebitIban'), ]; if ($order->getLineItems() !== null) { - $parameters = array_merge($parameters, $this->lineItemHydrator->mapOrderLines($currency, $order, $context)); + $parameters = array_merge($parameters, $this->serviceAccessor->lineItemHydrator->mapOrderLines($currency, $order, $context)); } $this->applyPhoneParameter($order, $parameters, $dataBag, $context); - $this->applyBirthdayParameter($order, $parameters, $dataBag->get('securedDirectDebitBirthday') ?? '', $context); + $this->applyBirthdayParameter($order, $parameters, $dataBag, $context); return $parameters; } diff --git a/src/Payone/RequestParameter/Builder/SecuredInstallment/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/SecuredInstallment/AuthorizeRequestParameterBuilder.php index f632e7a22..22e0c2abf 100644 --- a/src/Payone/RequestParameter/Builder/SecuredInstallment/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/SecuredInstallment/AuthorizeRequestParameterBuilder.php @@ -4,28 +4,25 @@ namespace PayonePayment\Payone\RequestParameter\Builder\SecuredInstallment; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; use PayonePayment\Components\DeviceFingerprint\AbstractDeviceFingerprintService; use PayonePayment\Components\Helper\OrderFetcherInterface; -use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydratorInterface; use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler; use PayonePayment\PaymentHandler\PayoneSecuredInstallmentPaymentHandler; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; use Shopware\Core\Checkout\Order\OrderEntity; use Shopware\Core\Framework\Context; -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; class AuthorizeRequestParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( + RequestBuilderServiceAccessor $serviceAccessor, protected OrderFetcherInterface $orderFetcher, - protected AbstractDeviceFingerprintService $deviceFingerprintService, - protected CurrencyPrecisionInterface $currencyPrecision, - protected LineItemHydratorInterface $lineItemHydrator, - protected EntityRepository $customerRepository + protected AbstractDeviceFingerprintService $deviceFingerprintService ) { + parent::__construct($serviceAccessor); } /** @@ -50,7 +47,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PIN, 'request' => self::REQUEST_ACTION_AUTHORIZE, 'add_paydata[device_token]' => $this->deviceFingerprintService->getDeviceIdentToken($salesChannelContext), - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($order->getAmountTotal(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($order->getAmountTotal(), $currency), 'currency' => $currency->getIsoCode(), 'bankaccountholder' => $customer->getFirstName() . ' ' . $customer->getLastName(), 'iban' => $dataBag->get('securedInstallmentIban'), @@ -58,11 +55,11 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): ]; if ($order->getLineItems() !== null) { - $parameters = array_merge($parameters, $this->lineItemHydrator->mapOrderLines($currency, $order, $context)); + $parameters = array_merge($parameters, $this->serviceAccessor->lineItemHydrator->mapOrderLines($currency, $order, $context)); } $this->applyPhoneParameter($order, $parameters, $dataBag, $context); - $this->applyBirthdayParameter($order, $parameters, $dataBag->get('securedInstallmentBirthday') ?? '', $context); + $this->applyBirthdayParameter($order, $parameters, $dataBag, $context); return $parameters; } diff --git a/src/Payone/RequestParameter/Builder/SecuredInstallment/InstallmentOptionsRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/SecuredInstallment/InstallmentOptionsRequestParameterBuilder.php index 65f6968bb..71b431040 100644 --- a/src/Payone/RequestParameter/Builder/SecuredInstallment/InstallmentOptionsRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/SecuredInstallment/InstallmentOptionsRequestParameterBuilder.php @@ -26,7 +26,7 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'add_paydata[businessRelation]' => 'b2c', 'clearingtype' => self::CLEARING_TYPE_FINANCING, 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PIN, - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($cart->getPrice()->getTotalPrice(), $currency), 'currency' => $currency->getIsoCode(), ]; } diff --git a/src/Payone/RequestParameter/Builder/SecuredInvoice/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/SecuredInvoice/AuthorizeRequestParameterBuilder.php index 1e5aa378e..76c8988d5 100644 --- a/src/Payone/RequestParameter/Builder/SecuredInvoice/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/SecuredInvoice/AuthorizeRequestParameterBuilder.php @@ -4,30 +4,25 @@ namespace PayonePayment\Payone\RequestParameter\Builder\SecuredInvoice; -use PayonePayment\Components\Currency\CurrencyPrecisionInterface; use PayonePayment\Components\DeviceFingerprint\AbstractDeviceFingerprintService; use PayonePayment\Components\Helper\OrderFetcherInterface; -use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydratorInterface; use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler; use PayonePayment\PaymentHandler\PayoneSecuredInvoicePaymentHandler; use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder; +use PayonePayment\Payone\RequestParameter\Builder\RequestBuilderServiceAccessor; use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct; use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; -use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressCollection; -use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressEntity; use Shopware\Core\Checkout\Order\OrderEntity; use Shopware\Core\Framework\Context; -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; class AuthorizeRequestParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( + RequestBuilderServiceAccessor $serviceAccessor, protected OrderFetcherInterface $orderFetcher, - protected AbstractDeviceFingerprintService $deviceFingerprintService, - protected CurrencyPrecisionInterface $currencyPrecision, - protected LineItemHydratorInterface $lineItemHydrator, - protected EntityRepository $customerRepository + protected AbstractDeviceFingerprintService $deviceFingerprintService ) { + parent::__construct($serviceAccessor); } /** @@ -47,16 +42,16 @@ public function getRequestParameter(AbstractRequestParameterStruct $arguments): 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PIV, 'request' => self::REQUEST_ACTION_AUTHORIZE, 'add_paydata[device_token]' => $this->deviceFingerprintService->getDeviceIdentToken($salesChannelContext), - 'amount' => $this->currencyPrecision->getRoundedTotalAmount($order->getAmountTotal(), $currency), + 'amount' => $this->serviceAccessor->currencyPrecision->getRoundedTotalAmount($order->getAmountTotal(), $currency), 'currency' => $currency->getIsoCode(), ]; if ($order->getLineItems() !== null) { - $parameters = array_merge($parameters, $this->lineItemHydrator->mapOrderLines($currency, $order, $context)); + $parameters = array_merge($parameters, $this->serviceAccessor->lineItemHydrator->mapOrderLines($currency, $order, $context)); } $this->applyPhoneParameter($order, $parameters, $dataBag, $context); - $this->applyBirthdayParameter($order, $parameters, $dataBag->get('payoneInvoiceBirthday') ?? '', $context); + $this->applyBirthdayParameter($order, $parameters, $dataBag, $context); $this->applyB2bParameters($order, $parameters); return $parameters; diff --git a/src/Payone/RequestParameter/Builder/SystemRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/SystemRequestParameterBuilder.php index 8248bb433..407e923e5 100644 --- a/src/Payone/RequestParameter/Builder/SystemRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/SystemRequestParameterBuilder.php @@ -22,10 +22,12 @@ class SystemRequestParameterBuilder extends AbstractRequestParameterBuilder { public function __construct( + RequestBuilderServiceAccessor $serviceAccessor, private readonly PluginService $pluginService, private readonly string $shopwareVersion, private readonly ConfigReaderInterface $configReader ) { + parent::__construct($serviceAccessor); } /** diff --git a/src/Payone/RequestParameter/Builder/Trustly/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/Trustly/AuthorizeRequestParameterBuilder.php index 547b33229..d3f072d42 100644 --- a/src/Payone/RequestParameter/Builder/Trustly/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/Trustly/AuthorizeRequestParameterBuilder.php @@ -10,6 +10,7 @@ use PayonePayment\Payone\RequestParameter\Struct\PaymentTransactionStruct; use PayonePayment\Struct\PaymentTransaction; use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentProcessException; +use Shopware\Core\Checkout\Payment\PaymentException; use Symfony\Component\HttpFoundation\ParameterBag; class AuthorizeRequestParameterBuilder extends AbstractRequestParameterBuilder @@ -48,7 +49,22 @@ private function validateIbanRequestParameter(ParameterBag $dataBag, PaymentTran $iban = $dataBag->get('iban'); if (empty($iban) || !\is_string($iban)) { - throw new AsyncPaymentProcessException($transaction->getOrderTransaction()->getId(), 'Missing iban parameter.'); + if (class_exists(PaymentException::class)) { + throw PaymentException::asyncProcessInterrupted( + $transaction->getOrderTransaction()->getId(), + 'Missing iban parameter.' + ); + } elseif (class_exists(AsyncPaymentProcessException::class)) { + // required for shopware version <= 6.5.3 + // @phpstan-ignore-next-line + throw new AsyncPaymentProcessException( + $transaction->getOrderTransaction()->getId(), + 'Missing iban parameter.' + ); + } + + // should never occur. Just to be safe. + throw new \RuntimeException('payment process interrupted. Missing iban parameter.'); } return $iban; diff --git a/src/PayonePayment.php b/src/PayonePayment.php index c400b752a..25175b4cb 100644 --- a/src/PayonePayment.php +++ b/src/PayonePayment.php @@ -9,6 +9,7 @@ use PayonePayment\Installer\CustomFieldInstaller; use PayonePayment\Installer\PaymentMethodInstaller; use PayonePayment\Installer\RuleInstaller\RuleInstallerSecureInvoice; +use Shopware\Core\Checkout\Payment\PaymentMethodDefinition; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Plugin; use Shopware\Core\Framework\Plugin\Context\ActivateContext; @@ -177,13 +178,16 @@ private function getPaymentMethodInstaller(): PaymentMethodInstaller $paymentMethodSalesChannelRepository = $this->container->get('sales_channel_payment_method.repository'); /** @var Connection $connection */ $connection = $this->container->get(Connection::class); + /** @var PaymentMethodDefinition $paymentMethodDefinition */ + $paymentMethodDefinition = $this->container->get(PaymentMethodDefinition::class); return new PaymentMethodInstaller( $pluginIdProvider, $paymentMethodRepository, $salesChannelRepository, $paymentMethodSalesChannelRepository, - $connection + $connection, + $paymentMethodDefinition ); } diff --git a/src/RequestConstants.php b/src/RequestConstants.php new file mode 100644 index 000000000..0e42a8667 --- /dev/null +++ b/src/RequestConstants.php @@ -0,0 +1,16 @@ + {{ $tc('payonePayment.notificationTarget.detail.label.buttonSave') }} @@ -31,85 +32,86 @@ {% endblock %} - {% block payone_notification_target_detail_content %} - + {% endblock %} diff --git a/src/Resources/app/administration/src/module/payone-notification-target/page/payone-notification-target-list/payone-notification-target-list.html.twig b/src/Resources/app/administration/src/module/payone-notification-target/page/payone-notification-target-list/payone-notification-target-list.html.twig index bf971a26d..89cdd8768 100644 --- a/src/Resources/app/administration/src/module/payone-notification-target/page/payone-notification-target-list/payone-notification-target-list.html.twig +++ b/src/Resources/app/administration/src/module/payone-notification-target/page/payone-notification-target-list/payone-notification-target-list.html.twig @@ -2,7 +2,7 @@ {% block payone_notification_target_list_smart_bar_header %} -