/**
  * This processes the registration form from the admin and returns either the true or false depending on the success of the process.
  *
  * Note that this method handles not only validating the registration form but also saving to the database all the data in the session.
  *
  * @access  public
  * @return mixed bool|int (either false on fail OR TXN id on success)
  */
 public function process_registration_from_admin()
 {
     //nonce check was done in admin so no need to do here.
     //first lets validate the registration form
     $this->init_for_admin();
     //if failure in processing attendee info then let's get out early
     if (!$this->_process_attendee_information()) {
         return FALSE;
     }
     // same deal when saving everything
     if (!$this->_save_all_registration_information()) {
         return FALSE;
     }
     //all is good so let's continue with finalizing the registration.
     EE_Registry::instance()->SSN->set_session_data(array('transaction', NULL));
     $this->_transaction->set_txn_session_data(EE_Registry::instance()->SSN->get_session_data());
     $this->_cart->get_grand_total()->save_this_and_descendants_to_txn($this->_transaction->ID());
     //is this free event?
     if ($this->_cart->get_grand_total()->total() == EEH_Template::format_currency(0, TRUE)) {
         $this->_transaction->set_status(EEM_Transaction::complete_status_code);
     } else {
         $this->_transaction->set_status(EEM_Transaction::incomplete_status_code);
     }
     $this->_transaction->finalize(TRUE);
     EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
     return $this->_transaction->ID();
 }
 /**
  * @param \EE_Transaction $transaction
  * @return bool
  */
 public function set_transaction(EE_Transaction $transaction)
 {
     // first remove the session from the transaction before we save the transaction in the session
     $transaction->set_txn_session_data(NULL);
     $this->_session_data['transaction'] = $transaction;
     return TRUE;
 }
 /**
  * Cleans the session so that it doesn't store the credit card or CVV to the DB
  * @param EE_Transaction $transaction to also update
  * @return void
  */
 protected function _clean_billing_info_in_session($transaction)
 {
     $session_data = EE_Registry::instance()->SSN->get_session_data();
     if (isset($session_data['billing_info']) && is_array($session_data['billing_info'])) {
         foreach ($session_data['billing_info'] as $name => $billing_input_array) {
             if ($billing_input_array['sanitize'] == 'ccard') {
                 $session_data['billing_info'][$name]['value'] = $this->MaskCreditCard($billing_input_array['value']);
             } elseif ($billing_input_array['sanitize'] == 'ccv') {
                 $session_data['billing_info'][$name]['value'] = '';
             }
         }
     }
     $success = EE_Registry::instance()->SSN->update($session_data);
     unset($session_data['transaction']);
     $transaction->set_txn_session_data($session_data);
     $transaction->save();
 }