How can I get the order ID from Commerce (using Rules)? I need to call a function upon successful completion of an order, and that function needs to know the OrderID that called it.

I have setup a rule 

Event:
"Completing the checkout process"

Conditions:
None

Actions:
[custom function]

I am aware of two possible ways pass the order_id. 


Using a data selector (though I'm not exactly sure what this should be), and passing it through a 'value' argument -or-
Calling the function commerce_cart_order_id($uid) from within my function.


commerce_cart_order_id($uid) did not seem to return anything. 

global $user;
$uid = $user-&gt;uid;  
$order_id = commerce_cart_order_id($uid);
drupal_set_message(t('OrderID:  ' . $order_id), 'status');


Has anyone got any suggestions on what I might be doing wrong? Many thanks.
As you have mentioned, you want to act on completion of the order, so there is a hook of drupal_commerce, which get called on completion..

hook_commerce_checkout_complete($order)


I have used this hook for some action at the order completion in my custom module. If you call this hook in your custom module then $order variable will have all the information related to order. Check this in your custom module --

function MYMODULE_commerce_checkout_complete($order){
  dpm($order);
}