Index: uc_protx_vsp_direct_workflow.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/uc_protx_vsp_direct/Attic/uc_protx_vsp_direct_workflow.inc,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 uc_protx_vsp_direct_workflow.inc --- uc_protx_vsp_direct_workflow.inc 4 Sep 2009 19:43:08 -0000 1.1.2.5 +++ uc_protx_vsp_direct_workflow.inc 14 Apr 2010 12:58:14 -0000 @@ -69,6 +69,31 @@ function uc_protx_vsp_direct_action_3dse uc_protx_vsp_direct_txdata_save($txdata); } +function uc_protx_vsp_direct_action_account_type_form($settings = array()) { + $form['uc_protx_vsp_direct_action_account_type'] = array( + '#type' => 'select', + '#title' => t('Account type'), + '#description' => t('This allows you to change the merchant account used for a SagePay transaction. The default is "E-commerce account" but the "Mail order/telephone order account" can be useful when taking payments through the admin pages.'), + '#options' => array( + 'E' => t('E-commerce account'), + 'M' => t('Mail order/telephone order account'), + 'C' => t('Continuous authority account'), + ), + '#default_value' => $settings['uc_protx_vsp_direct_action_account_type'], + ); + + return $form; +} + +function uc_protx_vsp_direct_action_account_type_submit($form_id, $form_values) { + return array('uc_protx_vsp_direct_action_account_type' => $form_values['uc_protx_vsp_direct_action_account_type']); +} + +function uc_protx_vsp_direct_action_account_type($txdata, $settings) { + $txdata['AccountType'] = $settings['uc_protx_vsp_direct_action_account_type']; + uc_protx_vsp_direct_txdata_save($txdata); +} + function uc_protx_vsp_direct_condition_card_form($settings = array()) { // TODO: Add validation for method ID /* @@ -117,6 +142,10 @@ function uc_protx_vsp_direct_condition_c return $condition; } +function uc_protx_vsp_direct_condition_admin($order, $settings) { + return arg(0) == 'admin'; +} + /****************************************************************************** * Workflow-ng Hooks * ******************************************************************************/ @@ -152,6 +181,17 @@ function uc_protx_vsp_direct_condition_i '#module' => UC_PROTX_VSP_DIRECT_CATEGORY, ); + $conditions['uc_protx_vsp_direct_condition_admin'] = array( + '#label' => t('Check the order is being processed by an admin'), + '#arguments' => array( + 'order' => array( + '#entity' => 'order', + '#label' => t('Order') + ) + ), + '#module' => UC_PROTX_VSP_DIRECT_CATEGORY, + ); + return $conditions; } @@ -168,6 +208,17 @@ function uc_protx_vsp_direct_action_info '#module' => UC_PROTX_VSP_DIRECT_CATEGORY, ); + $actions['uc_protx_vsp_direct_action_account_type'] = array( + '#label' => t('Set account type'), + '#arguments' => array( + 'uc_protx_vsp_direct_txdata' => array( + '#entity' => 'uc_protx_vsp_direct_txdata', + '#label' => t('SagePay transaction data') + ) + ), + '#module' => UC_PROTX_VSP_DIRECT_CATEGORY, + ); + return $actions; } @@ -193,5 +244,30 @@ function uc_protx_vsp_direct_configurati ), ); + $configurations['uc_protx_vsp_direct_admin_order'] = array( + '#type' => 'configuration', + '#label' => t('Use mail order/telephone order account when order is processed by an admin'), + '#event' => 'uc_protx_vsp_direct_event_txsend', + '#module' => UC_PROTX_VSP_DIRECT_CATEGORY, + '#active' => FALSE, + ); + $configurations['uc_protx_vsp_direct_admin_order'][] = array( + '#type' => 'condition', + '#name' => 'uc_protx_vsp_direct_condition_admin', + '#argument map' => array( + 'order' => 'order', + ), + ); + $configurations['uc_protx_vsp_direct_admin_order'][] = array( + '#type' => 'action', + '#name' => 'uc_protx_vsp_direct_action_account_type', + '#argument map' => array( + 'uc_protx_vsp_direct_txdata' => 'uc_protx_vsp_direct_txdata', + ), + '#settings' => array( + 'uc_protx_vsp_direct_action_account_type' => 'M', + ), + ); + return $configurations; } \ No newline at end of file