From c0032bb9159862ff97a9073a0a46c4161afd18bc Mon Sep 17 00:00:00 2001 From: paeddl Date: Wed, 13 May 2026 12:41:13 +0200 Subject: [PATCH] v6.5.7 --- CHANGELOG_de-DE.md | 8 +++ CHANGELOG_en-GB.md | 8 +++ README.md | 1 - composer.json | 2 +- src/Components/ConfigReader/ConfigReader.php | 1 + .../ExpressCheckoutService.php | 5 +- .../UnzerGooglePayPaymentHandler.php | 2 +- .../PaymentResourceHydrator.php | 2 + .../Storefront/ExtensionFactory.php | 2 +- .../Confirm/UnzerDataPageExtension.php | 24 +++++++++ src/Components/UnzerUtil/UnzerApiUtil.php | 54 +++++++++++++++++++ .../Checkout/ConfirmPageEventListener.php | 8 ++- .../ExpressButtonsEventListener.php | 5 +- .../component/unzer-payment-history/index.js | 8 +++ .../administration/src/snippets/de-DE.json | 3 +- .../administration/src/snippets/en-GB.json | 3 +- .../js/unzer-payment6/unzer-payment6.js | 2 +- .../app/storefront/src/scss/base.scss | 1 + .../unzer-payment/elements-apple-pay.scss | 1 - .../unzer-payment/elements-confirm.scss | 7 +++ .../unzer-payment/express-buttons.scss | 4 ++ .../unzer-payment.express-buttons.plugin.js | 9 ++++ .../src/unzer/unzer-payment.base.plugin.js | 46 ++++++++++++---- .../unzer/unzer-payment.google-pay.plugin.js | 5 +- .../config/dependencies/event_listeners.xml | 2 + .../config/dependencies/services.xml | 4 ++ src/Resources/config/settings.xml | 8 +++ .../administration/js/unzer-payment6.js | 2 +- .../snippet/de_DE/unzer-payment.de-DE.json | 1 + .../snippet/en_GB/unzer-payment.en-GB.json | 1 + .../unzer/confirm-form-extension.html.twig | 2 + .../component/unzer/express-buttons.html.twig | 5 +- .../unzer/frames/credit-card.html.twig | 1 + .../paylater-direct-debit-secured.html.twig | 1 + .../frames/paylater-installment.html.twig | 1 + .../unzer/frames/paylater-invoice.html.twig | 1 + .../unzer/frames/sepa-direct-debit.html.twig | 1 + .../page/checkout/confirm/index.html.twig | 27 +++++++++- 38 files changed, 239 insertions(+), 29 deletions(-) create mode 100644 src/Components/UnzerUtil/UnzerApiUtil.php create mode 100644 src/Resources/app/storefront/src/scss/component/unzer-payment/express-buttons.scss diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index 22285244..4c5d7067 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,3 +1,11 @@ +# 6.5.7 +* Zuverlässigerer Checkout: Der „Bezahlen“-Button wartet jetzt, bis alle erforderlichen Komponenten vollständig geladen sind, wodurch fehlgeschlagene Bestellungen verhindert werden. +* Leistungsverbesserung: Ein redundanter Abruf der Händlerkonfiguration wurde entfernt, wenn die Konfiguration bereits vorhanden ist. +* Bugfix – PayPal Express: Nutzer werden nach der Erstellung der Zahlungsart nun korrekt zum Checkout zurückgeleitet, anstatt eine Fehlerseite zu sehen. +* UI-Fix – Express-Checkout-Buttons: Einheitliche Abstände zwischen den Buttons für Checkout, PayPal Express, Google Pay und Apple Pay auf der Warenkorbseite sowie im Seitenmenü. +* Neu – Transaktionsstatus im Zahlungsverlauf: Eine Status-Spalte wurde im Zahlungsverlauf der Shopware-Bestelldetails (Unzer-Bereich) hinzugefügt und wird mit Webhook-Updates synchron gehalten. +* Bugfix – Express Checkout mit Gutscheinen: Wenn im Warenkorb-Seitenmenü ein Gutschein angewendet und direkt danach Google Pay, Apple Pay oder PayPal Express angeklickt wird, schlägt die Zahlung nicht mehr fehl. + # 6.5.6 * Fix: Fehlende Übersetzungen neuer Zahlungsarten konnten nach einem Update im Frontend zu einer Fehlermeldung führen * Fix: Dateien veralteter Zahlungsarten wurden nicht korrekt entfernt und konnten in einigen Fällen Probleme verursachen diff --git a/CHANGELOG_en-GB.md b/CHANGELOG_en-GB.md index a26d0cbd..f212177b 100644 --- a/CHANGELOG_en-GB.md +++ b/CHANGELOG_en-GB.md @@ -1,3 +1,11 @@ +# 6.5.7 +* More reliable checkout: The "Pay" button now waits until all required components are fully loaded, preventing failed orders. +* Performance improvement: Eliminated a redundant merchant config fetch when the config is already provided. +* Bugfix – PayPal Express: Users are now correctly returned to checkout after payment type creation instead of seeing an error page. +* UI fix – Express Checkout buttons: Consistent spacing between Checkout, PayPal Express, Google Pay, and Apple Pay buttons on the cart page and side menu. +* New – Transaction status in payment history: Added a Status column to the payment history in Shopware Order Details (Unzer section), kept in sync with webhook updates. +* Bugfix – Express Checkout with vouchers: Applying a voucher in the cart side menu and immediately clicking Google Pay / Apple Pay / PayPal Express no longer causes the payment to fail. + # 6.5.6 * Fix: Missing translation of new payment methods could display an error in Frontend after updating * Fix: Files from deprecated payment methods was not properly removed and could in some cases create issues diff --git a/README.md b/README.md index 22aab321..a3cff303 100644 --- a/README.md +++ b/README.md @@ -74,4 +74,3 @@ For any issues or questions please get in touch with our support. **Twitter**: [@UnzerTech](https://twitter.com/UnzerTech) **Webpage**: https://unzer.com/ - diff --git a/composer.json b/composer.json index 532f37e9..b528d104 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "unzerdev/shopware6", "description": "Unzer payment integration for Shopware 6", - "version": "6.5.6", + "version": "6.5.7", "type": "shopware-platform-plugin", "license": "Apache-2.0", "minimum-stability": "dev", diff --git a/src/Components/ConfigReader/ConfigReader.php b/src/Components/ConfigReader/ConfigReader.php index 31f60066..a33a8f90 100644 --- a/src/Components/ConfigReader/ConfigReader.php +++ b/src/Components/ConfigReader/ConfigReader.php @@ -18,6 +18,7 @@ class ConfigReader implements ConfigReaderInterface public const CONFIG_KEY_PRIVATE_KEY = 'privateKey'; public const CONFIG_KEY_TEST_DATA = 'testData'; public const CONFIG_KEY_EXTENDED_LOGGING = 'extendedLogging'; + public const CONFIG_KEY_BLOCK_CONFIRM_BUTTON_ON_LOAD = 'blockConfirmButtonOnLoad'; public const CONFIG_KEY_BOOKING_MODE_CARD = 'bookingModeCreditCard'; public const CONFIG_KEY_BOOKING_MODE_PAYPAL = 'bookingModePayPal'; diff --git a/src/Components/ExpressCheckout/ExpressCheckoutService.php b/src/Components/ExpressCheckout/ExpressCheckoutService.php index 1351df07..498b442e 100644 --- a/src/Components/ExpressCheckout/ExpressCheckoutService.php +++ b/src/Components/ExpressCheckout/ExpressCheckoutService.php @@ -114,7 +114,7 @@ private function getRegisterDataFromGooglePayData(array $paymentData, SalesChann { $data = new DataBag(); $password = Uuid::randomHex(); - $name = $paymentData['paymentMethodData']['info']['billingAddress']['name'] ?? '---- ----'; + $name = $paymentData['paymentMethodData']['info']['billingAddress']['name'] ?? self::ADDRESS_PART_PLACEHOLDER . ' ' . self::ADDRESS_PART_PLACEHOLDER; $names = $this->separateName($name); $shippingAddress = $this->getAddressFromGoogleData($paymentData['shippingAddress'] ?? [], $salesChannelContext->getContext()); @@ -261,6 +261,9 @@ private function getAddressFromUnzerCustomer(Customer $customer, Context $contex if (empty($address->getStreet())) { $address->setStreet(self::ADDRESS_PART_PLACEHOLDER); } + if (empty($address->getName())) { + $address->setName(self::ADDRESS_PART_PLACEHOLDER . ' ' . self::ADDRESS_PART_PLACEHOLDER); + } $nameParts = $this->separateName($address->getName()); diff --git a/src/Components/PaymentHandler/UnzerGooglePayPaymentHandler.php b/src/Components/PaymentHandler/UnzerGooglePayPaymentHandler.php index 753b2558..6db299d1 100755 --- a/src/Components/PaymentHandler/UnzerGooglePayPaymentHandler.php +++ b/src/Components/PaymentHandler/UnzerGooglePayPaymentHandler.php @@ -87,7 +87,7 @@ public function pay( } } - public static function fetchChannelId(Unzer $client, bool $cached = true): string + public static function fetchChannelId(Unzer $client): string { try { $keyPair = $client->fetchKeyPair(true); diff --git a/src/Components/ResourceHydrator/PaymentResourceHydrator/PaymentResourceHydrator.php b/src/Components/ResourceHydrator/PaymentResourceHydrator/PaymentResourceHydrator.php index 90626071..adf9b22c 100644 --- a/src/Components/ResourceHydrator/PaymentResourceHydrator/PaymentResourceHydrator.php +++ b/src/Components/ResourceHydrator/PaymentResourceHydrator/PaymentResourceHydrator.php @@ -365,6 +365,8 @@ protected function hydrateTransactionItem(AbstractTransactionType $item, string $state = 'success'; if ($item->isError()) { $state = 'error'; + } elseif ($item->isPending()) { + $state = 'pending'; } return [ diff --git a/src/Components/Storefront/ExtensionFactory.php b/src/Components/Storefront/ExtensionFactory.php index 41c9f663..31937213 100644 --- a/src/Components/Storefront/ExtensionFactory.php +++ b/src/Components/Storefront/ExtensionFactory.php @@ -67,7 +67,7 @@ private function readConfig(?string $salesChannelId = null): void private function fetchGooglePayChannelId($salesChannelId = null, int $cacheTtl = 7200): string { - $cacheKey = 'UnzerGooglePayChannelId_' . ($salesChannelId ?? 'main'); + $cacheKey = 'UnzerGooglePayChannelId_' . ($salesChannelId ?? 'main') . '_' . $this->configData->get(ConfigReader::CONFIG_KEY_PUBLIC_KEY); return $this->cache->get($cacheKey, function (ItemInterface $item) use ($salesChannelId, $cacheTtl) { $item->expiresAfter($cacheTtl); diff --git a/src/Components/Struct/PageExtension/Checkout/Confirm/UnzerDataPageExtension.php b/src/Components/Struct/PageExtension/Checkout/Confirm/UnzerDataPageExtension.php index bf59f3ec..9f7ef28a 100644 --- a/src/Components/Struct/PageExtension/Checkout/Confirm/UnzerDataPageExtension.php +++ b/src/Components/Struct/PageExtension/Checkout/Confirm/UnzerDataPageExtension.php @@ -19,6 +19,10 @@ class UnzerDataPageExtension extends Struct private bool $showTestData; + private bool $blockButtonOnLoad = true; + + private ?array $keyPairConfig = null; + private ?Customer $unzerCustomer; public function getPublicKey(): string @@ -51,6 +55,26 @@ public function setShowTestData(bool $showTestData): void $this->showTestData = $showTestData; } + public function getBlockButtonOnLoad(): bool + { + return $this->blockButtonOnLoad; + } + + public function setBlockButtonOnLoad(bool $blockButtonOnLoad): void + { + $this->blockButtonOnLoad = $blockButtonOnLoad; + } + + public function getKeyPairConfig(): ?array + { + return $this->keyPairConfig; + } + + public function setKeyPairConfig(?array $keyPairConfig): void + { + $this->keyPairConfig = $keyPairConfig; + } + public function getUnzerCustomer(): ?Customer { return $this->unzerCustomer; diff --git a/src/Components/UnzerUtil/UnzerApiUtil.php b/src/Components/UnzerUtil/UnzerApiUtil.php new file mode 100644 index 00000000..ecf8faee --- /dev/null +++ b/src/Components/UnzerUtil/UnzerApiUtil.php @@ -0,0 +1,54 @@ +cache->get($cacheKey, function (ItemInterface $item) use ($publicKey, $cacheTtl): ?array { + $item->expiresAfter($cacheTtl); + + return $this->getKeypairConfig($publicKey); + }); + } + + private function getKeypairConfig(string $publicKey): ?array + { + try { + $host = str_starts_with($publicKey, 'p-pub-') ? 'api.unzer.com' : 'sbx-api.unzer.com'; + + $ch = curl_init('https://' . $host . '/v1/keypair/types'); + curl_setopt_array($ch, [ + \CURLOPT_RETURNTRANSFER => true, + \CURLOPT_USERPWD => $publicKey . ':', + \CURLOPT_HTTPHEADER => ['Accept: application/json'], + \CURLOPT_TIMEOUT => 5, + ]); + + $response = curl_exec($ch); + $status = curl_getinfo($ch, \CURLINFO_HTTP_CODE); + curl_close($ch); + + if (!\is_string($response) || $status !== 200) { + return null; + } + + $decoded = json_decode($response, true); + + return \is_array($decoded) ? $decoded : null; + } catch (\Throwable $e) { + return null; + } + } +} diff --git a/src/EventListeners/Checkout/ConfirmPageEventListener.php b/src/EventListeners/Checkout/ConfirmPageEventListener.php index 724a45d6..ff9c796a 100644 --- a/src/EventListeners/Checkout/ConfirmPageEventListener.php +++ b/src/EventListeners/Checkout/ConfirmPageEventListener.php @@ -36,6 +36,7 @@ use UnzerPayment6\Components\Struct\PageExtension\Checkout\Confirm\PaymentFramePageExtension; use UnzerPayment6\Components\Struct\PageExtension\Checkout\Confirm\PayPalPageExtension; use UnzerPayment6\Components\Struct\PageExtension\Checkout\Confirm\UnzerDataPageExtension; +use UnzerPayment6\Components\UnzerUtil\UnzerApiUtil; use UnzerPayment6\DataAbstractionLayer\Entity\PaymentDevice\UnzerPaymentDeviceEntity; use UnzerPayment6\DataAbstractionLayer\Repository\PaymentDevice\UnzerPaymentDeviceRepositoryInterface; use UnzerPayment6\Installer\PaymentInstaller; @@ -55,6 +56,7 @@ public function __construct( private readonly KeyPairConfigReader $keyPairConfigReader, private readonly ExtensionFactory $extensionFactory, private readonly CustomerResourceHydratorInterface $customerResourceHydrator, + private readonly UnzerApiUtil $unzerApiUtil, ) { } @@ -126,11 +128,13 @@ private function addUnzerDataExtension(PageLoadedEvent $event): void $context = $event->getSalesChannelContext()->getContext(); $extension = new UnzerDataPageExtension(); - $extension->setPublicKey($this->getPublicKey($event->getSalesChannelContext())); + $publicKey = $this->getPublicKey($event->getSalesChannelContext()); + $extension->setPublicKey($publicKey); $extension->setLocale($this->getLocaleByLanguageId($context->getLanguageId(), $context)); $extension->setShowTestData((bool) $this->configData->get(ConfigReader::CONFIG_KEY_TEST_DATA)); + $extension->setBlockButtonOnLoad((bool) $this->configData->get(ConfigReader::CONFIG_KEY_BLOCK_CONFIRM_BUTTON_ON_LOAD)); $extension->setUnzerCustomer($this->getUnzerCustomer($event)); - + $extension->setKeyPairConfig($this->unzerApiUtil->getCachedKeypairConfig($publicKey)); $event->getPage()->addExtension(UnzerDataPageExtension::EXTENSION_NAME, $extension); } diff --git a/src/EventListeners/ExpressButtons/ExpressButtonsEventListener.php b/src/EventListeners/ExpressButtons/ExpressButtonsEventListener.php index 479f45f8..9c96b78c 100644 --- a/src/EventListeners/ExpressButtons/ExpressButtonsEventListener.php +++ b/src/EventListeners/ExpressButtons/ExpressButtonsEventListener.php @@ -19,6 +19,7 @@ use UnzerPayment6\Components\Storefront\ExtensionFactory; use UnzerPayment6\Components\Struct\PageExtension\Checkout\Confirm\ApplePayV2PageExtension; use UnzerPayment6\Components\Struct\PageExtension\Checkout\Confirm\GooglePayPageExtension; +use UnzerPayment6\Components\UnzerUtil\UnzerApiUtil; use UnzerPayment6\Installer\PaymentInstaller; class ExpressButtonsEventListener implements EventSubscriberInterface @@ -26,7 +27,8 @@ class ExpressButtonsEventListener implements EventSubscriberInterface public function __construct( private ConfigReaderInterface $configReader, private ExtensionFactory $extensionFactory, - private EntityRepository $salesChannelRepository + private EntityRepository $salesChannelRepository, + private UnzerApiUtil $unzerApiUtil ) { } @@ -50,6 +52,7 @@ public function addExpressButtons(PageLoadedEvent $event): void $event->getPage()->addExtension('UnzerExpressButtons', new ArrayStruct([ 'publicKey' => $config->get(ConfigReader::CONFIG_KEY_PUBLIC_KEY), + 'keyPairConfig' => $this->unzerApiUtil->getCachedKeypairConfig($config->get(ConfigReader::CONFIG_KEY_PUBLIC_KEY)), 'usePaypal' => $config->get(ConfigReader::CONFIG_KEY_USE_EXPRESS_PAYPAL) && $this->isPaymentMethodActive(PaymentInstaller::PAYMENT_ID_PAYPAL, $event->getSalesChannelContext()), 'useGooglePay' => $config->get(ConfigReader::CONFIG_KEY_USE_EXPRESS_GOOGLE) && $this->isPaymentMethodActive(PaymentInstaller::PAYMENT_ID_GOOGLE_PAY, $event->getSalesChannelContext()), 'useApplePay' => $config->get(ConfigReader::CONFIG_KEY_USE_EXPRESS_APPLEPAY) && $this->isPaymentMethodActive(PaymentInstaller::PAYMENT_ID_APPLE_PAY_V2, $event->getSalesChannelContext()), diff --git a/src/Resources/app/administration/src/module/unzer-payment/component/unzer-payment-history/index.js b/src/Resources/app/administration/src/module/unzer-payment/component/unzer-payment-history/index.js index 6e10e6bd..4fb00109 100644 --- a/src/Resources/app/administration/src/module/unzer-payment/component/unzer-payment-history/index.js +++ b/src/Resources/app/administration/src/module/unzer-payment/component/unzer-payment-history/index.js @@ -83,6 +83,7 @@ Component.register('unzer-payment-history', { type: this.transactionTypeRenderer(transaction.type), amount: amount, date: date, + state: transaction.state || '', resource: transaction, }); } @@ -114,6 +115,13 @@ Component.register('unzer-payment-history', { ), rawData: true, }, + { + property: 'state', + label: this.$tc( + 'unzer-payment.paymentDetails.history.column.state' + ), + rawData: true, + }, ]; }, }, diff --git a/src/Resources/app/administration/src/snippets/de-DE.json b/src/Resources/app/administration/src/snippets/de-DE.json index 8652ddcd..a43279a1 100644 --- a/src/Resources/app/administration/src/snippets/de-DE.json +++ b/src/Resources/app/administration/src/snippets/de-DE.json @@ -7,7 +7,8 @@ "column": { "type": "Typ", "amount": "Betrag", - "date": "Datum" + "date": "Datum", + "state": "Status" }, "type": { "authorization": "Reservierung", diff --git a/src/Resources/app/administration/src/snippets/en-GB.json b/src/Resources/app/administration/src/snippets/en-GB.json index 600cf210..d6cef697 100644 --- a/src/Resources/app/administration/src/snippets/en-GB.json +++ b/src/Resources/app/administration/src/snippets/en-GB.json @@ -7,7 +7,8 @@ "column": { "type": "Type", "amount": "Amount", - "date": "Date" + "date": "Date", + "state": "State" }, "type": { "authorization": "Authorization", diff --git a/src/Resources/app/storefront/dist/storefront/js/unzer-payment6/unzer-payment6.js b/src/Resources/app/storefront/dist/storefront/js/unzer-payment6/unzer-payment6.js index 11a27b8c..f60ba153 100644 --- a/src/Resources/app/storefront/dist/storefront/js/unzer-payment6/unzer-payment6.js +++ b/src/Resources/app/storefront/dist/storefront/js/unzer-payment6/unzer-payment6.js @@ -1 +1 @@ -(()=>{"use strict";let e=window.PluginBaseClass;class t extends e{init(){this._registerElements(),this._registerEvents()}_registerElements(){this.submitButton=this.getSubmitButton()}getSubmitButton(){let e=document.getElementById(this.options.submitButtonId);return e||(e=document.getElementById(this.options.confirmFormId).getElementsByTagName("button")[0]),e||null}_registerEvents(){this.submitButton.addEventListener("click",this._onSubmitButtonClick.bind(this)),this.options.unzerCustomer&&Promise.all([customElements.whenDefined("unzer-payment")]).then(()=>{let e=document.getElementById("unzer-payment-component");e&&e.setCustomerData(this.options.unzerCustomer)})}setSubmitButtonActive(e){e?(this.submitButton.classList.remove(this.options.disabledClass),this.submitButton.disabled=!1):(this.submitButton.classList.add(this.options.disabledClass),this.submitButton.disabled=!0)}submitTypeId(e,t){if(document.getElementById(this.options.resourceIdElementId).value=e,t){let e=document.getElementById(this.options.threatMetrixIdElementId);e&&(e.value=t)}this.setSubmitButtonActive(!0),this.submitButton.click(),this.setSubmitButtonActive(!1)}showNotLoadedError(){this.showError({message:this.options.errorNotReady})}showError(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=document.getElementsByClassName(this.options.errorWrapperClass).item(0),s=document.querySelectorAll(this.options.errorContentSelector)[0];t&&""!==s.innerText?s.innerText="".concat(s.innerText,"\n").concat(e.message):s.innerText=e.message,n.hidden=!1,n.scrollIntoView({block:"end",behavior:"smooth"}),this.setSubmitButtonActive(!0),this.submitting=!1}renderErrorToElement(e,t){let n=document.getElementsByClassName(this.options.errorWrapperClass).item(0),s=document.querySelectorAll(this.options.errorContentSelector)[0];n.hidden=!1,s.innerText=e.message,t.appendChild(n)}async _onSubmitButtonClick(e){if(!0===this.submitting)return;if(this.submitting=!0,e.preventDefault(),!this._validateForm()){this.submitting=!1,this.setSubmitButtonActive(!0);return}this.setSubmitButtonActive(!1);let t=document.querySelector(this.options.savedDeviceSelectedRadioButtonSelector);if(t&&t.id!==this.options.savedDeviceRadioButtonNewAccountId)this.submitTypeId(t.value,null);else{let e=document.getElementById("unzer-payment-component");if(e){if(void 0===e.submit){this.showNotLoadedError();return}try{let t=await e.submit();if(t.submitResponse){if(!0===t.submitResponse.success){if("object"==typeof e.currentPaymentMethod&&e.currentPaymentMethod.tagName.toLowerCase().includes("-paylater")&&!t.threatMetrixId){this.showNotLoadedError();return}this.submitTypeId(t.submitResponse.data.id,t.threatMetrixId||null)}else this.showError({message:this.options.generalError})}else this.showError({message:this.options.generalError})}catch(t){e.scrollIntoView({block:"end",behavior:"smooth"}),this.submitting=!1,this.setSubmitButtonActive(!0)}}else this.setSubmitButtonActive(!0),this.submitButton.click(),this.setSubmitButtonActive(!1)}}_validateForm(){let e=!0,t=document.forms[this.options.confirmFormId].elements;this._clearErrorMessage();for(let n=0;n0&&this.showError({message:this.options.errorShouldNotBeEmpty.replace(/%field%/,s.labels[0].innerText)},!0),e=!1):s.classList.remove("is-invalid")}return e}_clearErrorMessage(){let e=document.getElementsByClassName(this.options.errorWrapperClass).item(0),t=document.querySelectorAll(this.options.errorContentSelector)[0];e.hidden=!0,t.innerText=""}getB2bCustomerObject(e){let t="".concat(e.firstName," ").concat(e.lastName),n=e.birthday?new Date(e.birthday):null,s={firstname:e.firstName,lastname:e.lastName,email:e.email,company:e.activeBillingAddress.company,salutation:e.salutation.salutationKey,billingAddress:{name:t,street:e.activeBillingAddress.street,zip:e.activeBillingAddress.zipcode,city:e.activeBillingAddress.city,country:e.activeBillingAddress.country.iso},shippingAddress:{name:t,street:e.activeShippingAddress.street,zip:e.activeShippingAddress.zipcode,city:e.activeShippingAddress.city,country:e.activeShippingAddress.country.iso}};return n&&(s.birthDate=n.getFullYear()+"-"+(n.getMonth()+1).toString().padStart(2,"0")+"-"+n.getDay().toString().padStart(2,"0")),s}}t.options={publicKey:null,shopLocale:null,unzerCustomer:null,submitButtonId:"confirmFormSubmit",disabledClass:"disabled",resourceIdElementId:"unzerResourceId",threatMetrixIdElementId:"unzerThreatMetrixId",confirmFormId:"confirmOrderForm",errorWrapperClass:"unzer-payment--error-wrapper",errorContentSelector:".unzer-payment--error-wrapper .alert-content",errorShouldNotBeEmpty:"%field% should not be empty",errorNotReady:"Payment method is not loaded yet. Please wait.",generalError:"Error! Please try again.",isOrderEdit:!1,savedDeviceRadioButtonSelector:'*[name="savedPaymentDevice"]',savedDeviceRadioButtonNewAccountId:"device-new",savedDeviceSelectedRadioButtonSelector:'*[name="savedPaymentDevice"]:checked'},t.submitting=!1;let n=window.PluginBaseClass;class s extends n{init(){this._unzerPaymentPlugin=window.PluginManager.getPluginInstances("UnzerPaymentBase")[0]}_handleError(e){this._unzerPaymentPlugin.showError(e)}_setSubmitButtonActive(e){this._unzerPaymentPlugin.setSubmitButtonActive(e)}_getSubmitButton(){return this._unzerPaymentPlugin.getSubmitButton()}}s._unzerPaymentPlugin=null,window.PluginBaseClass;class o extends s{init(){super.init(),this._registerEvents()}_registerEvents(){if(this.options.hasSavedDevices){let e=this.el.querySelectorAll(this.options.radioButtonSelector);for(let t=0;tthis._onRadioButtonChange(e));document.querySelector(this.options.selectedRadioButtonSelector).dispatchEvent(new Event("change"))}}_onRadioButtonChange(e){let t=e.target;this.el.querySelector(this.options.elementWrapperSelector).hidden=t.id!==this.options.radioButtonNewAccountId}}o.options={elementWrapperSelector:".unzer-payment-create-component-container",radioButtonSelector:'*[name="savedPaymentDevice"]',radioButtonNewAccountId:"device-new",selectedRadioButtonSelector:'*[name="savedPaymentDevice"]:checked',hasSavedDevices:!1},window.PluginBaseClass;class i extends s{init(){super.init(),this._createForm(),this._hideBuyButton()}_disableApplePay(){document.querySelector(this.options.applePayMethodSelector).remove(),document.querySelectorAll("[data-unzer-payment-apple-pay-v2]").forEach(e=>e.remove()),this._handleError({message:this.options.noApplePayMessage}),this._unzerPaymentPlugin.setSubmitButtonActive(!1)}_createForm(){Promise.all([customElements.whenDefined("unzer-payment")]).then(()=>{let e=document.getElementById("unzer-payment-component");e&&(e.setApplePayData(this._getApplePayPaymentRequest()),document.getElementById("unzer-checkout-component").onPaymentSubmit=t=>{t.submitResponse&&t.submitResponse.success&&this._unzerPaymentPlugin._validateForm()&&(e.style.display="none",this._unzerPaymentPlugin.submitting=!0,this._unzerPaymentPlugin.submitTypeId(t.submitResponse.data.id))})})}_getApplePayPaymentRequest(){return{countryCode:this.options.countryCode,currencyCode:this.options.currency,supportedNetworks:this.options.supportedNetworks,merchantCapabilities:this.options.merchantCapabilities,total:{label:this.options.shopName,amount:this.options.amount}}}_hideBuyButton(){document.querySelector(this.options.checkoutConfirmButtonSelector).style.display="none"}}i.options={countryCode:"DE",currency:"EUR",shopName:"Unzer GmbH",amount:"0.0",applePayButtonSelector:".apple-pay-button",checkoutConfirmButtonSelector:"#confirmFormSubmit",applePayMethodSelector:".unzer-payment-apple-pay-v2-method-wrapper",authorizePaymentUrl:"",merchantValidationUrl:"",noApplePayMessage:"",supportedNetworks:["masterCard","visa"]};class r extends s{init(){super.init(),Promise.all([customElements.whenDefined("unzer-payment")]).then(()=>{let e=document.getElementById("unzer-payment-component");e&&e.setBasketData({amount:this.options.paylaterInstallmentAmount,currencyType:this.options.paylaterInstallmentCurrency,country:this.options.countryIso})})}}r.options={countryIso:"",paylaterInstallmentAmount:"",paylaterInstallmentCurrency:""};class a extends s{init(){super.init(),this._registerGooglePayButton(),this._hideBuyButton()}_registerGooglePayButton(){Promise.all([customElements.whenDefined("unzer-payment")]).then(()=>{let e=document.getElementById("unzer-payment-component");e&&(e.setGooglePayData({gatewayMerchantId:this.options.gatewayMerchantId,merchantInfo:{merchantName:this.options.merchantName,merchantId:this.options.merchantId},transactionInfo:{currencyCode:this.options.currency,countryCode:this.options.countryCode,totalPriceStatus:"ESTIMATED",totalPrice:String(this.options.amount)},buttonOptions:{buttonColor:this.options.buttonColor,buttonSizeMode:this.options.buttonSizeMode},allowedCardNetworks:this.options.allowedCardNetworks,allowCreditCards:this.options.allowCreditCards,allowPrepaidCards:this.options.allowPrepaidCards}),document.getElementById("unzer-checkout-component").onPaymentSubmit=t=>{t.submitResponse&&t.submitResponse.success?!this._unzerPaymentPlugin._validateForm()||(e.style.display="none",this._unzerPaymentPlugin.submitting=!0,this._unzerPaymentPlugin.submitTypeId(t.submitResponse.data.id)):console.error(t)})})}_hideBuyButton(){this._getSubmitButton().style.display="none"}}a.options={googlePayButtonId:"unzer-google-pay-button",merchantName:"",merchantId:"",gatewayMerchantId:"",currency:"EUR",amount:"0.0",countryCode:"DE",allowedCardNetworks:[],allowCreditCards:!0,allowPrepaidCards:!0,buttonColor:"default",buttonSizeMode:"fill"},a.submitting=!1;let l=window.PluginBaseClass;class u extends l{init(){this.includeJs(),this.registerActions()}includeJs(){if(!document.querySelector('script[src*="static-v2.unzer.com/v2/ui-components/index.js"]')){let e=document.createElement("script");e.type="module",e.src="https://static-v2.unzer.com/v2/ui-components/index.js",document.head.appendChild(e)}}registerActions(){Promise.all([customElements.whenDefined("unzer-payment"),customElements.whenDefined("unzer-google-pay"),customElements.whenDefined("unzer-paypal-express"),customElements.whenDefined("unzer-apple-pay")]).then(()=>{let e=this.el.querySelector(".unzer-express-payment"),t=this.el.querySelector(".unzer-paypal-express"),n=this.el.querySelector(".unzer-google-pay"),s=this.el.querySelector(".unzer-apple-pay");e&&(t&&this.registerPaypalExpress(t,e),n&&this.registerGooglePay(n,e),s&&this.registerApplePay(s,e))})}registerPaypalExpress(e,t){e.id="unzer-paypal-button-"+Math.floor(1e4*Math.random()),e.addEventListener("click",async e=>{e.stopPropagation();let n=await t.submit();if(n.submitResponse&&n.submitResponse.success){let e=n.submitResponse.data.id;fetch("/unzer/paypal-express",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentTypeId:e})}).then(e=>e.json()).then(e=>{location.href=e.redirectUrl})}})}registerGooglePay(e,t){t.setGooglePayData({gatewayMerchantId:this.options.googlePay.gatewayMerchantId,merchantInfo:{merchantName:this.options.googlePay.merchantName,merchantId:this.options.googlePay.merchantId},transactionInfo:{currencyCode:this.options.googlePay.currency,countryCode:this.options.googlePay.countryCode,totalPriceStatus:"ESTIMATED",checkoutOption:"DEFAULT",totalPrice:String(this.options.googlePay.amount)},buttonOptions:{buttonColor:this.options.googlePay.buttonColor,buttonSizeMode:this.options.googlePay.buttonSizeMode},allowedCardNetworks:this.options.googlePay.allowedCardNetworks,allowCreditCards:this.options.googlePay.allowCreditCards,allowPrepaidCards:this.options.googlePay.allowPrepaidCards,billingAddressParameters:{format:"MIN"},billingAddressRequired:!0,emailRequired:!0,onPaymentDataChangedCallback:()=>({}),shippingOptionParameters:{},onPaymentAuthorizedCallback:async(e,n,s)=>{let o=(await t.submit()).submitResponse.data.id;fetch("/unzer/google-pay-express",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentTypeId:o,paymentData:e})}).then(e=>e.json()).then(e=>{location.href=e.redirectUrl})},shippingAddressRequired:!0,shippingOptionRequired:!1})}registerApplePay(e,t){let n={countryCode:this.options.applePay.countryCode,currencyCode:this.options.applePay.currency,supportedNetworks:this.options.applePay.supportedNetworks,merchantCapabilities:this.options.applePay.merchantCapabilities,total:{label:this.options.applePay.shopName,amount:String(this.options.applePay.amount)},requiredShippingContactFields:["postalAddress","name","email","phone"],requiredBillingContactFields:["postalAddress","name","email","phone"],onPaymentAuthorizedCallback:async(e,n,s,o)=>{let i=o.payment.shippingContact,r=o.payment.billingContact,a=await t.submit();a.submitResponse.success?n():s();let l=a.submitResponse.data.id;fetch("/unzer/applepay-express",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentTypeId:l,paymentData:e,shippingContact:i,billingContact:r})}).then(e=>e.json()).then(e=>{location.href=e.redirectUrl})}};n.initApplePaySession=e=>{},null==t||t.setApplePayData(n)}}u.options={googlePay:{},applePay:{}},window.PluginManager.register("UnzerPaymentBase",t,"[data-unzer-payment-base]"),window.PluginManager.register("UnzerPaymentCreditCard",class extends o{},"[data-unzer-payment-credit-card]"),window.PluginManager.register("UnzerPaymentPayPal",class extends o{},"[data-unzer-payment-paypal]"),window.PluginManager.register("UnzerPaymentSepaDirectDebit",class extends o{},"[data-unzer-payment-sepa-direct-debit]"),window.PluginManager.register("UnzerPaymentApplePayV2",i,"[data-unzer-payment-apple-pay-v2]"),window.PluginManager.register("UnzerPaymentPaylaterInvoice",class extends s{},"[data-unzer-payment-paylater-invoice]"),window.PluginManager.register("UnzerPaymentPaylaterInstallment",r,"[data-unzer-payment-paylater-installment]"),window.PluginManager.register("UnzerPaymentPaylaterDirectDebitSecured",class extends s{},"[data-unzer-payment-paylater-direct-debit-secured]"),window.PluginManager.register("UnzerPaymentGooglePay",a,"[data-unzer-payment-google-pay]"),window.PluginManager.register("UnzerPaymentExpressButtons",u,"[data-unzer-payment-express-buttons]")})(); \ No newline at end of file +(()=>{"use strict";let e=window.PluginBaseClass;class t extends e{init(){this._registerElements(),this._registerEvents()}_registerElements(){this.submitButton=this.getSubmitButton()}getSubmitButton(){let e=document.getElementById(this.options.submitButtonId);return e||(e=document.getElementById(this.options.confirmFormId).getElementsByTagName("button")[0]),e||null}_registerEvents(){this.submitButton.addEventListener("click",this._onSubmitButtonClick.bind(this)),customElements.whenDefined("unzer-payment").then(()=>{let e=document.getElementById("unzer-payment-component");e&&(this.options.unzerCustomer&&e.setCustomerData(this.options.unzerCustomer),this.options.keyPairConfig&&e.setMerchantConfigData(this.options.keyPairConfig))}),document.querySelector("unzer-payment")?customElements.whenDefined("unzer-payment").then(()=>{this.unblockButton()}):this.unblockButton()}unblockButton(){let e=document.querySelector('[data-unzer-blocked-button="true"]');if(e){var t;e.removeAttribute("disabled"),e.removeAttribute("data-unzer-blocked-button"),(t=document.querySelector(".unzer-blocked-button-message"))===null||void 0===t||t.remove()}}setSubmitButtonActive(e){e?(this.submitButton.classList.remove(this.options.disabledClass),this.submitButton.disabled=!1):(this.submitButton.classList.add(this.options.disabledClass),this.submitButton.disabled=!0)}submitTypeId(e,t){if(document.getElementById(this.options.resourceIdElementId).value=e,t){let e=document.getElementById(this.options.threatMetrixIdElementId);e&&(e.value=t)}this.setSubmitButtonActive(!0),this.submitButton.click(),this.setSubmitButtonActive(!1)}showNotLoadedError(){this.showError({message:this.options.errorNotReady})}showError(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=document.getElementsByClassName(this.options.errorWrapperClass).item(0),o=document.querySelectorAll(this.options.errorContentSelector)[0];t&&""!==o.innerText?o.innerText="".concat(o.innerText,"\n").concat(e.message):o.innerText=e.message,n.hidden=!1,n.scrollIntoView({block:"end",behavior:"smooth"}),this.setSubmitButtonActive(!0),this.submitting=!1}renderErrorToElement(e,t){let n=document.getElementsByClassName(this.options.errorWrapperClass).item(0),o=document.querySelectorAll(this.options.errorContentSelector)[0];n.hidden=!1,o.innerText=e.message,t.appendChild(n)}async _onSubmitButtonClick(e){if(!0===this.submitting)return;if(this.submitting=!0,e.preventDefault(),!this._validateForm()){this.submitting=!1,this.setSubmitButtonActive(!0);return}this.setSubmitButtonActive(!1);let t=document.querySelector(this.options.savedDeviceSelectedRadioButtonSelector);if(t&&t.id!==this.options.savedDeviceRadioButtonNewAccountId)this.submitTypeId(t.value,null);else{let e=document.getElementById("unzer-payment-component");if(e){if(void 0===e.submit){this.showNotLoadedError();return}try{let t=await e.submit();if(t.submitResponse){if(!0===t.submitResponse.success){if("object"==typeof e.currentPaymentMethod&&e.currentPaymentMethod.tagName.toLowerCase().includes("-paylater")&&!t.threatMetrixId){this.showNotLoadedError();return}this.submitTypeId(t.submitResponse.data.id,t.threatMetrixId||null)}else this.showError({message:this.options.generalError})}else this.showError({message:this.options.generalError})}catch(t){e.scrollIntoView({block:"end",behavior:"smooth"}),this.submitting=!1,this.setSubmitButtonActive(!0)}}else this.setSubmitButtonActive(!0),this.submitButton.click(),this.setSubmitButtonActive(!1)}}_validateForm(){let e=!0,t=document.forms[this.options.confirmFormId].elements;this._clearErrorMessage();for(let n=0;n0&&this.showError({message:this.options.errorShouldNotBeEmpty.replace(/%field%/,o.labels[0].innerText)},!0),e=!1):o.classList.remove("is-invalid")}return e}_clearErrorMessage(){let e=document.getElementsByClassName(this.options.errorWrapperClass).item(0),t=document.querySelectorAll(this.options.errorContentSelector)[0];e.hidden=!0,t.innerText=""}getB2bCustomerObject(e){let t="".concat(e.firstName," ").concat(e.lastName),n=e.birthday?new Date(e.birthday):null,o={firstname:e.firstName,lastname:e.lastName,email:e.email,company:e.activeBillingAddress.company,salutation:e.salutation.salutationKey,billingAddress:{name:t,street:e.activeBillingAddress.street,zip:e.activeBillingAddress.zipcode,city:e.activeBillingAddress.city,country:e.activeBillingAddress.country.iso},shippingAddress:{name:t,street:e.activeShippingAddress.street,zip:e.activeShippingAddress.zipcode,city:e.activeShippingAddress.city,country:e.activeShippingAddress.country.iso}};return n&&(o.birthDate=n.getFullYear()+"-"+(n.getMonth()+1).toString().padStart(2,"0")+"-"+n.getDay().toString().padStart(2,"0")),o}}t.options={publicKey:null,shopLocale:null,unzerCustomer:null,keyPairConfig:null,submitButtonId:"confirmFormSubmit",disabledClass:"disabled",resourceIdElementId:"unzerResourceId",threatMetrixIdElementId:"unzerThreatMetrixId",confirmFormId:"confirmOrderForm",errorWrapperClass:"unzer-payment--error-wrapper",errorContentSelector:".unzer-payment--error-wrapper .alert-content",errorShouldNotBeEmpty:"%field% should not be empty",errorNotReady:"Payment method is not loaded yet. Please wait.",generalError:"Error! Please try again.",isOrderEdit:!1,savedDeviceRadioButtonSelector:'*[name="savedPaymentDevice"]',savedDeviceRadioButtonNewAccountId:"device-new",savedDeviceSelectedRadioButtonSelector:'*[name="savedPaymentDevice"]:checked'},t.submitting=!1;let n=window.PluginBaseClass;class o extends n{init(){this._unzerPaymentPlugin=window.PluginManager.getPluginInstances("UnzerPaymentBase")[0]}_handleError(e){this._unzerPaymentPlugin.showError(e)}_setSubmitButtonActive(e){this._unzerPaymentPlugin.setSubmitButtonActive(e)}_getSubmitButton(){return this._unzerPaymentPlugin.getSubmitButton()}}o._unzerPaymentPlugin=null,window.PluginBaseClass;class s extends o{init(){super.init(),this._registerEvents()}_registerEvents(){if(this.options.hasSavedDevices){let e=this.el.querySelectorAll(this.options.radioButtonSelector);for(let t=0;tthis._onRadioButtonChange(e));document.querySelector(this.options.selectedRadioButtonSelector).dispatchEvent(new Event("change"))}}_onRadioButtonChange(e){let t=e.target;this.el.querySelector(this.options.elementWrapperSelector).hidden=t.id!==this.options.radioButtonNewAccountId}}s.options={elementWrapperSelector:".unzer-payment-create-component-container",radioButtonSelector:'*[name="savedPaymentDevice"]',radioButtonNewAccountId:"device-new",selectedRadioButtonSelector:'*[name="savedPaymentDevice"]:checked',hasSavedDevices:!1},window.PluginBaseClass;class i extends o{init(){super.init(),this._createForm(),this._hideBuyButton()}_disableApplePay(){document.querySelector(this.options.applePayMethodSelector).remove(),document.querySelectorAll("[data-unzer-payment-apple-pay-v2]").forEach(e=>e.remove()),this._handleError({message:this.options.noApplePayMessage}),this._unzerPaymentPlugin.setSubmitButtonActive(!1)}_createForm(){Promise.all([customElements.whenDefined("unzer-payment")]).then(()=>{let e=document.getElementById("unzer-payment-component");e&&(e.setApplePayData(this._getApplePayPaymentRequest()),document.getElementById("unzer-checkout-component").onPaymentSubmit=t=>{t.submitResponse&&t.submitResponse.success&&this._unzerPaymentPlugin._validateForm()&&(e.style.display="none",this._unzerPaymentPlugin.submitting=!0,this._unzerPaymentPlugin.submitTypeId(t.submitResponse.data.id))})})}_getApplePayPaymentRequest(){return{countryCode:this.options.countryCode,currencyCode:this.options.currency,supportedNetworks:this.options.supportedNetworks,merchantCapabilities:this.options.merchantCapabilities,total:{label:this.options.shopName,amount:this.options.amount}}}_hideBuyButton(){document.querySelector(this.options.checkoutConfirmButtonSelector).style.display="none"}}i.options={countryCode:"DE",currency:"EUR",shopName:"Unzer GmbH",amount:"0.0",applePayButtonSelector:".apple-pay-button",checkoutConfirmButtonSelector:"#confirmFormSubmit",applePayMethodSelector:".unzer-payment-apple-pay-v2-method-wrapper",authorizePaymentUrl:"",merchantValidationUrl:"",noApplePayMessage:"",supportedNetworks:["masterCard","visa"]};class r extends o{init(){super.init(),Promise.all([customElements.whenDefined("unzer-payment")]).then(()=>{let e=document.getElementById("unzer-payment-component");e&&e.setBasketData({amount:this.options.paylaterInstallmentAmount,currencyType:this.options.paylaterInstallmentCurrency,country:this.options.countryIso})})}}r.options={countryIso:"",paylaterInstallmentAmount:"",paylaterInstallmentCurrency:""};class a extends o{init(){super.init(),this._registerGooglePayButton(),this._hideBuyButton()}_registerGooglePayButton(){Promise.all([customElements.whenDefined("unzer-payment"),customElements.whenDefined("unzer-checkout")]).then(()=>{let e=document.getElementById("unzer-payment-component");e&&(e.setGooglePayData({gatewayMerchantId:this.options.gatewayMerchantId,merchantInfo:{merchantName:this.options.merchantName,merchantId:this.options.merchantId},transactionInfo:{currencyCode:this.options.currency,countryCode:this.options.countryCode,totalPriceStatus:"ESTIMATED",totalPrice:String(this.options.amount)},buttonOptions:{buttonColor:this.options.buttonColor,buttonSizeMode:this.options.buttonSizeMode},allowedCardNetworks:this.options.allowedCardNetworks,allowCreditCards:this.options.allowCreditCards,allowPrepaidCards:this.options.allowPrepaidCards}),document.getElementById("unzer-checkout-component").onPaymentSubmit=t=>{t.submitResponse&&t.submitResponse.success?!this._unzerPaymentPlugin._validateForm()||(e.style.display="none",this._unzerPaymentPlugin.submitting=!0,this._unzerPaymentPlugin.submitTypeId(t.submitResponse.data.id)):console.error(t)})})}_hideBuyButton(){this._getSubmitButton().style.display="none"}}a.options={googlePayButtonId:"unzer-google-pay-button",merchantName:"",merchantId:"",gatewayMerchantId:"",currency:"EUR",amount:"0.0",countryCode:"DE",allowedCardNetworks:[],allowCreditCards:!0,allowPrepaidCards:!0,buttonColor:"default",buttonSizeMode:"fill"},a.submitting=!1;let l=window.PluginBaseClass;class u extends l{init(){this.includeJs(),this.registerActions()}includeJs(){if(!document.querySelector('script[src*="static-v2.unzer.com/v2/ui-components/index.js"]')){let e=document.createElement("script");e.type="module",e.src="https://static-v2.unzer.com/v2/ui-components/index.js",document.head.appendChild(e)}}registerActions(){Promise.all([customElements.whenDefined("unzer-payment"),customElements.whenDefined("unzer-google-pay"),customElements.whenDefined("unzer-paypal-express"),customElements.whenDefined("unzer-apple-pay")]).then(()=>{let e=this.el.querySelector(".unzer-express-payment");this.options.keyPairConfig&&e.setMerchantConfigData(this.options.keyPairConfig);let t=this.el.querySelector(".unzer-paypal-express"),n=this.el.querySelector(".unzer-google-pay"),o=this.el.querySelector(".unzer-apple-pay");if(e){if(t&&this.registerPaypalExpress(t,e),n){this.registerGooglePay(n,e);let t=n.parentNode;n.remove(),t.appendChild(n)}o&&this.registerApplePay(o,e)}})}registerPaypalExpress(e,t){e.id="unzer-paypal-button-"+Math.floor(1e4*Math.random()),e.addEventListener("click",async e=>{e.stopPropagation();let n=await t.submit();if(n.submitResponse&&n.submitResponse.success){let e=n.submitResponse.data.id;fetch("/unzer/paypal-express",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentTypeId:e})}).then(e=>e.json()).then(e=>{location.href=e.redirectUrl})}})}registerGooglePay(e,t){t.setGooglePayData({gatewayMerchantId:this.options.googlePay.gatewayMerchantId,merchantInfo:{merchantName:this.options.googlePay.merchantName,merchantId:this.options.googlePay.merchantId},transactionInfo:{currencyCode:this.options.googlePay.currency,countryCode:this.options.googlePay.countryCode,totalPriceStatus:"ESTIMATED",checkoutOption:"DEFAULT",totalPrice:String(this.options.googlePay.amount)},buttonOptions:{buttonColor:this.options.googlePay.buttonColor,buttonSizeMode:this.options.googlePay.buttonSizeMode},allowedCardNetworks:this.options.googlePay.allowedCardNetworks,allowCreditCards:this.options.googlePay.allowCreditCards,allowPrepaidCards:this.options.googlePay.allowPrepaidCards,billingAddressParameters:{format:"MIN"},billingAddressRequired:!0,emailRequired:!0,onPaymentDataChangedCallback:()=>({}),shippingOptionParameters:{},onPaymentAuthorizedCallback:async(e,n,o)=>{let s=(await t.submit()).submitResponse.data.id;fetch("/unzer/google-pay-express",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentTypeId:s,paymentData:e})}).then(e=>e.json()).then(e=>{location.href=e.redirectUrl})},shippingAddressRequired:!0,shippingOptionRequired:!1})}registerApplePay(e,t){let n={countryCode:this.options.applePay.countryCode,currencyCode:this.options.applePay.currency,supportedNetworks:this.options.applePay.supportedNetworks,merchantCapabilities:this.options.applePay.merchantCapabilities,total:{label:this.options.applePay.shopName,amount:String(this.options.applePay.amount)},requiredShippingContactFields:["postalAddress","name","email","phone"],requiredBillingContactFields:["postalAddress","name","email","phone"],onPaymentAuthorizedCallback:async(e,n,o,s)=>{let i=s.payment.shippingContact,r=s.payment.billingContact,a=await t.submit();a.submitResponse.success?n():o();let l=a.submitResponse.data.id;fetch("/unzer/applepay-express",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentTypeId:l,paymentData:e,shippingContact:i,billingContact:r})}).then(e=>e.json()).then(e=>{location.href=e.redirectUrl})}};n.initApplePaySession=e=>{},null==t||t.setApplePayData(n)}}u.options={googlePay:{},applePay:{},keyPairConfig:null},window.PluginManager.register("UnzerPaymentBase",t,"[data-unzer-payment-base]"),window.PluginManager.register("UnzerPaymentCreditCard",class extends s{},"[data-unzer-payment-credit-card]"),window.PluginManager.register("UnzerPaymentPayPal",class extends s{},"[data-unzer-payment-paypal]"),window.PluginManager.register("UnzerPaymentSepaDirectDebit",class extends s{},"[data-unzer-payment-sepa-direct-debit]"),window.PluginManager.register("UnzerPaymentApplePayV2",i,"[data-unzer-payment-apple-pay-v2]"),window.PluginManager.register("UnzerPaymentPaylaterInvoice",class extends o{},"[data-unzer-payment-paylater-invoice]"),window.PluginManager.register("UnzerPaymentPaylaterInstallment",r,"[data-unzer-payment-paylater-installment]"),window.PluginManager.register("UnzerPaymentPaylaterDirectDebitSecured",class extends o{},"[data-unzer-payment-paylater-direct-debit-secured]"),window.PluginManager.register("UnzerPaymentGooglePay",a,"[data-unzer-payment-google-pay]"),window.PluginManager.register("UnzerPaymentExpressButtons",u,"[data-unzer-payment-express-buttons]")})(); \ No newline at end of file diff --git a/src/Resources/app/storefront/src/scss/base.scss b/src/Resources/app/storefront/src/scss/base.scss index 04c95569..26d3c9d7 100755 --- a/src/Resources/app/storefront/src/scss/base.scss +++ b/src/Resources/app/storefront/src/scss/base.scss @@ -4,3 +4,4 @@ @import 'component/unzer-payment/elements-order-history'; @import 'component/unzer-payment/elements-sepa'; @import 'component/unzer-payment/elements-apple-pay'; +@import 'component/unzer-payment/express-buttons'; diff --git a/src/Resources/app/storefront/src/scss/component/unzer-payment/elements-apple-pay.scss b/src/Resources/app/storefront/src/scss/component/unzer-payment/elements-apple-pay.scss index f7d56206..8a69bcba 100644 --- a/src/Resources/app/storefront/src/scss/component/unzer-payment/elements-apple-pay.scss +++ b/src/Resources/app/storefront/src/scss/component/unzer-payment/elements-apple-pay.scss @@ -2,7 +2,6 @@ display: inline-block; -webkit-appearance: -apple-pay-button; -apple-pay-button-type: buy; - margin-top: 10px; --apple-pay-button-width: 100%; --apple-pay-button-height: 30px; --apple-pay-button-border-radius: 5px; diff --git a/src/Resources/app/storefront/src/scss/component/unzer-payment/elements-confirm.scss b/src/Resources/app/storefront/src/scss/component/unzer-payment/elements-confirm.scss index d750c201..77a7cff0 100755 --- a/src/Resources/app/storefront/src/scss/component/unzer-payment/elements-confirm.scss +++ b/src/Resources/app/storefront/src/scss/component/unzer-payment/elements-confirm.scss @@ -77,3 +77,10 @@ .unzersave-payment-device-container { margin: 1em 0; } + +.unzer-blocked-button-message { + display: flex; + gap: 10px; + margin: 10px 0; + align-items: center; +} diff --git a/src/Resources/app/storefront/src/scss/component/unzer-payment/express-buttons.scss b/src/Resources/app/storefront/src/scss/component/unzer-payment/express-buttons.scss new file mode 100644 index 00000000..7f3058c2 --- /dev/null +++ b/src/Resources/app/storefront/src/scss/component/unzer-payment/express-buttons.scss @@ -0,0 +1,4 @@ +/* temporary until changed by Unzer */ +.unzer-google-pay-express-container { + line-height: 0; +} diff --git a/src/Resources/app/storefront/src/unzer/express/unzer-payment.express-buttons.plugin.js b/src/Resources/app/storefront/src/unzer/express/unzer-payment.express-buttons.plugin.js index 7147755e..9b7b9690 100644 --- a/src/Resources/app/storefront/src/unzer/express/unzer-payment.express-buttons.plugin.js +++ b/src/Resources/app/storefront/src/unzer/express/unzer-payment.express-buttons.plugin.js @@ -4,6 +4,7 @@ export default class UnzerPaymentExpressButtonsPlugin extends Plugin { static options = { googlePay: {}, applePay: {}, + keyPairConfig: null, }; /** @@ -39,6 +40,11 @@ export default class UnzerPaymentExpressButtonsPlugin extends Plugin { const unzerExpressPayment = this.el.querySelector( '.unzer-express-payment' ); + if (this.options.keyPairConfig) { + unzerExpressPayment.setMerchantConfigData( + this.options.keyPairConfig + ); + } const unzerPaypalExpress = this.el.querySelector( '.unzer-paypal-express' ); @@ -58,6 +64,9 @@ export default class UnzerPaymentExpressButtonsPlugin extends Plugin { if (unzerGooglePay) { this.registerGooglePay(unzerGooglePay, unzerExpressPayment); + const container = unzerGooglePay.parentNode; + unzerGooglePay.remove(); + container.appendChild(unzerGooglePay); } if (unzerApplePay) { diff --git a/src/Resources/app/storefront/src/unzer/unzer-payment.base.plugin.js b/src/Resources/app/storefront/src/unzer/unzer-payment.base.plugin.js index 13844ba3..98c93a3e 100755 --- a/src/Resources/app/storefront/src/unzer/unzer-payment.base.plugin.js +++ b/src/Resources/app/storefront/src/unzer/unzer-payment.base.plugin.js @@ -5,6 +5,7 @@ export default class UnzerPaymentBasePlugin extends Plugin { publicKey: null, shopLocale: null, unzerCustomer: null, + keyPairConfig: null, submitButtonId: 'confirmFormSubmit', disabledClass: 'disabled', resourceIdElementId: 'unzerResourceId', @@ -57,19 +58,42 @@ export default class UnzerPaymentBasePlugin extends Plugin { 'click', this._onSubmitButtonClick.bind(this) ); - if (this.options.unzerCustomer) { - Promise.all([customElements.whenDefined('unzer-payment')]).then( - () => { - const unzerPaymentElement = document.getElementById( - 'unzer-payment-component' + + customElements.whenDefined('unzer-payment').then(() => { + const unzerPaymentElement = document.getElementById( + 'unzer-payment-component' + ); + if (unzerPaymentElement) { + if (this.options.unzerCustomer) { + unzerPaymentElement.setCustomerData( + this.options.unzerCustomer ); - if (unzerPaymentElement) { - unzerPaymentElement.setCustomerData( - this.options.unzerCustomer - ); - } } - ); + if (this.options.keyPairConfig) { + unzerPaymentElement.setMerchantConfigData( + this.options.keyPairConfig + ); + } + } + }); + + if (!document.querySelector('unzer-payment')) { + this.unblockButton(); + } else { + customElements.whenDefined('unzer-payment').then(() => { + this.unblockButton(); + }); + } + } + + unblockButton() { + const blockedButton = document.querySelector( + '[data-unzer-blocked-button="true"]' + ); + if (blockedButton) { + blockedButton.removeAttribute('disabled'); + blockedButton.removeAttribute('data-unzer-blocked-button'); + document.querySelector('.unzer-blocked-button-message')?.remove(); } } diff --git a/src/Resources/app/storefront/src/unzer/unzer-payment.google-pay.plugin.js b/src/Resources/app/storefront/src/unzer/unzer-payment.google-pay.plugin.js index 782ceb8e..36fa930a 100755 --- a/src/Resources/app/storefront/src/unzer/unzer-payment.google-pay.plugin.js +++ b/src/Resources/app/storefront/src/unzer/unzer-payment.google-pay.plugin.js @@ -32,7 +32,10 @@ export default class UnzerPaymentGooglePayPlugin extends UnzerPaymentBaseParent * @private */ _registerGooglePayButton() { - Promise.all([customElements.whenDefined('unzer-payment')]).then(() => { + Promise.all([ + customElements.whenDefined('unzer-payment'), + customElements.whenDefined('unzer-checkout'), + ]).then(() => { const unzerPaymentElement = document.getElementById( 'unzer-payment-component' ); diff --git a/src/Resources/config/dependencies/event_listeners.xml b/src/Resources/config/dependencies/event_listeners.xml index be996d2e..a7419f3b 100644 --- a/src/Resources/config/dependencies/event_listeners.xml +++ b/src/Resources/config/dependencies/event_listeners.xml @@ -21,6 +21,7 @@ + @@ -68,6 +69,7 @@ + diff --git a/src/Resources/config/dependencies/services.xml b/src/Resources/config/dependencies/services.xml index 4a7e0435..8f9f2828 100644 --- a/src/Resources/config/dependencies/services.xml +++ b/src/Resources/config/dependencies/services.xml @@ -117,5 +117,9 @@ + + + + diff --git a/src/Resources/config/settings.xml b/src/Resources/config/settings.xml index 2af494fd..0bc347c3 100755 --- a/src/Resources/config/settings.xml +++ b/src/Resources/config/settings.xml @@ -314,6 +314,14 @@ Advanced settings Erweiterte Einstellungen + + blockConfirmButtonOnLoad + + + + + + statusForAutomaticShippingNotification state_machine_state diff --git a/src/Resources/public/administration/js/unzer-payment6.js b/src/Resources/public/administration/js/unzer-payment6.js index cdb850bf..6a8a4f6e 100644 --- a/src/Resources/public/administration/js/unzer-payment6.js +++ b/src/Resources/public/administration/js/unzer-payment6.js @@ -1 +1 @@ -!function(){var e={296:function(){},906:function(){},836:function(){},325:function(){},299:function(){},963:function(){let{Application:e}=Shopware,t=Shopware.Classes.ApiService;class n extends t{constructor(e,t,n="unzer-payment"){super(e,t,n)}validateCredentials(e){return this.httpClient.post(`_action/${this.getApiBasePath()}/validate-credentials`,e,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}registerWebhooks(e){return this.httpClient.post(`_action/${this.getApiBasePath()}/register-webhooks`,e,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}clearWebhooks(e){return this.httpClient.post(`_action/${this.getApiBasePath()}/clear-webhooks`,e,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}getWebhooks(e){return this.httpClient.post(`_action/${this.getApiBasePath()}/get-webhooks`,{privateKey:e},{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}getGooglePayGatewayMerchantId(e){return this.httpClient.get(`_action/${this.getApiBasePath()}/get-google-pay-gateway-merchant-id?salesChannelId=${e||""}`,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}}e.addServiceProvider("UnzerPaymentConfigurationService",t=>new n(e.getContainer("init").httpClient,t.loginService))},748:function(){let{Application:e}=Shopware,t=Shopware.Classes.ApiService;class n extends t{constructor(e,t,n="unzer-payment"){super(e,t,n)}fetchPaymentDetails(e){let n=`_action/${this.getApiBasePath()}/transaction/${e}/details`;return this.httpClient.get(n,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}chargeTransaction(e,n,a){let s=`_action/${this.getApiBasePath()}/transaction/${e}/charge/${a}`;return this.httpClient.get(s,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}refundTransaction(e,n,a,s=null){let i=`_action/${this.getApiBasePath()}/transaction/${e}/refund/${n}/${a}`;return null!==s&&(i=`${i}/${s}`),this.httpClient.get(i,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}cancelTransaction(e,n,a){let s=`_action/${this.getApiBasePath()}/transaction/${e}/cancel/${n}/${a}`;return this.httpClient.get(s,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}ship(e){let n=`_action/${this.getApiBasePath()}/transaction/${e}/ship`;return this.httpClient.get(n,{headers:this.getBasicHeaders()}).then(e=>t.handleResponse(e))}}e.addServiceProvider("UnzerPaymentService",t=>new n(e.getContainer("init").httpClient,t.loginService))},337:function(){let{Component:e}=Shopware,{Criteria:t,EntityCollection:n}=Shopware.Data;e.extend("unzer-entity-multi-select-delivery-status","sw-entity-multi-id-select",{inject:["repositoryFactory"],props:{repository:{type:Object,required:!0,default(){return this.repositoryFactory.create("state_machine_state")}},criteria:{type:Object,required:!1,default(){let e=new t(1,100);return e.addFilter(t.equals("stateMachine.technicalName","order_delivery.state")),e}},entityCollection(){}}})},708:function(){let{Component:e}=Shopware,{Criteria:t}=Shopware.Data;e.extend("unzer-entity-single-select-delivery-status","sw-entity-single-select",{props:{criteria:{type:Object,required:!1,default(){let e=new t(1,100);return e.addFilter(t.equals("stateMachine.technicalName","order_delivery.state")),e}}}})},129:function(e,t,n){var a=n(296);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("0620ec53",a,!0,{})},425:function(e,t,n){var a=n(906);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("f0afdb6a",a,!0,{})},345:function(e,t,n){var a=n(836);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("61f99e4d",a,!0,{})},90:function(e,t,n){var a=n(325);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("05921a3e",a,!0,{})},34:function(e,t,n){var a=n(299);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(534).A)("3bbcbade",a,!0,{})},534:function(e,t,n){"use strict";function a(e,t){for(var n=[],a={},s=0;sn.parts.length&&(a.parts.length=n.parts.length)}else{for(var i=[],s=0;s\n {% block unzer_payment_actions_amount_field %}\n
\n \n \n
\n {% endblock %}\n
\n \n {% block unzer_payment_actions_charge_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.chargeButton\') }}\n \n {% endblock %}\n\n {% block unzer_payment_actions_cancel_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.cancelButton\') }}\n \n {% endblock %}\n \n \n {% block unzer_payment_actions_reason_field %}\n \n \n {% endblock %}\n\n {% block unzer_payment_actions_refund_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.refundButton\') }}\n \n {% endblock %}\n \n {% block unzer_payment_actions_button_container_inner %}{% endblock %}\n
\n \n\n
\n {{ $tc(\'unzer-payment.paymentDetails.actions.noActions\') }}\n
\n{% endblock %}',inject:["UnzerPaymentService"],mixins:[t.getByName("notification")],data(){return{isLoading:!1,isSuccessful:!1,transactionAmount:0,reasonCode:null}},props:{transactionResource:{type:Object,required:!0},paymentResource:{type:Object,required:!0},decimalPrecision:{type:Number,required:!0,default:4}},computed:{isChargePossible:function(){return"authorization"===this.transactionResource.type&&"error"!==this.transactionResource.state},isRefundPossible:function(){return"charge"===this.transactionResource.type&&"error"!==this.transactionResource.state&&!(this.transactionResource.isFirst&&"085b64d0028a8bd447294e03c4eb411a"===this.paymentResource.paymentMethodId&&"pending"!==this.paymentResource.state.name&&"partly"!==this.paymentResource.state.name)},maxTransactionAmount(){let e=0,t=this.isRefundPossible&&"085b64d0028a8bd447294e03c4eb411a"===this.paymentResource.paymentMethodId;return this.isRefundPossible&&(e=this.transactionResource.amount),this.isChargePossible&&(e=this.paymentResource.amount.remaining),"remainingAmount"in this.transactionResource&&(e=this.transactionResource.remainingAmount),this.transactionResource.isFirst&&t&&(e=this.paymentResource.amount.remaining),e/10**this.paymentResource.amount.decimalPrecision},reasonCodeSelection(){return[{label:this.$tc("unzer-payment.paymentDetails.actions.reason.cancel"),value:"CANCEL"},{label:this.$tc("unzer-payment.paymentDetails.actions.reason.credit"),value:"CREDIT"},{label:this.$tc("unzer-payment.paymentDetails.actions.reason.return"),value:"RETURN"}]}},created(){this.transactionAmount=this.maxTransactionAmount},methods:{charge(){this.isLoading=!0,this.UnzerPaymentService.chargeTransaction(this.paymentResource.orderTransactionId,this.transactionResource.id,this.transactionAmount).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.chargeSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.chargeSuccessMessage")}),this.isSuccessful=!0,this.$emit("reload")}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.genericErrorMessage")),"paylater-invoice-document-required"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.paylaterInvoiceDocumentRequiredErrorMessage")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.chargeErrorTitle"),message:t}),this.isLoading=!1})},refund(){this.isLoading=!0,this.UnzerPaymentService.refundTransaction(this.paymentResource.orderTransactionId,this.transactionResource.id,this.transactionAmount,this.reasonCode).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.refundSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.refundSuccessMessage")}),this.isSuccessful=!0,this.$emit("reload")}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.genericErrorMessage")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.refundErrorTitle"),message:t}),this.isLoading=!1})},startCancel(){this.$emit("cancel",this.transactionAmount)}}});let{Component:a,Mixin:s,Module:i}=Shopware;a.register("unzer-payment-detail",{template:'{% block unzer_payment_detail %}\n \n \n {% block unzer_payment_detail_footer %}\n \n {% block unzer_payment_detail_ship_button %}\n \n {{ $tc(\'unzer-payment.paymentDetails.actions.shipButton\') }}\n \n {% endblock %}\n \n {% endblock %}\n \n{% endblock %}',inject:["UnzerPaymentService"],mixins:[s.getByName("notification")],data(){return{isLoading:!1,isSuccessful:!1,paylaterPaymentMethods:["09588ffee8064f168e909ff31889dd7f","12fbfbce271a43a89b3783453b88e9a6","6d6adcd4b7bf40499873c294a85f32ed"]}},props:{paymentResource:{type:Object,required:!0}},computed:{unzerMaxDigits(){let e=i.getModuleRegistry().get("unzer-payment");return e&&e.manifest?e.manifest.maxDigits:4},remainingAmount(){return this.paymentResource&&this.paymentResource.amount?this.formatAmount(this.paymentResource.amount.remaining,this.paymentResource.amount.decimalPrecision):0},cancelledAmount(){return this.paymentResource&&this.paymentResource.amount?this.formatAmount(this.paymentResource.amount.cancelled,this.paymentResource.amount.decimalPrecision):0},chargedAmount(){return this.paymentResource&&this.paymentResource.amount?this.formatAmount(this.paymentResource.amount.charged,this.paymentResource.amount.decimalPrecision):0}},methods:{reloadOrderDetail(){this.$emit("reloadOrderDetails")},ship(){this.isLoading=!0,this.UnzerPaymentService.ship(this.paymentResource.orderTransactionId).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.shipSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.shipSuccessMessage")}),this.isSuccessful=!0,this.$emit("reload")}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t?t=this.$tc("unzer-payment.paymentDetails.notifications.genericErrorMessage"):"invoice-missing-error"===t?t=this.$tc("unzer-payment.paymentDetails.notifications.invoiceNotFoundMessage"):"documentdate-missing-error"===t?t=this.$tc("unzer-payment.paymentDetails.notifications.documentDateMissingError"):"payment-missing-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.paymentMissingError")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.shipErrorTitle"),message:t}),this.isLoading=!1})},formatAmount(e,t){return e/10**Math.min(this.unzerMaxDigits,t)},formatCurrency(e){return Shopware.Utils.format.currency(e||0,this.paymentResource.currency)},isPaylaterPaymentMethod(e){return this.paylaterPaymentMethods.indexOf(e)>=0}}});let{Component:r,Module:o,Mixin:c}=Shopware;r.register("unzer-payment-history",{template:'{% block unzer_payment_history %}\n \n {% block unzer_payment_history_container %}\n \n {% endblock %}\n \n{% endblock %}',inject:["repositoryFactory","UnzerPaymentService"],mixins:[c.getByName("notification")],data(){return{showCancelModal:!1,isCancelLoading:!1,cancelAmount:0}},props:{paymentResource:{type:Object,required:!0}},computed:{unzerMaxDigits(){let e=o.getModuleRegistry().get("unzer-payment");return e&&e.manifest?e.manifest.maxDigits:4},orderTransactionRepository:function(){return this.repositoryFactory.create("order_transaction")},decimalPrecision(){return this.paymentResource&&this.paymentResource.amount&&this.paymentResource.amount.decimalPrecision?Math.min(this.unzerMaxDigits,this.paymentResource.amount.decimalPrecision):this.unzerMaxDigits},data:function(){let e=[];return Object.values(this.paymentResource.transactions).forEach(t=>{let n=this.formatCurrency(this.formatAmount(parseFloat(t.amount),this.decimalPrecision)),a=Shopware.Filter.getByName("date")(t.date,{hour:"numeric",minute:"numeric",second:"numeric"});e.push({type:this.transactionTypeRenderer(t.type),amount:n,date:a,resource:t})}),e},columns:function(){return[{property:"type",label:this.$tc("unzer-payment.paymentDetails.history.column.type"),rawData:!0},{property:"amount",label:this.$tc("unzer-payment.paymentDetails.history.column.amount"),rawData:!0},{property:"date",label:this.$tc("unzer-payment.paymentDetails.history.column.date"),rawData:!0}]}},methods:{transactionTypeRenderer:function(e){switch(e){case"authorization":return this.$tc("unzer-payment.paymentDetails.history.type.authorization");case"charge":return this.$tc("unzer-payment.paymentDetails.history.type.charge");case"shipment":return this.$tc("unzer-payment.paymentDetails.history.type.shipment");case"refund":return this.$tc("unzer-payment.paymentDetails.history.type.refund");case"cancellation":return this.$tc("unzer-payment.paymentDetails.history.type.cancellation");default:return this.$tc("unzer-payment.paymentDetails.history.type.default")}},reload:function(){this.$emit("reload"),this.$emit("reloadOrderDetails")},formatAmount(e,t){return e/10**t},openCancelModal(e,t){this.showCancelModal=e.resource.id,this.cancelAmount=t},closeCancelModal(){this.showCancelModal=!1,this.cancelAmount=0},cancel(){this.isCancelLoading=!0,this.UnzerPaymentService.cancelTransaction(this.paymentResource.orderTransactionId,this.paymentResource.id,this.cancelAmount).then(()=>{this.createNotificationSuccess({title:this.$tc("unzer-payment.paymentDetails.notifications.cancelSuccessTitle"),message:this.$tc("unzer-payment.paymentDetails.notifications.cancelSuccessMessage")}),this.reload()}).catch(e=>{let t=e.response.data.errors[0];"generic-error"===t&&(t=this.$tc("unzer-payment.paymentDetails.notifications.cancelErrorMessage")),this.createNotificationError({title:this.$tc("unzer-payment.paymentDetails.notifications.cancelErrorTitle"),message:t}),this.isCancelLoading=!1,this.reload()})},formatCurrency(e){return Shopware.Utils.format.currency(e||0,this.paymentResource.currency)}}});let{Component:l}=Shopware;l.register("unzer-payment-metadata",{template:'{% block unzer_payment_metadata %}\n