Skip to content

Commit

Permalink
Merge pull request #26 from michielgerritsen/release-week-33
Browse files Browse the repository at this point in the history
Release week 33
  • Loading branch information
Marvin-Magmodules authored Sep 2, 2024
2 parents 6a258c1 + bbd7485 commit f0e3a4e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 40 deletions.
29 changes: 10 additions & 19 deletions src/Mollie_HyvaCheckout/Service/PlaceOrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Hyva\Checkout\Model\Magewire\Component\EvaluationResultInterface;
use Hyva\Checkout\Model\Magewire\Payment\AbstractPlaceOrderService;
use Magento\Checkout\Model\Session;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Message\Manager;
use Magento\Framework\UrlInterface;
use Magento\Payment\Helper\Data;
Expand All @@ -18,6 +19,7 @@
use Magento\Sales\Api\OrderRepositoryInterface;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Payment\Model\Methods\CreditcardVault;
use Mollie\Payment\Service\Mollie\FormatExceptionMessages;
use Mollie\Payment\Service\Mollie\Order\RedirectUrl;

class PlaceOrderService extends AbstractPlaceOrderService
Expand All @@ -31,6 +33,7 @@ class PlaceOrderService extends AbstractPlaceOrderService

private Session $checkoutSession;
private RedirectUrl $redirectUrl;
private FormatExceptionMessages $formatExceptionMessages;

public function __construct(
CartManagementInterface $cartManagement,
Expand All @@ -39,7 +42,8 @@ public function __construct(
Manager $messageManager,
UrlInterface $url,
Session $checkoutSession,
RedirectUrl $redirectUrl
RedirectUrl $redirectUrl,
FormatExceptionMessages $formatExceptionMessages
) {
parent::__construct($cartManagement);
$this->orderRepository = $orderRepository;
Expand All @@ -48,13 +52,14 @@ public function __construct(
$this->url = $url;
$this->checkoutSession = $checkoutSession;
$this->redirectUrl = $redirectUrl;
$this->formatExceptionMessages = $formatExceptionMessages;
}

public function evaluateCompletion(EvaluationResultFactory $resultFactory, ?int $orderId = null): EvaluationResultInterface
{
return $resultFactory->createSuccess();
}

public function canPlaceOrder(): bool
{
return true;
Expand All @@ -78,26 +83,12 @@ public function getRedirectUrl(Quote $quote, ?int $orderId = null): string
try {
return $this->redirectUrl->execute($method, $order);
} catch (ApiException $exception) {
$this->messageManager->addErrorMessage($this->formatExceptionMessage($exception));
$this->messageManager->addErrorMessage($this->formatExceptionMessages->execute($exception));
$this->checkoutSession->restoreQuote();

return $this->url->getUrl('checkout/cart');
} catch (LocalizedException $exception) {
throw new LocalizedException(__($this->formatExceptionMessages->execute($exception)));
}
}

public function formatExceptionMessage(\Exception $exception): string
{
if (stripos(
$exception->getMessage(),
'The webhook URL is invalid because it is unreachable from Mollie\'s point of view'
) !== false) {
return __(
'The webhook URL is invalid because it is unreachable from Mollie\'s point of view. ' .
'View this article for more information: ' .
'https://github.com/mollie/magento2/wiki/Webhook-Communication-between-your-Magento-webshop-and-Mollie'
);
}

return __('Something went wrong while placing the order. Error: "%1"', $exception->getMessage());
}
}
8 changes: 0 additions & 8 deletions src/Mollie_HyvaCheckout/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@
</arguments>
</type>

<virtualType name="Mollie\HyvaCheckout\Magewire\Checkout\Payment\Method\Ideal"
type="Mollie\HyvaCheckout\Magewire\Checkout\Payment\Method\WithIssuer"
>
<arguments>
<argument name="method" xsi:type="string">ideal</argument>
</arguments>
</virtualType>

<virtualType name="Mollie\HyvaCheckout\Magewire\Checkout\Payment\Method\Kbc"
type="Mollie\HyvaCheckout\Magewire\Checkout\Payment\Method\WithIssuer"
>
Expand Down
1 change: 1 addition & 0 deletions src/Mollie_HyvaCheckout/etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<item name="mollie_methods_mybank" xsi:type="object">Mollie\HyvaCheckout\Service\PlaceOrderService</item>
<item name="mollie_methods_paypal" xsi:type="object">Mollie\HyvaCheckout\Service\PlaceOrderService</item>
<item name="mollie_methods_paysafecard" xsi:type="object">Mollie\HyvaCheckout\Service\PlaceOrderService</item>
<item name="mollie_methods_payconic" xsi:type="object">Mollie\HyvaCheckout\Service\PlaceOrderService</item>
<item name="mollie_methods_przelewy24" xsi:type="object">Mollie\HyvaCheckout\Service\PlaceOrderService</item>
<item name="mollie_methods_riverty" xsi:type="object">Mollie\HyvaCheckout\Service\PlaceOrderService</item>
<item name="mollie_methods_sofort" xsi:type="object">Mollie\HyvaCheckout\Service\PlaceOrderService</item>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
<?xml version="1.0"?>
<!--
~ Copyright Magmodules.eu. All rights reserved.
~ See COPYING.txt for license details.
-->

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"
>
<body>
<referenceBlock name="checkout.payment.methods">
<block name="checkout.payment.method.mollie_methods_ideal"
as="mollie_methods_ideal"
class="Mollie\HyvaCheckout\Block\Checkout\Payment\Issuer"
>
<arguments>
<argument name="mollie_method" xsi:type="string">mollie_methods_ideal</argument>
<argument name="magewire" xsi:type="object">
Mollie\HyvaCheckout\Magewire\Checkout\Payment\Method\Ideal
</argument>
</arguments>
</block>

<block name="checkout.payment.method.mollie_methods_creditcard"
as="mollie_methods_creditcard"
template="Mollie_HyvaCheckout::component/payment/method/creditcard.phtml">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* See COPYING.txt for license details.
*/
?>
<div><!-- iDeal issuer list is disabled, but we still need a div for Magewire --></div>
<div><!-- Issuer list is disabled, but we still need a div for Magewire --></div>

0 comments on commit f0e3a4e

Please sign in to comment.