function espresso_display_wepay($payment_data) { extract($payment_data); // Setup class if (empty($event_name)) { $event_name = "Event number #" . $event_id; } include_once 'Wepay.php'; echo '<!-- Event Espresso WePay Gateway Version ' . Espresso_Wepay::$version . '-->'; $wepay_settings = get_option('event_espresso_wepay_settings'); global $org_options; if ($wepay_settings['use_sandbox']) { Espresso_Wepay::useStaging($wepay_settings['wepay_client_id'], $wepay_settings['wepay_client_secret']); } else { Espresso_Wepay::useProduction($wepay_settings['wepay_client_id'], $wepay_settings['wepay_client_secret']); } $quantity = isset($quantity) && $quantity > 0 ? $quantity : espresso_count_attendees_for_registration($attendee_id); $fields['account_id'] = $wepay_settings['account_id']; $fields['short_description'] = stripslashes_deep($event_name); $fields['long_description'] = stripslashes_deep($event_name) . ' | ' . __('Name:', 'event_espresso') . ' ' . stripslashes_deep($fname . ' ' . $lname) . ' | ' . __('Registrant Email:', 'event_espresso') . ' ' . $attendee_email . ' | ' . __('Total Registrants:', 'event_espresso') . ' ' . $quantity; $fields['type'] = 'SERVICE'; $fields['reference_id'] = $attendee_id; $fields['amount'] = number_format($event_cost, 2, '.', ''); $fields['redirect_uri'] = add_query_arg(array('id' => $attendee_id, 'r_id' => $registration_id, 'event_id' => $event_id, 'attendee_action' => 'post_payment', 'form_action' => 'payment', 'type' => 'wepay'), get_permalink($org_options['return_url'])); $fields['callback_uri'] = add_query_arg(array('id' => $attendee_id, 'r_id' => $registration_id, 'event_id' => $event_id, 'attendee_action' => 'post_payment', 'form_action' => 'payment', 'type' => 'wepay'), get_permalink($org_options['notify_url'])); // $fields['redirect_uri'] = $home . '/?page_id=' . $org_options['return_url'] . '&id=' . $attendee_id . '&r_id=' . $registration_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment&type=wepay'; // $fields['callback_uri'] = $home . '/?page_id=' . $org_options['notify_url'] . '&id=' . $attendee_id . '&r_id=' . $registration_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment&type=wepay'; if ($wepay_settings['force_ssl_return']) { $fields['redirect_uri'] = str_replace("http://", "https://", $fields['redirect_uri']); $fields['callback_uri'] = str_replace("http://", "https://", $fields['callback_uri']); } if (empty($wepay_settings['access_token'])) { return; } try { $wepay = new Espresso_Wepay($wepay_settings['access_token']); $raw = $wepay->request('checkout/create', $fields); } catch (Exception $e) { printf(__("WePay seems to be misconfigured. Error: %s", "event_espresso"), $e->getMessage()); return; } if (empty($raw->checkout_uri)) { return; } $uri = $raw->checkout_uri; if ($wepay_settings['bypass_payment_page'] == 'Y') { $wepay->submitPayment($uri); //Enable auto redirect to payment site } else { $wepay->submitButton($uri, $wepay_settings['button_url'], 'wepay'); //Display payment button wp_deregister_script('jquery.validate.pack'); } if ($wepay_settings['use_sandbox']) { echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $wepay->dump_fields($fields); // for debugging, output a table of all the fields } }
function espresso_display_wepay($payment_data) { extract($payment_data); // Setup class include_once 'Wepay.php'; echo '<!-- Event Espresso Wepay Gateway Version ' . Wepay::$version . '-->'; $wepay_settings = get_option('event_espresso_wepay_settings'); global $org_options; if ($wepay_settings['use_sandbox']) { Wepay::useStaging($wepay_settings['wepay_client_id'], $wepay_settings['wepay_client_secret']); } else { Wepay::useProduction($wepay_settings['wepay_client_id'], $wepay_settings['wepay_client_secret']); } $quantity = isset($quantity) && $quantity > 0 ? $quantity : espresso_count_attendees_for_registration($attendee_id); $fields['account_id'] = $wepay_settings['account_id']; $fields['short_description'] = stripslashes_deep($event_name); $fields['long_description'] = stripslashes_deep($event_name) . ' | ' . __('Name:', 'event_espresso') . ' ' . stripslashes_deep($fname . ' ' . $lname) . ' | ' . __('Registrant Email:', 'event_espresso') . ' ' . $attendee_email . ' | ' . __('Total Registrants:', 'event_espresso') . ' ' . $quantity; $fields['type'] = 'SERVICE'; $fields['reference_id'] = $attendee_id; $fields['amount'] = number_format($event_cost, 2, '.', ''); $fields['redirect_uri'] = home_url() . '/?page_id=' . $org_options['return_url'] . '&id=' . $attendee_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment'; $fields['callback_uri'] = home_url() . '/?page_id=' . $org_options['notify_url'] . '&id=' . $attendee_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment'; if (empty($wepay_settings['access_token'])) { return; } $wepay = new Wepay($wepay_settings['access_token']); $raw = $wepay->request('checkout/create', $fields); if (empty($raw->checkout_uri)) { return; } $uri = $raw->checkout_uri; if ($wepay_settings['bypass_payment_page'] == 'Y') { $wepay->submitPayment($uri); //Enable auto redirect to payment site } else { $wepay->submitButton($uri, $wepay_settings['button_url'], 'wepay'); //Display payment button wp_deregister_script('jquery.validate.pack'); } if ($wepay_settings['use_sandbox']) { echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $wepay->dump_fields($fields); // for debugging, output a table of all the fields } }
function espresso_display_exact($payment_data) { extract($payment_data); // Setup class include_once 'Exact.php'; global $org_options; $myExact = new Espresso_Exact(); // initiate an instance of the class echo '<!--Event Espresso Exact.com Gateway Version ' . $myExact->gateway_version . '-->'; $exact_settings = get_option('event_espresso_exact_settings'); $exact_login_id = empty($exact_settings['exact_login_id']) ? '' : $exact_settings['exact_login_id']; $exact_transaction_key = empty($exact_settings['exact_transaction_key']) ? '' : $exact_settings['exact_transaction_key']; $button_type = empty($exact_settings['button_type']) ? '' : $exact_settings['button_type']; //$button_url = $exact_settings['button_url']; $image_url = empty($exact_settings['image_url']) ? '' : $exact_settings['image_url']; $use_sandbox = $exact_settings['use_sandbox']; $use_testmode = $exact_settings['test_transactions']; if ($use_testmode == true) { // Enable test mode if needed $myExact->enableTestMode(); } if ($use_sandbox) { // Enable test mode if needed $myExact->useTestServer(); } $quantity = isset($quantity) && $quantity > 0 ? $quantity : espresso_count_attendees_for_registration($attendee_id); $myExact->setUserInfo($exact_login_id, $exact_transaction_key); $myExact->addField('x_amount', number_format($event_cost, 2)); $myExact->addField('x_show_form', 'PAYMENT_FORM'); $myExact->addField('x_reference_3', $registration_id . '|exact'); $myExact->addField('x_relay_response', 'TRUE'); if ($exact_settings['force_ssl_return']) { $home = str_replace("http://", "https://", home_url()); } else { $home = home_url(); } $myExact->addField('x_relay_url', $home . '/?type=exact&page_id=' . $org_options['return_url']); $myExact->addField('x_description', stripslashes_deep($event_name) . ' | ' . __('Reg. ID:', 'event_espresso') . ' ' . $attendee_id . ' | ' . __('Name:', 'event_espresso') . ' ' . stripslashes_deep($fname . ' ' . $lname) . ' | ' . __('Total Registrants:', 'event_espresso') . ' ' . $quantity); $myExact->addField('x_logo_url', $image_url); $myExact->addField('x_invoice_num', event_espresso_session_id()); //Post variables $myExact->addField('x_cust_id', $attendee_id); $myExact->addField('x_first_name', $fname); $myExact->addField('x_last_name', $lname); $myExact->addField('x_email', $attendee_email); $myExact->addField('x_address', $address); $myExact->addField('x_city', $city); $myExact->addField('x_state', $state); $myExact->addField('x_zip', $zip); $myExact->addField('x_fp_sequence', $attendee_id); //Enable this function if you want to send payment notification before the person has paid. //This function is copied on the payment processing page //event_espresso_send_payment_notification($attendee_id, $txn_id, $amount_pd); //Decide if you want to auto redirect to your payment website or display a payment button. if (!empty($exact_settings['bypass_payment_page']) && $exact_settings['bypass_payment_page'] == 'Y') { $myExact->submitPayment(); //Enable auto redirect to payment site } else { if (empty($exact_settings['button_url'])) { //$button_url = EVENT_ESPRESSO_GATEWAY_URL . "exact/exact-logo.png"; if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "/exact/exact-logo.png")) { $button_url = EVENT_ESPRESSO_GATEWAY_DIR . "/exact/exact-logo.png"; } else { $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/exact/exact-logo.png"; } } elseif (file_exists($exact_settings['button_url'])) { $button_url = $exact_settings['button_url']; } else { //If no other buttons exist, then use the default location $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/exact/exact-logo.png"; } $myExact->submitButton($button_url, 'exact'); //Display payment button } if ($use_sandbox) { echo '<p>Test credit card # 4007000000027</p>'; echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $myExact->dump_fields(); // for debugging, output a table of all the fields } }
function espresso_display_nab($payment_data) { include_once 'Nab.php'; $mynab = new Espresso_nab(); // initiate an instance of the class global $org_options; do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); $nab_result_url = home_url() . '/?page_id=' . $org_options['return_url'] . '&id=' . $payment_data['attendee_id'] . '&r_id=' . $payment_data['registration_id'] . '&event_id=' . $payment_data['event_id'] . '&attendee_action=post_payment&form_action=payment&type=nab'; $nab_settings = get_option('event_espresso_nab_settings'); $nab_id = $nab_settings['nab_merchant_id']; $nab_pass = $nab_settings['nab_merchant_password']; $use_sandbox = $nab_settings['nab_use_sandbox']; $temp_timezone_holder = date_default_timezone_get(); date_default_timezone_set('UTC'); $timestamp = date('YmdHis'); date_default_timezone_set($temp_timezone_holder); if ($use_sandbox == 1) { $nab_post_url = "https://transact.nab.com.au/test/directpost/authorise"; } else { $nab_post_url = "https://transact.nab.com.au/live/directpost/authorise"; } $quantity = isset($quantity) && $quantity > 0 ? $quantity : espresso_count_attendees_for_registration($payment_data['attendee_id']); $mynab->addField('EPS_MERCHANT', $nab_id); $mynab->addField('EPS_PASSWORD', $nab_pass); $mynab->addField('EPS_REFERENCEID', $payment_data['registration_id']); $mynab->addField('EPS_AMOUNT', number_format($payment_data['event_cost'], 2, '.', '')); $mynab->addField('EPS_TIMESTAMP', $timestamp); ?> <div id="nab-payment-option-dv" class="payment-option-dv"> <a id="nab-payment-option-lnk" class="payment-option-lnk display-the-hidden" rel="nab-payment-option-form" style="cursor:pointer;"> <img alt="Pay using a Credit Card" src="<?php echo EVENT_ESPRESSO_PLUGINFULLURL; ?> gateways/pay-by-credit-card.png"> </a> <div id="nab-payment-option-form-dv" class="hide-if-js"> <div class = "event_espresso_form_wrapper"> <form method="post" action="<?php echo $nab_post_url; ?> "> <input type="hidden" name="EPS_MERCHANT" value="<?php echo $nab_id; ?> "> <input type="hidden" name="EPS_PASSWORD" value="<?php echo $nab_pass; ?> "> <input type="hidden" name="EPS_REFERENCEID" value="<?php echo $payment_data['registration_id']; ?> "> <input type="hidden" name="EPS_AMOUNT" value="<?php echo number_format($payment_data['event_cost'], 2, '.', ''); ?> "> <input type="hidden" name="EPS_TIMESTAMP" value="<?php echo $timestamp; ?> "> <input type="hidden" name="EPS_FINGERPRINT" value="<?php echo $mynab->prepareSubmit(); ?> "> <input type="hidden" name="EPS_RESULTURL" value="<?php echo $nab_result_url; ?> "> <input type="hidden" name="EPS_FIRSTNAME" value="<?php echo $payment_data['fname']; ?> "> <input type="hidden" name="EPS_LASTNAME" value="<?php echo $payment_data['lname']; ?> "> <input type="hidden" name="EPS_ZIPCODE" value="<?php echo $payment_data['zip']; ?> "> <input type="hidden" name="EPS_TOWN" value="<?php echo $payment_data['city']; ?> "> <input type="hidden" name="EPS_EMAILADDRESS" value="<?php echo $payment_data['attendee_email']; ?> "> <fieldset id="nab-billing-info-dv"> <h4 class="section-title"><?php _e('Credit Card Information', 'event_espresso'); ?> </h4> <p> <label for="EPS_CARDTYPE"><?php _e('Card Type:', 'event_espresso'); ?> </label> <select name="EPS_CARDTYPE" class="inputbox" style="width:167px"> <option value="visa"><?php _e('Visa', 'event_espresso'); ?> </option> <option value="mastercard"><?php _e('MasterCard', 'event_espresso'); ?> </option> <option value="amex"><?php _e('Amex', 'event_espresso'); ?> </option> </select> </p> <p> <label for="EPS_CARDNUMBER"><?php _e('Card Number:', 'event_espresso'); ?> </label> <input type="text" class="inputbox" name="EPS_CARDNUMBER" size="27" autocomplete="off"/> </p> <p> <label for="EPS_CCV"><?php _e('Card CCV:', 'event_espresso'); ?> </label> <input type="text" class="inputbox" name="EPS_CCV" size="27" autocomplete="off" /> </p> <p> <label for="EPS_EXPIRYMONTH"><?php _e('Card Expires:', 'event_espresso'); ?> </label> <select name="EPS_EXPIRYMONTH" class="inputbox"> <option value="">- <?php _e('Month', 'event_espresso'); ?> -</option> <option value="1">01</option> <option value="2">02</option> <option value="3">03</option> <option value="4">04</option> <option value="5">05</option> <option value="6">06</option> <option value="7">07</option> <option value="8">08</option> <option value="9">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> <select name="EPS_EXPIRYYEAR" class="inputbox"> <option value="">- <?php _e('Year', 'event_espresso'); ?> -</option> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> <option value="2021">2021</option> <option value="2022">2022</option> <option value="2023">2023</option> <option value="2024">2024</option> <option value="2025">2025</option> </select> </p> <p class="event_form_submit"> <input type="submit" value="<?php _e('Complete Purchase', 'event_espresso'); ?> " class="submit-payment-btn"/> </p> </fieldset> </form> <?php wp_deregister_script('jquery.validate.pack'); if ($use_sandbox == true) { echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $mynab->dump_fields(); } ?> <br/> <p class="choose-diff-pay-option-pg"> <a class="hide-the-displayed" rel="nab-payment-option-form" style="cursor:pointer;"><?php _e('Choose a different payment option', 'event_espresso'); ?> </a> </p> </div> </div> </div> <?php }
function event_espresso_add_attendees_to_db_multi() { global $wpdb, $org_options; //Added by Imon $primary_registration_id = NULL; $events_in_session = $_SESSION['espresso_session']['events_in_session']; if (event_espresso_invoke_cart_error($events_in_session)) { return false; } $count_of_events = count($events_in_session); $current_session_id = $_SESSION['espresso_session']['id']; //Debug //echo "<pre>", print_r($_SESSION), "</pre>"; //echo '<pre>'.print_r($_POST, true).'</pre>'; //echo "<pre>", print_r($events_in_session), "</pre>"; //echo "<pre>", print_r($org_options), "</pre>"; $event_name = $count_of_events . ' ' . $org_options['organization'] . __(' events', 'event_espresso'); $event_cost = $_SESSION['espresso_session']['grand_total']; $multi_reg = true; // If there are events in the session, add them one by one to the attendee table if ($count_of_events > 0) { //first event key will be used to find the first attendee $first_event_id = key($events_in_session); //Debug //echo '<pre>$events_in_session - '.print_r($events_in_session, true).'</pre>'; reset($events_in_session); foreach ($events_in_session as $key => $_event_id) { //Debug //echo '<p>$_event_id - '. $_event_id.'</p>'; //echo '<pre>'.print_r($_event_id, true).'</pre>'; $event_meta = event_espresso_get_event_meta($key); $event_attendees = $_event_id['event_attendees']; $session_vars['data'] = $_event_id; //Debug //echo '<p>$_event_id - '. $_event_id.'</p>'; //echo '<pre>'.print_r($session_vars['data'], true).'</pre>'; if (is_array($event_attendees)) { $counter = 1; foreach ($event_attendees as $k_price_id => $v_attendees) { //foreach price type in event attendees $session_vars['data'] = $_event_id; //Debug //echo '<pre>$session_vars[\'data\' - ]'.print_r($session_vars['data'], true).'</pre>'; foreach ($v_attendees as $vkey => $vval) { //Added by Imon $vval['price_id'] = $k_price_id; $session_vars['event_attendees'] = $vval; //this has all the attendee information, name, questions.... $session_vars['data']['price_type'] = $_event_id['price_id'][$k_price_id]['price_type']; if (isset($event_meta['additional_attendee_reg_info']) && $event_meta['additional_attendee_reg_info'] == 1) { //Getting he wrong number of attendees at this point //Debug //echo '<p>$_REQUEST[\'num_people\'] - '.$_REQUEST['num_people'].'</p>'; //echo '<p>$_event_id[\'price_id\'][$k_price_id] - '.$_event_id['price_id'][$k_price_id].'</p>'; //echo '<pre>$_event_id[\'price_id\'][$k_price_id] - '.print_r($_event_id['price_id'][$k_price_id]['attendee_quantity'], true).'</pre>'; //echo '<pre>'.print_r($_POST, true).'</pre>'; $num_people = $_event_id['price_id'][$k_price_id]['attendee_quantity']; $session_vars['data']['num_people'] = empty($num_people) || $num_people == 0 ? 1 : $num_people; //Debug //echo '<p>$session_vars[\'data\'][\'num_people\'] - '.$session_vars['data']['num_people'].'</p>'; } //Debug /* echo $key.'<br />'; echo '<pre>$session_vars - '.print_r($session_vars, true).'</pre>'; echo '<br />'; */ $tmp_registration_id = event_espresso_add_attendees_to_db($key, $session_vars); //Debug //echo 'tmp_registration_id =' . $tmp_registration_id.'<br />'; if ($primary_registration_id === NULL) { $primary_registration_id = $tmp_registration_id; } $c2_sql = "select * from " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " where primary_registration_id = '{$primary_registration_id}' and registration_id = '{$tmp_registration_id}'"; //Debug //echo $c2_sql.'<br />'; $check = $wpdb->get_row($c2_sql); if ($check === NULL) { $tmp_data = array("primary_registration_id" => $primary_registration_id, "registration_id" => $tmp_registration_id); $wpdb->insert(EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE, $tmp_data); } } $counter++; } } } //Post the gateway page with the payment options if ($event_cost != '0.00') { //find first registrant's name, email, count of registrants $sql = "SELECT id, fname, lname, email, address, city, state, zip, event_id, registration_id,\n\t\t\t\t\t\t(SELECT count( id )\n\t\t\t\t\t\t\tFROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session = '" . $wpdb->escape($current_session_id) . "'\n\t\t\t\t\t\t\t) AS quantity\n\t\t\t\t\t\t\tFROM " . EVENTS_ATTENDEE_TABLE . " WHERE event_id = " . $wpdb->escape($first_event_id) . " AND attendee_session = '" . $wpdb->escape($current_session_id) . "' LIMIT 1"; //echo $sql; $r = $wpdb->get_row($sql); $event_id = $r->event_id; $attendee_id = $r->id; $fname = $r->fname; $lname = $r->lname; $address = $r->address; $city = $r->city; $state = $r->state; $zip = $r->zip; $attendee_email = $r->email; $registration_id = $r->registration_id; $quantity = espresso_count_attendees_for_registration($r->registration_id); ?> <?php /* //removing edit links for now...will fix edit attendee page in 3.2 cb #830 <a href="?page_id=<?php echo $org_options['event_page_id']; ?>®event_action=show_shopping_cart"> <?php _e('Edit Cart', 'event_espresso'); ?> </a> <?php _e(' or ', 'event_espresso'); ?> <a href="?page_id=<?php echo $org_options['event_page_id']; ?>®event_action=load_checkout_page"> <?php _e('Edit Registrant Information', 'event_espresso'); ?></a> */ ?> <h3><?php _e('Your registration is not complete until payment is received.', 'event_espresso'); ?> </h3> <p><strong class="event_espresso_name"> <?php _e('Amount due: ', 'event_espresso'); ?> </strong> <span class="event_espresso_value"><?php echo $org_options['currency_symbol']; echo $event_cost; ?> </span></p> <p><?php echo $org_options['email_before_payment'] == 'Y' ? __('A confirmation email has been sent with additional details of your registration.', 'event_espresso') : ''; ?> </p> <?php //Show payment options if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "gateway_display.php")) { require_once EVENT_ESPRESSO_GATEWAY_DIR . "gateway_display.php"; } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "gateways/gateway_display.php"; } //Check to see if the site owner wants to send an confirmation eamil before payment is recieved. if ($org_options['email_before_payment'] == 'Y') { event_espresso_email_confirmations(array('session_id' => $_SESSION['espresso_session']['id'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true', 'multi_reg' => true)); } } else { ?> <p><?php _e('Thank you! Your registration is confirmed for', 'event_espresso'); ?> <strong><?php echo stripslashes_deep($event_name); ?> </strong></p> <p><?php _e('A confirmation email has been sent with additional details of your registration.', 'event_espresso'); ?> </p> <?php event_espresso_email_confirmations(array('session_id' => $_SESSION['espresso_session']['id'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true', 'multi_reg' => true)); event_espresso_clear_session(); } } }
function events_payment_page($attendee_id, $price_id = 0, $coupon_code = '', $groupon_code = '') { global $wpdb, $org_options, $simpleMath; $today = date("m-d-Y"); $num_people = 0; $Organization = $org_options['organization']; $Organization_street1 = $org_options['organization_street1']; $Organization_street2 = $org_options['organization_street2']; $Organization_city = $org_options['organization_city']; $Organization_state = $org_options['organization_state']; $Organization_zip = $org_options['organization_zip']; $contact = $org_options['contact_email']; $registrar = $org_options['contact_email']; $currency_format = getCountryFullData($org_options['organization_country']); $message = $org_options['message']; $return_url = $org_options['return_url']; $cancel_return = $org_options['cancel_return']; $notify_url = $org_options['notify_url']; $event_page_id = $org_options['event_page_id']; $attendees = $wpdb->get_results("SELECT * FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id ='" . $attendee_id . "'"); foreach ($attendees as $attendee) { //$attendee_id = $attendee->id; $attendee_last = $attendee->lname; $attendee_first = $attendee->fname; $attendee_address = $attendee->address; $attendee_address2 = $attendee->address2; $attendee_city = $attendee->city; $attendee_state = $attendee->state; $attendee_zip = $attendee->zip; $attendee_email = $attendee->email; //$attendee_organization_name = $attendee->organization_name; //$attendee_country = $attendee->country_id; $phone = $attendee->phone; $attendee_phone = $attendee->phone; $date = $attendee->date; $quantity = $attendee->quantity; $payment_status = $attendee->payment_status; $txn_type = $attendee->txn_type; //$event_cost = $attendee->amount_pd; $payment_date = $attendee->payment_date; $event_id = $attendee->event_id; $registration_id = $attendee->registration_id; } //$event_meta = event_espresso_get_event_meta($event_id); //Get the questions for the attendee $questions = $wpdb->get_results("SELECT ea.answer, eq.question\n\t\t\t\t\t\tFROM " . EVENTS_ANSWER_TABLE . " ea\n\t\t\t\t\t\tLEFT JOIN " . EVENTS_QUESTION_TABLE . " eq ON eq.id = ea.question_id\n\t\t\t\t\t\tWHERE ea.attendee_id = '" . $attendee_id . "' and eq.admin_only = 'N' ORDER BY eq.sequence asc "); //echo $wpdb->last_query; $display_questions = ''; foreach ($questions as $question) { $display_questions .= '<p>' . $question->question . ':<br /> ' . str_replace(',', '<br />', $question->answer) . '</p>'; } $num_peoplea = $wpdb->get_results("SELECT COUNT(registration_id) FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id ='" . $registration_id . "'", ARRAY_N); $num_people = $num_peoplea[0][0]; //If we are using the number of attendees dropdown, and if ($quantity > 1) { $num_people = $quantity; } $events = $wpdb->get_results("SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE id ='" . $event_id . "'"); foreach ($events as $event) { //$event_id = $event->id; $event_name = stripslashes_deep($event->event_name); $event_desc = stripslashes_deep($event->event_desc); $event_description = stripslashes_deep($event->event_desc); $event_identifier = $event->event_identifier; $send_mail = $event->send_mail; $active = $event->is_active; $conf_mail = $event->conf_mail; //$alt_email = $event->alt_email; //This is used to get the alternate email address that a payment can be made to using PayPal if (function_exists('event_espresso_coupon_payment_page')) { $use_coupon_code = $event->use_coupon_code; } if (function_exists('event_espresso_groupon_payment_page')) { $use_groupon_code = $event->use_groupon_code; } } $attendee_name = stripslashes_deep($attendee_first . ' ' . $attendee_last); //Figure out if the person has registered using a price selection if (!empty($_REQUEST['price_select']) && $_REQUEST['price_select'] == true) { $price_options = explode('|', $_REQUEST['price_option'], 2); $price_id = $price_options[0]; $price_type = $price_options[1]; $p_id = $price_id; $event_cost = event_espresso_get_final_price($price_id, $event_id); } elseif ($price_id > 0) { $event_cost = event_espresso_get_final_price($price_id, $event_id); $p_id = $price_id; } else { //$event_cost = $_POST['event_cost']; $event_cost = event_espresso_get_final_price($_POST['price_id'], $event_id); $p_id = $_POST['price_id']; } //Test the early discount amount to make sure we are getting the right amount //print_r(early_discount_amount($event_id, $event_cost)); $event_price = number_format($event_cost, 2, '.', ''); $event_price_x_attendees = number_format($event_cost * $num_people, 2, '.', ''); $event_original_cost = number_format($simpleMath->multiply($event_cost, $num_people), 2, '.', ''); /* * Added for seating chart addon */ /* * This code block overrides the cost using seating chart add-on price */ if (defined('ESPRESSO_SEATING_CHART')) { if (seating_chart::check_event_has_seating_chart($event_id) !== false) { $sc_cost_row = $wpdb->get_row("select sum(sces.purchase_price) as purchase_price from " . EVENTS_SEATING_CHART_EVENT_SEAT_TABLE . " sces inner join " . EVENTS_ATTENDEE_TABLE . " ea on sces.attendee_id = ea.id where ea.registration_id = '{$registration_id}'"); if ($sc_cost_row !== NULL) { $event_cost = number_format($sc_cost_row->purchase_price, 2, '.', ''); $event_original_cost = $event_cost; $event_price_x_attendees = $event_cost; } } } /* * End seating chart addon */ if (function_exists('event_espresso_coupon_payment_page') && (!empty($_REQUEST['coupon_code']) || !empty($coupon_code))) { $event_cost = event_espresso_coupon_payment_page($use_coupon_code, $event_id, $event_original_cost, $attendee_id, $num_people); /* * at this point , the $event_cost is correct * The next line divided by the number of people and reassigned it to the same $even_cost var, making the event cost less * I renamed it to another variable */ $event_price_x_attendees = number_format($event_cost, 2, '.', ''); $coupon_code = $_REQUEST['coupon_code']; } else { if (function_exists('event_espresso_groupon_payment_page') && ($_REQUEST['groupon_code'] != '' || $coupon_code != '')) { $event_cost = event_espresso_groupon_payment_page($use_groupon_code, $event_id, $event_original_cost, $attendee_id); $groupon_code = $_REQUEST['groupon_code']; } else { $event_cost = $event_original_cost; } } if ($num_people != 0) { $event_individual_cost = number_format($event_cost / $num_people, 2, '.', ''); } $event_discount_label = $event_original_cost > $event_cost ? ' (' . __('Discount of ', 'event_espresso') . $org_options['currency_symbol'] . number_format($event_original_cost - $event_cost, 2, ".", ",") . __(' applied', 'event_espresso') . ')' : ''; if ($event_cost == '0.00') { $event_cost = '0.00'; $payment_status = 'Completed'; $sql = array('amount_pd' => $event_cost, 'payment_status' => $payment_status, 'payment_date' => $today); $sql_data = array('%s', '%s', '%s'); } else { $sql = array('amount_pd' => $event_cost, 'payment_status' => $payment_status); $sql_data = array('%s', '%s'); } //Add the cost and payment status to the attendee $update_id = array('id' => $attendee_id); $wpdb->update(EVENTS_ATTENDEE_TABLE, $sql, $update_id, $sql_data, array('%d')); //If this is a group registration, we need to make sure all attendees have the same payment status if (espresso_count_attendees_for_registration($attendee_id) > 1) { $wpdb->query("UPDATE " . EVENTS_ATTENDEE_TABLE . " SET payment_status = '{$payment_status}' WHERE registration_id ='" . $registration_id . "'"); } $display_cost = $event_cost != "0.00" ? $org_options['currency_symbol'] . $event_individual_cost : __('Free', 'event_espresso'); //Pull in the template if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "confirmation_display.php")) { require_once EVENT_ESPRESSO_TEMPLATE_DIR . "confirmation_display.php"; //This is the path to the template file if available } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/confirmation_display.php"; } }
function espresso_display_eway($payment_data) { extract($payment_data); // Setup class include_once 'Eway.php'; echo '<!-- Event Espresso eway Gateway Version ' . $eway_gateway_version . '-->'; $myeway = new eway(); // initiate an instance of the class global $org_options; //global $attendee_id; $eway_settings = get_option('event_espresso_eway_settings'); $eway_id = $eway_settings['eway_id']; $eway_username = $eway_settings['eway_username']; //$image_url = $eway_settings['button_url']; $eway_cur = $eway_settings['currency_format']; $use_sandbox = $eway_settings['use_sandbox']; $quantity = isset($quantity) && $quantity > 0 ? $quantity : espresso_count_attendees_for_registration($attendee_id); if ($use_sandbox) { // Enable test mode if needed $myeway->enableTestMode(); $myeway->addField('CustomerID', '87654321'); $myeway->addField('UserName', 'TestAccount'); } else { $myeway->addField('CustomerID', $eway_id); $myeway->addField('UserName', $eway_username); } $myeway->addField('Amount', number_format($event_cost, 2, '.', '')); $myeway->addField('Currency', $eway_cur); $myeway->addField('PageTitle', ''); $myeway->addField('PageDescription', ''); $myeway->addField('PageFooter', ''); $myeway->addField('Language', ''); $myeway->addField('CompanyName', str_replace("&", "%26", $org_options['organization'])); $myeway->addField('CustomerFirstName', $fname); $myeway->addField('CustomerLastName', $lname); $myeway->addField('CustomerAddress', $address); $myeway->addField('CustomerCity', $city); $myeway->addField('CustomerState', $state); $myeway->addField('CustomerPostCode', $zip); $myeway->addField('CustomerCountry', ''); $myeway->addField('CustomerEmail', $attendee_email); $myeway->addField('CustomerPhone', $phone); $myeway->addField('InvoiceDescription', stripslashes_deep($event_name) . ' | ' . __('Name:', 'event_espresso') . ' ' . stripslashes_deep($fname . ' ' . $lname) . ' | ' . __('Registrant Email:', 'event_espresso') . ' ' . $attendee_email . ' | ' . __('Total Registrants:', 'event_espresso') . ' ' . $quantity); $myeway->addField('CancelURL', str_replace("&", "%26", home_url() . '/?page_id=' . $org_options['cancel_return'])); if ($eway_settings['force_ssl_return']) { $home = str_replace("http://", "https://", home_url()); } else { $home = home_url(); } $myeway->addField('ReturnURL', $home . '/?page_id=' . $org_options['notify_url'] . '&id=' . $attendee_id . '®istration_id=' . $registration_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment&type=eway'); $myeway->addField('CompanyLogo', $eway_settings['image_url']); $myeway->addField('PageBanner', ''); $myeway->addField('MerchantReference', ''); $myeway->addField('MerchantInvoice', ''); $myeway->addField('MerchantOption1', ''); $myeway->addField('MerchantOption2', ''); $myeway->addField('MerchantOption3', ''); $myeway->addField('ModifiableCustomerDetails', 'false'); if ($eway_settings['bypass_payment_page'] == 'Y') { $myeway->submitPayment(); //Enable auto redirect to payment site } else { if (empty($eway_settings['button_url'])) { if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "eway/eway_logo.png")) { $button_url = EVENT_ESPRESSO_GATEWAY_URL . "eway/eway_logo.png"; } else { $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/eway/eway_logo.png"; } } else { $button_url = $eway_settings['button_url']; } $myeway->submitButton($button_url, 'eway'); //Display payment button wp_deregister_script('jquery.validate.pack'); } if ($use_sandbox) { echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $myeway->dump_fields(); // for debugging, output a table of all the fields } }
function espresso_display_authnet($payment_data) { extract($payment_data); // Setup class include_once 'Authorize.php'; global $org_options, $wpdb; $myAuthorize = new Espresso_Authorize(); // initiate an instance of the class echo '<!--Event Espresso Authorize.net Gateway Version ' . $myAuthorize->gateway_version . '-->'; $authnet_settings = get_option('event_espresso_authnet_settings'); $authnet_login_id = empty($authnet_settings['authnet_login_id']) ? '' : $authnet_settings['authnet_login_id']; $authnet_transaction_key = empty($authnet_settings['authnet_transaction_key']) ? '' : $authnet_settings['authnet_transaction_key']; $image_url = empty($authnet_settings['image_url']) ? '' : $authnet_settings['image_url']; $use_sandbox = $authnet_settings['use_sandbox']; $use_testmode = $authnet_settings['test_transactions']; if ($use_testmode) { // Enable test mode if needed $myAuthorize->enableTestMode(); } if ($use_sandbox) { // Enable test mode if needed $myAuthorize->useTestServer(); } $quantity = !empty($quantity) ? $quantity : espresso_count_attendees_for_registration($attendee_id); $myAuthorize->setUserInfo($authnet_login_id, $authnet_transaction_key); if ($authnet_settings['force_ssl_return']) { $home = str_replace('http:', 'https:', home_url()); } else { $home = home_url(); } $myAuthorize->addField('x_Relay_URL', $home . '/?page_id=' . $org_options['return_url'] . '&r_id=' . $registration_id . '&type=authnet'); $myAuthorize->addField('x_Description', stripslashes_deep($event_name) . ' | ' . __('Reg. ID:', 'event_espresso') . ' ' . $attendee_id . ' | ' . __('Name:', 'event_espresso') . ' ' . stripslashes_deep($fname . ' ' . $lname) . ' | ' . __('Total Registrants:', 'event_espresso') . ' ' . $quantity); $myAuthorize->addField('x_Amount', number_format($event_cost, 2)); $myAuthorize->addField('x_Logo_URL', $image_url); $myAuthorize->addField('x_Invoice_num', 'au-' . event_espresso_session_id()); //Post variables $myAuthorize->addField('x_cust_id', $attendee_id); $myAuthorize->addField('x_first_name', $fname); $myAuthorize->addField('x_last_name', $lname); $myAuthorize->addField('x_Email', $attendee_email); $myAuthorize->addField('x_Address', $address); $myAuthorize->addField('x_City', $city); $myAuthorize->addField('x_State', $state); $myAuthorize->addField('x_Zip', $zip); $sql = "SELECT attendee_session FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id='" . $attendee_id . "'"; $session_id = $wpdb->get_var($sql); $sql = "SELECT a.final_price, a.quantity, ed.event_name, a.price_option, a.fname, a.lname FROM " . EVENTS_ATTENDEE_TABLE . " a JOIN " . EVENTS_DETAIL_TABLE . " ed ON a.event_id=ed.id "; $sql .= " WHERE attendee_session='" . $session_id . "' ORDER BY a.id ASC"; $items = $wpdb->get_results($sql); foreach ($items as $key => $item) { $item_num = $key + 1; $myAuthorize->addLineItem($item_num, strlen($item->event_name) > 30 ? substr_replace($item->event_name, '', 30) : $item->event_name, substr_replace($item->price_option . ' for ' . $item->event_name . '. Attendee: ' . $item->fname . ' ' . $item->lname, '', 255), $item->quantity, $item->final_price, FALSE); } //Enable this function if you want to send payment notification before the person has paid. //This function is copied on the payment processing page //event_espresso_send_payment_notification($attendee_id, $txn_id, $amount_pd); //Decide if you want to auto redirect to your payment website or display a payment button. if (!empty($authnet_settings['bypass_payment_page']) && $authnet_settings['bypass_payment_page'] == 'Y') { $myAuthorize->submitPayment(); //Enable auto redirect to payment site } else { if (empty($authnet_settings['button_url'])) { //$button_url = EVENT_ESPRESSO_GATEWAY_URL . "authnet/authnet-logo.png"; if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "/pay-by-credit-card.png")) { $button_url = EVENT_ESPRESSO_GATEWAY_DIR . "/pay-by-credit-card.png"; } else { $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/pay-by-credit-card.png"; } } elseif (file_exists($authnet_settings['button_url'])) { $button_url = $authnet_settings['button_url']; } else { //If no other buttons exist, then use the default location $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/pay-by-credit-card.png"; } $myAuthorize->submitButton($button_url, 'authnet'); //Display payment button } if ($use_sandbox) { echo '<p>Test credit card # 4007000000027</p>'; echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $myAuthorize->dump_fields(); // for debugging, output a table of all the fields } }
function espresso_display_authnet($payment_data) { extract($payment_data); // Setup class include_once 'Authorize.php'; global $org_options; $myAuthorize = new Authorize(); // initiate an instance of the class echo '<!--Event Espresso Authorize.net Gateway Version ' . $myAuthorize->gateway_version . '-->'; $authnet_settings = get_option('event_espresso_authnet_settings'); $authnet_login_id = empty($authnet_settings['authnet_login_id']) ? '' : $authnet_settings['authnet_login_id']; $authnet_transaction_key = empty($authnet_settings['authnet_transaction_key']) ? '' : $authnet_settings['authnet_transaction_key']; $button_type = empty($authnet_settings['button_type']) ? '' : $authnet_settings['button_type']; //$button_url = $authnet_settings['button_url']; $image_url = empty($authnet_settings['image_url']) ? '' : $authnet_settings['image_url']; $use_sandbox = $authnet_settings['use_sandbox']; $use_testmode = $authnet_settings['test_transactions']; if ($use_testmode == true) { // Enable test mode if needed $myAuthorize->enableTestMode(); } if ($use_sandbox) { // Enable test mode if needed $myAuthorize->useTestServer(); } $quantity = !empty($quantity) ? $quantity : espresso_count_attendees_for_registration($attendee_id); $myAuthorize->setUserInfo($authnet_login_id, $authnet_transaction_key); $myAuthorize->addField('x_Relay_URL', home_url() . '/?page_id=' . $org_options['notify_url']); $myAuthorize->addField('x_Description', stripslashes_deep($event_name) . ' | ' . __('Reg. ID:', 'event_espresso') . ' ' . $attendee_id . ' | ' . __('Name:', 'event_espresso') . ' ' . stripslashes_deep($fname . ' ' . $lname) . ' | ' . __('Total Registrants:', 'event_espresso') . ' ' . $quantity); $myAuthorize->addField('x_Amount', number_format($event_cost, 2)); $myAuthorize->addField('x_Logo_URL', $image_url); $myAuthorize->addField('x_Invoice_num', 'au-' . event_espresso_session_id()); //Post variables $myAuthorize->addField('x_cust_id', $attendee_id); $myAuthorize->addField('x_first_name', $fname); $myAuthorize->addField('x_last_name', $lname); $myAuthorize->addField('x_Email', $attendee_email); $myAuthorize->addField('x_Address', $address); $myAuthorize->addField('x_City', $city); $myAuthorize->addField('x_State', $state); $myAuthorize->addField('x_Zip', $zip); //Enable this function if you want to send payment notification before the person has paid. //This function is copied on the payment processing page //event_espresso_send_payment_notification($attendee_id, $txn_id, $amount_pd); //Decide if you want to auto redirect to your payment website or display a payment button. if (!empty($authnet_settings['bypass_payment_page']) && $authnet_settings['bypass_payment_page'] == 'Y') { $myAuthorize->submitPayment(); //Enable auto redirect to payment site } else { if (empty($authnet_settings['button_url'])) { //$button_url = EVENT_ESPRESSO_GATEWAY_URL . "authnet/btn_cc_vmad.gif"; if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "/authnet/btn_cc_vmad.gif")) { $button_url = EVENT_ESPRESSO_GATEWAY_DIR . "/authnet/btn_cc_vmad.gif"; } else { $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/authnet/btn_cc_vmad.gif"; } } elseif (file_exists($authnet_settings['button_url'])) { $button_url = $authnet_settings['button_url']; } else { //If no other buttons exist, then use the default location $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/authnet/btn_cc_vmad.gif"; } $myAuthorize->submitButton($button_url, 'authnet'); //Display payment button } if ($use_sandbox) { echo '<p>Test credit card # 4007000000027</p>'; echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $myAuthorize->dump_fields(); // for debugging, output a table of all the fields } }
function events_payment_page($attendee_id = FALSE, $notifications = array()) { do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); if (!$attendee_id) { wp_die(__('An error occured. No Attendee was received.', 'event_espresso')); } global $wpdb, $org_options; $num_people = 0; // $Organization = $org_options['organization']; // $Organization_street1 = $org_options['organization_street1']; // $Organization_street2 = $org_options['organization_street2']; // $Organization_city = $org_options['organization_city']; // $Organization_state = $org_options['organization_state']; // $Organization_zip = $org_options['organization_zip']; // $contact = $org_options['contact_email']; // $registrar = $org_options['contact_email']; // $currency_format = getCountryFullData($org_options['organization_country']); $message = $org_options['message']; $return_url = $org_options['return_url']; $cancel_return = $org_options['cancel_return']; $notify_url = $org_options['notify_url']; $event_page_id = $org_options['event_page_id']; // GET ATTENDEE $SQL = "SELECT * FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id =%d"; $attendee = $wpdb->get_row($wpdb->prepare($SQL, $attendee_id)); //printr( $attendee, '$attendee <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); $attendee_last = $attendee->lname; $attendee_first = $attendee->fname; $attendee_name = stripslashes_deep($attendee_first . ' ' . $attendee_last); $attendee_address = $attendee->address; $attendee_address2 = $attendee->address2; $attendee_city = $attendee->city; $attendee_state = $attendee->state; $attendee_zip = $attendee->zip; $attendee_email = $attendee->email; $phone = $attendee->phone; $attendee_phone = $attendee->phone; $date = $attendee->date; $quantity = (int) $attendee->quantity; $payment_status = $attendee->payment_status; $txn_type = $attendee->txn_type; $payment_date = $attendee->payment_date; $event_id = $attendee->event_id; $registration_id = $attendee->registration_id; $orig_price = (double) $attendee->orig_price; $final_price = (double) $attendee->final_price; //Get the questions for the attendee $SQL = "SELECT ea.answer, eq.question "; $SQL .= "\tFROM " . EVENTS_ANSWER_TABLE . " ea "; $SQL .= "LEFT JOIN " . EVENTS_QUESTION_TABLE . " eq ON eq.id = ea.question_id "; $SQL .= "\tWHERE ea.attendee_id = %d and eq.admin_only != 'Y' "; $SQL .= "\tORDER BY eq.sequence asc "; $questions = $wpdb->get_results($wpdb->prepare($SQL, $attendee_id)); // echo '<h4>LQ : ' . $wpdb->last_query . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; // printr( $questions, '$questions <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); $display_questions = ''; foreach ($questions as $question) { $question->question = trim(stripslashes(str_replace(''', "'", $question->question))); $question->question = htmlspecialchars($question->question, ENT_QUOTES, 'UTF-8'); $question->answer = trim(stripslashes(str_replace(''', "'", $question->answer))); $question->answer = htmlspecialchars($question->answer, ENT_QUOTES, 'UTF-8'); $display_questions .= '<p>' . $question->question . ':<br /> ' . str_replace(',', '<br />', $question->answer) . '</p>'; } // update total cost for primary attendee $total_cost = (double) $final_price * (int) $quantity - $attendee->amount_pd; $total_attendees = (int) $quantity; $attendee_prices[] = array('option' => $attendee->price_option, 'qty' => (int) $quantity, 'price' => (double) ($final_price - $attendee->amount_pd)); // get # of attendees $SQL = "SELECT price_option, quantity, final_price, amount_pd FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id =%s"; $prices = $wpdb->get_results($wpdb->prepare($SQL, $registration_id)); //printr( $prices, '$prices <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); if ($prices !== FALSE) { $total_cost = 0; $total_attendees = 0; $attendee_prices = array(); // ensure prices is an array $prices = is_array($prices) ? $prices : array($prices); foreach ($prices as $price) { // update total cost for all attendees $total_cost += (double) ($price->final_price * (int) $price->quantity) - (double) $price->amount_pd; $total_attendees += $price->quantity; $attendee_prices[] = array('option' => $price->price_option, 'qty' => (int) $price->quantity, 'price' => (double) ($price->final_price - $price->amount_pd)); } } $SQL = "SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE id = %d"; $event = $wpdb->get_row($wpdb->prepare($SQL, $event_id)); $event_name = isset($event->event_name) ? stripslashes_deep($event->event_name) : ''; $event_description = $event_desc = isset($event->event_desc) ? stripslashes_deep($event->event_desc) : ''; $event_identifier = isset($event->event_identifier) ? $event->event_identifier : ''; $send_mail = isset($event->send_mail) ? $event->send_mail : ''; $active = isset($event->is_active) ? $event->is_active : TRUE; $conf_mail = isset($event->conf_mail) ? $event->conf_mail : ''; //$event_price_x_attendees = number_format( $final_price * $num_people, 2, '.', '' ); $event_original_cost = $orig_price; // Added for seating chart addon // This code block overrides the cost using seating chart add-on price if (defined('ESPRESSO_SEATING_CHART') && class_exists("seating_chart") && seating_chart::check_event_has_seating_chart($event_id) !== false) { $SQL = "SELECT sum(sces.purchase_price) as purchase_price "; $SQL .= "FROM " . EVENTS_SEATING_CHART_EVENT_SEAT_TABLE . " sces "; $SQL .= "INNER JOIN " . EVENTS_ATTENDEE_TABLE . " ea ON sces.attendee_id = ea.id "; $SQL .= "WHERE ea.registration_id = %s"; if ($seat = $wpdb->get_row($wpdb->prepare($SQL, $registration_id))) { $total_cost = number_format($seat->purchase_price, 2, '.', ''); //$event_price_x_attendees = (float)$final_price; } } if ($total_cost == 0) { $payment_status = 'Completed'; //DO NOT TRANSLATE $today = date(get_option('date_format')); $data = array('amount_pd' => 0.0, 'payment_status' => $payment_status, 'payment_date' => $today); $format = array('%f', '%s', '%s'); $update_id = array('id' => $attendee_id); $wpdb->update(EVENTS_ATTENDEE_TABLE, $data, $update_id, $format, array('%d')); //If this is a group registration, we need to make sure all attendees have the same payment status if (espresso_count_attendees_for_registration($attendee_id) > 1) { $wpdb->query("UPDATE " . EVENTS_ATTENDEE_TABLE . " SET payment_status = '{$payment_status}' WHERE registration_id ='" . $registration_id . "'"); } } if (function_exists('espresso_update_attendee_coupon_info') && $attendee_id && !empty($attendee->coupon_code)) { espresso_update_attendee_coupon_info($attendee_id, $attendee->coupon_code); } if (function_exists('espresso_update_groupon') && $attendee_id && !empty($attendee->coupon_code)) { espresso_update_groupon($attendee_id, $attendee->coupon_code); } // echo '<h4>$attendee_id : ' . $attendee_id . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; // echo '<h4>$total_cost : ' . $total_cost . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; espresso_update_primary_attendee_total_cost($attendee_id, $total_cost, __FILE__); if (!empty($notifications['coupons']) || !empty($notifications['groupons'])) { echo '<div id="event_espresso_notifications" class="clearfix event-data-display no-hide">'; echo $notifications['coupons']; // add space between $coupon_notifications and $groupon_notifications ( if any $groupon_notifications exist ) echo !empty($notifications['coupons']) && !empty($notifications['groupons']) ? '<br/>' : ''; echo $notifications['groupons']; echo '</div>'; } if (isset($org_options['skip_confirmation_page']) && $org_options['skip_confirmation_page'] == 'Y') { $redirect_url = home_url() . '/?page_id=' . $org_options['event_page_id'] . '®event_action=confirm_registration'; $_POST['regevent_action'] = 'confirm_registration'; $_POST['confirm'] = 'Confirm Registration'; $_POST['confirm_registration'] = TRUE; $_POST['attendee_id'] = $attendee_id; $_POST['event_id'] = $event_id; $_POST['registration_id'] = $registration_id; espresso_confirm_registration(); } else { $display_cost = $total_cost > 0 ? $org_options['currency_symbol'] . number_format($total_cost, 2, '.', '') : __('Free', 'event_espresso'); // Pull in the template if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "confirmation_display.php")) { require_once EVENT_ESPRESSO_TEMPLATE_DIR . "confirmation_display.php"; //This is the path to the template file if available } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/confirmation_display.php"; } } }
function espresso_display_nab($payment_data) { extract($payment_data); include_once 'Nab.php'; echo '<!-- Event Espresso nab Gateway Version ' . $nab_gateway_version . '-->'; $mynab = new nab(); // initiate an instance of the class global $org_options, $wpdb; do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); $nab_result_url = home_url() . '/?page_id=' . $org_options['notify_url'] . '&id=' . $attendee_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment&type=nab'; $nab_settings = get_option('event_espresso_nab_settings'); $nab_id = $nab_settings['nab_merchant_id']; $nab_pass = $nab_settings['nab_merchant_password']; $use_sandbox = $nab_settings['nab_use_sandbox']; $registration_id = $wpdb->get_var("select registration_id from " . EVENTS_ATTENDEE_TABLE . " where id = {$attendee_id}"); $temp_timezone_holder = date_default_timezone_get(); date_default_timezone_set('UTC'); $timestamp = date('YmdHis'); date_default_timezone_set($temp_timezone_holder); if ($use_sandbox == 1) { $nab_post_url = "https://transact.nab.com.au/test/directpost/authorise"; } else { $nab_post_url = "https://transact.nab.com.au/live/directpost/authorise"; } $quantity = isset($quantity) && $quantity > 0 ? $quantity : espresso_count_attendees_for_registration($attendee_id); $mynab->addField('EPS_MERCHANT', $nab_id); $mynab->addField('EPS_PASSWORD', $nab_pass); $mynab->addField('EPS_REFERENCEID', $registration_id); $mynab->addField('EPS_AMOUNT', number_format($event_cost, 2, '.', '')); $mynab->addField('EPS_TIMESTAMP', $timestamp); if (empty($nab_settings['button_url'])) { if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "nab/nab_logo.png")) { $button_url = EVENT_ESPRESSO_GATEWAY_URL . "nab/nab_logo.png"; } else { $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/nab/nab_logo.png"; } } else { $button_url = $nab_settings['button_url']; } ?> <form method="post" action="<?php echo $nab_post_url; ?> "> <input type="hidden" name="EPS_MERCHANT" value="<?php echo $nab_id; ?> "> <input type="hidden" name="EPS_PASSWORD" value="<?php echo $nab_pass; ?> "> <input type="hidden" name="EPS_REFERENCEID" value="<?php echo $registration_id; ?> "> <input type="hidden" name="EPS_AMOUNT" value="<?php echo number_format($event_cost, 2, '.', ''); ?> "> <input type="hidden" name="EPS_TIMESTAMP" value="<?php echo $timestamp; ?> "> <input type="hidden" name="EPS_FINGERPRINT" value="<?php echo $mynab->prepareSubmit(); ?> "> <input type="hidden" name="EPS_RESULTURL" value="<?php echo $nab_result_url; ?> "> <input type="hidden" name="EPS_FIRSTNAME" value="<?php echo $fname; ?> "> <input type="hidden" name="EPS_LASTNAME" value="<?php echo $lname; ?> "> <input type="hidden" name="EPS_ZIPCODE" value="<?php echo $zip; ?> "> <input type="hidden" name="EPS_TOWN" value="<?php echo $city; ?> "> <input type="hidden" name="EPS_EMAILADDRESS" value="<?php echo $attendee_email; ?> "> <table> <tbody> <tr> <td colspan="2"><b>Enter Account Details</b></td> </tr> <tr> <td>Card Type :</td> <td><select name="EPS_CARDTYPE" class="inputbox" style="width:167px"> <option value="visa">Visa</option> <option value="mastercard">MasterCard</option> <option value="amex">Amex</option> </select></td> </tr> <tr> <td>Card Number :</td> <td><input type="text" class="inputbox" name="EPS_CARDNUMBER" value="4444333322221111" size="27"/></td> </tr> <tr> <td> Card CCV :</td> <td><input type="text" class="inputbox" name="EPS_CCV" value="234" size="27" /></td> </tr> <tr> <td>Card Expires :</td> <td><select name="EPS_EXPIRYMONTH" class="inputbox"> <option value="">- Month -</option> <option value="1">01</option> <option value="2">02</option> <option value="3">03</option> <option value="4" selected>04</option> <option value="5">05</option> <option value="6">06</option> <option value="7">07</option> <option value="8">08</option> <option value="9">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> <select name="EPS_EXPIRYYEAR" class="inputbox"> <option value="">- Year -</option> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012" selected>2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> <option value="2021">2021</option> <option value="2022">2022</option> <option value="2023">2023</option> <option value="2024">2024</option> <option value="2025">2025</option> </select></td> </tr> <tr height=''50px''> <td align="left" colspan="2"><input type="submit" value="Post Payment" class="submit_button"/></td> </tr> </tbody> </table> </form> <?php wp_deregister_script('jquery.validate.pack'); if ($use_sandbox == true) { echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $mynab->dump_fields(); } }