How to update failed transaction detail in drupal commerce I am using drupal commerce to built a e-commerce site .

My problem is when a transaction is failed or get a late response then the transaction is not created.

Can i create it manually or i have to ? if yes then how?

Or is their any other way to attach my transaction detail to order .

Any help most appriciate. Thank you.
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.