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.

  • This question is very vague. What payment module are you using? This sounds like a bug in the module or perhaps PHP is dying before the request times out. – nvahalik Nov 6 '15 at 17:46

You need to load the failed transaction from order id as shown below:

  $query = new EntityFieldQuery;
  $result = $query
    ->entityCondition('entity_type', 'commerce_payment_transaction')
    ->propertyCondition('order_id', $order->order_id)
    ->propertyOrderBy('transaction_id', 'DESC')
    ->range(0, 1)

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

//Use following line instead of loading transaction in order to create new transaction object
//$transaction = commerce_payment_transaction_new('commerce_payment_example', $order->order_id);
$transaction = commerce_payment_transaction_load($transaction_id);
$transaction->amount = $charge['amount'];
$transaction->currency_code = $charge['currency_code'];

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

| improve this answer | |
  • Thanks for your interest but in my case transaction is not created yet. i.e, if customer close the window just after payment. – Lucifer Mar 11 '15 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.