From 613fc6a458b177f6e3685e29100456b447096564 Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Tue, 19 Nov 2024 10:16:39 +0100 Subject: [PATCH] Add Online Banking Finland payment method ISSUE: ADCRSET21I-4 --- README.md | 1 + src/AdyenPaymentShopware6.php | 107 +++++++++++------- ...lineBankingFinlandPaymentMethodHandler.php | 11 ++ .../OnlineBankingFinlandPaymentMethod.php | 78 +++++++++++++ src/PaymentMethods/PaymentMethods.php | 3 +- .../storefront/js/adyen-payment-shopware6.js | 2 +- .../app/storefront/src/configuration/adyen.js | 5 +- .../config/services/payment-handlers.xml | 4 + 8 files changed, 165 insertions(+), 46 deletions(-) create mode 100644 src/Handlers/OnlineBankingFinlandPaymentMethodHandler.php create mode 100644 src/PaymentMethods/OnlineBankingFinlandPaymentMethod.php diff --git a/README.md b/README.md index 567ec239..4f379e05 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ The plugin integrates card component (Secured Fields) using Adyen Checkout for a - Vipps - WeChat Pay - Open Banking / Pay by Bank + - Online Banking Finland ## API Library This module is using the Adyen APIs Library for PHP for all (API) connections to Adyen. diff --git a/src/AdyenPaymentShopware6.php b/src/AdyenPaymentShopware6.php index 3a00c8b0..f9c0a792 100644 --- a/src/AdyenPaymentShopware6.php +++ b/src/AdyenPaymentShopware6.php @@ -175,6 +175,10 @@ public function update(UpdateContext $updateContext): void if (\version_compare($currentVersion, '3.16.0', '<')) { $this->updateTo3160($updateContext); } + + if (\version_compare($currentVersion, '3.17.0', '<')) { + $this->updateTo3170($updateContext); + } } private function addPaymentMethod(PaymentMethods\PaymentMethodInterface $paymentMethod, Context $context): void @@ -236,10 +240,11 @@ private function getPaymentMethodId(string $paymentMethodHandler): ?string } private function setPaymentMethodIsActive( - bool $active, - Context $context, + bool $active, + Context $context, PaymentMethods\PaymentMethodInterface $paymentMethod - ): void { + ): void + { /** @var EntityRepository $paymentRepository */ $paymentRepository = $this->container->get('payment_method.repository'); @@ -321,11 +326,11 @@ private function updateTo160(UpdateContext $updateContext): void { //Version 1.6.0 introduces applepay, paywithgoogle, dotpay and bancontact foreach ([ - new PaymentMethods\ApplePayPaymentMethod, - new PaymentMethods\GooglePayPaymentMethod, - new PaymentMethods\DotpayPaymentMethod, - new PaymentMethods\BancontactCardPaymentMethod - ] as $method) { + new PaymentMethods\ApplePayPaymentMethod, + new PaymentMethods\GooglePayPaymentMethod, + new PaymentMethods\DotpayPaymentMethod, + new PaymentMethods\BancontactCardPaymentMethod + ] as $method) { $this->addPaymentMethod( $method, $updateContext->getContext() @@ -342,9 +347,9 @@ private function updateTo200(UpdateContext $updateContext): void { //Version 2.0.0 introduces amazonpay, blik foreach ([ - new PaymentMethods\AmazonPayPaymentMethod, - new PaymentMethods\BlikPaymentMethod, - ] as $method) { + new PaymentMethods\AmazonPayPaymentMethod, + new PaymentMethods\BlikPaymentMethod, + ] as $method) { $this->addPaymentMethod( $method, $updateContext->getContext() @@ -361,23 +366,23 @@ private function updateTo300(UpdateContext $updateContext): void { //Version 3.0.0 introduces the following payment methods foreach ([ - new PaymentMethods\AfterpayDefaultPaymentMethod, - new PaymentMethods\AlipayPaymentMethod, - new PaymentMethods\AlipayHkPaymentMethod, - new PaymentMethods\ClearpayPaymentMethod, - new PaymentMethods\EpsPaymentMethod, - new PaymentMethods\Facilypay3xPaymentMethod, - new PaymentMethods\Facilypay4xPaymentMethod, - new PaymentMethods\Facilypay6xPaymentMethod, - new PaymentMethods\Facilypay10xPaymentMethod, - new PaymentMethods\Facilypay12xPaymentMethod, - new PaymentMethods\PaysafecardPaymentMethod, - new PaymentMethods\RatepayPaymentMethod, - new PaymentMethods\RatepayDirectdebitPaymentMethod, - new PaymentMethods\SwishPaymentMethod, - new PaymentMethods\TrustlyPaymentMethod, - new PaymentMethods\TwintPaymentMethod, - ] as $method) { + new PaymentMethods\AfterpayDefaultPaymentMethod, + new PaymentMethods\AlipayPaymentMethod, + new PaymentMethods\AlipayHkPaymentMethod, + new PaymentMethods\ClearpayPaymentMethod, + new PaymentMethods\EpsPaymentMethod, + new PaymentMethods\Facilypay3xPaymentMethod, + new PaymentMethods\Facilypay4xPaymentMethod, + new PaymentMethods\Facilypay6xPaymentMethod, + new PaymentMethods\Facilypay10xPaymentMethod, + new PaymentMethods\Facilypay12xPaymentMethod, + new PaymentMethods\PaysafecardPaymentMethod, + new PaymentMethods\RatepayPaymentMethod, + new PaymentMethods\RatepayDirectdebitPaymentMethod, + new PaymentMethods\SwishPaymentMethod, + new PaymentMethods\TrustlyPaymentMethod, + new PaymentMethods\TwintPaymentMethod, + ] as $method) { $this->addPaymentMethod( $method, $updateContext->getContext() @@ -427,15 +432,15 @@ private function updateTo370(UpdateContext $updateContext): void * MB Way, Multibanco, WeChat Pay, MobilePay, Vipps, Affirm & PayBright */ foreach ([ - new PaymentMethods\MbwayPaymentMethod(), - new PaymentMethods\MultibancoPaymentMethod(), - new PaymentMethods\WechatpayqrPaymentMethod(), - new PaymentMethods\WechatpaywebPaymentMethod(), - new PaymentMethods\MobilePayPaymentMethod(), - new PaymentMethods\VippsPaymentMethod(), - new PaymentMethods\AffirmPaymentMethod(), - new PaymentMethods\PayBrightPaymentMethod() - ] as $method) { + new PaymentMethods\MbwayPaymentMethod(), + new PaymentMethods\MultibancoPaymentMethod(), + new PaymentMethods\WechatpayqrPaymentMethod(), + new PaymentMethods\WechatpaywebPaymentMethod(), + new PaymentMethods\MobilePayPaymentMethod(), + new PaymentMethods\VippsPaymentMethod(), + new PaymentMethods\AffirmPaymentMethod(), + new PaymentMethods\PayBrightPaymentMethod() + ] as $method) { $this->addPaymentMethod( $method, $updateContext->getContext() @@ -455,8 +460,8 @@ private function updateTo3100(UpdateContext $updateContext): void * Open Banking / Pay by Bank */ foreach ([ - new PaymentMethods\OpenBankingPaymentMethod(), - ] as $method) { + new PaymentMethods\OpenBankingPaymentMethod(), + ] as $method) { $this->addPaymentMethod( $method, $updateContext->getContext() @@ -522,6 +527,23 @@ private function updateTo3160(UpdateContext $updateContext): void ); } + private function updateTo3170(UpdateContext $updateContext): void + { + // Version 3.17.0 introduces Online Banking Finland + $method = new PaymentMethods\OnlineBankingFinlandPaymentMethod(); + + $this->addPaymentMethod( + $method, + $updateContext->getContext() + ); + + $this->setPaymentMethodIsActive( + true, + $updateContext->getContext(), + $method + ); + } + private function safeCopyAsset($source, $destination): bool { try { @@ -539,9 +561,10 @@ private function safeCopyAsset($source, $destination): bool */ private function deactivateAndRemovePaymentMethod( UpdateContext $updateContext, - string $paymentMethodHandler, - string $description = null - ): void { + string $paymentMethodHandler, + string $description = null + ): void + { /** @var EntityRepository $paymentRepository */ $paymentRepository = $this->container->get('payment_method.repository'); /** @var EntityRepository $salesChannelPaymentRepository */ diff --git a/src/Handlers/OnlineBankingFinlandPaymentMethodHandler.php b/src/Handlers/OnlineBankingFinlandPaymentMethodHandler.php new file mode 100644 index 00000000..63b2e200 --- /dev/null +++ b/src/Handlers/OnlineBankingFinlandPaymentMethodHandler.php @@ -0,0 +1,11 @@ +{var a=n(6285),i=n(3206),o=n(8254),r=n(4690);class d extends a.Z{init(){let e=this;this._client=new o.Z,this.adyenCheckout=Promise,this.paymentMethodInstance=null,this.selectedGiftcard=null,this.initializeCheckoutComponent().then(function(){this.observeGiftcardSelection()}.bind(this)),this.adyenGiftcardDropDown=i.Z.querySelectorAll(document,"#giftcardDropdown"),this.adyenGiftcard=i.Z.querySelectorAll(document,".adyen-giftcard"),this.giftcardHeader=i.Z.querySelector(document,".adyen-giftcard-header"),this.giftcardItem=i.Z.querySelector(document,".adyen-giftcard-item"),this.giftcardComponentClose=i.Z.querySelector(document,".adyen-close-giftcard-component"),this.minorUnitsQuotient=adyenGiftcardsConfiguration.totalInMinorUnits/adyenGiftcardsConfiguration.totalPrice,this.giftcardDiscount=adyenGiftcardsConfiguration.giftcardDiscount,this.remainingAmount=(adyenGiftcardsConfiguration.totalPrice-this.giftcardDiscount).toFixed(2),this.remainingGiftcardBalance=(adyenGiftcardsConfiguration.giftcardBalance/this.minorUnitsQuotient).toFixed(2),this.shoppingCartSummaryBlock=i.Z.querySelectorAll(document,".checkout-aside-summary-list"),this.offCanvasSummaryDetails=null,this.shoppingCartSummaryDetails=null,this.giftcardComponentClose.onclick=function(t){t.currentTarget.style.display="none",e.selectedGiftcard=null,e.giftcardItem.innerHTML="",e.giftcardHeader.innerHTML=" ",e.paymentMethodInstance&&e.paymentMethodInstance.unmount()},document.getElementById("showGiftcardButton").addEventListener("click",(function(){this.style.display="none",document.getElementById("giftcardDropdown").style.display="block"})),window.addEventListener("DOMContentLoaded",(()=>{document.getElementById("giftcardsContainer").addEventListener("click",(e=>{if(e.target.classList.contains("adyen-remove-giftcard")){const t=e.target.getAttribute("dataid");this.removeGiftcard(t)}}))})),window.addEventListener("DOMContentLoaded",(e=>{parseInt(adyenGiftcardsConfiguration.giftcardDiscount,10)&&this.fetchRedeemedGiftcards()}))}async initializeCheckoutComponent(){const{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,a={locale:e,clientKey:t,environment:n,amount:{currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}};this.adyenCheckout=await AdyenCheckout(a)}observeGiftcardSelection(){let e=this,t=document.getElementById("giftcardDropdown"),n=document.querySelector(".btn-outline-info");t.addEventListener("change",(function(){t.value&&(e.selectedGiftcard=JSON.parse(event.currentTarget.options[event.currentTarget.selectedIndex].dataset.giftcard),e.mountGiftcardComponent(e.selectedGiftcard),t.value="",n.style.display="none")}))}mountGiftcardComponent(e){this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardItem.innerHTML="",r.Z.create(i.Z.querySelector(document,"#adyen-giftcard-component"));var t=document.createElement("img");t.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",t.classList.add("adyen-giftcard-logo"),this.giftcardItem.insertBefore(t,this.giftcardItem.firstChild),this.giftcardHeader.innerHTML=e.name,this.giftcardComponentClose.style.display="block";const n=Object.assign({},e,{showPayButton:!0,onBalanceCheck:this.handleBalanceCheck.bind(this,e)});try{this.paymentMethodInstance=this.adyenCheckout.create("giftcard",n),this.paymentMethodInstance.mount("#adyen-giftcard-component")}catch(e){console.log("giftcard not available")}r.Z.remove(i.Z.querySelector(document,"#adyen-giftcard-component"))}handleBalanceCheck(e,t,n,a){let i={};i.paymentMethod=JSON.stringify(a.paymentMethod),i.amount=JSON.stringify({currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}),this._client.post(`${adyenGiftcardsConfiguration.checkBalanceUrl}`,JSON.stringify(i),function(t){if((t=JSON.parse(t)).hasOwnProperty("pspReference")){const n=t.transactionLimit?parseFloat(t.transactionLimit.value):parseFloat(t.balance.value);a.giftcard={currency:adyenGiftcardsConfiguration.currency,value:(n/this.minorUnitsQuotient).toFixed(2),title:e.name},this.saveGiftcardStateData(a)}else n(t.resultCode)}.bind(this))}fetchRedeemedGiftcards(){this._client.get(adyenGiftcardsConfiguration.fetchRedeemedGiftcardsUrl,function(e){e=JSON.parse(e);let t=document.getElementById("giftcardsContainer"),n=document.querySelector(".btn-outline-info");t.innerHTML="",e.redeemedGiftcards.giftcards.forEach((function(e){let n=parseFloat(e.deductedAmount);n=n.toFixed(2);let a=adyenGiftcardsConfiguration.translationAdyenGiftcardDeductedBalance+": "+adyenGiftcardsConfiguration.currencySymbol+n,i=document.createElement("div");var o=document.createElement("img");o.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",o.classList.add("adyen-giftcard-logo");let r=document.createElement("a");r.href="#",r.textContent=adyenGiftcardsConfiguration.translationAdyenGiftcardRemove,r.setAttribute("dataid",e.stateDataId),r.classList.add("adyen-remove-giftcard"),r.style.display="block",i.appendChild(o),i.innerHTML+=`${e.title}`,i.appendChild(r),i.innerHTML+=`

${a}


`,t.appendChild(i)})),this.remainingAmount=e.redeemedGiftcards.remainingAmount,this.giftcardDiscount=e.redeemedGiftcards.totalDiscount,this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardComponentClose.style.display="none",this.giftcardItem.innerHTML="",this.giftcardHeader.innerHTML=" ",this.appendGiftcardSummary(),this.remainingAmount>0?n.style.display="block":(this.adyenGiftcardDropDown.length>0&&(this.adyenGiftcardDropDown[0].style.display="none"),n.style.display="none");document.getElementById("giftcardsContainer")}.bind(this))}saveGiftcardStateData(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),r.Z.remove(document.body))}.bind(this))}removeGiftcard(e){r.Z.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),(e=>{"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),r.Z.remove(document.body))}))}appendGiftcardSummary(){if(this.shoppingCartSummaryBlock.length){let e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary");for(let t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+e+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}}var s=n(207);const c={updatablePaymentMethods:["scheme","ideal","sepadirectdebit","oneclick","dotpay","bcmc","bcmc_mobile","blik","klarna_b2b","eps","facilypay_3x","facilypay_4x","facilypay_6x","facilypay_10x","facilypay_12x","afterpay_default","ratepay","ratepay_directdebit","giftcard","paybright","affirm","multibanco","mbway","vipps","mobilepay","wechatpayQR","wechatpayWeb","paybybank"],componentsWithPayButton:{applepay:{extra:{},onClick(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)}},googlepay:{extra:{buttonSizeMode:"fill"},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:function(e,t,n){"CANCELED"!==e.statusCode&&("statusMessage"in e?console.log(e.statusMessage):console.log(e.statusCode))}},paypal:{extra:{},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()},onError:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},onCancel:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},responseHandler:function(e,t){try{(t=JSON.parse(t)).isFinal&&(location.href=e.returnUrl),this.handleAction(t.action)}catch(e){console.error(e)}}},amazonpay:{extra:{productType:"PayAndShip",checkoutMode:"ProcessOrder",returnUrl:location.href},prePayRedirect:!0,sessionKey:"amazonCheckoutSessionId",onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:(e,t)=>{console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaymentmethodhandler",klarna_account:"handler_adyen_klarnaaccountpaymentmethodhandler",klarna_paynow:"handler_adyen_klarnapaynowpaymentmethodhandler",ratepay:"handler_adyen_ratepaypaymentmethodhandler",ratepay_directdebit:"handler_adyen_ratepaydirectdebitpaymentmethodhandler",sepadirectdebit:"handler_adyen_sepapaymentmethodhandler",sofort:"handler_adyen_sofortpaymentmethodhandler",paypal:"handler_adyen_paypalpaymentmethodhandler",oneclick:"handler_adyen_oneclickpaymentmethodhandler",giropay:"handler_adyen_giropaypaymentmethodhandler",applepay:"handler_adyen_applepaypaymentmethodhandler",googlepay:"handler_adyen_googlepaypaymentmethodhandler",dotpay:"handler_adyen_dotpaypaymentmethodhandler",bcmc:"handler_adyen_bancontactcardpaymentmethodhandler",bcmc_mobile:"handler_adyen_bancontactmobilepaymentmethodhandler",amazonpay:"handler_adyen_amazonpaypaymentmethodhandler",twint:"handler_adyen_twintpaymentmethodhandler",eps:"handler_adyen_epspaymentmethodhandler",swish:"handler_adyen_swishpaymentmethodhandler",alipay:"handler_adyen_alipaypaymentmethodhandler",alipay_hk:"handler_adyen_alipayhkpaymentmethodhandler",blik:"handler_adyen_blikpaymentmethodhandler",clearpay:"handler_adyen_clearpaypaymentmethodhandler",facilypay_3x:"handler_adyen_facilypay3xpaymentmethodhandler",facilypay_4x:"handler_adyen_facilypay4xpaymentmethodhandler",facilypay_6x:"handler_adyen_facilypay6xpaymentmethodhandler",facilypay_10x:"handler_adyen_facilypay10xpaymentmethodhandler",facilypay_12x:"handler_adyen_facilypay12xpaymentmethodhandler",afterpay_default:"handler_adyen_afterpaydefaultpaymentmethodhandler",trustly:"handler_adyen_trustlypaymentmethodhandler",paysafecard:"handler_adyen_paysafecardpaymentmethodhandler",giftcard:"handler_adyen_giftcardpaymentmethodhandler",mbway:"handler_adyen_mbwaypaymentmethodhandler",multibanco:"handler_adyen_multibancopaymentmethodhandler",wechatpayQR:"handler_adyen_wechatpayqrpaymentmethodhandler",wechatpayWeb:"handler_adyen_wechatpaywebpaymentmethodhandler",mobilepay:"handler_adyen_mobilepaypaymentmethodhandler",vipps:"handler_adyen_vippspaymentmethodhandler",affirm:"handler_adyen_affirmpaymentmethodhandler",paybright:"handler_adyen_paybrightpaymentmethodhandler",paybybank:"handler_adyen_openbankingpaymentmethodhandler",klarna_b2b:"handler_adyen_billiepaymentmethodhandler"}};class l extends a.Z{init(){this._client=new o.Z,this.selectedAdyenPaymentMethod=this.getSelectedPaymentMethodKey(),this.confirmOrderForm=i.Z.querySelector(document,"#confirmOrderForm"),this.confirmFormSubmit=i.Z.querySelector(document,'#confirmOrderForm button[type="submit"]'),this.shoppingCartSummaryBlock=i.Z.querySelectorAll(document,".checkout-aside-summary-list"),this.minorUnitsQuotient=adyenCheckoutOptions.amount/adyenCheckoutOptions.totalPrice,this.giftcardDiscount=adyenCheckoutOptions.giftcardDiscount,this.remainingAmount=adyenCheckoutOptions.totalPrice-this.giftcardDiscount,this.responseHandler=this.handlePaymentAction,this.adyenCheckout=Promise,this.initializeCheckoutComponent().then(function(){adyenCheckoutOptions.selectedPaymentMethodPluginId===adyenCheckoutOptions.adyenPluginId&&(adyenCheckoutOptions&&adyenCheckoutOptions.paymentStatusUrl&&adyenCheckoutOptions.checkoutOrderUrl&&adyenCheckoutOptions.paymentHandleUrl?(this.selectedAdyenPaymentMethod in c.componentsWithPayButton&&this.initializeCustomPayButton(),c.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod)&&!this.stateData?this.renderPaymentComponent(this.selectedAdyenPaymentMethod):this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this))):console.error("Adyen payment configuration missing."))}.bind(this)),adyenCheckoutOptions.payInFullWithGiftcard>0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}async initializeCheckoutComponent(){const{locale:e,clientKey:t,environment:n,merchantAccount:a}=adyenCheckoutConfiguration,i=adyenCheckoutOptions.paymentMethodsResponse,o={locale:e,clientKey:t,environment:n,showPayButton:this.selectedAdyenPaymentMethod in c.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(i),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:a,shopperEmail:shopperDetails.shopperEmail}}}};this.adyenCheckout=await AdyenCheckout(o)}handleOnAdditionalDetails(e){this._client.post(`${adyenCheckoutOptions.paymentDetailsUrl}`,JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),function(e){200===this._client._request.status?this.responseHandler(e):location.href=this.errorUrl.toString()}.bind(this))}onConfirmOrderSubmit(e){const t=i.Z.querySelector(document,"#confirmOrderForm");if(!t.checkValidity())return;e.preventDefault(),r.Z.create(document.body);const n=s.Z.serialize(t);this.confirmOrder(n)}renderPaymentComponent(e){if("oneclick"===e)return void this.renderStoredPaymentMethodComponents();if("giftcard"===e)return;let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e}));if(0===t.length)return void("test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e));let n=t[0];this.mountPaymentComponent(n,!1)}renderStoredPaymentMethodComponents(){this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach((e=>{let t=`[data-adyen-stored-payment-method-id="${e.id}"]`;this.mountPaymentComponent(e,!0,t)})),this.hideStorePaymentMethodComponents();let e=null;i.Z.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach((t=>{e||(e=t.value),t.addEventListener("change",this.showSelectedStoredPaymentMethod.bind(this))})),this.showSelectedStoredPaymentMethod(null,e)}showSelectedStoredPaymentMethod(e,t=null){this.hideStorePaymentMethodComponents();let n=`[data-adyen-stored-payment-method-id="${t=e?e.target.value:t}"]`;i.Z.querySelector(document,n).style.display="block"}hideStorePaymentMethodComponents(){i.Z.querySelectorAll(document,".stored-payment-component").forEach((e=>{e.style.display="none"}))}confirmOrder(e,t={}){const n=adyenCheckoutOptions.orderId;e.set("affiliateCode",adyenCheckoutOptions.affiliateCode),e.set("campaignCode",adyenCheckoutOptions.campaignCode),n?this.updatePayment(e,n,t):this.createOrder(e,t)}updatePayment(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}createOrder(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}afterCreateOrder(e={},t){let n;try{n=JSON.parse(t)}catch(e){return r.Z.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}if(n.url)return void(location.href=n.url);this.orderId=n.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",n.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",n.id);let a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(const t in e)a[t]=e[t];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}afterSetPayment(e={},t){try{JSON.parse(t).success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){return r.Z.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}}afterPayOrder(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){return r.Z.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post(`${adyenCheckoutOptions.paymentStatusUrl}`,JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}handlePaymentAction(e){try{const t=JSON.parse(e);if((t.isFinal||"voucher"===t.action.type)&&(location.href=this.returnUrl),t.action){const e={};"threeDS2"===t.action.type&&(e.challengeWindowSize="05"),this.adyenCheckout.createFromAction(t.action,e).mount("[data-adyen-payment-action-container]");if(["threeDS2","qrCode"].includes(t.action.type))if(window.jQuery)$("[data-adyen-payment-action-modal]").modal({show:!0});else new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show()}}catch(e){console.log(e)}}initializeCustomPayButton(){const e=c.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,e);let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((e=>e.type===this.selectedAdyenPaymentMethod));if(t.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((e=>"paywithgoogle"===e.type))),t.length<1)return;let n=t[0];if(!adyenCheckoutOptions.amount)return void console.error("Failed to fetch Cart/Order total amount.");if(e.prePayRedirect)return void this.renderPrePaymentButton(e,n);const a=Object.assign(e.extra,n,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;r.Z.create(document.body)},onSubmit:function(t,n){if(t.isValid){let a={stateData:JSON.stringify(t.data)},i=s.Z.serialize(this.confirmOrderForm);"responseHandler"in e&&(this.responseHandler=e.responseHandler.bind(n,this)),this.confirmOrder(i,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",t)}.bind(this),onCancel:(t,n)=>{r.Z.remove(document.body),e.onCancel(t,n,this)},onError:(t,n)=>{"PayPal"===n.props.name&&"CANCEL"===t.name&&this._client.post(`${adyenCheckoutOptions.cancelOrderTransactionUrl}`,JSON.stringify({orderId:this.orderId})),r.Z.remove(document.body),e.onError(t,n,this),console.log(t)}}),i=this.adyenCheckout.create(n.type,a);try{"isAvailable"in i?i.isAvailable().then(function(){this.mountCustomPayButton(i)}.bind(this)).catch((e=>{console.log(n.type+" is not available",e)})):this.mountCustomPayButton(i)}catch(e){console.log(e)}}renderPrePaymentButton(e,t){"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));const n=Object.assign(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;r.Z.create(document.body)},onError:(t,n)=>{r.Z.remove(document.body),e.onError(t,n,this),console.log(t)}});let a=this.adyenCheckout.create(t.type,n);this.mountCustomPayButton(a)}completePendingPayment(e,t){const n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){r.Z.create(document.body);const a=this.adyenCheckout.create(e,{[t.sessionKey]:n.searchParams.get(t.sessionKey),showOrderButton:!1,onSubmit:function(e,t){if(e.isValid){let t={stateData:JSON.stringify(e.data)},n=s.Z.serialize(this.confirmOrderForm);this.confirmOrder(n,t)}}.bind(this)});this.mountCustomPayButton(a),a.submit()}}getSelectedPaymentMethodKey(){return Object.keys(c.paymentMethodTypeHandlers).find((e=>c.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler))}mountCustomPayButton(e){let t=document.querySelector("#confirmOrderForm");if(t){let n=t.querySelector("button[type=submit]");if(n&&!n.disabled){let a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}mountPaymentComponent(e,t=!1,n=null){const a=Object.assign({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:function(n,a){if(n.isValid){t&&void 0!==e.holderName&&(n.data.paymentMethod.holderName=e.holderName);let a={stateData:JSON.stringify(n.data)},i=s.Z.serialize(this.confirmOrderForm);r.Z.create(document.body),this.confirmOrder(i,a)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}.bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);let o=t?n:"#"+this.el.id;try{const t=this.adyenCheckout.create(e.type,a);t.mount(o),this.confirmFormSubmit.addEventListener("click",function(e){i.Z.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),t.submit())}.bind(this))}catch(t){return console.error(e.type,t),!1}}appendGiftcardSummary(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){let e=parseFloat(this.giftcardDiscount).toFixed(2),t=parseFloat(this.remainingAmount).toFixed(2),n='
'+adyenCheckoutOptions.translationAdyenGiftcardDiscount+'
'+adyenCheckoutOptions.currencySymbol+e+'
'+adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount+'
'+adyenCheckoutOptions.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}setAddressDetails(e){return""!==activeShippingAddress.phoneNumber?e.addressDetails={name:shopperDetails.firstName+" "+shopperDetails.lastName,addressLine1:activeShippingAddress.street,city:activeShippingAddress.city,postalCode:activeShippingAddress.postalCode,countryCode:activeShippingAddress.country,phoneNumber:activeShippingAddress.phoneNumber}:e.productType="PayOnly",e}}class h extends a.Z{init(){this._client=new o.Z,this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){const{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{currency:a,values:i,backgroundUrl:o,logoUrl:r,name:d,description:s,url:c}=adyenGivingConfiguration,l={locale:e,clientKey:t,environment:n},h={amounts:{currency:a,values:i.split(",").map((e=>Number(e)))},backgroundUrl:o,logoUrl:r,description:s,name:d,url:c,showCancelButton:!0,onDonate:this.handleOnDonate.bind(this),onCancel:this.handleOnCancel.bind(this)};this.adyenCheckout=await AdyenCheckout(l),this.adyenCheckout.create("donation",h).mount("#donation-container")}handleOnDonate(e,t){const n=adyenGivingConfiguration.orderId;let a={stateData:JSON.stringify(e.data),orderId:n};a.returnUrl=window.location.href,this._client.post(`${adyenGivingConfiguration.donationEndpointUrl}`,JSON.stringify({...a}),function(e){200!==this._client._request.status?t.setStatus("error"):t.setStatus("success")}.bind(this))}handleOnCancel(){let e=adyenGivingConfiguration.continueActionUrl;window.location=e}}class y extends a.Z{init(){this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){const{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{action:a}=adyenSuccessActionConfiguration,i={locale:e,clientKey:t,environment:n};this.adyenCheckout=await AdyenCheckout(i),this.adyenCheckout.createFromAction(JSON.parse(a)).mount("#success-action-container")}}const m=window.PluginManager;m.register("CartPlugin",d,"#adyen-giftcards-container"),m.register("ConfirmOrderPlugin",l,"#adyen-payment-checkout-mask"),m.register("AdyenGivingPlugin",h,"#adyen-giving-container"),m.register("AdyenSuccessAction",y,"#adyen-success-action-container")}},e=>{e.O(0,["vendor-node","vendor-shared"],(()=>{return t=6253,e(e.s=t);var t}));e.O()}]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([["adyen-payment-shopware6"],{"4Gix":function(e,t,n){"use strict";t.a={updatablePaymentMethods:["scheme","ideal","sepadirectdebit","oneclick","dotpay","bcmc","bcmc_mobile","blik","klarna_b2b","eps","facilypay_3x","facilypay_4x","facilypay_6x","facilypay_10x","facilypay_12x","afterpay_default","ratepay","ratepay_directdebit","giftcard","paybright","affirm","multibanco","mbway","vipps","mobilepay","wechatpayQR","wechatpayWeb","paybybank"],componentsWithPayButton:{applepay:{extra:{},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)}},googlepay:{extra:{buttonSizeMode:"fill"},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:function(e,t,n){"CANCELED"!==e.statusCode&&("statusMessage"in e?console.log(e.statusMessage):console.log(e.statusCode))}},paypal:{extra:{},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()},onError:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},onCancel:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},responseHandler:function(e,t){try{(t=JSON.parse(t)).isFinal&&(location.href=e.returnUrl),this.handleAction(t.action)}catch(e){console.error(e)}}},amazonpay:{extra:{productType:"PayAndShip",checkoutMode:"ProcessOrder",returnUrl:location.href},prePayRedirect:!0,sessionKey:"amazonCheckoutSessionId",onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:function(e,t){console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaymentmethodhandler",klarna_account:"handler_adyen_klarnaaccountpaymentmethodhandler",klarna_paynow:"handler_adyen_klarnapaynowpaymentmethodhandler",ratepay:"handler_adyen_ratepaypaymentmethodhandler",ratepay_directdebit:"handler_adyen_ratepaydirectdebitpaymentmethodhandler",sepadirectdebit:"handler_adyen_sepapaymentmethodhandler",sofort:"handler_adyen_sofortpaymentmethodhandler",paypal:"handler_adyen_paypalpaymentmethodhandler",oneclick:"handler_adyen_oneclickpaymentmethodhandler",giropay:"handler_adyen_giropaypaymentmethodhandler",applepay:"handler_adyen_applepaypaymentmethodhandler",googlepay:"handler_adyen_googlepaypaymentmethodhandler",dotpay:"handler_adyen_dotpaypaymentmethodhandler",bcmc:"handler_adyen_bancontactcardpaymentmethodhandler",bcmc_mobile:"handler_adyen_bancontactmobilepaymentmethodhandler",amazonpay:"handler_adyen_amazonpaypaymentmethodhandler",twint:"handler_adyen_twintpaymentmethodhandler",eps:"handler_adyen_epspaymentmethodhandler",swish:"handler_adyen_swishpaymentmethodhandler",alipay:"handler_adyen_alipaypaymentmethodhandler",alipay_hk:"handler_adyen_alipayhkpaymentmethodhandler",blik:"handler_adyen_blikpaymentmethodhandler",clearpay:"handler_adyen_clearpaypaymentmethodhandler",facilypay_3x:"handler_adyen_facilypay3xpaymentmethodhandler",facilypay_4x:"handler_adyen_facilypay4xpaymentmethodhandler",facilypay_6x:"handler_adyen_facilypay6xpaymentmethodhandler",facilypay_10x:"handler_adyen_facilypay10xpaymentmethodhandler",facilypay_12x:"handler_adyen_facilypay12xpaymentmethodhandler",afterpay_default:"handler_adyen_afterpaydefaultpaymentmethodhandler",trustly:"handler_adyen_trustlypaymentmethodhandler",paysafecard:"handler_adyen_paysafecardpaymentmethodhandler",giftcard:"handler_adyen_giftcardpaymentmethodhandler",mbway:"handler_adyen_mbwaypaymentmethodhandler",multibanco:"handler_adyen_multibancopaymentmethodhandler",wechatpayQR:"handler_adyen_wechatpayqrpaymentmethodhandler",wechatpayWeb:"handler_adyen_wechatpaywebpaymentmethodhandler",mobilepay:"handler_adyen_mobilepaypaymentmethodhandler",vipps:"handler_adyen_vippspaymentmethodhandler",affirm:"handler_adyen_affirmpaymentmethodhandler",paybright:"handler_adyen_paybrightpaymentmethodhandler",paybybank:"handler_adyen_openbankingpaymentmethodhandler",klarna_b2b:"handler_adyen_billiepaymentmethodhandler"}}},HbFT:function(e,t,n){"use strict";n.r(t);var a=n("FGIj"),o=n("gHbT"),r=n("k8s9"),i=n("u0Tz");function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(){return(d=Object.assign||function(e){for(var t=1;t".concat(e.title,""),o.appendChild(i),o.innerHTML+='

'.concat(a,"


"),t.appendChild(o)})),this.remainingAmount=e.redeemedGiftcards.remainingAmount,this.giftcardDiscount=e.redeemedGiftcards.totalDiscount,this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardComponentClose.style.display="none",this.giftcardItem.innerHTML="",this.giftcardHeader.innerHTML=" ",this.appendGiftcardSummary(),this.remainingAmount>0?n.style.display="block":(this.adyenGiftcardDropDown.length>0&&(this.adyenGiftcardDropDown[0].style.display="none"),n.style.display="none"),document.getElementById("giftcardsContainer")}.bind(this))}},{key:"saveGiftcardStateData",value:function(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),i.a.remove(document.body))}.bind(this))}},{key:"removeGiftcard",value:function(e){var t=this;i.a.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),(function(e){"token"in(e=JSON.parse(e))&&(t.fetchRedeemedGiftcards(),i.a.remove(document.body))}))}},{key:"appendGiftcardSummary",value:function(){if(this.shoppingCartSummaryBlock.length)for(var e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary"),t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+n+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+a+"
";this.shoppingCartSummaryBlock[0].innerHTML+=o}}}])&&u(n.prototype,a),c&&u(n,c),t}(a.a),f=n("q5xn");function g(e){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k(e,t,n,a,o,r,i){try{var c=e[r](i),d=c.value}catch(e){return void n(e)}c.done?t(d):Promise.resolve(d).then(a,o)}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function O(e,t){for(var n=0;n0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}},{key:"initializeCheckoutComponent",value:(k=regeneratorRuntime.mark((function e(){var t,n,a,o,r,i,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=adyenCheckoutConfiguration,n=t.locale,a=t.clientKey,o=t.environment,r=t.merchantAccount,i=adyenCheckoutOptions.paymentMethodsResponse,c={locale:n,clientKey:a,environment:o,showPayButton:this.selectedAdyenPaymentMethod in s.a.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(i),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:r,shopperEmail:shopperDetails.shopperEmail}}}},e.next=5,AdyenCheckout(c);case 5:this.adyenCheckout=e.sent;case 6:case"end":return e.stop()}}),e,this)})),C=function(){var e=this,t=arguments;return new Promise((function(n,a){var o=k.apply(e,t);function r(e){h(o,n,a,r,i,"next",e)}function i(e){h(o,n,a,r,i,"throw",e)}r(void 0)}))},function(){return C.apply(this,arguments)})},{key:"handleOnAdditionalDetails",value:function(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),function(e){200===this._client._request.status?this.responseHandler(e):location.href=this.errorUrl.toString()}.bind(this))}},{key:"onConfirmOrderSubmit",value:function(e){var t=r.a.querySelector(document,"#confirmOrderForm");if(t.checkValidity()){e.preventDefault(),d.a.create(document.body);var n=c.a.serialize(t);this.confirmOrder(n)}}},{key:"renderPaymentComponent",value:function(e){if("oneclick"!==e){if("giftcard"!==e){var t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e}));if(0!==t.length){var n=t[0];this.mountPaymentComponent(n,!1)}else"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e)}}else this.renderStoredPaymentMethodComponents()}},{key:"renderStoredPaymentMethodComponents",value:function(){var e=this;this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach((function(t){var n='[data-adyen-stored-payment-method-id="'.concat(t.id,'"]');e.mountPaymentComponent(t,!0,n)})),this.hideStorePaymentMethodComponents();var t=null;r.a.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach((function(n){t||(t=n.value),n.addEventListener("change",e.showSelectedStoredPaymentMethod.bind(e))})),this.showSelectedStoredPaymentMethod(null,t)}},{key:"showSelectedStoredPaymentMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;var n='[data-adyen-stored-payment-method-id="'.concat(t,'"]'),a=r.a.querySelector(document,n);a.style.display="block"}},{key:"hideStorePaymentMethodComponents",value:function(){r.a.querySelectorAll(document,".stored-payment-component").forEach((function(e){e.style.display="none"}))}},{key:"confirmOrder",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=adyenCheckoutOptions.orderId;e.set("affiliateCode",adyenCheckoutOptions.affiliateCode),e.set("campaignCode",adyenCheckoutOptions.campaignCode),n?this.updatePayment(e,n,t):this.createOrder(e,t)}},{key:"updatePayment",value:function(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}},{key:"createOrder",value:function(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}},{key:"afterCreateOrder",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;try{e=JSON.parse(n)}catch(e){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",n)}if(e.url)location.href=e.url;else{this.orderId=e.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",e.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",e.id);var a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(var o in t)a[o]=t[o];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}}},{key:"afterSetPayment",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{var n=JSON.parse(t);n.success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}}},{key:"afterPayOrder",value:function(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post("".concat(adyenCheckoutOptions.paymentStatusUrl),JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}},{key:"handlePaymentAction",value:function(t){try{var n=JSON.parse(t);if((n.isFinal||"voucher"===n.action.type)&&(location.href=this.returnUrl),n.action){var o={};"threeDS2"===n.action.type&&(o.challengeWindowSize="05"),this.adyenCheckout.createFromAction(n.action,o).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(n.action.type)&&(e?a("[data-adyen-payment-action-modal]").modal({show:!0}):new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show())}}catch(e){console.log(e)}}},{key:"initializeCustomPayButton",value:function(){var e=this,t=s.a.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,t);var n=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e.selectedAdyenPaymentMethod}));if(n.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(n=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(e){return"paywithgoogle"===e.type}))),!(n.length<1)){var a=n[0];if(adyenCheckoutOptions.amount)if(t.prePayRedirect)this.renderPrePaymentButton(t,a);else{var o=y(t.extra,a,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:function(n,a){if(!t.onClick(n,a,e))return!1;d.a.create(document.body)},onSubmit:function(e,n){if(e.isValid){var a={stateData:JSON.stringify(e.data)},o=c.a.serialize(this.confirmOrderForm);"responseHandler"in t&&(this.responseHandler=t.responseHandler.bind(n,this)),this.confirmOrder(o,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",e)}.bind(this),onCancel:function(n,a){d.a.remove(document.body),t.onCancel(n,a,e)},onError:function(n,a){"PayPal"===a.props.name&&"CANCEL"===n.name&&e._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:e.orderId})),d.a.remove(document.body),t.onError(n,a,e),console.log(n)}}),r=this.adyenCheckout.create(a.type,o);try{"isAvailable"in r?r.isAvailable().then(function(){this.mountCustomPayButton(r)}.bind(this)).catch((function(e){console.log(a.type+" is not available",e)})):this.mountCustomPayButton(r)}catch(e){console.log(e)}}else console.error("Failed to fetch Cart/Order total amount.")}}},{key:"renderPrePaymentButton",value:function(e,t){var n=this;"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));var a=y(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:function(t,a){if(!e.onClick(t,a,n))return!1;d.a.create(document.body)},onError:function(t,a){d.a.remove(document.body),e.onError(t,a,n),console.log(t)}}),o=this.adyenCheckout.create(t.type,a);this.mountCustomPayButton(o)}},{key:"completePendingPayment",value:function(e,t){var n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){var a;d.a.create(document.body);var o=this.adyenCheckout.create(e,(u(a={},t.sessionKey,n.searchParams.get(t.sessionKey)),u(a,"showOrderButton",!1),u(a,"onSubmit",function(e,t){if(e.isValid){var n={stateData:JSON.stringify(e.data)},a=c.a.serialize(this.confirmOrderForm);this.confirmOrder(a,n)}}.bind(this)),a));this.mountCustomPayButton(o),o.submit()}}},{key:"getSelectedPaymentMethodKey",value:function(){return Object.keys(s.a.paymentMethodTypeHandlers).find((function(e){return s.a.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler}))}},{key:"mountCustomPayButton",value:function(e){var t=document.querySelector("#confirmOrderForm");if(t){var n=t.querySelector("button[type=submit]");if(n&&!n.disabled){var a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}},{key:"mountPaymentComponent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=y({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:function(n,a){if(n.isValid){t&&void 0!==e.holderName&&(n.data.paymentMethod.holderName=e.holderName);var o={stateData:JSON.stringify(n.data)},r=c.a.serialize(this.confirmOrderForm);d.a.create(document.body),this.confirmOrder(r,o)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}.bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);var o=t?n:"#"+this.el.id;try{var i=this.adyenCheckout.create(e.type,a);i.mount(o),this.confirmFormSubmit.addEventListener("click",function(e){r.a.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),i.submit())}.bind(this))}catch(t){return console.error(e.type,t),!1}}},{key:"appendGiftcardSummary",value:function(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){var e=parseFloat(this.giftcardDiscount).toFixed(2),t=parseFloat(this.remainingAmount).toFixed(2),n='
'+adyenCheckoutOptions.translationAdyenGiftcardDiscount+'
'+adyenCheckoutOptions.currencySymbol+e+'
'+adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount+'
'+adyenCheckoutOptions.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}},{key:"setAddressDetails",value:function(e){return""!==activeShippingAddress.phoneNumber?e.addressDetails={name:shopperDetails.firstName+" "+shopperDetails.lastName,addressLine1:activeShippingAddress.street,city:activeShippingAddress.city,postalCode:activeShippingAddress.postalCode,countryCode:activeShippingAddress.country,phoneNumber:activeShippingAddress.phoneNumber}:e.productType="PayOnly",e}}])&&p(o.prototype,l),b&&p(o,b),n}(o.a)}).call(this,n("UoTJ"),n("UoTJ"))}},[["HbFT","runtime","vendor-node","vendor-shared"]]]); \ No newline at end of file diff --git a/src/Resources/app/storefront/src/configuration/adyen.js b/src/Resources/app/storefront/src/configuration/adyen.js index 73db72c0..df214562 100644 --- a/src/Resources/app/storefront/src/configuration/adyen.js +++ b/src/Resources/app/storefront/src/configuration/adyen.js @@ -25,7 +25,7 @@ export default { 'scheme', 'ideal', 'sepadirectdebit', 'oneclick', 'dotpay', 'bcmc', 'bcmc_mobile', 'blik', 'klarna_b2b', 'eps', 'facilypay_3x', 'facilypay_4x', 'facilypay_6x', 'facilypay_10x', 'facilypay_12x', 'afterpay_default', 'ratepay', 'ratepay_directdebit', 'giftcard', 'paybright', 'affirm', 'multibanco', 'mbway', 'vipps', 'mobilepay', - 'wechatpayQR', 'wechatpayWeb', 'paybybank' + 'wechatpayQR', 'wechatpayWeb', 'paybybank', 'ebanking_FI' ], componentsWithPayButton: { 'applepay': { @@ -156,6 +156,7 @@ export default { 'affirm': 'handler_adyen_affirmpaymentmethodhandler', 'paybright': 'handler_adyen_paybrightpaymentmethodhandler', 'paybybank': 'handler_adyen_openbankingpaymentmethodhandler', - 'klarna_b2b': 'handler_adyen_billiepaymentmethodhandler' + 'klarna_b2b': 'handler_adyen_billiepaymentmethodhandler', + 'ebanking_FI': 'handler_adyen_onlinebankingfinlandpaymentmethodhandler' } } diff --git a/src/Resources/config/services/payment-handlers.xml b/src/Resources/config/services/payment-handlers.xml index 7fa8ee33..a138182f 100644 --- a/src/Resources/config/services/payment-handlers.xml +++ b/src/Resources/config/services/payment-handlers.xml @@ -255,6 +255,10 @@ parent="Adyen\Shopware\Handlers\AbstractPaymentMethodHandler"> + + +