From c9ba4a973efe779c3c37f5efe6f74fdea3b8f54b Mon Sep 17 00:00:00 2001 From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:49:02 +0100 Subject: [PATCH 1/4] Fix Instore for PaymentMethodId 1927 --- Model/Paymentmethod/Instore.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Model/Paymentmethod/Instore.php b/Model/Paymentmethod/Instore.php index 3b1aaad8..94925108 100644 --- a/Model/Paymentmethod/Instore.php +++ b/Model/Paymentmethod/Instore.php @@ -76,16 +76,20 @@ public function startTransaction(Order $order, $fromAdmin = false) $transaction = (new PayPaymentCreate($order, $this))->create(); - $instorePayment = \Paynl\Instore::payment(['transactionId' => $transaction->getTransactionId(), 'terminalId' => $terminalId]); - + if ($this->getPaymentOptionId() == '1927') { + $additionalData['terminal_hash'] = $transaction->getData()['terminal']['hash']; + $url = $transaction->getRedirectUrl(); + } else { + $instorePayment = \Paynl\Instore::payment(['transactionId' => $transaction->getTransactionId(), 'terminalId' => $terminalId]); + $additionalData['terminal_hash'] = $instorePayment->getHash(); + $url = $instorePayment->getRedirectUrl(); + } + $additionalData['transactionId'] = $transaction->getTransactionId(); - $additionalData['terminal_hash'] = $instorePayment->getHash(); $additionalData['payment_option'] = $terminalId; $order->getPayment()->setAdditionalInformation($additionalData); $order->save(); - - $url = $instorePayment->getRedirectUrl(); } catch (\Exception $e) { $this->payHelper->logCritical($e->getMessage(), [], $store); From 761b85dea30460a7c1194a65c9452606bdf3f25d Mon Sep 17 00:00:00 2001 From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:57:57 +0100 Subject: [PATCH 2/4] Code polish --- Model/Paymentmethod/Instore.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Paymentmethod/Instore.php b/Model/Paymentmethod/Instore.php index 94925108..999efac0 100644 --- a/Model/Paymentmethod/Instore.php +++ b/Model/Paymentmethod/Instore.php @@ -84,7 +84,7 @@ public function startTransaction(Order $order, $fromAdmin = false) $additionalData['terminal_hash'] = $instorePayment->getHash(); $url = $instorePayment->getRedirectUrl(); } - + $additionalData['transactionId'] = $transaction->getTransactionId(); $additionalData['payment_option'] = $terminalId; From 21d7e2eecd8ac787fea40e734f9133c987cea249 Mon Sep 17 00:00:00 2001 From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:52:53 +0100 Subject: [PATCH 3/4] Improve code --- Controller/Checkout/Finish.php | 2 ++ Model/Paymentmethod/Instore.php | 2 +- Model/Paymentmethod/PaymentMethod.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Controller/Checkout/Finish.php b/Controller/Checkout/Finish.php index 082b6e68..e8f651b3 100644 --- a/Controller/Checkout/Finish.php +++ b/Controller/Checkout/Finish.php @@ -166,6 +166,8 @@ public function execute() $pinStatus = $this->handlePin($information['terminal_hash'], $order); if (!empty($pinStatus)) { $bSuccess = true; + } else { + $bPending = false; } } diff --git a/Model/Paymentmethod/Instore.php b/Model/Paymentmethod/Instore.php index 999efac0..eb3c8222 100644 --- a/Model/Paymentmethod/Instore.php +++ b/Model/Paymentmethod/Instore.php @@ -76,7 +76,7 @@ public function startTransaction(Order $order, $fromAdmin = false) $transaction = (new PayPaymentCreate($order, $this))->create(); - if ($this->getPaymentOptionId() == '1927') { + if ($this->getPaymentOptionId() === 1927) { $additionalData['terminal_hash'] = $transaction->getData()['terminal']['hash']; $url = $transaction->getRedirectUrl(); } else { diff --git a/Model/Paymentmethod/PaymentMethod.php b/Model/Paymentmethod/PaymentMethod.php index f58fa0fa..6bc7d3bb 100644 --- a/Model/Paymentmethod/PaymentMethod.php +++ b/Model/Paymentmethod/PaymentMethod.php @@ -540,7 +540,7 @@ public function startTransaction(Order $order) */ public function getPaymentOptionId() { - $paymentOptionId = $this->getConfigData('payment_option_id'); + $paymentOptionId = (int)$this->getConfigData('payment_option_id'); if (empty($paymentOptionId)) { $paymentOptionId = $this->getDefaultPaymentOptionId(); From 8990113f98d9d56d0f7a9e35aaa04b76c6bc4b55 Mon Sep 17 00:00:00 2001 From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com> Date: Fri, 22 Mar 2024 15:45:09 +0100 Subject: [PATCH 4/4] Code Polish --- Controller/Checkout/Finish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/Checkout/Finish.php b/Controller/Checkout/Finish.php index e8f651b3..f890dcb9 100644 --- a/Controller/Checkout/Finish.php +++ b/Controller/Checkout/Finish.php @@ -166,7 +166,7 @@ public function execute() $pinStatus = $this->handlePin($information['terminal_hash'], $order); if (!empty($pinStatus)) { $bSuccess = true; - } else { + } else { $bPending = false; } }