diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index a27d6a91..8411f1b8 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -19,7 +19,7 @@ jobs: php: - 8.2 symfony: - - '6.2.*' + - '6.4.*' env: APP_ENV: test steps: @@ -38,7 +38,7 @@ jobs: run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' - name: 'Composer - Set cache' - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: '${{ steps.composer-cache.outputs.dir }}' key: 'php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles(''**/composer.json'') }}' @@ -58,17 +58,12 @@ jobs: id: end-of-setup - name: 'PHPStan - Run' - run: 'if [ -f rulesets/phpstan.neon ]; then vendor/bin/phpstan analyse -c rulesets/phpstan.neon src/ ; else echo PHPStan rulesets file does not exist, skipping step ; fi' - if: 'always() && steps.end-of-setup.outcome == ''success''' - - - name: 'PHPSpec - Run' - run: 'if [ -f phpspec.yml.dist ]; then vendor/bin/phpspec run ; else echo PHPSpec config file does not exist, skipping step ; fi' - if: 'always() && steps.end-of-setup.outcome == ''success''' - - - name: 'Checks security issues - Run' - run: 'symfony security:check' + run: 'if [ -f ruleset/phpstan.neon ]; then vendor/bin/phpstan analyse -c ruleset/phpstan.neon src/ ; else echo PHPStan rulesets file does not exist, skipping step ; fi' if: 'always() && steps.end-of-setup.outcome == ''success''' + # TODO: launch Grumphp + sonarcloud: + if: github.event.repository.fork != true runs-on: ubuntu-latest continue-on-error: true steps: diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml index fbf898ac..15e307f9 100644 --- a/.github/workflows/sylius.yaml +++ b/.github/workflows/sylius.yaml @@ -19,12 +19,15 @@ jobs: matrix: php: - 8.2 + - 8.4 sylius: - - 1.12.0 + - 2.1.0 + - 2.0.0 symfony: - - 6.2 + - 6.4 + - 7.3 node: - - 14.x + - 20.x env: APP_ENV: test package-name: payplug/sylius-payplug-plugin @@ -43,9 +46,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: '${{ matrix.node }}' - - - name: 'Wkhtmltopdf - Install' - run: "sudo apt-get update\nsudo apt-get install xvfb libfontconfig wkhtmltopdf\nprintf '#!/bin/bash\\nxvfb-run -a --server-args=\"-screen 0, 1024x768x24\" /usr/bin/wkhtmltopdf -q $*' | sudo tee /usr/bin/wkhtmltopdf.sh\nsudo chmod a+x /usr/bin/wkhtmltopdf.sh\nsudo ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf\n" - uses: actions/checkout@v3 - @@ -54,7 +54,7 @@ jobs: run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT' - name: 'Composer - Set cache' - uses: actions/cache@v3 + uses: actions/cache@v4 id: cache-composer with: path: '${{ steps.composer-cache.outputs.dir }}' @@ -73,48 +73,39 @@ jobs: run: 'echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT' - name: 'Yarn - Set Cache' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: '${{ steps.yarn-cache.outputs.dir }}' key: 'node-${{ matrix.node }}-yarn-${{ hashFiles(''**/package.json **/yarn.lock'') }}' restore-keys: "node-${{ matrix.node }}-yarn-\n" - name: 'Install Sylius-Standard and Plugin' - run: 'make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }} PHP_VERSION=${{ matrix.php }}' - - - name: 'Output PHP version for Symfony CLI' - working-directory: ./tests/Application - run: 'php -v | head -n 1 | awk ''{ print $2 }'' > .php-version' + run: 'make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }}' - name: 'Install certificates' - working-directory: ./tests/Application run: 'symfony server:ca:install' - name: 'Run Chrome headless' - working-directory: ./tests/Application run: 'google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server=''direct://'' --proxy-bypass-list=''*'' https://127.0.0.1 > /dev/null 2>&1 &' - name: 'Run webserver' - working-directory: ./tests/Application - run: 'symfony server:start --port=8080 --dir=public --daemon' + run: 'symfony server:start --port=8080 --daemon' id: end-of-setup-sylius - name: 'Doctrine Schema Validate - Run' - working-directory: ./tests/Application - run: 'php bin/console doctrine:schema:validate --skip-sync' + run: 'vendor/bin/console doctrine:schema:validate --skip-sync' - name: 'Run PHPUnit' run: 'make phpunit' if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' - - - name: 'Configure Behat' - run: 'make behat-configure' - if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' - - - name: 'Run behat' - working-directory: ./tests/Application - run: 'vendor/bin/behat --strict --no-interaction -f progress || vendor/bin/behat --strict -vvv --no-interaction --rerun' - if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' +# - +# name: 'Configure Behat' +# run: 'make behat-configure' +# if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' +# - +# name: 'Run behat' +# run: 'vendor/bin/behat --strict --no-interaction -f progress || vendor/bin/behat --strict -vvv --no-interaction --rerun' +# if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' - uses: actions/upload-artifact@v4 if: failure() diff --git a/.gitignore b/.gitignore index 88b66083..19975f9a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,7 @@ /.idea *.map + +/tests/TestApplication/.env.local +/tests/TestApplication/.env.*.local +/var/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..7be32a5b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [2.0.0] - Unreleased + +### Added +- Support for Sylius v2.0+ +- PHP 8.2+ compatibility +- Use Payment Request API from Sylius +- New Unified Authentication System (OAuth2) + +> [!IMPORTANT] +> Merchants will need to contact support to switch to the new authentication method. + +### Changed +- Plugin structure has been changed to follow the new Symfony bundle structure +- Front assets have been migrated to use Stimulus + +### Removed +- Drop Payum support +- Drop Sylius 1.x support +- Drop usage of Secret key - Use OAuth2 instead + +Please refer to [github releases](https://github.com/payplug/SyliusPayPlugPlugin/releases) for historical release information. + +--- + +For migration guides and upgrade instructions, see [UPGRADE.md](UPGRADE.md). +For contributing guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 30982a48..8c9b7307 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ From the plugin root directory, run the following commands: $ make install -e SYLIUS_VERSION=XX SYMFONY_VERSION=YY PHP_VERSION=ZZ ``` -Default values : XX=1.12.0 and YY=6.1 and ZZ=8.1 +Default values : XX=1.14.0 and YY=6.4 and ZZ=8.2 To be able to setup the plugin database, remember to configure you database credentials in `install/Application/.env.local` and `install/Application/.env.test.local`. @@ -22,7 +22,7 @@ $ make reset - GrumPHP (see configuration [grumphp.yml](grumphp.yml).) - GrumPHP is executed by the Git pre-commit hook, but you can launch it manualy with : + GrumPHP is executed by the Git pre-commit hook, but you can launch it manually with : ```bash $ make grumphp diff --git a/Makefile b/Makefile index cc5d2e48..b3007cc4 100644 --- a/Makefile +++ b/Makefile @@ -1,91 +1,42 @@ .DEFAULT_GOAL := help SHELL=/bin/bash COMPOSER_ROOT=composer -TEST_DIRECTORY=tests/Application -CONSOLE=cd tests/Application && php bin/console -e test -COMPOSER=cd tests/Application && composer -YARN=cd tests/Application && yarn - -SYLIUS_VERSION=1.12.0 -SYMFONY_VERSION=6.1 -PHP_VERSION=8.1 +TEST_DIRECTORY=tests/TestApplication +CONSOLE=vendor/bin/console +COMPOSER=composer +SYLIUS_VERSION=2.1.0 +SYMFONY_VERSION=6.4 PLUGIN_NAME=payplug/sylius-payplug-plugin ### ### DEVELOPMENT ### ¯¯¯¯¯¯¯¯¯¯¯ - -install: sylius ## Install Plugin on Sylius [SYLIUS_VERSION=1.12.0] [SYMFONY_VERSION=6.1] [PHP_VERSION=8.1] +install: sylius ## Install all dependencies with [SYLIUS_VERSION=2.1.0] [SYMFONY_VERSION=6.4] .PHONY: install reset: ## Remove dependencies -ifneq ("$(wildcard tests/Application/bin/console)","") ${CONSOLE} doctrine:database:drop --force --if-exists || true -endif - rm -rf tests/Application + rm -rf vendor .PHONY: reset -phpunit: phpunit-configure phpunit-run ## Run PHPUnit +phpunit: ## Run PHPUnit tests + ./vendor/bin/phpunit .PHONY: phpunit ### ### OTHER ### ¯¯¯¯¯¯ - -sylius: sylius-standard install-plugin install-sylius +sylius: install-sylius .PHONY: sylius -sylius-standard: -ifeq ($(shell [[ $(SYLIUS_VERSION) == *dev ]] && echo true ),true) - ${COMPOSER_ROOT} create-project sylius/sylius-standard:${SYLIUS_VERSION} ${TEST_DIRECTORY} --no-install --no-scripts -else - ${COMPOSER_ROOT} create-project sylius/sylius-standard ${TEST_DIRECTORY} "~${SYLIUS_VERSION}" --no-install --no-scripts -endif - ${COMPOSER} config allow-plugins true -ifeq ($(shell [[ $(SYLIUS_VERSION) == *dev ]] && echo true ),true) - ${COMPOSER} require sylius/sylius:"${SYLIUS_VERSION}" -else - ${COMPOSER} require sylius/sylius:"~${SYLIUS_VERSION}" -endif - -install-plugin: - ${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}' - ${COMPOSER} config extra.symfony.allow-contrib true - ${COMPOSER} config minimum-stability "dev" - ${COMPOSER} config prefer-stable true - ${COMPOSER} require "${PLUGIN_NAME}:*" --prefer-source --no-scripts - - cp -r install/Application tests - sed -i "4a \ \ \ \ form_themes: ['form/form_gateway_config_row.html.twig']" ${TEST_DIRECTORY}/config/packages/twig.yaml - mkdir -p ${TEST_DIRECTORY}/templates/form/ - cp -R src/Resources/views/form/* ${TEST_DIRECTORY}/templates/form/ - -# As of sylius/refund-plugin 1.2 the folder does not exist anymore -ifneq ($(PHP_VERSION), 8) - mkdir -p ${TEST_DIRECTORY}/templates/bundles/SyliusAdminBundle/ - cp -R src/Resources/views/SyliusAdminBundle/* ${TEST_DIRECTORY}/templates/bundles/SyliusAdminBundle/ -endif - install-sylius: - #${CONSOLE} sylius:install -n -s default - ${CONSOLE} doctrine:database:create -n - ${CONSOLE} messenger:setup-transports -n - ${CONSOLE} doctrine:migration:migrate -n - ${CONSOLE} sylius:fixture:load -n - ${YARN} install - ${YARN} build - ${YARN} gulp - ${CONSOLE} translation:extract en PayPlugSyliusPayPlugPlugin --dump-messages - ${CONSOLE} translation:extract fr PayPlugSyliusPayPlugPlugin --dump-messages - - ${CONSOLE} cache:clear + @echo "Installing Sylius ${SYLIUS_VERSION} using TestApplication" + ${COMPOSER} config extra.symfony.require "^${SYMFONY_VERSION}" + ${COMPOSER} install + ${COMPOSER} require --dev sylius/test-application:"^${SYLIUS_VERSION}@alpha" -n -W # TODO: Remove alpha when stable + ${COMPOSER} test-application:install -phpunit-configure: - cp phpunit.xml.dist ${TEST_DIRECTORY}/phpunit.xml - echo -e "\nMOCK_SERVER_HOST=localhost\nMOCK_SERVER_PORT=8987\n" >> ${TEST_DIRECTORY}/.env.test.local -phpunit-run: - cd ${TEST_DIRECTORY} && ./vendor/bin/phpunit behat-configure: ## Configure Behat (cd ${TEST_DIRECTORY} && cp behat.yml.dist behat.yml) @@ -101,7 +52,7 @@ grumphp: vendor/bin/grumphp run help: SHELL=/bin/bash -help: ## Dislay this help +help: ## Display this help @IFS=$$'\n'; for line in `grep -h -E '^[a-zA-Z_#-]+:?.*?##.*$$' $(MAKEFILE_LIST)`; do if [ "$${line:0:2}" = "##" ]; then \ echo $$line | awk 'BEGIN {FS = "## "}; {printf "\033[33m %s\033[0m\n", $$2}'; else \ echo $$line | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m%s\n", $$1, $$2}'; fi; \ diff --git a/README.md b/README.md index 7f1e8df1..5d2f4eea 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ In local environment, the plugin will not work properly because you will not be ```shell mkdir -p templates/bundles/SyliusAdminBundle/ - cp -R vendor/payplug/sylius-payplug-plugin/src/Resources/views/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/ + cp -R vendor/payplug/sylius-payplug-plugin/templates/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/ ``` 4. Add Payplug to refundable payment method for Sylius Refund Plugin in `config/services.yaml` @@ -70,7 +70,7 @@ In local environment, the plugin will not work properly because you will not be ```yaml sylius_payplug: - resource: "@PayPlugSyliusPayPlugPlugin/Resources/config/routing.yaml" + resource: "@PayPlugSyliusPayPlugPlugin/config/routing.yaml" ``` 8. Add Traits for Customer and PaymentMethod entities @@ -85,6 +85,7 @@ In local environment, the plugin will not work properly because you will not be namespace App\Entity\Customer; use Doctrine\ORM\Mapping as ORM; + use PayPlug\SyliusPayPlugPlugin\Entity\CardsOwnerInterface; use PayPlug\SyliusPayPlugPlugin\Entity\Traits\CustomerTrait; use Sylius\Component\Core\Model\Customer as BaseCustomer; @@ -94,7 +95,7 @@ In local environment, the plugin will not work properly because you will not be */ #[ORM\Entity] #[ORM\Table(name: 'sylius_customer')] - class Customer extends BaseCustomer + class Customer extends BaseCustomer implements CardsOwnerInterface { use CustomerTrait; } @@ -209,9 +210,9 @@ Copy Sylius templates overridden in plugin to your templates directory (e.g temp mkdir -p templates/bundles/SyliusAdminBundle/ mkdir -p templates/bundles/SyliusShopBundle/ mkdir -p templates/bundles/SyliusUiBundle/ -cp -R vendor/payplug/sylius-payplug-plugin/src/Resources/views/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/ -cp -R vendor/payplug/sylius-payplug-plugin/src/Resources/views/SyliusShopBundle/* templates/bundles/SyliusShopBundle/ -cp -R vendor/payplug/sylius-payplug-plugin/src/Resources/views/SyliusUiBundle/* templates/bundles/SyliusUiBundle/ +cp -R vendor/payplug/sylius-payplug-plugin/templates/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/ +cp -R vendor/payplug/sylius-payplug-plugin/templates/SyliusShopBundle/* templates/bundles/SyliusShopBundle/ +cp -R vendor/payplug/sylius-payplug-plugin/templates/SyliusUiBundle/* templates/bundles/SyliusUiBundle/ ``` You also need to edit your twig config to add your path to avoid our configuration to be prepended : diff --git a/RELEASE.md b/RELEASE.md index 7f73a0af..6cc12383 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,4 +1,6 @@ # Release Process Upon releasing a new version there are checks and updates to be made: -* Update plugin's version inside `src/PayPlugSyliusPayPlugPlugin.php` and `src/Resources/dev/package.json` +* Update plugin's version inside `src/PayPlugSyliusPayPlugPlugin.php` +* Ensure that the `CHANGELOG.md` is up to date with the changes made +* Ensure that the date of the release version is updated in `CHANGELOG.md` diff --git a/src/Resources/dev/.eslintignore b/assets/.eslintignore similarity index 100% rename from src/Resources/dev/.eslintignore rename to assets/.eslintignore diff --git a/src/Resources/dev/.eslintrc b/assets/.eslintrc similarity index 100% rename from src/Resources/dev/.eslintrc rename to assets/.eslintrc diff --git a/src/Resources/dev/.gitignore b/assets/.gitignore similarity index 100% rename from src/Resources/dev/.gitignore rename to assets/.gitignore diff --git a/assets/admin/entrypoint.js b/assets/admin/entrypoint.js new file mode 100644 index 00000000..9ccfccbe --- /dev/null +++ b/assets/admin/entrypoint.js @@ -0,0 +1 @@ +// Mandatory by test application diff --git a/assets/controllers.json b/assets/controllers.json new file mode 100644 index 00000000..5582d953 --- /dev/null +++ b/assets/controllers.json @@ -0,0 +1,41 @@ +{ + "controllers": { + "@payplug/sylius-payplug-plugin": { + "oney-popin": { + "enabled": true, + "fetch": "lazy", + "autoimport": { + "@payplug/sylius-payplug-plugin/shop/dist/oney_common/index.css": true, + "@payplug/sylius-payplug-plugin/shop/dist/oney_popin/index.css": true + } + }, + "integrated-payment": { + "enabled": true, + "fetch": "lazy", + "autoimport": { + "@payplug/sylius-payplug-plugin/shop/dist/payment/integrated.css": true + } + }, + "oney-payment": { + "enabled": true, + "fetch": "lazy" + }, + "payment-logo": { + "enabled": true, + "fetch": "lazy" + }, + "checkout-select-payment": { + "enabled": true, + "fetch": "lazy", + "autoimport": { + "@payplug/sylius-payplug-plugin/shop/dist/payment/index.css": true + } + }, + "apple-pay": { + "enabled": true, + "fetch": "lazy" + } + } + }, + "entrypoints": [] +} diff --git a/src/Resources/dev/images/integrated/account.svg b/assets/images/integrated/account.svg similarity index 100% rename from src/Resources/dev/images/integrated/account.svg rename to assets/images/integrated/account.svg diff --git a/src/Resources/dev/images/integrated/calendar.svg b/assets/images/integrated/calendar.svg similarity index 100% rename from src/Resources/dev/images/integrated/calendar.svg rename to assets/images/integrated/calendar.svg diff --git a/src/Resources/dev/images/integrated/card.svg b/assets/images/integrated/card.svg similarity index 100% rename from src/Resources/dev/images/integrated/card.svg rename to assets/images/integrated/card.svg diff --git a/src/Resources/dev/images/integrated/cb-dark.svg b/assets/images/integrated/cb-dark.svg similarity index 100% rename from src/Resources/dev/images/integrated/cb-dark.svg rename to assets/images/integrated/cb-dark.svg diff --git a/src/Resources/dev/images/integrated/cb.svg b/assets/images/integrated/cb.svg similarity index 100% rename from src/Resources/dev/images/integrated/cb.svg rename to assets/images/integrated/cb.svg diff --git a/src/Resources/dev/images/integrated/lock.svg b/assets/images/integrated/lock.svg similarity index 100% rename from src/Resources/dev/images/integrated/lock.svg rename to assets/images/integrated/lock.svg diff --git a/src/Resources/dev/images/integrated/logo-payplug.png b/assets/images/integrated/logo-payplug.png similarity index 100% rename from src/Resources/dev/images/integrated/logo-payplug.png rename to assets/images/integrated/logo-payplug.png diff --git a/src/Resources/dev/images/integrated/mastercard-dark.svg b/assets/images/integrated/mastercard-dark.svg similarity index 100% rename from src/Resources/dev/images/integrated/mastercard-dark.svg rename to assets/images/integrated/mastercard-dark.svg diff --git a/src/Resources/dev/images/integrated/mastercard.svg b/assets/images/integrated/mastercard.svg similarity index 100% rename from src/Resources/dev/images/integrated/mastercard.svg rename to assets/images/integrated/mastercard.svg diff --git a/src/Resources/dev/images/integrated/visa-dark.svg b/assets/images/integrated/visa-dark.svg similarity index 100% rename from src/Resources/dev/images/integrated/visa-dark.svg rename to assets/images/integrated/visa-dark.svg diff --git a/src/Resources/dev/images/integrated/visa.svg b/assets/images/integrated/visa.svg similarity index 100% rename from src/Resources/dev/images/integrated/visa.svg rename to assets/images/integrated/visa.svg diff --git a/assets/package.json b/assets/package.json new file mode 100644 index 00000000..52494447 --- /dev/null +++ b/assets/package.json @@ -0,0 +1,76 @@ +{ + "name": "@payplug/sylius-payplug-plugin", + "license": "MIT", + "version": "2.0.0", + "keywords": [ + "symfony-ux" + ], + "description": "Sylius Payplug Plugin", + "type": "module", + "files": [ + "dist" + ], + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "symfony": { + "controllers": { + "oney-popin": { + "main": "shop/controllers/oney-popin_controller.js", + "enabled": true, + "webpackMode": "lazy", + "fetch": "lazy", + "autoimport": { + "@payplug/sylius-payplug-plugin/shop/dist/oney_common/index.css": true, + "@payplug/sylius-payplug-plugin/shop/dist/oney_popin/index.css": true + } + }, + "integrated-payment": { + "main": "shop/controllers/integrated-payment_controller.js", + "webpackMode": "lazy", + "fetch": "lazy", + "enabled": true, + "autoimport": { + "@payplug/sylius-payplug-plugin/shop/dist/payment/integrated.css": true + } + }, + "oney-payment": { + "main": "shop/controllers/oney-payment_controller.js", + "webpackMode": "lazy", + "fetch": "lazy", + "enabled": true + }, + "payment-logo": { + "main": "shop/controllers/payment-logo_controller.js", + "webpackMode": "lazy", + "fetch": "lazy", + "enabled": true + }, + "checkout-select-payment": { + "main": "shop/controllers/checkout-select-payment_controller.js", + "autoimport": { + "@payplug/sylius-payplug-plugin/shop/dist/payment/index.css": true + }, + "webpackMode": "lazy", + "fetch": "lazy", + "enabled": true + }, + "apple-pay": { + "main": "shop/controllers/apple-pay_controller.js", + "webpackMode": "lazy", + "fetch": "lazy", + "enabled": true + } + } + }, + "peerDependencies": { + "@hotwired/stimulus": "^3.0.0" + }, + "devDependencies": { + "@hotwired/stimulus": "^3.0.0" + }, + "dependencies": { + "jquery": "^3.5.1", + "webfontloader": "^1.6.28" + } +} diff --git a/assets/shop/controllers/apple-pay_controller.js b/assets/shop/controllers/apple-pay_controller.js new file mode 100644 index 00000000..e9d99adc --- /dev/null +++ b/assets/shop/controllers/apple-pay_controller.js @@ -0,0 +1,166 @@ +import { Controller } from '@hotwired/stimulus'; +import $ from 'jquery'; + +/* stimulusFetch: 'lazy' */ +export default class extends Controller { + connect() { + this.applePayHandler(); + } + showApplePayButton() { + const applePayButton = $(document).find("apple-pay-button"); + if (applePayButton.length) { + applePayButton.addClass('enabled'); + } + } + hideApplePayButton() { + const applePayButton = $(document).find("apple-pay-button.enabled"); + if (applePayButton.length) { + applePayButton.removeClass('enabled'); + } + } + applePayHandler() { + const applePayChoice = $(".payment-item .checkbox-applepay input:radio"); + if (applePayChoice) { + if (applePayChoice.is(':checked')) { + this.disableNextStepButton(); + this.showApplePayButton(); + } else { + this.enableNextStepButton(); + this.hideApplePayButton(); + } + } + $(".payment-item .checkbox input:radio").on('change', this.onPaymentMethodChoice); + $(document).find("apple-pay-button").on('click', this.onApplePayButtonClick); + } + onPaymentMethodChoice(event) { + const isApplePay = $(event.currentTarget).closest('.checkbox-applepay').length; + if (isApplePay) { + this.showApplePayButton(); + this.disableNextStepButton(); + } else { + this.hideApplePayButton(); + this.enableNextStepButton(); + } + } + onApplePayButtonClick(event) { + const applePayButton = $(event.currentTarget); + + if (applePaySessionRequestSettings === undefined) { + console.error('Invalid Apple Pay settings!'); + return false; + } + + // Create ApplePaySession + const session = new ApplePaySession(3, applePaySessionRequestSettings); + + session.onvalidatemerchant = async event => { + $.ajax({ + url: applePayButton.data('validate-merchant-route'), + method: 'POST', + cache: false, + data: {}, + success: (authorization) => { + let result = authorization.merchant_session; + console.log(result); + + if (authorization.success === true) { + console.log(authorization.merchant_session); + session.completeMerchantValidation(result); + } else { + session.abort(); + } + }, + error: (XHR, status, error) => { + console.log(XHR, status, error); + session.abort(); + window.location.reload(); + }, + }); + }; + + session.onpaymentauthorized = event => { + $.ajax({ + url: applePayButton.data('payment-authorized-route'), + method: 'POST', + cache: false, + data: { + token: event.payment.token + }, + success: (authorization) => { + try { + var apple_pay_Session_status = ApplePaySession.STATUS_SUCCESS; + + console.log(authorization); + console.log(authorization.data.responseToApple.status); + if (authorization.data.responseToApple.status != 1) { + apple_pay_Session_status = ApplePaySession.STATUS_FAILURE; + } + + const result = { + "status": apple_pay_Session_status + }; + + console.log(apple_pay_Session_status); + console.log(result); + + session.completePayment(result); + + console.log(authorization.data.returnUrl); + window.location.href = authorization.data.returnUrl; + } catch (err) { + console.error(err); + window.location.reload(); + } + }, + error: (XHR, status, error) => { + console.log(XHR, status, error); + session.abort(); + window.location.reload(); + }, + }); + }; + + session.oncancel = event => { + console.log('Cancelling Apple Pay session!'); + + $.ajax({ + url: applePayButton.data('session-cancel-route'), + cache: false, + method: 'POST', + data: {}, + success: (authorization) => { + console.log('Cancelled!'); + console.log(authorization.data.returnUrl); + window.location.href = authorization.data.returnUrl; + }, + error: (XHR, status, error) => { + console.log(XHR, status, error); + window.location.reload(); + }, + }); + }; + + session.begin(); + } + disableNextStepButton() { + const nextStepButton = $('form[name*="checkout_select_payment"] [data-test-next-step]'); + nextStepButton.replaceWith( + $("", { + id: 'next-step', + class: 'btn btn-primary btn-icon', + html: nextStepButton.html() + }) + ); + } + enableNextStepButton() { + const nextStepButton = $('form[name*="checkout_select_payment"] [data-test-next-step]'); + nextStepButton.replaceWith( + $(" - - - {% endif %} - diff --git a/src/Resources/views/SyliusShopBundle/Account/SavedCards/Index/_header.html.twig b/src/Resources/views/SyliusShopBundle/Account/SavedCards/Index/_header.html.twig deleted file mode 100644 index f9f75099..00000000 --- a/src/Resources/views/SyliusShopBundle/Account/SavedCards/Index/_header.html.twig +++ /dev/null @@ -1,6 +0,0 @@ -

- {{ 'payplug_sylius_payplug_plugin.ui.account.saved_cards.title'|trans }} -
{{ 'payplug_sylius_payplug_plugin.ui.account.saved_cards.sub_title'|trans }}
- - {{ sylius_template_event('sylius.shop.account.saved_cards.index.header.content') }} -

\ No newline at end of file diff --git a/src/Resources/views/SyliusShopBundle/Checkout/SelectPayment/_choice.html.twig b/src/Resources/views/SyliusShopBundle/Checkout/SelectPayment/_choice.html.twig deleted file mode 100644 index 0ee200c8..00000000 --- a/src/Resources/views/SyliusShopBundle/Checkout/SelectPayment/_choice.html.twig +++ /dev/null @@ -1,135 +0,0 @@ -{% set oneyFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\OneyGatewayFactory::FACTORY_NAME') %} -{% set payplugFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\PayplugGatewayFactory::FACTORY_NAME') %} -{% set bancontactFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\BancontactGatewayFactory::FACTORY_NAME') %} -{% set applePayFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\ApplePayGatewayFactory::FACTORY_NAME') %} -{% set americanExpressFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\AmericanExpressGatewayFactory::FACTORY_NAME') %} - -{% set checkboxClass = '' %} -{% if method.gatewayConfig.factoryName == oneyFactoryName %} - {% set checkboxClass = 'checkbox-oney' %} -{% elseif method.gatewayConfig.factoryName == payplugFactoryName %} - {% set checkboxClass = 'checkbox-payplug' %} -{% elseif method.gatewayConfig.factoryName == bancontactFactoryName %} - {% set checkboxClass = 'checkbox-bancontact' %} -{% elseif method.gatewayConfig.factoryName == applePayFactoryName %} - {% set checkboxClass = 'checkbox-applepay' %} -{% elseif method.gatewayConfig.factoryName == americanExpressFactoryName %} - {% set checkboxClass = 'checkbox-american-express' %} -{% endif %} - -{% set showOney = false %} -{% set hasSavedCards = false %} - -{% if method.gatewayConfig.factoryName == oneyFactoryName and form.parent.parent.oney_payment_choice is defined %} - {% set showOney = true %} -{% elseif is_granted('ROLE_USER') - and method.gatewayConfig.factoryName == payplugFactoryName - and form.parent.parent.payplug_card_choice is defined - and is_save_card_enabled(method) - and sylius.customer.cards is not empty -%} - {% set hasSavedCards = true %} -{% endif %} - -
-
-
- {{ form_widget(form, sylius_test_form_attribute('payment-method-select')) }} -
-
-
- - {% if method.gatewayConfig.factoryName == oneyFactoryName %} - - {% elseif method.gatewayConfig.factoryName == payplugFactoryName %} - {{ form_label(form, null, {'label_attr': {'data-test-payment-method-label': '', 'data-gateway': 'payplug'}}) }} - {% elseif method.gatewayConfig.factoryName == applePayFactoryName %} -
- -
- {% elseif method.gatewayConfig.factoryName == americanExpressFactoryName %} -
- -
- {% elseif method.gatewayConfig.factoryName == bancontactFactoryName %} -
- -
- {% else %} - {{ form_label(form, null, {'label_attr': {'data-test-payment-method-label': ''}}) }} - {% endif %} -
- {% if method.description is not null %} -
-

{{ method.description }}

-
- {% endif %} - {% if showOney %} -
- {{ form_row(form.parent.parent.oney_payment_choice) }} -
- {% if app.session is not null and app.session.get('oney_has_error') == true %} - - {% endif %} - {% elseif hasSavedCards %} -
- {{ form_row(form.parent.parent.payplug_card_choice) }} -
- {% endif %} - {% if method.gatewayConfig.factoryName is same as payplugFactoryName and method.gatewayConfig.config.integratedPayment is defined and method.gatewayConfig.config.integratedPayment is same as true %} - {% include '@PayPlugSyliusPayPlugPlugin/form/integrated.html.twig' with { - 'paymentMethod': method, - 'payment': order.getLastPayment('cart'), - 'hasSavedCards': hasSavedCards, - } %} - {% endif %} - {% if method.gatewayConfig.factoryName == applePayFactoryName %} - - - - {% endif %} -
-
diff --git a/src/Resources/views/SyliusShopBundle/Checkout/SelectPayment/_navigation.html.twig b/src/Resources/views/SyliusShopBundle/Checkout/SelectPayment/_navigation.html.twig deleted file mode 100644 index 2bc14319..00000000 --- a/src/Resources/views/SyliusShopBundle/Checkout/SelectPayment/_navigation.html.twig +++ /dev/null @@ -1,17 +0,0 @@ -{% set enabled = order.payments|length %} - -
-
- {% if sylius_is_shipping_required(order) %} - {{ 'sylius.ui.change_shipping_method'|trans }} - {% else %} - {{ 'sylius.ui.change_address'|trans }} - {% endif %} -
-
- -
-
diff --git a/src/Resources/views/SyliusShopBundle/Order/show.html.twig b/src/Resources/views/SyliusShopBundle/Order/show.html.twig deleted file mode 100644 index a6e90703..00000000 --- a/src/Resources/views/SyliusShopBundle/Order/show.html.twig +++ /dev/null @@ -1,6 +0,0 @@ -{% extends '@!SyliusShop/Order/show.html.twig' %} - -{% block content %} - {{ sylius_template_event('sylius.shop.order.select_payment.before_form') }} - {{ parent() }} -{% endblock %} \ No newline at end of file diff --git a/src/Resources/views/SyliusUiBundle/Modal/_confirmation.html.twig b/src/Resources/views/SyliusUiBundle/Modal/_confirmation.html.twig deleted file mode 100644 index 5e0dc0fa..00000000 --- a/src/Resources/views/SyliusUiBundle/Modal/_confirmation.html.twig +++ /dev/null @@ -1,26 +0,0 @@ -{% set currentRoute = payplug_get_current_route() %} - diff --git a/src/Resources/views/card/index.html.twig b/src/Resources/views/card/index.html.twig deleted file mode 100644 index 68614718..00000000 --- a/src/Resources/views/card/index.html.twig +++ /dev/null @@ -1,10 +0,0 @@ -{% extends '@PayPlugSyliusPayPlugPlugin/card/layout.html.twig' %} - -{% import '@SyliusUi/Macro/messages.html.twig' as messages %} -{% import '@SyliusUi/Macro/buttons.html.twig' as buttons %} - -{% block title %}{{ 'payplug_sylius_payplug_plugin.ui.account.saved_cards.title'|trans }} | {{ parent() }}{% endblock %} - -{% block subcontent %} - {{ sylius_template_event('sylius.shop.account.saved_cards.index.subcontent', {'savedCards': savedCards}) }} -{% endblock %} diff --git a/src/Resources/views/card/layout.html.twig b/src/Resources/views/card/layout.html.twig deleted file mode 100644 index fc9f4bf4..00000000 --- a/src/Resources/views/card/layout.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{% extends '@SyliusShop/Account/layout.html.twig' %} - -{% block stylesheets %} - {{ parent() }} - {{ sylius_template_event('sylius.shop.account.saved_cards.layout.stylesheets') }} -{% endblock %} - -{% block content %} - {% block breadcrumb %} - - {% endblock %} - -
-
- {{ sylius_template_event('sylius.shop.account.layout.menu') }} -
-
- {{ sylius_template_event('sylius.shop.account.layout.before_subcontent') }} - - {% block subcontent %} - {% endblock %} - - {{ sylius_template_event('sylius.shop.account.layout.after_subcontent') }} -
-
-{% endblock %} diff --git a/src/Resources/views/form/complete_info_popin.html.twig b/src/Resources/views/form/complete_info_popin.html.twig deleted file mode 100644 index b7ec8455..00000000 --- a/src/Resources/views/form/complete_info_popin.html.twig +++ /dev/null @@ -1,44 +0,0 @@ -
-
- - - -
-
-
-

{{ 'payplug_sylius_payplug_plugin.form.complete_info.missing_title'|trans }}

-
- {{ form_start(form, {'attr': {'class': 'ui form loadable', 'novalidate': 'novalidate'}}) }} - {% set phoneField = form.billing_phone ?? form.shipping_phone ?? form.phone ?? null %} - {% if phoneField is not null %} -
- - {{ form_widget(phoneField, {attr: {class: 'required'}}) }} - {{ form_errors(phoneField) }} -
- {% endif %} - {% if form.email is defined %} -
- - {{ form_widget(form.email, {attr: {class: 'required'}}) }} - {{ form_errors(form.email) }} -
- {% endif %} -
- {{ form_widget(form.submit, { label: 'payplug_sylius_payplug_plugin.form.complete_info.submit', attr: { class: 'ui large primary button' }}) }} - {{ 'payplug_sylius_payplug_plugin.ui.cancel'|trans }} -
- {{ form_rest(form) }} - {{ form_end(form) }} -
-
-
- -

{{ 'payplug_sylius_payplug_plugin.form.complete_info.success_title'|trans }}

-
-

{{ 'payplug_sylius_payplug_plugin.form.complete_info.success_instruction'|trans }}

-
-
diff --git a/src/Resources/views/javascripts/oney_common.html.twig b/src/Resources/views/javascripts/oney_common.html.twig deleted file mode 100644 index 6370e61a..00000000 --- a/src/Resources/views/javascripts/oney_common.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/oney_common/index.js'} %} diff --git a/src/Resources/views/javascripts/select_payment_js.html.twig b/src/Resources/views/javascripts/select_payment_js.html.twig deleted file mode 100644 index 84d44572..00000000 --- a/src/Resources/views/javascripts/select_payment_js.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/payment/index.js'} %} diff --git a/src/Resources/views/javascripts/webfont_loader.html.twig b/src/Resources/views/javascripts/webfont_loader.html.twig deleted file mode 100644 index 3c3c060c..00000000 --- a/src/Resources/views/javascripts/webfont_loader.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js'} %} diff --git a/src/Resources/views/oney/cart/pay_with_oney.html.twig b/src/Resources/views/oney/cart/pay_with_oney.html.twig deleted file mode 100644 index f22394dd..00000000 --- a/src/Resources/views/oney/cart/pay_with_oney.html.twig +++ /dev/null @@ -1,49 +0,0 @@ -{% if is_oney_enabled() and can_show_mea() %} - {% set data = [] %} - {% set logo_disabled = '3x4x-alt.svg' %} - {% set logo_enabled = '3x4x.svg' %} - {% if is_oney_without_fees() %} - {% set logo_enabled = '3x4x-without-fees.svg' %} - {% set logo_disabled = '3x4x-without-fees-alt.svg' %} - {% endif %} - {% if oney_cart_eligible() %} - {% set logo_name = logo_enabled %} - {% if is_oney_without_fees() %} - {% set logo_enabled = '3x4x-without-fees.svg' %} - {% endif %} - {% else %} - {% set data = oney_ineligible_reasons() %} - {% set logo_name = logo_disabled %} - {% endif %} -
- {{ 'payplug_sylius_payplug_plugin.ui.or_pay_with_oney'|trans }} - -
-
-
-
{% if data is not empty %} -
- - - -
-
- {% for reason in data.reasons %} -

{{ reason|trans(data.trans_params) }}

- {% endfor %} -
- {% endif %}
- - - - -
-{% endif %} diff --git a/src/Resources/views/oney/product/pay_with_oney.html.twig b/src/Resources/views/oney/product/pay_with_oney.html.twig deleted file mode 100644 index fc01aa50..00000000 --- a/src/Resources/views/oney/product/pay_with_oney.html.twig +++ /dev/null @@ -1,49 +0,0 @@ -{% if is_oney_enabled() and can_show_mea() %} - {% set logo_disabled = '3x4x-alt.svg' %} - {% set logo_enabled = '3x4x.svg' %} - {% if is_oney_without_fees() %} - {% set logo_enabled = '3x4x-without-fees.svg' %} - {% set logo_disabled = '3x4x-without-fees-alt.svg' %} - {% endif %} - {% if oney_product_eligible() %} - {% set logo_name = logo_enabled %} - {% if is_oney_without_fees() %} - {% set logo_enabled = '3x4x-without-fees.svg' %} - {% endif %} - {% else %} - {% set logo_name = logo_disabled %} - {% endif %} -
- {{ 'payplug_sylius_payplug_plugin.ui.or_pay_with_oney'|trans }} - -
-
-
-
-
-
- - -
- {% for variantCodes in sylius_product_variant_codes(product, sylius.channel) %} -
- {% endfor %} -
- -{% endif %} diff --git a/src/Resources/views/stylesheets/oney_common.html.twig b/src/Resources/views/stylesheets/oney_common.html.twig deleted file mode 100644 index c55ea177..00000000 --- a/src/Resources/views/stylesheets/oney_common.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/oney_common/index.css'} %} diff --git a/src/Resources/views/stylesheets/payment_method_css.html.twig b/src/Resources/views/stylesheets/payment_method_css.html.twig deleted file mode 100644 index a3a71c36..00000000 --- a/src/Resources/views/stylesheets/payment_method_css.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/admin/payment_method/index.css'} %} diff --git a/src/Resources/views/stylesheets/saved_cards.html.twig b/src/Resources/views/stylesheets/saved_cards.html.twig deleted file mode 100644 index f027c015..00000000 --- a/src/Resources/views/stylesheets/saved_cards.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/account/index.css'} %} \ No newline at end of file diff --git a/src/Resources/views/stylesheets/select_payment_css.html.twig b/src/Resources/views/stylesheets/select_payment_css.html.twig deleted file mode 100644 index 55cfa340..00000000 --- a/src/Resources/views/stylesheets/select_payment_css.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/payment/index.css'} %} diff --git a/src/StateMachine/Transition/OrderPaymentTransitions.php b/src/StateMachine/Transition/OrderPaymentTransitions.php index 5ff74ed6..3711db32 100644 --- a/src/StateMachine/Transition/OrderPaymentTransitions.php +++ b/src/StateMachine/Transition/OrderPaymentTransitions.php @@ -4,9 +4,9 @@ namespace PayPlug\SyliusPayPlugPlugin\StateMachine\Transition; -interface OrderPaymentTransitions -{ - public const GRAPH = 'payplug_sylius_order_payment'; +use Sylius\Component\Core\OrderPaymentTransitions as BaseOrderPaymentTransitions; - public const TRANSITION_REQUEST_PAYMENT = 'request_payment'; +interface OrderPaymentTransitions extends BaseOrderPaymentTransitions +{ + public const TRANSITION_ONEY_REQUEST_PAYMENT = 'oney_request_payment'; } diff --git a/src/Twig/GetCurrentRouteExtension.php b/src/Twig/GetCurrentRouteExtension.php index 455f1833..c396db49 100644 --- a/src/Twig/GetCurrentRouteExtension.php +++ b/src/Twig/GetCurrentRouteExtension.php @@ -11,28 +11,25 @@ final class GetCurrentRouteExtension extends AbstractExtension { - /** @var Request|null */ - private $request; - public function __construct( - RequestStack $requestStack + private RequestStack $requestStack, ) { - $this->request = $requestStack->getCurrentRequest(); } public function getFunctions(): array { return [ - new TwigFunction('payplug_get_current_route', [$this, 'payplugGetCurrentRoute']), + new TwigFunction('payplug_get_current_route', $this->payplugGetCurrentRoute(...)), ]; } public function payplugGetCurrentRoute(): string { - if (!$this->request instanceof Request) { + $currentRequest = $this->requestStack->getCurrentRequest(); + if (!$currentRequest instanceof Request) { return ''; } - return $this->request->get('_route', ''); + return $currentRequest->get('_route', ''); } } diff --git a/src/Twig/GetPayPlugApiUrlExtension.php b/src/Twig/GetPayPlugApiUrlExtension.php index 236308bc..f345cff6 100644 --- a/src/Twig/GetPayPlugApiUrlExtension.php +++ b/src/Twig/GetPayPlugApiUrlExtension.php @@ -12,7 +12,7 @@ final class GetPayPlugApiUrlExtension extends AbstractExtension public function getFunctions(): array { return [ - new TwigFunction('payplug_get_api_url', [$this, 'getApiUrl']), + new TwigFunction('payplug_get_api_url', $this->getApiUrl(...)), ]; } diff --git a/src/Twig/OneyExtension.php b/src/Twig/OneyExtension.php index 4e2c9a7d..e7952400 100644 --- a/src/Twig/OneyExtension.php +++ b/src/Twig/OneyExtension.php @@ -14,34 +14,18 @@ final class OneyExtension extends AbstractExtension { - /** @var \Sylius\Component\Resource\Repository\RepositoryInterface */ - private $gatewayConfigRepository; - - /** @var \Sylius\Component\Resource\Repository\RepositoryInterface */ - private $paymentMethodRepository; - - /** @var \Sylius\Component\Channel\Context\ChannelContextInterface */ - private $channelContext; - - /** @var \PayPlug\SyliusPayPlugPlugin\Checker\OneyChecker */ - private $oneyChecker; - public function __construct( - RepositoryInterface $gatewayConfigRepository, - RepositoryInterface $paymentMethodRepository, - ChannelContextInterface $channelContext, - OneyChecker $oneyChecker + private RepositoryInterface $gatewayConfigRepository, + private RepositoryInterface $paymentMethodRepository, + private ChannelContextInterface $channelContext, + private OneyChecker $oneyChecker, ) { - $this->gatewayConfigRepository = $gatewayConfigRepository; - $this->paymentMethodRepository = $paymentMethodRepository; - $this->channelContext = $channelContext; - $this->oneyChecker = $oneyChecker; } public function getFunctions(): array { return [ - new TwigFunction('is_oney_enabled', [$this, 'isOneyEnabled']), + new TwigFunction('is_oney_enabled', $this->isOneyEnabled(...)), ]; } diff --git a/src/Twig/OneyRulesExtension.php b/src/Twig/OneyRulesExtension.php index 64ff192c..fe2116e7 100644 --- a/src/Twig/OneyRulesExtension.php +++ b/src/Twig/OneyRulesExtension.php @@ -15,6 +15,7 @@ use Sylius\Component\Core\Repository\ProductRepositoryInterface; use Sylius\Component\Currency\Model\CurrencyInterface; use Sylius\Component\Order\Context\CartContextInterface; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\RequestStack; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; @@ -22,52 +23,29 @@ final class OneyRulesExtension extends AbstractExtension { - /** @var CartContextInterface */ - private $cartContext; - - /** @var OneyCheckerInterface */ - private $oneyChecker; - - /** @var PayPlugApiClientInterface */ - private $oneyClient; - - /** @var MoneyFormatterInterface */ - private $moneyFormatter; - - /** @var ProductRepositoryInterface */ - private $productRepository; - - /** @var RequestStack */ - private $requestStack; - public function __construct( - OneyCheckerInterface $oneyChecker, - CartContextInterface $cartContext, - PayPlugApiClientInterface $oneyClient, - MoneyFormatterInterface $moneyFormatter, - ProductRepositoryInterface $productRepository, - RequestStack $requestStack + private OneyCheckerInterface $oneyChecker, + private CartContextInterface $cartContext, + #[Autowire('@payplug_sylius_payplug_plugin.api_client.oney')] + private PayPlugApiClientInterface $oneyClient, + private MoneyFormatterInterface $moneyFormatter, + private ProductRepositoryInterface $productRepository, + private RequestStack $requestStack, ) { - $this->oneyChecker = $oneyChecker; - $this->cartContext = $cartContext; - $this->oneyClient = $oneyClient; - $this->moneyFormatter = $moneyFormatter; - $this->productRepository = $productRepository; - $this->requestStack = $requestStack; } public function getFunctions(): array { return [ - new TwigFunction('oney_cart_eligible', [$this, 'isCartEligible']), - new TwigFunction('oney_product_eligible', [$this, 'isProductEligible']), - new TwigFunction('oney_ineligible_reasons', [$this, 'getReasonsOfIneligibility']), + new TwigFunction('oney_cart_eligible', $this->isCartEligible(...)), + new TwigFunction('oney_product_eligible', $this->isProductEligible(...)), + new TwigFunction('oney_ineligible_reasons', $this->getReasonsOfIneligibility(...)), ]; } public function isCartEligible(?OrderInterface $currentCart = null): bool { - if (null === $currentCart) { + if (!$currentCart instanceof \Sylius\Component\Core\Model\OrderInterface) { /** @var OrderInterface $currentCart */ $currentCart = $this->cartContext->getCart(); } @@ -91,7 +69,7 @@ public function isCartEligible(?OrderInterface $currentCart = null): bool if (null === $currencyCode) { throw new \LogicException('No currency code found'); } - } catch (\Throwable $throwable) { + } catch (\Throwable) { // unable to find currency_code return false; } @@ -104,7 +82,7 @@ public function getReasonsOfIneligibility(?OrderInterface $currentCart = null): $data = []; $transParam = []; - if (null === $currentCart) { + if (!$currentCart instanceof \Sylius\Component\Core\Model\OrderInterface) { /** @var OrderInterface $currentCart */ $currentCart = $this->cartContext->getCart(); } @@ -137,18 +115,18 @@ public function getReasonsOfIneligibility(?OrderInterface $currentCart = null): '%min_amount%' => $this->moneyFormatter->format( $account['configuration']['oney']['min_amounts'][$currencyCode], $currencyCode, - $currentCart->getLocaleCode() + $currentCart->getLocaleCode(), ), ]; $transParam[] = [ '%max_amount%' => $this->moneyFormatter->format( $account['configuration']['oney']['max_amounts'][$currencyCode], $currencyCode, - $currentCart->getLocaleCode() + $currentCart->getLocaleCode(), ), ]; } - } catch (\Throwable $throwable) { + } catch (\Throwable) { // do nothing } @@ -164,7 +142,7 @@ public function isProductEligible(): bool $currentCart = $this->cartContext->getCart(); $request = $this->requestStack->getCurrentRequest(); - if (null === $request || 'sylius_shop_product_show' !== $request->get('_route')) { + if (!$request instanceof \Symfony\Component\HttpFoundation\Request || 'sylius_shop_product_show' !== $request->get('_route')) { return false; } @@ -183,7 +161,7 @@ public function isProductEligible(): bool if (null === $currencyCode) { throw new \LogicException('No currency code found'); } - } catch (\Throwable $throwable) { + } catch (\Throwable) { // unable to find currency_code return false; } @@ -196,7 +174,7 @@ public function isProductEligible(): bool $product = $this->productRepository->findOneByChannelAndSlug( $channel, $currentCart->getLocaleCode(), - $request->get('_route_params')['slug'] + $request->get('_route_params')['slug'], ); Assert::isInstanceOf($product, ProductInterface::class); diff --git a/src/Twig/OneySimulationExtension.php b/src/Twig/OneySimulationExtension.php index 63cfe274..45c3a651 100644 --- a/src/Twig/OneySimulationExtension.php +++ b/src/Twig/OneySimulationExtension.php @@ -18,40 +18,21 @@ final class OneySimulationExtension extends AbstractExtension { - /** @var \Sylius\Component\Order\Context\CartContextInterface */ - private $cartContext; - - /** @var \PayPlug\SyliusPayPlugPlugin\Provider\OneySimulation\OneySimulationDataProviderInterface */ - private $oneySimulationDataProvider; - - /** @var \Symfony\Component\HttpFoundation\RequestStack */ - private $requestStack; - - /** @var \Sylius\Component\Core\Repository\OrderRepositoryInterface */ - private $orderRepository; - - private OneySupportedPaymentChoiceProvider $oneySupportedPaymentChoiceProvider; - public function __construct( - CartContextInterface $cartContext, - OneySimulationDataProviderInterface $oneySimulationDataProvider, - RequestStack $requestStack, - OrderRepositoryInterface $orderRepository, - OneySupportedPaymentChoiceProvider $oneySupportedPaymentChoiceProvider + private CartContextInterface $cartContext, + private OneySimulationDataProviderInterface $oneySimulationDataProvider, + private RequestStack $requestStack, + private OrderRepositoryInterface $orderRepository, + private OneySupportedPaymentChoiceProvider $oneySupportedPaymentChoiceProvider, ) { - $this->cartContext = $cartContext; - $this->oneySimulationDataProvider = $oneySimulationDataProvider; - $this->requestStack = $requestStack; - $this->orderRepository = $orderRepository; - $this->oneySupportedPaymentChoiceProvider = $oneySupportedPaymentChoiceProvider; } public function getFunctions(): array { return [ - new TwigFunction('oney_simulation_data', [$this, 'getSimulationData']), - new TwigFunction('oney_supported_choices', [$this, 'getSupportedPaymentChoices']), - new TwigFunction('is_oney_without_fees', [$this, 'isPaymentChoiceWithoutFees']), + new TwigFunction('oney_simulation_data', $this->getSimulationData(...)), + new TwigFunction('oney_supported_choices', $this->getSupportedPaymentChoices(...)), + new TwigFunction('is_oney_without_fees', $this->isPaymentChoiceWithoutFees(...)), ]; } @@ -90,9 +71,9 @@ public function getSupportedPaymentChoices(): array public function isPaymentChoiceWithoutFees(): bool { - return \count(\array_filter( + return \array_filter( $this->getSupportedPaymentChoices(), - fn (string $choice) => \in_array($choice, OneyGatewayFactory::ONEY_WITHOUT_FEES_CHOICES, true) - )) > 0; + fn (string $choice) => \in_array($choice, OneyGatewayFactory::ONEY_WITHOUT_FEES_CHOICES, true), + ) !== []; } } diff --git a/src/Twig/PayPlugExtension.php b/src/Twig/PayPlugExtension.php index d0689c43..9ebfcfc7 100644 --- a/src/Twig/PayPlugExtension.php +++ b/src/Twig/PayPlugExtension.php @@ -12,23 +12,17 @@ final class PayPlugExtension extends AbstractExtension { - /** @var CanSaveCardCheckerInterface */ - private $canSaveCardChecker; - private PayPlugApiClientFactory $apiClientFactory; - public function __construct( - CanSaveCardCheckerInterface $canSaveCardChecker, - PayPlugApiClientFactory $apiClientFactory, + private CanSaveCardCheckerInterface $canSaveCardChecker, + private PayPlugApiClientFactory $apiClientFactory, ) { - $this->canSaveCardChecker = $canSaveCardChecker; - $this->apiClientFactory = $apiClientFactory; } public function getFunctions(): array { return [ - new TwigFunction('is_save_card_enabled', [$this, 'isSaveCardAllowed']), - new TwigFunction('is_payplug_test_mode_enabled', [$this, 'isTest']), + new TwigFunction('is_save_card_enabled', $this->isSaveCardAllowed(...)), + new TwigFunction('is_payplug_test_mode_enabled', $this->isTest(...)), ]; } @@ -41,6 +35,6 @@ public function isTest(PaymentMethodInterface $paymentMethod): bool { $client = $this->apiClientFactory->createForPaymentMethod($paymentMethod); - return ((bool) $client->getAccount()['is_live']) !== true; + return !(bool) $client->getAccount()['is_live']; } } diff --git a/src/Twig/ProductVariantsCodesExtension.php b/src/Twig/ProductVariantsCodesExtension.php index 3dc49e47..df1b6b55 100644 --- a/src/Twig/ProductVariantsCodesExtension.php +++ b/src/Twig/ProductVariantsCodesExtension.php @@ -15,7 +15,7 @@ final class ProductVariantsCodesExtension extends AbstractExtension public function getFunctions(): array { return [ - new TwigFunction('sylius_product_variant_codes', [$this, 'provideVariantsCodes']), + new TwigFunction('sylius_product_variant_codes', $this->provideVariantsCodes(...)), ]; } diff --git a/src/Twig/ShowMeaExtension.php b/src/Twig/ShowMeaExtension.php index 4a1aca72..e74e601f 100644 --- a/src/Twig/ShowMeaExtension.php +++ b/src/Twig/ShowMeaExtension.php @@ -6,30 +6,26 @@ use PayPlug\SyliusPayPlugPlugin\ApiClient\PayPlugApiClientInterface; use Sylius\Component\Locale\Context\LocaleContextInterface; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; final class ShowMeaExtension extends AbstractExtension { - /** @var PayPlugApiClientInterface */ - private $oneyClient; - - /** @var LocaleContextInterface */ - private $localeContext; - /** @var string */ public $localeCode; - public function __construct(LocaleContextInterface $localeContext, PayPlugApiClientInterface $oneyClient) - { - $this->localeContext = $localeContext; - $this->oneyClient = $oneyClient; + public function __construct( + private LocaleContextInterface $localeContext, + #[Autowire('@payplug_sylius_payplug_plugin.api_client.oney')] + private PayPlugApiClientInterface $oneyClient, + ) { } public function getFunctions(): array { return [ - new TwigFunction('can_show_mea', [$this, 'canShowMEA']), + new TwigFunction('can_show_mea', $this->canShowMEA(...)), ]; } @@ -42,11 +38,7 @@ public function canShowMEA(): bool return false; } - if ($this->getLocaleCode() === $this->oneyClient->getAccount()['country']) { - return true; - } - - return false; + return $this->getLocaleCode() === $this->oneyClient->getAccount()['country']; } private function getLocaleCode(): string diff --git a/src/Validator/OneyInvalidDataRetriever.php b/src/Validator/OneyInvalidDataRetriever.php index 191e8e4d..6ada2326 100644 --- a/src/Validator/OneyInvalidDataRetriever.php +++ b/src/Validator/OneyInvalidDataRetriever.php @@ -70,7 +70,7 @@ private function isPhoneAddressValid(AddressInterface $address): bool } return PhoneNumberType::MOBILE === $this->phoneNumberUtil->getNumberType($parsedNumber); - } catch (\Throwable $throwable) { + } catch (\Throwable) { return false; } } diff --git a/src/Validator/PaymentMethodValidator.php b/src/Validator/PaymentMethodValidator.php new file mode 100644 index 00000000..bb88cf29 --- /dev/null +++ b/src/Validator/PaymentMethodValidator.php @@ -0,0 +1,101 @@ +getGatewayConfig()) { + return; + } + + $errors = match ($paymentMethod->getGatewayConfig()->getFactoryName()) { + PayPlugGatewayFactory::FACTORY_NAME => $this->processPayplug($paymentMethod), + OneyGatewayFactory::FACTORY_NAME => $this->processOney($paymentMethod), + BancontactGatewayFactory::FACTORY_NAME => $this->processBancontact($paymentMethod), + AmericanExpressGatewayFactory::FACTORY_NAME => $this->processAmex($paymentMethod), + ApplePayGatewayFactory::FACTORY_NAME => $this->processApplePay($paymentMethod), + default => throw new \InvalidArgumentException("Unsupported payment method"), + }; + + foreach ($errors as $error) { + $this->requestStack->getSession()->getFlashBag()->add('payplug_error', $error->getMessage()); + } + if (0 !== count($errors)) { + $paymentMethod->disable(); + $this->requestStack->getSession()->getFlashBag()->add('payplug_error', 'payplug_sylius_payplug_plugin.admin.payment_method_disabled'); + } + $this->entityManager->flush(); + } + + private function processPayplug(PaymentMethodInterface $paymentMethod): ConstraintViolationListInterface + { + $config = $paymentMethod->getGatewayConfig()?->getConfig() ?? []; + $constraintList = [new IsCanSavePaymentMethod()]; + + if (true === $config[PayPlugGatewayFactory::ONE_CLICK]) { + $constraintList[] = new PayplugPermission(Permission::CAN_SAVE_CARD); + } + if (true === $config[PayPlugGatewayFactory::DEFERRED_CAPTURE]) { + $constraintList[] = new PayplugPermission(Permission::CAN_CREATE_DEFERRED_PAYMENT); + } + if (true === $config[PayPlugGatewayFactory::INTEGRATED_PAYMENT]) { + $constraintList[] = new PayplugPermission(Permission::CAN_USE_INTEGRATED_PAYMENTS); + } + + return $this->validator->validate($paymentMethod, $constraintList, self::VALIDATION_GROUPS); + } + + private function processOney(PaymentMethodInterface $paymentMethod): ConstraintViolationListInterface + { + $constraintList = [new IsOneyEnabled()]; + return $this->validator->validate($paymentMethod, $constraintList, self::VALIDATION_GROUPS); + } + + private function processBancontact(PaymentMethodInterface $paymentMethod): ConstraintViolationListInterface + { + $constraintList = [new IsCanSavePaymentMethod()]; + return $this->validator->validate($paymentMethod, $constraintList, self::VALIDATION_GROUPS); + } + + private function processAmex(PaymentMethodInterface $paymentMethod): ConstraintViolationListInterface + { + $constraintList = [new IsCanSavePaymentMethod()]; + return $this->validator->validate($paymentMethod, $constraintList, self::VALIDATION_GROUPS); + } + + private function processApplePay(PaymentMethodInterface $paymentMethod): ConstraintViolationListInterface + { + $constraintList = [new IsCanSavePaymentMethod()]; + return $this->validator->validate($paymentMethod, $constraintList, self::VALIDATION_GROUPS); + } +} diff --git a/templates/admin/payment_method/form/deferred_capture.html.twig b/templates/admin/payment_method/form/deferred_capture.html.twig new file mode 100644 index 00000000..be0c32d2 --- /dev/null +++ b/templates/admin/payment_method/form/deferred_capture.html.twig @@ -0,0 +1,5 @@ +{% set form = hookable_metadata.context.form.gatewayConfig.config.deferredCapture %} + +
+ {{ form_row(form) }} +
\ No newline at end of file diff --git a/templates/admin/payment_method/form/fees_for.html.twig b/templates/admin/payment_method/form/fees_for.html.twig new file mode 100644 index 00000000..5d1be6ac --- /dev/null +++ b/templates/admin/payment_method/form/fees_for.html.twig @@ -0,0 +1,5 @@ +{% set form = hookable_metadata.context.form.gatewayConfig.config.fees_for %} + +
+ {{ form_row(form) }} +
\ No newline at end of file diff --git a/templates/admin/payment_method/form/integrated_payment.html.twig b/templates/admin/payment_method/form/integrated_payment.html.twig new file mode 100644 index 00000000..26c8c373 --- /dev/null +++ b/templates/admin/payment_method/form/integrated_payment.html.twig @@ -0,0 +1,5 @@ +{% set form = hookable_metadata.context.form.gatewayConfig.config.integratedPayment %} + +
+ {{ form_row(form) }} +
\ No newline at end of file diff --git a/templates/admin/payment_method/form/live_checkbox.html.twig b/templates/admin/payment_method/form/live_checkbox.html.twig new file mode 100644 index 00000000..82c955e9 --- /dev/null +++ b/templates/admin/payment_method/form/live_checkbox.html.twig @@ -0,0 +1,5 @@ +{% set form = hookable_metadata.context.form.gatewayConfig.config.live %} + +
+ {{ form_row(form) }} +
diff --git a/templates/admin/payment_method/form/one_click.html.twig b/templates/admin/payment_method/form/one_click.html.twig new file mode 100644 index 00000000..9b8ca882 --- /dev/null +++ b/templates/admin/payment_method/form/one_click.html.twig @@ -0,0 +1,5 @@ +{% set form = hookable_metadata.context.form.gatewayConfig.config.oneClick %} + +
+ {{ form_row(form) }} +
\ No newline at end of file diff --git a/templates/admin/payment_method/form/renew_oauth.html.twig b/templates/admin/payment_method/form/renew_oauth.html.twig new file mode 100644 index 00000000..ee30d8f9 --- /dev/null +++ b/templates/admin/payment_method/form/renew_oauth.html.twig @@ -0,0 +1,5 @@ +{% set form = hookable_metadata.context.form.gatewayConfig.config.renew_oauth %} + +
+ {{ form_row(form, {attr: {name:"renew_oauth"}}) }} +
diff --git a/templates/admin/shared/flashes.html.twig b/templates/admin/shared/flashes.html.twig new file mode 100644 index 00000000..9e656426 --- /dev/null +++ b/templates/admin/shared/flashes.html.twig @@ -0,0 +1,30 @@ +{% set session = _context.app.session|default(null) %} + +
+{% for flash in session.flashbag.get('payplug_error') %} + +{% endfor %} +
diff --git a/templates/form/complete_info_popin.html.twig b/templates/form/complete_info_popin.html.twig new file mode 100644 index 00000000..80165aaa --- /dev/null +++ b/templates/form/complete_info_popin.html.twig @@ -0,0 +1,26 @@ +{% form_theme form '@SyliusShop/form/theme.html.twig' %} + +
+
+ {{ form_start(form, {'attr': {'class': 'ui form loadable', 'novalidate': 'novalidate'}}) }} + {% set phoneField = form.billing_phone ?? form.shipping_phone ?? form.phone ?? null %} + {% if phoneField is not null %} + {{ form_row(phoneField, {attr: {class: 'required'}}) }} + {% endif %} + {% if form.email is defined %} + {{ form_row(form.email, {attr: {class: 'required'}}) }} + {% endif %} +
+ {{ form_row(form.submit, { label: 'payplug_sylius_payplug_plugin.form.complete_info.submit', attr: { class: 'btn btn-primary' }}) }} +
+ {{ form_rest(form) }} + {{ form_end(form) }} +
+
+
+ +

{{ 'payplug_sylius_payplug_plugin.form.complete_info.success_title'|trans }}

+
+

{{ 'payplug_sylius_payplug_plugin.form.complete_info.success_instruction'|trans }}

+
+
diff --git a/templates/form/form_gateway_config_row.html.twig b/templates/form/form_gateway_config_row.html.twig new file mode 100644 index 00000000..e4737b58 --- /dev/null +++ b/templates/form/form_gateway_config_row.html.twig @@ -0,0 +1,33 @@ +{% block _sylius_admin_payment_method_gatewayConfig_factoryName_help %} +
+ {% set isOney = constant('\\PayPlug\\SyliusPayPlugPlugin\\Gateway\\OneyGatewayFactory::FACTORY_NAME') in form.vars.value %} + {% if isOney %} + + {% endif %} +
+{% endblock %} + +{% block _sylius_admin_payment_method_gatewayConfig_config_payplug_checkbox_widget %} +
+ {{- form_widget(form) -}} +
+{% endblock %} + +{% block _sylius_admin_payment_method_gatewayConfig_config_fees_for_row %} +
+ {{ form_label(form) }} + {%- for child in form %} +
+ {{- form_widget(child, {'attr': 'client' in child.vars.value ? {'checked': 'checked'} : {}}, sylius_test_form_attribute('option')) -}} + {{- form_label(child, null, {translation_domain: choice_translation_domain}) -}} +
+ {% endfor -%} +
+ {{- form_errors(form) -}} +{% endblock %} + +{% block _sylius_admin_payment_method_gatewayConfig_config_fees_for_label %} + {{ label|trans }} +{% endblock %} diff --git a/src/Resources/views/form/form_gateway_config_row.html.twig b/templates/form/sylius_checkout_select_payment_row.html.twig similarity index 59% rename from src/Resources/views/form/form_gateway_config_row.html.twig rename to templates/form/sylius_checkout_select_payment_row.html.twig index d4d52219..f6b2ae7b 100644 --- a/src/Resources/views/form/form_gateway_config_row.html.twig +++ b/templates/form/sylius_checkout_select_payment_row.html.twig @@ -1,94 +1,7 @@ -{% block _sylius_payment_method_gatewayConfig_factoryName_row %} - {% set isOney = constant('\\PayPlug\\SyliusPayPlugPlugin\\Gateway\\OneyGatewayFactory::FACTORY_NAME') in form.vars.value %} - {% if isOney %} -
-
-
-
{{ ('payplug_sylius_payplug_plugin.ui.oney_gateway_config.info')|trans({'%link%': 'https://support.payplug.com/hc/fr/articles/360015899980-Le-paiement-fractionn%C3%A9-garanti-avec-Oney-sur-Sylius'})|raw }}
-
-
-
- {% endif %} -
- {{- form_row(form, not isOney ? {'attr': {'style': 'margin: 0 0 1rem;'}} : {}) -}} -
-{% endblock %} - -{% block _sylius_payment_method_gatewayConfig_config_secretKey_row %} - {% set hasFeesFor = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\OneyGatewayFactory::FEES_FOR') in form.parent.children|keys %} - {% if hasFeesFor %} - {# close previous to avoid 2 columns #} - {% endif %} -
- {{- form_label(form) -}} - {{- form_widget(form) -}} - - {{- form_help(form) -}} - - {% for error in errors %} -
- {{ error.message|raw }} -
- {% endfor %} -
- {% if hasFeesFor %} -
- {% endif %} -{% endblock %} - -{% block _sylius_payment_method_gatewayConfig_config_fees_for_row %} -
-
-
- {{ form_label(form) }} -
- {%- for child in form %} -
-
- {{- form_label(child, null, {translation_domain: choice_translation_domain}) -}} - {{- form_widget(child, {'attr': 'client' in child.vars.value ? {'checked': 'checked'} : {}}, sylius_test_form_attribute('option')) -}} -
-
- {% endfor -%} -
- {{- form_errors(form) -}} -
- -{% endblock %} - -{% block _sylius_payment_method_gatewayConfig_config_payplug_checkbox_row %} -
-
- {{- form_label(form) -}} - {{- form_widget(form) -}} -
- - - {{- form_help(form) -}} - - {% for error in errors %} -
- {{ error.message|raw }} -
- {% endfor %} -
-{% endblock %} - -{% block _sylius_payment_method_enabled_errors %} - {% for error in errors %} -
- {{ error.message|raw }} -
- {% endfor %} -{% endblock %} - -{% block _sylius_checkout_select_payment_payments_entry_oney_payment_choice_row %} +{% block oney_payment_choice_row %} {% set data = oney_simulation_data() %} - {% import "@SyliusShop/Common/Macro/money.html.twig" as money %} + {% import "@SyliusShop/shared/macro/money.html.twig" as money %} +
{% for keyChoice, choice in form.vars.choices %} @@ -108,16 +21,17 @@ {% endif %}
{% endblock %} -{% block _sylius_checkout_select_payment_payments_entry_payplug_card_choice_row %} +{% block payplug_saved_cards %}
{% for card in sylius.customer.cards %} {% set cardExpirationDate = ("%04d"|format(card.expirationYear) ~ '-' ~ "%02d"|format(card.expirationMonth))|date("Y-m") %} @@ -164,11 +78,11 @@ id="payplug_choice_card_{{ card.id }}" name="{{ form.vars.full_name }}" class="payplug-payment-choice__input payment-choice__input" - {% if form.vars.value is not empty %} - {{ form.vars.value == card.id ? 'checked="checked"' : '' }} - {% elseif loop.index is same as(1) %} - checked="checked" - {% endif %} + {% if form.vars.value is not empty %} + {{ form.vars.value == card.id ? 'checked="checked"' : '' }} + {% elseif loop.index is same as(1) %} + checked="checked" + {% endif %} >
{% endblock %} + +{% block _sylius_shop_checkout_select_payment_payments_entry_payplug_card_choice_row %} + {{ block('payplug_saved_cards') }} +{% endblock %} + +{% block _sylius_checkout_select_payment_payments_entry_payplug_card_choice_row %} + {{ block('payplug_saved_cards') }} +{% endblock %} diff --git a/templates/shared/form/select_payment/payment/choice.html.twig b/templates/shared/form/select_payment/payment/choice.html.twig new file mode 100644 index 00000000..19a28816 --- /dev/null +++ b/templates/shared/form/select_payment/payment/choice.html.twig @@ -0,0 +1,14 @@ +{% set form = hookable_metadata.context.form %} + +
+ {{ form_errors(form.method) }} + + {% for key, choice_form in form.method %} + {% hook 'choice' with { 'form': choice_form, 'method': form.method.vars.choices[key].data } %} + {% else %} + {% hook 'choice#unavailable' %} + {% endfor %} +
diff --git a/templates/shared/modal/index.html.twig b/templates/shared/modal/index.html.twig new file mode 100644 index 00000000..50e29481 --- /dev/null +++ b/templates/shared/modal/index.html.twig @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/src/Resources/views/shop/1click.html.twig b/templates/shop/1click.html.twig similarity index 100% rename from src/Resources/views/shop/1click.html.twig rename to templates/shop/1click.html.twig diff --git a/src/Resources/views/form/integrated.html.twig b/templates/shop/integrated/index.html.twig similarity index 87% rename from src/Resources/views/form/integrated.html.twig rename to templates/shop/integrated/index.html.twig index b1a30243..1329c28e 100644 --- a/src/Resources/views/form/integrated.html.twig +++ b/templates/shop/integrated/index.html.twig @@ -23,10 +23,12 @@ } /* ]] */ - -
-
-
+
+
+ {{ 'sylius.ui.loading'|trans }}
@@ -39,17 +41,18 @@
{{ 'payplug_sylius_payplug_plugin.ui.integrated_payment.scheme.label'|trans }}
+ {# @todo: adding radio prop name will lead to an invalid model name but it doesn't matter for now #}
@@ -83,7 +86,7 @@
{% if is_save_card_enabled(paymentMethod) %}
- + {# No name to not trigger LiveComponent #}
- -{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/payment/integrated.js'} %} -{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/payment/integrated.css'} %} diff --git a/templates/shop/oney/cart/pay_with_oney.html.twig b/templates/shop/oney/cart/pay_with_oney.html.twig new file mode 100644 index 00000000..c68e8ae9 --- /dev/null +++ b/templates/shop/oney/cart/pay_with_oney.html.twig @@ -0,0 +1,55 @@ +{% if is_oney_enabled() and can_show_mea() %} + {% set data = [] %} + {% set logo_disabled = '3x4x-alt.svg' %} + {% set logo_enabled = '3x4x.svg' %} + {% if is_oney_without_fees() %} + {% set logo_enabled = '3x4x-without-fees.svg' %} + {% set logo_disabled = '3x4x-without-fees-alt.svg' %} + {% endif %} + {% if oney_cart_eligible() %} + {% set logo_name = logo_enabled %} + {% if is_oney_without_fees() %} + {% set logo_enabled = '3x4x-without-fees.svg' %} + {% endif %} + {% else %} + {% set data = oney_ineligible_reasons() %} + {% set logo_name = logo_disabled %} + {% endif %} +
+
+ {{ 'sylius.ui.loading'|trans }} +
+ {{ 'payplug_sylius_payplug_plugin.ui.or_pay_with_oney'|trans }} + +
+ {% if data is not empty %} +
+ + + +
+
+ {% for reason in data.reasons %} +

{{ reason|trans(data.trans_params) }}

+ {% endfor %} +
+ {% endif %} +
+
+{% endif %} diff --git a/src/Resources/views/oney/popin.html.twig b/templates/shop/oney/popin.html.twig similarity index 86% rename from src/Resources/views/oney/popin.html.twig rename to templates/shop/oney/popin.html.twig index 01283c0b..f0b48837 100644 --- a/src/Resources/views/oney/popin.html.twig +++ b/templates/shop/oney/popin.html.twig @@ -1,11 +1,7 @@ -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} +{% import "@SyliusShop/shared/macro/money.html.twig" as money %} + {% if data is empty %} {% set data = ineligibilityData %} - {% if is_oney_without_fees() %} - {% set logo_name = '3x4x-without-fees.svg' %} - {% else %} - {% set logo_name = '3x4x.svg' %} - {% endif %}
@@ -36,8 +32,10 @@ {% for key, choice in oney_supported_choices() %}
- Paiement en {{ key + 3 }}x + {{ ('payplug_sylius_payplug_plugin.ui.oney_x' ~ (key + 3) ~ '_with_fees_payment')|trans }}
{{ 'payplug_sylius_payplug_plugin.ui.popin_paiement_desc'|trans({ diff --git a/templates/shop/oney/product/pay_with_oney.html.twig b/templates/shop/oney/product/pay_with_oney.html.twig new file mode 100644 index 00000000..490f8064 --- /dev/null +++ b/templates/shop/oney/product/pay_with_oney.html.twig @@ -0,0 +1,53 @@ +{% if is_oney_enabled() and can_show_mea() %} + {% set logo_disabled = '3x4x-alt.svg' %} + {% set logo_enabled = '3x4x.svg' %} + {% if is_oney_without_fees() %} + {% set logo_enabled = '3x4x-without-fees.svg' %} + {% set logo_disabled = '3x4x-without-fees-alt.svg' %} + {% endif %} + {% if oney_product_eligible() %} + {% set logo_name = logo_enabled %} + {% if is_oney_without_fees() %} + {% set logo_enabled = '3x4x-without-fees.svg' %} + {% endif %} + {% else %} + {% set logo_name = logo_disabled %} + {% endif %} +
+
+ {{ 'sylius.ui.loading'|trans }} +
+ {{ 'payplug_sylius_payplug_plugin.ui.or_pay_with_oney'|trans }} + +
+
+ {% for variant_codes in sylius_product_variant_codes(hookable_metadata.context.product, sylius.channel) %} +
+ {% endfor %} +
+
+{% endif %} diff --git a/templates/shop/saved_cards/index.html.twig b/templates/shop/saved_cards/index.html.twig new file mode 100644 index 00000000..226cb743 --- /dev/null +++ b/templates/shop/saved_cards/index.html.twig @@ -0,0 +1,10 @@ +{% extends '@PayPlugSyliusPayPlugPlugin/shop/saved_cards/layout.html.twig' %} + +{% import '@SyliusShop/shared/messages.html.twig' as messages %} +{% import '@SyliusShop/shared/buttons.html.twig' as buttons %} + +{% block title %}{{ 'payplug_sylius_payplug_plugin.ui.account.saved_cards.title'|trans }} | {{ parent() }}{% endblock %} + +{% block subcontent %} + {% hook 'sylius.shop.account.saved_cards.index.subcontent' with { _prefixes: [], savedCards: savedCards } %} +{% endblock %} diff --git a/templates/shop/saved_cards/index/_header.html.twig b/templates/shop/saved_cards/index/_header.html.twig new file mode 100644 index 00000000..63628de6 --- /dev/null +++ b/templates/shop/saved_cards/index/_header.html.twig @@ -0,0 +1,4 @@ +
+

{{ 'payplug_sylius_payplug_plugin.ui.account.saved_cards.title'|trans }}

+ {{ 'payplug_sylius_payplug_plugin.ui.account.saved_cards.sub_title'|trans }} +
\ No newline at end of file diff --git a/src/Resources/views/SyliusShopBundle/Account/SavedCards/Index/_subcontent.html.twig b/templates/shop/saved_cards/index/_subcontent.html.twig similarity index 68% rename from src/Resources/views/SyliusShopBundle/Account/SavedCards/Index/_subcontent.html.twig rename to templates/shop/saved_cards/index/_subcontent.html.twig index e3fdf002..e4412e13 100644 --- a/src/Resources/views/SyliusShopBundle/Account/SavedCards/Index/_subcontent.html.twig +++ b/templates/shop/saved_cards/index/_subcontent.html.twig @@ -1,22 +1,23 @@ -{% import '@SyliusUi/Macro/buttons.html.twig' as buttons %} -{% import '@SyliusUi/Macro/messages.html.twig' as messages %} +{% import '@SyliusShop/shared/buttons.html.twig' as buttons %} +{% import '@SyliusShop/shared/messages.html.twig' as messages %} +{% set savedCards = get_hookable_context().savedCards %} - -
- {% if savedCards|length == 0 %} - {{ messages.info('payplug_sylius_payplug_plugin.ui.account.saved_cards.no_results_to_display') }} - {% else %} - - {% endif %} -
+ + +
+ {% endif %} +
+
\ No newline at end of file diff --git a/templates/shop/saved_cards/layout.html.twig b/templates/shop/saved_cards/layout.html.twig new file mode 100644 index 00000000..190d26e9 --- /dev/null +++ b/templates/shop/saved_cards/layout.html.twig @@ -0,0 +1,29 @@ +{% extends '@SyliusShop/account/common/index.html.twig' %} + +{% set prefixes = ['sylius_shop.account.saved_card'] %} +{% from '@SyliusShop/shared/breadcrumbs.html.twig' import breadcrumbs as breadcrumbs %} + +{% block content %} +
+
+ {% block breadcrumb %} +
+ {{ breadcrumbs([ + { label: 'sylius.ui.home'|trans, path: path('sylius_shop_homepage')}, + { label: 'sylius.ui.my_account'|trans, path: path('sylius_shop_account_dashboard')}, + { label: 'payplug_sylius_payplug_plugin.ui.account.saved_cards.title'|trans, active: true} + ]) }} +
+ {% endblock %} + +
+ {% hook 'sylius_shop.account.common.index.content.menu' %} +
+ +
+ {% block subcontent %} + {% endblock %} +
+
+
+{% endblock %} diff --git a/templates/shop/select_payment/_american_express.html.twig b/templates/shop/select_payment/_american_express.html.twig new file mode 100644 index 00000000..03754436 --- /dev/null +++ b/templates/shop/select_payment/_american_express.html.twig @@ -0,0 +1,7 @@ +{% set form = hookable_metadata.context.form %} + +
diff --git a/templates/shop/select_payment/_apple_pay.html.twig b/templates/shop/select_payment/_apple_pay.html.twig new file mode 100644 index 00000000..3ae26542 --- /dev/null +++ b/templates/shop/select_payment/_apple_pay.html.twig @@ -0,0 +1,55 @@ +{% set form = hookable_metadata.context.form %} +{% set method = hookable_metadata.context.method %} +{% set order = hookable_metadata.context.order %} +{% set factoryName = method.gatewayConfig.factoryName %} +{% set code = method.code %} + +{% set applePayFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\ApplePayGatewayFactory::FACTORY_NAME') %} +{% set checkboxClass = 'checkbox-applepay' %} + +
+ +
+ +
+
+ + + + +
+ diff --git a/templates/shop/select_payment/_bancontact.html.twig b/templates/shop/select_payment/_bancontact.html.twig new file mode 100644 index 00000000..daf895e5 --- /dev/null +++ b/templates/shop/select_payment/_bancontact.html.twig @@ -0,0 +1,7 @@ +{% set form = hookable_metadata.context.form %} + +
diff --git a/templates/shop/select_payment/_oney.html.twig b/templates/shop/select_payment/_oney.html.twig new file mode 100644 index 00000000..fc5d2cd8 --- /dev/null +++ b/templates/shop/select_payment/_oney.html.twig @@ -0,0 +1,51 @@ +{% set form = hookable_metadata.context.form %} +{% set method = hookable_metadata.context.method %} +{% set order = hookable_metadata.context.order %} +{% set factoryName = method.gatewayConfig.factoryName %} +{% set code = method.code %} + +{% set oneyFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\OneyGatewayFactory::FACTORY_NAME') %} +{% set checkboxClass = 'checkbox-oney' %} + +{% set showOney = false %} +{% if form.parent.parent.oney_payment_choice is defined %} + {% set showOney = true %} +{% endif %} + +{% set values = { + modal: '.oney-complete-info-popin', + area: 'body[data-route=sylius_shop_checkout_select_payment]' +} %} + +{% if app.session is not null and app.session.flashbag.get('oney_has_error')|first is same as true %} + {% set completeInfoRoute = {route: path('payplug_sylius_oney_complete_info') ~ '?tokenValue=' ~ order.tokenValue} %} + {% set values = values|merge(completeInfoRoute) %} +{% endif %} + + + diff --git a/templates/shop/select_payment/_payplug.html.twig b/templates/shop/select_payment/_payplug.html.twig new file mode 100644 index 00000000..98d2b3e1 --- /dev/null +++ b/templates/shop/select_payment/_payplug.html.twig @@ -0,0 +1,46 @@ +{% set form = hookable_metadata.context.form %} +{% set method = hookable_metadata.context.method %} +{% set order = hookable_metadata.context.order %} +{% set factoryName = method.gatewayConfig.factoryName %} +{% set code = method.code %} + +{% set payplugFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\PayplugGatewayFactory::FACTORY_NAME') %} +{% set checkboxClass = 'checkbox-payplug' %} + +{% set hasSavedCards = false %} +{% if is_granted('ROLE_USER') + and form.parent.parent.payplug_card_choice is defined + and is_save_card_enabled(method) + and sylius.customer.cards is not empty +%} + {% set hasSavedCards = true %} +{% endif %} + +{% set integratedPayment = false %} +{% if method.gatewayConfig.config.integratedPayment is defined and method.gatewayConfig.config.integratedPayment is same as true %} + {% set integratedPayment = true %} +{% endif %} + +
+ + {{ form_label(form, null, {'label_attr': {'data-test-payment-method-label': '', 'data-gateway': 'payplug'}}) }} + + + {% if hasSavedCards %} +
+ {{ form_row(form.parent.parent.payplug_card_choice) }} +
+ {% endif %} + + {% if integratedPayment %} + {% include '@PayPlugSyliusPayPlugPlugin/shop/integrated/index.html.twig' with { + 'paymentMethod': method, + 'payment': order.getLastPayment('cart'), + 'hasSavedCards': hasSavedCards, + } %} + {% endif %} +
diff --git a/templates/shop/select_payment/choice.html.twig b/templates/shop/select_payment/choice.html.twig new file mode 100644 index 00000000..dbda00d3 --- /dev/null +++ b/templates/shop/select_payment/choice.html.twig @@ -0,0 +1,12 @@ +{% set form = hookable_metadata.context.form %} +{% set method = hookable_metadata.context.method %} +{% set order = hookable_metadata.context.order %} +{% set factoryName = method.gatewayConfig.factoryName %} + +{% set oneyFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\OneyGatewayFactory::FACTORY_NAME') %} +{% set payplugFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\PayplugGatewayFactory::FACTORY_NAME') %} +{% set bancontactFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\BancontactGatewayFactory::FACTORY_NAME') %} +{% set applePayFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\ApplePayGatewayFactory::FACTORY_NAME') %} +{% set americanExpressFactoryName = constant('PayPlug\\SyliusPayPlugPlugin\\Gateway\\AmericanExpressGatewayFactory::FACTORY_NAME') %} + +{% hook '#' ~ factoryName %} diff --git a/tests/Behat/Context/Cli/UpdatePaymentStateContext.php b/tests/Behat/Context/Cli/UpdatePaymentStateContext.php index b030afc0..84137afa 100644 --- a/tests/Behat/Context/Cli/UpdatePaymentStateContext.php +++ b/tests/Behat/Context/Cli/UpdatePaymentStateContext.php @@ -48,7 +48,7 @@ public function __construct( PayPlugApiMocker $payPlugApiMocker, PaymentFactoryInterface $paymentFactory, PaymentRepositoryInterface $paymentRepository, - SharedStorageInterface $sharedStorage + SharedStorageInterface $sharedStorage, ) { $this->kernel = $kernel; $this->payPlugApiMocker = $payPlugApiMocker; diff --git a/tests/Behat/Context/Setup/OrderContext.php b/tests/Behat/Context/Setup/OrderContext.php index d9e7caf2..7e96fe2b 100644 --- a/tests/Behat/Context/Setup/OrderContext.php +++ b/tests/Behat/Context/Setup/OrderContext.php @@ -27,7 +27,7 @@ final class OrderContext implements Context public function __construct( ObjectManager $objectManager, StateMachineFactoryInterface $stateMachineFactory, - RegistryInterface $payum + RegistryInterface $payum, ) { $this->objectManager = $objectManager; $this->stateMachineFactory = $stateMachineFactory; diff --git a/tests/Behat/Context/Setup/PayPlugContext.php b/tests/Behat/Context/Setup/PayPlugContext.php index e8560c93..493e38b6 100644 --- a/tests/Behat/Context/Setup/PayPlugContext.php +++ b/tests/Behat/Context/Setup/PayPlugContext.php @@ -36,7 +36,7 @@ public function __construct( PaymentMethodRepositoryInterface $paymentMethodRepository, ExampleFactoryInterface $paymentMethodExampleFactory, FactoryInterface $paymentMethodTranslationFactory, - ObjectManager $paymentMethodManager + ObjectManager $paymentMethodManager, ) { $this->sharedStorage = $sharedStorage; $this->paymentMethodRepository = $paymentMethodRepository; @@ -48,13 +48,15 @@ public function __construct( /** * @Given the store has a payment method :paymentMethodName with a code :paymentMethodCode and PayPlug payment gateway */ - public function theStoreHasAPaymentMethodWithACodeAndPayPlugPaymentGateway(string $paymentMethodName, string $paymentMethodCode): void - { + public function theStoreHasAPaymentMethodWithACodeAndPayPlugPaymentGateway( + string $paymentMethodName, + string $paymentMethodCode, + ): void { $paymentMethod = $this->createPaymentMethodPayPlug( $paymentMethodName, $paymentMethodCode, PayPlugGatewayFactory::FACTORY_NAME, - 'PayPlug' + 'PayPlug', ); $paymentMethod->getGatewayConfig()->setConfig([ @@ -68,13 +70,15 @@ public function theStoreHasAPaymentMethodWithACodeAndPayPlugPaymentGateway(strin /** * @Given the store has a payment method :paymentMethodName with a code :paymentMethodCode and Oney payment gateway */ - public function theStoreHasAPaymentMethodWithACodeAndOneyPaymentGateway(string $paymentMethodName, string $paymentMethodCode): void - { + public function theStoreHasAPaymentMethodWithACodeAndOneyPaymentGateway( + string $paymentMethodName, + string $paymentMethodCode, + ): void { $paymentMethod = $this->createPaymentMethodPayPlug( $paymentMethodName, $paymentMethodCode, OneyGatewayFactory::FACTORY_NAME, - 'Oney' + 'Oney', ); $paymentMethod->getGatewayConfig()->setConfig([ @@ -88,13 +92,15 @@ public function theStoreHasAPaymentMethodWithACodeAndOneyPaymentGateway(string $ /** * @Given the store has a payment method :paymentMethodName with a code :paymentMethodCode other than PayPlug payment gateway */ - public function theStoreHasAPaymentMethodWithACodeOtherThanPayplugPaymentGateway(string $paymentMethodName, string $paymentMethodCode): void - { + public function theStoreHasAPaymentMethodWithACodeOtherThanPayplugPaymentGateway( + string $paymentMethodName, + string $paymentMethodCode, + ): void { $this->createPaymentMethodPayPlug( $paymentMethodName, $paymentMethodCode, $paymentMethodCode, - '' + '', ); $this->paymentMethodManager->flush(); @@ -106,7 +112,7 @@ private function createPaymentMethodPayPlug( string $factoryName, string $description = '', bool $addForCurrentChannel = true, - int $position = null + int $position = null, ): PaymentMethodInterface { /** @var PaymentMethodInterface $paymentMethod */ $paymentMethod = $this->paymentMethodExampleFactory->create([ diff --git a/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodContext.php b/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodContext.php index 80da429f..0227c28f 100644 --- a/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodContext.php +++ b/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodContext.php @@ -37,7 +37,7 @@ public function iShouldBeNotifiedThatCannotBeBlank(string $fields): void foreach ($fields as $field) { Assert::true($this->createPage->containsErrorWithMessage(sprintf( 'The %s cannot be empty.', - strtolower(trim($field)) + strtolower(trim($field)), ))); } } diff --git a/tests/Behat/Context/Ui/Admin/RefundContext.php b/tests/Behat/Context/Ui/Admin/RefundContext.php index 2cd0c734..59e393cd 100644 --- a/tests/Behat/Context/Ui/Admin/RefundContext.php +++ b/tests/Behat/Context/Ui/Admin/RefundContext.php @@ -49,7 +49,7 @@ public function __construct( NotifyAction $notifyAction, NotificationCheckerInterface $notificationChecker, EntityManagerInterface $entityManager, - RefundHistoryRepositoryInterface $payplugRefundHistoryRepository + RefundHistoryRepositoryInterface $payplugRefundHistoryRepository, ) { $this->payPlugApiMocker = $payPlugApiMocker; $this->managingOrdersContext = $managingOrdersContext; @@ -77,7 +77,7 @@ public function decideToRefundProduct( OrderInterface $order, int $unitNumber, string $productName, - string $paymentMethod + string $paymentMethod, ): void { $this->payPlugApiMocker->mockApiRetrieveNotRefundablePayment(function () use ( $order, @@ -127,7 +127,7 @@ public function iShouldSeeAnErrorMessage(string $errorMessage) { $this->notificationChecker->checkNotification( $errorMessage, - NotificationType::failure() + NotificationType::failure(), ); } @@ -138,7 +138,7 @@ public function iShouldSeeASuccessMessage(string $successMessage) { $this->notificationChecker->checkNotification( $successMessage, - NotificationType::success() + NotificationType::success(), ); } @@ -149,7 +149,7 @@ public function decideToRefundProductAfter48Hours( OrderInterface $order, int $unitNumber, string $productName, - string $paymentMethod + string $paymentMethod, ): void { $this->payPlugApiMocker->mockApiRetrievePayment(function () use ( $order, diff --git a/tests/Behat/Context/Ui/Shop/CheckoutContext.php b/tests/Behat/Context/Ui/Shop/CheckoutContext.php index 20ea7e36..ae35eef1 100644 --- a/tests/Behat/Context/Ui/Shop/CheckoutContext.php +++ b/tests/Behat/Context/Ui/Shop/CheckoutContext.php @@ -31,7 +31,7 @@ public function __construct( CompletePageInterface $summaryPage, ShowPageInterface $orderDetails, PayPlugApiMocker $payPlugApiMocker, - PaymentPageInterface $paymentPage + PaymentPageInterface $paymentPage, ) { $this->summaryPage = $summaryPage; $this->orderDetails = $orderDetails; @@ -40,8 +40,8 @@ public function __construct( } /** - * @When I confirm my order with PayPlug payment * @Given I have confirmed my order with PayPlug payment + * @When I confirm my order with PayPlug payment */ public function iConfirmMyOrderWithPayPlugPayment(): void { @@ -81,8 +81,8 @@ public function iHaveFailedPayPlugPayment() } /** - * @When I cancel my PayPlug payment * @Given I have cancelled PayPlug payment + * @When I cancel my PayPlug payment */ public function iCancelMyPayPlugPayment(): void { @@ -102,8 +102,8 @@ public function iLeaveMyPayPlugPaymentPage(): void } /** - * @When PayPlug notified that the payment is expired * @Given I have left PayPlug payment page for more than 15 minutes + * @When PayPlug notified that the payment is expired */ public function PayPlugExpiredThePayment(): void { diff --git a/tests/Behat/Mocker/PayPlugApiMocker.php b/tests/Behat/Mocker/PayPlugApiMocker.php index 5911e536..f6e07ce5 100644 --- a/tests/Behat/Mocker/PayPlugApiMocker.php +++ b/tests/Behat/Mocker/PayPlugApiMocker.php @@ -8,48 +8,43 @@ use Payplug\Resource\Refund; use PayPlug\SyliusPayPlugPlugin\ApiClient\PayPlugApiClientInterface; use PayPlug\SyliusPayPlugPlugin\Gateway\PayPlugGatewayFactory; -use Sylius\Behat\Service\Mocker\MockerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; final class PayPlugApiMocker { - /** @var ContainerInterface */ - private $container; - - /** @var MockerInterface */ - private $mocker; - - public function __construct(MockerInterface $mocker, ContainerInterface $container) + public function __construct(private ContainerInterface $container) { - $this->mocker = $mocker; - $this->container = $container; } - public function getPayPlugApiClient() + public function getPayPlugApiClient(): PayPlugApiClient { - return new PayPlugApiClient($this->container, 'payplug_sylius_payplug_plugin.api_client.payplug'); + return new PayPlugApiClient( + $this->container, + 'payplug_sylius_payplug_plugin.api_client.payplug', + ); } public function mockApiRefundedPayment(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); - $mock - ->shouldReceive('initialise') - ; + $mock = \Mockery::mock( + 'payplug_sylius_payplug_plugin.api_client.payplug', + PayPlugApiClientInterface::class, + ); + $mock->shouldReceive('initialise'); $mock ->shouldReceive('refundPayment') ->andReturn(\Mockery::mock('refund', Refund::class)) ; $action(); - $this->mocker->unmockAll(); } public function mockApiRefundedWithAmountPayment(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); - $mock - ->shouldReceive('initialise') - ; + $mock = \Mockery::mock( + 'payplug_sylius_payplug_plugin.api_client.payplug', + PayPlugApiClientInterface::class, + ); + $mock->shouldReceive('initialise'); $payment = \Mockery::mock('payment', Payment::class); $payment->id = 'pay_1'; $payment->is_paid = true; @@ -70,15 +65,15 @@ public function mockApiRefundedWithAmountPayment(callable $action): void ->andReturn($refund) ; $action(); - $this->mocker->unmockAll(); } public function mockApiCreatePayment(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); - $mock - ->shouldReceive('initialise') - ; + $mock = \Mockery::mock( + 'payplug_sylius_payplug_plugin.api_client.payplug', + PayPlugApiClientInterface::class, + ); + $mock->shouldReceive('initialise'); $payment = \Mockery::mock('payment', Payment::class); $payment->id = 'pay_1'; $payment->is_live = false; @@ -90,16 +85,15 @@ public function mockApiCreatePayment(callable $action): void ->andReturn($payment) ; $action(); - $this->mocker->unmockAll(); } public function mockApiSuccessfulPayment(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); - $mock - ->shouldReceive('initialise') - ->shouldReceive('createPayment') - ; + $mock = \Mockery::mock( + 'payplug_sylius_payplug_plugin.api_client.payplug', + PayPlugApiClientInterface::class, + ); + $mock->shouldReceive('initialise', 'createPayment'); $payment = \Mockery::mock('payment', Payment::class); $payment->id = 'pay_1'; $payment->is_paid = true; @@ -113,14 +107,13 @@ public function mockApiSuccessfulPayment(callable $action): void ->andReturn($payment) ; $action(); - $this->mocker->unmockAll(); } public function mockApiRetrievePayment(callable $action): void { - $mock = $this->mocker->mockService( + $mock = \Mockery::mock( 'payplug_sylius_payplug_plugin.api_client.oney', - PayPlugApiClientInterface::class + PayPlugApiClientInterface::class, ); $payment = \Mockery::mock('payment', Payment::class); $payment->refundable_until = (new \DateTime())->add(new \DateInterval('P2D'))->getTimestamp(); @@ -130,14 +123,13 @@ public function mockApiRetrievePayment(callable $action): void ->andReturn($payment) ; $action(); - $this->mocker->unmockAll(); } public function mockApiRetrieveNotRefundablePayment(callable $action): void { - $mock = $this->mocker->mockService( + $mock = \Mockery::mock( 'payplug_sylius_payplug_plugin.api_client.oney', - PayPlugApiClientInterface::class + PayPlugApiClientInterface::class, ); $payment = \Mockery::mock('payment', Payment::class); $payment->refundable_until = (new \DateTime())->add(new \DateInterval('P2D'))->getTimestamp(); @@ -147,15 +139,15 @@ public function mockApiRetrieveNotRefundablePayment(callable $action): void ->andReturn($payment) ; $action(); - $this->mocker->unmockAll(); } public function mockApiFailedPayment(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); - $mock - ->shouldReceive('initialise') - ; + $mock = \Mockery::mock( + 'payplug_sylius_payplug_plugin.api_client.payplug', + PayPlugApiClientInterface::class, + ); + $mock->shouldReceive('initialise'); $payment = \Mockery::mock('payment', Payment::class); $payment->id = 'pay_1'; $payment->is_paid = false; @@ -164,19 +156,21 @@ public function mockApiFailedPayment(callable $action): void ->andReturn($payment) ; $action(); - $this->mocker->unmockAll(); } public function mockApiExpiredPayment(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); - $mock - ->shouldReceive('initialise') - ; + $mock = \Mockery::mock( + 'payplug_sylius_payplug_plugin.api_client.payplug', + PayPlugApiClientInterface::class, + ); + $mock->shouldReceive('initialise'); + $payment = \Mockery::mock('payment', Payment::class); $payment->id = 'pay_1'; $payment->status = 'failure'; $payment->is_paid = false; + $failure = new \stdClass(); $failure->code = 'timeout'; $failure->message = 'The customer has not tried to pay and left the payment page.'; @@ -186,15 +180,16 @@ public function mockApiExpiredPayment(callable $action): void ->andReturn($payment) ; $action(); - $this->mocker->unmockAll(); } public function mockApiCreatedPayment(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); - $mock - ->shouldReceive('initialise') - ; + $mock = \Mockery::mock( + 'payplug_sylius_payplug_plugin.api_client.payplug', + PayPlugApiClientInterface::class, + ); + $mock->shouldReceive('initialise'); + $payment = \Mockery::mock('payment', Payment::class); $payment->id = 'pay_1'; $payment->status = 'created'; @@ -204,21 +199,20 @@ public function mockApiCreatedPayment(callable $action): void ->andReturn($payment) ; $action(); - $this->mocker->unmockAll(); } public function mockApiCancelledPayment(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); - $mock - ->shouldReceive('initialise') - ; + $mock = \Mockery::mock( + 'payplug_sylius_payplug_plugin.api_client.payplug', + PayPlugApiClientInterface::class, + ); + $mock->shouldReceive('initialise'); $payment = \Mockery::mock('payment', Payment::class); $payment->id = 'pay_1'; $payment->state = 'abort'; $payment->is_paid = false; - $mock ->shouldReceive('abortPayment')->once() ->withArgs(['pay_1']) @@ -226,21 +220,20 @@ public function mockApiCancelledPayment(callable $action): void ; $action(); - $this->mocker->unmockAll(); } public function mockMultipleApiCancelledPayment(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); - $mock - ->shouldReceive('initialise') - ; + $mock = \Mockery::mock( + 'payplug_sylius_payplug_plugin.api_client.payplug', + PayPlugApiClientInterface::class, + ); + $mock->shouldReceive('initialise'); $payment = \Mockery::mock('payment', Payment::class); $payment->id = 'pay_1'; $payment->state = 'abort'; $payment->is_paid = false; - $mock ->shouldReceive('abortPayment') ->withArgs(['pay_1']) @@ -248,37 +241,38 @@ public function mockMultipleApiCancelledPayment(callable $action): void ; $action(); - $this->mocker->unmockAll(); } public function mockApiStatePayment(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); + $mock = \Mockery::mock( + 'payplug_sylius_payplug_plugin.api_client.payplug', + PayPlugApiClientInterface::class, + ); $mock->shouldReceive('initialise'); $payment = \Mockery::mock('payment', Payment::class); $payment->state = 'failed'; $payment->is_paid = false; $payment->failure = true; $mock - ->shouldReceive('retrieve')//->withArgs(['paymentId' => '123456']) + ->shouldReceive('retrieve') ->andReturn($payment) ; $action(); - $this->mocker->unmockAll(); } public function refundPaymentWithAmount(callable $action): void { $action(); - $this->mocker->unmockAll(); } public function mockApiRefundedFromPayPlugPortal(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); - $mock - ->shouldReceive('initialise') - ; + $mock = \Mockery::mock( + 'payplug_sylius_payplug_plugin.api_client.payplug', + PayPlugApiClientInterface::class, + ); + $mock->shouldReceive('initialise'); $refund = \Mockery::mock('refund', Refund::class); $refund->amount = 34000; $refund->currency = 'EUR'; @@ -290,12 +284,11 @@ public function mockApiRefundedFromPayPlugPortal(callable $action): void ->andReturn($refund) ; $action(); - $this->mocker->unmockAll(); } public function mockApiRefundPartiallyFromPayPlugPortal(callable $action, int $amount): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); + $mock = \Mockery::mock('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); $mock ->shouldReceive('initialise') ; @@ -310,12 +303,11 @@ public function mockApiRefundPartiallyFromPayPlugPortal(callable $action, int $a ->andReturn($refund) ; $action(); - $this->mocker->unmockAll(); } public function mockPayPlugApiGetGatewayFactoryName(callable $action): void { - $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); + $mock = \Mockery::mock('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); $mock ->shouldReceive([ 'getGatewayFactoryName' => PayPlugGatewayFactory::FACTORY_NAME, @@ -323,15 +315,14 @@ public function mockPayPlugApiGetGatewayFactoryName(callable $action): void ; $action(); - $this->mocker->unmockAll(); } public function enableOney(): void { $this->mocker->unmockAll(); - $mock = $this->mocker->mockService( + $mock = \Mockery::mock( 'payplug_sylius_payplug_plugin.api_client.oney', - PayPlugApiClientInterface::class + PayPlugApiClientInterface::class, ); $mock->shouldReceive([ 'getPermissions' => ['can_use_oney' => true], @@ -357,10 +348,9 @@ public function enableOney(): void public function disableOney(): void { - $this->mocker->unmockAll(); - $mock = $this->mocker->mockService( + $mock = \Mockery::mock( 'payplug_sylius_payplug_plugin.api_client.oney', - PayPlugApiClientInterface::class + PayPlugApiClientInterface::class, ); $mock->shouldReceive([ 'getPermissions' => ['can_use_oney' => false], diff --git a/tests/Behat/Page/Shop/Payum/PaymentPage.php b/tests/Behat/Page/Shop/Payum/PaymentPage.php index 44638591..b2b63b21 100644 --- a/tests/Behat/Page/Shop/Payum/PaymentPage.php +++ b/tests/Behat/Page/Shop/Payum/PaymentPage.php @@ -22,7 +22,7 @@ public function __construct( Session $session, $parameters, RepositoryInterface $securityTokenRepository, - KernelBrowser $client + KernelBrowser $client, ) { parent::__construct($session, $parameters); @@ -37,7 +37,7 @@ public function capture(array $parameters = []): void $url = $captureToken->getTargetUrl(); if (count($parameters) > 0) { - $url .= '?'.http_build_query($parameters); + $url .= '?' . http_build_query($parameters); } $this->getDriver()->visit($url); diff --git a/tests/Behat/Resources/services.xml b/tests/Behat/Resources/services.xml index 17aaf2a8..561a4c21 100644 --- a/tests/Behat/Resources/services.xml +++ b/tests/Behat/Resources/services.xml @@ -18,7 +18,7 @@ - + diff --git a/tests/Behat/Resources/services/contexts/setup.xml b/tests/Behat/Resources/services/contexts/setup.xml index d135a3d3..91d432e6 100644 --- a/tests/Behat/Resources/services/contexts/setup.xml +++ b/tests/Behat/Resources/services/contexts/setup.xml @@ -13,11 +13,11 @@ - - - - - - + + + + + + diff --git a/tests/Behat/Resources/services/contexts/ui.xml b/tests/Behat/Resources/services/contexts/ui.xml index 654fc942..bba842a6 100644 --- a/tests/Behat/Resources/services/contexts/ui.xml +++ b/tests/Behat/Resources/services/contexts/ui.xml @@ -9,7 +9,7 @@ - + diff --git a/tests/Behat/Resources/suites/ui/paying_with_payplug_for_order.yml b/tests/Behat/Resources/suites/ui/paying_with_payplug_for_order.yml index 8f06e1fb..659d5003 100644 --- a/tests/Behat/Resources/suites/ui/paying_with_payplug_for_order.yml +++ b/tests/Behat/Resources/suites/ui/paying_with_payplug_for_order.yml @@ -31,7 +31,7 @@ default: - payplug_sylius_payplug_plugin.behat.context.setup.payplug - - sylius.behat.context.ui.paypal +# - sylius.behat.context.ui.paypal - sylius.behat.context.ui.shop.cart - sylius.behat.context.ui.shop.checkout - sylius.behat.context.ui.shop.checkout.addressing diff --git a/tests/Behat/Resources/suites/ui/refunding_payplug_payment.yml b/tests/Behat/Resources/suites/ui/refunding_payplug_payment.yml index b282c649..decb7841 100644 --- a/tests/Behat/Resources/suites/ui/refunding_payplug_payment.yml +++ b/tests/Behat/Resources/suites/ui/refunding_payplug_payment.yml @@ -23,7 +23,7 @@ default: - sylius.behat.context.setup.user - payplug_sylius_payplug_plugin.behat.context.setup.payplug - - payplug_sylius_payplug_plugin.behat.context.setup.order +# - payplug_sylius_payplug_plugin.behat.context.setup.order - sylius.behat.context.transform.address - sylius.behat.context.transform.channel diff --git a/tests/TestApplication/.env b/tests/TestApplication/.env new file mode 100644 index 00000000..8b9cf095 --- /dev/null +++ b/tests/TestApplication/.env @@ -0,0 +1,7 @@ +DATABASE_URL=mysql://root@127.0.0.1/test_application_%kernel.environment% + +SYLIUS_TEST_APP_CONFIGS_TO_IMPORT="@PayPlugSyliusPayPlugPlugin/tests/TestApplication/config/config.yaml" +SYLIUS_TEST_APP_ROUTES_TO_IMPORT="@PayPlugSyliusPayPlugPlugin/tests/TestApplication/config/routing.yaml" +SYLIUS_TEST_APP_BUNDLES_PATH="tests/TestApplication/config/bundles.php" + +SYLIUS_MESSENGER_TRANSPORT_PAYMENT_REQUEST_DSN="sync://" diff --git a/tests/TestApplication/config/bundles.php b/tests/TestApplication/config/bundles.php new file mode 100644 index 00000000..48514e52 --- /dev/null +++ b/tests/TestApplication/config/bundles.php @@ -0,0 +1,8 @@ + ['all' => true], + Knp\Bundle\SnappyBundle\KnpSnappyBundle::class => ['all' => true], + Sylius\RefundPlugin\SyliusRefundPlugin::class => ['all' => true], + PayPlug\SyliusPayPlugPlugin\PayPlugSyliusPayPlugPlugin::class => ['all' => true], +]; diff --git a/tests/TestApplication/config/config.yaml b/tests/TestApplication/config/config.yaml new file mode 100644 index 00000000..1acc0396 --- /dev/null +++ b/tests/TestApplication/config/config.yaml @@ -0,0 +1,87 @@ +imports: + - { resource: "@SyliusRefundPlugin/config/config.yaml" } + - { resource: "@PayPlugSyliusPayPlugPlugin/config/config.yml" } + +parameters: + locale: fr_FR + currency: EUR + sylius_refund.supported_gateways: + - payplug + - payplug_oney + - cash_on_delivery + +sylius_refund: + pdf_generator: + enabled: false + +doctrine: + orm: + entity_managers: + default: + mappings: + TestApplication: + is_bundle: false + type: attribute + dir: '%kernel.project_dir%/../../../tests/TestApplication/src/Entity' + prefix: Tests\PayPlug\SyliusPayPlugPlugin +sylius_customer: + resources: + customer: + classes: + model: Tests\PayPlug\SyliusPayPlugPlugin\Entity\Customer +sylius_payment: + resources: + payment_method: + classes: + model: Tests\PayPlug\SyliusPayPlugPlugin\Entity\PaymentMethod + payment: + classes: + model: Tests\PayPlug\SyliusPayPlugPlugin\Entity\Payment +sylius_fixtures: + suites: + default: + fixtures: + geographical: + options: + countries: + - 'US' + - 'FR' + - 'DE' + - 'AU' + - 'CA' + - 'MX' + - 'NZ' + - 'PT' + - 'ES' + - 'CN' + - 'GB' + - 'PL' + zones: + FR: + name: 'France' + countries: + - 'FR' + + channel: + options: + custom: + fashion_web_store: + name: 'Fashion Web Store' + code: 'FASHION_WEB' + locales: + - '%locale%' + currencies: + - 'EUR' + enabled: true + hostname: '%env(resolve:SYLIUS_FIXTURES_HOSTNAME)%' + theme_name: '%env(resolve:SYLIUS_FIXTURES_THEME_NAME)%' + shop_billing_data: + company: 'Sylius' + tax_id: '0001112222' + country_code: 'FR' + street: 'Test St. 15' + city: 'eCommerce Town' + postcode: '00 33 22' + menu_taxon: 'MENU_CATEGORY' + contact_phone_number: '+41 123 456 789' + contact_email: 'contact@example.com' diff --git a/tests/TestApplication/config/routing.yaml b/tests/TestApplication/config/routing.yaml new file mode 100644 index 00000000..54af5a42 --- /dev/null +++ b/tests/TestApplication/config/routing.yaml @@ -0,0 +1,5 @@ +sylius_refund: + resource: "@SyliusRefundPlugin/config/routes.yaml" + +sylius_payplug: + resource: "@PayPlugSyliusPayPlugPlugin/config/routing.yaml" diff --git a/tests/TestApplication/package.json b/tests/TestApplication/package.json new file mode 100644 index 00000000..0280f00d --- /dev/null +++ b/tests/TestApplication/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@payplug/sylius-payplug-plugin": "file:../../../assets" + } +} diff --git a/install/Application/src/Entity/Customer/Customer.php b/tests/TestApplication/src/Entity/Customer.php similarity index 53% rename from install/Application/src/Entity/Customer/Customer.php rename to tests/TestApplication/src/Entity/Customer.php index 6dfffb49..05196860 100644 --- a/install/Application/src/Entity/Customer/Customer.php +++ b/tests/TestApplication/src/Entity/Customer.php @@ -2,26 +2,15 @@ declare(strict_types=1); -namespace App\Entity\Customer; +namespace Tests\PayPlug\SyliusPayPlugPlugin\Entity; -use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use PayPlug\SyliusPayPlugPlugin\Entity\Traits\CustomerTrait; use Sylius\Component\Core\Model\Customer as BaseCustomer; -/** - * @ORM\Entity - * @ORM\Table(name="sylius_customer") - */ #[ORM\Entity] #[ORM\Table(name: 'sylius_customer')] class Customer extends BaseCustomer { use CustomerTrait; - - public function __construct() - { - parent::__construct(); - $this->cards = new ArrayCollection(); - } } diff --git a/install/Application/src/Entity/Payment/Payment.php b/tests/TestApplication/src/Entity/Payment.php similarity index 84% rename from install/Application/src/Entity/Payment/Payment.php rename to tests/TestApplication/src/Entity/Payment.php index 7a13282a..0fc1e5c7 100644 --- a/install/Application/src/Entity/Payment/Payment.php +++ b/tests/TestApplication/src/Entity/Payment.php @@ -2,17 +2,13 @@ declare(strict_types=1); -namespace App\Entity\Payment; +namespace Tests\PayPlug\SyliusPayPlugPlugin\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use PayPlug\SyliusPayPlugPlugin\Entity\Traits\PaymentTrait; use Sylius\Component\Core\Model\Payment as BasePayment; -/** - * @ORM\Entity - * @ORM\Table(name="sylius_payment") - */ #[ORM\Entity] #[ORM\Table(name: 'sylius_payment')] class Payment extends BasePayment diff --git a/install/Application/src/Entity/Payment/PaymentMethod.php b/tests/TestApplication/src/Entity/PaymentMethod.php similarity index 86% rename from install/Application/src/Entity/Payment/PaymentMethod.php rename to tests/TestApplication/src/Entity/PaymentMethod.php index 70cba7d2..7dad0a1c 100644 --- a/install/Application/src/Entity/Payment/PaymentMethod.php +++ b/tests/TestApplication/src/Entity/PaymentMethod.php @@ -2,18 +2,15 @@ declare(strict_types=1); -namespace App\Entity\Payment; +namespace Tests\PayPlug\SyliusPayPlugPlugin\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use PayPlug\SyliusPayPlugPlugin\Entity\Traits\PaymentMethodTrait; use Sylius\Component\Core\Model\PaymentMethod as BasePaymentMethod; use Sylius\Component\Payment\Model\PaymentMethodTranslationInterface; +use Sylius\Component\Payment\Model\PaymentMethodTranslation; -/** - * @ORM\Entity - * @ORM\Table(name="sylius_payment_method") - */ #[ORM\Entity] #[ORM\Table(name: 'sylius_payment_method')] class PaymentMethod extends BasePaymentMethod diff --git a/src/Resources/translations/flashes.en.yml b/translations/flashes.en.yml similarity index 57% rename from src/Resources/translations/flashes.en.yml rename to translations/flashes.en.yml index 68820d60..1faaa11a 100644 --- a/src/Resources/translations/flashes.en.yml +++ b/translations/flashes.en.yml @@ -5,3 +5,7 @@ payplug_sylius_payplug_plugin: transaction_failed_1click: The transaction was not completed and your card was not charged. warning: payment_success_no_card_saved: The payment was successful but we were unable to save your credit card details. + admin: + oauth_callback_success: The OAuth connection was established successfully. + payment_method_disabled: ⚠️ The payment method has been disabled because some validation criteria are not met. + oauth_setup_error: An error occurred while setting up the OAuth connection. Please try again. diff --git a/src/Resources/translations/flashes.fr.yml b/translations/flashes.fr.yml similarity index 57% rename from src/Resources/translations/flashes.fr.yml rename to translations/flashes.fr.yml index 6449312e..b05b5110 100644 --- a/src/Resources/translations/flashes.fr.yml +++ b/translations/flashes.fr.yml @@ -5,3 +5,7 @@ payplug_sylius_payplug_plugin: transaction_failed_1click: La transaction a échoué, votre carte de paiement ne sera pas débitée. warning: payment_success_no_card_saved: Le paiement a été effectué avec succès, mais nous n'avons pas pu enregistrer votre carte bancaire. + admin: + oauth_callback_success: La connexion OAuth a été établie avec succès. + payment_method_disabled: ⚠️ La méthode de paiement a été désactivée car certains critères de validation ne sont pas remplis. + oauth_setup_error: Une erreur s'est produite lors de la configuration de la connexion OAuth. Veuillez réessayer. diff --git a/src/Resources/translations/flashes.it.yml b/translations/flashes.it.yml similarity index 57% rename from src/Resources/translations/flashes.it.yml rename to translations/flashes.it.yml index 7a9ac5db..10cd5113 100644 --- a/src/Resources/translations/flashes.it.yml +++ b/translations/flashes.it.yml @@ -5,3 +5,7 @@ payplug_sylius_payplug_plugin: transaction_failed_1click: La transazione non è stata conclusa e non è stato effettuato alcun addebito sulla tua carta. warning: payment_success_no_card_saved: Il pagamento è andato a buon fine ma non è stato possibile salvare la tua carta di credito. + admin: + oauth_callback_success: La connessione OAuth è stata stabilita con successo. + payment_method_disabled: ⚠️ Il metodo di pagamento è stato disattivato perché alcuni criteri di validazione non sono soddisfatti. + oauth_setup_error: Si è verificato un errore durante la configurazione della connessione OAuth. Per favore riprova. diff --git a/src/Resources/translations/messages.en.yml b/translations/messages.en.yml similarity index 93% rename from src/Resources/translations/messages.en.yml rename to translations/messages.en.yml index 44ca681b..53f4ec16 100644 --- a/src/Resources/translations/messages.en.yml +++ b/translations/messages.en.yml @@ -29,10 +29,8 @@ payplug_sylius_payplug_plugin: error: billing.postcode: The postal code %postalCode% entered for the billing address is invalid shipping.postcode: The postal code %postalCode% entered for the delivery address is invalid - secret_key: Secret key payplug_gateway_label: Payplug payment_refund_locally: The payment refund was made locally only. - retrieve_secret_key_in_api_configuration_portal: Find your LIVE and TEST Secret Keys in your Payplug portal test_mode: TEST Mode payplug_id: | Payplug ID: %paymentId% @@ -109,6 +107,13 @@ payplug_sylius_payplug_plugin: deferred_capture: process_order_info: | You will be charged when your order is processed. + live: LIVE Mode + live_help: | + When this option is enabled, LIVE mode is used.
+ If disabled, TEST mode will be applied + renew_oauth: Force OAuth reconnection + renew_oauth_help: | + If this option is checked, a new authentication flow will be started when clicking the "Update" button. form: oney_error: Some missing information is required to pay using Oney by Payplug complete_info: @@ -123,7 +128,7 @@ payplug_sylius_payplug_plugin: base_currency_not_euro: | Channel #channel_code#: #payment_method# is only available on channels with EURO as a currency only_one_gateway_allowed: | - Please note that the %gateway_title% payment method has already been set. To change it, go to your payment methods. + Please note that the %gateway_title% payment method has already been set. To change it, go to your payment methods. one_click_enable: Enable One click one_click_help: | Allow your customers to save their credit card details for later diff --git a/src/Resources/translations/messages.fr.yml b/translations/messages.fr.yml similarity index 94% rename from src/Resources/translations/messages.fr.yml rename to translations/messages.fr.yml index ee8e9289..c024c679 100644 --- a/src/Resources/translations/messages.fr.yml +++ b/translations/messages.fr.yml @@ -29,10 +29,8 @@ payplug_sylius_payplug_plugin: error: billing.postcode: Le code postal %postalCode% renseigné pour l'adresse de facturation est invalide shipping.postcode: Le code postal %postalCode% renseigné pour l'adresse de livraison est invalide - secret_key: Clé secrète payplug_gateway_label: Payplug payment_refund_locally: Le remboursement du paiement a été effectué uniquement localement. - retrieve_secret_key_in_api_configuration_portal: Retrouvez vos Secret Key LIVE et TEST dans votre portail Payplug test_mode: Mode TEST payplug_id: | ID Payplug : %paymentId% @@ -129,6 +127,13 @@ payplug_sylius_payplug_plugin: process_order_info: | Vous serez prélevé(é) lors du traitement de votre commande. + live: Mode LIVE + live_help: | + Lorsque cette option est activée, le mode LIVE est utilisé.
+ Si elle est désactivée, le mode TEST sera appliqué + renew_oauth: Forcer la reconnexion OAuth + renew_oauth_help: | + Si cette option est cochée, un nouveau flux d’authentification sera lancé lors du clic sur le bouton "Mise à jour". form: oney_error: Il y a des informations manquantes pour pouvoir payer en utilisant Oney by Payplug complete_info: @@ -143,7 +148,7 @@ payplug_sylius_payplug_plugin: base_currency_not_euro: | Canal #channel_code# : #payment_method# n’est disponible que sur des canaux dont la devise est l’EURO only_one_gateway_allowed: | - Attention, le moyen de paiement %gateway_title% existe déjà. Pour le modifier, rendez-vous sur vos moyens de paiement. + Attention, le moyen de paiement %gateway_title% existe déjà. Pour le modifier, rendez-vous sur vos moyens de paiement. one_click_enable: Activer le One click one_click_help: | Permettez à vos clients d'enregistrer leurs coordonnées de carte de paiement pour effectuer ultérieurement diff --git a/src/Resources/translations/messages.it.yml b/translations/messages.it.yml similarity index 93% rename from src/Resources/translations/messages.it.yml rename to translations/messages.it.yml index f8c23bcb..b703af6a 100644 --- a/src/Resources/translations/messages.it.yml +++ b/translations/messages.it.yml @@ -29,10 +29,8 @@ payplug_sylius_payplug_plugin: error: billing.postcode: Il codice postale %postalCode% inserito per l’indirizzo di fatturazione non è valido shipping.postcode: Il codice postale %postalCode% inserito per l’indirizzo di consegna non è valido - secret_key: ID segreto payplug_gateway_label: Payplug payment_refund_locally: Il rimborso del pagamento è stato effettuato solo a livello locale (interno). - retrieve_secret_key_in_api_configuration_portal: Trova il tuo ID segreto LIVE e TEST nel tuo portale Payplug test_mode: Modalità TEST payplug_id: | ID Payplug : %paymentId% @@ -109,6 +107,13 @@ payplug_sylius_payplug_plugin: deferred_capture: process_order_info: | L'addebito avverrà al momento dell'elaborazione dell'ordine. + live: Modalità LIVE + live_help: | + Quando questa opzione è attivata, viene utilizzata la modalità LIVE.
+ Se disattivata, verrà applicata la modalità TEST + renew_oauth: Forza la riconnessione OAuth + renew_oauth_help: | + Se questa opzione è selezionata, un nuovo flusso di autenticazione verrà avviato quando si fa clic sul pulsante "Aggiorna". form: oney_error: Mancano alcune informazioni per poter pagare con “Oney by Payplug” complete_info: @@ -123,7 +128,7 @@ payplug_sylius_payplug_plugin: base_currency_not_euro: | Il canale #channel_code# : #payment_method# è disponibile solo per i canali la cui valuta è in EURO only_one_gateway_allowed: | - Attenzione: il metodo di pagamento %gateway_title% è già definito. Per modificarlo, vai ai tuoi metodi di pagamento. + Attenzione: il metodo di pagamento %gateway_title% è già definito. Per modificarlo, vai ai tuoi metodi di pagamento. one_click_enable: Attiva un clic one_click_help: | Consenti ai tuoi clienti di salvare i dettagli della loro carta di credito per dopo diff --git a/src/Resources/translations/validators.en.yml b/translations/validators.en.yml similarity index 77% rename from src/Resources/translations/validators.en.yml rename to translations/validators.en.yml index 78facf6b..8ca73234 100644 --- a/src/Resources/translations/validators.en.yml +++ b/translations/validators.en.yml @@ -16,28 +16,30 @@ payplug_sylius_payplug_plugin: can_not_save_cards: | You do not have access to this feature. For more information, please contact us at: support@payplug.com - bancontact: + payplug_bancontact: can_not_save_method_with_test_key: | - The Bancontact payment method is not available for the TEST mode. - Please activate the LIVE mode by adding the corresponding secret key. + The Bancontact payment method is not available for the TEST mode. + Please activate the LIVE mode. can_not_save_method_no_access: | - You don't have access to this feature yet. - To activate Bancontact, please fill in - this form + You don't have access to this feature yet. + To activate Bancontact, please fill in + this form and activate the LIVE mode. - apple_pay: + payplug_apple_pay: can_not_save_method_with_test_key: | The Apple Pay payment method is not available for the TEST mode. + Please activate the LIVE mode. can_not_save_method_no_access: | - You don't have access to this feature yet. - To activate Apple Pay, please fill in + You don't have access to this feature yet. + To activate Apple Pay, please fill in this form and activate the LIVE mode. - american_express: + payplug_american_express: can_not_save_method_with_test_key: | The American Express payment method is not available for the TEST mode. + Please activate the LIVE mode. can_not_save_method_no_access: | - You don't have access to this feature yet. - To activate American Express, please fill in + You don't have access to this feature yet. + To activate American Express, please fill in this form and activate the LIVE mode. diff --git a/src/Resources/translations/validators.fr.yml b/translations/validators.fr.yml similarity index 75% rename from src/Resources/translations/validators.fr.yml rename to translations/validators.fr.yml index e2ab2a5c..4da2b61b 100644 --- a/src/Resources/translations/validators.fr.yml +++ b/translations/validators.fr.yml @@ -15,28 +15,30 @@ payplug_sylius_payplug_plugin: can_not_save_cards: | Vous n'avez pas accès à cette fonctionnalité. Pour plus d'informations, veuillez nous contacter à : support@payplug.com - bancontact: - can_not_save_method_with_test_key: | - Le paiement par Bancontact n’est pas disponible en mode TEST. - Veuillez activer le mode LIVE en saisissant la clé secrète correspondante. + payplug_bancontact: + can_not_save_method_with_test_key: | + Le paiement par Bancontact n’est pas disponible en mode TEST. + Veuillez activer le mode LIVE. can_not_save_method_no_access: | - Vous n'avez pas accès à cette fonctionnalité. - Pour activer Bancontact, rendez-vous sur - ce formulaire + Vous n'avez pas accès à cette fonctionnalité. + Pour activer Bancontact, rendez-vous sur + ce formulaire et activez le mode LIVE. - apple_pay: + payplug_apple_pay: can_not_save_method_with_test_key: | Le paiement par Apple Pay n’est pas disponible en mode TEST. + Veuillez activer le mode LIVE. can_not_save_method_no_access: | - Vous n'avez pas accès à cette fonctionnalité. - Pour activer Apple Pay, rendez-vous sur + Vous n'avez pas accès à cette fonctionnalité. + Pour activer Apple Pay, rendez-vous sur ce formulaire et activez le mode LIVE. - american_express: + payplug_american_express: can_not_save_method_with_test_key: | Le paiement par American Express n’est pas disponible en mode TEST. + Veuillez activer le mode LIVE. can_not_save_method_no_access: | - Vous n'avez pas accès à cette fonctionnalité. - Pour activer American Express, rendez-vous sur + Vous n'avez pas accès à cette fonctionnalité. + Pour activer American Express, rendez-vous sur ce formulaire et activez le mode LIVE. diff --git a/src/Resources/translations/validators.it.yml b/translations/validators.it.yml similarity index 79% rename from src/Resources/translations/validators.it.yml rename to translations/validators.it.yml index 1abcd3f6..fdd6fe52 100644 --- a/src/Resources/translations/validators.it.yml +++ b/translations/validators.it.yml @@ -15,28 +15,30 @@ payplug_sylius_payplug_plugin: can_not_save_cards: | Non hai accesso a questa funzionalità. Per ulteriori informazioni, contattaci al seguente indirizzo e-mail: support@payplug.com - bancontact: + payplug_bancontact: can_not_save_method_with_test_key: | - Il metodo di pagamento Bancontact non è disponibile in modalità TEST. - Attiva la modalità LIVE utilizzando la chiave segreta corrispondente. + Il metodo di pagamento Bancontact non è disponibile in modalità TEST. + Attiva la modalità LIVE. can_not_save_method_no_access: | - Non puoi ancora accedere a questa funzionalità. - Per attivare Bancontact, compila - questo modulo + Non puoi ancora accedere a questa funzionalità. + Per attivare Bancontact, compila + questo modulo e attiva la modalità LIVE. - apple_pay: + payplug_american_express: can_not_save_method_with_test_key: | Il pagamento Apple Pay non è disponibile in modalità TEST. + Attiva la modalità LIVE. can_not_save_method_no_access: | - Non puoi ancora accedere a questa funzionalità. - Per attivare Apple Pay, compila + Non puoi ancora accedere a questa funzionalità. + Per attivare Apple Pay, compila questo modulo e attiva la modalità LIVE. american_express: can_not_save_method_with_test_key: | Il pagamento American Express non è disponibile in modalità TEST. + Attiva la modalità LIVE. can_not_save_method_no_access: | - Non puoi ancora accedere a questa funzionalità. - Per attivare American Express, compila + Non puoi ancora accedere a questa funzionalità. + Per attivare American Express, compila questo modulo e attiva la modalità LIVE.