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() ?? ''); + } }