From c5020d7d056457bcd22a9ffbf72a823a1046460e Mon Sep 17 00:00:00 2001 From: paeddl Date: Fri, 27 Mar 2026 09:56:53 +0100 Subject: [PATCH 1/2] v6.5.5 --- CHANGELOG_de-DE.md | 2 ++ CHANGELOG_en-GB.md | 2 ++ composer.json | 2 +- .../AbstractUnzerPaymentHandler.php | 3 ++- .../PaymentHandler/Traits/CanAuthorize.php | 3 +++ .../PaymentHandler/Traits/CanCharge.php | 3 +++ .../UnzerPayPalPaymentHandler.php | 5 +++++ .../CreditCardTransitionMapper.php | 3 ++- .../MetadataResourceHydrator.php | 6 ++++++ src/Installer/PaymentInstaller.php | 10 +++++----- .../component/unzer-payment-actions/index.js | 10 ++++++++-- .../page/unzer-payment-tab/index.js | 2 +- .../js/unzer-payment6/unzer-payment6.js | 2 +- .../unzer/unzer-payment.apple-pay-v2.plugin.js | 18 +++--------------- .../public/administration/js/unzer-payment6.js | 2 +- 15 files changed, 45 insertions(+), 28 deletions(-) diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index 10d111e0..be0453cb 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,3 +1,5 @@ +# 6.5.5 + # 6.5.4 * Aktualisierung iDEAL Payment Naming diff --git a/CHANGELOG_en-GB.md b/CHANGELOG_en-GB.md index 4ddb6117..475684cc 100644 --- a/CHANGELOG_en-GB.md +++ b/CHANGELOG_en-GB.md @@ -1,3 +1,5 @@ +# 6.5.5 + # 6.5.4 * Updated iDEAL Payment naming diff --git a/composer.json b/composer.json index dc1f0bc2..1da52155 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "unzerdev/shopware6", "description": "Unzer payment integration for Shopware 6", - "version": "6.5.4", + "version": "6.5.5", "type": "shopware-platform-plugin", "license": "Apache-2.0", "minimum-stability": "dev", diff --git a/src/Components/PaymentHandler/AbstractUnzerPaymentHandler.php b/src/Components/PaymentHandler/AbstractUnzerPaymentHandler.php index 2b81e32d..2d2a943e 100755 --- a/src/Components/PaymentHandler/AbstractUnzerPaymentHandler.php +++ b/src/Components/PaymentHandler/AbstractUnzerPaymentHandler.php @@ -121,7 +121,8 @@ public function pay( $this->unzerClient = $this->clientFactory->createClientFromSalesChannelContext($salesChannelContext, $currentRequest); $this->unzerBasket = $this->basketHydrator->hydrateObject($salesChannelContext, $transaction); - $this->unzerMetadata = $this->metadataHydrator->hydrateObject($salesChannelContext, $transaction); + $orderTransaction = $this->fetchTransactionById($transaction->getOrderTransaction()->getId(), $salesChannelContext->getContext()); + $this->unzerMetadata = $this->metadataHydrator->hydrateObject($salesChannelContext, $orderTransaction); $this->metadataHydrator->setIsExpress($this->unzerMetadata, $this->isExpress); $this->unzerCustomer = $this->getUnzerCustomer($currentRequest->get('unzerCustomerId', ''), $transaction->getOrderTransaction()->getPaymentMethodId(), $transaction->getOrderTransaction(), $salesChannelContext); diff --git a/src/Components/PaymentHandler/Traits/CanAuthorize.php b/src/Components/PaymentHandler/Traits/CanAuthorize.php index c7ff0c25..eca63e6f 100644 --- a/src/Components/PaymentHandler/Traits/CanAuthorize.php +++ b/src/Components/PaymentHandler/Traits/CanAuthorize.php @@ -35,6 +35,9 @@ public function authorize( ); $authorization->setOrderId($this->unzerBasket->getOrderId()); + if (!empty($this->unzerMetadata) && !empty($this->unzerMetadata->getMetadata('shopwareOrderNumber'))) { + $authorization->setInvoiceId($this->unzerMetadata->getMetadata('shopwareOrderNumber')); + } $authorization->setCard3ds(true); if ($recurrenceType !== null) { diff --git a/src/Components/PaymentHandler/Traits/CanCharge.php b/src/Components/PaymentHandler/Traits/CanCharge.php index 3cf158b0..785019d5 100644 --- a/src/Components/PaymentHandler/Traits/CanCharge.php +++ b/src/Components/PaymentHandler/Traits/CanCharge.php @@ -38,6 +38,9 @@ public function charge( ); $charge->setOrderId($this->unzerBasket->getOrderId()); + if (!empty($this->unzerMetadata) && !empty($this->unzerMetadata->getMetadata('shopwareOrderNumber'))) { + $charge->setInvoiceId($this->unzerMetadata->getMetadata('shopwareOrderNumber')); + } $charge->setCard3ds(true); if ($recurrenceType !== null) { diff --git a/src/Components/PaymentHandler/UnzerPayPalPaymentHandler.php b/src/Components/PaymentHandler/UnzerPayPalPaymentHandler.php index 95000903..592e3870 100644 --- a/src/Components/PaymentHandler/UnzerPayPalPaymentHandler.php +++ b/src/Components/PaymentHandler/UnzerPayPalPaymentHandler.php @@ -340,6 +340,7 @@ private function payExpress( $unzerClient->updateBasket($unzerBasket); $orderTransaction = $this->fetchTransactionById($transaction->getOrderTransaction()->getId(), $salesChannelContext->getContext()); + // this does implicitly update the customer object $this->getUnzerCustomer($payment->getCustomer()?->getId() ?? '', $transaction->getOrderTransaction()->getPaymentMethodId(), $orderTransaction, $salesChannelContext); @@ -349,6 +350,8 @@ private function payExpress( $unzerBasket->getCurrencyCode(), $transaction->getReturnUrl() ); + $authorization->setInvoiceId($orderTransaction->getOrder()->getOrderNumber()); + $authorization->setOrderId($orderTransaction->getId()); $unzerClient->updateAuthorization($payment->getId(), $authorization); } else { $charge = new Charge( @@ -356,6 +359,8 @@ private function payExpress( $unzerBasket->getCurrencyCode(), $transaction->getReturnUrl() ); + $charge->setInvoiceId($orderTransaction->getOrder()->getOrderNumber()); + $charge->setOrderId($orderTransaction->getId()); $unzerClient->updateCharge($payment->getId(), $charge); } $this->persistPaymentInformation( diff --git a/src/Components/PaymentTransitionMapper/CreditCardTransitionMapper.php b/src/Components/PaymentTransitionMapper/CreditCardTransitionMapper.php index 46c299a7..4730f6a6 100644 --- a/src/Components/PaymentTransitionMapper/CreditCardTransitionMapper.php +++ b/src/Components/PaymentTransitionMapper/CreditCardTransitionMapper.php @@ -9,6 +9,7 @@ use UnzerPayment6\Components\PaymentTransitionMapper\Traits\IsBasicPaymentMethodTransitionMapperWithBookingMode; use UnzerSDK\Resources\PaymentTypes\BasePaymentType; use UnzerSDK\Resources\PaymentTypes\Card; +use UnzerSDK\Resources\PaymentTypes\Clicktopay; class CreditCardTransitionMapper extends AbstractTransitionMapper { @@ -19,7 +20,7 @@ class CreditCardTransitionMapper extends AbstractTransitionMapper public function supports(BasePaymentType $paymentType): bool { - return $paymentType instanceof Card; + return $paymentType instanceof Card || $paymentType instanceof Clicktopay; } protected function getResourceName(): string diff --git a/src/Components/ResourceHydrator/MetadataResourceHydrator.php b/src/Components/ResourceHydrator/MetadataResourceHydrator.php index f5580cd8..3e516a2e 100755 --- a/src/Components/ResourceHydrator/MetadataResourceHydrator.php +++ b/src/Components/ResourceHydrator/MetadataResourceHydrator.php @@ -4,6 +4,8 @@ namespace UnzerPayment6\Components\ResourceHydrator; +use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity; +use Shopware\Core\Checkout\Order\OrderEntity; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; @@ -43,6 +45,10 @@ public function hydrateObject( $unzerMetadata->setShopVersion($this->shopwareVersion); $unzerMetadata->addMetadata('pluginType', 'unzerdev/shopware6'); + if ($transaction instanceof OrderTransactionEntity && $transaction->getOrder() instanceof OrderEntity) { + $unzerMetadata->addMetadata('shopwareOrderNumber', $transaction->getOrder()->getOrderNumber()); + } + if ($pluginData !== null) { $unzerMetadata->addMetadata('pluginVersion', $pluginData->getVersion()); } diff --git a/src/Installer/PaymentInstaller.php b/src/Installer/PaymentInstaller.php index 64640348..b164bf60 100755 --- a/src/Installer/PaymentInstaller.php +++ b/src/Installer/PaymentInstaller.php @@ -174,12 +174,12 @@ class PaymentInstaller implements InstallerInterface 'technicalName' => 'unzer_installment', 'translations' => [ 'de-DE' => [ - 'name' => 'Ratenkauf', - 'description' => 'Unzer Ratenkauf', + 'name' => 'Ratenzahlung', + 'description' => 'Ratenzahlung mit Unzer payments', ], 'en-GB' => [ 'name' => 'Installment', - 'description' => 'Unzer Installment', + 'description' => 'Installment with Unzer payments', ], ], ], @@ -302,8 +302,8 @@ class PaymentInstaller implements InstallerInterface 'technicalName' => 'unzer_invoice', 'translations' => [ 'de-DE' => [ - 'name' => 'Rechnungskauf', - 'description' => 'Rechnungskauf mit Unzer payments', + 'name' => 'Rechnung', + 'description' => 'Zahlung auf Rechnung mit Unzer payments', ], 'en-GB' => [ 'name' => 'Invoice', diff --git a/src/Resources/app/administration/src/module/unzer-payment/component/unzer-payment-actions/index.js b/src/Resources/app/administration/src/module/unzer-payment/component/unzer-payment-actions/index.js index 2609fc3c..5e40ec65 100644 --- a/src/Resources/app/administration/src/module/unzer-payment/component/unzer-payment-actions/index.js +++ b/src/Resources/app/administration/src/module/unzer-payment/component/unzer-payment-actions/index.js @@ -67,7 +67,10 @@ Component.register('unzer-payment-actions', { maxTransactionAmount() { let amount = 0; - let isAmountForPrepaymentRefund = this.isRefundPossible && this.paymentResource.paymentMethodId === '085b64d0028a8bd447294e03c4eb411a'; + let isAmountForPrepaymentRefund = + this.isRefundPossible && + this.paymentResource.paymentMethodId === + '085b64d0028a8bd447294e03c4eb411a'; if (this.isRefundPossible) { amount = this.transactionResource.amount; @@ -81,7 +84,10 @@ Component.register('unzer-payment-actions', { amount = this.transactionResource.remainingAmount; } - if (this.transactionResource.isFirst && isAmountForPrepaymentRefund) { + if ( + this.transactionResource.isFirst && + isAmountForPrepaymentRefund + ) { amount = this.paymentResource.amount.remaining; } diff --git a/src/Resources/app/administration/src/module/unzer-payment/page/unzer-payment-tab/index.js b/src/Resources/app/administration/src/module/unzer-payment/page/unzer-payment-tab/index.js index 05a7f753..f58cef54 100644 --- a/src/Resources/app/administration/src/module/unzer-payment/page/unzer-payment-tab/index.js +++ b/src/Resources/app/administration/src/module/unzer-payment/page/unzer-payment-tab/index.js @@ -15,7 +15,7 @@ Component.register('unzer-payment-tab', { paymentResources: [], loadedResources: 0, isLoading: true, - order:null + order: null, }; }, 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 01d35fb9..d149e7c3 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&&(console.log("set customer data",this.options.unzerCustomer),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)}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)try{let t=await e.submit();t.submitResponse?!0===t.submitResponse.success?(console.log("submit response: ",t.submitResponse),this.submitTypeId(t.submitResponse.data.id,t.threatMetrixId||null)):this.showError({message:"GENERAL ERROR"}):this.showError({message:"EXCEPTIONAL ERROR"})}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",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._hasCapability()?(this._createForm(),this._hideBuyButton()):this._disableApplePay()}_hasCapability(){return window.ApplePaySession&&window.ApplePaySession.canMakePayments()&&window.ApplePaySession.supportsVersion(6)}_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 a 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})})}}a.options={countryIso:"",paylaterInstallmentAmount:"",paylaterInstallmentCurrency:""};class r 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.log("ERROR",t)})})}_hideBuyButton(){this._getSubmitButton().style.display="none"}}r.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"},r.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)=>{console.log("paymentData:",e);let o=await t.submit(),i=o.submitResponse.data.id;console.log(o,"--- success paymentTypeId",i),console.log("submit response: ",o),fetch("/unzer/google-pay-express",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentTypeId:i,paymentData:e})}).then(e=>e.json()).then(e=>{console.log(JSON.stringify(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)=>{console.log("paymentData:",e);let i=o.payment.shippingContact,a=o.payment.billingContact;console.log(i),console.log(a);let r=await t.submit();r.submitResponse.success?n():s();let l=r.submitResponse.data.id;console.log(r,"--- success paymentTypeId",l),console.log("submit response: ",r),fetch("/unzer/applepay-express",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentTypeId:l,paymentData:e,shippingContact:i,billingContact:a})}).then(e=>e.json()).then(e=>{console.log(JSON.stringify(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",a,"[data-unzer-payment-paylater-installment]"),window.PluginManager.register("UnzerPaymentPaylaterDirectDebitSecured",class extends s{},"[data-unzer-payment-paylater-direct-debit-secured]"),window.PluginManager.register("UnzerPaymentGooglePay",r,"[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)),this.options.unzerCustomer&&Promise.all([customElements.whenDefined("unzer-payment")]).then(()=>{let e=document.getElementById("unzer-payment-component");e&&(console.log("set customer data",this.options.unzerCustomer),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)}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)try{let t=await e.submit();t.submitResponse?!0===t.submitResponse.success?(console.log("submit response: ",t.submitResponse),this.submitTypeId(t.submitResponse.data.id,t.threatMetrixId||null)):this.showError({message:"GENERAL ERROR"}):this.showError({message:"EXCEPTIONAL ERROR"})}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",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 a 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})})}}a.options={countryIso:"",paylaterInstallmentAmount:"",paylaterInstallmentCurrency:""};class r 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.log("ERROR",t)})})}_hideBuyButton(){this._getSubmitButton().style.display="none"}}r.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"},r.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)=>{console.log("paymentData:",e);let o=await t.submit(),i=o.submitResponse.data.id;console.log(o,"--- success paymentTypeId",i),console.log("submit response: ",o),fetch("/unzer/google-pay-express",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentTypeId:i,paymentData:e})}).then(e=>e.json()).then(e=>{console.log(JSON.stringify(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)=>{console.log("paymentData:",e);let i=o.payment.shippingContact,a=o.payment.billingContact;console.log(i),console.log(a);let r=await t.submit();r.submitResponse.success?n():s();let l=r.submitResponse.data.id;console.log(r,"--- success paymentTypeId",l),console.log("submit response: ",r),fetch("/unzer/applepay-express",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentTypeId:l,paymentData:e,shippingContact:i,billingContact:a})}).then(e=>e.json()).then(e=>{console.log(JSON.stringify(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",a,"[data-unzer-payment-paylater-installment]"),window.PluginManager.register("UnzerPaymentPaylaterDirectDebitSecured",class extends s{},"[data-unzer-payment-paylater-direct-debit-secured]"),window.PluginManager.register("UnzerPaymentGooglePay",r,"[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/unzer/unzer-payment.apple-pay-v2.plugin.js b/src/Resources/app/storefront/src/unzer/unzer-payment.apple-pay-v2.plugin.js index 24e85ce8..892ae38e 100755 --- a/src/Resources/app/storefront/src/unzer/unzer-payment.apple-pay-v2.plugin.js +++ b/src/Resources/app/storefront/src/unzer/unzer-payment.apple-pay-v2.plugin.js @@ -17,21 +17,8 @@ export default class UnzerPaymentApplePayPlugin extends UnzerPaymentBaseParent { init() { super.init(); - if (this._hasCapability()) { - this._createForm(); - // this._registerEvents(); - this._hideBuyButton(); - } else { - this._disableApplePay(); - } - } - - _hasCapability() { - return ( - window.ApplePaySession && - window.ApplePaySession.canMakePayments() && - window.ApplePaySession.supportsVersion(6) - ); + this._createForm(); + this._hideBuyButton(); } _disableApplePay() { @@ -89,6 +76,7 @@ export default class UnzerPaymentApplePayPlugin extends UnzerPaymentBaseParent { }, }; } + /** * @private */ diff --git a/src/Resources/public/administration/js/unzer-payment6.js b/src/Resources/public/administration/js/unzer-payment6.js index b273cc10..cdb850bf 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