Example #1
0
 /**
  * {@inheritdoc}
  */
 public function build($type)
 {
     if ($this->isPaymentExists() && $this->transactionId !== null) {
         $transaction = $this->transactionRepository->getByTransactionId($this->transactionId, $this->payment->getId(), $this->order->getId());
         if (!$transaction) {
             $transaction = $this->transactionRepository->create()->setTxnId($this->transactionId);
         }
         $transaction->setPaymentId($this->payment->getId())->setPayment($this->payment)->setOrderId($this->order->getId())->setOrder($this->order)->setTxnType($type)->isFailsafe($this->failSafe);
         if ($this->payment->hasIsTransactionClosed()) {
             $transaction->setIsClosed((int) $this->payment->getIsTransactionClosed());
         }
         if ($this->transactionAdditionalInfo) {
             foreach ($this->transactionAdditionalInfo as $key => $value) {
                 $transaction->setAdditionalInformation($key, $value);
             }
         }
         $this->transactionAdditionalInfo = [];
         $this->payment->setLastTransId($transaction->getTxnId());
         $this->payment->setCreatedTransaction($transaction);
         $this->order->addRelatedObject($transaction);
         if ($this->document && $this->document instanceof AbstractModel) {
             $this->document->setTransactionId($transaction->getTxnId());
         }
         return $this->linkWithParentTransaction($transaction);
     }
     return null;
 }