/** * @depends testCreate * * @param OrderModel $order */ public function testUpdateTransactionRef(OrderModel $order) { $transactionRef = uniqid('TRANSREF'); $this->orderEvent->setTransactionRef($transactionRef); $this->orderEvent->setOrder($order); $this->orderAction->updateTransactionRef($this->orderEvent); $this->assertEquals($transactionRef, $this->orderEvent->getOrder()->getTransactionRef()); $this->assertEquals($transactionRef, OrderQuery::create()->findPk($order->getId())->getTransactionRef()); }
/** * Save the transaction/payment ref in the order * * @param int $orderId the order ID * @param int $transactionRef the transaction reference * * @throws \Exception */ public function saveTransactionRef($orderId, $transactionRef) { try { $orderId = intval($orderId); if (null !== ($order = $this->getOrder($orderId))) { $event = new OrderEvent($order); $event->setTransactionRef($transactionRef); $this->dispatch(TheliaEvents::ORDER_UPDATE_TRANSACTION_REF, $event); $this->getLog()->addInfo($this->getTranslator()->trans("Payment transaction %transaction_ref for order ref. %ref, ID %id has been successfully saved.", ['%transaction_ref' => $transactionRef, '%ref' => $order->getRef(), '%id' => $order->getId()])); } } catch (\Exception $ex) { $this->getLog()->addError($this->getTranslator()->trans("Error occurred while saving payment transaction %transaction_ref for order ID %id.", ['%transaction_ref' => $transactionRef, '%id' => $orderId])); throw $ex; } }