function espresso_replace_invoice_shortcodes($content) { $EE = EE_Registry::instance(); //Create the logo if (!empty($this->invoice_settings['invoice_logo_url'])) { $invoice_logo_url = $this->invoice_settings['invoice_logo_url']; } else { $invoice_logo_url = $EE->CFG->organization->logo_url; } if (!empty($invoice_logo_url)) { $image_size = getimagesize($invoice_logo_url); $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; } else { $invoice_logo_image = ''; } $SearchValues = array("[organization]", "[registration_code]", "[transaction_id]", "[name]", "[base_url]", "[download_link]", "[invoice_logo_image]", "[street]", "[city]", "[state]", "[zip]", "[email]", "[vat]", "[registration_date]", "[instructions]"); $primary_attendee = $this->transaction->primary_registration()->attendee(); $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID); if ($org_state) { $org_state_name = $org_state->name(); } else { $org_state_name = ''; } $ReplaceValues = array(stripslashes($EE->CFG->organization->name), $this->registration->reg_code(), $this->transaction->ID(), $primary_attendee->full_name(), is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice') ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' : EE_GATEWAYS_URL . 'Invoice/lib/templates/', $this->registration->invoice_url(), $invoice_logo_image, empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->address_1 : $EE->CFG->organization->address_1 . '<br>' . $EE->CFG->organization->address_2, $EE->CFG->organization->city, $org_state_name, $EE->CFG->organization->zip, $EE->CFG->organization->email, $EE->CFG->organization->vat, date_i18n(get_option('date_format'), strtotime($this->registration->date())), $this->invoice_settings['pdf_instructions']); return str_replace($SearchValues, $ReplaceValues, $content); }
/** * Constructs and initializes an WooCommerce iDEAL data proxy * * @param WC_Order $order */ public function __construct($gateway, EE_Line_Item $line_item, EE_Transaction $transaction) { parent::__construct(); $this->gateway = $gateway; $this->line_item = $line_item; $this->transaction = $transaction; $this->primary_registrant = $transaction->primary_registration(); $this->primary_attendee = $this->primary_registrant->attendee(); }
/** * init * * @access public * @return void */ public function init() { $this->_get_reg_url_link(); if (!$this->get_txn()) { EE_Registry::instance()->load_helper('HTML'); echo EEH_HTML::div(EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . sprintf(__('This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', 'event_espresso'), '<br/>'), '', 'ee-attention'); return NULL; } // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" if ($this->_current_txn->status_ID() == EEM_Transaction::failed_status_code) { $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); $this->_current_txn->save(); } $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration ? $this->_current_txn->primary_registration() : NULL; $this->_is_primary = $this->_primary_registrant->reg_url_link() == $this->_reg_url_link ? TRUE : FALSE; $show_try_pay_again_link_default = apply_filters('AFEE__EES_Espresso_Thank_You__init__show_try_pay_again_link_default', TRUE); // txn status ? if ($this->_current_txn->is_completed()) { $this->_show_try_pay_again_link = $show_try_pay_again_link_default; } else { if ($this->_current_txn->is_incomplete() && ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment())) { $this->_show_try_pay_again_link = TRUE; } else { if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { // its pending $this->_show_try_pay_again_link = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) && EE_Registry::instance()->CFG->registration->show_pending_payment_options ? TRUE : $show_try_pay_again_link_default; } else { $this->_show_try_pay_again_link = $show_try_pay_again_link_default; } } } $this->_payments_closed = !$this->_current_txn->payment_method() instanceof EE_Payment_Method ? TRUE : FALSE; if (!$this->_current_txn->payment_method() instanceof EE_Payment_Method || $this->_current_txn->payment_method() instanceof EE_Payment_Method && $this->_current_txn->payment_method()->is_off_line()) { $this->_is_offline_payment_method = true; } else { $this->_is_offline_payment_method = false; } // link to SPCO $revisit_spco_url = add_query_arg(array('ee' => '_register', 'revisit' => TRUE, 'e_reg_url_link' => $this->_reg_url_link), EE_Registry::instance()->CFG->core->reg_page_url()); // link to SPCO payment_options $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->payment_overview_url() : add_query_arg(array('step' => 'payment_options'), $revisit_spco_url); // link to SPCO attendee_information $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->edit_attendee_information_url() : FALSE; EE_Registry::instance()->load_helper('Template'); EE_Registry::instance()->load_helper('Template_Validator'); do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn); // set no cache headers and constants EE_System::do_not_cache(); }
/** * init * * @access public * @return void */ public function init() { $this->_get_reg_url_link(); if (!$this->get_txn()) { return NULL; } // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" if ($this->_current_txn->status_ID() == EEM_Transaction::failed_status_code) { $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); $this->_current_txn->save(); } $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration ? $this->_current_txn->primary_registration() : NULL; $this->_is_primary = $this->_primary_registrant->reg_url_link() == $this->_reg_url_link ? TRUE : FALSE; $show_try_pay_again_link_default = apply_filters('AFEE__EES_Espresso_Thank_You__init__show_try_pay_again_link_default', TRUE); // txn status ? if ($this->_current_txn->is_completed()) { $this->_show_try_pay_again_link = $show_try_pay_again_link_default; } else { if ($this->_current_txn->is_incomplete() && ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment())) { $this->_show_try_pay_again_link = TRUE; } else { if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { // its pending $this->_show_try_pay_again_link = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) && EE_Registry::instance()->CFG->registration->show_pending_payment_options ? TRUE : $show_try_pay_again_link_default; } else { $this->_show_try_pay_again_link = $show_try_pay_again_link_default; } } } $this->_payments_closed = !$this->_current_txn->payment_method() instanceof EE_Payment_Method ? TRUE : FALSE; if (!$this->_current_txn->payment_method() instanceof EE_Payment_Method || $this->_current_txn->payment_method() instanceof EE_Payment_Method && $this->_current_txn->payment_method()->is_off_line()) { $this->_is_offline_payment_method = true; } else { $this->_is_offline_payment_method = false; } // link to SPCO $revisit_spco_url = add_query_arg(array('ee' => '_register', 'revisit' => TRUE, 'e_reg_url_link' => $this->_reg_url_link), EE_Registry::instance()->CFG->core->reg_page_url()); // link to SPCO payment_options $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->payment_overview_url() : add_query_arg(array('step' => 'payment_options'), $revisit_spco_url); // link to SPCO attendee_information $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->edit_attendee_information_url() : FALSE; EE_Registry::instance()->load_helper('Template'); EE_Registry::instance()->load_helper('Template_Validator'); do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn); // set no cache headers and constants EE_System::do_not_cache(); }
/** * txn_registrant_side_meta_box * generates HTML for the Edit Transaction side meta box * * @access public * @throws \EE_Error * @return void */ public function txn_registrant_side_meta_box() { $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null; if (!$primary_att instanceof EE_Attendee) { $this->_template_args['no_attendee_message'] = __('There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', 'event_espresso'); $primary_att = EEM_Attendee::instance()->create_default_object(); } $this->_template_args['ATT_ID'] = $primary_att->ID(); $this->_template_args['prime_reg_fname'] = $primary_att->fname(); $this->_template_args['prime_reg_lname'] = $primary_att->lname(); $this->_template_args['prime_reg_email'] = $primary_att->email(); $this->_template_args['prime_reg_phone'] = $primary_att->phone(); $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $primary_att->ID()), REG_ADMIN_URL); // get formatted address for registrant $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE); }
/** * init * * @access public * @return void */ public function init() { //get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request $this->_current_txn = EE_Registry::instance()->load_model('Transaction')->get_transaction_from_reg_url_link($this->_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 we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" if ($this->_current_txn->status_ID() == EEM_Transaction::failed_status_code) { $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); $this->_current_txn->save(); } $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration ? $this->_current_txn->primary_registration() : NULL; $this->_is_primary = $this->_primary_registrant->reg_url_link() == $this->_reg_url_link ? TRUE : FALSE; // txn status ? if ($this->_current_txn->is_completed()) { $this->_show_try_pay_again_link = FALSE; } else { if ($this->_current_txn->is_incomplete() && ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment())) { $this->_show_try_pay_again_link = TRUE; } else { if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { // its pending $this->_show_try_pay_again_link = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) && EE_Registry::instance()->CFG->registration->show_pending_payment_options ? TRUE : FALSE; } else { $this->_show_try_pay_again_link = FALSE; } } } $this->_is_offline_payment_method = in_array($this->_current_txn->selected_gateway(TRUE), array('Bank', 'Check', 'Invoice')); if ($this->_current_txn->last_payment() instanceof EE_Payment && $this->_current_txn->last_payment()->gateway() != NULL) { $this->_is_offline_payment_method = in_array($this->_current_txn->last_payment()->gateway(), array('Bank', 'Check', 'Invoice')); } // link to SPCO $revisit_spco_url = add_query_arg(array('ee' => '_register', 'revisit' => TRUE, 'e_reg_url_link' => $this->_reg_url_link), EE_Registry::instance()->CFG->core->reg_page_url()); // link to SPCO payment_options $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->payment_overview_url() : add_query_arg(array('step' => 'payment_options'), $revisit_spco_url); // link to SPCO attendee_information $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->edit_attendee_information_url() : FALSE; EE_Registry::instance()->load_helper('Template'); EE_Registry::instance()->load_helper('Template_Validator'); do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn); }
/** * _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__); }
function espresso_replace_invoice_shortcodes($content) { $EE = EE_Registry::instance(); //Create the logo $invoice_logo_url = $this->invoice_payment_method->get_extra_meta('pdf_logo_image', TRUE, $EE->CFG->organization->logo_url); if (!empty($invoice_logo_url)) { $image_size = getimagesize($invoice_logo_url); $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; } else { $invoice_logo_image = ''; } $SearchValues = array("[organization]", "[registration_code]", "[transaction_id]", "[name]", "[base_url]", "[download_link]", "[invoice_logo_image]", "[street]", "[city]", "[state]", "[zip]", "[email]", "[vat]", "[registration_date]", "[instructions]"); $primary_attendee = $this->transaction->primary_registration()->attendee(); $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID); if ($org_state) { $org_state_name = $org_state->name(); } else { $org_state_name = ''; } $ReplaceValues = array($EE->CFG->organization->get_pretty('name'), $this->registration->reg_code(), $this->transaction->ID(), $primary_attendee->full_name(), is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice') ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' : EE_GATEWAYS_URL . 'Invoice/lib/templates/', $this->registration->invoice_url(), $invoice_logo_image, empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty('address_1') : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2'), $EE->CFG->organization->get_pretty('city'), $org_state_name, $EE->CFG->organization->get_pretty('zip'), $EE->CFG->organization->get_pretty('email'), $EE->CFG->organization->vat, $this->registration->get_i18n_datetime('REG_date', get_option('date_format')), $this->invoice_payment_method->get_extra_meta('pdf_instructions', TRUE)); return str_replace($SearchValues, $ReplaceValues, $content); }
/** * generates HTML for the Edit Transaction side meta box * @access private * @return void */ function _txn_registrant_side_meta_box() { $primary_att = $this->_transaction->primary_registration()->get_first_related('Attendee'); if (empty($primary_att)) { throw new EE_Error(__("For some reason, the primary attendee cannot be retrieved for this transaction. It is possible there is an error in the database", 'event_espresso')); } $this->_template_args['ATT_ID'] = $primary_att->get('ATT_ID'); $this->_template_args['prime_reg_fname'] = $primary_att->get('ATT_fname'); $this->_template_args['prime_reg_lname'] = $primary_att->get('ATT_lname'); $this->_template_args['prime_reg_email'] = $primary_att->get('ATT_email'); $this->_template_args['prime_reg_address'] = $primary_att->get('ATT_address'); $this->_template_args['prime_reg_address2'] = $primary_att->get('ATT_address2'); $this->_template_args['prime_reg_city'] = $primary_att->get('ATT_city'); $state = $primary_att->state_obj(); $this->_template_args['prime_reg_state'] = !empty($state) ? $state->get('STA_name') : ''; $this->_template_args['prime_reg_country'] = $primary_att->get('CNT_ISO'); $this->_template_args['prime_reg_zip'] = $primary_att->get('ATT_zip'); $this->_template_args['prime_reg_phone'] = $primary_att->get('ATT_phone'); $this->_template_args['registrant_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'registrant'), TXN_ADMIN_URL); $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php'; echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); }
/** * Saves the billing info onto the attendee of the primary registrant on this transaction, and * cleans it first. * @param EE_Billing_Attendee_Info_Form $billing_form * @param EE_Transaction $transaction * @return boolean success */ protected function _save_billing_info_to_attendee($billing_form, $transaction) { if (!$transaction || !$transaction instanceof EE_Transaction) { EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); return false; } $primary_reg = $transaction->primary_registration(); if (!$primary_reg) { EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); return false; } $attendee = $primary_reg->attendee(); if (!$attendee) { EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); return false; } return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); }
/** * Handle IPN for transaction */ public function handle_ipn_for_transaction(EE_Transaction $transaction) { global $pronamic_payment, $pronamic_url; // Transaction ID $transaction_id = $transaction->ID(); // Payment $payment = $this->_PAY->get_payment_by_txn_id_chq_nmbr($transaction_id); if (empty($payment)) { $payment = EE_Payment::new_instance(array('TXN_ID' => $transaction_id, 'STS_ID' => EEM_Payment::status_id_approved, 'PAY_timestamp' => $transaction->datetime(), 'PAY_amount' => $pronamic_payment->amount, 'PAY_gateway' => __('iDEAL', 'pronamic_ideal'), 'PAY_txn_id_chq_nmbr' => $transaction_id)); } else { $payment->set_status(EEM_Payment::status_id_approved); } // Save $payment->save(); // URL $registration = $transaction->primary_registration(); $pronamic_url = $this->_get_return_url($registration); // Return update return $this->update_transaction_with_payment($transaction, $payment); }
/** * This helper method can be used by any incoming data handlers to setup the data correctly. All that is required is that $this->reg_objs be set. * @throws \EE_Error */ protected function _assemble_data() { //verify that reg_objs is set if (!is_array($this->reg_objs) && !reset($this->reg_objs) instanceof EE_Registration) { throw new EE_Error(__('In order to assemble the data correctly, the "reg_objs" property must be an array of EE_Registration objects', 'event_espresso')); } //get all attendee and events associated with the registrations in this transaction $events = $event_setup = $evtcache = $tickets = $datetimes = array(); $answers = $questions = $attendees = $line_items = $registrations = array(); $total_ticket_count = 0; if (!empty($this->reg_objs)) { $event_attendee_count = array(); foreach ($this->reg_objs as $reg) { //account for filtered registrations by status. if (!empty($this->filtered_reg_status) && $this->filtered_reg_status !== $reg->status_ID()) { continue; } $evt_id = $reg->event_ID(); /** @type EE_Ticket $ticket */ $ticket = $reg->get_first_related('Ticket'); $relateddatetime = $ticket->datetimes(); $total_ticket_count++; $tickets[$ticket->ID()]['ticket'] = $ticket; $tickets[$ticket->ID()]['count'] = is_array($tickets[$ticket->ID()]) && isset($tickets[$ticket->ID()]['count']) ? $tickets[$ticket->ID()]['count'] + 1 : 1; $tickets[$ticket->ID()]['att_objs'][$reg->attendee_ID()] = $reg->attendee(); $tickets[$ticket->ID()]['dtt_objs'] = $relateddatetime; $tickets[$ticket->ID()]['reg_objs'][$reg->ID()] = $reg; $event = $reg->event(); $tickets[$ticket->ID()]['EE_Event'] = $event; $evtcache[$evt_id] = $event; $eventsetup[$evt_id]['reg_objs'][$reg->ID()] = $reg; $eventsetup[$evt_id]['tkt_objs'][$ticket->ID()] = $ticket; $eventsetup[$evt_id]['att_objs'][$reg->attendee_ID()] = $reg->attendee(); $event_attendee_count[$evt_id] = isset($event_attendee_count[$evt_id]) ? $event_attendee_count[$evt_id] + 1 : 0; $attendees[$reg->attendee_ID()]['line_ref'][] = $evt_id; $attendees[$reg->attendee_ID()]['att_obj'] = $reg->attendee(); $attendees[$reg->attendee_ID()]['reg_objs'][$reg->ID()] = $reg; //$attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID(); $attendees[$reg->attendee_ID()]['attendee_email'] = $reg->attendee() instanceof EE_Attendee ? $reg->attendee()->email() : ''; $attendees[$reg->attendee_ID()]['tkt_objs'][$ticket->ID()] = $ticket; $attendees[$reg->attendee_ID()]['evt_objs'][$evt_id] = $event; //registrations $registrations[$reg->ID()]['tkt_obj'] = $ticket; $registrations[$reg->ID()]['evt_obj'] = $event; $registrations[$reg->ID()]['reg_obj'] = $reg; $registrations[$reg->ID()]['att_obj'] = $reg->attendee(); //set up answer objects $rel_ans = $reg->get_many_related('Answer'); foreach ($rel_ans as $ansid => $answer) { if (!isset($questions[$ansid])) { $questions[$ansid] = $answer->get_first_related('Question'); } $answers[$ansid] = $answer; $registrations[$reg->ID()]['ans_objs'][$ansid] = $answer; } foreach ($relateddatetime as $dtt_id => $datetime) { $eventsetup[$evt_id]['dtt_objs'][$dtt_id] = $datetime; $registrations[$reg->ID()]['dtt_objs'][$dtt_id] = $datetime; if (isset($datetimes[$dtt_id])) { continue; //already have this info in the datetimes array. } $datetimes[$dtt_id]['tkt_objs'][] = $ticket; $datetimes[$dtt_id]['datetime'] = $datetime; $datetimes[$dtt_id]['evt_objs'][$evt_id] = $event; $datetimes[$dtt_id]['reg_objs'][$reg->ID()] = $reg; } } //let's loop through the unique event=>reg items and setup data on them if (!empty($eventsetup)) { foreach ($eventsetup as $evt_id => $items) { if ($this->txn instanceof EE_Transaction) { $ticket_line_items_for_event = EEM_Line_Item::instance()->get_all(array(array('Ticket.Datetime.EVT_ID' => $evt_id, 'TXN_ID' => $this->txn->ID()), 'default_where_conditions' => 'none')); } else { $ticket_line_items_for_event = array(); } $events[$evt_id] = array('ID' => $evt_id, 'event' => $evtcache[$evt_id], 'name' => $evtcache[$evt_id] instanceof EE_Event ? $evtcache[$evt_id]->name() : '', 'total_attendees' => $event_attendee_count[$evt_id], 'reg_objs' => $items['reg_objs'], 'tkt_objs' => $items['tkt_objs'], 'att_objs' => $items['att_objs'], 'dtt_objs' => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(), 'line_items' => $ticket_line_items_for_event); //make sure the tickets have the line items setup for them. foreach ($ticket_line_items_for_event as $line_id => $line_item) { if ($line_item instanceof EE_Line_Item) { $tickets[$line_item->ticket()->ID()]['line_item'] = $line_item; $tickets[$line_item->ticket()->ID()]['sub_line_items'] = $line_item->children(); $line_items[$line_item->ID()]['children'] = $line_item->children(); $line_items[$line_item->ID()]['EE_Ticket'] = $line_item->ticket(); } } } } $this->grand_total_line_item = $this->txn instanceof EE_Transaction ? $this->txn->total_line_item() : null; } //lets set the attendees and events properties $this->attendees = $attendees; $this->events = $events; $this->tickets = $tickets; $this->line_items_with_children = $line_items; $this->datetimes = $datetimes; $this->questions = $questions; $this->answers = $answers; $this->total_ticket_count = $total_ticket_count; $this->registrations = $registrations; if ($this->txn instanceof EE_Transaction) { $this->tax_line_items = $this->txn->tax_items(); $this->additional_line_items = $this->txn->non_ticket_line_items(); $this->payments = $this->txn->payments(); //setup primary registration if we have a single transaction object to work with //let's get just the primary_attendee_data! First we get the primary registration object. $primary_reg = $this->txn->primary_registration(); // verify if ($primary_reg instanceof EE_Registration) { // get attendee object if ($primary_reg->attendee() instanceof EE_Attendee) { //now we can setup the primary_attendee_data array $this->primary_attendee_data = array('registration_id' => $primary_reg->ID(), 'att_obj' => $primary_reg->attendee(), 'reg_obj' => $primary_reg, 'primary_att_obj' => $primary_reg->attendee(), 'primary_reg_obj' => $primary_reg); } else { EE_Error::add_error(__('Incoming data does not have a valid Attendee object for the primary registrant.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); } } else { EE_Error::add_error(__('Incoming data does not have a valid Registration object for the primary registrant.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); } } }
/** * Saves the cleaned billing info to the trasnaction's primary registration's attendee. * @param array $billing_info where keys are keys in the espresso_reg_page_billing_inputs()'s array, values are their * cleaned values. * @param EE_Transaction $transaction * @return boolean */ protected function _save_billing_info_to_attendee($billing_info, $transaction) { if (!$transaction || !$transaction instanceof EE_Transaction) { EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); return false; } $primary_reg = $transaction->primary_registration(); if (!$primary_reg) { EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); return false; } $attendee_id = $primary_reg->attendee_ID(); if (!$attendee_id) { EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); return false; } $billing_input_field_settings = $this->espresso_reg_page_billing_inputs(); $billing_info_ready_for_saving = array(); foreach ($billing_input_field_settings as $field_name => $settings) { $cleaned_value = isset($billing_info[$field_name]) && isset($billing_info[$field_name]['value']) ? $billing_info[$field_name]['value'] : null; if ($settings['sanitize'] == 'ccv') { //dont save ccv data continue; } elseif ($settings['sanitize'] == 'ccard') { $billing_info_ready_for_saving[$field_name] = EEM_Gateways::instance()->MaskCreditCard($cleaned_value); } else { //all others save normally $billing_info_ready_for_saving[$field_name] = $cleaned_value; } } $success = update_post_meta($attendee_id, 'billing_info_' . $this->_gateway_name, $billing_info_ready_for_saving); return $success; }
/** * toggle_abandoned_transaction_status * upgrades a TXNs status from failed or abandoned to incomplete * @access public * @param EE_Transaction $transaction * @return boolean */ public function toggle_abandoned_transaction_status(EE_Transaction $transaction) { // set incoming TXN_Status $this->set_old_txn_status($transaction->status_ID()); // if TXN status has not been updated already due to a payment, and is still set as "failed" or "abandoned"... if ($transaction->status_ID() == EEM_Transaction::failed_status_code || $transaction->status_ID() == EEM_Transaction::abandoned_status_code) { $this->set_new_txn_status(EEM_Transaction::incomplete_status_code); // if a contact record for the primary registrant has been created if ($transaction->primary_registration() instanceof EE_Registration && $transaction->primary_registration()->attendee() instanceof EE_Attendee) { $transaction->set_status(EEM_Transaction::incomplete_status_code); $this->set_new_txn_status(EEM_Transaction::incomplete_status_code); } else { // no contact record? yer abandoned! $transaction->set_status(EEM_Transaction::abandoned_status_code); $this->set_new_txn_status(EEM_Transaction::abandoned_status_code); } return TRUE; } return FALSE; }
/** * column_actions * @param \EE_Transaction $item * @return string */ function column_actions(EE_Transaction $item) { $registration = $item->primary_registration(); $attendee = $registration->attendee(); EE_Registry::instance()->load_helper('MSG_Template'); //Build row actions $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $item->ID()), TXN_ADMIN_URL); $dl_invoice_lnk_url = $registration->invoice_url(); $dl_receipt_lnk_url = $registration->receipt_url(); $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $registration->ID()), REG_ADMIN_URL); $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'send_payment_reminder', 'TXN_ID' => $item->ID()), TXN_ADMIN_URL); //Build row actions $view_lnk = ' <li> <a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text"> <span class="dashicons dashicons-cart"></span> </a> </li>'; //only show invoice link if message type is active. if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) { $dl_invoice_lnk = ' <li> <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '" target="_blank" href="' . $dl_invoice_lnk_url . '" class="tiny-text"> <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> </a> </li>'; } else { $dl_invoice_lnk = ''; } //only show receipt link if message type is active. if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('receipt')) { $dl_receipt_lnk = ' <li> <a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '" target="_blank" href="' . $dl_receipt_lnk_url . '" class="tiny-text"> <span class="dashicons dashicons-media-default ee-icon-size-18"></span> </a> </li>'; } else { $dl_receipt_lnk = ''; } //only show payment reminder link if the message type is active. if (EEH_MSG_Template::is_mt_active('payment_reminder')) { $send_pay_lnk = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder') ? ' <li> <a href="' . $send_pay_lnk_url . '" title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text"> <span class="dashicons dashicons-email-alt"></span> </a> </li>' : ''; $send_pay_lnk = $item->get('STS_ID') != EEM_Transaction::complete_status_code && $item->get('STS_ID') != EEM_Transaction::overpaid_status_code ? $send_pay_lnk : ''; } else { $send_pay_lnk = ''; } $view_reg_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $registration->ID()) ? ' <li> <a href="' . $view_reg_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text"> <span class="dashicons dashicons-clipboard"></span> </a> </li>' : ''; return $this->_action_string($view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk, $item, 'ul', 'txn-overview-actions-ul'); }