function event_espresso_txn() { ob_start(); global $wpdb, $org_options, $espresso_content; do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); do_action('action_hook_espresso_transaction'); $active_gateways = get_option('event_espresso_active_gateways', array()); if (empty($active_gateways)) { $subject = __('Website Payment IPN Not Setup', 'event_espresso'); $body = sprintf(__('The IPN for %s at %s has not been properly setup and is not working. Date/time %s', 'event_espresso'), $org_options['organization'], home_url(), date('g:i A')); wp_mail($org_options['contact_email'], $subject, $body); return; } /*foreach ($active_gateways as $gateway => $path) { event_espresso_require_gateway($gateway . "/init.php"); }*/ $payment_data = array('attendee_id' => NULL); $payment_data['attendee_id'] = apply_filters('filter_hook_espresso_transactions_get_attendee_id', ''); if (empty($payment_data['attendee_id'])) { echo "An error occurred. No ID or an invalid ID was supplied."; } else { $payment_data = apply_filters('filter_hook_espresso_prepare_payment_data_for_gateways', $payment_data); $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data); $payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data); if (espresso_return_reg_id() == false || $payment_data['registration_id'] != espresso_return_reg_id()) { wp_die(__('There was a problem finding your Registration ID', 'event_espresso')); } $payment_data = apply_filters('filter_hook_espresso_transactions_get_payment_data', $payment_data); espresso_log::singleton()->log(array('file' => __FILE__, 'function' => __FUNCTION__, 'status' => 'Payment for: ' . $payment_data['lname'] . ', ' . $payment_data['fname'] . '|| registration id: ' . $payment_data['registration_id'] . '|| transaction details: ' . $payment_data['txn_details'])); $payment_data = apply_filters('filter_hook_espresso_update_attendee_payment_data_in_db', $payment_data); //add and then immediately do action, so developers can modify this behavior on 'after_payment' add_action('action_hook_espresso_email_after_payment', 'espresso_email_after_payment'); do_action('action_hook_espresso_email_after_payment', $payment_data); extract($payment_data); if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "payment_overview.php")) { require_once EVENT_ESPRESSO_TEMPLATE_DIR . "payment_overview.php"; //This is the path to the template file if available } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/payment_overview.php"; } } $_REQUEST['page_id'] = $org_options['return_url']; ee_init_session(); $espresso_content = ob_get_contents(); ob_end_clean(); add_shortcode('ESPRESSO_TXN_PAGE', 'espresso_return_espresso_content'); return $espresso_content; }
function espresso_do_log_entry($file, $function, $message) { espresso_log::singleton()->log(array('file' => $file, 'function' => $function, 'status' => $message)); }
function event_espresso_pay() { do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); global $wpdb, $org_options; $payment_data = array('attendee_id' => ''); $active_gateways = get_option('event_espresso_active_gateways', array()); foreach ($active_gateways as $gateway => $path) { event_espresso_require_gateway($gateway . "/init.php"); } $payment_data['attendee_id'] = apply_filters('filter_hook_espresso_transactions_get_attendee_id', $payment_data['attendee_id']); $REG_ID = espresso_return_reg_id(); if ($REG_ID != false && empty($payment_data['attendee_id'])) { $SQL = "SELECT id FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id='" . $REG_ID . "' ORDER BY id LIMIT 1"; $payment_data['attendee_id'] = $wpdb->get_var($wpdb->prepare($SQL, NULL)); $payment_data = apply_filters('filter_hook_espresso_prepare_payment_data_for_gateways', $payment_data); $payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data); $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data); } elseif (!empty($payment_data['attendee_id'])) { $payment_data = apply_filters('filter_hook_espresso_prepare_payment_data_for_gateways', $payment_data); $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data); $payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data); if ($REG_ID == false || $payment_data['registration_id'] != $REG_ID) { wp_die(__('There was a problem finding your Registration ID', 'event_espresso')); } if ($payment_data['payment_status'] != 'Completed') { $payment_data = apply_filters('filter_hook_espresso_thank_you_get_payment_data', $payment_data); $payment_details = array('file' => __FILE__, 'function' => __FUNCTION__, 'status' => 'Payment for: ' . $payment_data['lname'] . ', ' . $payment_data['fname'] . '|| attendee_session id: ' . $payment_data['attendee_session'] . '|| registration id: ' . $payment_data['registration_id'] . '|| transaction details: ' . $payment_data['txn_details']); espresso_log::singleton()->log($payment_details); $payment_data = apply_filters('filter_hook_espresso_update_attendee_payment_data_in_db', $payment_data); do_action('action_hook_espresso_email_after_payment', $payment_data); } } if (!empty($payment_data['attendee_id'])) { extract($payment_data); //printr( $payment_data, '$payment_data <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "payment_overview.php")) { require_once EVENT_ESPRESSO_TEMPLATE_DIR . "payment_overview.php"; //This is the path to the template file if available } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/payment_overview.php"; } if ($payment_status != "Completed") { echo '<a name="payment_options" id="payment_options"></a>'; if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "return_payment.php")) { require_once EVENT_ESPRESSO_TEMPLATE_DIR . "return_payment.php"; //This is the path to the template file if available } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/return_payment.php"; } } } $_REQUEST['page_id'] = $org_options['return_url']; unset($_SESSION['espresso_session']['id']); ee_init_session(); }
function event_espresso_pay() { ob_start(); do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); global $wpdb, $org_options, $espresso_content; $payment_data = array('attendee_id' => ''); $payment_data['attendee_id'] = apply_filters('filter_hook_espresso_transactions_get_attendee_id', $payment_data['attendee_id']); $REG_ID = espresso_return_reg_id(); if ($REG_ID != false && empty($payment_data['attendee_id'])) { //we're assuming there is NO payment data in this request, so we'll just //prepare the $payment_data for display only. No processing of payment etc. $SQL = "SELECT id FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id='" . $REG_ID . "' ORDER BY id LIMIT 1"; $payment_data['attendee_id'] = $wpdb->get_var($wpdb->prepare($SQL, NULL)); $payment_data = apply_filters('filter_hook_espresso_prepare_payment_data_for_gateways', $payment_data); $payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data); $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data); } elseif (!empty($payment_data['attendee_id'])) { $payment_data = apply_filters('filter_hook_espresso_prepare_payment_data_for_gateways', $payment_data); $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data); $payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data); if ($REG_ID == false || $payment_data['registration_id'] != $REG_ID) { wp_die(__('There was a problem finding your Registration ID', 'event_espresso')); } if ($payment_data['amount_owed'] > 0.0 && $payment_data['payment_status'] != 'Refund') { $payment_data = apply_filters('filter_hook_espresso_thank_you_get_payment_data', $payment_data); $payment_details = array('file' => __FILE__, 'function' => __FUNCTION__, 'status' => 'Payment for: ' . $payment_data['lname'] . ', ' . $payment_data['fname'] . '|| attendee_session id: ' . $payment_data['attendee_session'] . '|| registration id: ' . $payment_data['registration_id'] . '|| transaction details: ' . $payment_data['txn_details']); espresso_log::singleton()->log($payment_details); $payment_data = apply_filters('filter_hook_espresso_update_attendee_payment_data_in_db', $payment_data); add_action('action_hook_espresso_email_after_payment', 'espresso_email_after_payment'); do_action('action_hook_espresso_email_after_payment', $payment_data); } } if (!empty($payment_data['attendee_id'])) { extract($payment_data); //printr( $payment_data, '$payment_data <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "payment_overview.php")) { require_once EVENT_ESPRESSO_TEMPLATE_DIR . "payment_overview.php"; //This is the path to the template file if available } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/payment_overview.php"; } if ($payment_status != "Completed") { echo '<a name="payment_options" id="payment_options"></a>'; if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "return_payment.php")) { require_once EVENT_ESPRESSO_TEMPLATE_DIR . "return_payment.php"; //This is the path to the template file if available } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/return_payment.php"; } } } if (isset($payment_data['attendee_session'])) { event_espresso_clear_session_of_attendee($payment_data['attendee_session']); } $_REQUEST['page_id'] = $org_options['return_url']; $espresso_content = ob_get_contents(); ob_end_clean(); add_shortcode('ESPRESSO_PAYMENTS', 'espresso_return_espresso_content'); return $espresso_content; }
/** * handles payment IPN info from google just like it would be handled in the * transactiosn shortcode, but this function should be hoooked to the plugins_loaded * hook, thus executing much before any other output is generated. * This is necessary because google requires us to send a very specific xml resposne * to their ipn, not html (which is what we'd ahve to return if this were called * during a shortcode) * @return type */ function espresso_google_run_transaction_code_before_shortcode() { if (array_key_exists('type', $_REQUEST) && array_key_exists('ipn', $_REQUEST) && $_REQUEST['type'] == 'google_checkout' && $_REQUEST['ipn'] == 'true') { event_espresso_require_gateway("process_payments.php"); $payment_data['attendee_id'] = apply_filters('filter_hook_espresso_transactions_get_attendee_id', ''); if (isset($payment_data['attendee_id'])) { $payment_data = apply_filters('filter_hook_espresso_prepare_payment_data_for_gateways', $payment_data); $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data); $payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data); if (espresso_return_reg_id() == false || $payment_data['registration_id'] != espresso_return_reg_id()) { return; } $payment_data = espresso_process_google_checkout_ipn($payment_data); $payment_data['txn_details'] = serialize($_REQUEST); espresso_log::singleton()->log(array('file' => __FILE__, 'function' => __FUNCTION__, 'status' => 'Payment for: ' . $payment_data['lname'] . ', ' . $payment_data['fname'] . '|| registration id: ' . $payment_data['registration_id'] . '|| transaction details: ' . $payment_data['txn_details'])); $payment_data = apply_filters('filter_hook_espresso_update_attendee_payment_data_in_db', $payment_data); //add_action('action_hook_espresso_email_after_payment', 'espresso_email_after_payment');//this line shouldn't be necessary because ofa refactor I did where this //is added process_payments file, but apparently it hasn't gotten integrated into trunk yet... do_action('action_hook_espresso_email_after_payment', $payment_data); die; } } }