/** * _process_finalize_registration * * @access private * @return void */ private function _process_finalize_registration() { do_action('AHEE_log', __FILE__, __FUNCTION__, ''); // save everything if ($this->_continue_reg && $this->_save_all_registration_information()) { // echo '<h2 style="color:#E76700;">_process_finalize_registration<br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h2>'; // save TXN data to the cart $this->_cart->get_grand_total()->save_this_and_descendants_to_txn($this->_transaction->ID()); do_action('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->_transaction); // if Default REG Status is set to REQUIRES APPROVAL... then payments are NOT allowed if (EE_Registry::instance()->REQ->is_set('selected_gateway') && EE_Registry::instance()->REQ->get('selected_gateway') == 'payments_closed') { // echo '<h2 style="color:#E76700;">payments_closed<br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h2>'; // set TXN Status to Open $this->_transaction->set_status(EEM_Transaction::incomplete_status_code); $this->_transaction->save(); $this->_transaction->finalize(); $notices = EE_Error::get_notices(FALSE); $response = array('msg' => array('success' => isset($notices['success']) ? $notices['success'] : '', 'errors' => isset($notices['errors']) ? $notices['errors'] : '')); $this->_thank_you_page_url = add_query_arg(array('e_reg_url_link' => $this->_transaction->primary_registration()->reg_url_link()), get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); // Default REG Status is set to PENDING PAYMENT OR APPROVED, and payments are allowed } else { // attempt to perform transaction via payment gateway $response = EE_Registry::instance()->load_model('Gateways')->process_payment_start($this->_cart->get_grand_total(), $this->_transaction); $this->_thank_you_page_url = $response['forward_url']; } if (isset($response['msg']['success'])) { $response_data = array('success' => $response['msg']['success'], 'return_data' => array('redirect-to-thank-you-page' => $this->_thank_you_page_url)); $response_data = apply_filters('FHEE__EE_Single_Page_Checkout__JSON_response', $response_data); // printr( $response_data, '$response_data <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); // echo '<h4>thank_you_page_url : ' . $this->_thank_you_page_url . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; if (EE_Registry::instance()->REQ->front_ajax) { echo json_encode($response_data); die; } else { wp_safe_redirect($this->_thank_you_page_url); exit; } } else { EE_Error::add_error($response['msg']['error'], __FILE__, __FUNCTION__, __LINE__); } // printr( $response, '$response <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); } $this->go_to_next_step(__FUNCTION__); }
/** * refresh_entity_map * simply loops through the current transaction and updates * each model's entity map using EEM_Base::refresh_entity_map_with() * * @access public * @return bool */ protected function refresh_entity_map() { // verify the transaction if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) { // never cache payment info $this->transaction->clear_cache('Payment'); /** @type EE_Transaction_Processor $transaction_processor */ $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); // is the Payment Options Reg Step completed ? if ($transaction_processor->reg_step_completed($this->transaction, 'payment_options')) { // then check for payments and update TXN accordingly /** @type EE_Transaction_Payments $transaction_payments */ $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); $transaction_payments->calculate_total_payments_and_update_status($this->transaction); } // grab the saved registrations from the transaction foreach ($this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration) { $this->_refresh_registration($reg_cache_ID, $registration); } // make sure our cached TXN is added to the model entity mapper $this->transaction = $this->transaction->get_model()->refresh_entity_map_with($this->transaction->ID(), $this->transaction); } else { EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return FALSE; } if ($this->cart instanceof EE_Cart) { $grand_total = $this->cart->get_grand_total(); if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) { $grand_total = $grand_total->get_model()->refresh_entity_map_with($this->cart->get_grand_total()->ID(), $this->cart->get_grand_total()); } if ($grand_total instanceof EE_Line_Item) { $this->cart = EE_Cart::instance($grand_total); } else { EE_Error::add_error(__('A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return false; } } return TRUE; }