Context:
- How is
\Magento\Sales\Model\Order\Payment\Transaction\Builder::transactionAdditionalInfo
declared and used? - How is
\Magento\Sales\Model\Order\Payment::setTransactionId()
implemented and used? - How is
\Magento\Sales\Model\Order\Invoice::setTransactionId()
implemented and used? - How is
\Magento\Sales\Model\Order\Creditmemo::setTransactionId()
implemented and used?
Implementation
ffea3cd/app/code/Magento/Sales/Model/Order/Payment/Transaction/Builder.php#L174-L215
/**
* {@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;
}
Usages
1. \Magento\Sales\Model\Order\Payment::addTransaction()
Details: How is \Magento\Sales\Model\Order\Payment::addTransaction()
implemented and used?
2. \Magento\Sales\Model\Order\Payment\Operations\CaptureOperation::capture()
Details: How does \Magento\Sales\Model\Order\Payment\Operations\CaptureOperation::capture()
work?
3. \Magento\Paypal\Model\Express::order()
https://github.com/magento/magento2/blob/ffea3cd/app/code/Magento/Paypal/Model/Express.php#L399-L403