Modify order state

Posts: 26
Joined: 12/18/2007
Bug Finder

I've been implementing a neos and a tripledeal payment provider for the past few weeks and i'm nearing completion of them (most propably i'll donate them to the community when they are finished and tested)

but i have one small problem now. i cant find out how to change the state from "pending" to "post_checkout" when the order is sent to the payment provider and from "post_checkout" to "post_payment" after the payment provider replies back.

I use this code:

function uc_neos_ok() {
  unset($_SESSION['cart_order'], $_SESSION['do_complete']);
  uc_cart_empty(uc_cart_get_id());
  $id = $_GET["orderID"];
  if ($id < 1) {
    drupal_access_denied();
    return;
  }

  uc_order_comment_save($id, $user->uid, t('Bestel proces afgerond door klant'), 'admin');
  uc_order_update_status($id, uc_order_state_default('post_checkout'));
return variable_get('neos_success_msg', '');
}

but the order always stays "pending".

complete module is in the attachment

AttachmentSize
uc_neos_payment.zip4.14 KB
Posts: 26
Joined: 12/18/2007
Bug Finder

doesn't anyone know a solution?

i also added the workflow-ng module btw and i'm running ubercart alpha 8

Posts: 5617
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Hmm... perhaps I can propose an alternative that may solve your issue? Instead of hardcoding status changes in the module, have you considered making a workflow-ng configuration? This gets triggered by a few different functions, like when payments get entered or a person completes checkout. This should let you tie in exactly where you need and update the status w/o hardcoding. Then if you want, you can actually define this workflow configuration as a default enabled workflow in your module so other folks can use it.

Posts: 26
Joined: 12/18/2007
Bug Finder

well I didn't consider it as I didn't know this was possible Eye-wink

but if you can tell me where I can find information about it then I will consider it

Posts: 26
Joined: 12/18/2007
Bug Finder

thats odd... my question in the first post is gone Shocked

Posts: 971
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Posts: 2349
Joined: 08/07/2007
AdministratoreLiTe!

Fixed.

Posts: 26
Joined: 12/18/2007
Bug Finder

ok thx

i'm near solving the problem myself. i'll post tomorrow what i found out Eye-wink

*cliffhanger*

Posts: 26
Joined: 12/18/2007
Bug Finder

ok i've been reading in the manual that you could update the status with this:
uc_order_update_status($id, uc_order_state_default('payment_received'));

and this didn't work...

but this does work:

uc_order_update_status($id, 'payment_received');

so I think this page is wrong:
http://www.ubercart.org/docs/api/uc_order_state_default

Posts: 5617
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Honestly, the former should work unless something screwed up on the setup of your order states/statuses. The second works because you're directly setting it to the payment_received status which is also the name of an entire order state. Tricky language, I know, but the code should work. The way to check it would be to look in your uc_order_statuses table and see what state is assigned for the payment_received status. If you wanted to put some benchmarks in the code to isolate the issue, you could put some drupal_set_message() calls in the uc_order_update_status() function.

In any event, glad it works for you as is.

Also, if you wanted to see an example of updating order status in a workflow configuration instead of hardcoding it, you can check out the function uc_payment_configuration() in uc_payment_workflow.inc.