diff --git a/src/Helper/PaymentStatusHelper.php b/src/Helper/PaymentStatusHelper.php index d8b8c78f0..15728bebf 100644 --- a/src/Helper/PaymentStatusHelper.php +++ b/src/Helper/PaymentStatusHelper.php @@ -3,10 +3,8 @@ namespace Kiener\MolliePayments\Helper; use Exception; -use Kiener\MolliePayments\Handler\Method\ApplePayPayment; use Kiener\MolliePayments\Service\LoggerService; use Kiener\MolliePayments\Service\Order\OrderStateService; -use Kiener\MolliePayments\Service\PaymentMethodService; use Kiener\MolliePayments\Service\SettingsService; use Kiener\MolliePayments\Setting\MollieSettingStruct; use Mollie\Api\Resources\Order; @@ -49,9 +47,6 @@ class PaymentStatusHelper /** @var EntityRepositoryInterface */ protected $orderTransactionRepository; - /** @var PaymentMethodService */ - protected $paymentMethodService; - /** * PaymentStatusHelper constructor. * @@ -67,8 +62,7 @@ public function __construct( SettingsService $settingsService, StateMachineRegistry $stateMachineRegistry, EntityRepositoryInterface $paymentMethodRepository, - EntityRepositoryInterface $orderTransactionRepository, - PaymentMethodService $paymentMethodService + EntityRepositoryInterface $orderTransactionRepository ) { $this->logger = $logger; @@ -79,7 +73,6 @@ public function __construct( $this->paymentMethodRepository = $paymentMethodRepository; $this->orderTransactionRepository = $orderTransactionRepository; - $this->paymentMethodService = $paymentMethodService; } /** @@ -163,8 +156,7 @@ public function processPaymentStatus( $useMollieFailureHandling = !$settings->isShopwareFailedPaymentMethod(); - if ($useMollieFailureHandling - && $this->paymentMethodService->isPaidApplePayTransaction($transaction, $mollieOrder) === false) { + if ($useMollieFailureHandling) { $currentCustomerSelectedPaymentMethod = $mollieOrder->method; if (is_null($currentCustomerSelectedPaymentMethod)) { diff --git a/src/MolliePayments.php b/src/MolliePayments.php index ecf881d9c..87a9d7ad3 100644 --- a/src/MolliePayments.php +++ b/src/MolliePayments.php @@ -3,7 +3,6 @@ namespace Kiener\MolliePayments; use Exception; -use Kiener\MolliePayments\Service\ApplePayDomainVerificationService; use Kiener\MolliePayments\Service\CustomFieldService; use Kiener\MolliePayments\Service\PaymentMethodService; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface; @@ -61,18 +60,12 @@ public function install(InstallContext $context) : void public function update(UpdateContext $context): void { parent::update($context); - - if($context->getPlugin()->isActive() === true) { - // add domain verification - /** @var ApplePayDomainVerificationService $domainVerificationService */ - $domainVerificationService = $this->container->get(ApplePayDomainVerificationService::class); - $domainVerificationService->downloadDomainAssociationFile(); - } } public function postInstall(InstallContext $context): void { parent::postInstall($context); + } public function uninstall(UninstallContext $context) : void @@ -91,15 +84,10 @@ public function activate(ActivateContext $context) : void $paymentMethodHelper ->setClassName(get_class($this)) ->addPaymentMethods($context->getContext()); - - // add domain verification - /** @var ApplePayDomainVerificationService $domainVerificationService */ - $domainVerificationService = $this->container->get(ApplePayDomainVerificationService::class); - $domainVerificationService->downloadDomainAssociationFile(); } public function deactivate(DeactivateContext $context) : void { parent::deactivate($context); } -} +} \ No newline at end of file diff --git a/src/Resources/app/storefront/dist/storefront/js/mollie-payments.js b/src/Resources/app/storefront/dist/storefront/js/mollie-payments.js index aa700eb68..57043579f 100644 --- a/src/Resources/app/storefront/dist/storefront/js/mollie-payments.js +++ b/src/Resources/app/storefront/dist/storefront/js/mollie-payments.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([["mollie-payments"],{eYm7:function(e,t,n){"use strict";n.r(t);n("wcNg");var o=n("FGIj");function r(e){return(r="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 i(e,t,n,o,r,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(o,r)}function a(e,t){for(var n=0;n1&&(e._data.csrfTokenAuthorize=o[0].value,e._data.csrfTokenShippingMethods=o[1].value);var r=e._data.form.querySelector('input[name="id"]').value,i=e._data.form.querySelector('input[name="name"]').value,a=e._data.form.querySelector('input[name="price"]').value,c=e._data.form.querySelector('input[name="countryCode"]').value,u=e._data.form.querySelector('input[name="currency"]').value,l=e.getProductPrice(r);e._data.cartAmount=a,e._data.currency=u,e.createPaymentRequest("product",c,u,i),l.then((function(t){e._data.selectedProduct=t.data,e._data.cartAmount=e._data.selectedProduct.price}))}))}))}},{key:"createPaymentRequest",value:function(e,t,n,o){var r=this,i={countryCode:t,currencyCode:n,supportedNetworks:["amex","maestro","masterCard","visa","vPay"],merchantCapabilities:["supports3DS"],requiredShippingContactFields:["name","postalAddress","phone","email"],total:{label:o,amount:this._data.cartAmount}},a=new ApplePaySession(3,i);a.onvalidatemerchant=function(e){r.performValidation(e.validationURL).then((function(e){try{a.completeMerchantValidation(e)}catch(e){r.displayNotification(e.message,a)}})).catch((function(e){r.displayNotification(e,a)}))},a.onshippingcontactselected=function(e){r._data.shippingContact=e.shippingContact,void 0!==r._data.shippingContact.countryCode&&(t=r._data.shippingContact.countryCode);var n=ApplePaySession.STATUS_SUCCESS;r.getShippingMethods(t).then((function(e){if(void 0!==e.error&&null!==e.error)r.displayNotification(e.error,a);else{e.length&&(r._data.shippingMethodId=e[0].identifier,r._data.shippingAmount=e[0].amount);var t={type:"final",label:"Total amount",amount:r.totalAmount()},o=[{type:"final",label:"Subtotal",amount:r._data.cartAmount},{type:"final",label:"Shipping costs",amount:r._data.shippingAmount}];r.getShippingAmount().then((function(e){r._data.cartToken=e.cartToken,r._data.shippingMethodId=e.shippingMethod.id,r._data.shippingAmount=e.totalPrice})).catch((function(e){r.displayNotification(e,a)}));try{a.completeShippingContactSelection(n,e,t,o)}catch(e){r.displayNotification(e.message,a)}}})).catch((function(e){r.displayNotification(e,a)}))},a.onshippingmethodselected=function(e){r._data.shippingMethodId=e.shippingMethod.identifier,r.getShippingAmount().then((function(e){r._data.cartToken=e.cartToken,r._data.shippingAmount=e.totalPrice;var t=ApplePaySession.STATUS_SUCCESS,n={type:"final",label:"Total amount",amount:r.totalAmount()},o=[{type:"final",label:"Subtotal",amount:r._data.cartAmount},{type:"final",label:"Shipping costs",amount:r._data.shippingAmount}];try{a.completeShippingMethodSelection(t,n,o)}catch(e){r.displayNotification(e.message,a)}})).catch((function(e){r.displayNotification(e,a)}))},a.onpaymentmethodselected=function(){var e={type:"final",label:"Total amount",amount:r.totalAmount()},t=[{type:"final",label:"Subtotal",amount:r._data.cartAmount},{type:"final",label:"Shipping costs",amount:r._data.shippingAmount}];try{a.completePaymentMethodSelection(e,t)}catch(e){r.displayNotification(e.message,a)}},a.onpaymentauthorized=function(e){r.sendPaymentToken(e.payment).then((function(e){var t,n;if(void 0!==e.errors&&null!==e.errors&&e.errors.length>0){t=ApplePaySession.STATUS_FAILURE;var o="";e.errors.forEach((function(e){o+=e+"
"})),r.displayNotification(o,a)}else void 0!==e.redirectUrl&&null!==e.redirectUrl&&""!==e.redirectUrl&&(t=ApplePaySession.STATUS_SUCCESS,n=e.redirectUrl);try{a.completePayment(t)}catch(e){r.displayNotification(e.message,a)}n&&(document.location=n)})).catch((function(e){r.displayNotification(e,a)}))},a.oncancel=function(){},a.begin()}},{key:"performValidation",value:function(e){return new Promise((function(t,n){fetch("/mollie/apple-pay/validate?validationUrl="+e).then((function(e){return e.json()})).then((function(e){return t(e)})).catch((function(e){n()}))}))}},{key:"sendPaymentToken",value:function(e){var t=this,n={paymentToken:JSON.stringify(e.token),shippingContact:JSON.stringify(e.shippingContact),currency:t._data.currency,customer:t._data.shippingContact,productId:t._data.selectedProduct.id,shippingMethodId:t._data.shippingMethodId,cartAmount:t._data.cartAmount,cartToken:t._data.cartToken,shippingAmount:t._data.shippingAmount,totalAmount:t.totalAmount(),_csrf_token:t._data.csrfTokenAuthorize};return new Promise((function(e){t._client.post("/mollie/apple-pay/authorize",JSON.stringify(n),(function(t){return e(JSON.parse(t))}))}))}},{key:"getProductPrice",value:function(e){return new Promise((function(t,n){fetch("/mollie/apple-pay/product/"+e+"/price").then((function(e){return e.json()})).then((function(e){return t(e)})).catch((function(e){n()}))}))}},{key:"getShippingAmount",value:function(){var e=this;return new Promise((function(t,n){fetch("/mollie/apple-pay/shipping-costs/"+e._data.shippingMethodId+"/"+e._data.selectedProduct.id).then((function(e){return e.json()})).then((function(e){return t(e)})).catch((function(e){n()}))}))}},{key:"getShippingMethods",value:function(e){var t=this,n={countryCode:e,_csrf_token:t._data.csrfTokenShippingMethods};return new Promise((function(e){t._client.post("/mollie/apple-pay/shipping-methods",JSON.stringify(n),(function(t){return e(JSON.parse(t))}))}))}},{key:"displayNotification",value:function(e,t,n){var o=document.querySelector("div.flashbags.container");if(null==n&&(n="danger"),void 0!==o){var r='");o.innerHTML=r,window.scrollTo(0,0)}}},{key:"clearNotification",value:function(){var e=document.querySelector("div.flashbags.container");void 0!==e&&(e.innerHTML="")}}])&&j(n.prototype,o),r&&j(n,r),t}(o.a);function N(e){return(N="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 U(e,t){for(var n=0;n=0&&t.item(n)!==this;);return n>-1});e&&e!==document;e=e.parentNode)if(e.matches(t))return e;return null}},{key:"init",value:function(){var e=document.querySelector(".payment-method-input.applepay"),t=this.getClosest(e,".payment-method");t&&t.classList&&(window.ApplePaySession&&window.ApplePaySession.canMakePayments()||t.classList.add("d-none"))}}])&&U(n.prototype,o),r&&U(n,r),t}(o.a),B=window.PluginManager;B.register("MollieIDealIssuer",O),B.register("MollieApplePayDirect",M),B.register("MollieApplePayPaymentMethod",H),B.register("MollieCreditCardComponents",f,"#mollie_components_credit_card"),B.register("MollieCreditCardComponentsSw64",_,"#mollie_components_credit_card_sw64")}},[["eYm7","runtime","vendor-node","vendor-shared"]]]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([["mollie-payments"],{tHPJ:function(e,t,n){"use strict";n.r(t);n("wcNg");var o=n("FGIj");function r(e){return(r="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 i(e,t,n,o,r,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(o,r)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n1&&(e._data.csrfTokenAuthorize=o[0].value,e._data.csrfTokenShippingMethods=o[1].value);var r=e._data.form.querySelector('input[name="id"]').value,i=e._data.form.querySelector('input[name="name"]').value,a=e._data.form.querySelector('input[name="price"]').value,c=e._data.form.querySelector('input[name="countryCode"]').value,u=e._data.form.querySelector('input[name="currency"]').value,l=e.getProductPrice(r);e._data.cartAmount=a,e._data.currency=u,e.createPaymentRequest("product",c,u,i),l.then((function(t){e._data.selectedProduct=t.data,e._data.cartAmount=e._data.selectedProduct.price}))}))}))}},{key:"createPaymentRequest",value:function(e,t,n,o){var r=this,i={countryCode:t,currencyCode:n,supportedNetworks:["amex","maestro","masterCard","visa","vPay"],merchantCapabilities:["supports3DS"],requiredShippingContactFields:["name","postalAddress","phone","email"],total:{label:o,amount:this._data.cartAmount}},a=new ApplePaySession(3,i);a.onvalidatemerchant=function(e){r.performValidation(e.validationURL).then((function(e){try{a.completeMerchantValidation(e)}catch(e){r.displayNotification(e.message,a)}})).catch((function(e){r.displayNotification(e,a)}))},a.onshippingcontactselected=function(e){r._data.shippingContact=e.shippingContact,void 0!==r._data.shippingContact.countryCode&&(t=r._data.shippingContact.countryCode);var n=ApplePaySession.STATUS_SUCCESS;r.getShippingMethods(t).then((function(e){if(void 0!==e.error&&null!==e.error)r.displayNotification(e.error,a);else{e.length&&(r._data.shippingMethodId=e[0].identifier,r._data.shippingAmount=e[0].amount);var t={type:"final",label:"Total amount",amount:r.totalAmount()},o=[{type:"final",label:"Subtotal",amount:r._data.cartAmount},{type:"final",label:"Shipping costs",amount:r._data.shippingAmount}];r.getShippingAmount().then((function(e){r._data.cartToken=e.cartToken,r._data.shippingMethodId=e.shippingMethod.id,r._data.shippingAmount=e.totalPrice})).catch((function(e){r.displayNotification(e,a)}));try{a.completeShippingContactSelection(n,e,t,o)}catch(e){r.displayNotification(e.message,a)}}})).catch((function(e){r.displayNotification(e,a)}))},a.onshippingmethodselected=function(e){r._data.shippingMethodId=e.shippingMethod.identifier,r.getShippingAmount().then((function(e){r._data.cartToken=e.cartToken,r._data.shippingAmount=e.totalPrice;var t=ApplePaySession.STATUS_SUCCESS,n={type:"final",label:"Total amount",amount:r.totalAmount()},o=[{type:"final",label:"Subtotal",amount:r._data.cartAmount},{type:"final",label:"Shipping costs",amount:r._data.shippingAmount}];try{a.completeShippingMethodSelection(t,n,o)}catch(e){r.displayNotification(e.message,a)}})).catch((function(e){r.displayNotification(e,a)}))},a.onpaymentmethodselected=function(){var e={type:"final",label:"Total amount",amount:r.totalAmount()},t=[{type:"final",label:"Subtotal",amount:r._data.cartAmount},{type:"final",label:"Shipping costs",amount:r._data.shippingAmount}];try{a.completePaymentMethodSelection(e,t)}catch(e){r.displayNotification(e.message,a)}},a.onpaymentauthorized=function(e){r.sendPaymentToken(e.payment).then((function(e){var t,n;if(void 0!==e.errors&&null!==e.errors&&e.errors.length>0){t=ApplePaySession.STATUS_FAILURE;var o="";e.errors.forEach((function(e){o+=e+"
"})),r.displayNotification(o,a)}else void 0!==e.redirectUrl&&null!==e.redirectUrl&&""!==e.redirectUrl&&(t=ApplePaySession.STATUS_SUCCESS,n=e.redirectUrl);try{a.completePayment(t)}catch(e){r.displayNotification(e.message,a)}n&&(document.location=n)})).catch((function(e){r.displayNotification(e,a)}))},a.oncancel=function(){},a.begin()}},{key:"performValidation",value:function(e){return new Promise((function(t,n){fetch("/mollie/apple-pay/validate?validationUrl="+e).then((function(e){return e.json()})).then((function(e){return t(e)})).catch((function(e){n()}))}))}},{key:"sendPaymentToken",value:function(e){var t=this,n={paymentToken:JSON.stringify(e.token),shippingContact:JSON.stringify(e.shippingContact),currency:t._data.currency,customer:t._data.shippingContact,productId:t._data.selectedProduct.id,shippingMethodId:t._data.shippingMethodId,cartAmount:t._data.cartAmount,cartToken:t._data.cartToken,shippingAmount:t._data.shippingAmount,totalAmount:t.totalAmount(),_csrf_token:t._data.csrfTokenAuthorize};return new Promise((function(e){t._client.post("/mollie/apple-pay/authorize",JSON.stringify(n),(function(t){return e(JSON.parse(t))}))}))}},{key:"getProductPrice",value:function(e){return new Promise((function(t,n){fetch("/mollie/apple-pay/product/"+e+"/price").then((function(e){return e.json()})).then((function(e){return t(e)})).catch((function(e){n()}))}))}},{key:"getShippingAmount",value:function(){var e=this;return new Promise((function(t,n){fetch("/mollie/apple-pay/shipping-costs/"+e._data.shippingMethodId+"/"+e._data.selectedProduct.id).then((function(e){return e.json()})).then((function(e){return t(e)})).catch((function(e){n()}))}))}},{key:"getShippingMethods",value:function(e){var t=this,n={countryCode:e,_csrf_token:t._data.csrfTokenShippingMethods};return new Promise((function(e){t._client.post("/mollie/apple-pay/shipping-methods",JSON.stringify(n),(function(t){return e(JSON.parse(t))}))}))}},{key:"displayNotification",value:function(e,t,n){var o=document.querySelector("div.flashbags.container");if(null==n&&(n="danger"),void 0!==o){var r='");o.innerHTML=r,window.scrollTo(0,0)}}},{key:"clearNotification",value:function(){var e=document.querySelector("div.flashbags.container");void 0!==e&&(e.innerHTML="")}}])&&M(n.prototype,o),r&&M(n,r),t}(o.a);function B(e){return(B="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 z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function J(e,t){for(var n=0;n=0&&t.item(n)!==this;);return n>-1});e&&e!==document;e=e.parentNode)if(e.matches(t))return e;return null}},{key:"init",value:function(){var e=document.querySelector(".payment-method-input.applepay"),t=this.getClosest(e,".payment-method");t&&t.classList&&(window.ApplePaySession&&window.ApplePaySession.canMakePayments()||t.classList.add("d-none"))}}])&&J(n.prototype,o),r&&J(n,r),t}(o.a),W=window.PluginManager;W.register("MollieIDealIssuer",j),W.register("MollieApplePayDirect",R),W.register("MollieApplePayPaymentMethod",Q),W.register("MollieCreditCardComponents",m,"#mollie_components_credit_card"),W.register("MollieCreditCardComponentsSw64",w,"#mollie_components_credit_card_sw64")}},[["tHPJ","runtime","vendor-node","vendor-shared"]]]); \ No newline at end of file diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index f55a96ecd..9128c25b3 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -50,7 +50,6 @@ - @@ -73,10 +72,6 @@ - - - - @@ -127,7 +122,6 @@ %kernel.shopware_version% - @@ -206,6 +200,8 @@ + + diff --git a/src/Service/ApplePayDomainVerificationService.php b/src/Service/ApplePayDomainVerificationService.php deleted file mode 100644 index cee585996..000000000 --- a/src/Service/ApplePayDomainVerificationService.php +++ /dev/null @@ -1,25 +0,0 @@ -filesystem = $filesystem; - } - - public function downloadDomainAssociationFile() : void { - $content = file_get_contents(self::URL_FILE); - - $this->filesystem->put(self::LOCAL_FILE, $content); - } -} diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index d1e03f98a..3f642752c 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -23,8 +23,6 @@ use Mollie\Api\MollieApiClient; use Mollie\Api\Resources\Method; use Mollie\Api\Resources\MethodCollection; -use Mollie\Api\Resources\Order; -use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity; use Shopware\Core\Checkout\Payment\PaymentMethodEntity; use Shopware\Core\Content\Media\MediaCollection; use Shopware\Core\Content\Media\MediaService; @@ -335,6 +333,9 @@ public function getPaymentHandlers() */ private function getMediaId(array $paymentMethod, Context $context): string { + /** @var string $mediaId */ + $mediaId = ''; + /** @var string $fileName */ $fileName = $paymentMethod['name'] . '-icon'; @@ -345,38 +346,33 @@ private function getMediaId(array $paymentMethod, Context $context): string $icons = $this->mediaRepository->search($criteria, $context); if ($icons->count() && $icons->first() !== null) { - return $icons->first()->getId(); - } - - // Add icon to the media library - $iconMime = 'image/svg+xml'; - $iconExt = 'svg'; - $iconBlob = file_get_contents('https://www.mollie.com/external/icons/payment-methods/' . $paymentMethod['name'] . '.svg'); + $mediaId = $icons->first()->getId(); + } else { + // Add icon to the media library + + $iconBlob = file_get_contents('https://www.mollie.com/external/icons/payment-methods/' . $paymentMethod['name'] . '.svg'); + + if(!empty(trim($iconBlob))) { + $iconMime = 'image/svg+xml'; + $iconExt = 'svg'; + } else { + $iconBlob = file_get_contents('https://www.mollie.com/external/icons/payment-methods/' . $paymentMethod['name'] . '.png'); + $iconMime = 'image/png'; + $iconExt = 'png'; + } - if(empty(trim($iconBlob))) { - $iconBlob = file_get_contents('https://www.mollie.com/external/icons/payment-methods/' . $paymentMethod['name'] . '.png'); - $iconMime = 'image/png'; - $iconExt = 'png'; + $mediaId = $this->mediaService->saveFile( + $iconBlob, + $iconExt, + $iconMime, + $fileName, + $context, + 'Mollie Payments - Icons', + null, + false + ); } - return $this->mediaService->saveFile( - $iconBlob, - $iconExt, - $iconMime, - $fileName, - $context, - 'Mollie Payments - Icons', - null, - false - ); - } - - /** - * @param OrderTransactionEntity $transaction - * @param Order $mollieOrder - * @return bool - */ - public function isPaidApplePayTransaction(OrderTransactionEntity $transaction, Order $mollieOrder) : bool { - return $transaction->getPaymentMethod()->getHandlerIdentifier() === ApplePayPayment::class && $mollieOrder->isPaid() === true; + return $mediaId; } } diff --git a/src/Service/ShippingMethodService.php b/src/Service/ShippingMethodService.php index 5a97a70b6..6ea289c62 100644 --- a/src/Service/ShippingMethodService.php +++ b/src/Service/ShippingMethodService.php @@ -90,7 +90,6 @@ public function getShippingMethodsForApplePayDirect(SalesChannelContext $context $availableShippingMethods !== null && $availableShippingMethods->count() ) { - /** @var ShippingMethodEntity $shippingMethod */ foreach ($availableShippingMethods as $shippingMethod) { if ( $shippingMethod->getPrices()->count() @@ -117,8 +116,10 @@ public function getShippingMethodsForApplePayDirect(SalesChannelContext $context $detail = ''; - if ($shippingMethod->getDeliveryTime() !== null) { - $detail = $shippingMethod->getDeliveryTime()->getTranslation('name') ?: $shippingMethod->getDeliveryTime()->getName(); + if ( + $shippingMethod->getDeliveryTime() !== null + ) { + $detail = $shippingMethod->getDeliveryTime()->getName(); } $shippingMethods[] = [ diff --git a/src/Storefront/Controller/ApplePayDirectController.php b/src/Storefront/Controller/ApplePayDirectController.php index 07d2d1c84..0f25d7f53 100644 --- a/src/Storefront/Controller/ApplePayDirectController.php +++ b/src/Storefront/Controller/ApplePayDirectController.php @@ -35,7 +35,6 @@ use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; use Shopware\Core\Framework\Routing\Annotation\RouteScope; use Shopware\Core\Framework\Uuid\Uuid; -use Shopware\Core\System\SalesChannel\Context\SalesChannelContextFactory; use Shopware\Core\System\SalesChannel\Context\SalesChannelContextService; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Shopware\Storefront\Controller\StorefrontController; @@ -83,12 +82,6 @@ class ApplePayDirectController extends StorefrontController /** @var string */ private $shopwareVersion; - /** @var SalesChannelContextFactory */ - private $salesChannelContextFactory; - - /** - * @param SalesChannelContextFactory $salesChannelContextFactory - */ public function __construct( MollieApiClient $apiClient, CartService $cartService, @@ -102,8 +95,7 @@ public function __construct( SettingsService $settingsService, ShippingMethodService $shippingMethodService, ContainerInterface $container, - string $shopwareVersion, - $salesChannelContextfactory + string $shopwareVersion ) { $this->apiClient = $apiClient; @@ -119,7 +111,6 @@ public function __construct( $this->shippingMethodService = $shippingMethodService; $this->container = $container; $this->shopwareVersion = $shopwareVersion; - $this->salesChannelContextFactory = $salesChannelContextfactory; } /** @@ -471,8 +462,7 @@ public function shippingMethods(SalesChannelContext $context, Request $request): $this->customerService->getCountryId($countryCode, $context->getContext()), null, null, - null, - $context->getContext()->getLanguageId() + null ); } else { $newSalesChannelContext = $context; @@ -570,8 +560,7 @@ public function process(CustomerEntity $customer, string $cartToken, string $shi $customer->getDefaultShippingAddress() !== null ? $customer->getDefaultShippingAddress()->getCountryId() : null, $customer->getId(), $customer->getDefaultPaymentMethod() !== null ? $customer->getDefaultPaymentMethod()->getId() : null, - $shippingMethodId, - $context->getContext()->getLanguageId() + $shippingMethodId ); // Persist the order @@ -713,8 +702,7 @@ private function createSalesChannelContext( ?string $countryId, ?string $customerId, ?string $paymentMethodId = null, - ?string $shippingMethodId = null, - ?string $languageId = null + ?string $shippingMethodId = null ): SalesChannelContext { /** @var array $options */ @@ -740,12 +728,14 @@ private function createSalesChannelContext( $options[SalesChannelContextService::SHIPPING_METHOD_ID] = $shippingMethodId; } - // Add language to options - if ((string) $languageId !== '') { - $options[SalesChannelContextService::LANGUAGE_ID] = $languageId; + $salesChannelFactory = null; + if (version_compare($this->shopwareVersion,'6.4','>=')) { + $salesChannelFactory=$this->container->get('Shopware\Core\System\SalesChannel\Context\CachedSalesChannelContextFactory'); + } else { + $salesChannelFactory=$this->container->get('Shopware\Core\System\SalesChannel\Context\SalesChannelContextFactory'); } - $salesChannelContext = $this->salesChannelContextFactory->create( + $salesChannelContext = $salesChannelFactory->create( $newToken, $context->getSalesChannel()->getId(), $options diff --git a/src/Storefront/Controller/WebhookController.php b/src/Storefront/Controller/WebhookController.php index 4a45606ab..3b9e65221 100644 --- a/src/Storefront/Controller/WebhookController.php +++ b/src/Storefront/Controller/WebhookController.php @@ -104,7 +104,6 @@ public function webhookCall(SalesChannelContext $context, $transactionId): JsonR $criteria = new Criteria(); $criteria->addFilter(new EqualsFilter('id', $transactionId)); $criteria->addAssociation('order'); - $criteria->addAssociation('paymentMethod'); } catch (InconsistentCriteriaIdsException $e) { $errorMessage = $errorMessage ?? $e->getMessage(); } diff --git a/tests/Service/ApplePayDomainVerificationServiceTest.php b/tests/Service/ApplePayDomainVerificationServiceTest.php deleted file mode 100644 index 9bca2f8a3..000000000 --- a/tests/Service/ApplePayDomainVerificationServiceTest.php +++ /dev/null @@ -1,16 +0,0 @@ -