當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractModel::setTransactionId方法代碼示例

本文整理匯總了PHP中Magento\Sales\Model\AbstractModel::setTransactionId方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractModel::setTransactionId方法的具體用法?PHP AbstractModel::setTransactionId怎麽用?PHP AbstractModel::setTransactionId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Sales\Model\AbstractModel的用法示例。


在下文中一共展示了AbstractModel::setTransactionId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: build

 /**
  * {@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;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:30,代碼來源:Builder.php

示例2: _addTransaction

 /**
  * Create transaction,
  * prepare its insertion into hierarchy and add its information to payment and comments
  *
  * To add transactions and related information,
  * the following information should be set to payment before processing:
  * - transaction_id
  * - is_transaction_closed (optional) - whether transaction should be closed or open (closed by default)
  * - parent_transaction_id (optional)
  * - should_close_parent_transaction (optional) - whether to close parent transaction (closed by default)
  *
  * If the sales document is specified, it will be linked to the transaction as related for future usage.
  * Currently transaction ID is set into the sales object
  * This method writes the added transaction ID into last_trans_id field of the payment object
  *
  * To make sure transaction object won't cause trouble before saving, use $failsafe = true
  *
  * @param string $type
  * @param \Magento\Sales\Model\AbstractModel $salesDocument
  * @param bool $failsafe
  * @return null|Transaction
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _addTransaction($type, $salesDocument = null, $failsafe = false)
 {
     if ($this->getSkipTransactionCreation()) {
         $this->unsTransactionId();
         return null;
     }
     // look for set transaction ids
     $transactionId = $this->getTransactionId();
     if (null !== $transactionId) {
         // set transaction parameters
         $transaction = false;
         if ($this->getOrder()->getId()) {
             $transaction = $this->_lookupTransaction($transactionId);
         }
         if (!$transaction) {
             $transaction = $this->_transactionFactory->create()->setTxnId($transactionId);
         }
         $transaction->setOrderPaymentObject($this)->setTxnType($type)->isFailsafe($failsafe);
         if ($this->hasIsTransactionClosed()) {
             $transaction->setIsClosed((int) $this->getIsTransactionClosed());
         }
         //set transaction addition information
         if ($this->_transactionAdditionalInfo) {
             foreach ($this->_transactionAdditionalInfo as $key => $value) {
                 $transaction->setAdditionalInformation($key, $value);
             }
             $this->_transactionAdditionalInfo = [];
         }
         // link with sales entities
         $this->setLastTransId($transactionId);
         $this->setCreatedTransaction($transaction);
         $this->getOrder()->addRelatedObject($transaction);
         if ($salesDocument && $salesDocument instanceof \Magento\Sales\Model\AbstractModel) {
             $salesDocument->setTransactionId($transactionId);
         }
         // link with parent transaction
         $parentTransactionId = $this->getParentTransactionId();
         if ($parentTransactionId) {
             $transaction->setParentTxnId($parentTransactionId);
             if ($this->getShouldCloseParentTransaction()) {
                 $parentTransaction = $this->_lookupTransaction($parentTransactionId);
                 if ($parentTransaction) {
                     if (!$parentTransaction->getIsClosed()) {
                         $parentTransaction->isFailsafe($failsafe)->close(false);
                     }
                     $this->getOrder()->addRelatedObject($parentTransaction);
                 }
             }
         }
         return $transaction;
     }
     return null;
 }
開發者ID:niranjanssiet,項目名稱:magento2,代碼行數:77,代碼來源:Payment.php


注:本文中的Magento\Sales\Model\AbstractModel::setTransactionId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。