From 043751e93df088f524acb41b9f5176ba42fc51e0 Mon Sep 17 00:00:00 2001 From: Leandra Masi <70567200+LeandraMasi@users.noreply.github.com> Date: Thu, 18 Sep 2025 17:17:52 +0200 Subject: [PATCH] RATESWSX-332: upgrade plugin to be compatible with SW 6.7.x.x --- .github/workflows/php.yml | 14 +- .gitignore | 2 +- CHANGELOG.md | 7 + README.md | 16 +- composer.json | 11 +- .../AdminOrders/Service/DfpService.php | 6 +- .../AdminOrders/Service/SessionService.php | 7 +- .../Subscriber/LoginSubscriber.php | 2 +- .../Controller/AbstractCheckoutController.php | 2 +- .../Controller/CheckoutController.php | 2 +- .../Event/RatepayPaymentFilterEvent.php | 2 +- .../Service/DataValidationService.php | 2 +- .../Checkout/Service/ExtensionService.php | 18 +- .../Checkout/Service/PaymentFilterService.php | 4 +- .../Checkout/Struct/PaymentDataResponse.php | 3 + .../DeviceFingerprint/DfpService.php | 8 +- .../DeviceFingerprint/DfpServiceInterface.php | 4 +- .../DependencyInjection/controller.xml | 3 - .../InstallmentCalculationException.php | 2 +- .../Struct/InstallmentCalculationResponse.php | 8 +- .../Controller/ProductPanel.php | 2 + .../PaymentHandler/AbstractPaymentHandler.php | 64 ++++-- .../Constraint/AbstractNotBlank.php | 2 +- .../PaymentHandler/DebitPaymentHandler.php | 2 +- .../DependencyInjection/services.xml | 2 +- .../Event/AbstractPaymentEvent.php | 6 +- .../Event/PaymentFailedEvent.php | 6 +- .../InstallmentPaymentHandler.php | 2 +- .../PaymentHandler/LegacyPaymentHandler.php | 10 +- .../RatepayApi/Factory/PaymentFactory.php | 3 +- .../Exception/ForwardException.php | 2 +- .../Exception/RedirectException.php | 2 +- .../PaymentSuccessfulSubscriber.php | 4 +- src/Core/Entity/Extension/OrderExtension.php | 7 +- .../Extension/OrderLineItemExtension.php | 7 +- src/Core/Entity/RatepayOrderDataEntity.php | 2 +- .../OrderRouteRequestSubscriber.php | 32 +++ .../administration/build/webpack.config.js | 11 - .../ratepay-admin-create-order-form/index.js | 29 +-- .../ratepay-admin-create-order-form.twig | 46 ++-- .../ratepay-order-details.html.twig | 4 +- .../ratepay-order-history-log-grid.html.twig | 4 +- .../ratepay-order-management/index.js | 19 +- .../ratepay-order-management.html.twig | 201 +++++++++--------- .../ratepay-order-management.scss | 79 ++++--- .../sw-order/page/sw-order-detail/index.js | 36 +--- .../sw-order/page/sw-order-list/index.js | 3 + .../sw-order-list/sw-order-list.html.twig | 14 +- .../view/sw-order-detail-ratepay/index.js | 9 +- .../sw-order-detail-ratepay.html.twig | 2 +- .../js/rpay-payments/rpay-payments.js | 4 +- src/Resources/config/services.xml | 4 + .../assets/rpay-payments-Bh0AbCMf.js | 8 + .../assets/rpay-payments-Bh0AbCMf.js.map | 1 + .../assets/rpay-payments-D9GnBg_p.js | 8 + .../assets/rpay-payments-D9GnBg_p.js.map | 1 + .../assets/rpay-payments-DQrD5tLS.css | 1 + .../administration/css/rpay-payments.css | 105 --------- src/Util/CriteriaHelper.php | 6 +- .../DeliveryStatusSubscriberTest.php | 4 +- .../PaymentStatusSubscriberTest.php | 4 +- 61 files changed, 443 insertions(+), 438 deletions(-) create mode 100644 src/Core/Subscriber/OrderRouteRequestSubscriber.php delete mode 100644 src/Resources/app/administration/build/webpack.config.js create mode 100644 src/Resources/public/administration/assets/rpay-payments-Bh0AbCMf.js create mode 100644 src/Resources/public/administration/assets/rpay-payments-Bh0AbCMf.js.map create mode 100644 src/Resources/public/administration/assets/rpay-payments-D9GnBg_p.js create mode 100644 src/Resources/public/administration/assets/rpay-payments-D9GnBg_p.js.map create mode 100644 src/Resources/public/administration/assets/rpay-payments-DQrD5tLS.css delete mode 100644 src/Resources/public/administration/css/rpay-payments.css diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 90c43c35..8171b527 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -19,9 +19,17 @@ jobs: runs-on: 'ubuntu-latest' strategy: matrix: - php-version: [ '8.2', '8.3' ] + php-version: [ '8.2', '8.3', '8.4' ] + composer-version: [ '2.2', '2.8' ] mysql-version: [ '8.0' ] - shopware-version: [ 'v6.6.0.0', 'v6.6.1.0', 'v6.6.2.0', 'v6.6.3.0', 'v6.6.4.0' ] + shopware-version: [ 'v6.7.0.0', 'v6.7.1.0', 'v6.7.2.0' ] + exclude: + - php-version: 8.2 + composer-version: 2.8 + - php-version: 8.3 + composer-version: 2.8 + - php-version: 8.4 + composer-version: 2.2 fail-fast: false max-parallel: 10 services: @@ -39,7 +47,7 @@ jobs: with: php-version: ${{ matrix.php-version }} extensions: mbstring, xdebug, curl, dom, fileinfo, gd, iconv, intl, json, xml, mbstring, pdo, phar, zip, sodium, pdo_mysql - tools: composer:2.2 + tools: composer:${{ matrix.composer-version }} - name: "Check PHP Version" run: php -v diff --git a/.gitignore b/.gitignore index 95d6f4b1..a228c3cc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ /var/cache/ composer.lock __COMPOSER_HOME__ -node_modules/ +src/Resources/app/administration/node_modules diff --git a/CHANGELOG.md b/CHANGELOG.md index bbb9c4d2..b0225192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## Version 8.0.0 - Released on 2025-09-18 + +* RATESWSX-332: add Shopware 6.7.x.x compatibility +* RATESWSX-332: build tool: migration from Webpack to Vite +* RATESWSX-332: upgrade code to be compatible with PHP 8.2, PHP 8.3 and PHP 8.4 +* RATESWSX-332: upgrade composer version to be compatible with PHP 8.4 + ## Version 7.2.0 - Released on 2024-12-09 * RATESWSX-320: dfp: remove validation & improve user-identification diff --git a/README.md b/README.md index ba44ba77..85fc7b04 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # Ratepay GmbH - Shopware 6 Payment Module -| Module | Ratepay Payment Plugin for Shopware 6 | -|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------| -| Author | Interlutions GmbH | -| Shop Version | `6.3.0.2 to 6.6.x.x` | -| Link | http://www.ratepay.com | -| Mail | integration@ratepay.com | -| Full Documentation | [click here](https://docs.ratepay.com/docs/developer/shop_modules/shopware/shopware_6/ratepay_payment_plugin_for_shopware_6/) | -| Legal Disclaimer | [click here](https://docs.ratepay.com/docs/developer/shop_modules/overview/) | +| Module | Ratepay Payment Plugin for Shopware 6 | +|--------------------|-------------------------------------------------------------------------------------------------------------------------------| +| Author | Interlutions GmbH | +| Shop Version | `6.3.0.2 to 6.7.x.x` | +| Link | http://www.ratepay.com | +| Mail | integration@ratepay.com | +| Full Documentation | [click here](https://docs.ratepay.com/docs/developer/shop_modules/shopware/shopware_6/ratepay_payment_plugin_for_shopware_6/) | +| Legal Disclaimer | [click here](https://docs.ratepay.com/docs/developer/shop_modules/overview/) | ## Installation via Shopware Store diff --git a/composer.json b/composer.json index 06469b3d..698f8796 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "ratepay/shopware6-module", "description": "Ratepay payment methods for Shopware 6", - "version": "7.2.0", + "version": "8.0.0", "license": "MIT", "authors": [ { @@ -41,9 +41,9 @@ } }, "require": { - "php": "^8.1", + "php": "^8.2", "ratepay/php-library": "^1.8", - "shopware/core": "~6.6.0", + "shopware/core": "~6.7.0", "ext-simplexml": "*", "ext-json": "*" }, @@ -73,5 +73,10 @@ "rector/rector": "^1.1", "symplify/easy-coding-standard": "^12.2", "phpunit/phpunit": "^9.6" + }, + "config": { + "allow-plugins": { + "symfony/runtime": false + } } } diff --git a/src/Components/AdminOrders/Service/DfpService.php b/src/Components/AdminOrders/Service/DfpService.php index b2a7ee2c..40b7ec56 100644 --- a/src/Components/AdminOrders/Service/DfpService.php +++ b/src/Components/AdminOrders/Service/DfpService.php @@ -25,17 +25,17 @@ public function __construct( ) { } - public function generatedDfpId(Request $request, SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): ?string + public function generatedDfpId(Request $request, SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): ?string { return $this->isDfpRequired($salesChannelContext, $orderEntity) ? $this->decorated->generatedDfpId($request, $salesChannelContext, $orderEntity) : null; } - public function getDfpSnippet(Request $request, SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): ?string + public function getDfpSnippet(Request $request, SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): ?string { return $this->isDfpRequired($salesChannelContext, $orderEntity) ? $this->decorated->getDfpSnippet($request, $salesChannelContext, $orderEntity) : null; } - public function isDfpRequired(SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): bool + public function isDfpRequired(SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): bool { $session = $this->requestStack->getMainRequest()->getSession(); if ($this->sessionService->isAdminSession($salesChannelContext, $session)) { diff --git a/src/Components/AdminOrders/Service/SessionService.php b/src/Components/AdminOrders/Service/SessionService.php index e34bf146..c510be79 100644 --- a/src/Components/AdminOrders/Service/SessionService.php +++ b/src/Components/AdminOrders/Service/SessionService.php @@ -33,11 +33,6 @@ public function canLogout(SalesChannelContext $context, SessionInterface $sessio public function isLoggedInAsCustomer(SalesChannelContext $context, SessionInterface $session): bool { - // supported since SW 6.6.5.x - TODO remove this check if compatibility has been change to Shopware >= 6.6.5 - if (method_exists($context, 'getImitatingUserId') && $context->getImitatingUserId() !== null) { - return true; - } - if ($context->getCustomerId() === null) { return false; } @@ -55,7 +50,7 @@ public function destroy(SessionInterface $session): void { $session->remove($this->sessionKey); - // make sure that the third-party modules did not left any data, which we will check + // make sure that the third-party modules did not leave any data, which we will check foreach ($this->getThirdPartyLoginAsSessionKeys() as $key) { $session->remove($key); } diff --git a/src/Components/AdminOrders/Subscriber/LoginSubscriber.php b/src/Components/AdminOrders/Subscriber/LoginSubscriber.php index 000c31d0..fb091838 100644 --- a/src/Components/AdminOrders/Subscriber/LoginSubscriber.php +++ b/src/Components/AdminOrders/Subscriber/LoginSubscriber.php @@ -27,7 +27,7 @@ public function __construct( public static function getSubscribedEvents(): array { return [ - CustomerLogoutEvent::class => ['onLogout', -3000], // as late as possible to prioritize thirdparty modules + CustomerLogoutEvent::class => ['onLogout', -3000], // as late as possible to prioritize third-party modules ]; } diff --git a/src/Components/Checkout/Controller/AbstractCheckoutController.php b/src/Components/Checkout/Controller/AbstractCheckoutController.php index 13a2e2fa..5b999029 100644 --- a/src/Components/Checkout/Controller/AbstractCheckoutController.php +++ b/src/Components/Checkout/Controller/AbstractCheckoutController.php @@ -18,5 +18,5 @@ abstract class AbstractCheckoutController { abstract public function getDecorated(): self; - abstract public function getPaymentData(Request $request, SalesChannelContext $salesChannelContext, string $orderId = null): Response; + abstract public function getPaymentData(Request $request, SalesChannelContext $salesChannelContext, ?string $orderId = null): Response; } diff --git a/src/Components/Checkout/Controller/CheckoutController.php b/src/Components/Checkout/Controller/CheckoutController.php index 7c63ba11..fcbab656 100644 --- a/src/Components/Checkout/Controller/CheckoutController.php +++ b/src/Components/Checkout/Controller/CheckoutController.php @@ -43,7 +43,7 @@ public function __construct( ], methods: ['GET'] )] - public function getPaymentData(Request $request, SalesChannelContext $salesChannelContext, string $orderId = null): Response + public function getPaymentData(Request $request, SalesChannelContext $salesChannelContext, ?string $orderId = null): Response { try { if ($orderId) { diff --git a/src/Components/Checkout/Event/RatepayPaymentFilterEvent.php b/src/Components/Checkout/Event/RatepayPaymentFilterEvent.php index 54d3a9b6..c4cb97bd 100644 --- a/src/Components/Checkout/Event/RatepayPaymentFilterEvent.php +++ b/src/Components/Checkout/Event/RatepayPaymentFilterEvent.php @@ -57,7 +57,7 @@ public function isAvailable(): bool } /** - * if $isAvailable is false, the event will stopped. + * if $isAvailable is false, the event will be stopped. */ public function setIsAvailable(bool $isAvailable): void { diff --git a/src/Components/Checkout/Service/DataValidationService.php b/src/Components/Checkout/Service/DataValidationService.php index a0e1b4d0..9a83d3cb 100644 --- a/src/Components/Checkout/Service/DataValidationService.php +++ b/src/Components/Checkout/Service/DataValidationService.php @@ -29,7 +29,7 @@ public function __construct( ) { } - public function validatePaymentData(DataBag $parameterBag, SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): void + public function validatePaymentData(DataBag $parameterBag, SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): void { if ($orderEntity instanceof OrderEntity) { $paymentMethodId = $orderEntity->getTransactions()->last()->getPaymentMethodId(); diff --git a/src/Components/Checkout/Service/ExtensionService.php b/src/Components/Checkout/Service/ExtensionService.php index 99a959c6..8198818e 100644 --- a/src/Components/Checkout/Service/ExtensionService.php +++ b/src/Components/Checkout/Service/ExtensionService.php @@ -139,7 +139,7 @@ public function createOrderExtensionEntity( public function buildPaymentDataExtension( SalesChannelContext $salesChannelContext, ?OrderEntity $order = null, - Request $httpRequest = null + ?Request $httpRequest = null ): ?ArrayStruct { $paymentMethod = $salesChannelContext->getPaymentMethod(); @@ -169,19 +169,19 @@ public function buildPaymentDataExtension( } $extension = new ArrayStruct(); - $extension->offsetSet('isSandbox', $profileConfig->isSandbox()); - $extension->offsetSet('birthday', $customerBirthday ?? null); - $extension->offsetSet('vatId', $customerVatId ?? null); - $extension->offsetSet('phoneNumber', $customerPhoneNumber ?? null); - $extension->offsetSet('company', $customerCompany ?? null); - $extension->offsetSet('accountHolders', $accountHolders ?? null); - $extension->offsetSet( + $extension->set('isSandbox', $profileConfig->isSandbox()); + $extension->set('birthday', $customerBirthday ?? null); + $extension->set('vatId', $customerVatId ?? null); + $extension->set('phoneNumber', $customerPhoneNumber ?? null); + $extension->set('company', $customerCompany ?? null); + $extension->set('accountHolders', $accountHolders ?? null); + $extension->set( 'paymentMethod', strtolower((string) constant($paymentMethod->getHandlerIdentifier() . '::RATEPAY_METHOD')) ); if ($httpRequest instanceof Request) { - // add user entered values again, so that the user have not to reenter his values + // add user entered values again, so that the user has not to reenter his values foreach (RequestHelper::getArray($httpRequest, RequestHelper::RATEPAY_DATA_KEY) ?: [] as $key => $value) { if ($key === 'birthday' && is_array($value)) { $value = (new DateTime())->setDate((int) $value['year'], (int) $value['month'], (int) $value['day']); diff --git a/src/Components/Checkout/Service/PaymentFilterService.php b/src/Components/Checkout/Service/PaymentFilterService.php index e86f245a..a0a7f7b6 100644 --- a/src/Components/Checkout/Service/PaymentFilterService.php +++ b/src/Components/Checkout/Service/PaymentFilterService.php @@ -35,7 +35,7 @@ public function __construct( ) { } - public function filterPaymentMethods(PaymentMethodCollection $paymentMethodCollection, SalesChannelContext $salesChannelContext, OrderEntity $order = null): void + public function filterPaymentMethods(PaymentMethodCollection $paymentMethodCollection, SalesChannelContext $salesChannelContext, ?OrderEntity $order = null): void { foreach ($paymentMethodCollection->getElements() as $key => $paymentMethod) { if (!$this->isPaymentMethodAvailable($paymentMethod, $salesChannelContext, $order)) { @@ -44,7 +44,7 @@ public function filterPaymentMethods(PaymentMethodCollection $paymentMethodColle } } - private function isPaymentMethodAvailable(PaymentMethodEntity $paymentMethod, SalesChannelContext $salesChannelContext, OrderEntity $order = null): bool + private function isPaymentMethodAvailable(PaymentMethodEntity $paymentMethod, SalesChannelContext $salesChannelContext, ?OrderEntity $order = null): bool { if ($paymentMethod->getHandlerIdentifier() === LegacyPaymentHandler::class) { return false; diff --git a/src/Components/Checkout/Struct/PaymentDataResponse.php b/src/Components/Checkout/Struct/PaymentDataResponse.php index acf73d66..91011684 100644 --- a/src/Components/Checkout/Struct/PaymentDataResponse.php +++ b/src/Components/Checkout/Struct/PaymentDataResponse.php @@ -13,6 +13,9 @@ use Shopware\Core\Framework\Struct\ArrayStruct; use Shopware\Core\System\SalesChannel\StoreApiResponse; +/** + * @extends StoreApiResponse + */ class PaymentDataResponse extends StoreApiResponse { public function __construct(ArrayStruct $paymentExtension, int $status = self::HTTP_OK) diff --git a/src/Components/DeviceFingerprint/DfpService.php b/src/Components/DeviceFingerprint/DfpService.php index af778227..40751125 100644 --- a/src/Components/DeviceFingerprint/DfpService.php +++ b/src/Components/DeviceFingerprint/DfpService.php @@ -39,7 +39,7 @@ public function __construct( * provide the user-agent via header or a request variable `userAgent` to generate a more unique device-identifier * the request-variable is prioritized */ - public function generatedDfpId(Request $request, SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): ?string + public function generatedDfpId(Request $request, SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): ?string { if (!$this->isDfpRequired($salesChannelContext, $orderEntity)) { return null; @@ -52,7 +52,7 @@ public function generatedDfpId(Request $request, SalesChannelContext $salesChann return $this->getCustomerToken($request, $salesChannelContext); } - public function getDfpSnippet(Request $request, SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): ?string + public function getDfpSnippet(Request $request, SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): ?string { if ($id = $this->generatedDfpId($request, $salesChannelContext, $orderEntity)) { $dfpHelper = new DeviceFingerprint($this->configService->getDeviceFingerprintSnippetId()); @@ -62,7 +62,7 @@ public function getDfpSnippet(Request $request, SalesChannelContext $salesChanne return null; } - public function isDfpRequired(SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): bool + public function isDfpRequired(SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): bool { return true; } @@ -93,7 +93,7 @@ private function getCustomerToken(Request $request, SalesChannelContext $context 'uuid' => $existingHashData->uuid, 'token' => $context->getToken(), - // user-agent is only required for logged-in users. This will prevent that they can not switch the device + // user-agent is only required for logged-in users. This will prevent switching the device 'user-agent' => $request->get('userAgent') ?? $request->headers->get('User-Agent') ?? $context->getCustomer()?->getRemoteAddress(), // if user-agent is not given, we need another parameter. We will try the last-login. diff --git a/src/Components/DeviceFingerprint/DfpServiceInterface.php b/src/Components/DeviceFingerprint/DfpServiceInterface.php index e99def97..4468c10b 100644 --- a/src/Components/DeviceFingerprint/DfpServiceInterface.php +++ b/src/Components/DeviceFingerprint/DfpServiceInterface.php @@ -16,9 +16,9 @@ interface DfpServiceInterface { - public function generatedDfpId(Request $request, SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): ?string; + public function generatedDfpId(Request $request, SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): ?string; - public function getDfpSnippet(Request $request, SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): ?string; + public function getDfpSnippet(Request $request, SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): ?string; public function isDfpRequired(SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): bool; } diff --git a/src/Components/InstallmentCalculator/DependencyInjection/controller.xml b/src/Components/InstallmentCalculator/DependencyInjection/controller.xml index d8de3a57..11e02f89 100644 --- a/src/Components/InstallmentCalculator/DependencyInjection/controller.xml +++ b/src/Components/InstallmentCalculator/DependencyInjection/controller.xml @@ -16,9 +16,6 @@ - - - diff --git a/src/Components/InstallmentCalculator/Exception/InstallmentCalculationException.php b/src/Components/InstallmentCalculator/Exception/InstallmentCalculationException.php index 972b9bd7..87352425 100644 --- a/src/Components/InstallmentCalculator/Exception/InstallmentCalculationException.php +++ b/src/Components/InstallmentCalculator/Exception/InstallmentCalculationException.php @@ -17,7 +17,7 @@ class InstallmentCalculationException extends ShopwareHttpException { - public function __construct(string $message = null, array $parameters = [], ?Throwable $e = null) + public function __construct(?string $message = null, array $parameters = [], ?Throwable $e = null) { $message = 'Calculation of the installment plan was not successful. ' . $message; diff --git a/src/Components/InstallmentCalculator/Struct/InstallmentCalculationResponse.php b/src/Components/InstallmentCalculator/Struct/InstallmentCalculationResponse.php index 97904f39..479639d5 100644 --- a/src/Components/InstallmentCalculator/Struct/InstallmentCalculationResponse.php +++ b/src/Components/InstallmentCalculator/Struct/InstallmentCalculationResponse.php @@ -13,13 +13,11 @@ use Shopware\Core\Framework\Struct\ArrayStruct; use Shopware\Core\System\SalesChannel\StoreApiResponse; +/** + * @extends StoreApiResponse + */ class InstallmentCalculationResponse extends StoreApiResponse { - /** - * @var ArrayStruct - */ - protected $object; - /** * @param array{translations: array, plan: array} $data */ diff --git a/src/Components/OrderManagement/Controller/ProductPanel.php b/src/Components/OrderManagement/Controller/ProductPanel.php index 8026ac26..221a9c76 100644 --- a/src/Components/OrderManagement/Controller/ProductPanel.php +++ b/src/Components/OrderManagement/Controller/ProductPanel.php @@ -77,7 +77,9 @@ public function __construct( public function load(string $orderId, Context $context): JsonResponse { $criteria = new Criteria([$orderId]); + $criteria->addAssociation(OrderExtension::EXTENSION_NAME); $criteria->addAssociation('lineItems'); + $criteria->addAssociation('lineItems.' . OrderLineItemExtension::EXTENSION_NAME); $order = $this->orderRepository->search($criteria, $context)->first(); diff --git a/src/Components/PaymentHandler/AbstractPaymentHandler.php b/src/Components/PaymentHandler/AbstractPaymentHandler.php index b63e3a2b..43b891d9 100644 --- a/src/Components/PaymentHandler/AbstractPaymentHandler.php +++ b/src/Components/PaymentHandler/AbstractPaymentHandler.php @@ -31,24 +31,28 @@ use Ratepay\RpayPayments\Util\CriteriaHelper; use Ratepay\RpayPayments\Util\RequestHelper; use RuntimeException; +use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity; use Shopware\Core\Checkout\Order\OrderEntity; -use Shopware\Core\Checkout\Payment\Cart\PaymentHandler\SynchronousPaymentHandlerInterface; -use Shopware\Core\Checkout\Payment\Cart\SyncPaymentTransactionStruct; -use Shopware\Core\Checkout\Payment\Exception\SyncPaymentProcessException; +use Shopware\Core\Checkout\Payment\Cart\PaymentHandler\PaymentHandlerType; +use Shopware\Core\Checkout\Payment\Cart\PaymentTransactionStruct; use Shopware\Core\Checkout\Payment\PaymentException; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; +use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; +use Shopware\Core\Framework\Struct\Struct; use Shopware\Core\Framework\Validation\DataBag\DataBag; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Shopware\Storefront\Controller\StorefrontController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\ParameterBag; +use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\Session; use Throwable; -abstract class AbstractPaymentHandler implements SynchronousPaymentHandlerInterface +abstract class AbstractPaymentHandler extends \Shopware\Core\Checkout\Payment\Cart\PaymentHandler\AbstractPaymentHandler { /** * @var string @@ -57,6 +61,7 @@ abstract class AbstractPaymentHandler implements SynchronousPaymentHandlerInterf public function __construct( private readonly EntityRepository $orderRepository, + private readonly EntityRepository $orderTransactionRepository, private readonly PaymentRequestService $paymentRequestService, private readonly EventDispatcherInterface $eventDispatcher, private readonly PluginConfigService $configService, @@ -68,21 +73,44 @@ public function __construct( abstract public static function getRatepayPaymentMethodName(): string; - public function pay(SyncPaymentTransactionStruct $transaction, RequestDataBag $dataBag, SalesChannelContext $salesChannelContext): void + public function supports(PaymentHandlerType $type, string $paymentMethodId, Context $context): bool { + // This payment handler does not support recurring payments nor refunds + return false; + } + + public function pay(Request $request, PaymentTransactionStruct $transaction, Context $context, ?Struct $validateStruct): ?RedirectResponse + { + $salesChannelContext = $request->attributes->get('sw-sales-channel-context'); + + $data = $request->get('ratepay'); + $ratepayDataBag = new RequestDataBag($data); + + $dataBag = new RequestDataBag(); + $dataBag->set('paymentDetails', [ + 'ratepay' => $ratepayDataBag, + ]); + $ratepayData = RequestHelper::getRatepayData($dataBag) ?: new ParameterBag(); - $order = $this->getOrderWithAssociations($transaction->getOrder(), $salesChannelContext->getContext()); + $orderTransactionId = $transaction->getOrderTransactionId(); + $orderTransaction = $this->getOrderTransactionById($orderTransactionId, $context); + + $orderEntity = $orderTransaction?->getOrder(); + $order = $this->getOrderWithAssociations($orderEntity, Context::createDefaultContext()); - if (!$order instanceof OrderEntity || $ratepayData->count() === 0) { - throw $this->syncProcessInterrupted($transaction->getOrderTransaction()->getId(), 'unknown error during payment'); + $paymentMethod = $order->getTransactions()->first()->getPaymentMethod(); + $orderTransaction->setPaymentMethod($paymentMethod); + + if (!$order instanceof OrderEntity || count($ratepayData) === 0 || !$orderTransaction) { + throw $this->syncProcessInterrupted($orderTransactionId, 'unknown error during payment'); } try { $paymentRequestData = new PaymentRequestData( $salesChannelContext, $order, - $transaction->getOrderTransaction(), + $orderTransaction, $dataBag, $this->configService->isSendDiscountsAsCartItem(), $this->configService->isSendShippingCostsAsCartItem() @@ -112,7 +140,7 @@ public function pay(SyncPaymentTransactionStruct $transaction, RequestDataBag $d if ($response->isSuccessful()) { $this->eventDispatcher->dispatch(new PaymentSuccessfulEvent( $order, - $transaction, + $orderTransaction, $dataBag, $salesChannelContext, $response @@ -133,7 +161,7 @@ public function pay(SyncPaymentTransactionStruct $transaction, RequestDataBag $d } catch (RatepayException $ratepayException) { $this->eventDispatcher->dispatch(new PaymentFailedEvent( $order, - $transaction, + $orderTransaction, $dataBag, $salesChannelContext, $response ?? null, @@ -144,11 +172,13 @@ public function pay(SyncPaymentTransactionStruct $transaction, RequestDataBag $d $session->getFlashBag()->add(StorefrontController::DANGER, $ratepayException->getMessage()); } - throw $this->syncProcessInterrupted($transaction->getOrderTransaction()->getId(), $ratepayException->getMessage(), $ratepayException); + throw $this->syncProcessInterrupted($orderTransactionId, $ratepayException->getMessage(), $ratepayException); } + + return null; } - public function getValidationDefinitions(DataBag $requestDataBag, SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): array + public function getValidationDefinitions(DataBag $requestDataBag, SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): array { $validations = []; @@ -198,4 +228,12 @@ private function syncProcessInterrupted(string $orderTransactionId, string $erro // should never occur - just to be safe return new RuntimeException('payment interrupted: ' . $errorMessage, 0, $e); } + + private function getOrderTransactionById(string $orderTransactionId, Context $context): ?OrderTransactionEntity + { + $criteria = new Criteria([$orderTransactionId]); + $criteria->addAssociation('order'); + + return $this->orderTransactionRepository->search($criteria, $context::createDefaultContext())->first(); + } } diff --git a/src/Components/PaymentHandler/Constraint/AbstractNotBlank.php b/src/Components/PaymentHandler/Constraint/AbstractNotBlank.php index d08902dc..67ceb903 100644 --- a/src/Components/PaymentHandler/Constraint/AbstractNotBlank.php +++ b/src/Components/PaymentHandler/Constraint/AbstractNotBlank.php @@ -17,7 +17,7 @@ abstract class AbstractNotBlank extends NotBlank { - public function __construct(array $options = null) + public function __construct(?array $options = null) { $options['message'] = AbstractPaymentHandler::ERROR_SNIPPET_VIOLATION_PREFIX . static::getRatepayErrorCode(); parent::__construct($options); diff --git a/src/Components/PaymentHandler/DebitPaymentHandler.php b/src/Components/PaymentHandler/DebitPaymentHandler.php index c4f2ee4a..fc765572 100644 --- a/src/Components/PaymentHandler/DebitPaymentHandler.php +++ b/src/Components/PaymentHandler/DebitPaymentHandler.php @@ -24,7 +24,7 @@ class DebitPaymentHandler extends AbstractPaymentHandler */ final public const RATEPAY_METHOD = 'ELV'; - public function getValidationDefinitions(DataBag $requestDataBag, SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): array + public function getValidationDefinitions(DataBag $requestDataBag, SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): array { return array_merge( parent::getValidationDefinitions($requestDataBag, $salesChannelContext, $orderEntity), diff --git a/src/Components/PaymentHandler/DependencyInjection/services.xml b/src/Components/PaymentHandler/DependencyInjection/services.xml index 58453c55..4e7a1c92 100644 --- a/src/Components/PaymentHandler/DependencyInjection/services.xml +++ b/src/Components/PaymentHandler/DependencyInjection/services.xml @@ -13,7 +13,7 @@ - + diff --git a/src/Components/PaymentHandler/Event/AbstractPaymentEvent.php b/src/Components/PaymentHandler/Event/AbstractPaymentEvent.php index 268e3ac2..c05b83a7 100644 --- a/src/Components/PaymentHandler/Event/AbstractPaymentEvent.php +++ b/src/Components/PaymentHandler/Event/AbstractPaymentEvent.php @@ -12,8 +12,8 @@ namespace Ratepay\RpayPayments\Components\PaymentHandler\Event; use RatePAY\Model\Response\PaymentRequest; +use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity; use Shopware\Core\Checkout\Order\OrderEntity; -use Shopware\Core\Checkout\Payment\Cart\SyncPaymentTransactionStruct; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Event\ShopwareEvent; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; @@ -24,7 +24,7 @@ abstract class AbstractPaymentEvent extends Event implements ShopwareEvent { public function __construct( private readonly OrderEntity $order, - private readonly SyncPaymentTransactionStruct $transaction, + private readonly OrderTransactionEntity $transaction, private readonly RequestDataBag $requestDataBag, private readonly SalesChannelContext $salesChannelContext, private readonly ?PaymentRequest $response = null @@ -41,7 +41,7 @@ public function getContext(): Context return $this->salesChannelContext->getContext(); } - public function getTransaction(): SyncPaymentTransactionStruct + public function getTransaction(): OrderTransactionEntity { return $this->transaction; } diff --git a/src/Components/PaymentHandler/Event/PaymentFailedEvent.php b/src/Components/PaymentHandler/Event/PaymentFailedEvent.php index 840f255e..395bda47 100644 --- a/src/Components/PaymentHandler/Event/PaymentFailedEvent.php +++ b/src/Components/PaymentHandler/Event/PaymentFailedEvent.php @@ -12,8 +12,8 @@ namespace Ratepay\RpayPayments\Components\PaymentHandler\Event; use RatePAY\Model\Response\PaymentRequest; +use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity; use Shopware\Core\Checkout\Order\OrderEntity; -use Shopware\Core\Checkout\Payment\Cart\SyncPaymentTransactionStruct; use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Throwable; @@ -22,10 +22,10 @@ class PaymentFailedEvent extends AbstractPaymentEvent { public function __construct( OrderEntity $order, - SyncPaymentTransactionStruct $transaction, + OrderTransactionEntity $transaction, RequestDataBag $requestDataBag, SalesChannelContext $salesChannelContext, - PaymentRequest $response = null, + ?PaymentRequest $response = null, private readonly ?Throwable $exception = null ) { parent::__construct($order, $transaction, $requestDataBag, $salesChannelContext, $response); diff --git a/src/Components/PaymentHandler/InstallmentPaymentHandler.php b/src/Components/PaymentHandler/InstallmentPaymentHandler.php index 61ee594d..d741425e 100644 --- a/src/Components/PaymentHandler/InstallmentPaymentHandler.php +++ b/src/Components/PaymentHandler/InstallmentPaymentHandler.php @@ -31,7 +31,7 @@ class InstallmentPaymentHandler extends AbstractPaymentHandler /** * @return DataValidationDefinition[] */ - public function getValidationDefinitions(DataBag $requestDataBag, SalesChannelContext $salesChannelContext, OrderEntity $orderEntity = null): array + public function getValidationDefinitions(DataBag $requestDataBag, SalesChannelContext $salesChannelContext, ?OrderEntity $orderEntity = null): array { $validations = parent::getValidationDefinitions($requestDataBag, $salesChannelContext, $orderEntity); diff --git a/src/Components/PaymentHandler/LegacyPaymentHandler.php b/src/Components/PaymentHandler/LegacyPaymentHandler.php index 11a43eb8..e39007a5 100644 --- a/src/Components/PaymentHandler/LegacyPaymentHandler.php +++ b/src/Components/PaymentHandler/LegacyPaymentHandler.php @@ -12,9 +12,11 @@ use RuntimeException; use Shopware\Core\Checkout\Payment\Cart\PaymentHandler\DefaultPayment; -use Shopware\Core\Checkout\Payment\Cart\SyncPaymentTransactionStruct; -use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; -use Shopware\Core\System\SalesChannel\SalesChannelContext; +use Shopware\Core\Checkout\Payment\Cart\PaymentTransactionStruct; +use Shopware\Core\Framework\Context; +use Shopware\Core\Framework\Struct\Struct; +use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\Request; /** * @deprecated @@ -22,7 +24,7 @@ */ class LegacyPaymentHandler extends DefaultPayment { - public function pay(SyncPaymentTransactionStruct $transaction, RequestDataBag $dataBag, SalesChannelContext $salesChannelContext): void + public function pay(Request $request, PaymentTransactionStruct $transaction, Context $context, ?Struct $validateStruct): ?RedirectResponse { throw new RuntimeException('payment method does not exist anymore.'); } diff --git a/src/Components/RatepayApi/Factory/PaymentFactory.php b/src/Components/RatepayApi/Factory/PaymentFactory.php index 0693a972..396422fe 100644 --- a/src/Components/RatepayApi/Factory/PaymentFactory.php +++ b/src/Components/RatepayApi/Factory/PaymentFactory.php @@ -29,9 +29,10 @@ protected function _getData(AbstractRequestData $requestData): ?object { /** @var PaymentRequestData $requestData */ $transaction = $requestData->getTransaction(); + $order = $requestData->getOrder(); $payment = new Payment(); - $handler = $transaction->getPaymentMethod()->getHandlerIdentifier(); + $handler = $order->getTransactions()->first()->getPaymentMethod()->getHandlerIdentifier(); $ratepayMethod = constant($handler . '::RATEPAY_METHOD'); $payment->setMethod($ratepayMethod); $payment->setAmount($transaction->getAmount()->getTotalPrice()); diff --git a/src/Components/RedirectException/Exception/ForwardException.php b/src/Components/RedirectException/Exception/ForwardException.php index 4adef35e..2f3600a9 100644 --- a/src/Components/RedirectException/Exception/ForwardException.php +++ b/src/Components/RedirectException/Exception/ForwardException.php @@ -21,7 +21,7 @@ public function __construct( private readonly string $route, private readonly array $routeParams = [], private readonly array $queryParams = [], - Exception $exception = null + ?Exception $exception = null ) { parent::__construct('', 0, $exception); } diff --git a/src/Components/RedirectException/Exception/RedirectException.php b/src/Components/RedirectException/Exception/RedirectException.php index 2ce66901..08c20da3 100644 --- a/src/Components/RedirectException/Exception/RedirectException.php +++ b/src/Components/RedirectException/Exception/RedirectException.php @@ -20,7 +20,7 @@ public function __construct( private readonly RedirectResponse $redirectResponse, string $message = '', int $code = 0, - Exception $previousException = null + ?Exception $previousException = null ) { parent::__construct($message, $code, $previousException); } diff --git a/src/Components/StateMachine/Subscriber/PaymentSuccessfulSubscriber.php b/src/Components/StateMachine/Subscriber/PaymentSuccessfulSubscriber.php index 401e107f..472fd3af 100644 --- a/src/Components/StateMachine/Subscriber/PaymentSuccessfulSubscriber.php +++ b/src/Components/StateMachine/Subscriber/PaymentSuccessfulSubscriber.php @@ -36,13 +36,13 @@ public static function getSubscribedEvents(): array public function changeTransactionState(PaymentSuccessfulEvent $event): void { - $paymentMethod = $event->getTransaction()->getOrderTransaction()->getPaymentMethod(); + $paymentMethod = $event->getTransaction()->getPaymentMethod(); $newState = $this->configService->getPaymentStatusForMethod($paymentMethod); if ($newState && $newState !== OrderTransactionStates::STATE_OPEN) { $this->stateMachineRegistry->transition( new Transition( OrderTransactionDefinition::ENTITY_NAME, - $event->getTransaction()->getOrderTransaction()->getId(), + $event->getTransaction()->getId(), $newState, 'stateId' ), diff --git a/src/Core/Entity/Extension/OrderExtension.php b/src/Core/Entity/Extension/OrderExtension.php index ee3dc5ed..302d3a1e 100644 --- a/src/Core/Entity/Extension/OrderExtension.php +++ b/src/Core/Entity/Extension/OrderExtension.php @@ -33,7 +33,7 @@ public function extendFields(FieldCollection $collection): void 'id', 'order_id', RatepayOrderDataDefinition::class, - true + false ))->addFlags(new RestrictDelete()) ); } @@ -42,4 +42,9 @@ public function getDefinitionClass(): string { return OrderDefinition::class; } + + public function getEntityName(): string + { + return OrderDefinition::ENTITY_NAME; + } } diff --git a/src/Core/Entity/Extension/OrderLineItemExtension.php b/src/Core/Entity/Extension/OrderLineItemExtension.php index 47de1f22..4943b25e 100644 --- a/src/Core/Entity/Extension/OrderLineItemExtension.php +++ b/src/Core/Entity/Extension/OrderLineItemExtension.php @@ -33,7 +33,7 @@ public function extendFields(FieldCollection $collection): void 'id', 'order_line_item_id', RatepayOrderLineItemDataDefinition::class, - true + false ))->addFlags(new RestrictDelete()) ); } @@ -42,4 +42,9 @@ public function getDefinitionClass(): string { return OrderLineItemDefinition::class; } + + public function getEntityName(): string + { + return OrderLineItemDefinition::ENTITY_NAME; + } } diff --git a/src/Core/Entity/RatepayOrderDataEntity.php b/src/Core/Entity/RatepayOrderDataEntity.php index 3d3a7858..1addb02d 100644 --- a/src/Core/Entity/RatepayOrderDataEntity.php +++ b/src/Core/Entity/RatepayOrderDataEntity.php @@ -166,7 +166,7 @@ public function isSendShippingCostsAsCartItem(): bool /** * @return mixed */ - public function getAdditionalData(string $key = null) + public function getAdditionalData(?string $key = null) { return $key ? ($this->additionalData[$key] ?? null) : $this->additionalData; } diff --git a/src/Core/Subscriber/OrderRouteRequestSubscriber.php b/src/Core/Subscriber/OrderRouteRequestSubscriber.php new file mode 100644 index 00000000..fd969eb4 --- /dev/null +++ b/src/Core/Subscriber/OrderRouteRequestSubscriber.php @@ -0,0 +1,32 @@ + 'onOrderRouteRequest', + ]; + } + + public function onOrderRouteRequest(OrderRouteRequestEvent $event): void + { + $criteria = $event->getCriteria(); + $criteria->addAssociation(OrderExtension::EXTENSION_NAME); + } +} diff --git a/src/Resources/app/administration/build/webpack.config.js b/src/Resources/app/administration/build/webpack.config.js deleted file mode 100644 index 13fe06b2..00000000 --- a/src/Resources/app/administration/build/webpack.config.js +++ /dev/null @@ -1,11 +0,0 @@ -const { resolve } = require('path'); -module.exports = () => { - return { - resolve: { - alias: { - 'xml-formatter': resolve(__dirname, '..', 'node_modules', 'xml-formatter'), - 'highlight.js': resolve(__dirname, '..', 'node_modules', 'highlight.js'), - } - } - }; -} diff --git a/src/Resources/app/administration/src/component/ratepay/ratepay-admin-create-order-form/index.js b/src/Resources/app/administration/src/component/ratepay/ratepay-admin-create-order-form/index.js index b48e5f7f..6232ac40 100644 --- a/src/Resources/app/administration/src/component/ratepay/ratepay-admin-create-order-form/index.js +++ b/src/Resources/app/administration/src/component/ratepay/ratepay-admin-create-order-form/index.js @@ -25,7 +25,8 @@ Component.register('ratepay-admin-create-order-form', { data() { return { loading: false, - salesChannels: null, + salesChannels: [], + salesChannelDomains: [], selectedSalesChannelId: null, selectedSalesChannelDomainId: null, @@ -39,26 +40,26 @@ Component.register('ratepay-admin-create-order-form', { this.salesChannelRepository = this.repositoryFactory.create('sales_channel'); this.salesChannelDomainRepository = this.repositoryFactory.create('sales_channel_domain'); - let criteria = new Criteria(); + const criteria = new Criteria(); criteria.addFilter(Criteria.not('AND', [Criteria.equals('domains.url', null)])); criteria.addFilter(Criteria.equals('active', true)); - criteria.addAssociation('domains'); + criteria.addAssociation('domains'); // optional, can prefill domains this.loading = true; - this.salesChannelRepository - .search(criteria, Shopware.Context.api) - .then((result) => { - this.salesChannels = result.filter((item) => { - return item.domains.length > 0; - }); - this.loading = false; - }); + this.salesChannelRepository.search(criteria, Shopware.Context.api).then((result) => { + this.salesChannels = result.filter(item => item.domains.length > 0); + this.loading = false; + }); }, computed: { - salesChannelDomains() { - return this.selectedSalesChannelId ? this.salesChannels.get(this.selectedSalesChannelId)?.domains ?? [] : []; - }, + domainCriteria() { + const criteria = new Criteria(); + if (this.selectedSalesChannelId) { + criteria.addFilter(Criteria.equals('salesChannelId', this.selectedSalesChannelId)); + } + return criteria; + } }, methods: { diff --git a/src/Resources/app/administration/src/component/ratepay/ratepay-admin-create-order-form/ratepay-admin-create-order-form.twig b/src/Resources/app/administration/src/component/ratepay/ratepay-admin-create-order-form/ratepay-admin-create-order-form.twig index 209f511a..6166e082 100644 --- a/src/Resources/app/administration/src/component/ratepay/ratepay-admin-create-order-form/ratepay-admin-create-order-form.twig +++ b/src/Resources/app/administration/src/component/ratepay/ratepay-admin-create-order-form/ratepay-admin-create-order-form.twig @@ -1,32 +1,28 @@ {# - ~ Copyright (c) Ratepay GmbH - ~ - ~ For the full copyright and license information, please view the LICENSE - ~ file that was distributed with this source code. +~ Copyright (c) 2020 Ratepay GmbH +~ +~ For the full copyright and license information, please view the LICENSE +~ file that was distributed with this source code. #} -
- - - - +
+ - - - - + {{ $t('ratepay.admin.create-order.modal.start-session') }} diff --git a/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-details/ratepay-order-details.html.twig b/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-details/ratepay-order-details.html.twig index 5fc86e3b..972bd90d 100644 --- a/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-details/ratepay-order-details.html.twig +++ b/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-details/ratepay-order-details.html.twig @@ -5,7 +5,7 @@ ~ file that was distributed with this source code. #} - - + diff --git a/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-history-log-grid/ratepay-order-history-log-grid.html.twig b/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-history-log-grid/ratepay-order-history-log-grid.html.twig index 7baa71b6..10ddf798 100644 --- a/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-history-log-grid/ratepay-order-history-log-grid.html.twig +++ b/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-history-log-grid/ratepay-order-history-log-grid.html.twig @@ -5,7 +5,7 @@ ~ file that was distributed with this source code. #} - + - + diff --git a/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-management/index.js b/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-management/index.js index cdad100c..8f731155 100644 --- a/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-management/index.js +++ b/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-management/index.js @@ -126,6 +126,13 @@ Component.register('ratepay-order-management', { taxRepository() { return this.repositoryFactory.create('tax'); }, + taxOptions() { + return this.taxes.map(tax => ({ + id: tax.id, + value: tax.id, + label: this.getTaxLabel(tax), + })); + }, }, created() { @@ -166,14 +173,14 @@ Component.register('ratepay-order-management', { this.addDebit.data.tax = this.defaultTax; this.addDebit.data.taxId = this.defaultTax.id; }, - updateCreditTax() { - if (this.addCredit.data.taxId) { - this.addCredit.data.tax = this.taxes.get(this.addCredit.data.taxId); + updateCreditTax(newTaxId) { + if (newTaxId) { + this.addCredit.data.tax = this.taxes.get(newTaxId); } }, - updateDebitTax() { - if (this.addDebit.data.taxId) { - this.addDebit.data.tax = this.taxes.get(this.addDebit.data.taxId); + updateDebitTax(newTaxId) { + if (newTaxId) { + this.addDebit.data.tax = this.taxes.get(newTaxId); } }, onClickButtonDeliver() { diff --git a/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-management/ratepay-order-management.html.twig b/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-management/ratepay-order-management.html.twig index bdcad7d1..68e419f6 100644 --- a/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-management/ratepay-order-management.html.twig +++ b/src/Resources/app/administration/src/module/sw-order/component/ratepay-order-management/ratepay-order-management.html.twig @@ -1,11 +1,12 @@ {# - ~ Copyright (c) Ratepay GmbH - ~ - ~ For the full copyright and license information, please view the LICENSE - ~ file that was distributed with this source code. +~ Copyright (c) Ratepay GmbH +~ +~ For the full copyright and license information, please view the LICENSE +~ file that was distributed with this source code. #} - +