145 \
Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
147 \
Magento\Sales\Model\OrderFactory $orderFactory,
150 \
Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory,
151 TransactionFactory $transactionFactory,
156 $this->_orderFactory = $orderFactory;
157 $this->_dateFactory = $dateFactory;
158 $this->_transactionFactory = $transactionFactory;
180 parent::_construct();
192 return $this->
setData(
'txn_id', $txnId);
209 throw new \Magento\Framework\Exception\LocalizedException(
210 __(
'The parent transaction ID must have a transaction ID.')
216 return $this->
setData(
'parent_txn_id', $parentTxnId);
228 return $this->
setData(
'txn_type', $txnType);
240 if (
null === $this->_parentTransaction) {
242 $this->_parentTransaction =
false;
245 $this->_parentTransaction = $this->_transactionFactory->create();
247 $this->_parentTransaction
251 if (!$this->_parentTransaction->getId()) {
252 $this->_parentTransaction =
false;
254 $this->_parentTransaction->hasChildTransaction(
true);
283 if (empty($types) &&
null === $txnId) {
285 }
elseif ($types && !is_array($types)) {
291 if (empty($this->_children)) {
295 if ($this->_identifiedChildren) {
296 if (isset($this->_identifiedChildren[$txnId])) {
300 foreach ($this->_children as $child) {
301 if ($child->getTxnId() === $txnId) {
316 foreach ($this->_children as $child) {
317 if (in_array($child->getType(), $types,
true)) {
318 $result[$child->getId()] = $child;
340 }
catch (\Exception $e) {
346 $authTransaction =
false;
354 $authTransaction = $this;
360 if ($authTransaction) {
362 $authTransaction->close($shouldSave);
365 return $authTransaction;
379 $captureTransaction =
false;
382 $captureTransaction = $this;
390 if ($captureTransaction) {
391 $captureTransaction->close($shouldSave);
393 return $captureTransaction;
424 if (
null !== $whetherHasChild) {
425 $this->_hasChild = (bool)$whetherHasChild;
427 }
elseif (
null === $this->_hasChild) {
429 $this->_hasChild =
true;
431 $this->_hasChild =
false;
450 throw new \Magento\Framework\Exception\LocalizedException(
451 __(
'Payment transactions disallow storing objects.')
475 return isset(
$info[$key]) ?
$info[$key] :
null;
490 if (is_array(
$info)) {
508 public function close($shouldSave =
true)
510 if (!$this->_isFailsafe) {
513 if (1 == $this->
getIsClosed() && $this->_isFailsafe) {
514 throw new \Magento\Framework\Exception\LocalizedException(
522 if ($this->_transactionsAutoLinking && self::TYPE_AUTH === $this->
getTxnType()) {
525 if ($paymentTransaction) {
526 $paymentTransaction->close($shouldSave);
528 }
catch (\Exception $e) {
529 if (!$this->_isFailsafe) {
545 $orderId = $this->
_getData(
'order_id');
566 if ($this->
_order ===
null) {
592 throw new \Magento\Framework\Exception\LocalizedException(
593 __(
'Set order for existing transactions not allowed')
608 if (
null === $setFailsafe) {
611 $this->_isFailsafe = (bool)$setFailsafe;
630 if (!$this->
getId()) {
631 $this->
setCreatedAt($this->_dateFactory->create()->gmtDate());
633 return parent::beforeSave();
646 if (
null !== $this->_children) {
653 throw new \Magento\Framework\Exception\LocalizedException(
__(
'At minimum, you need to set a payment ID.'));
667 )->addPaymentIdFilter(
669 )->addParentIdFilter(
674 $this->_children = [];
675 $this->_identifiedChildren = [];
680 $this->_children[$child->getId()] = $child;
681 if (
false !== $this->_identifiedChildren) {
682 $childTxnId = $child->getTxnId();
683 if (!$childTxnId ||
'0' == $childTxnId) {
684 $this->_identifiedChildren =
false;
686 $this->_identifiedChildren[$child->getTxnId()] = $child;
690 if (
false === $this->_identifiedChildren) {
691 $this->_identifiedChildren = [];
725 \Magento\Sales\Model\Order\Payment\Transaction::TYPE_ORDER =>
__(
'Order'),
726 \Magento\Sales\Model\Order\Payment\Transaction::TYPE_AUTH =>
__(
'Authorization'),
727 \Magento\Sales\Model\Order\Payment\Transaction::TYPE_CAPTURE =>
__(
'Capture'),
728 \Magento\Sales\Model\Order\Payment\Transaction::TYPE_VOID =>
__(
'Void'),
729 \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND =>
__(
'Refund')
740 if ($this->_orderWebsiteId ===
null) {
755 if (
null === $txnType) {
767 throw new \Magento\Framework\Exception\LocalizedException(
768 __(
'We found an unsupported transaction type "%1".', $txnType)
785 throw new \Magento\Framework\Exception\LocalizedException(
786 __(
'Please set a proper payment and order id.')
801 if (
null !== $txnId && 0 == strlen($txnId)) {
802 throw new \Magento\Framework\Exception\LocalizedException(
__(
'Please enter a Transaction ID.'));
815 if (!$this->
getId()) {
816 throw new \Magento\Framework\Exception\LocalizedException(
817 __(
'You can\'t do this without a transaction object.')
900 $this->_eventManager->dispatch($this->_eventPrefix .
'_html_txn_id', $this->
_getEventData());
901 return isset($this->_data[
'html_txn_id']) ? $this->_data[
'html_txn_id'] : $this->
getTxnId();
hasChildTransaction($whetherHasChild=null)
getParentTransaction($shouldLoad=true)
setParentTxnId($parentTxnId, $txnId=null)
_verifyTxnType($txnType=null)
_getExtensionAttributes()
closeCapture($shouldSave=true)
elseif(isset( $params[ 'redirect_parent']))
_verifyThisTransactionExists()
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
canVoidAuthorizationCompletely()
getChildTransactions($types=null, $txnId=null, $recursive=false)
setAdditionalInformation($key, $value)
getAdditionalInformation($key=null)
closeAuthorization($shouldSave=true, $dryRun=false)
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Api\OrderPaymentRepositoryInterface $orderPaymentRepository, \Magento\Sales\Api\OrderRepositoryInterface $orderRepository, \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory, TransactionFactory $transactionFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
isFailsafe($setFailsafe=null)
getData($key='', $index=null)
setExtensionAttributes(\Magento\Sales\Api\Data\TransactionExtensionInterface $extensionAttributes)
setData($key, $value=null)
unsAdditionalInformation($key=null)
foreach( $_productCollection as $_product)() ?>" class $info
$_transactionsAutoLinking
_verifyPaymentObject($dryRun=false)