How to update failed transaction detail in drupal commerce
You need to load the failed transaction from order id as shown below:

&lt;?php
  $query = new EntityFieldQuery;
  $result = $query
    -&gt;entityCondition('entity_type', 'commerce_payment_transaction')
    -&gt;propertyCondition('order_id', $order-&gt;order_id)
    -&gt;propertyOrderBy('transaction_id', 'DESC')
    -&gt;range(0, 1)
    -&gt;execute();
?&gt;


Then load transaction using commerce_payment_transaction_load($transaction_id) &amp; update transaction object as shown below:

&lt;?php
//Use following line instead of loading transaction in order to create new transaction object
//$transaction = commerce_payment_transaction_new('commerce_payment_example', $order-&gt;order_id);
$transaction = commerce_payment_transaction_load($transaction_id);
$transaction-&gt;amount = $charge['amount'];
$transaction-&gt;currency_code = $charge['currency_code'];
$transaction-&gt;status = COMMERCE_PAYMENT_STATUS_SUCCESS;
commerce_payment_transaction_save($transaction);
?&gt;


You can set a cron to periodically check failed transaction &amp; check status of same at Payment Gateway &amp; update accordingly.