From 5b0cbbd4f4782b00efb3e1a724f2d7967bf2deac Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Thu, 11 Jul 2024 14:50:51 +0200 Subject: [PATCH] Abort payment attempt when the order is already paid --- Model/Client/Payments.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Model/Client/Payments.php b/Model/Client/Payments.php index 95eb35c76f9..1070a0d5a52 100644 --- a/Model/Client/Payments.php +++ b/Model/Client/Payments.php @@ -16,6 +16,7 @@ use Mollie\Api\MollieApiClient; use Mollie\Api\Resources\Payment as MolliePayment; use Mollie\Api\Types\PaymentStatus; +use Mollie\Payment\Exceptions\PaymentAborted; use Mollie\Payment\Helper\General as MollieHelper; use Mollie\Payment\Model\Client\Payments\ProcessTransaction; use Mollie\Payment\Service\Mollie\DashboardUrl; @@ -552,6 +553,10 @@ private function getCheckoutUrl(MollieApiClient $mollieApi, ?string $transaction } $payment = $mollieApi->payments->get($transactionId); + if ($payment->status == 'paid') { + throw new PaymentAborted(__('This order already has been paid.')); + } + return $payment->getCheckoutUrl(); } }