From fde49775642f7099d44c741887cab18fd25a9284 Mon Sep 17 00:00:00 2001 From: NETZKOLLEKTIV Date: Tue, 2 Jan 2024 09:31:25 +0000 Subject: [PATCH] check for financing decision outcome before creating the order --- .../Frontend/PaymentEasycredit.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Frontend/NetzkollektivEasyCredit/Controllers/Frontend/PaymentEasycredit.php b/src/Frontend/NetzkollektivEasyCredit/Controllers/Frontend/PaymentEasycredit.php index 7d48c62..3299ae9 100644 --- a/src/Frontend/NetzkollektivEasyCredit/Controllers/Frontend/PaymentEasycredit.php +++ b/src/Frontend/NetzkollektivEasyCredit/Controllers/Frontend/PaymentEasycredit.php @@ -77,16 +77,21 @@ public function getTransactionInfoBySecuredTransaction($transactionId, $secToken public function indexAction() { - $transactionId = $this->helper->getPluginSession()["transaction_id"]; - $paymentUniqueId = $this->createPaymentUniqueId(); + try { + $checkout = $this->container->get('easyCreditCheckout'); - $orderNumber = $this->saveOrder($transactionId, $paymentUniqueId, null, false); - $orderId = $this->getOrderId($transactionId, $paymentUniqueId); + if (!$checkout->isApproved()) { + throw new \Exception('The transaction is not approved.'); + } - $this->saveOrderAttributes($orderId); + $transactionId = $this->helper->getPluginSession()["transaction_id"]; + $paymentUniqueId = $this->createPaymentUniqueId(); + + $orderNumber = $this->saveOrder($transactionId, $paymentUniqueId, null, false); + $orderId = $this->getOrderId($transactionId, $paymentUniqueId); + + $this->saveOrderAttributes($orderId); - try { - $checkout = $this->container->get('easyCreditCheckout'); if (!$checkout->authorize($orderNumber)) { throw new \Exception('The transaction could not be authorized.'); }