From c7349c71c8fd47dee0cd4ec80d5fcc3e39eac408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 16 Jun 2020 10:54:41 +0200 Subject: [PATCH 01/13] Add basic payment classes --- src/Configuration/ConfigurationPrefixes.php | 3 + src/DependencyInjection/handlers.xml | 12 ++ src/DependencyInjection/requests.xml | 23 +++ src/Installer/PaymentMethodInstaller.php | 2 + .../PayoneIDealPaymentHandler.php | 154 ++++++++++++++++++ src/PaymentMethod/PayoneIDeal.php | 42 +++++ .../IDeal/AbstractIDealAuthorizeRequest.php | 67 ++++++++ .../AbstractIDealAuthorizeRequestFactory.php | 56 +++++++ .../Request/IDeal/IDealAuthorizeRequest.php | 18 ++ .../IDeal/IDealAuthorizeRequestFactory.php | 9 + .../IDeal/IDealPreAuthorizeRequest.php | 18 ++ .../IDeal/IDealPreAuthorizeRequestFactory.php | 9 + .../translations/de_DE/messages.de-DE.json | 4 + .../translations/en_GB/messages.en-GB.json | 4 + .../payone/ideal/ideal-form.html.twig | 54 ++++++ 15 files changed, 475 insertions(+) create mode 100644 src/PaymentHandler/PayoneIDealPaymentHandler.php create mode 100644 src/PaymentMethod/PayoneIDeal.php create mode 100644 src/Payone/Request/IDeal/AbstractIDealAuthorizeRequest.php create mode 100644 src/Payone/Request/IDeal/AbstractIDealAuthorizeRequestFactory.php create mode 100644 src/Payone/Request/IDeal/IDealAuthorizeRequest.php create mode 100644 src/Payone/Request/IDeal/IDealAuthorizeRequestFactory.php create mode 100644 src/Payone/Request/IDeal/IDealPreAuthorizeRequest.php create mode 100644 src/Payone/Request/IDeal/IDealPreAuthorizeRequestFactory.php create mode 100644 src/Resources/views/storefront/payone/ideal/ideal-form.html.twig diff --git a/src/Configuration/ConfigurationPrefixes.php b/src/Configuration/ConfigurationPrefixes.php index 21faa0d22..be38de143 100644 --- a/src/Configuration/ConfigurationPrefixes.php +++ b/src/Configuration/ConfigurationPrefixes.php @@ -6,6 +6,7 @@ use PayonePayment\PaymentHandler\PayoneCreditCardPaymentHandler; use PayonePayment\PaymentHandler\PayoneDebitPaymentHandler; +use PayonePayment\PaymentHandler\PayoneIDealPaymentHandler; use PayonePayment\PaymentHandler\PayonePayolutionDebitPaymentHandler; use PayonePayment\PaymentHandler\PayonePayolutionInstallmentPaymentHandler; use PayonePayment\PaymentHandler\PayonePayolutionInvoicingPaymentHandler; @@ -23,6 +24,7 @@ interface ConfigurationPrefixes public const CONFIGURATION_PREFIX_PAYOLUTION_INSTALLMENT = 'payolutionInstallment'; public const CONFIGURATION_PREFIX_PAYOLUTION_DEBIT = 'payolutionDebit'; public const CONFIGURATION_PREFIX_SOFORT = 'sofort'; + public const CONFIGURATION_PREFIX_IDEAL = 'iDeal'; public const CONFIGURATION_PREFIXES = [ PayoneCreditCardPaymentHandler::class => self::CONFIGURATION_PREFIX_CREDITCARD, @@ -33,5 +35,6 @@ interface ConfigurationPrefixes PayonePayolutionInstallmentPaymentHandler::class => self::CONFIGURATION_PREFIX_PAYOLUTION_INSTALLMENT, PayonePayolutionDebitPaymentHandler::class => self::CONFIGURATION_PREFIX_PAYOLUTION_DEBIT, PayoneSofortBankingPaymentHandler::class => self::CONFIGURATION_PREFIX_SOFORT, + PayoneIDealPaymentHandler::class => self::CONFIGURATION_PREFIX_IDEAL, ]; } diff --git a/src/DependencyInjection/handlers.xml b/src/DependencyInjection/handlers.xml index a043c05a5..ef91d1d13 100644 --- a/src/DependencyInjection/handlers.xml +++ b/src/DependencyInjection/handlers.xml @@ -126,5 +126,17 @@ + + + + + + + + + + + + diff --git a/src/DependencyInjection/requests.xml b/src/DependencyInjection/requests.xml index 98ac9cbcf..5ab492a6f 100644 --- a/src/DependencyInjection/requests.xml +++ b/src/DependencyInjection/requests.xml @@ -173,6 +173,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Installer/PaymentMethodInstaller.php b/src/Installer/PaymentMethodInstaller.php index 420d4c4c7..2742edc29 100644 --- a/src/Installer/PaymentMethodInstaller.php +++ b/src/Installer/PaymentMethodInstaller.php @@ -8,6 +8,7 @@ use PayonePayment\PaymentMethod\PaymentMethodInterface; use PayonePayment\PaymentMethod\PayoneCreditCard; use PayonePayment\PaymentMethod\PayoneDebit; +use PayonePayment\PaymentMethod\PayoneIDeal; use PayonePayment\PaymentMethod\PayonePayolutionDebit; use PayonePayment\PaymentMethod\PayonePayolutionInstallment; use PayonePayment\PaymentMethod\PayonePayolutionInvoicing; @@ -37,6 +38,7 @@ class PaymentMethodInstaller implements InstallerInterface PayonePayolutionInvoicing::class, PayonePayolutionDebit::class, PayoneSofortBanking::class, + PayoneIDeal::class, ]; /** @var PluginIdProvider */ diff --git a/src/PaymentHandler/PayoneIDealPaymentHandler.php b/src/PaymentHandler/PayoneIDealPaymentHandler.php new file mode 100644 index 000000000..cf129877f --- /dev/null +++ b/src/PaymentHandler/PayoneIDealPaymentHandler.php @@ -0,0 +1,154 @@ +preAuthRequestFactory = $preAuthRequestFactory; + $this->authRequestFactory = $authRequestFactory; + $this->client = $client; + $this->translator = $translator; + $this->dataHandler = $dataHandler; + $this->stateHandler = $stateHandler; + } + + /** + * {@inheritdoc} + */ + public function pay(AsyncPaymentTransactionStruct $transaction, RequestDataBag $dataBag, SalesChannelContext $salesChannelContext): RedirectResponse + { + // Get configured authorization method + $authorizationMethod = $this->getAuthorizationMethod( + $transaction->getOrder()->getSalesChannelId(), + 'iDealAuthorizationMethod', + 'authorization' + ); + + $paymentTransaction = PaymentTransaction::fromAsyncPaymentTransactionStruct($transaction); + + // Select request factory based on configured authorization method + $factory = $authorizationMethod === 'preauthorization' + ? $this->preAuthRequestFactory + : $this->authRequestFactory; + + $request = $factory->getRequestParameters( + $paymentTransaction, + $salesChannelContext + ); + + try { + $response = $this->client->request($request); + } catch (PayoneRequestException $exception) { + throw new AsyncPaymentProcessException( + $transaction->getOrderTransaction()->getId(), + $exception->getResponse()['error']['CustomerMessage'] + ); + } catch (Throwable $exception) { + throw new AsyncPaymentProcessException( + $transaction->getOrderTransaction()->getId(), + $this->translator->trans('PayonePayment.errorMessages.genericError') + ); + } + + if (empty($response['status']) && $response['status'] !== 'REDIRECT') { + throw new AsyncPaymentProcessException( + $transaction->getOrderTransaction()->getId(), + $this->translator->trans('PayonePayment.errorMessages.genericError') + ); + } + + // Prepare custom fields for the transaction + $data = $this->prepareTransactionCustomFields($request, $response, [ + CustomFieldInstaller::TRANSACTION_STATE => $response['status'], + CustomFieldInstaller::ALLOW_CAPTURE => false, + CustomFieldInstaller::ALLOW_REFUND => false, + ]); + + $this->dataHandler->saveTransactionData($paymentTransaction, $salesChannelContext->getContext(), $data); + $this->dataHandler->logResponse($paymentTransaction, $salesChannelContext->getContext(), ['request' => $request, 'response' => $response]); + + return new RedirectResponse($response['redirecturl']); + } + + /** + * {@inheritdoc} + */ + public function finalize(AsyncPaymentTransactionStruct $transaction, Request $request, SalesChannelContext $salesChannelContext): void + { + $this->stateHandler->handleStateResponse($transaction, (string) $request->query->get('state')); + } + + /** + * {@inheritdoc} + */ + public static function isCapturable(array $transactionData, array $customFields): bool + { + if ($customFields[CustomFieldInstaller::AUTHORIZATION_TYPE] !== TransactionStatusService::AUTHORIZATION_TYPE_PREAUTHORIZATION) { + return false; + } + + return strtolower($transactionData['txaction']) === TransactionStatusService::ACTION_PAID; + } + + /** + * {@inheritdoc} + */ + public static function isRefundable(array $transactionData, array $customFields): bool + { + if (strtolower($transactionData['txaction']) === TransactionStatusService::ACTION_CAPTURE && (float) $transactionData['receivable'] !== 0.0) { + return true; + } + + return strtolower($transactionData['txaction']) === TransactionStatusService::ACTION_PAID; + } +} diff --git a/src/PaymentMethod/PayoneIDeal.php b/src/PaymentMethod/PayoneIDeal.php new file mode 100644 index 000000000..d50e97828 --- /dev/null +++ b/src/PaymentMethod/PayoneIDeal.php @@ -0,0 +1,42 @@ + [ + 'name' => 'PAYONE iDeal', + 'description' => 'Überweisen Sie schnell und sicher mit Ihren Online Banking Zugangsdaten.', + ], + 'en-GB' => [ + 'name' => 'PAYONE iDeal', + 'description' => 'Wire the amount instantly with your online banking credentials.', + ], + ]; + + /** @var int */ + protected $position = 110; +} diff --git a/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequest.php b/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequest.php new file mode 100644 index 000000000..340ffdebd --- /dev/null +++ b/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequest.php @@ -0,0 +1,67 @@ +redirectHandler = $redirectHandler; + $this->currencyRepository = $currencyRepository; + } + + public function getRequestParameters(PaymentTransaction $transaction, Context $context): array + { + if (empty($transaction->getReturnUrl())) { + throw new InvalidOrderException($transaction->getOrder()->getId()); + } + + $currency = $this->getOrderCurrency($transaction->getOrder(), $context); + + return [ + 'clearingtype' => 'sb', + 'onlinebanktransfertype' => 'IDL', + 'bankcountry' => 'NL', + 'amount' => (int) ($transaction->getOrder()->getAmountTotal() * (10 ** $currency->getDecimalPrecision())), + 'currency' => $currency->getIsoCode(), + 'reference' => $transaction->getOrder()->getOrderNumber(), + 'successurl' => $this->redirectHandler->encode($transaction->getReturnUrl() . '&state=success'), + 'errorurl' => $this->redirectHandler->encode($transaction->getReturnUrl() . '&state=error'), + 'backurl' => $this->redirectHandler->encode($transaction->getReturnUrl() . '&state=cancel'), + ]; + } + + private function getOrderCurrency(OrderEntity $order, Context $context): CurrencyEntity + { + $criteria = new Criteria([$order->getCurrencyId()]); + + /** @var null|CurrencyEntity $currency */ + $currency = $this->currencyRepository->search($criteria, $context)->first(); + + if (null === $currency) { + throw new RuntimeException('missing order currency entity'); + } + + return $currency; + } +} diff --git a/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequestFactory.php b/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequestFactory.php new file mode 100644 index 000000000..099dc5f36 --- /dev/null +++ b/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequestFactory.php @@ -0,0 +1,56 @@ +iDealRequest = $iDealRequest; + $this->customerRequest = $customerRequest; + $this->systemRequest = $systemRequest; + } + + public function getRequestParameters( + PaymentTransaction $transaction, + SalesChannelContext $context + ): array { + $this->requests[] = $this->systemRequest->getRequestParameters( + $transaction->getOrder()->getSalesChannelId(), + ConfigurationPrefixes::CONFIGURATION_PREFIX_IDEAL, + $context->getContext() + ); + + $this->requests[] = $this->customerRequest->getRequestParameters( + $context + ); + + $this->requests[] = $this->iDealRequest->getRequestParameters( + $transaction, + $context->getContext() + ); + + return $this->createRequest(); + } +} diff --git a/src/Payone/Request/IDeal/IDealAuthorizeRequest.php b/src/Payone/Request/IDeal/IDealAuthorizeRequest.php new file mode 100644 index 000000000..edbad225a --- /dev/null +++ b/src/Payone/Request/IDeal/IDealAuthorizeRequest.php @@ -0,0 +1,18 @@ + 'authorization', + ]); + } +} diff --git a/src/Payone/Request/IDeal/IDealAuthorizeRequestFactory.php b/src/Payone/Request/IDeal/IDealAuthorizeRequestFactory.php new file mode 100644 index 000000000..a72df74e8 --- /dev/null +++ b/src/Payone/Request/IDeal/IDealAuthorizeRequestFactory.php @@ -0,0 +1,9 @@ + 'preauthorization', + ]); + } +} diff --git a/src/Payone/Request/IDeal/IDealPreAuthorizeRequestFactory.php b/src/Payone/Request/IDeal/IDealPreAuthorizeRequestFactory.php new file mode 100644 index 000000000..c2a3e03bb --- /dev/null +++ b/src/Payone/Request/IDeal/IDealPreAuthorizeRequestFactory.php @@ -0,0 +1,9 @@ +SEPA-Lastschriftmandat." } + }, + "ideal": { + "cardTitle": "iDeal Online Bank", + "bankGroupFieldLabel": "Bankengruppe Ihrer Hausbank" } }, "error": { diff --git a/src/Resources/translations/en_GB/messages.en-GB.json b/src/Resources/translations/en_GB/messages.en-GB.json index c74d2d96d..299121a71 100644 --- a/src/Resources/translations/en_GB/messages.en-GB.json +++ b/src/Resources/translations/en_GB/messages.en-GB.json @@ -103,6 +103,10 @@ "mandateCheckbox": { "textWithLink": "I hereby issue the SEPA direct debit mandate." } + }, + "ideal": { + "cardTitle": "iDeal Online Bank", + "bankGroupFieldLabel": "Banking group of you bank" } }, "error": { diff --git a/src/Resources/views/storefront/payone/ideal/ideal-form.html.twig b/src/Resources/views/storefront/payone/ideal/ideal-form.html.twig new file mode 100644 index 000000000..a4ccc3f1a --- /dev/null +++ b/src/Resources/views/storefront/payone/ideal/ideal-form.html.twig @@ -0,0 +1,54 @@ +
+ {% block page_checkout_confirm_payone_card_title_ideal %} +
+ {{ "PayonePayment.ideal.cardTitle" | trans }} +
+ {% endblock %} + + + + {% block page_checkout_confirm_payone_card_content_ideal %} +
+
+ +
+
+ +
+
+ +
+ {% endblock %} +
+ From 4402d41cfbaf062709dbbd3c95e7883cece969fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 16 Jun 2020 13:03:16 +0200 Subject: [PATCH 02/13] Add checkout payment method filter for NL customers --- src/DependencyInjection/listeners.xml | 4 + .../CheckoutConfirmIDealEventListener.php | 77 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/EventListener/CheckoutConfirmIDealEventListener.php diff --git a/src/DependencyInjection/listeners.xml b/src/DependencyInjection/listeners.xml index 6c81a5d7c..0cff4600f 100644 --- a/src/DependencyInjection/listeners.xml +++ b/src/DependencyInjection/listeners.xml @@ -51,5 +51,9 @@
+ + + + diff --git a/src/EventListener/CheckoutConfirmIDealEventListener.php b/src/EventListener/CheckoutConfirmIDealEventListener.php new file mode 100644 index 000000000..57e5d5d31 --- /dev/null +++ b/src/EventListener/CheckoutConfirmIDealEventListener.php @@ -0,0 +1,77 @@ + 'hideIDealForNonNlCustomers', + AccountPaymentMethodPageLoadedEvent::class => 'hideIDealForNonNlCustomers', + ]; + } + + /** + * @param AccountPaymentMethodPageLoadedEvent|CheckoutConfirmPageLoadedEvent $event + */ + public function hideIDealForNonNlCustomers($event): void + { + $paymentMethods = $event->getPage()->getPaymentMethods(); + + if ($this->isNlCustomer($event->getSalesChannelContext())) { + return; + } + + $paymentMethods = $this->removePaymentMethod($paymentMethods, PayoneIDeal::UUID); + $event->getPage()->setPaymentMethods($paymentMethods); + } + + /** + * Returns whether or not the customer's billing address + * is inside NL or not. Or false if no customer or billing + * address is given. + * + * @param SalesChannelContext $context + * @return bool + */ + private function isNlCustomer(SalesChannelContext $context): bool + { + $customer = $context->getCustomer(); + + if (null === $customer) { + return false; + } + + $billingAddress = $customer->getActiveBillingAddress(); + + if (null === $billingAddress) { + return false; + } + + return $billingAddress->getCountry()->getIso() === 'NL'; + } + + private function removePaymentMethod(PaymentMethodCollection $paymentMethods, string $paymentMethodId): PaymentMethodCollection + { + return $paymentMethods->filter( + static function (PaymentMethodEntity $paymentMethod) use ($paymentMethodId) { + return $paymentMethod->getId() !== $paymentMethodId; + } + ); + } +} From 5c9c48980fc5384d54caaa6602899e6e315aab6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 16 Jun 2020 13:30:54 +0200 Subject: [PATCH 03/13] Provide iDEAL backend settings --- src/Resources/config/settings.xml | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/Resources/config/settings.xml b/src/Resources/config/settings.xml index b7b36189f..b65aaf993 100644 --- a/src/Resources/config/settings.xml +++ b/src/Resources/config/settings.xml @@ -404,6 +404,60 @@ + + iDEAL + + payment_ideal + + + iDealMerchantId + + Uses the basic configuration value if nothing is entered here. + Nutzt den Wert der Grundeinstellungen, falls nichts eingetragen wird. + + + + iDealAccountId + + Uses the basic configuration value if nothing is entered here. + Nutzt den Wert der Grundeinstellungen, falls nichts eingetragen wird. + + + + iDealPortalId + + Uses the basic configuration value if nothing is entered here. + Nutzt den Wert der Grundeinstellungen, falls nichts eingetragen wird. + + + + iDealPortalKey + + Uses the basic configuration value if nothing is entered here. + Nutzt den Wert der Grundeinstellungen, falls nichts eingetragen wird. + + + + iDealAuthorizationMethod + + + Use this option to set the authorization method for this payment type. + Legt die Autorisierungsmethode für diese Zahlungsart fest. + + + + + + + Payolution Installment From f75866c4a70852142b7ab5b140fdc1ed0548dcac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 16 Jun 2020 13:47:45 +0200 Subject: [PATCH 04/13] Process iDEAL bank group type field --- .../PayoneIDealPaymentHandler.php | 40 +++++++++++++++++++ .../IDeal/AbstractIDealAuthorizeRequest.php | 9 ++++- .../AbstractIDealAuthorizeRequestFactory.php | 3 ++ .../Request/IDeal/IDealAuthorizeRequest.php | 10 +++-- .../IDeal/IDealPreAuthorizeRequest.php | 10 +++-- 5 files changed, 64 insertions(+), 8 deletions(-) diff --git a/src/PaymentHandler/PayoneIDealPaymentHandler.php b/src/PaymentHandler/PayoneIDealPaymentHandler.php index cf129877f..94d01f347 100644 --- a/src/PaymentHandler/PayoneIDealPaymentHandler.php +++ b/src/PaymentHandler/PayoneIDealPaymentHandler.php @@ -26,6 +26,24 @@ class PayoneIDealPaymentHandler extends AbstractPayonePaymentHandler implements AsynchronousPaymentHandlerInterface { + /** + * Valid iDEAL bank groups according to: + * https://docs.payone.com/pages/releaseview.action?pageId=1213906 + */ + protected const VALID_IDEAL_BANK_GROUPS = [ + 'ABN_AMRO_BANK', + 'BUNQ_BANK', + 'RABOBANK', + 'ASN_BANK', + 'SNS_BANK', + 'TRIODOS_BANK', + 'SNS_REGIO_BANK', + 'ING_BANK', + 'KNAB_BANK', + 'VAN_LANSCHOT_BANKIERS', + 'MONEYOU', + ]; + /** @var IDealPreAuthorizeRequestFactory */ private $preAuthRequestFactory; @@ -76,6 +94,15 @@ public function pay(AsyncPaymentTransactionStruct $transaction, RequestDataBag $ $paymentTransaction = PaymentTransaction::fromAsyncPaymentTransactionStruct($transaction); + try { + $this->validate($dataBag); + } catch (PayoneRequestException $e) { + throw new AsyncPaymentProcessException( + $transaction->getOrderTransaction()->getId(), + $this->translator->trans('PayonePayment.errorMessages.genericError') + ); + } + // Select request factory based on configured authorization method $factory = $authorizationMethod === 'preauthorization' ? $this->preAuthRequestFactory @@ -83,6 +110,7 @@ public function pay(AsyncPaymentTransactionStruct $transaction, RequestDataBag $ $request = $factory->getRequestParameters( $paymentTransaction, + $dataBag, $salesChannelContext ); @@ -120,6 +148,18 @@ public function pay(AsyncPaymentTransactionStruct $transaction, RequestDataBag $ return new RedirectResponse($response['redirecturl']); } + /** + * @throws PayoneRequestException + */ + private function validate(RequestDataBag $dataBag) + { + $bankGroup = $dataBag->get('idealBankGroup'); + + if (!in_array($bankGroup, static::VALID_IDEAL_BANK_GROUPS, true)) { + throw new PayoneRequestException('No valid iDEAL bank group'); + } + } + /** * {@inheritdoc} */ diff --git a/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequest.php b/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequest.php index 340ffdebd..964c8807d 100644 --- a/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequest.php +++ b/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequest.php @@ -12,6 +12,7 @@ use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; +use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\Currency\CurrencyEntity; abstract class AbstractIDealAuthorizeRequest @@ -30,8 +31,11 @@ public function __construct( $this->currencyRepository = $currencyRepository; } - public function getRequestParameters(PaymentTransaction $transaction, Context $context): array - { + public function getRequestParameters( + PaymentTransaction $transaction, + RequestDataBag $dataBag, + Context $context + ): array { if (empty($transaction->getReturnUrl())) { throw new InvalidOrderException($transaction->getOrder()->getId()); } @@ -42,6 +46,7 @@ public function getRequestParameters(PaymentTransaction $transaction, Context $c 'clearingtype' => 'sb', 'onlinebanktransfertype' => 'IDL', 'bankcountry' => 'NL', + 'bankgrouptype' => $dataBag->get('idealBankGroup'), 'amount' => (int) ($transaction->getOrder()->getAmountTotal() * (10 ** $currency->getDecimalPrecision())), 'currency' => $currency->getIsoCode(), 'reference' => $transaction->getOrder()->getOrderNumber(), diff --git a/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequestFactory.php b/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequestFactory.php index 099dc5f36..8c90a814c 100644 --- a/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequestFactory.php +++ b/src/Payone/Request/IDeal/AbstractIDealAuthorizeRequestFactory.php @@ -9,6 +9,7 @@ use PayonePayment\Payone\Request\Customer\CustomerRequest; use PayonePayment\Payone\Request\System\SystemRequest; use PayonePayment\Struct\PaymentTransaction; +use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; abstract class AbstractIDealAuthorizeRequestFactory extends AbstractRequestFactory @@ -34,6 +35,7 @@ public function __construct( public function getRequestParameters( PaymentTransaction $transaction, + RequestDataBag $dataBag, SalesChannelContext $context ): array { $this->requests[] = $this->systemRequest->getRequestParameters( @@ -48,6 +50,7 @@ public function getRequestParameters( $this->requests[] = $this->iDealRequest->getRequestParameters( $transaction, + $dataBag, $context->getContext() ); diff --git a/src/Payone/Request/IDeal/IDealAuthorizeRequest.php b/src/Payone/Request/IDeal/IDealAuthorizeRequest.php index edbad225a..5c68ca1ca 100644 --- a/src/Payone/Request/IDeal/IDealAuthorizeRequest.php +++ b/src/Payone/Request/IDeal/IDealAuthorizeRequest.php @@ -6,12 +6,16 @@ use PayonePayment\Struct\PaymentTransaction; use Shopware\Core\Framework\Context; +use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; class IDealAuthorizeRequest extends AbstractIDealAuthorizeRequest { - public function getRequestParameters(PaymentTransaction $transaction, Context $context): array - { - return array_merge(parent::getRequestParameters($transaction, $context), [ + public function getRequestParameters( + PaymentTransaction $transaction, + RequestDataBag $dataBag, + Context $context + ): array { + return array_merge(parent::getRequestParameters($transaction, $dataBag, $context), [ 'request' => 'authorization', ]); } diff --git a/src/Payone/Request/IDeal/IDealPreAuthorizeRequest.php b/src/Payone/Request/IDeal/IDealPreAuthorizeRequest.php index a0f9f96cc..73dec636b 100644 --- a/src/Payone/Request/IDeal/IDealPreAuthorizeRequest.php +++ b/src/Payone/Request/IDeal/IDealPreAuthorizeRequest.php @@ -6,12 +6,16 @@ use PayonePayment\Struct\PaymentTransaction; use Shopware\Core\Framework\Context; +use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; class IDealPreAuthorizeRequest extends AbstractIDealAuthorizeRequest { - public function getRequestParameters(PaymentTransaction $transaction, Context $context): array - { - return array_merge(parent::getRequestParameters($transaction, $context), [ + public function getRequestParameters( + PaymentTransaction $transaction, + RequestDataBag $dataBag, + Context $context + ): array { + return array_merge(parent::getRequestParameters($transaction, $dataBag, $context), [ 'request' => 'preauthorization', ]); } From 6bf349c24c82b34071b148d221bf671e8b8a7425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 16 Jun 2020 14:57:17 +0200 Subject: [PATCH 05/13] Hide iDEAL for non-EUR currencies --- .../CheckoutConfirmIDealEventListener.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/EventListener/CheckoutConfirmIDealEventListener.php b/src/EventListener/CheckoutConfirmIDealEventListener.php index 57e5d5d31..c0fb2e0f1 100644 --- a/src/EventListener/CheckoutConfirmIDealEventListener.php +++ b/src/EventListener/CheckoutConfirmIDealEventListener.php @@ -33,7 +33,10 @@ public function hideIDealForNonNlCustomers($event): void { $paymentMethods = $event->getPage()->getPaymentMethods(); - if ($this->isNlCustomer($event->getSalesChannelContext())) { + if ( + $this->isEuroCurrency($event->getSalesChannelContext()) && + $this->isNlCustomer($event->getSalesChannelContext()) + ) { return; } @@ -41,6 +44,17 @@ public function hideIDealForNonNlCustomers($event): void $event->getPage()->setPaymentMethods($paymentMethods); } + /** + * Returns whether or not the currency is EUR. + * + * @param SalesChannelContext $context + * @return bool + */ + private function isEuroCurrency(SalesChannelContext $context): bool + { + return $context->getCurrency()->getIsoCode() === 'EUR'; + } + /** * Returns whether or not the customer's billing address * is inside NL or not. Or false if no customer or billing From d7eee9373b9ab8a6bf78235044f6be7906d3fcbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 16 Jun 2020 15:01:32 +0200 Subject: [PATCH 06/13] Disable CSRF protection for redirect handler --- src/Controller/RedirectController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/RedirectController.php b/src/Controller/RedirectController.php index 47d8b537c..d3510e623 100644 --- a/src/Controller/RedirectController.php +++ b/src/Controller/RedirectController.php @@ -25,7 +25,7 @@ public function __construct(RedirectHandler $redirectHandler) /** * @RouteScope(scopes={"storefront"}) - * @Route("/payone/redirect", name="payone_redirect") + * @Route("/payone/redirect", name="payone_redirect", defaults={"csrf_protected"=false}) */ public function execute(Request $request): Response { From 6a5cd1b85c83d9dc3471718d0bae418a324d1b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Mon, 22 Jun 2020 11:25:31 +0200 Subject: [PATCH 07/13] Provide payment test data for iDEAL --- src/Controller/SettingsController.php | 17 +++++++++++++++++ .../module/payone-payment/snippet/de_DE.json | 3 ++- .../module/payone-payment/snippet/en_GB.json | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Controller/SettingsController.php b/src/Controller/SettingsController.php index d0da2e7e8..f116ab5ce 100644 --- a/src/Controller/SettingsController.php +++ b/src/Controller/SettingsController.php @@ -9,6 +9,7 @@ use PayonePayment\Configuration\ConfigurationPrefixes; use PayonePayment\PaymentHandler\PayoneCreditCardPaymentHandler; use PayonePayment\PaymentHandler\PayoneDebitPaymentHandler; +use PayonePayment\PaymentHandler\PayoneIDealPaymentHandler; use PayonePayment\PaymentHandler\PayonePayolutionDebitPaymentHandler; use PayonePayment\PaymentHandler\PayonePayolutionInstallmentPaymentHandler; use PayonePayment\PaymentHandler\PayonePayolutionInvoicingPaymentHandler; @@ -204,6 +205,22 @@ private function getPaymentParameters(string $paymentClass): array 'successurl' => 'https://www.payone.com', ]; + case PayoneIDealPaymentHandler::class: + return [ + 'request' => 'preauthorization', + 'clearingtype' => 'sb', + 'onlinebanktransfertype' => 'IDL', + 'bankcountry' => 'NL', + 'bankgrouptype' => 'ING_BANK', + 'amount' => 100, + 'currency' => 'EUR', + 'reference' => sprintf('%s%d', self::REFERENCE_PREFIX_TEST, random_int(1000000000000, 9999999999999)), + 'firstname' => 'Test', + 'lastname' => 'Test', + 'country' => 'NL', + 'successurl' => 'https://www.payone.com', + ]; + break; case PayonePayolutionInvoicingPaymentHandler::class: return [ diff --git a/src/Resources/app/administration/src/module/payone-payment/snippet/de_DE.json b/src/Resources/app/administration/src/module/payone-payment/snippet/de_DE.json index a531ac58f..a0120d9eb 100644 --- a/src/Resources/app/administration/src/module/payone-payment/snippet/de_DE.json +++ b/src/Resources/app/administration/src/module/payone-payment/snippet/de_DE.json @@ -33,7 +33,8 @@ "payolutionInstallment": "Die API-Zugangsdaten für Paysafe Pay Later Ratenzahlung sind nicht korrekt.", "payolutionInvoicing": "Die API-Zugangsdaten für Paysafe Pay Later Rechnungskauf sind nicht korrekt.", "payolutionDebit": "Die API-Zugangsdaten für Paysafe Pay Later Lastschrift sind nicht korrekt.", - "sofort": "Die API-Zugangsdaten für SOFORT sind nicht korrekt." + "sofort": "Die API-Zugangsdaten für SOFORT sind nicht korrekt.", + "iDeal": "Die API-Zugangsdaten für iDEAL sind nicht korrekt." } }, "supportModal": { diff --git a/src/Resources/app/administration/src/module/payone-payment/snippet/en_GB.json b/src/Resources/app/administration/src/module/payone-payment/snippet/en_GB.json index af471b7fc..e6cc876a5 100644 --- a/src/Resources/app/administration/src/module/payone-payment/snippet/en_GB.json +++ b/src/Resources/app/administration/src/module/payone-payment/snippet/en_GB.json @@ -33,7 +33,8 @@ "payolutionInstallment": "The API credentials for Paysafe Pay Later Installment are not valid.", "payolutionInvoicing": "The API credentials for Paysafe Pay Later Invoicing are not valid.", "payolutionDebit": "The API credentials for Paysafe Pay Later Debit are not valid.", - "sofort": "The API credentials for SOFORT are not valid." + "sofort": "The API credentials for SOFORT are not valid.", + "iDeal": "The API credentials for iDEAL are not valid." } }, "supportModal": { From 093efbb7f696136724d3c2bd7d632f8c23f2ae9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 23 Jun 2020 10:56:15 +0200 Subject: [PATCH 08/13] Fix missing static config prefix in backend --- .../src/module/payone-payment/page/payone-settings/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Resources/app/administration/src/module/payone-payment/page/payone-settings/index.js b/src/Resources/app/administration/src/module/payone-payment/page/payone-settings/index.js index 21a0cb9d8..02abcc034 100644 --- a/src/Resources/app/administration/src/module/payone-payment/page/payone-settings/index.js +++ b/src/Resources/app/administration/src/module/payone-payment/page/payone-settings/index.js @@ -82,7 +82,8 @@ Component.register('payone-settings', { 'payolutionInvoicing', 'payolutionInstallment', 'payolutionDebit', - 'sofort' + 'sofort', + 'iDeal', ]; }, From f46a19c6be09a551393e924afeaf0fdb869f439f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 23 Jun 2020 08:41:59 +0000 Subject: [PATCH 09/13] Add compiled backend files --- src/Resources/public/administration/js/payone-payment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/public/administration/js/payone-payment.js b/src/Resources/public/administration/js/payone-payment.js index ab1b0ba9e..2689a89da 100644 --- a/src/Resources/public/administration/js/payone-payment.js +++ b/src/Resources/public/administration/js/payone-payment.js @@ -1 +1 @@ -(this.webpackJsonp=this.webpackJsonp||[]).push([["payone-payment"],{DMdC:function(e,t,n){},KBQv:function(e,t){const{Application:n}=Shopware,a=Shopware.Classes.ApiService;class s extends a{constructor(e,t,n="payone"){super(e,t,n)}capturePayment(e){const t=`_action/${this.getApiBasePath()}/capture-payment`;return this.httpClient.post(t,{transaction:e},{headers:this.getBasicHeaders()}).then(e=>a.handleResponse(e))}refundPayment(e){const t=`_action/${this.getApiBasePath()}/refund-payment`;return this.httpClient.post(t,{transaction:e},{headers:this.getBasicHeaders()}).then(e=>a.handleResponse(e))}}n.addServiceProvider("PayonePaymentService",e=>{const t=n.getContainer("init");return new s(t.httpClient,e.loginService)})},Lvox:function(e,t,n){var a=n("DMdC");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("3806acf0",a,!0,{})},McCE:function(e,t,n){var a=n("McMq");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("f06f327e",a,!0,{})},McMq:function(e,t,n){},NXBA:function(e,t,n){},OPxs:function(e,t,n){"use strict";n.r(t);var a=n("mLM4"),s=n.n(a);n("McCE");const{Component:i,Mixin:o}=Shopware;i.register("payone-settings",{template:s.a,mixins:[o.getByName("notification"),o.getByName("sw-inline-snippet")],inject:["PayonePaymentSettingsService"],data:()=>({isLoading:!1,isTesting:!1,isSaveSuccessful:!1,isTestSuccessful:!1,config:{},merchantIdFilled:!1,accountIdFilled:!1,portalIdFilled:!1,portalKeyFilled:!1,showValidationErrors:!1,isSupportModalOpen:!1,stateMachineTransitionActions:[],collapsibleState:{status_mapping:!0,payment_credit_card:!0,payment_paypal:!0,payment_paypal_express:!0,payment_debit:!0,payment_sofort:!0,payment_payolution_installment:!0,payment_payolution_invoicing:!0,payment_payolution_debit:!0}}),created(){this.createdComponent()},computed:{credentialsMissing:function(){return!(this.merchantIdFilled&&this.accountIdFilled&&this.portalIdFilled&&this.portalKeyFilled)}},metaInfo(){return{title:this.$createTitle()}},methods:{createdComponent(){let e=this;this.PayonePaymentSettingsService.getStateMachineTransitionActions().then(t=>{t.data.forEach(t=>{e.stateMachineTransitionActions.push({label:e.$tc("payone-payment.transitionActionNames."+t.label),value:t.value})})})},paymentMethodPrefixes:()=>["creditCard","debit","paypal","paypalExpress","payolutionInvoicing","payolutionInstallment","payolutionDebit","sofort"],isCollapsible(e){return e.name in this.collapsibleState},displayField(e,t,n){return!(n.name in this.collapsibleState)||!this.collapsibleState[n.name]},isCollapsed(e){return this.collapsibleState[e.name]},toggleCollapsible(e){e.name in this.collapsibleState&&(this.collapsibleState[e.name]=!this.collapsibleState[e.name])},saveFinish(){this.isSaveSuccessful=!1},testFinish(){this.isTestSuccessful=!1},onConfigChange(e){this.config=e,this.checkCredentialsFilled(),this.showValidationErrors=!1},checkCredentialsFilled(){this.merchantIdFilled=!!this.getConfigValue("merchantId"),this.accountIdFilled=!!this.getConfigValue("accountId"),this.portalIdFilled=!!this.getConfigValue("portalId"),this.portalKeyFilled=!!this.getConfigValue("portalKey")},getConfigValue(e){const t=this.$refs.systemConfig.actualConfigData.null;return null===this.$refs.systemConfig.currentSalesChannelId?this.config[`PayonePayment.settings.${e}`]:this.config[`PayonePayment.settings.${e}`]||t[`PayonePayment.settings.${e}`]},getPaymentConfigValue(e,t){let n=e.charAt(0).toUpperCase()+e.slice(1);return this.getConfigValue(t+n)||this.getConfigValue(e)},onSave(){this.credentialsMissing?this.showValidationErrors=!0:(this.isSaveSuccessful=!1,this.isLoading=!0,this.$refs.systemConfig.saveAll().then(()=>{this.isLoading=!1,this.isSaveSuccessful=!0}).catch(()=>{this.isLoading=!1}))},onTest(){this.isTesting=!0,this.isTestSuccessful=!1;let e={};this.paymentMethodPrefixes().forEach(t=>{e[t]={merchantId:this.getPaymentConfigValue("merchantId",t),accountId:this.getPaymentConfigValue("accountId",t),portalId:this.getPaymentConfigValue("portalId",t),portalKey:this.getPaymentConfigValue("portalKey",t)}}),this.PayonePaymentSettingsService.validateApiCredentials(e).then(e=>{const t=e.testCount,n=e.credentialsValid,a=e.errors;if(n)this.createNotificationSuccess({title:this.$tc("payone-payment.settingsForm.titleSuccess"),message:t>0?this.$tc("payone-payment.settingsForm.messageTestSuccess"):this.$tc("payone-payment.settingsForm.messageTestNoTestedPayments")}),this.isTestSuccessful=!0;else for(let e in a)a.hasOwnProperty(e)&&this.createNotificationError({title:this.$tc("payone-payment.settingsForm.titleError"),message:this.$tc("payone-payment.settingsForm.messageTestError."+e)});this.isTesting=!1}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.settingsForm.titleError"),message:this.$tc("payone-payment.settingsForm.messageTestError.general")}),this.isTesting=!1})},getBind(e,t){return t!==this.config&&this.onConfigChange(t),this.showValidationErrors&&("PayonePayment.settings.merchantId"!==e.name||this.merchantIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.accountId"!==e.name||this.accountIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.portalId"!==e.name||this.portalIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.portalKey"!==e.name||this.portalKeyFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")})),e}}});var r=n("jAFz"),l=n.n(r);n("Lvox");const{Component:c,Mixin:p}=Shopware;c.override("sw-order-detail-base",{template:l.a,inject:["PayonePaymentService"],mixins:[p.getByName("notification")],data:()=>({disableButtons:!1}),methods:{isPayonePayment:e=>!!e.customFields&&e.customFields.payone_transaction_id,isCapturePossible(e){return!!e.customFields&&(!this.disableButtons&&e.customFields.payone_allow_capture)},isRefundPossible(e){return!!e.customFields&&(!this.disableButtons&&e.customFields.payone_allow_refund)},hasPayonePayment(e){let t=this,n=!1;return!!e.transactions&&(e.transactions.map((function(e){t.isPayonePayment(e)&&(n=!0)})),n)},captureOrder(e){let t=this;this.isPayonePayment(e)&&(t.disableButtons=!0,this.PayonePaymentService.capturePayment(e.id).then(()=>{this.createNotificationSuccess({title:this.$tc("payone-payment.capture.successTitle"),message:this.$tc("payone-payment.capture.successMessage")}),t.reloadEntityData(),t.disableButtons=!1}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.capture.errorTitle"),message:e.response.data.message}),t.disableButtons=!1}))},refundOrder(e){let t=this;this.isPayonePayment(e)&&(t.disableButtons=!0,this.PayonePaymentService.refundPayment(e.id).then(()=>{this.createNotificationSuccess({title:this.$tc("payone-payment.refund.successTitle"),message:this.$tc("payone-payment.refund.successMessage")}),t.reloadEntityData(),t.disableButtons=!1}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.refund.errorTitle"),message:e.response.data.message}),t.disableButtons=!1}))}}});var d=n("Yjca"),u=n.n(d);n("d11z");const{Component:m}=Shopware;m.override("sw-settings-index",{template:u.a});var y=n("m1C4"),h=n("eQpg");const{Module:g}=Shopware;g.register("payone-payment",{type:"plugin",name:"PayonePayment",title:"payone-payment.general.mainMenuItemGeneral",description:"payone-payment.general.descriptionTextModule",version:"1.0.0",targetVersion:"1.0.0",icon:"default-action-settings",snippets:{"de-DE":y,"en-GB":h},routeMiddleware(e,t){e(t)},routes:{index:{component:"payone-settings",path:"index",meta:{parentPath:"sw.settings.index"}}}});n("KBQv"),n("Q7qL")},Q7qL:function(e,t){const{Application:n}=Shopware,a=Shopware.Classes.ApiService;class s extends a{constructor(e,t,n="payone_payment"){super(e,t,n)}validateApiCredentials(e){const t=this.getBasicHeaders();return this.httpClient.post(`_action/${this.getApiBasePath()}/validate-api-credentials`,{credentials:e},{headers:t}).then(e=>a.handleResponse(e))}getStateMachineTransitionActions(){const e=this.getBasicHeaders();return this.httpClient.get(`_action/${this.getApiBasePath()}/get-state-machine-transition-actions`,{headers:e}).then(e=>a.handleResponse(e))}}n.addServiceProvider("PayonePaymentSettingsService",e=>{const t=n.getContainer("init");return new s(t.httpClient,e.loginService)})},Yjca:function(e,t){e.exports='{% block sw_settings_content_card_slot_plugins %}\n {% parent %}\n\n \n \n \n{% endblock %}\n'},d11z:function(e,t,n){var a=n("NXBA");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("e7715378",a,!0,{})},eQpg:function(e){e.exports=JSON.parse('{"payone-payment":{"title":"PAYONE","general":{"mainMenuItemGeneral":"PAYONE","descriptionTextModule":"Settings for PAYONE"},"capture":{"buttonTitle":"Capture","successTitle":"PAYONE","successMessage":"Capture processed successfully.","errorTitle":"PAYONE"},"refund":{"buttonTitle":"Refund","successTitle":"PAYONE","successMessage":"Refund processed successfully.","errorTitle":"PAYONE"},"settingsForm":{"save":"Save","test":"Test API Credentials","titleSuccess":"Success","titleError":"Error","messageTestSuccess":"The API credentials were verified successfully.","messageTestNoTestedPayments":"No payment methods were tested during the check because none of the PAYONE payment methods are activated. Please activate at least one PAYONE payment method under Settings --\x3e Shop --\x3e Payment.","messageTestError":{"general":"The API credentials could not be verified successfully.","creditCard":"The API credentials for Credit Card are not valid.","debit":"The API credentials for Debit are not valid.","paypalExpress":"The API credentials for PayPal Express are not valid.","paypal":"The API credentials for PayPal are not valid.","payolutionInstallment":"The API credentials for Paysafe Pay Later Installment are not valid.","payolutionInvoicing":"The API credentials for Paysafe Pay Later Invoicing are not valid.","payolutionDebit":"The API credentials for Paysafe Pay Later Debit are not valid.","sofort":"The API credentials for SOFORT are not valid."}},"supportModal":{"menuButton":"Support","title":"How Can We Help You?","documentation":{"description":"Read our online manual","button":"Online Manual"},"support":{"description":"Contact our technical support","button":"Tech Support"},"repository":{"description":"Report errors on GitHub","button":"GitHub"}},"transitionActionNames":{"cancel":"Cancel","complete":"Complete","pay":"Pay","pay_partially":"Pay partially","process":"Process","refund":"Refund","refund_partially":"Refund partially","remind":"Remind","reopen":"Reopen","retour":"Retour","retour_partially":"Retour partially","ship":"Ship","ship_partially":"Ship partially"},"messageNotBlank":"This field must not be empty.","txid":"TXID","sequenceNumber":{"label":"Sequence Number","empty":"none"},"transactionState":"State"}}')},jAFz:function(e,t){e.exports='{% block sw_order_detail_delivery_metadata %}\n {% parent %}\n\n \n{% endblock %}\n'},m1C4:function(e){e.exports=JSON.parse('{"payone-payment":{"title":"PAYONE","general":{"mainMenuItemGeneral":"PAYONE","descriptionTextModule":"Einstellungen für PAYONE"},"capture":{"buttonTitle":"Capture","successTitle":"PAYONE","successMessage":"Capture erfolgreich durchgeführt.","errorTitle":"PAYONE"},"refund":{"buttonTitle":"Refund","successTitle":"PAYONE","successMessage":"Refund erfolgreich durchgeführt.","errorTitle":"PAYONE"},"settingsForm":{"save":"Speichern","test":"API-Zugangsdaten testen","titleSuccess":"Erfolg","titleError":"Fehler","messageTestSuccess":"Die API-Zugangsdaten wurden erfolgreich validiert.","messageTestNoTestedPayments":"Bei der Prüfung wurden keine Zahlarten getestet, weil keine der PAYONE Zahlarten aktiviert ist. Bitte aktivieren Sie mindestens eine PAYONE Zahlart unter Einstellungen --\x3e Shop --\x3e Zahlungsarten.","messageTestError":{"general":"Die API-Zugangsdaten konnten nicht validiert werden.","creditCard":"Die API-Zugangsdaten für Kreditkarte sind nicht korrekt.","debit":"Die API-Zugangsdaten für Lastschrift sind nicht korrekt.","paypalExpress":"Die API-Zugangsdaten für PayPal Express sind nicht korrekt.","paypal":"Die API-Zugangsdaten für PayPal sind nicht korrekt.","payolutionInstallment":"Die API-Zugangsdaten für Paysafe Pay Later Ratenzahlung sind nicht korrekt.","payolutionInvoicing":"Die API-Zugangsdaten für Paysafe Pay Later Rechnungskauf sind nicht korrekt.","payolutionDebit":"Die API-Zugangsdaten für Paysafe Pay Later Lastschrift sind nicht korrekt.","sofort":"Die API-Zugangsdaten für SOFORT sind nicht korrekt."}},"supportModal":{"menuButton":"Support","title":"Wie können wir Ihnen helfen?","documentation":{"description":"Lesen Sie unsere Online-Dokumentation","button":"Dokumentation"},"support":{"description":"Kontaktieren Sie unseren technischen Support","button":"Technischer Support"},"repository":{"description":"Melden Sie Fehler und Verbesserungen auf GitHub","button":"GitHub"}},"transitionActionNames":{"cancel":"Stornieren","complete":"Abschließen","pay":"Bezahlen","pay_partially":"Teilweise bezahlen","process":"Durchführen","refund":"Rückerstatten","refund_partially":"Teilweise rückerstatten","remind":"Erinnern","reopen":"Wieder öffnen","retour":"Retoure","retour_partially":"Teilweise retounieren","ship":"Versenden","ship_partially":"Teilweise versenden"},"messageNotBlank":"Dieser Wert darf nicht leer sein.","txid":"TXID","sequenceNumber":{"label":"Sequenznummer","empty":"keine"},"transactionState":"Status"}}')},mLM4:function(e,t){e.exports='{% block payone_payment %}\n\n {% block payone_payment_header %}\n \n {% endblock %}\n\n {% block payone_payment_actions %}\n \n {% endblock %}\n\n {% block payone_payment_settings_content %}\n \n {% endblock %}\n\n{% endblock %}\n'}},[["OPxs","runtime","vendors-node"]]]); \ No newline at end of file +(this.webpackJsonp=this.webpackJsonp||[]).push([["payone-payment"],{DMdC:function(e,t,n){},KBQv:function(e,t){const{Application:n}=Shopware,a=Shopware.Classes.ApiService;class s extends a{constructor(e,t,n="payone"){super(e,t,n)}capturePayment(e){const t=`_action/${this.getApiBasePath()}/capture-payment`;return this.httpClient.post(t,{transaction:e},{headers:this.getBasicHeaders()}).then(e=>a.handleResponse(e))}refundPayment(e){const t=`_action/${this.getApiBasePath()}/refund-payment`;return this.httpClient.post(t,{transaction:e},{headers:this.getBasicHeaders()}).then(e=>a.handleResponse(e))}}n.addServiceProvider("PayonePaymentService",e=>{const t=n.getContainer("init");return new s(t.httpClient,e.loginService)})},Lvox:function(e,t,n){var a=n("DMdC");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("3806acf0",a,!0,{})},McCE:function(e,t,n){var a=n("McMq");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("f06f327e",a,!0,{})},McMq:function(e,t,n){},NXBA:function(e,t,n){},OPxs:function(e,t,n){"use strict";n.r(t);var a=n("mLM4"),s=n.n(a);n("McCE");const{Component:i,Mixin:o}=Shopware;i.register("payone-settings",{template:s.a,mixins:[o.getByName("notification"),o.getByName("sw-inline-snippet")],inject:["PayonePaymentSettingsService"],data:()=>({isLoading:!1,isTesting:!1,isSaveSuccessful:!1,isTestSuccessful:!1,config:{},merchantIdFilled:!1,accountIdFilled:!1,portalIdFilled:!1,portalKeyFilled:!1,showValidationErrors:!1,isSupportModalOpen:!1,stateMachineTransitionActions:[],collapsibleState:{status_mapping:!0,payment_credit_card:!0,payment_paypal:!0,payment_paypal_express:!0,payment_debit:!0,payment_sofort:!0,payment_payolution_installment:!0,payment_payolution_invoicing:!0,payment_payolution_debit:!0}}),created(){this.createdComponent()},computed:{credentialsMissing:function(){return!(this.merchantIdFilled&&this.accountIdFilled&&this.portalIdFilled&&this.portalKeyFilled)}},metaInfo(){return{title:this.$createTitle()}},methods:{createdComponent(){let e=this;this.PayonePaymentSettingsService.getStateMachineTransitionActions().then(t=>{t.data.forEach(t=>{e.stateMachineTransitionActions.push({label:e.$tc("payone-payment.transitionActionNames."+t.label),value:t.value})})})},paymentMethodPrefixes:()=>["creditCard","debit","paypal","paypalExpress","payolutionInvoicing","payolutionInstallment","payolutionDebit","sofort","iDeal"],isCollapsible(e){return e.name in this.collapsibleState},displayField(e,t,n){return!(n.name in this.collapsibleState)||!this.collapsibleState[n.name]},isCollapsed(e){return this.collapsibleState[e.name]},toggleCollapsible(e){e.name in this.collapsibleState&&(this.collapsibleState[e.name]=!this.collapsibleState[e.name])},saveFinish(){this.isSaveSuccessful=!1},testFinish(){this.isTestSuccessful=!1},onConfigChange(e){this.config=e,this.checkCredentialsFilled(),this.showValidationErrors=!1},checkCredentialsFilled(){this.merchantIdFilled=!!this.getConfigValue("merchantId"),this.accountIdFilled=!!this.getConfigValue("accountId"),this.portalIdFilled=!!this.getConfigValue("portalId"),this.portalKeyFilled=!!this.getConfigValue("portalKey")},getConfigValue(e){const t=this.$refs.systemConfig.actualConfigData.null;return null===this.$refs.systemConfig.currentSalesChannelId?this.config[`PayonePayment.settings.${e}`]:this.config[`PayonePayment.settings.${e}`]||t[`PayonePayment.settings.${e}`]},getPaymentConfigValue(e,t){let n=e.charAt(0).toUpperCase()+e.slice(1);return this.getConfigValue(t+n)||this.getConfigValue(e)},onSave(){this.credentialsMissing?this.showValidationErrors=!0:(this.isSaveSuccessful=!1,this.isLoading=!0,this.$refs.systemConfig.saveAll().then(()=>{this.isLoading=!1,this.isSaveSuccessful=!0}).catch(()=>{this.isLoading=!1}))},onTest(){this.isTesting=!0,this.isTestSuccessful=!1;let e={};this.paymentMethodPrefixes().forEach(t=>{e[t]={merchantId:this.getPaymentConfigValue("merchantId",t),accountId:this.getPaymentConfigValue("accountId",t),portalId:this.getPaymentConfigValue("portalId",t),portalKey:this.getPaymentConfigValue("portalKey",t)}}),this.PayonePaymentSettingsService.validateApiCredentials(e).then(e=>{const t=e.testCount,n=e.credentialsValid,a=e.errors;if(n)this.createNotificationSuccess({title:this.$tc("payone-payment.settingsForm.titleSuccess"),message:t>0?this.$tc("payone-payment.settingsForm.messageTestSuccess"):this.$tc("payone-payment.settingsForm.messageTestNoTestedPayments")}),this.isTestSuccessful=!0;else for(let e in a)a.hasOwnProperty(e)&&this.createNotificationError({title:this.$tc("payone-payment.settingsForm.titleError"),message:this.$tc("payone-payment.settingsForm.messageTestError."+e)});this.isTesting=!1}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.settingsForm.titleError"),message:this.$tc("payone-payment.settingsForm.messageTestError.general")}),this.isTesting=!1})},getBind(e,t){return t!==this.config&&this.onConfigChange(t),this.showValidationErrors&&("PayonePayment.settings.merchantId"!==e.name||this.merchantIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.accountId"!==e.name||this.accountIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.portalId"!==e.name||this.portalIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.portalKey"!==e.name||this.portalKeyFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")})),e}}});var r=n("jAFz"),l=n.n(r);n("Lvox");const{Component:c,Mixin:p}=Shopware;c.override("sw-order-detail-base",{template:l.a,inject:["PayonePaymentService"],mixins:[p.getByName("notification")],data:()=>({disableButtons:!1}),methods:{isPayonePayment:e=>!!e.customFields&&e.customFields.payone_transaction_id,isCapturePossible(e){return!!e.customFields&&(!this.disableButtons&&e.customFields.payone_allow_capture)},isRefundPossible(e){return!!e.customFields&&(!this.disableButtons&&e.customFields.payone_allow_refund)},hasPayonePayment(e){let t=this,n=!1;return!!e.transactions&&(e.transactions.map((function(e){t.isPayonePayment(e)&&(n=!0)})),n)},captureOrder(e){let t=this;this.isPayonePayment(e)&&(t.disableButtons=!0,this.PayonePaymentService.capturePayment(e.id).then(()=>{this.createNotificationSuccess({title:this.$tc("payone-payment.capture.successTitle"),message:this.$tc("payone-payment.capture.successMessage")}),t.reloadEntityData(),t.disableButtons=!1}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.capture.errorTitle"),message:e.response.data.message}),t.disableButtons=!1}))},refundOrder(e){let t=this;this.isPayonePayment(e)&&(t.disableButtons=!0,this.PayonePaymentService.refundPayment(e.id).then(()=>{this.createNotificationSuccess({title:this.$tc("payone-payment.refund.successTitle"),message:this.$tc("payone-payment.refund.successMessage")}),t.reloadEntityData(),t.disableButtons=!1}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.refund.errorTitle"),message:e.response.data.message}),t.disableButtons=!1}))}}});var d=n("Yjca"),u=n.n(d);n("d11z");const{Component:m}=Shopware;m.override("sw-settings-index",{template:u.a});var y=n("m1C4"),h=n("eQpg");const{Module:g}=Shopware;g.register("payone-payment",{type:"plugin",name:"PayonePayment",title:"payone-payment.general.mainMenuItemGeneral",description:"payone-payment.general.descriptionTextModule",version:"1.0.0",targetVersion:"1.0.0",icon:"default-action-settings",snippets:{"de-DE":y,"en-GB":h},routeMiddleware(e,t){e(t)},routes:{index:{component:"payone-settings",path:"index",meta:{parentPath:"sw.settings.index"}}}});n("KBQv"),n("Q7qL")},Q7qL:function(e,t){const{Application:n}=Shopware,a=Shopware.Classes.ApiService;class s extends a{constructor(e,t,n="payone_payment"){super(e,t,n)}validateApiCredentials(e){const t=this.getBasicHeaders();return this.httpClient.post(`_action/${this.getApiBasePath()}/validate-api-credentials`,{credentials:e},{headers:t}).then(e=>a.handleResponse(e))}getStateMachineTransitionActions(){const e=this.getBasicHeaders();return this.httpClient.get(`_action/${this.getApiBasePath()}/get-state-machine-transition-actions`,{headers:e}).then(e=>a.handleResponse(e))}}n.addServiceProvider("PayonePaymentSettingsService",e=>{const t=n.getContainer("init");return new s(t.httpClient,e.loginService)})},Yjca:function(e,t){e.exports='{% block sw_settings_content_card_slot_plugins %}\n {% parent %}\n\n \n \n \n{% endblock %}\n'},d11z:function(e,t,n){var a=n("NXBA");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("e7715378",a,!0,{})},eQpg:function(e){e.exports=JSON.parse('{"payone-payment":{"title":"PAYONE","general":{"mainMenuItemGeneral":"PAYONE","descriptionTextModule":"Settings for PAYONE"},"capture":{"buttonTitle":"Capture","successTitle":"PAYONE","successMessage":"Capture processed successfully.","errorTitle":"PAYONE"},"refund":{"buttonTitle":"Refund","successTitle":"PAYONE","successMessage":"Refund processed successfully.","errorTitle":"PAYONE"},"settingsForm":{"save":"Save","test":"Test API Credentials","titleSuccess":"Success","titleError":"Error","messageTestSuccess":"The API credentials were verified successfully.","messageTestNoTestedPayments":"No payment methods were tested during the check because none of the PAYONE payment methods are activated. Please activate at least one PAYONE payment method under Settings --\x3e Shop --\x3e Payment.","messageTestError":{"general":"The API credentials could not be verified successfully.","creditCard":"The API credentials for Credit Card are not valid.","debit":"The API credentials for Debit are not valid.","paypalExpress":"The API credentials for PayPal Express are not valid.","paypal":"The API credentials for PayPal are not valid.","payolutionInstallment":"The API credentials for Paysafe Pay Later Installment are not valid.","payolutionInvoicing":"The API credentials for Paysafe Pay Later Invoicing are not valid.","payolutionDebit":"The API credentials for Paysafe Pay Later Debit are not valid.","sofort":"The API credentials for SOFORT are not valid.","iDeal":"The API credentials for iDEAL are not valid."}},"supportModal":{"menuButton":"Support","title":"How Can We Help You?","documentation":{"description":"Read our online manual","button":"Online Manual"},"support":{"description":"Contact our technical support","button":"Tech Support"},"repository":{"description":"Report errors on GitHub","button":"GitHub"}},"transitionActionNames":{"cancel":"Cancel","complete":"Complete","pay":"Pay","pay_partially":"Pay partially","process":"Process","refund":"Refund","refund_partially":"Refund partially","remind":"Remind","reopen":"Reopen","retour":"Retour","retour_partially":"Retour partially","ship":"Ship","ship_partially":"Ship partially"},"messageNotBlank":"This field must not be empty.","txid":"TXID","sequenceNumber":{"label":"Sequence Number","empty":"none"},"transactionState":"State"}}')},jAFz:function(e,t){e.exports='{% block sw_order_detail_delivery_metadata %}\n {% parent %}\n\n \n{% endblock %}\n'},m1C4:function(e){e.exports=JSON.parse('{"payone-payment":{"title":"PAYONE","general":{"mainMenuItemGeneral":"PAYONE","descriptionTextModule":"Einstellungen für PAYONE"},"capture":{"buttonTitle":"Capture","successTitle":"PAYONE","successMessage":"Capture erfolgreich durchgeführt.","errorTitle":"PAYONE"},"refund":{"buttonTitle":"Refund","successTitle":"PAYONE","successMessage":"Refund erfolgreich durchgeführt.","errorTitle":"PAYONE"},"settingsForm":{"save":"Speichern","test":"API-Zugangsdaten testen","titleSuccess":"Erfolg","titleError":"Fehler","messageTestSuccess":"Die API-Zugangsdaten wurden erfolgreich validiert.","messageTestNoTestedPayments":"Bei der Prüfung wurden keine Zahlarten getestet, weil keine der PAYONE Zahlarten aktiviert ist. Bitte aktivieren Sie mindestens eine PAYONE Zahlart unter Einstellungen --\x3e Shop --\x3e Zahlungsarten.","messageTestError":{"general":"Die API-Zugangsdaten konnten nicht validiert werden.","creditCard":"Die API-Zugangsdaten für Kreditkarte sind nicht korrekt.","debit":"Die API-Zugangsdaten für Lastschrift sind nicht korrekt.","paypalExpress":"Die API-Zugangsdaten für PayPal Express sind nicht korrekt.","paypal":"Die API-Zugangsdaten für PayPal sind nicht korrekt.","payolutionInstallment":"Die API-Zugangsdaten für Paysafe Pay Later Ratenzahlung sind nicht korrekt.","payolutionInvoicing":"Die API-Zugangsdaten für Paysafe Pay Later Rechnungskauf sind nicht korrekt.","payolutionDebit":"Die API-Zugangsdaten für Paysafe Pay Later Lastschrift sind nicht korrekt.","sofort":"Die API-Zugangsdaten für SOFORT sind nicht korrekt.","iDeal":"Die API-Zugangsdaten für iDEAL sind nicht korrekt."}},"supportModal":{"menuButton":"Support","title":"Wie können wir Ihnen helfen?","documentation":{"description":"Lesen Sie unsere Online-Dokumentation","button":"Dokumentation"},"support":{"description":"Kontaktieren Sie unseren technischen Support","button":"Technischer Support"},"repository":{"description":"Melden Sie Fehler und Verbesserungen auf GitHub","button":"GitHub"}},"transitionActionNames":{"cancel":"Stornieren","complete":"Abschließen","pay":"Bezahlen","pay_partially":"Teilweise bezahlen","process":"Durchführen","refund":"Rückerstatten","refund_partially":"Teilweise rückerstatten","remind":"Erinnern","reopen":"Wieder öffnen","retour":"Retoure","retour_partially":"Teilweise retounieren","ship":"Versenden","ship_partially":"Teilweise versenden"},"messageNotBlank":"Dieser Wert darf nicht leer sein.","txid":"TXID","sequenceNumber":{"label":"Sequenznummer","empty":"keine"},"transactionState":"Status"}}')},mLM4:function(e,t){e.exports='{% block payone_payment %}\n\n {% block payone_payment_header %}\n \n {% endblock %}\n\n {% block payone_payment_actions %}\n \n {% endblock %}\n\n {% block payone_payment_settings_content %}\n \n {% endblock %}\n\n{% endblock %}\n'}},[["OPxs","runtime","vendors-node"]]]); \ No newline at end of file From e58e5f4834b38b1fbabe2555572dc2986103cf8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 30 Jun 2020 11:42:24 +0200 Subject: [PATCH 10/13] Fix code style issue --- src/Controller/RedirectController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/RedirectController.php b/src/Controller/RedirectController.php index d3510e623..21e031ba7 100644 --- a/src/Controller/RedirectController.php +++ b/src/Controller/RedirectController.php @@ -25,7 +25,7 @@ public function __construct(RedirectHandler $redirectHandler) /** * @RouteScope(scopes={"storefront"}) - * @Route("/payone/redirect", name="payone_redirect", defaults={"csrf_protected"=false}) + * @Route("/payone/redirect", name="payone_redirect", defaults={"csrf_protected": false}) */ public function execute(Request $request): Response { From b779fa67cdbc87e272a28936ee30b2ff0a22d721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 30 Jun 2020 11:56:32 +0200 Subject: [PATCH 11/13] Fix invalid handler reference --- src/DependencyInjection/handler/payment_handler.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DependencyInjection/handler/payment_handler.xml b/src/DependencyInjection/handler/payment_handler.xml index 6b297fe68..7f9894056 100644 --- a/src/DependencyInjection/handler/payment_handler.xml +++ b/src/DependencyInjection/handler/payment_handler.xml @@ -112,7 +112,7 @@ - + From 014067758afe7b167cd510d30d15312fb57c61fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 30 Jun 2020 11:40:24 +0200 Subject: [PATCH 12/13] Build administration files --- src/Resources/public/administration/js/payone-payment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/public/administration/js/payone-payment.js b/src/Resources/public/administration/js/payone-payment.js index eebb30fd4..25476ae43 100644 --- a/src/Resources/public/administration/js/payone-payment.js +++ b/src/Resources/public/administration/js/payone-payment.js @@ -1 +1 @@ -(this.webpackJsonp=this.webpackJsonp||[]).push([["payone-payment"],{"+ZX5":function(e,t,n){var a=n("RWCW");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("b30379ae",a,!0,{})},"0gwv":function(e,t,n){},"2amc":function(e,t,n){},"39qa":function(e,t,n){},"6dql":function(e,t,n){},"6gA7":function(e,t){e.exports='{% block sw_settings_content_card_slot_plugins %}\n {% parent %}\n\n \n \n \n{% endblock %}\n'},"8px5":function(e,t,n){"use strict";n.r(t);var a=n("ryVJ"),i=n.n(a);n("+ZX5");const{Component:s,Mixin:o,Context:r}=Shopware;s.register("payone-capture-button",{template:i.a,mixins:[o.getByName("notification")],inject:["PayonePaymentService","repositoryFactory"],props:{order:{type:Object,required:!0}},computed:{transaction(){return this.order.transactions[0]},totalTransactionAmount(){return Math.round(this.transaction.amount.totalPrice*10**this.order.currency.decimalPrecision,0)},capturedAmount(){return this.transaction.customFields&&void 0!==this.transaction.customFields.payone_captured_amount?this.transaction.customFields.payone_captured_amount:0},remainingAmount(){return this.totalTransactionAmount-this.capturedAmount},maxCaptureAmount(){return this.remainingAmount/10**this.order.currency.decimalPrecision},buttonEnabled(){return!!this.transaction.customFields&&(this.remainingAmount>0&&this.capturedAmount>0||this.transaction.customFields.payone_allow_capture)},captureButtonDisabled(){return!!this.isLoading||this.captureAmount<=0}},data:()=>({isLoading:!1,hasError:!1,showCaptureModal:!1,isCaptureSuccessful:!1,selection:[],captureAmount:0}),methods:{calculateCaptureAmount(){let e=0;this.selection.forEach(t=>{t.selected&&(e+=t.unit_price*t.quantity)}),e>this.remainingAmount&&(e=this.remainingAmount),this.captureAmount=e},openCaptureModal(){this.showCaptureModal=!0,this.isCaptureSuccessful=!1,this.selection=[]},closeCaptureModal(){this.showCaptureModal=!1},onCaptureFinished(){this.isCaptureSuccessful=!1},captureOrder(){const e={orderTransactionId:this.transaction.id,payone_order_id:this.transaction.customFields.payone_transaction_id,salesChannel:this.order.salesChannel,amount:this.captureAmount,orderLines:[],complete:this.captureAmount===this.remainingAmount};this.isLoading=!0,this.selection.forEach(t=>{this.order.lineItems.forEach(n=>{if(n.id===t.id&&t.selected&&0{this.order.lineItems.forEach(n=>{if(n.id===t.id&&0{this.createNotificationSuccess({title:this.$tc("payone-payment.capture.successTitle"),message:this.$tc("payone-payment.capture.successMessage")}),this.isCaptureSuccessful=!0}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.capture.errorTitle"),message:e.message}),this.isCaptureSuccessful=!1}).finally(()=>{this.isLoading=!1,this.closeCaptureModal(),this.$nextTick().then(()=>{this.$emit("reload")})})},onSelectItem(e,t){0===this.selection.length&&this._populateSelectionProperty(),this.selection.forEach(n=>{n.id===e&&(n.selected=t)}),this.calculateCaptureAmount()},onChangeQuantity(e,t){0===this.selection.length&&this._populateSelectionProperty(),this.selection.forEach(n=>{n.id===e&&(n.quantity=t)}),this.calculateCaptureAmount()},_populateSelectionProperty(){this.order.lineItems.forEach(e=>{let t=e.quantity;e.customFields&&e.customFields.payone_captured_quantity&&0({isLoading:!1,hasError:!1,showRefundModal:!1,isRefundSuccessful:!1,selection:[],refundAmount:0}),computed:{transaction(){return this.order.transactions[0]},remainingAmount(){return void 0===this.transaction.customFields||void 0===this.transaction.customFields.payone_captured_amount?0:this.transaction.customFields.payone_captured_amount-this.refundedAmount},refundedAmount(){return void 0===this.transaction.customFields||void 0===this.transaction.customFields.payone_refunded_amount?0:this.transaction.customFields.payone_refunded_amount},maxRefundAmount(){return this.remainingAmount/10**this.order.currency.decimalPrecision},buttonEnabled(){return!!this.transaction.customFields&&(this.remainingAmount>0&&this.refundedAmount>0||this.transaction.customFields.payone_allow_refund)}},methods:{calculateRefundAmount(){let e=0;this.selection.forEach(t=>{t.selected&&(e+=t.unit_price*t.quantity)}),Math.round(e*10**this.order.currency.decimalPrecision>this.remainingAmount)&&(e=this.remainingAmount/10**this.order.currency.decimalPrecision),this.refundAmount=e},openRefundModal(){this.showRefundModal=!0,this.isRefundSuccessful=!1,this.selection=[]},closeRefundModal(){this.showRefundModal=!1},onRefundFinished(){this.isRefundSuccessful=!1},refundOrder(){const e={orderTransactionId:this.transaction.id,payone_order_id:this.transaction.customFields.payone_transaction_id,salesChannel:this.order.salesChannel,amount:this.refundAmount,orderLines:[],complete:this.refundAmount===this.maxRefundAmount};this.isLoading=!0,this.selection.forEach(t=>{this.order.lineItems.forEach(n=>{if(n.id===t.id&&t.selected&&0{this.createNotificationSuccess({title:this.$tc("payone-payment.refund.successTitle"),message:this.$tc("payone-payment.refund.successMessage")}),this.isRefundSuccessful=!0}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.refund.errorTitle"),message:e.message}),this.isRefundSuccessful=!1}).finally(()=>{this.isLoading=!1,this.closeRefundModal(),this.$nextTick().then(()=>{this.$emit("reload")})})},refundFullOrder(){const e={orderTransactionId:this.transaction.id,payone_order_id:this.transaction.customFields.payone_transaction_id,salesChannel:this.order.salesChannel,amount:this.maxRefundAmount,orderLines:[],complete:!0};this.isLoading=!0,this._populateSelectionProperty(),this.selection.forEach(t=>{this.order.lineItems.forEach(n=>{if(n.id===t.id&&0{this.createNotificationSuccess({title:this.$tc("payone-payment.refund.successTitle"),message:this.$tc("payone-payment.refund.successMessage")}),this.isRefundSuccessful=!0}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.refund.errorTitle"),message:e.message}),this.isRefundSuccessful=!1}).finally(()=>{this.isLoading=!1,this.closeRefundModal(),this.$nextTick().then(()=>{this.$emit("reload")})})},onSelectItem(e,t){0===this.selection.length&&this._populateSelectionProperty(),this.selection.forEach(n=>{n.id===e&&(n.selected=t)}),this.calculateRefundAmount()},onChangeQuantity(e,t){0===this.selection.length&&this._populateSelectionProperty(),this.selection.forEach(n=>{n.id===e&&(n.quantity=t)}),this.calculateRefundAmount()},_populateSelectionProperty(){this.order.lineItems.forEach(e=>{let t=e.quantity;e.customFields&&e.customFields.payone_refunded_quantity&&0{const n=this.$options.filters.currency(t.totalPrice,this.order.currency.shortName,this.order.decimal_precision);let a=!1,i=t.quantity;t.customFields&&("refund"===this.mode?(t.customFields.payone_captured_quantity&&0>t.customFields.payone_captured_quantity&&(i=t.customFields.payone_captured_quantity),t.customFields.payone_refunded_quantity&&(i-=t.customFields.payone_refunded_quantity)):"capture"===this.mode&&t.customFields.payone_captured_quantity&&0i&&(a=!0),e.push({id:t.id,product:t.label,quantity:i,disabled:a,selected:!1,price:n,orderItem:t})}),e},orderItemColumns(){return[{property:"product",label:this.$tc("payone-payment.modal.columns.product"),rawData:!0},{property:"quantity",label:this.$tc("payone-payment.modal.columns.quantity"),rawData:!0},{property:"price",label:this.$tc("payone-payment.modal.columns.price"),rawData:!0}]}},methods:{onSelectItem(e,t,n){this.$emit("select-item",t.id,n)},onChangeQuantity(e,t){this.$emit("change-quantity",t,e)}}});var h=n("qAO5"),f=n.n(h);const{Component:g}=Shopware;g.extend("payone-data-grid","sw-data-grid",{template:f.a});var b=n("u0ga"),_=n.n(b);n("LO2o");const{Component:w,Mixin:P}=Shopware;w.register("payone-settings",{template:_.a,mixins:[P.getByName("notification"),P.getByName("sw-inline-snippet")],inject:["PayonePaymentSettingsService"],data:()=>({isLoading:!1,isTesting:!1,isSaveSuccessful:!1,isTestSuccessful:!1,config:{},merchantIdFilled:!1,accountIdFilled:!1,portalIdFilled:!1,portalKeyFilled:!1,showValidationErrors:!1,isSupportModalOpen:!1,stateMachineTransitionActions:[],collapsibleState:{status_mapping:!0,payment_credit_card:!0,payment_paypal:!0,payment_paypal_express:!0,payment_debit:!0,payment_sofort:!0,payment_payolution_installment:!0,payment_payolution_invoicing:!0,payment_payolution_debit:!0}}),created(){this.createdComponent()},computed:{credentialsMissing:function(){return!(this.merchantIdFilled&&this.accountIdFilled&&this.portalIdFilled&&this.portalKeyFilled)}},metaInfo(){return{title:this.$createTitle()}},methods:{createdComponent(){let e=this;this.PayonePaymentSettingsService.getStateMachineTransitionActions().then(t=>{t.data.forEach(t=>{e.stateMachineTransitionActions.push({label:e.$tc("payone-payment.transitionActionNames."+t.label),value:t.value})})})},paymentMethodPrefixes:()=>["creditCard","debit","paypal","paypalExpress","payolutionInvoicing","payolutionInstallment","payolutionDebit","sofort"],isCollapsible(e){return e.name in this.collapsibleState},displayField(e,t,n){return!(n.name in this.collapsibleState)||!this.collapsibleState[n.name]},isCollapsed(e){return this.collapsibleState[e.name]},toggleCollapsible(e){e.name in this.collapsibleState&&(this.collapsibleState[e.name]=!this.collapsibleState[e.name])},saveFinish(){this.isSaveSuccessful=!1},testFinish(){this.isTestSuccessful=!1},onConfigChange(e){this.config=e,this.checkCredentialsFilled(),this.showValidationErrors=!1},checkCredentialsFilled(){this.merchantIdFilled=!!this.getConfigValue("merchantId"),this.accountIdFilled=!!this.getConfigValue("accountId"),this.portalIdFilled=!!this.getConfigValue("portalId"),this.portalKeyFilled=!!this.getConfigValue("portalKey")},getConfigValue(e){const t=this.$refs.systemConfig.actualConfigData.null;return null===this.$refs.systemConfig.currentSalesChannelId?this.config[`PayonePayment.settings.${e}`]:this.config[`PayonePayment.settings.${e}`]||t[`PayonePayment.settings.${e}`]},getPaymentConfigValue(e,t){let n=e.charAt(0).toUpperCase()+e.slice(1);return this.getConfigValue(t+n)||this.getConfigValue(e)},onSave(){this.credentialsMissing?this.showValidationErrors=!0:(this.isSaveSuccessful=!1,this.isLoading=!0,this.$refs.systemConfig.saveAll().then(()=>{this.isLoading=!1,this.isSaveSuccessful=!0}).catch(()=>{this.isLoading=!1}))},onTest(){this.isTesting=!0,this.isTestSuccessful=!1;let e={};this.paymentMethodPrefixes().forEach(t=>{e[t]={merchantId:this.getPaymentConfigValue("merchantId",t),accountId:this.getPaymentConfigValue("accountId",t),portalId:this.getPaymentConfigValue("portalId",t),portalKey:this.getPaymentConfigValue("portalKey",t)}}),this.PayonePaymentSettingsService.validateApiCredentials(e).then(e=>{const t=e.testCount,n=e.credentialsValid,a=e.errors;if(n)this.createNotificationSuccess({title:this.$tc("payone-payment.settingsForm.titleSuccess"),message:t>0?this.$tc("payone-payment.settingsForm.messageTestSuccess"):this.$tc("payone-payment.settingsForm.messageTestNoTestedPayments")}),this.isTestSuccessful=!0;else for(let e in a)a.hasOwnProperty(e)&&this.createNotificationError({title:this.$tc("payone-payment.settingsForm.titleError"),message:this.$tc("payone-payment.settingsForm.messageTestError."+e)});this.isTesting=!1}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.settingsForm.titleError"),message:this.$tc("payone-payment.settingsForm.messageTestError.general")}),this.isTesting=!1})},getBind(e,t){return t!==this.config&&this.onConfigChange(t),this.showValidationErrors&&("PayonePayment.settings.merchantId"!==e.name||this.merchantIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.accountId"!==e.name||this.accountIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.portalId"!==e.name||this.portalIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.portalKey"!==e.name||this.portalKeyFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")})),e}}});var v=n("yse3"),S=n.n(v);n("vpUQ");const{Component:A,Mixin:C}=Shopware;A.override("sw-order-detail-base",{template:S.a,inject:["PayonePaymentService"],mixins:[C.getByName("notification")],data:()=>({disableButtons:!1}),methods:{isPayonePayment:e=>!!e.customFields&&e.customFields.payone_transaction_id,hasPayonePayment(e){let t=this,n=!1;return!!e.transactions&&(e.transactions.map((function(e){t.isPayonePayment(e)&&(n=!0)})),n)}}});var k=n("6gA7"),x=n.n(k);n("UG+L");const{Component:E}=Shopware;E.override("sw-settings-index",{template:x.a});n("kdYO");var I=n("GCI0"),F=n("cp9z");const{Module:T}=Shopware;T.register("payone-payment",{type:"plugin",name:"PayonePayment",title:"payone-payment.general.mainMenuItemGeneral",description:"payone-payment.general.descriptionTextModule",version:"1.0.0",targetVersion:"1.0.0",icon:"default-action-settings",snippets:{"de-DE":I,"en-GB":F},routeMiddleware(e,t){e(t)},routes:{index:{component:"payone-settings",path:"index",meta:{parentPath:"sw.settings.index"}}}});n("Kbji"),n("xLPZ")},AZXl:function(e,t,n){var a=n("Wz7V");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("5e924171",a,!0,{})},Enq4:function(e,t){e.exports='{% block payone_payment_payment_details %}\n
\n \n \n {{ $tc(\'payone-payment.refund.buttonTitle\') }}\n \n \n\n \n \n \n\n
\n \n \n \n \n \n \n
\n\n \n
\n
\n{% endblock %}\n'},GCI0:function(e){e.exports=JSON.parse('{"payone-payment":{"title":"PAYONE","general":{"mainMenuItemGeneral":"PAYONE","descriptionTextModule":"Einstellungen für PAYONE"},"capture":{"buttonTitle":"Capture","successTitle":"PAYONE","successMessage":"Capture erfolgreich durchgeführt.","errorTitle":"PAYONE","errorMessage":"Capture konnte nicht durchgeführt werden.","tooltips":{"impossible":"Einzug unmöglich"}},"refund":{"buttonTitle":"Refund","successTitle":"PAYONE","successMessage":"Refund erfolgreich durchgeführt.","errorTitle":"PAYONE","errorMessage":"Refund konnte nicht durchgeführt werden.","tooltips":{"impossible":"Erstattung unmöglich"}},"modal":{"capture":{"title":"Einzug","submit":"Einziehen","fullSubmit":"Alles Einziehen","amount":"Einzugswert","captured":"Eingezogener Wert"},"refund":{"title":"Erstattung","submit":"Erstatten","fullSubmit":"Alles Erstatten","amount":"Erstattungswert","refunded":"Erstatteter Wert"},"close":"Schließen","orderAmount":"Bestellungswert","remainingAmount":"Ausstehender Wert","labelComment":"Label comment","descriptionHelpText":"Description help text","columns":{"reference":"Referenz","product":"Produkt","quantity":"Anzahl","price":"Preis"}},"settingsForm":{"save":"Speichern","test":"API-Zugangsdaten testen","titleSuccess":"Erfolg","titleError":"Fehler","messageTestSuccess":"Die API-Zugangsdaten wurden erfolgreich validiert.","messageTestNoTestedPayments":"Bei der Prüfung wurden keine Zahlarten getestet, weil keine der PAYONE Zahlarten aktiviert ist. Bitte aktivieren Sie mindestens eine PAYONE Zahlart unter Einstellungen --\x3e Shop --\x3e Zahlungsarten.","messageTestError":{"general":"Die API-Zugangsdaten konnten nicht validiert werden.","creditCard":"Die API-Zugangsdaten für Kreditkarte sind nicht korrekt.","debit":"Die API-Zugangsdaten für Lastschrift sind nicht korrekt.","paypalExpress":"Die API-Zugangsdaten für PayPal Express sind nicht korrekt.","paypal":"Die API-Zugangsdaten für PayPal sind nicht korrekt.","payolutionInstallment":"Die API-Zugangsdaten für Paysafe Pay Later Ratenzahlung sind nicht korrekt.","payolutionInvoicing":"Die API-Zugangsdaten für Paysafe Pay Later Rechnungskauf sind nicht korrekt.","payolutionDebit":"Die API-Zugangsdaten für Paysafe Pay Later Lastschrift sind nicht korrekt.","sofort":"Die API-Zugangsdaten für SOFORT sind nicht korrekt."}},"supportModal":{"menuButton":"Support","title":"Wie können wir Ihnen helfen?","documentation":{"description":"Lesen Sie unsere Online-Dokumentation","button":"Dokumentation"},"support":{"description":"Kontaktieren Sie unseren technischen Support","button":"Technischer Support"},"repository":{"description":"Melden Sie Fehler und Verbesserungen auf GitHub","button":"GitHub"}},"transitionActionNames":{"cancel":"Stornieren","complete":"Abschließen","pay":"Bezahlen","pay_partially":"Teilweise bezahlen","process":"Durchführen","refund":"Rückerstatten","refund_partially":"Teilweise rückerstatten","remind":"Erinnern","reopen":"Wieder öffnen","retour":"Retoure","retour_partially":"Teilweise retounieren","ship":"Versenden","ship_partially":"Teilweise versenden"},"messageNotBlank":"Dieser Wert darf nicht leer sein.","txid":"TXID","sequenceNumber":{"label":"Sequenznummer","empty":"keine"},"transactionState":"Status","error":{"transaction":{"notFound":"Es wurde keine passende Transaktion gefundend","orderNotFound":"Es wurde keine passende Bestellung gefundend"}}}}')},IorZ:function(e,t,n){var a=n("2amc");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("5a07224e",a,!0,{})},Kbji:function(e,t){const{Application:n}=Shopware,a=Shopware.Classes.ApiService;class i extends a{constructor(e,t,n="payone"){super(e,t,n)}capturePayment(e){const t=`_action/${this.getApiBasePath()}/capture-payment`;return this.httpClient.post(t,e,{headers:this.getBasicHeaders()}).then(e=>a.handleResponse(e))}refundPayment(e){const t=`_action/${this.getApiBasePath()}/refund-payment`;return this.httpClient.post(t,e,{headers:this.getBasicHeaders()}).then(e=>a.handleResponse(e))}}n.addServiceProvider("PayonePaymentService",e=>{const t=n.getContainer("init");return new i(t.httpClient,e.loginService)})},LO2o:function(e,t,n){var a=n("0gwv");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("4a1eb8e9",a,!0,{})},RWCW:function(e,t,n){},"UG+L":function(e,t,n){var a=n("6dql");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("e9fd0dc8",a,!0,{})},Wz7V:function(e,t,n){},cp9z:function(e){e.exports=JSON.parse('{"payone-payment":{"title":"PAYONE","general":{"mainMenuItemGeneral":"PAYONE","descriptionTextModule":"Settings for PAYONE"},"capture":{"buttonTitle":"Capture","successTitle":"PAYONE","successMessage":"Capture processed successfully.","errorTitle":"PAYONE","errorMessage":"Capture could not be processed.","tooltips":{"impossible":"Capture impossible"}},"refund":{"buttonTitle":"Refund","successTitle":"PAYONE","successMessage":"Refund processed successfully.","errorTitle":"PAYONE","errorMessage":"Refund could not be processed.","tooltips":{"impossible":"Refund impossible"}},"modal":{"capture":{"title":"Capture","submit":"Capture","fullSubmit":"Full capture","amount":"Capture amount","captured":"Captured amount"},"refund":{"title":"Refund","submit":"Refund","fullSubmit":"Full Refund","amount":"Refund amount","refunded":"Refunded amount"},"orderAmount":"Order amount","remainingAmount":"Remaining amount","descriptionHelpText":"Description help text","close":"Close","labelComment":"Label comment","columns":{"reference":"Reference","product":"Product","quantity":"Quantity","price":"Price"}},"settingsForm":{"save":"Save","test":"Test API Credentials","titleSuccess":"Success","titleError":"Error","messageTestSuccess":"The API credentials were verified successfully.","messageTestNoTestedPayments":"No payment methods were tested during the check because none of the PAYONE payment methods are activated. Please activate at least one PAYONE payment method under Settings --\x3e Shop --\x3e Payment.","messageTestError":{"general":"The API credentials could not be verified successfully.","creditCard":"The API credentials for Credit Card are not valid.","debit":"The API credentials for Debit are not valid.","paypalExpress":"The API credentials for PayPal Express are not valid.","paypal":"The API credentials for PayPal are not valid.","payolutionInstallment":"The API credentials for Paysafe Pay Later Installment are not valid.","payolutionInvoicing":"The API credentials for Paysafe Pay Later Invoicing are not valid.","payolutionDebit":"The API credentials for Paysafe Pay Later Debit are not valid.","sofort":"The API credentials for SOFORT are not valid."}},"supportModal":{"menuButton":"Support","title":"How Can We Help You?","documentation":{"description":"Read our online manual","button":"Online Manual"},"support":{"description":"Contact our technical support","button":"Tech Support"},"repository":{"description":"Report errors on GitHub","button":"GitHub"}},"transitionActionNames":{"cancel":"Cancel","complete":"Complete","pay":"Pay","pay_partially":"Pay partially","process":"Process","refund":"Refund","refund_partially":"Refund partially","remind":"Remind","reopen":"Reopen","retour":"Retour","retour_partially":"Retour partially","ship":"Ship","ship_partially":"Ship partially"},"messageNotBlank":"This field must not be empty.","txid":"TXID","sequenceNumber":{"label":"Sequence Number","empty":"none"},"transactionState":"State","error":{"transaction":{"notFound":"No matching transaction could be found","orderNotFound":"No matching order could be found"}}}}')},kdYO:function(e,t){const{Filter:n}=Shopware,{currency:a}=Shopware.Utils.format;n.register("payone_currency",(e,t,n,i)=>null===e?"-":(n||(n=0),a(e/=10**n,t,i)))},p9i7:function(e,t){e.exports='{% block payone_payment_details %}\n
\n \n\n \n\n \n\n \n \n
\n{% endblock %}\n'},qAO5:function(e,t){e.exports='{% block sw_data_grid_select_item_checkbox %}\n \n \n\n \n \n{% endblock %}\n'},ryVJ:function(e,t){e.exports='{% block payone_payment_payment_details %}\n
\n \n \n {{ $tc(\'payone-payment.capture.buttonTitle\') }}\n \n \n\n \n \n \n\n
\n \n \n \n \n \n \n
\n\n \n
\n
\n{% endblock %}\n'},u0ga:function(e,t){e.exports='{% block payone_payment %}\n\n {% block payone_payment_header %}\n \n {% endblock %}\n\n {% block payone_payment_actions %}\n \n {% endblock %}\n\n {% block payone_payment_settings_content %}\n \n {% endblock %}\n\n{% endblock %}\n'},vpUQ:function(e,t,n){var a=n("39qa");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("1359af28",a,!0,{})},xLPZ:function(e,t){const{Application:n}=Shopware,a=Shopware.Classes.ApiService;class i extends a{constructor(e,t,n="payone_payment"){super(e,t,n)}validateApiCredentials(e){const t=this.getBasicHeaders();return this.httpClient.post(`_action/${this.getApiBasePath()}/validate-api-credentials`,{credentials:e},{headers:t}).then(e=>a.handleResponse(e))}getStateMachineTransitionActions(){const e=this.getBasicHeaders();return this.httpClient.get(`_action/${this.getApiBasePath()}/get-state-machine-transition-actions`,{headers:e}).then(e=>a.handleResponse(e))}}n.addServiceProvider("PayonePaymentSettingsService",e=>{const t=n.getContainer("init");return new i(t.httpClient,e.loginService)})},yse3:function(e,t){e.exports='{% block sw_order_detail_delivery_metadata %}\n {% parent %}\n\n \n{% endblock %}\n'}},[["8px5","runtime","vendors-node"]]]); +(this.webpackJsonp=this.webpackJsonp||[]).push([["payone-payment"],{"4yeS":function(e,t,n){},AuFV:function(e,t){e.exports='{% block sw_data_grid_select_item_checkbox %}\n \n \n\n \n \n{% endblock %}\n'},DMdC:function(e,t,n){},E7l4:function(e,t){e.exports='{% block payone_payment_details %}\n
\n \n\n \n\n \n\n \n \n
\n{% endblock %}\n'},Jolr:function(e,t,n){var a=n("s6j0");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("f1a6c96e",a,!0,{})},KBQv:function(e,t){const{Application:n}=Shopware,a=Shopware.Classes.ApiService;class i extends a{constructor(e,t,n="payone"){super(e,t,n)}capturePayment(e){const t=`_action/${this.getApiBasePath()}/capture-payment`;return this.httpClient.post(t,e,{headers:this.getBasicHeaders()}).then(e=>a.handleResponse(e))}refundPayment(e){const t=`_action/${this.getApiBasePath()}/refund-payment`;return this.httpClient.post(t,e,{headers:this.getBasicHeaders()}).then(e=>a.handleResponse(e))}}n.addServiceProvider("PayonePaymentService",e=>{const t=n.getContainer("init");return new i(t.httpClient,e.loginService)})},Klmz:function(e,t,n){var a=n("zsm5");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("a28cbb14",a,!0,{})},Lvox:function(e,t,n){var a=n("DMdC");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("3806acf0",a,!0,{})},McCE:function(e,t,n){var a=n("McMq");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("f06f327e",a,!0,{})},McMq:function(e,t,n){},NXBA:function(e,t,n){},OPxs:function(e,t,n){"use strict";n.r(t);var a=n("asGc"),i=n.n(a);n("qwju");const{Component:s,Mixin:o,Context:r}=Shopware;s.register("payone-capture-button",{template:i.a,mixins:[o.getByName("notification")],inject:["PayonePaymentService","repositoryFactory"],props:{order:{type:Object,required:!0}},computed:{transaction(){return this.order.transactions[0]},totalTransactionAmount(){return Math.round(this.transaction.amount.totalPrice*10**this.order.currency.decimalPrecision,0)},capturedAmount(){return this.transaction.customFields&&void 0!==this.transaction.customFields.payone_captured_amount?this.transaction.customFields.payone_captured_amount:0},remainingAmount(){return this.totalTransactionAmount-this.capturedAmount},maxCaptureAmount(){return this.remainingAmount/10**this.order.currency.decimalPrecision},buttonEnabled(){return!!this.transaction.customFields&&(this.remainingAmount>0&&this.capturedAmount>0||this.transaction.customFields.payone_allow_capture)}},data:()=>({isLoading:!1,hasError:!1,showCaptureModal:!1,isCaptureSuccessful:!1,selection:[],captureAmount:0}),methods:{calculateCaptureAmount(){let e=0;this.selection.forEach(t=>{t.selected&&(e+=t.unit_price*t.quantity)}),e>this.remainingAmount&&(e=this.remainingAmount),this.captureAmount=e},openCaptureModal(){this.showCaptureModal=!0,this.isCaptureSuccessful=!1,this.selection=[]},closeCaptureModal(){this.showCaptureModal=!1},onCaptureFinished(){this.isCaptureSuccessful=!1},captureOrder(){const e={orderTransactionId:this.transaction.id,payone_order_id:this.transaction.customFields.payone_transaction_id,salesChannel:this.order.salesChannel,amount:this.captureAmount,orderLines:[],complete:this.captureAmount===this.remainingAmount};this.isLoading=!0,this.selection.forEach(t=>{this.order.lineItems.forEach(n=>{if(n.id===t.id&&t.selected&&0{this.order.lineItems.forEach(n=>{if(n.id===t.id&&0{this.createNotificationSuccess({title:this.$tc("payone-payment.capture.successTitle"),message:this.$tc("payone-payment.capture.successMessage")}),this.isCaptureSuccessful=!0}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.capture.errorTitle"),message:e.message}),this.isCaptureSuccessful=!1}).finally(()=>{this.isLoading=!1,this.closeCaptureModal(),this.$nextTick().then(()=>{this.$emit("reload")})})},onSelectItem(e,t){0===this.selection.length&&this._populateSelectionProperty(),this.selection.forEach(n=>{n.id===e&&(n.selected=t)}),this.calculateCaptureAmount()},onChangeQuantity(e,t){0===this.selection.length&&this._populateSelectionProperty(),this.selection.forEach(n=>{n.id===e&&(n.quantity=t)}),this.calculateCaptureAmount()},_populateSelectionProperty(){this.order.lineItems.forEach(e=>{let t=e.quantity;e.customFields&&e.customFields.payone_captured_quantity&&0({isLoading:!1,hasError:!1,showRefundModal:!1,isRefundSuccessful:!1,selection:[],refundAmount:0}),computed:{transaction(){return this.order.transactions[0]},remainingAmount(){return void 0===this.transaction.customFields||void 0===this.transaction.customFields.payone_captured_amount?0:this.transaction.customFields.payone_captured_amount-this.refundedAmount},refundedAmount(){return void 0===this.transaction.customFields||void 0===this.transaction.customFields.payone_refunded_amount?0:this.transaction.customFields.payone_refunded_amount},maxRefundAmount(){return this.remainingAmount/10**this.order.currency.decimalPrecision},buttonEnabled(){return!!this.transaction.customFields&&(this.remainingAmount>0&&this.refundedAmount>0||this.transaction.customFields.payone_allow_refund)}},methods:{calculateRefundAmount(){let e=0;this.selection.forEach(t=>{t.selected&&(e+=t.unit_price*t.quantity)}),Math.round(e*10**this.order.currency.decimalPrecision>this.remainingAmount)&&(e=this.remainingAmount/10**this.order.currency.decimalPrecision),this.refundAmount=e},openRefundModal(){this.showRefundModal=!0,this.isRefundSuccessful=!1,this.selection=[]},closeRefundModal(){this.showRefundModal=!1},onRefundFinished(){this.isRefundSuccessful=!1},refundOrder(){const e={orderTransactionId:this.transaction.id,payone_order_id:this.transaction.customFields.payone_transaction_id,salesChannel:this.order.salesChannel,amount:this.refundAmount,orderLines:[],complete:this.refundAmount===this.maxRefundAmount};this.isLoading=!0,this.selection.forEach(t=>{this.order.lineItems.forEach(n=>{if(n.id===t.id&&t.selected&&0{this.createNotificationSuccess({title:this.$tc("payone-payment.refund.successTitle"),message:this.$tc("payone-payment.refund.successMessage")}),this.isRefundSuccessful=!0}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.refund.errorTitle"),message:e.message}),this.isRefundSuccessful=!1}).finally(()=>{this.isLoading=!1,this.closeRefundModal(),this.$nextTick().then(()=>{this.$emit("reload")})})},refundFullOrder(){const e={orderTransactionId:this.transaction.id,payone_order_id:this.transaction.customFields.payone_transaction_id,salesChannel:this.order.salesChannel,amount:this.maxRefundAmount,orderLines:[],complete:!0};this.isLoading=!0,this._populateSelectionProperty(),this.selection.forEach(t=>{this.order.lineItems.forEach(n=>{if(n.id===t.id&&0{this.createNotificationSuccess({title:this.$tc("payone-payment.refund.successTitle"),message:this.$tc("payone-payment.refund.successMessage")}),this.isRefundSuccessful=!0}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.refund.errorTitle"),message:e.message}),this.isRefundSuccessful=!1}).finally(()=>{this.isLoading=!1,this.closeRefundModal(),this.$nextTick().then(()=>{this.$emit("reload")})})},onSelectItem(e,t){0===this.selection.length&&this._populateSelectionProperty(),this.selection.forEach(n=>{n.id===e&&(n.selected=t)}),this.calculateRefundAmount()},onChangeQuantity(e,t){0===this.selection.length&&this._populateSelectionProperty(),this.selection.forEach(n=>{n.id===e&&(n.quantity=t)}),this.calculateRefundAmount()},_populateSelectionProperty(){this.order.lineItems.forEach(e=>{let t=e.quantity;e.customFields&&e.customFields.payone_refunded_quantity&&0{const n=this.$options.filters.currency(t.totalPrice,this.order.currency.shortName,this.order.decimal_precision);let a=!1,i=t.quantity;t.customFields&&("refund"===this.mode?(t.customFields.payone_captured_quantity&&0>t.customFields.payone_captured_quantity&&(i=t.customFields.payone_captured_quantity),t.customFields.payone_refunded_quantity&&(i-=t.customFields.payone_refunded_quantity)):"capture"===this.mode&&t.customFields.payone_captured_quantity&&0i&&(a=!0),e.push({id:t.id,product:t.label,quantity:i,disabled:a,selected:!1,price:n,orderItem:t})}),e},orderItemColumns(){return[{property:"product",label:this.$tc("payone-payment.modal.columns.product"),rawData:!0},{property:"quantity",label:this.$tc("payone-payment.modal.columns.quantity"),rawData:!0},{property:"price",label:this.$tc("payone-payment.modal.columns.price"),rawData:!0}]}},methods:{onSelectItem(e,t,n){this.$emit("select-item",t.id,n)},onChangeQuantity(e,t){this.$emit("change-quantity",t,e)}}});var h=n("AuFV"),f=n.n(h);const{Component:g}=Shopware;g.extend("payone-data-grid","sw-data-grid",{template:f.a});var b=n("mLM4"),_=n.n(b);n("McCE");const{Component:w,Mixin:P}=Shopware;w.register("payone-settings",{template:_.a,mixins:[P.getByName("notification"),P.getByName("sw-inline-snippet")],inject:["PayonePaymentSettingsService"],data:()=>({isLoading:!1,isTesting:!1,isSaveSuccessful:!1,isTestSuccessful:!1,config:{},merchantIdFilled:!1,accountIdFilled:!1,portalIdFilled:!1,portalKeyFilled:!1,showValidationErrors:!1,isSupportModalOpen:!1,stateMachineTransitionActions:[],collapsibleState:{status_mapping:!0,payment_credit_card:!0,payment_paypal:!0,payment_paypal_express:!0,payment_debit:!0,payment_sofort:!0,payment_payolution_installment:!0,payment_payolution_invoicing:!0,payment_payolution_debit:!0}}),created(){this.createdComponent()},computed:{credentialsMissing:function(){return!(this.merchantIdFilled&&this.accountIdFilled&&this.portalIdFilled&&this.portalKeyFilled)}},metaInfo(){return{title:this.$createTitle()}},methods:{createdComponent(){let e=this;this.PayonePaymentSettingsService.getStateMachineTransitionActions().then(t=>{t.data.forEach(t=>{e.stateMachineTransitionActions.push({label:e.$tc("payone-payment.transitionActionNames."+t.label),value:t.value})})})},paymentMethodPrefixes:()=>["creditCard","debit","paypal","paypalExpress","payolutionInvoicing","payolutionInstallment","payolutionDebit","sofort","iDeal"],isCollapsible(e){return e.name in this.collapsibleState},displayField(e,t,n){return!(n.name in this.collapsibleState)||!this.collapsibleState[n.name]},isCollapsed(e){return this.collapsibleState[e.name]},toggleCollapsible(e){e.name in this.collapsibleState&&(this.collapsibleState[e.name]=!this.collapsibleState[e.name])},saveFinish(){this.isSaveSuccessful=!1},testFinish(){this.isTestSuccessful=!1},onConfigChange(e){this.config=e,this.checkCredentialsFilled(),this.showValidationErrors=!1},checkCredentialsFilled(){this.merchantIdFilled=!!this.getConfigValue("merchantId"),this.accountIdFilled=!!this.getConfigValue("accountId"),this.portalIdFilled=!!this.getConfigValue("portalId"),this.portalKeyFilled=!!this.getConfigValue("portalKey")},getConfigValue(e){const t=this.$refs.systemConfig.actualConfigData.null;return null===this.$refs.systemConfig.currentSalesChannelId?this.config[`PayonePayment.settings.${e}`]:this.config[`PayonePayment.settings.${e}`]||t[`PayonePayment.settings.${e}`]},getPaymentConfigValue(e,t){let n=e.charAt(0).toUpperCase()+e.slice(1);return this.getConfigValue(t+n)||this.getConfigValue(e)},onSave(){this.credentialsMissing?this.showValidationErrors=!0:(this.isSaveSuccessful=!1,this.isLoading=!0,this.$refs.systemConfig.saveAll().then(()=>{this.isLoading=!1,this.isSaveSuccessful=!0}).catch(()=>{this.isLoading=!1}))},onTest(){this.isTesting=!0,this.isTestSuccessful=!1;let e={};this.paymentMethodPrefixes().forEach(t=>{e[t]={merchantId:this.getPaymentConfigValue("merchantId",t),accountId:this.getPaymentConfigValue("accountId",t),portalId:this.getPaymentConfigValue("portalId",t),portalKey:this.getPaymentConfigValue("portalKey",t)}}),this.PayonePaymentSettingsService.validateApiCredentials(e).then(e=>{const t=e.testCount,n=e.credentialsValid,a=e.errors;if(n)this.createNotificationSuccess({title:this.$tc("payone-payment.settingsForm.titleSuccess"),message:t>0?this.$tc("payone-payment.settingsForm.messageTestSuccess"):this.$tc("payone-payment.settingsForm.messageTestNoTestedPayments")}),this.isTestSuccessful=!0;else for(let e in a)a.hasOwnProperty(e)&&this.createNotificationError({title:this.$tc("payone-payment.settingsForm.titleError"),message:this.$tc("payone-payment.settingsForm.messageTestError."+e)});this.isTesting=!1}).catch(e=>{this.createNotificationError({title:this.$tc("payone-payment.settingsForm.titleError"),message:this.$tc("payone-payment.settingsForm.messageTestError.general")}),this.isTesting=!1})},getBind(e,t){return t!==this.config&&this.onConfigChange(t),this.showValidationErrors&&("PayonePayment.settings.merchantId"!==e.name||this.merchantIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.accountId"!==e.name||this.accountIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.portalId"!==e.name||this.portalIdFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")}),"PayonePayment.settings.portalKey"!==e.name||this.portalKeyFilled||(e.config.error={code:1,detail:this.$tc("payone-payment.messageNotBlank")})),e}}});var v=n("jAFz"),S=n.n(v);n("Lvox");const{Component:A,Mixin:C}=Shopware;A.override("sw-order-detail-base",{template:S.a,inject:["PayonePaymentService"],mixins:[C.getByName("notification")],data:()=>({disableButtons:!1}),methods:{isPayonePayment:e=>!!e.customFields&&e.customFields.payone_transaction_id,hasPayonePayment(e){let t=this,n=!1;return!!e.transactions&&(e.transactions.map((function(e){t.isPayonePayment(e)&&(n=!0)})),n)}}});var k=n("Yjca"),x=n.n(k);n("d11z");const{Component:E}=Shopware;E.override("sw-settings-index",{template:x.a});n("fzay");var F=n("m1C4"),I=n("eQpg");const{Module:T}=Shopware;T.register("payone-payment",{type:"plugin",name:"PayonePayment",title:"payone-payment.general.mainMenuItemGeneral",description:"payone-payment.general.descriptionTextModule",version:"1.0.0",targetVersion:"1.0.0",icon:"default-action-settings",snippets:{"de-DE":F,"en-GB":I},routeMiddleware(e,t){e(t)},routes:{index:{component:"payone-settings",path:"index",meta:{parentPath:"sw.settings.index"}}}});n("KBQv"),n("Q7qL")},Q7qL:function(e,t){const{Application:n}=Shopware,a=Shopware.Classes.ApiService;class i extends a{constructor(e,t,n="payone_payment"){super(e,t,n)}validateApiCredentials(e){const t=this.getBasicHeaders();return this.httpClient.post(`_action/${this.getApiBasePath()}/validate-api-credentials`,{credentials:e},{headers:t}).then(e=>a.handleResponse(e))}getStateMachineTransitionActions(){const e=this.getBasicHeaders();return this.httpClient.get(`_action/${this.getApiBasePath()}/get-state-machine-transition-actions`,{headers:e}).then(e=>a.handleResponse(e))}}n.addServiceProvider("PayonePaymentSettingsService",e=>{const t=n.getContainer("init");return new i(t.httpClient,e.loginService)})},Yjca:function(e,t){e.exports='{% block sw_settings_content_card_slot_plugins %}\n {% parent %}\n\n \n \n \n{% endblock %}\n'},asGc:function(e,t){e.exports='{% block payone_payment_payment_details %}\n
\n \n \n {{ $tc(\'payone-payment.capture.buttonTitle\') }}\n \n \n\n \n \n \n\n
\n \n \n \n \n \n \n
\n\n \n
\n
\n{% endblock %}\n'},d11z:function(e,t,n){var a=n("NXBA");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("e7715378",a,!0,{})},eQpg:function(e){e.exports=JSON.parse('{"payone-payment":{"title":"PAYONE","general":{"mainMenuItemGeneral":"PAYONE","descriptionTextModule":"Settings for PAYONE"},"capture":{"buttonTitle":"Capture","successTitle":"PAYONE","successMessage":"Capture processed successfully.","errorTitle":"PAYONE","errorMessage":"Capture could not be processed.","tooltips":{"impossible":"Capture impossible"}},"refund":{"buttonTitle":"Refund","successTitle":"PAYONE","successMessage":"Refund processed successfully.","errorTitle":"PAYONE","errorMessage":"Refund could not be processed.","tooltips":{"impossible":"Refund impossible"}},"modal":{"capture":{"title":"Capture","submit":"Capture","fullSubmit":"Full capture","amount":"Capture amount","captured":"Captured amount"},"refund":{"title":"Refund","submit":"Refund","fullSubmit":"Full Refund","amount":"Refund amount","refunded":"Refunded amount"},"orderAmount":"Order amount","remainingAmount":"Remaining amount","descriptionHelpText":"Description help text","close":"Close","labelComment":"Label comment","columns":{"reference":"Reference","product":"Product","quantity":"Quantity","price":"Price"}},"settingsForm":{"save":"Save","test":"Test API Credentials","titleSuccess":"Success","titleError":"Error","messageTestSuccess":"The API credentials were verified successfully.","messageTestNoTestedPayments":"No payment methods were tested during the check because none of the PAYONE payment methods are activated. Please activate at least one PAYONE payment method under Settings --\x3e Shop --\x3e Payment.","messageTestError":{"general":"The API credentials could not be verified successfully.","creditCard":"The API credentials for Credit Card are not valid.","debit":"The API credentials for Debit are not valid.","paypalExpress":"The API credentials for PayPal Express are not valid.","paypal":"The API credentials for PayPal are not valid.","payolutionInstallment":"The API credentials for Paysafe Pay Later Installment are not valid.","payolutionInvoicing":"The API credentials for Paysafe Pay Later Invoicing are not valid.","payolutionDebit":"The API credentials for Paysafe Pay Later Debit are not valid.","sofort":"The API credentials for SOFORT are not valid.","iDeal":"The API credentials for iDEAL are not valid."}},"supportModal":{"menuButton":"Support","title":"How Can We Help You?","documentation":{"description":"Read our online manual","button":"Online Manual"},"support":{"description":"Contact our technical support","button":"Tech Support"},"repository":{"description":"Report errors on GitHub","button":"GitHub"}},"transitionActionNames":{"cancel":"Cancel","complete":"Complete","pay":"Pay","pay_partially":"Pay partially","process":"Process","refund":"Refund","refund_partially":"Refund partially","remind":"Remind","reopen":"Reopen","retour":"Retour","retour_partially":"Retour partially","ship":"Ship","ship_partially":"Ship partially"},"messageNotBlank":"This field must not be empty.","txid":"TXID","sequenceNumber":{"label":"Sequence Number","empty":"none"},"transactionState":"State","error":{"transaction":{"notFound":"No matching transaction could be found","orderNotFound":"No matching order could be found"}}}}')},fBZk:function(e,t){e.exports='{% block payone_payment_payment_details %}\n
\n \n \n {{ $tc(\'payone-payment.refund.buttonTitle\') }}\n \n \n\n \n \n \n\n
\n \n \n \n \n \n \n
\n\n \n
\n
\n{% endblock %}\n'},fzay:function(e,t){const{Filter:n}=Shopware,{currency:a}=Shopware.Utils.format;n.register("payone_currency",(e,t,n,i)=>null===e?"-":(n||(n=0),a(e/=10**n,t,i)))},jAFz:function(e,t){e.exports='{% block sw_order_detail_delivery_metadata %}\n {% parent %}\n\n \n{% endblock %}\n'},m1C4:function(e){e.exports=JSON.parse('{"payone-payment":{"title":"PAYONE","general":{"mainMenuItemGeneral":"PAYONE","descriptionTextModule":"Einstellungen für PAYONE"},"capture":{"buttonTitle":"Capture","successTitle":"PAYONE","successMessage":"Capture erfolgreich durchgeführt.","errorTitle":"PAYONE","errorMessage":"Capture konnte nicht durchgeführt werden.","tooltips":{"impossible":"Einzug unmöglich"}},"refund":{"buttonTitle":"Refund","successTitle":"PAYONE","successMessage":"Refund erfolgreich durchgeführt.","errorTitle":"PAYONE","errorMessage":"Refund konnte nicht durchgeführt werden.","tooltips":{"impossible":"Erstattung unmöglich"}},"modal":{"capture":{"title":"Einzug","submit":"Einziehen","fullSubmit":"Alles Einziehen","amount":"Einzugswert","captured":"Eingezogener Wert"},"refund":{"title":"Erstattung","submit":"Erstatten","fullSubmit":"Alles Erstatten","amount":"Erstattungswert","refunded":"Erstatteter Wert"},"close":"Schließen","orderAmount":"Bestellungswert","remainingAmount":"Ausstehender Wert","labelComment":"Label comment","descriptionHelpText":"Description help text","columns":{"reference":"Referenz","product":"Produkt","quantity":"Anzahl","price":"Preis"}},"settingsForm":{"save":"Speichern","test":"API-Zugangsdaten testen","titleSuccess":"Erfolg","titleError":"Fehler","messageTestSuccess":"Die API-Zugangsdaten wurden erfolgreich validiert.","messageTestNoTestedPayments":"Bei der Prüfung wurden keine Zahlarten getestet, weil keine der PAYONE Zahlarten aktiviert ist. Bitte aktivieren Sie mindestens eine PAYONE Zahlart unter Einstellungen --\x3e Shop --\x3e Zahlungsarten.","messageTestError":{"general":"Die API-Zugangsdaten konnten nicht validiert werden.","creditCard":"Die API-Zugangsdaten für Kreditkarte sind nicht korrekt.","debit":"Die API-Zugangsdaten für Lastschrift sind nicht korrekt.","paypalExpress":"Die API-Zugangsdaten für PayPal Express sind nicht korrekt.","paypal":"Die API-Zugangsdaten für PayPal sind nicht korrekt.","payolutionInstallment":"Die API-Zugangsdaten für Paysafe Pay Later Ratenzahlung sind nicht korrekt.","payolutionInvoicing":"Die API-Zugangsdaten für Paysafe Pay Later Rechnungskauf sind nicht korrekt.","payolutionDebit":"Die API-Zugangsdaten für Paysafe Pay Later Lastschrift sind nicht korrekt.","sofort":"Die API-Zugangsdaten für SOFORT sind nicht korrekt.","iDeal":"Die API-Zugangsdaten für iDEAL sind nicht korrekt."}},"supportModal":{"menuButton":"Support","title":"Wie können wir Ihnen helfen?","documentation":{"description":"Lesen Sie unsere Online-Dokumentation","button":"Dokumentation"},"support":{"description":"Kontaktieren Sie unseren technischen Support","button":"Technischer Support"},"repository":{"description":"Melden Sie Fehler und Verbesserungen auf GitHub","button":"GitHub"}},"transitionActionNames":{"cancel":"Stornieren","complete":"Abschließen","pay":"Bezahlen","pay_partially":"Teilweise bezahlen","process":"Durchführen","refund":"Rückerstatten","refund_partially":"Teilweise rückerstatten","remind":"Erinnern","reopen":"Wieder öffnen","retour":"Retoure","retour_partially":"Teilweise retounieren","ship":"Versenden","ship_partially":"Teilweise versenden"},"messageNotBlank":"Dieser Wert darf nicht leer sein.","txid":"TXID","sequenceNumber":{"label":"Sequenznummer","empty":"keine"},"transactionState":"Status","error":{"transaction":{"notFound":"Es wurde keine passende Transaktion gefundend","orderNotFound":"Es wurde keine passende Bestellung gefundend"}}}}')},mLM4:function(e,t){e.exports='{% block payone_payment %}\n\n {% block payone_payment_header %}\n \n {% endblock %}\n\n {% block payone_payment_actions %}\n \n {% endblock %}\n\n {% block payone_payment_settings_content %}\n \n {% endblock %}\n\n{% endblock %}\n'},qwju:function(e,t,n){var a=n("4yeS");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);(0,n("SZ7m").default)("dda1b75e",a,!0,{})},s6j0:function(e,t,n){},zsm5:function(e,t,n){}},[["OPxs","runtime","vendors-node"]]]); \ No newline at end of file From 3ca11552dce2cc9f4e1b352ad033b9054bc87ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ttcher?= Date: Tue, 30 Jun 2020 13:29:09 +0200 Subject: [PATCH 13/13] Fix style issues --- .../CheckoutConfirmIDealEventListener.php | 6 ---- .../PayoneIDealPaymentHandler.php | 30 +++++++++---------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/EventListener/CheckoutConfirmIDealEventListener.php b/src/EventListener/CheckoutConfirmIDealEventListener.php index c0fb2e0f1..ab2997ac6 100644 --- a/src/EventListener/CheckoutConfirmIDealEventListener.php +++ b/src/EventListener/CheckoutConfirmIDealEventListener.php @@ -46,9 +46,6 @@ public function hideIDealForNonNlCustomers($event): void /** * Returns whether or not the currency is EUR. - * - * @param SalesChannelContext $context - * @return bool */ private function isEuroCurrency(SalesChannelContext $context): bool { @@ -59,9 +56,6 @@ private function isEuroCurrency(SalesChannelContext $context): bool * Returns whether or not the customer's billing address * is inside NL or not. Or false if no customer or billing * address is given. - * - * @param SalesChannelContext $context - * @return bool */ private function isNlCustomer(SalesChannelContext $context): bool { diff --git a/src/PaymentHandler/PayoneIDealPaymentHandler.php b/src/PaymentHandler/PayoneIDealPaymentHandler.php index 94d01f347..a64fef06b 100644 --- a/src/PaymentHandler/PayoneIDealPaymentHandler.php +++ b/src/PaymentHandler/PayoneIDealPaymentHandler.php @@ -137,9 +137,9 @@ public function pay(AsyncPaymentTransactionStruct $transaction, RequestDataBag $ // Prepare custom fields for the transaction $data = $this->prepareTransactionCustomFields($request, $response, [ - CustomFieldInstaller::TRANSACTION_STATE => $response['status'], - CustomFieldInstaller::ALLOW_CAPTURE => false, - CustomFieldInstaller::ALLOW_REFUND => false, + CustomFieldInstaller::TRANSACTION_STATE => $response['status'], + CustomFieldInstaller::ALLOW_CAPTURE => false, + CustomFieldInstaller::ALLOW_REFUND => false, ]); $this->dataHandler->saveTransactionData($paymentTransaction, $salesChannelContext->getContext(), $data); @@ -148,18 +148,6 @@ public function pay(AsyncPaymentTransactionStruct $transaction, RequestDataBag $ return new RedirectResponse($response['redirecturl']); } - /** - * @throws PayoneRequestException - */ - private function validate(RequestDataBag $dataBag) - { - $bankGroup = $dataBag->get('idealBankGroup'); - - if (!in_array($bankGroup, static::VALID_IDEAL_BANK_GROUPS, true)) { - throw new PayoneRequestException('No valid iDEAL bank group'); - } - } - /** * {@inheritdoc} */ @@ -191,4 +179,16 @@ public static function isRefundable(array $transactionData, array $customFields) return strtolower($transactionData['txaction']) === TransactionStatusService::ACTION_PAID; } + + /** + * @throws PayoneRequestException + */ + private function validate(RequestDataBag $dataBag) + { + $bankGroup = $dataBag->get('idealBankGroup'); + + if (!in_array($bankGroup, static::VALID_IDEAL_BANK_GROUPS, true)) { + throw new PayoneRequestException('No valid iDEAL bank group'); + } + } }