/** * Set payment parent transaction id and current transaction id if it not set * @param Transaction $transaction * @return void */ private function setTransactionIdsForRefund(Transaction $transaction) { if (!$this->getTransactionId()) { $this->setTransactionId($this->transactionManager->generateTransactionId($this, Transaction::TYPE_REFUND, $transaction)); } $this->setParentTransactionId($transaction->getTxnId()); }
/** * Void payment either online or offline (process void notification) * NOTE: that in some cases authorization can be voided after a capture. In such case it makes sense to use * the amount void amount, for informational purposes. * Updates payment totals, updates order status and adds proper comments * * @param bool $isOnline * @param float $amount * @param string $gatewayCallback * @return $this * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function _void($isOnline, $amount = null, $gatewayCallback = 'void') { $order = $this->getOrder(); $authTransaction = $this->getAuthorizationTransaction(); $this->setTransactionId($this->transactionManager->generateTransactionId($this, Transaction::TYPE_VOID, $authTransaction)); $this->setShouldCloseParentTransaction(true); // attempt to void if ($isOnline) { $method = $this->getMethodInstance(); $method->setStore($order->getStoreId()); $method->{$gatewayCallback}($this); } if ($this->checkIfTransactionExists()) { return $this; } // if the authorization was untouched, we may assume voided amount = order grand total // but only if the payment auth amount equals to order grand total if ($authTransaction && $order->getBaseGrandTotal() == $this->getBaseAmountAuthorized() && 0 == $this->getBaseAmountCanceled()) { if ($authTransaction->canVoidAuthorizationCompletely()) { $amount = (double) $order->getBaseGrandTotal(); } } if ($amount) { $amount = $this->formatAmount($amount); } // update transactions, order state and add comments $transaction = $this->addTransaction(Transaction::TYPE_VOID, null, true); $message = $this->hasMessage() ? $this->getMessage() : __('Voided authorization.'); $message = $this->prependMessage($message); if ($amount) { $message .= ' ' . __('Amount: %1.', $this->formatPrice($amount)); } $message = $this->_appendTransactionToMessage($transaction, $message); $this->setOrderStateProcessing($message); $order->setDataChanges(true); return $this; }