set orders as 'complete' from custom module
Hello,
I have an issue related with Orders (I guess). This is the scenario: I have a custom payment gateway based on a remote web form displayed in a Chekout pane, works OK. When the data is received from the remote payment gateway and the transaction is completed, the user is redirected to a page of Drupal with the result of the process, that´s OK too. My issue is that when the remote payment gateway send the parameters to the page, and the parameters are received, I do not know how to programmatically set the order as 'completed' (the Order always is on 'shopping cart 'status). btw the Profile is stored OK too. any thoughts? or this is with Rules?,
this is the code that I have in this moment:
function commerce_checkout_pane_empty_cart() {
if($_GET['authorization'] == 'OK'){
global $user;
$user = user_load($user->uid);
$order = commerce_cart_order_load($user->uid);
$profile = commerce_customer_profile_new('billing', $user->uid);
$profile->commerce_customer_address = array(LANGUAGE_NONE => array(0 => addressfield_default_values()));
commerce_customer_profile_save($profile);
$order->commerce_customer_billing[LANGUAGE_NONE][0]['profile_id'] = $profile->profile_id;
commerce_order_save($order);
commerce_order_status_update($order,'checkout_complete');
commerce_checkout_complete($order);
}
}
thanks in advance.