Setting an order as Completed In code I am trying to mark an order as completed. I am doing this in hook_commerce_payment_order_paid_in_full

function my_module_commerce_payment_order_paid_in_full($transaction) {
  $orderid = $transaction-&gt;order_number;
  $order = commerce_order_load($orderid);
  commerce_order_status_update($order, 'completed');
}


However this does not seem to work. The state the call is at when going into this is processing

I also have the following 2 rules

{ "commerce_checkout_order_status_update" : {
    "LABEL" : "Update the order status on checkout completion",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "Commerce Checkout" ],
    "REQUIRES" : [ "commerce_order", "commerce_checkout" ],
    "ON" : [ "commerce_checkout_complete" ],
    "DO" : [
      { "commerce_order_update_state" : { "commerce_order" : [ "commerce-order" ], "order_state" : "pending" } }
    ]
  }
}


And

{ "rules_update_the_order_status_on_checkout_completion_if_payment_" : {
    "LABEL" : "Update the order status on checkout completion (if payment complete)",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "1",
    "TAGS" : [ "Commerce Checkout" ],
    "REQUIRES" : [ "commerce_payment", "commerce_order", "commerce_checkout" ],
    "ON" : [ "commerce_checkout_complete" ],
    "IF" : [
      { "commerce_payment_order_balance_comparison" : { "commerce_order" : [ "commerce_order" ], "value" : "0" } }
    ],
    "DO" : [
      { "commerce_order_update_status" : { "commerce_order" : [ "commerce_order" ], "order_status" : "completed" } }
    ]
  }
}


In short as soon as the balance is 0 I want the order to be complete.
If the problem is simply that orders are being marked "paid in full" while still in checkout and then having their statuses overridden when the checkout completion rules run, why don't you just add a condition to the default checkout completion rules to not change the order status if it's already completed?