/** * @param $type * @param $message * @param Order $order * @param \WirecardCEE_Stdlib_Return_ReturnAbstract $return * * @return \Magento\Sales\Api\Data\TransactionInterface|null */ public function saveTransaction($type, $message, $order, $return) { $additionalInformation = array(); foreach ($return->getReturned() as $fieldName => $fieldValue) { $additionalInformation[htmlentities($fieldName)] = htmlentities($fieldValue); } $payment = $order->getPayment(); $tid = ''; if ($return instanceof \WirecardCEE_Stdlib_Return_Success) { $tid = $return->getGatewayReferenceNumber(); } /* generate dummy GwRef for pending payments */ if (!strlen($tid)) { $tid = uniqid('tmp_'); } $transaction = $this->_transactionBuilder->setPayment($payment)->setOrder($order)->setTransactionId($tid)->build($type); $transaction->setIsClosed(0); /* must be set as RAW_DETAILS, otherwise they are not displayed in the admin area */ $transaction->setAdditionalInformation(Transaction::RAW_DETAILS, $additionalInformation); $payment->addTransactionCommentsToOrder($transaction, $message); return $transaction; }