Skip to content

Commit 10eb2e6

Browse files
AC-10042::/V1/transactions REST API returns error when parent_txn_id = txn_id
1 parent b98851f commit 10eb2e6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

app/code/Magento/Sales/Model/ResourceModel/Order/Payment/Transaction.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $transacti
146146
__('We don\'t have enough information to save the parent transaction ID.')
147147
);
148148
}
149+
/*$parentId = (int)$this->_lookupByTxnId($orderId, $paymentId, $parentTxnId, $idFieldName);
150+
if ($parentId) {
151+
$transaction->setData('parent_id', $parentId);
152+
}*/
153+
} else {
154+
$oldParentTxnId = $this->getParentTxnId($orderId);
155+
if($oldParentTxnId) {
156+
$transaction->setData('parent_txn_id', $oldParentTxnId);
157+
}
149158
}
150159

151160
// make sure unique key won't cause trouble
@@ -207,4 +216,19 @@ private function _getLoadByUniqueKeySelect($orderId, $paymentId, $txnId, $column
207216
$txnId
208217
);
209218
}
219+
/**
220+
* Retrieve transaction by the unique key of order_id
221+
* @param int $orderId
222+
*/
223+
protected function getParentTxnId($orderId) {
224+
$connection = $this->getConnection();
225+
$select = $connection->select()->from(
226+
$this->getMainTable(),
227+
['parent_txn_id']
228+
)->where(
229+
'order_id = ?',
230+
$orderId
231+
);
232+
return $connection->fetchOne($select);
233+
}
210234
}

0 commit comments

Comments
 (0)