Example #1
0
 /**
  * Update transaction ids for further processing
  * If no transactions were set before invoking, may generate an "offline" transaction id
  *
  * @param OrderPaymentInterface $payment
  * @param string $type
  * @param bool|Transaction $transactionBasedOn
  * @return string|null
  */
 public function generateTransactionId(OrderPaymentInterface $payment, $type, $transactionBasedOn = false)
 {
     if (!$payment->getParentTransactionId() && !$payment->getTransactionId() && $transactionBasedOn) {
         $payment->setParentTransactionId($transactionBasedOn->getTxnId());
     }
     // generate transaction id for an offline action or payment method that didn't set it
     if (($parentTxnId = $payment->getParentTransactionId()) && !$payment->getTransactionId()) {
         return "{$parentTxnId}-{$type}";
     }
     return $payment->getTransactionId();
 }
Example #2
0
 /**
  * Links transaction with parent transaction
  *
  * @param TransactionInterface $transaction
  * @return TransactionInterface
  */
 protected function linkWithParentTransaction(TransactionInterface $transaction)
 {
     $parentTransactionId = $this->payment->getParentTransactionId();
     if ($parentTransactionId) {
         $transaction->setParentTxnId($parentTransactionId);
         if ($this->payment->getShouldCloseParentTransaction()) {
             $parentTransaction = $this->transactionRepository->getByTransactionId($parentTransactionId, $this->payment->getid(), $this->order->getId());
             if ($parentTransaction) {
                 if (!$parentTransaction->getIsClosed()) {
                     $parentTransaction->isFailsafe($this->failSafe)->close(false);
                 }
                 $this->order->addRelatedObject($parentTransaction);
             }
         }
     }
     return $transaction;
 }