/** * debug * * @param string $class * @param string $func * @param string $line * @param array $info * @param bool $display_request */ function log($class = '', $func = '', $line = '', $info = array(), $display_request = false) { if (WP_DEBUG && false) { $debug_data = get_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array()); $default_data = array($class => $func . '() : ' . $line, 'request->step' => $this->step, 'request->action' => $this->action, 'current_step->slug' => $this->current_step instanceof EE_SPCO_Reg_Step ? $this->current_step->slug() : '', 'current_step->completed' => $this->current_step instanceof EE_SPCO_Reg_Step ? $this->current_step->completed() : '', 'txn_status_updated' => $this->txn_status_updated, 'reg_status_updated' => $this->reg_status_updated, 'reg_url_link' => $this->reg_url_link, 'REQ' => $display_request ? $_REQUEST : ''); if ($this->transaction instanceof EE_Transaction) { $default_data['TXN_status'] = $this->transaction->status_ID(); $default_data['TXN_reg_steps'] = $this->transaction->reg_steps(); foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) { $default_data['registrations'][$REG_ID] = $registration->status_ID(); } if ($this->transaction->ID()) { $TXN_ID = 'EE_Transaction: ' . $this->transaction->ID(); // don't serialize objects $info = $this->_strip_objects($info); if (!isset($debug_data[$TXN_ID])) { $debug_data[$TXN_ID] = array(); } $debug_data[$TXN_ID][microtime()] = array_merge($default_data, $info); update_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data); } } } }
/** * debug * * @param string $class * @param string $func * @param string $line * @param array $info * @param bool $display_request * @param string $debug_index * @param string $debug_key */ public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') { if (WP_DEBUG && false) { $debug_key = $debug_key . '_' . EE_Session::instance()->id(); $debug_data = get_option($debug_key, array()); $default_data = array($class => $func . '() : ' . $line, 'REQ' => $display_request ? $_REQUEST : ''); // don't serialize objects $info = self::strip_objects($info); $index = !empty($debug_index) ? $debug_index : 0; if (!isset($debug_data[$index])) { $debug_data[$index] = array(); } $debug_data[$index][microtime()] = array_merge($default_data, $info); update_option($debug_key, $debug_data); } }
/** * _validate_return * * @access private * @return bool */ private function _validate_offsite_return() { $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); if ($TXN_ID != $this->checkout->transaction->ID()) { // Houston... we might have a problem $invalid_TXN = false; // first gather some info $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); $primary_registrant = $valid_TXN instanceof EE_Transaction ? $valid_TXN->primary_registration() : null; // let's start by retrieving the cart for this TXN $cart = EE_Cart::get_cart_from_txn($this->checkout->transaction); if ($cart instanceof EE_Cart) { // verify that the current cart has tickets $tickets = $cart->get_tickets(); if (empty($tickets)) { $invalid_TXN = true; } } else { $invalid_TXN = true; } $valid_TXN_SID = $primary_registrant instanceof EE_Registration ? $primary_registrant->session_ID() : null; // validate current Session ID and compare against valid TXN session ID if (EE_Session::instance()->id() === null) { $invalid_TXN = true; } else { if (EE_Session::instance()->id() === $valid_TXN_SID) { // WARNING !!! // this could be PayPal sending back duplicate requests (ya they do that) // or it **could** mean someone is simply registering AGAIN after having just done so // so now we need to determine if this current TXN looks valid or not /** @type EE_Transaction_Processor $transaction_processor */ $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); // has this step even been started ? if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false)) { // really? you're half way through this reg step, but you never started it ? $invalid_TXN = true; } } } if ($invalid_TXN) { // is the valid TXN completed ? if ($valid_TXN instanceof EE_Transaction) { /** @type EE_Transaction_Processor $transaction_processor */ $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); // has this step even been started ? $reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug()); if ($reg_step_completed !== false && $reg_step_completed !== true) { // so it **looks** like this is a double request from PayPal // so let's try to pick up where we left off $this->checkout->transaction = $valid_TXN; $this->checkout->refresh_all_entities(true); return; } } // you appear to be lost? $this->_redirect_wayward_request($primary_registrant); } } }
/** * run - initial shortcode module setup called during "wp_loaded" hook * this method is primarily used for loading resources that will be required by the shortcode when it is actually processed * * @access public * @param WP $WP * @return void */ public function run(WP $WP) { // ensure this shortcode doesn't trigger on anything BUT the thank you page if (isset($WP->request) && basename($WP->request) != basename(EE_Registry::instance()->CFG->core->thank_you_page_url())) { return; } else { if (isset($WP->query_vars['page_id']) && $WP->query_vars['page_id'] != EE_Registry::instance()->CFG->core->thank_you_page_id) { return; } } // only do thank you page stuff if we have a REG_url_link in the url if (!EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { EE_Error::add_error(__('No transaction information could be retrieved because the registration URL link is missing or invalid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return; } // check for reg_url_link $this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link'); // and retrieve the current TXN $this->_current_txn = EE_Registry::instance()->load_model('Transaction')->get_transaction_from_reg_url_link(); // verify TXN if (!$this->_current_txn instanceof EE_Transaction) { EE_Error::add_error(__('No transaction information could be retrieved or the transaction data is not of the correct type.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return; } if (EE_Registry::instance()->REQ->is_set('resend')) { return EES_Espresso_Thank_You::resend_reg_confirmation_email(); } // soon to be derprecated EE_Registry::instance()->load_model('Gateways')->thank_you_page_logic($this->_current_txn); EE_Registry::instance()->LIB->EEM_Gateways->reset_session_data(); // load assets add_action('wp_enqueue_scripts', array($this, 'load_js'), 10); add_action('shutdown', array(EE_Session::instance(), 'clear_session')); return; }