Skip to content

Commit

Permalink
explode requires a string, incase payment TransactionId is null the p…
Browse files Browse the repository at this point in the history
…ayment should fail based on payment criteria, not php standard.

Added new method to reduce code repitition
  • Loading branch information
WebKenth authored May 22, 2023
1 parent 7bd3824 commit e9acf74
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Model/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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];

Expand All @@ -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];

Expand All @@ -171,4 +171,9 @@ public function cancel(\Magento\Payment\Model\InfoInterface $payment)

return $this;
}

public function splitTransactionId($payment)
{
return explode('-',$payment->getTransactionId() ?? '');
}
}

0 comments on commit e9acf74

Please sign in to comment.