From 9bd53424a65637cd841fae966df36cd01bd995a8 Mon Sep 17 00:00:00 2001 From: paeddl Date: Wed, 25 Mar 2026 11:30:13 +0100 Subject: [PATCH] v6.5.4 --- CHANGELOG_de-DE.md | 5 +- CHANGELOG_en-GB.md | 3 + composer.json | 2 +- .../CancelService/CancelService.php | 11 +- .../PaymentActions/PaymentActionService.php | 124 ++++++++---------- .../PaymentActions/Struct/RefundItem.php | 7 +- .../Struct/RefundItemCollection.php | 5 +- .../AbstractUnzerPaymentHandler.php | 37 +++--- .../PaymentHandler/Traits/CanRecur.php | 3 - .../UnzerWeroPaymentHandler.php | 2 +- .../UnzerUtil/UnzerTransactionUtil.php | 13 +- .../UnzerPaymentTransactionController.php | 49 ++++--- .../StateMachine/TransitionEventListener.php | 4 - src/Installer/PaymentInstaller.php | 60 ++++++++- .../unzer-payment-settings.html.twig | 3 + .../unzer-payment-settings.scss | 9 ++ .../administration/src/snippets/de-DE.json | 3 +- .../administration/src/snippets/en-GB.json | 3 +- .../administration/css/unzer-payment6.css | 2 +- .../administration/js/unzer-payment6.js | 2 +- 20 files changed, 195 insertions(+), 152 deletions(-) diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index 5ddbfe93..10d111e0 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,3 +1,6 @@ +# 6.5.4 +* Aktualisierung iDEAL Payment Naming + # 6.5.3 * **Wichtiger Hotfix** * Dieser Hotfix behebt ein Problem, bei dem einige Webhooks in Shopware 6.6 nicht korrekt registriert wurden. @@ -69,7 +72,7 @@ * EPS: Entfernung Bank Feld # 6.2.1 -* Cardholder Name in Kreditkarten-Checkout hinzugefügt +* Cardholder Name in Kreditkarten-Checkout hinzugefügt # 6.2.0 * TWINT als weitere Zahlungsart hinzugefügt diff --git a/CHANGELOG_en-GB.md b/CHANGELOG_en-GB.md index 96b5f725..4ddb6117 100644 --- a/CHANGELOG_en-GB.md +++ b/CHANGELOG_en-GB.md @@ -1,3 +1,6 @@ +# 6.5.4 +* Updated iDEAL Payment naming + # 6.5.3 * **Important hotfix** * This hotfix will fix an issue where some webhooks were not correctly registered in Shopware 6.6. diff --git a/composer.json b/composer.json index 243be51b..dc1f0bc2 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "unzerdev/shopware6", "description": "Unzer payment integration for Shopware 6", - "version": "6.5.3", + "version": "6.5.4", "type": "shopware-platform-plugin", "license": "Apache-2.0", "minimum-stability": "dev", diff --git a/src/Components/CancelService/CancelService.php b/src/Components/CancelService/CancelService.php index df608534..db296e8f 100644 --- a/src/Components/CancelService/CancelService.php +++ b/src/Components/CancelService/CancelService.php @@ -95,6 +95,7 @@ public function cancelChargeById(string $orderTransactionId, string $chargeId, f } $this->updateOrderStatus($client, $transaction, $context); + return $responseCancellation; } @@ -123,6 +124,11 @@ public function cancelAuthorizationById(string $orderTransactionId, string $paym $this->updateOrderStatus($client, $transaction, $context); } + public function isPaylaterPaymentMethod(string $paymentMethodId): bool + { + return \in_array($paymentMethodId, self::PAYLATER_PAYMENT_METHODS, true); + } + protected function getOrderTransaction(string $orderTransactionId, Context $context): ?OrderTransactionEntity { $criteria = new Criteria([$orderTransactionId]); @@ -141,11 +147,6 @@ protected function getCancelReasonCode(?string $reasonCode): string return $reasonCode ?? CancelReasonCodes::REASON_CODE_CANCEL; } - public function isPaylaterPaymentMethod(string $paymentMethodId): bool - { - return \in_array($paymentMethodId, self::PAYLATER_PAYMENT_METHODS, true); - } - private function updateOrderStatus(Unzer $client, OrderTransactionEntity $orderTransaction, Context $context): void { try { diff --git a/src/Components/PaymentActions/PaymentActionService.php b/src/Components/PaymentActions/PaymentActionService.php index 091ad4b8..99da8f4b 100644 --- a/src/Components/PaymentActions/PaymentActionService.php +++ b/src/Components/PaymentActions/PaymentActionService.php @@ -1,8 +1,7 @@ -logger->info('Capturing order', ['order' => $order->getId()]); $orderTransaction = $this->unzerTransactionUtil->getOrderTransactionFromOrder($order, $context); if ($orderTransaction === null) { return false; } + $this->logger->info('Capturing order', ['order' => $order->getId()]); $client = $this->clientFactory->createClient(KeyPairContext::createFromOrderTransaction($orderTransaction)); try { $charge = $client->performChargeOnPayment($orderTransaction->getId(), new Charge($orderTransaction->getAmount()->getTotalPrice())); @@ -67,21 +64,18 @@ public function captureOrder(OrderEntity $order, Context $context): bool return true; } - - - /** * @throws \Exception */ public function refundOrder(OrderEntity $order, Context $context): void { - $this->logger->info('Refunding order', ['order' => $order->getId()]); $orderTransaction = $this->unzerTransactionUtil->getOrderTransactionFromOrder($order, $context); if ($orderTransaction === null) { return; } + $this->logger->info('Refunding order', ['order' => $order->getId()]); $client = $this->clientFactory->createClient(KeyPairContext::createFromOrderTransaction($orderTransaction)); try { $payment = $client->fetchPayment($orderTransaction->getId()); @@ -98,7 +92,7 @@ public function refundOrder(OrderEntity $order, Context $context): void null, $context ); - } catch (Throwable $e) { + } catch (\Throwable $e) { $this->logger->error('Error while refunding charge', ['charge' => $charge->getId(), 'error' => $e->getMessage()]); } } @@ -113,7 +107,7 @@ public function refundOrder(OrderEntity $order, Context $context): void $authorization->getAmount() - $authorization->getCancelledAmount(), $context ); - } catch (Throwable $e) { + } catch (\Throwable $e) { $this->logger->error('Error while refunding authorization', ['authorization' => $authorization->getId(), 'error' => $e->getMessage()]); } } @@ -127,14 +121,11 @@ public function refundOrder(OrderEntity $order, Context $context): void } } - - public function executeReturnRefunds(OrderEntity $order, Context $context): void { - $this->logger->info('Refunding order based on returns', ['order' => $order->getId()]); - - if($this->orderReturnRepository === null) { + if ($this->orderReturnRepository === null) { $this->logger->warning('Returns repository does not exist'); + return; } @@ -144,9 +135,10 @@ public function executeReturnRefunds(OrderEntity $order, Context $context): void return; } + $this->logger->info('Refunding order based on returns', ['order' => $order->getId()]); $returnsToProcess = $this->getUnprocessedReturns($orderTransaction, $context); - foreach($returnsToProcess as $returnEntity) { + foreach ($returnsToProcess as $returnEntity) { $items = new RefundItemCollection(); foreach ($returnEntity->getLineItems() as $lineItem) { $refundItem = new RefundItem( @@ -163,8 +155,8 @@ public function executeReturnRefunds(OrderEntity $order, Context $context): void amount: $returnEntity->getAmountTotal(), context: $context, items: $items, - comment: 'SW Auto Refund from order #'.$order->getOrderNumber().' return #'.$returnEntity->getReturnNumber(), - referenceText: $order->getOrderNumber().'/'.$returnEntity->getReturnNumber() + comment: 'SW Auto Refund from order #' . $order->getOrderNumber() . ' return #' . $returnEntity->getReturnNumber(), + referenceText: $order->getOrderNumber() . '/' . $returnEntity->getReturnNumber() ); $transactionCustomFields = $orderTransaction->getCustomFields() ?? []; @@ -191,38 +183,6 @@ public function executeReturnRefunds(OrderEntity $order, Context $context): void ], ], $context); } - - } - - /** - * @return OrderReturnEntity[] - */ - protected function getUnprocessedReturns(OrderTransactionEntity $orderTransaction, Context $context): array - { - if ($this->orderReturnRepository === null) { - return []; - } - - $criteria = new Criteria(); - $criteria->addFilter(new EqualsFilter('orderId', $orderTransaction->getOrderId())); - $criteria->addAssociation('lineItems.lineItem.orderLineItem'); - - $returns = $this->orderReturnRepository->search($criteria, $context); - - $transactionCustomFields = $orderTransaction->getCustomFields() ?? []; - $processedReturns = $transactionCustomFields['unzerRefundDetails']['processedReturns'] ?? []; - - $unprocessedReturns = []; - - foreach ($returns as $return) { - if (isset($processedReturns[$return->getId()])) { - continue; - } - - $unprocessedReturns[] = $return; - } - - return $unprocessedReturns; } public function doUnifiedRefund(OrderTransactionEntity $orderTransaction, float $amount, Context $context, ?RefundItemCollection $items = null, string $comment = '', string $referenceText = ''): string @@ -230,7 +190,7 @@ public function doUnifiedRefund(OrderTransactionEntity $orderTransaction, float $client = $this->clientFactory->createClient(KeyPairContext::createFromOrderTransaction($orderTransaction)); $payment = UnzerTransactionUtil::fetchPaymentFromOrderTransaction($orderTransaction, $client); $charges = $payment->getCharges(); - $charge = reset($charges);//TODO + $charge = reset($charges); // TODO $cancellation = $this->cancelService->cancelChargeById($orderTransaction->getId(), $charge->getId(), $amount, null, $context, $referenceText); @@ -240,7 +200,7 @@ public function doUnifiedRefund(OrderTransactionEntity $orderTransaction, float } $transactionCustomFields['unzerRefundDetails'][$cancellation->getId()] = [ - 'items' => $items?$items->jsonSerialize():[], + 'items' => $items ? $items->jsonSerialize() : [], 'comment' => $comment, 'cancellation' => $cancellation->expose(), ]; @@ -252,15 +212,45 @@ public function doUnifiedRefund(OrderTransactionEntity $orderTransaction, float $orderTransaction->setCustomFields($transactionCustomFields); - if($items !== null && $items->count() > 0) { + if ($items !== null && $items->count() > 0) { $this->processRefundItems($items, $context); } return $cancellation->getId(); } + /** + * @return OrderReturnEntity[] + */ + protected function getUnprocessedReturns(OrderTransactionEntity $orderTransaction, Context $context): array + { + if ($this->orderReturnRepository === null) { + return []; + } + + $criteria = new Criteria(); + $criteria->addFilter(new EqualsFilter('orderId', $orderTransaction->getOrderId())); + $criteria->addAssociation('lineItems.lineItem.orderLineItem'); + + $returns = $this->orderReturnRepository->search($criteria, $context); + + $transactionCustomFields = $orderTransaction->getCustomFields() ?? []; + $processedReturns = $transactionCustomFields['unzerRefundDetails']['processedReturns'] ?? []; + + $unprocessedReturns = []; + + foreach ($returns as $return) { + if (isset($processedReturns[$return->getId()])) { + continue; + } + + $unprocessedReturns[] = $return; + } + + return $unprocessedReturns; + } - protected function processRefundItems(RefundItemCollection $items, Context $context) + protected function processRefundItems(RefundItemCollection $items, Context $context): void { foreach ($items->getElements() as $item) { $lineItemId = $item->getId(); @@ -292,7 +282,7 @@ protected function processRefundItems(RefundItemCollection $items, Context $cont } if ($quantity > 0) { $customFields = $lineItem->getCustomFields(); - if (!is_array($customFields)) { + if (!\is_array($customFields)) { $customFields = []; } @@ -306,4 +296,4 @@ protected function processRefundItems(RefundItemCollection $items, Context $cont } } } -} \ No newline at end of file +} diff --git a/src/Components/PaymentActions/Struct/RefundItem.php b/src/Components/PaymentActions/Struct/RefundItem.php index 5eabc68f..cc6e49e7 100644 --- a/src/Components/PaymentActions/Struct/RefundItem.php +++ b/src/Components/PaymentActions/Struct/RefundItem.php @@ -8,16 +8,13 @@ class RefundItem extends Struct { - - public function __construct( protected string $id, protected int $quantity = 0, protected float $amount = 0.0, protected int $resetStockQuantity = 0, protected ?string $label = null - ) - { + ) { } public static function fromArray(array $data): self @@ -55,4 +52,4 @@ public function getLabel(): ?string { return $this->label; } -} \ No newline at end of file +} diff --git a/src/Components/PaymentActions/Struct/RefundItemCollection.php b/src/Components/PaymentActions/Struct/RefundItemCollection.php index 1d930213..ea9e41d4 100644 --- a/src/Components/PaymentActions/Struct/RefundItemCollection.php +++ b/src/Components/PaymentActions/Struct/RefundItemCollection.php @@ -30,12 +30,13 @@ public static function fromArray(array $items): self return $collection; } - public function jsonSerialize():array + public function jsonSerialize(): array { $return = []; foreach ($this->getElements() as $item) { $return[] = $item->jsonSerialize(); } + return $return; } @@ -43,4 +44,4 @@ protected function getExpectedClass(): ?string { return RefundItem::class; } -} \ No newline at end of file +} diff --git a/src/Components/PaymentHandler/AbstractUnzerPaymentHandler.php b/src/Components/PaymentHandler/AbstractUnzerPaymentHandler.php index 5dbffd44..2b81e32d 100755 --- a/src/Components/PaymentHandler/AbstractUnzerPaymentHandler.php +++ b/src/Components/PaymentHandler/AbstractUnzerPaymentHandler.php @@ -93,26 +93,24 @@ abstract class AbstractUnzerPaymentHandler implements AsynchronousPaymentHandler * @param MetadataResourceHydrator $metadataHydrator */ public function __construct( - protected readonly ResourceHydratorInterface $basketHydrator, + protected readonly ResourceHydratorInterface $basketHydrator, protected readonly CustomerResourceHydratorInterface $customerHydrator, - protected readonly ResourceHydratorInterface $metadataHydrator, - protected readonly EntityRepository $transactionRepository, - protected readonly ConfigReaderInterface $configReader, - protected readonly TransactionStateHandlerInterface $transactionStateHandler, - protected readonly ClientFactoryInterface $clientFactory, - protected readonly RequestStack $requestStack, - protected readonly LoggerInterface $logger, - protected readonly CustomFieldsHelperInterface $customFieldsHelper - ) - { + protected readonly ResourceHydratorInterface $metadataHydrator, + protected readonly EntityRepository $transactionRepository, + protected readonly ConfigReaderInterface $configReader, + protected readonly TransactionStateHandlerInterface $transactionStateHandler, + protected readonly ClientFactoryInterface $clientFactory, + protected readonly RequestStack $requestStack, + protected readonly LoggerInterface $logger, + protected readonly CustomFieldsHelperInterface $customFieldsHelper + ) { } public function pay( AsyncPaymentTransactionStruct $transaction, - RequestDataBag $dataBag, - SalesChannelContext $salesChannelContext - ): RedirectResponse - { + RequestDataBag $dataBag, + SalesChannelContext $salesChannelContext + ): RedirectResponse { $this->logger->debug('Starting pay() base method in ' . static::class); $currentRequest = $this->getCurrentRequestFromStack($transaction->getOrderTransaction()->getId()); @@ -169,10 +167,9 @@ public function pay( public function finalize( AsyncPaymentTransactionStruct $transaction, - Request $request, - SalesChannelContext $salesChannelContext - ): void - { + Request $request, + SalesChannelContext $salesChannelContext + ): void { $this->logger->debug('Starting finalize() base method in ' . static::class); try { $this->pluginConfig = $this->configReader->read($salesChannelContext->getSalesChannel()->getId()); @@ -259,7 +256,7 @@ protected function executeFailTransition(string $transactionId, Context $context protected function getUnzerCustomer(string $unzerCustomerId, string $paymentMethodId, OrderTransactionEntity $orderTransaction, SalesChannelContext $salesChannelContext): AbstractUnzerResource { $customer = $salesChannelContext->getCustomer(); - if(empty($orderTransaction->getOrder())){ + if (empty($orderTransaction->getOrder())) { $orderTransaction = $this->fetchTransactionById($orderTransaction->getId(), $salesChannelContext->getContext()); } $fetchedCustomer = null; diff --git a/src/Components/PaymentHandler/Traits/CanRecur.php b/src/Components/PaymentHandler/Traits/CanRecur.php index 4bcf1bfa..7b5d9636 100644 --- a/src/Components/PaymentHandler/Traits/CanRecur.php +++ b/src/Components/PaymentHandler/Traits/CanRecur.php @@ -4,11 +4,8 @@ namespace UnzerPayment6\Components\PaymentHandler\Traits; -use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity; use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; -use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; -use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\System\SalesChannel\SalesChannelContext; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Resources\AbstractUnzerResource; diff --git a/src/Components/PaymentHandler/UnzerWeroPaymentHandler.php b/src/Components/PaymentHandler/UnzerWeroPaymentHandler.php index c80da54d..d633d16e 100644 --- a/src/Components/PaymentHandler/UnzerWeroPaymentHandler.php +++ b/src/Components/PaymentHandler/UnzerWeroPaymentHandler.php @@ -21,6 +21,6 @@ protected function getUnzerPaymentTypeObject(): Wero protected function setBookingMode(): void { $this->bookingMode = BookingMode::CHARGE; - #$this->bookingMode = $this->pluginConfig->get(ConfigReader::CONFIG_KEY_BOOKING_MODE_WERO, BookingMode::CHARGE); + // $this->bookingMode = $this->pluginConfig->get(ConfigReader::CONFIG_KEY_BOOKING_MODE_WERO, BookingMode::CHARGE); } } diff --git a/src/Components/UnzerUtil/UnzerTransactionUtil.php b/src/Components/UnzerUtil/UnzerTransactionUtil.php index 9efdcf88..9b103dfe 100644 --- a/src/Components/UnzerUtil/UnzerTransactionUtil.php +++ b/src/Components/UnzerUtil/UnzerTransactionUtil.php @@ -10,7 +10,6 @@ use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; -use Throwable; use UnzerPayment6\Components\TransactionStateHandler\TransactionStateHandlerInterface; use UnzerPayment6\Installer\CustomFieldInstaller; use UnzerPayment6\Installer\PaymentInstaller; @@ -35,11 +34,10 @@ ]; public function __construct( - protected EntityRepository $orderTransactionRepository, + protected EntityRepository $orderTransactionRepository, protected TransactionStateHandlerInterface $transactionStateHandler, - protected LoggerInterface $logger, - ) - { + protected LoggerInterface $logger, + ) { } public function getOrderTransaction(string $orderTransactionId, Context $context): ?OrderTransactionEntity @@ -73,7 +71,6 @@ public function getOrderTransactionFromOrderNumber(string $orderNumber, Context return $this->orderTransactionRepository->search($criteria, $context)->last(); } - public static function fetchPaymentFromOrderTransaction(OrderTransactionEntity $orderTransaction, Unzer $client): Payment { try { @@ -101,7 +98,7 @@ public function updateOrderTransactionStatus(Unzer $client, OrderTransactionEnti $payment, $context ); - } catch (Throwable $e) { + } catch (\Throwable $e) { $this->logger->error('error updating transaction state from util: ' . $e->getMessage(), ['trace' => $e->getTraceAsString()]); } } @@ -110,6 +107,4 @@ public function updateOrderTransaction(array $data, Context $context): void { $this->orderTransactionRepository->update([$data], $context); } - - } diff --git a/src/Controllers/Administration/UnzerPaymentTransactionController.php b/src/Controllers/Administration/UnzerPaymentTransactionController.php index 4fd12edd..64d16336 100644 --- a/src/Controllers/Administration/UnzerPaymentTransactionController.php +++ b/src/Controllers/Administration/UnzerPaymentTransactionController.php @@ -31,16 +31,15 @@ class UnzerPaymentTransactionController extends AbstractController { public function __construct( - private readonly ClientFactoryInterface $clientFactory, - private readonly UnzerTransactionUtil $unzerTransactionUtil, - private readonly PaymentActionService $paymentTransactionService, + private readonly ClientFactoryInterface $clientFactory, + private readonly UnzerTransactionUtil $unzerTransactionUtil, + private readonly PaymentActionService $paymentTransactionService, private readonly PaymentResourceHydratorInterface $hydrator, - private readonly CancelServiceInterface $cancelService, - private readonly ShipServiceInterface $shipService, - private readonly BasketConverterInterface $basketConverter, - private readonly LoggerInterface $logger - ) - { + private readonly CancelServiceInterface $cancelService, + private readonly ShipServiceInterface $shipService, + private readonly BasketConverterInterface $basketConverter, + private readonly LoggerInterface $logger + ) { } #[Route(path: '/api/_action/unzer-payment/transaction/{orderTransactionId}/details', name: 'api.action.unzer.transaction.details', methods: ['GET'])] @@ -84,8 +83,7 @@ public function fetchTransactionRefundInformation(string $orderTransactionId, Co try { $payment = UnzerTransactionUtil::fetchPaymentFromOrderTransaction($transaction, $client); - - //TODO: kill the overhead + // TODO: kill the overhead $data = $this->hydrator->hydrateArray($payment, $transaction, $client); $transactions = $data['transactions']; $refunds = array_filter($transactions, function (array $transaction) { @@ -102,7 +100,7 @@ public function fetchTransactionRefundInformation(string $orderTransactionId, Co $charges = $payment->getCharges(); // TODO: currently the unified refunds run on the first charge only /** @var Charge $charge */ - $charge = reset($charges);//TODO + $charge = reset($charges); // TODO if ($charge) { $amounts['charged'] = $charge->isSuccess() ? $charge->getAmount() : 0; if ($this->cancelService->isPaylaterPaymentMethod($transaction->getPaymentMethodId())) { @@ -189,25 +187,27 @@ public function unifiedRefund(Request $request, Context $context): JsonResponse } } catch (\Throwable $exception) { $exceptionReturnValues = $this->handleException($exception, 'no order transaction found for unifiedRefund', $exception->getMessage()); + return new JsonResponse($exceptionReturnValues[0], $exceptionReturnValues[1]); } - $amount = (float)$request->get('amount', 0); - $referenceText = (string)$request->get('referenceText', ''); - $items = RefundItemCollection::fromArray((array)$request->get('items', [])); - $comment = (string)$request->get('comment', ''); + $amount = (float) $request->get('amount', 0); + $referenceText = (string) $request->get('referenceText', ''); + $items = RefundItemCollection::fromArray((array) $request->get('items', [])); + $comment = (string) $request->get('comment', ''); try { - $this->paymentTransactionService->doUnifiedRefund( - orderTransaction: $orderTransaction, - amount: $amount, - context: $context, - items: $items, - comment: $comment, - referenceText: $referenceText - ); + $this->paymentTransactionService->doUnifiedRefund( + orderTransaction: $orderTransaction, + amount: $amount, + context: $context, + items: $items, + comment: $comment, + referenceText: $referenceText + ); } catch (UnzerApiException|\Throwable $exception) { $exceptionReturnValues = $this->handleException($exception, \sprintf('Error while executing refund transaction for order transaction [%s]: %s', $orderTransaction->getId(), $exception->getMessage())); + return new JsonResponse($exceptionReturnValues[0], $exceptionReturnValues[1]); } @@ -289,5 +289,4 @@ private function getInvoiceNumber(OrderTransactionEntity $transaction): ?string return $invoiceNumber; } - } diff --git a/src/EventListeners/StateMachine/TransitionEventListener.php b/src/EventListeners/StateMachine/TransitionEventListener.php index 8659dd87..37d17663 100644 --- a/src/EventListeners/StateMachine/TransitionEventListener.php +++ b/src/EventListeners/StateMachine/TransitionEventListener.php @@ -22,7 +22,6 @@ use UnzerPayment6\Components\Event\AutomaticShippingNotificationEvent; use UnzerPayment6\Components\PaymentActions\PaymentActionService; use UnzerPayment6\Components\ShipService\ShipServiceInterface; -use UnzerPayment6\Components\UnzerUtil\UnzerTransactionUtil; use UnzerPayment6\Components\Validator\AutomaticShippingValidatorInterface; use UnzerPayment6\Installer\CustomFieldInstaller; @@ -118,7 +117,6 @@ protected function doAutomaticTransactions(StateMachineTransitionEvent $event, ? } if (\is_array($autoCaptureStatus) && \in_array($event->getToPlace()->getId(), $autoCaptureStatus, true)) { - $this->logger->info(\sprintf('Automatic capture for order [%s] was triggered', $order->getOrderNumber())); try { $this->paymentActionService->captureOrder($order, $event->getContext()); } catch (\Throwable $exception) { @@ -157,8 +155,6 @@ protected function doAutomaticTransactions(StateMachineTransitionEvent $event, ? ]); } } - - } protected function setCustomFields( diff --git a/src/Installer/PaymentInstaller.php b/src/Installer/PaymentInstaller.php index aedcde70..64640348 100755 --- a/src/Installer/PaymentInstaller.php +++ b/src/Installer/PaymentInstaller.php @@ -5,6 +5,7 @@ namespace UnzerPayment6\Installer; use League\Flysystem\Filesystem; +use Shopware\Core\Checkout\Payment\Aggregate\PaymentMethodTranslation\PaymentMethodTranslationEntity; use Shopware\Core\Checkout\Payment\PaymentMethodEntity; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; @@ -153,16 +154,16 @@ class PaymentInstaller implements InstallerInterface [ 'id' => self::PAYMENT_ID_IDEAL, 'handlerIdentifier' => UnzerIdealPaymentHandler::class, - 'name' => 'iDEAL', + 'name' => 'iDEAL | Wero', 'technicalName' => 'unzer_ideal', 'translations' => [ 'de-DE' => [ - 'name' => 'iDEAL', - 'description' => 'iDEAL Zahlungen mit Unzer payments', + 'name' => 'iDEAL | Wero', + 'description' => 'iDEAL | Wero Zahlungen mit Unzer payments', ], 'en-GB' => [ - 'name' => 'iDEAL', - 'description' => 'iDEAL payments with Unzer payments', + 'name' => 'iDEAL | Wero', + 'description' => 'iDEAL | Wero payments with Unzer payments', ], ], ], @@ -511,6 +512,55 @@ private function upsertPaymentMethods(InstallContext $context): void } $this->removeOldPaymentMethods($context); $this->deprecatePaymentMethods($context); + $this->renameIdeal($context->getContext()); + } + + private function renameIdeal(Context $context): void + { + $criteria = new Criteria([self::PAYMENT_ID_IDEAL]); + $criteria->addAssociation('translations.language.locale'); + /** @var PaymentMethodEntity $existingPaymentMethod */ + $existingPaymentMethod = $this->paymentMethodRepository->search($criteria, $context)->first(); + if ($existingPaymentMethod === null) { + return; + } + $translations = []; + /** @var PaymentMethodTranslationEntity $translation */ + foreach ($existingPaymentMethod->getTranslations()->getElements() as $uniqueId => $translation) { + $newName = null; + $newDescription = null; + if (stripos($translation->getName(), 'wero') === false) { + $newName = str_replace('iDEAL', 'iDEAL | Wero', $translation->getName()); + } + if (stripos($translation->getDescription(), 'wero') === false) { + $newDescription = str_replace('iDEAL', 'iDEAL | Wero', $translation->getDescription()); + } + + if ($newName === null && $newDescription === null) { + continue; + } + + $localeCode = $translation->getLanguage()->getLocale()->getCode(); + + $translations[$localeCode] = [ + 'languageId' => $translation->getLanguageId(), + ]; + if ($newName !== null) { + $translations[$localeCode]['name'] = $newName; + } + if ($newDescription !== null) { + $translations[$localeCode]['description'] = $newDescription; + } + } + + if (empty($translations)) { + return; + } + + $this->paymentMethodRepository->update([[ + 'id' => $existingPaymentMethod->getId(), + 'translations' => $translations, + ]], $context); } private function deprecatePaymentMethods(InstallContext $context): void diff --git a/src/Resources/app/administration/src/module/unzer-payment-configuration/page/unzer-payment-settings/unzer-payment-settings.html.twig b/src/Resources/app/administration/src/module/unzer-payment-configuration/page/unzer-payment-settings/unzer-payment-settings.html.twig index 66dd32b0..627b665b 100644 --- a/src/Resources/app/administration/src/module/unzer-payment-configuration/page/unzer-payment-settings/unzer-payment-settings.html.twig +++ b/src/Resources/app/administration/src/module/unzer-payment-configuration/page/unzer-payment-settings/unzer-payment-settings.html.twig @@ -86,6 +86,9 @@ size="16px" :class="{'unzer-additional-keys__title-icon': true, 'is-expanded': isAdditionalKeysExpanded}" > +
t.handleResponse(e))}registerWebhooks(e){return this.httpClient.post(`_action/${this.getApiBasePath()}/register-webhooks`,e,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}clearWebhooks(e){return this.httpClient.post(`_action/${this.getApiBasePath()}/clear-webhooks`,e,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}getWebhooks(e){return this.httpClient.post(`_action/${this.getApiBasePath()}/get-webhooks`,{privateKey:e},{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}getGooglePayGatewayMerchantId(e){return this.httpClient.get(`_action/${this.getApiBasePath()}/get-google-pay-gateway-merchant-id?salesChannelId=${e||""}`,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}}e.addServiceProvider("UnzerPaymentConfigurationService",t=>new n(e.getContainer("init").httpClient,t.loginService))},748:function(){let{Application:e}=Shopware,t=Shopware.Classes.ApiService;class n extends t{constructor(e,t,n="unzer-payment"){super(e,t,n)}fetchPaymentDetails(e){let n=`_action/${this.getApiBasePath()}/transaction/${e}/details`;return this.httpClient.get(n,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}chargeTransaction(e,n,a){let s=`_action/${this.getApiBasePath()}/transaction/${e}/charge/${a}`;return this.httpClient.get(s,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}refundTransaction(e,n,a,s=null){let i=`_action/${this.getApiBasePath()}/transaction/${e}/refund/${n}/${a}`;return null!==s&&(i=`${i}/${s}`),this.httpClient.get(i,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}cancelTransaction(e,n,a){let s=`_action/${this.getApiBasePath()}/transaction/${e}/cancel/${n}/${a}`;return this.httpClient.get(s,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}ship(e){let n=`_action/${this.getApiBasePath()}/transaction/${e}/ship`;return this.httpClient.get(n,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}}e.addServiceProvider("UnzerPaymentService",t=>new n(e.getContainer("init").httpClient,t.loginService))},337:function(){let{Component:e}=Shopware,{Criteria:t,EntityCollection:n}=Shopware.Data;e.extend("unzer-entity-multi-select-delivery-status","sw-entity-multi-id-select",{inject:["repositoryFactory"],props:{repository:{type:Object,required:!0,default(){return this.repositoryFactory.create("state_machine_state")}},criteria:{type:Object,required:!1,default(){let e=new t(1,100);return e.addFilter(t.equals("stateMachine.technicalName","order_delivery.state")),e}},entityCollection(){}}})},708:function(){let{Component:e}=Shopware,{Criteria:t}=Shopware.Data;e.extend("unzer-entity-single-select-delivery-status","sw-entity-single-select",{props:{criteria:{type:Object,required:!1,default(){let e=new t(1,100);return e.addFilter(t.equals("stateMachine.technicalName","order_delivery.state")),e}}}})},129:function(e,t,n){var a=n(296);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("0620ec53",a,!0,{})},425:function(e,t,n){var a=n(906);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("f0afdb6a",a,!0,{})},345:function(e,t,n){var a=n(836);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("61f99e4d",a,!0,{})},90:function(e,t,n){var a=n(325);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("05921a3e",a,!0,{})},34:function(e,t,n){var a=n(299);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("3bbcbade",a,!0,{})},534:function(e,t,n){"use strict";function a(e,t){for(var n=[],a={},s=0;sn.parts.length&&(a.parts.length=n.parts.length)}else{for(var i=[],s=0;s\n {% block unzer_payment_actions_amount_field %}\n
\n \n \n
\n {% endblock %}\n
\n \n {% block unzer_payment_actions_charge_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.chargeButton\') }}\n \n {% endblock %}\n\n {% block unzer_payment_actions_cancel_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.cancelButton\') }}\n \n {% endblock %}\n \n \n {% block unzer_payment_actions_reason_field %}\n \n \n {% endblock %}\n\n {% block unzer_payment_actions_refund_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.refundButton\') }}\n \n {% endblock %}\n \n {% block unzer_payment_actions_button_container_inner %}{% endblock %}\n
\n \n\n
\n {{ $tc(\'unzer-payment.paymentDetails.actions.noActions\') }}\n
\n{% endblock %}',inject:["UnzerPaymentService"],mixins:[t.getByName("notification")],data(){return{isLoading:!1,isSuccessful:!1,transactionAmount:0,reasonCode:null}},props:{transactionResource:{type:Object,required:!0},paymentResource:{type:Object,required:!0},decimalPrecision:{type:Number,required:!0,default:4}},computed:{isChargePossible:function(){return"authorization"===this.transactionResource.type&&"error"!==this.transactionResource.state},isRefundPossible:function(){return"charge"===this.transactionResource.type&&"error"!==this.transactionResource.state&&!(this.transactionResource.isFirst&&"085b64d0028a8bd447294e03c4eb411a"===this.paymentResource.paymentMethodId&&"pending"!==this.paymentResource.state.name&&"partly"!==this.paymentResource.state.name)},maxTransactionAmount(){let e=0,t=this.isRefundPossible&&"085b64d0028a8bd447294e03c4eb411a"===this.paymentResource.paymentMethodId;return this.isRefundPossible&&(e=this.transactionResource.amount),this.isChargePossible&&(e=this.paymentResource.amount.remaining),"remainingAmount"in this.transactionResource&&(e=this.transactionResource.remainingAmount),this.transactionResource.isFirst&&t&&(e=this.paymentResource.amount.remaining),e/10**this.paymentResource.amount.decimalPrecision},reasonCodeSelection(){return[{label:this.$tc("unzer-payment.paymentDetails.actions.reason.cancel"),value:"CANCEL"},{label:this.$tc("unzer-payment.paymentDetails.actions.reason.credit"),value:"CREDIT"},{label:this.$tc("unzer-payment.paymentDetails.actions.reason.return"),value:"RETURN"}]}},created(){this.transactionAmount=this.maxTransactionAmount},methods:{charge(){this.isLoading=!0,this.UnzerPaymentService.chargeTransaction(this.paymentResource.orderTransactionId,this.transactionResource.id,this.transactionAmount).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.chargeSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.chargeSuccessMessage")}),this.isSuccessful=!0,this.$emit("reload")}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.genericErrorMessage")),"paylater-invoice-document-required"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.paylaterInvoiceDocumentRequiredErrorMessage")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.chargeErrorTitle"),message:t}),this.isLoading=!1})},refund(){this.isLoading=!0,this.UnzerPaymentService.refundTransaction(this.paymentResource.orderTransactionId,this.transactionResource.id,this.transactionAmount,this.reasonCode).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.refundSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.refundSuccessMessage")}),this.isSuccessful=!0,this.$emit("reload")}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.genericErrorMessage")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.refundErrorTitle"),message:t}),this.isLoading=!1})},startCancel(){this.$emit("cancel",this.transactionAmount)}}});let{Component:a,Mixin:s,Module:i}=Shopware;a.register("unzer-payment-detail",{template:'{% block unzer_payment_detail %}\n \n \n {% block unzer_payment_detail_footer %}\n \n {% block unzer_payment_detail_ship_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.shipButton\') }}\n \n {% endblock %}\n \n {% endblock %}\n \n{% endblock %}',inject:["UnzerPaymentService"],mixins:[s.getByName("notification")],data(){return{isLoading:!1,isSuccessful:!1,paylaterPaymentMethods:["09588ffee8064f168e909ff31889dd7f","12fbfbce271a43a89b3783453b88e9a6","6d6adcd4b7bf40499873c294a85f32ed"]}},props:{paymentResource:{type:Object,required:!0}},computed:{unzerMaxDigits(){let e=i.getModuleRegistry().get("unzer-payment");return e&&e.manifest?e.manifest.maxDigits:4},remainingAmount(){return this.paymentResource&&this.paymentResource.amount?this.formatAmount(this.paymentResource.amount.remaining,this.paymentResource.amount.decimalPrecision):0},cancelledAmount(){return this.paymentResource&&this.paymentResource.amount?this.formatAmount(this.paymentResource.amount.cancelled,this.paymentResource.amount.decimalPrecision):0},chargedAmount(){return this.paymentResource&&this.paymentResource.amount?this.formatAmount(this.paymentResource.amount.charged,this.paymentResource.amount.decimalPrecision):0}},methods:{reloadOrderDetail(){this.$emit("reloadOrderDetails")},ship(){this.isLoading=!0,this.UnzerPaymentService.ship(this.paymentResource.orderTransactionId).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.shipSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.shipSuccessMessage")}),this.isSuccessful=!0,this.$emit("reload")}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t?t=this.$tc("unzer-payment.paymentDetails.notifications.genericErrorMessage"):"invoice-missing-error"===t?t=this.$tc("unzer-payment.paymentDetails.notifications.invoiceNotFoundMessage"):"documentdate-missing-error"===t?t=this.$tc("unzer-payment.paymentDetails.notifications.documentDateMissingError"):"payment-missing-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.paymentMissingError")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.shipErrorTitle"),message:t}),this.isLoading=!1})},formatAmount(e,t){return e/10**Math.min(this.unzerMaxDigits,t)},formatCurrency(e){return Shopware.Utils.format.currency(e||0,this.paymentResource.currency)},isPaylaterPaymentMethod(e){return this.paylaterPaymentMethods.indexOf(e)>=0}}});let{Component:r,Module:o,Mixin:c}=Shopware;r.register("unzer-payment-history",{template:'{% block unzer_payment_history %}\n \n {% block unzer_payment_history_container %}\n \n {% endblock %}\n \n{% endblock %}',inject:["repositoryFactory","UnzerPaymentService"],mixins:[c.getByName("notification")],data(){return{showCancelModal:!1,isCancelLoading:!1,cancelAmount:0}},props:{paymentResource:{type:Object,required:!0}},computed:{unzerMaxDigits(){let e=o.getModuleRegistry().get("unzer-payment");return e&&e.manifest?e.manifest.maxDigits:4},orderTransactionRepository:function(){return this.repositoryFactory.create("order_transaction")},decimalPrecision(){return this.paymentResource&&this.paymentResource.amount&&this.paymentResource.amount.decimalPrecision?Math.min(this.unzerMaxDigits,this.paymentResource.amount.decimalPrecision):this.unzerMaxDigits},data:function(){let e=[];return Object.values(this.paymentResource.transactions).forEach(t=>{let n=this.formatCurrency(this.formatAmount(parseFloat(t.amount),this.decimalPrecision)),a=Shopware.Filter.getByName("date")(t.date,{hour:"numeric",minute:"numeric",second:"numeric"});e.push({type:this.transactionTypeRenderer(t.type),amount:n,date:a,resource:t})}),e},columns:function(){return[{property:"type",label:this.$tc("unzer-payment.paymentDetails.history.column.type"),rawData:!0},{property:"amount",label:this.$tc("unzer-payment.paymentDetails.history.column.amount"),rawData:!0},{property:"date",label:this.$tc("unzer-payment.paymentDetails.history.column.date"),rawData:!0}]}},methods:{transactionTypeRenderer:function(e){switch(e){case"authorization":return this.$tc("unzer-payment.paymentDetails.history.type.authorization");case"charge":return this.$tc("unzer-payment.paymentDetails.history.type.charge");case"shipment":return this.$tc("unzer-payment.paymentDetails.history.type.shipment");case"refund":return this.$tc("unzer-payment.paymentDetails.history.type.refund");case"cancellation":return this.$tc("unzer-payment.paymentDetails.history.type.cancellation");default:return this.$tc("unzer-payment.paymentDetails.history.type.default")}},reload:function(){this.$emit("reload"),this.$emit("reloadOrderDetails")},formatAmount(e,t){return e/10**t},openCancelModal(e,t){this.showCancelModal=e.resource.id,this.cancelAmount=t},closeCancelModal(){this.showCancelModal=!1,this.cancelAmount=0},cancel(){this.isCancelLoading=!0,this.UnzerPaymentService.cancelTransaction(this.paymentResource.orderTransactionId,this.paymentResource.id,this.cancelAmount).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.cancelSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.cancelSuccessMessage")}),this.reload()}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.cancelErrorMessage")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.cancelErrorTitle"),message:t}),this.isCancelLoading=!1,this.reload()})},formatCurrency(e){return Shopware.Utils.format.currency(e||0,this.paymentResource.currency)}}});let{Component:l}=Shopware;l.register("unzer-payment-metadata",{template:'{% block unzer_payment_metadata %}\n
\n{% endblock %}',snippets:{"de-DE":w,"en-GB":z}}),n(34)}()}(); \ No newline at end of file +!function(){var e={296:function(){},906:function(){},836:function(){},325:function(){},299:function(){},963:function(){let{Application:e}=Shopware,t=Shopware.Classes.ApiService;class n extends t{constructor(e,t,n="unzer-payment"){super(e,t,n)}validateCredentials(e){return this.httpClient.post(`_action/${this.getApiBasePath()}/validate-credentials`,e,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}registerWebhooks(e){return this.httpClient.post(`_action/${this.getApiBasePath()}/register-webhooks`,e,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}clearWebhooks(e){return this.httpClient.post(`_action/${this.getApiBasePath()}/clear-webhooks`,e,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}getWebhooks(e){return this.httpClient.post(`_action/${this.getApiBasePath()}/get-webhooks`,{privateKey:e},{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}getGooglePayGatewayMerchantId(e){return this.httpClient.get(`_action/${this.getApiBasePath()}/get-google-pay-gateway-merchant-id?salesChannelId=${e||""}`,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}}e.addServiceProvider("UnzerPaymentConfigurationService",t=>new n(e.getContainer("init").httpClient,t.loginService))},748:function(){let{Application:e}=Shopware,t=Shopware.Classes.ApiService;class n extends t{constructor(e,t,n="unzer-payment"){super(e,t,n)}fetchPaymentDetails(e){let n=`_action/${this.getApiBasePath()}/transaction/${e}/details`;return this.httpClient.get(n,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}chargeTransaction(e,n,a){let s=`_action/${this.getApiBasePath()}/transaction/${e}/charge/${a}`;return this.httpClient.get(s,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}refundTransaction(e,n,a,s=null){let i=`_action/${this.getApiBasePath()}/transaction/${e}/refund/${n}/${a}`;return null!==s&&(i=`${i}/${s}`),this.httpClient.get(i,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}cancelTransaction(e,n,a){let s=`_action/${this.getApiBasePath()}/transaction/${e}/cancel/${n}/${a}`;return this.httpClient.get(s,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}ship(e){let n=`_action/${this.getApiBasePath()}/transaction/${e}/ship`;return this.httpClient.get(n,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}}e.addServiceProvider("UnzerPaymentService",t=>new n(e.getContainer("init").httpClient,t.loginService))},337:function(){let{Component:e}=Shopware,{Criteria:t,EntityCollection:n}=Shopware.Data;e.extend("unzer-entity-multi-select-delivery-status","sw-entity-multi-id-select",{inject:["repositoryFactory"],props:{repository:{type:Object,required:!0,default(){return this.repositoryFactory.create("state_machine_state")}},criteria:{type:Object,required:!1,default(){let e=new t(1,100);return e.addFilter(t.equals("stateMachine.technicalName","order_delivery.state")),e}},entityCollection(){}}})},708:function(){let{Component:e}=Shopware,{Criteria:t}=Shopware.Data;e.extend("unzer-entity-single-select-delivery-status","sw-entity-single-select",{props:{criteria:{type:Object,required:!1,default(){let e=new t(1,100);return e.addFilter(t.equals("stateMachine.technicalName","order_delivery.state")),e}}}})},129:function(e,t,n){var a=n(296);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("0620ec53",a,!0,{})},425:function(e,t,n){var a=n(906);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("f0afdb6a",a,!0,{})},345:function(e,t,n){var a=n(836);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("61f99e4d",a,!0,{})},90:function(e,t,n){var a=n(325);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("05921a3e",a,!0,{})},34:function(e,t,n){var a=n(299);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("3bbcbade",a,!0,{})},534:function(e,t,n){"use strict";function a(e,t){for(var n=[],a={},s=0;sn.parts.length&&(a.parts.length=n.parts.length)}else{for(var i=[],s=0;s\n {% block unzer_payment_actions_amount_field %}\n
\n \n \n
\n {% endblock %}\n
\n \n {% block unzer_payment_actions_charge_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.chargeButton\') }}\n \n {% endblock %}\n\n {% block unzer_payment_actions_cancel_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.cancelButton\') }}\n \n {% endblock %}\n \n \n {% block unzer_payment_actions_reason_field %}\n \n \n {% endblock %}\n\n {% block unzer_payment_actions_refund_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.refundButton\') }}\n \n {% endblock %}\n \n {% block unzer_payment_actions_button_container_inner %}{% endblock %}\n
\n \n\n
\n {{ $tc(\'unzer-payment.paymentDetails.actions.noActions\') }}\n
\n{% endblock %}',inject:["UnzerPaymentService"],mixins:[t.getByName("notification")],data(){return{isLoading:!1,isSuccessful:!1,transactionAmount:0,reasonCode:null}},props:{transactionResource:{type:Object,required:!0},paymentResource:{type:Object,required:!0},decimalPrecision:{type:Number,required:!0,default:4}},computed:{isChargePossible:function(){return"authorization"===this.transactionResource.type&&"error"!==this.transactionResource.state},isRefundPossible:function(){return"charge"===this.transactionResource.type&&"error"!==this.transactionResource.state&&!(this.transactionResource.isFirst&&"085b64d0028a8bd447294e03c4eb411a"===this.paymentResource.paymentMethodId&&"pending"!==this.paymentResource.state.name&&"partly"!==this.paymentResource.state.name)},maxTransactionAmount(){let e=0,t=this.isRefundPossible&&"085b64d0028a8bd447294e03c4eb411a"===this.paymentResource.paymentMethodId;return this.isRefundPossible&&(e=this.transactionResource.amount),this.isChargePossible&&(e=this.paymentResource.amount.remaining),"remainingAmount"in this.transactionResource&&(e=this.transactionResource.remainingAmount),this.transactionResource.isFirst&&t&&(e=this.paymentResource.amount.remaining),e/10**this.paymentResource.amount.decimalPrecision},reasonCodeSelection(){return[{label:this.$tc("unzer-payment.paymentDetails.actions.reason.cancel"),value:"CANCEL"},{label:this.$tc("unzer-payment.paymentDetails.actions.reason.credit"),value:"CREDIT"},{label:this.$tc("unzer-payment.paymentDetails.actions.reason.return"),value:"RETURN"}]}},created(){this.transactionAmount=this.maxTransactionAmount},methods:{charge(){this.isLoading=!0,this.UnzerPaymentService.chargeTransaction(this.paymentResource.orderTransactionId,this.transactionResource.id,this.transactionAmount).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.chargeSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.chargeSuccessMessage")}),this.isSuccessful=!0,this.$emit("reload")}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.genericErrorMessage")),"paylater-invoice-document-required"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.paylaterInvoiceDocumentRequiredErrorMessage")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.chargeErrorTitle"),message:t}),this.isLoading=!1})},refund(){this.isLoading=!0,this.UnzerPaymentService.refundTransaction(this.paymentResource.orderTransactionId,this.transactionResource.id,this.transactionAmount,this.reasonCode).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.refundSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.refundSuccessMessage")}),this.isSuccessful=!0,this.$emit("reload")}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.genericErrorMessage")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.refundErrorTitle"),message:t}),this.isLoading=!1})},startCancel(){this.$emit("cancel",this.transactionAmount)}}});let{Component:a,Mixin:s,Module:i}=Shopware;a.register("unzer-payment-detail",{template:'{% block unzer_payment_detail %}\n \n \n {% block unzer_payment_detail_footer %}\n \n {% block unzer_payment_detail_ship_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.shipButton\') }}\n \n {% endblock %}\n \n {% endblock %}\n \n{% endblock %}',inject:["UnzerPaymentService"],mixins:[s.getByName("notification")],data(){return{isLoading:!1,isSuccessful:!1,paylaterPaymentMethods:["09588ffee8064f168e909ff31889dd7f","12fbfbce271a43a89b3783453b88e9a6","6d6adcd4b7bf40499873c294a85f32ed"]}},props:{paymentResource:{type:Object,required:!0}},computed:{unzerMaxDigits(){let e=i.getModuleRegistry().get("unzer-payment");return e&&e.manifest?e.manifest.maxDigits:4},remainingAmount(){return this.paymentResource&&this.paymentResource.amount?this.formatAmount(this.paymentResource.amount.remaining,this.paymentResource.amount.decimalPrecision):0},cancelledAmount(){return this.paymentResource&&this.paymentResource.amount?this.formatAmount(this.paymentResource.amount.cancelled,this.paymentResource.amount.decimalPrecision):0},chargedAmount(){return this.paymentResource&&this.paymentResource.amount?this.formatAmount(this.paymentResource.amount.charged,this.paymentResource.amount.decimalPrecision):0}},methods:{reloadOrderDetail(){this.$emit("reloadOrderDetails")},ship(){this.isLoading=!0,this.UnzerPaymentService.ship(this.paymentResource.orderTransactionId).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.shipSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.shipSuccessMessage")}),this.isSuccessful=!0,this.$emit("reload")}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t?t=this.$tc("unzer-payment.paymentDetails.notifications.genericErrorMessage"):"invoice-missing-error"===t?t=this.$tc("unzer-payment.paymentDetails.notifications.invoiceNotFoundMessage"):"documentdate-missing-error"===t?t=this.$tc("unzer-payment.paymentDetails.notifications.documentDateMissingError"):"payment-missing-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.paymentMissingError")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.shipErrorTitle"),message:t}),this.isLoading=!1})},formatAmount(e,t){return e/10**Math.min(this.unzerMaxDigits,t)},formatCurrency(e){return Shopware.Utils.format.currency(e||0,this.paymentResource.currency)},isPaylaterPaymentMethod(e){return this.paylaterPaymentMethods.indexOf(e)>=0}}});let{Component:r,Module:o,Mixin:c}=Shopware;r.register("unzer-payment-history",{template:'{% block unzer_payment_history %}\n \n {% block unzer_payment_history_container %}\n \n {% endblock %}\n \n{% endblock %}',inject:["repositoryFactory","UnzerPaymentService"],mixins:[c.getByName("notification")],data(){return{showCancelModal:!1,isCancelLoading:!1,cancelAmount:0}},props:{paymentResource:{type:Object,required:!0}},computed:{unzerMaxDigits(){let e=o.getModuleRegistry().get("unzer-payment");return e&&e.manifest?e.manifest.maxDigits:4},orderTransactionRepository:function(){return this.repositoryFactory.create("order_transaction")},decimalPrecision(){return this.paymentResource&&this.paymentResource.amount&&this.paymentResource.amount.decimalPrecision?Math.min(this.unzerMaxDigits,this.paymentResource.amount.decimalPrecision):this.unzerMaxDigits},data:function(){let e=[];return Object.values(this.paymentResource.transactions).forEach(t=>{let n=this.formatCurrency(this.formatAmount(parseFloat(t.amount),this.decimalPrecision)),a=Shopware.Filter.getByName("date")(t.date,{hour:"numeric",minute:"numeric",second:"numeric"});e.push({type:this.transactionTypeRenderer(t.type),amount:n,date:a,resource:t})}),e},columns:function(){return[{property:"type",label:this.$tc("unzer-payment.paymentDetails.history.column.type"),rawData:!0},{property:"amount",label:this.$tc("unzer-payment.paymentDetails.history.column.amount"),rawData:!0},{property:"date",label:this.$tc("unzer-payment.paymentDetails.history.column.date"),rawData:!0}]}},methods:{transactionTypeRenderer:function(e){switch(e){case"authorization":return this.$tc("unzer-payment.paymentDetails.history.type.authorization");case"charge":return this.$tc("unzer-payment.paymentDetails.history.type.charge");case"shipment":return this.$tc("unzer-payment.paymentDetails.history.type.shipment");case"refund":return this.$tc("unzer-payment.paymentDetails.history.type.refund");case"cancellation":return this.$tc("unzer-payment.paymentDetails.history.type.cancellation");default:return this.$tc("unzer-payment.paymentDetails.history.type.default")}},reload:function(){this.$emit("reload"),this.$emit("reloadOrderDetails")},formatAmount(e,t){return e/10**t},openCancelModal(e,t){this.showCancelModal=e.resource.id,this.cancelAmount=t},closeCancelModal(){this.showCancelModal=!1,this.cancelAmount=0},cancel(){this.isCancelLoading=!0,this.UnzerPaymentService.cancelTransaction(this.paymentResource.orderTransactionId,this.paymentResource.id,this.cancelAmount).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.cancelSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.cancelSuccessMessage")}),this.reload()}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.cancelErrorMessage")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.cancelErrorTitle"),message:t}),this.isCancelLoading=!1,this.reload()})},formatCurrency(e){return Shopware.Utils.format.currency(e||0,this.paymentResource.currency)}}});let{Component:l}=Shopware;l.register("unzer-payment-metadata",{template:'{% block unzer_payment_metadata %}\n