Skip to content

Commit

Permalink
Merge branch 'fix/MOL-808' into release/7.4.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Notice/NoticeModule.php
  • Loading branch information
inpsyde-maticluznar committed Oct 24, 2023
2 parents 7637b47 + bd741a7 commit 1f47ca9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Mollie\WooCommerce\Buttons\PayPalButton\PayPalButtonHandler;
use Mollie\WooCommerce\Gateway\Voucher\MaybeDisableGateway;
use Mollie\WooCommerce\Notice\AdminNotice;
use Mollie\WooCommerce\Notice\FrontendNotice;
use Mollie\WooCommerce\Notice\NoticeInterface;
use Mollie\WooCommerce\Payment\MollieObject;
use Mollie\WooCommerce\Payment\MollieOrderService;
Expand Down Expand Up @@ -480,8 +481,8 @@ public function instantiatePaymentMethodGateways(ContainerInterface $container):
{
$logger = $container->get(Logger::class);
assert($logger instanceof Logger);
$notice = $container->get(AdminNotice::class);
assert($notice instanceof AdminNotice);
$notice = $container->get(FrontendNotice::class);
assert($notice instanceof FrontendNotice);
$paymentService = $container->get(PaymentService::class);
assert($paymentService instanceof PaymentService);
$mollieOrderService = $container->get(MollieOrderService::class);
Expand Down
7 changes: 3 additions & 4 deletions src/Gateway/MolliePaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,12 @@ public function getReturnRedirectUrlForOrder(WC_Order $order): string
return $this->get_return_url($order);
} else {
$this->notice->addNotice(
'notice',
'error',
__(
'You have cancelled your payment. Please complete your order with a different payment method.',
'mollie-payments-for-woocommerce'
)
);

// Return to order payment page
return $failedRedirect;
}
Expand All @@ -599,7 +598,7 @@ public function getReturnRedirectUrlForOrder(WC_Order $order): string
&& !$payment->isAuthorized()
) {
$this->notice->addNotice(
'notice',
'error',
__(
'Your payment was not successful. Please complete your order with a different payment method.',
'mollie-payments-for-woocommerce'
Expand All @@ -613,7 +612,7 @@ public function getReturnRedirectUrlForOrder(WC_Order $order): string
}
} catch (UnexpectedValueException $exc) {
$this->notice->addNotice(
'notice',
'error',
__(
'Your payment was not successful. Please complete your order with a different payment method.',
'mollie-payments-for-woocommerce'
Expand Down
13 changes: 13 additions & 0 deletions src/Notice/FrontendNotice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Mollie\WooCommerce\Notice;

class FrontendNotice implements NoticeInterface
{
public function addNotice($level, $message): void
{
wc_add_notice($message, $level);
}
}
10 changes: 5 additions & 5 deletions src/Notice/NoticeModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@

namespace Mollie\WooCommerce\Notice;

use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule;
use Mollie\WooCommerce\Notice\AdminNotice;
use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface;
use Mollie\WooCommerce\Notice\NoticeInterface as Notice;
use Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
use Inpsyde\Modularity\Module\ServiceModule;

class NoticeModule implements ServiceModule
{
Expand All @@ -22,6 +19,9 @@ public function services(): array
AdminNotice::class => static function (): AdminNotice {
return new AdminNotice();
},
FrontendNotice::class => static function (): FrontendNotice {
return new FrontendNotice();
},
];
}
}

0 comments on commit 1f47ca9

Please sign in to comment.