diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index 1e1a1004..9d997e07 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -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; @@ -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); diff --git a/src/Gateway/MolliePaymentGateway.php b/src/Gateway/MolliePaymentGateway.php index 7550047d..7047080a 100644 --- a/src/Gateway/MolliePaymentGateway.php +++ b/src/Gateway/MolliePaymentGateway.php @@ -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; } @@ -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' @@ -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' diff --git a/src/Notice/FrontendNotice.php b/src/Notice/FrontendNotice.php new file mode 100644 index 00000000..02c59bef --- /dev/null +++ b/src/Notice/FrontendNotice.php @@ -0,0 +1,13 @@ + static function (): AdminNotice { return new AdminNotice(); }, + FrontendNotice::class => static function (): FrontendNotice { + return new FrontendNotice(); + }, ]; } }