From e9acf7425863d3f5d500035dddb3f58e15c07c7e Mon Sep 17 00:00:00 2001 From: Martin Kenth Knudsen Date: Mon, 22 May 2023 07:05:53 +0200 Subject: [PATCH] explode requires a string, incase payment TransactionId is null the payment should fail based on payment criteria, not php standard. Added new method to reduce code repitition --- Model/Payment.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Model/Payment.php b/Model/Payment.php index 394e924..73ede8e 100644 --- a/Model/Payment.php +++ b/Model/Payment.php @@ -105,7 +105,7 @@ public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount) { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $adapter = $objectManager->get(\QuickPay\Gateway\Model\Adapter\QuickPayAdapter::class); - $parts = explode('-',$payment->getTransactionId()); + $parts = $this->splitTransactionId($payment); $order = $payment->getOrder(); $transaction = $parts[0]; @@ -132,7 +132,7 @@ public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount) { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $adapter = $objectManager->get(\QuickPay\Gateway\Model\Adapter\QuickPayAdapter::class); - $parts = explode('-',$payment->getTransactionId()); + $parts = $this->splitTransactionId($payment); $order = $payment->getOrder(); $transaction = $parts[0]; @@ -157,7 +157,7 @@ public function cancel(\Magento\Payment\Model\InfoInterface $payment) { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $adapter = $objectManager->get(\QuickPay\Gateway\Model\Adapter\QuickPayAdapter::class); - $parts = explode('-',$payment->getTransactionId()); + $parts = $this->splitTransactionId($payment); $order = $payment->getOrder(); $transaction = $parts[0]; @@ -171,4 +171,9 @@ public function cancel(\Magento\Payment\Model\InfoInterface $payment) return $this; } + + public function splitTransactionId($payment) + { + return explode('-',$payment->getTransactionId() ?? ''); + } }