/**
 * initialise plugin once other plugins are loaded
 */
function em_gateway_stripe_token_register()
{
    //check that EM Pro is installed
    if (!defined('EMP_VERSION')) {
        add_action('admin_notices', 'em_pro_prereq');
        return false;
        //don't load plugin further
    }
    if (class_exists('EM_Gateways')) {
        require_once plugin_dir_path(__FILE__) . 'em-gateway-stripe-token.php';
        EM_Gateways::register_gateway('em_pro_stripe_token', 'EM_Gateway_Stripe_Token');
    }
}
コード例 #2
0
	/**
	* handle init action
	*/
	public function init() {
		// register with Events Manager
		if (class_exists('EM_Gateways')) {
			require EWAY_PAYMENTS_PLUGIN_ROOT . 'includes/integrations/class.EwayPaymentsEventsManager.php';
			EM_Gateways::register_gateway('eway', 'EwayPaymentsEventsManager');
		}

		// register with Another WordPress Classifieds Plugin
		if (isset($GLOBALS['awpcp'])) {
			require EWAY_PAYMENTS_PLUGIN_ROOT . 'includes/integrations/class.EwayPaymentsAWPCP.php';
			new EwayPaymentsAWPCP();
		}
	}
コード例 #3
0
function mycred_load_events_manager()
{
    if (!defined('EM_VERSION')) {
        return;
    }
    // Pro
    if (class_exists('EM_Pro') && class_exists('EM_Gateways')) {
        require_once myCRED_GATE_EVENT_DIR . 'mycred-eventsmanager-pro.php';
        EM_Gateways::register_gateway('mycred', 'EM_Gateway_myCRED');
    } else {
        require_once myCRED_GATE_EVENT_DIR . 'mycred-eventsmanager.php';
        $events = new myCRED_Events_Manager_Gateway();
        $events->load();
    }
}
コード例 #4
0
        /**
         * Gets called at the bottom of the form before the submit button. 
         * Outputs a gateway selector and allows gateways to hook in and provide their own payment information to be submitted.
         * By default each gateway is wrapped with a div with id em-booking-gateway-x where x is the gateway for JS to work.
         * 
         * To prevent this from firing, call this function after the init action:
         * remove_action('em_booking_form_footer', array('EM_Gateways','booking_form_footer'),1,2);
         * 
         * You'll have to ensure a gateway value is submitted in your booking form in order for paid bookings to be processed properly.
         */
        static function booking_form_footer()
        {
            global $EM_Gateways;
            //Display gateway input
            add_action('em_gateway_js', array('EM_Gateways', 'em_gateway_js'));
            //Check if we can user quick pay buttons
            if (get_option('dbem_gateway_use_buttons', 1)) {
                //backward compatability
                echo EM_Gateways::booking_form_buttons();
                return;
            }
            //Continue with payment gateway selection
            $active_gateways = self::active_gateways();
            if (is_array($active_gateways)) {
                //Add gateway selector
                if (count($active_gateways) > 1) {
                    ?>
			<p class="em-booking-gateway" id="em-booking-gateway">
				<label><?php 
                    echo get_option('dbem_gateway_label');
                    ?>
</label>
				<select name="gateway">
				<?php 
                    foreach ($active_gateways as $gateway => $active_val) {
                        if (array_key_exists($gateway, $EM_Gateways)) {
                            $selected = !empty($selected) ? $selected : $gateway;
                            echo '<option value="' . $gateway . '">' . get_option('em_' . $gateway . '_option_name') . '</option>';
                        }
                    }
                    ?>
				</select>
			</p>
			<?php 
                } elseif (count($active_gateways) == 1) {
                    foreach ($active_gateways as $gateway => $val) {
                        $selected = !empty($selected) ? $selected : $gateway;
                        echo '<input type="hidden" name="gateway" value="' . $gateway . '" />';
                    }
                }
                foreach ($active_gateways as $gateway => $active_val) {
                    echo '<div class="em-booking-gateway-form" id="em-booking-gateway-' . $gateway . '"';
                    echo $selected == $gateway ? '' : ' style="display:none;"';
                    echo '>';
                    $EM_Gateways[$gateway]->booking_form();
                    echo "</div>";
                }
            }
            return;
            //for filter compatibility
        }
コード例 #5
0
            update_option('em_' . $key, stripslashes($option));
        }
        //default action is to return true
        return true;
    }
    /**
     * Load Custom js for gateway admin
     */
    function gateway_admin_js($hook)
    {
        if ($hook == 'event_page_events-manager-gateways') {
            wp_enqueue_script('netbanx_gateway_admin', plugin_dir_url(__FILE__) . '/gateway.paypal-chained-payments-admin.js');
        }
    }
}
EM_Gateways::register_gateway('paypal_chained', 'EM_Gateway_Paypal_Chained');
/**
 * Deletes bookings pending payment that are more than x minutes old, defined by paypal options.
 */
function em_gateway_paypal_chained_booking_timeout()
{
    global $wpdb;
    //Get a time from when to delete
    $minutes_to_subtract = absint(get_option('em_paypal_booking_timeout'));
    if ($minutes_to_subtract > 0) {
        //get booking IDs without pending transactions
        $cut_off_time = date('Y-m-d H:i:s', current_time('timestamp') - $minutes_to_subtract * 60);
        $booking_ids = $wpdb->get_col('SELECT b.booking_id FROM ' . EM_BOOKINGS_TABLE . ' b LEFT JOIN ' . EM_TRANSACTIONS_TABLE . " t ON t.booking_id=b.booking_id  WHERE booking_date < '{$cut_off_time}' AND booking_status=4 AND transaction_id IS NULL");
        if (count($booking_ids) > 0) {
            //first delete ticket_bookings with expired bookings
            $sql = "DELETE FROM " . EM_TICKETS_BOOKINGS_TABLE . " WHERE booking_id IN (" . implode(',', $booking_ids) . ");";
コード例 #6
0
 /**
  * Retreive the paypal vars needed to send to the gatway to proceed with payment
  * @param EM_Booking $EM_Booking
  */
 function get_paypal_vars($EM_Booking)
 {
     global $wp_rewrite, $EM_Notices;
     $notify_url = $this->get_payment_return_url();
     $paypal_vars = array('business' => get_option('em_' . $this->gateway . "_email"), 'cmd' => '_cart', 'upload' => 1, 'currency_code' => get_option('dbem_bookings_currency', 'USD'), 'notify_url' => $notify_url, 'custom' => $EM_Booking->booking_id . ':' . $EM_Booking->event_id, 'charset' => 'UTF-8', 'bn' => 'NetWebLogic_SP');
     if (get_option('em_' . $this->gateway . "_lc")) {
         $paypal_vars['lc'] = get_option('em_' . $this->gateway . "_lc");
     }
     //address fields`and name/email fields to prefill on checkout page (if available)
     $paypal_vars['email'] = $EM_Booking->get_person()->user_email;
     $paypal_vars['first_name'] = $EM_Booking->get_person()->first_name;
     $paypal_vars['last_name'] = $EM_Booking->get_person()->last_name;
     if (EM_Gateways::get_customer_field('address', $EM_Booking) != '') {
         $paypal_vars['address1'] = EM_Gateways::get_customer_field('address', $EM_Booking);
     }
     if (EM_Gateways::get_customer_field('address_2', $EM_Booking) != '') {
         $paypal_vars['address2'] = EM_Gateways::get_customer_field('address_2', $EM_Booking);
     }
     if (EM_Gateways::get_customer_field('city', $EM_Booking) != '') {
         $paypal_vars['city'] = EM_Gateways::get_customer_field('city', $EM_Booking);
     }
     if (EM_Gateways::get_customer_field('state', $EM_Booking) != '') {
         $paypal_vars['state'] = EM_Gateways::get_customer_field('state', $EM_Booking);
     }
     if (EM_Gateways::get_customer_field('zip', $EM_Booking) != '') {
         $paypal_vars['zip'] = EM_Gateways::get_customer_field('zip', $EM_Booking);
     }
     if (EM_Gateways::get_customer_field('country', $EM_Booking) != '') {
         $paypal_vars['country'] = EM_Gateways::get_customer_field('country', $EM_Booking);
     }
     //tax is added regardless of whether included in ticket price, otherwise we can't calculate post/pre tax discounts
     if ($EM_Booking->get_price_taxes() > 0 && !get_option('em_' . $this->gateway . "_inc_tax")) {
         $paypal_vars['tax_cart'] = round($EM_Booking->get_price_taxes(), 2);
     }
     if (get_option('em_' . $this->gateway . "_return") != "") {
         $paypal_vars['return'] = get_option('em_' . $this->gateway . "_return");
     }
     if (get_option('em_' . $this->gateway . "_cancel_return") != "") {
         $paypal_vars['cancel_return'] = get_option('em_' . $this->gateway . "_cancel_return");
     }
     if (get_option('em_' . $this->gateway . "_format_logo") !== false) {
         $paypal_vars['cpp_logo_image'] = get_option('em_' . $this->gateway . "_format_logo");
     }
     if (get_option('em_' . $this->gateway . "_border_color") !== false) {
         $paypal_vars['cpp_cart_border_color'] = get_option('em_' . $this->gateway . "_format_border");
     }
     $count = 1;
     foreach ($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking) {
         /* @var $EM_Ticket_Booking EM_Ticket_Booking */
         //divide price by spaces for per-ticket price
         //we divide this way rather than by $EM_Ticket because that can be changed by user in future, yet $EM_Ticket_Booking will change if booking itself is saved.
         if (!get_option('em_' . $this->gateway . "_inc_tax")) {
             $price = $EM_Ticket_Booking->get_price() / $EM_Ticket_Booking->get_spaces();
         } else {
             $price = $EM_Ticket_Booking->get_price_with_taxes() / $EM_Ticket_Booking->get_spaces();
         }
         if ($price > 0) {
             $paypal_vars['item_name_' . $count] = wp_kses_data($EM_Ticket_Booking->get_ticket()->name);
             $paypal_vars['quantity_' . $count] = $EM_Ticket_Booking->get_spaces();
             $paypal_vars['amount_' . $count] = round($price, 2);
             $count++;
         }
     }
     //calculate discounts, if any:
     $discount = $EM_Booking->get_price_discounts_amount('pre') + $EM_Booking->get_price_discounts_amount('post');
     if ($discount > 0) {
         $paypal_vars['discount_amount_cart'] = $discount;
     }
     return apply_filters('em_gateway_paypal_get_paypal_vars', $paypal_vars, $EM_Booking, $this);
 }
コード例 #7
0
 /**
  * Retreive the authorize_aim vars needed to send to the gateway to proceed with payment
  * @param EM_Booking $EM_Booking
  */
 function authorize_and_capture($EM_Booking)
 {
     global $EM_Notices;
     $sale = $this->get_api();
     //Get transaction ID for authorization/capture
     $sale->amount = $amount = $EM_Booking->get_price(false, false, true);
     $sale->exp_date = $_REQUEST['x_exp_date_month'] . '/' . $_REQUEST['x_exp_date_year'];
     $sale->card_num = $_REQUEST['x_card_num'];
     $sale->card_code = $_REQUEST['x_card_code'];
     //Email Info
     $sale->email_customer = get_option('em_' . $this->gateway . '_email_customer', 0) ? '1' : '0';
     //for later
     $sale->header_email_receipt = get_option('em_' . $this->gateway . '_header_email_receipt');
     $sale->footer_email_receipt = get_option('em_' . $this->gateway . '_footer_email_receipt');
     //Order Info
     $sale->invoice_num = $EM_Booking->booking_id;
     $sale->description = preg_replace('/[^a-zA-Z0-9\\s]/i', "", $EM_Booking->get_event()->event_name);
     //clean event name
     //Customer Info
     $sale->email = $EM_Booking->get_person()->user_email;
     $sale->customer_ip = $_SERVER['REMOTE_ADDR'];
     $sale->cust_id = get_option('dbem_bookings_registration_disable') ? 'booking-' . $EM_Booking->booking_id : 'user-' . $EM_Booking->get_person()->ID;
     //Address Info
     $names = explode(' ', $EM_Booking->get_person()->get_name());
     if (!empty($names[0])) {
         $sale->first_name = array_shift($names);
     }
     if (implode(' ', $names) != '') {
         $sale->last_name = implode(' ', $names);
     }
     //address slightly special address field
     $address = '';
     if (EM_Gateways::get_customer_field('address', $EM_Booking) != '') {
         $address = EM_Gateways::get_customer_field('address', $EM_Booking);
     }
     if (EM_Gateways::get_customer_field('address_2', $EM_Booking) != '') {
         $address .= ', ' . EM_Gateways::get_customer_field('address_2', $EM_Booking);
     }
     if (!empty($address)) {
         $sale->address = substr($address, 0, 60);
     }
     //cut off at 60 characters
     if (EM_Gateways::get_customer_field('city', $EM_Booking) != '') {
         $sale->city = EM_Gateways::get_customer_field('city', $EM_Booking);
     }
     if (EM_Gateways::get_customer_field('state', $EM_Booking) != '') {
         $sale->state = EM_Gateways::get_customer_field('state', $EM_Booking);
     }
     if (EM_Gateways::get_customer_field('zip', $EM_Booking) != '') {
         $sale->zip = EM_Gateways::get_customer_field('zip', $EM_Booking);
     }
     if (EM_Gateways::get_customer_field('country', $EM_Booking) != '') {
         $countries = em_get_countries();
         $sale->country = $countries[EM_Gateways::get_customer_field('country', $EM_Booking)];
     }
     if (EM_Gateways::get_customer_field('phone', $EM_Booking) != '') {
         $sale->phone = EM_Gateways::get_customer_field('phone', $EM_Booking);
     }
     if (EM_Gateways::get_customer_field('fax', $EM_Booking) != '') {
         $sale->fax = EM_Gateways::get_customer_field('fax', $EM_Booking);
     }
     if (EM_Gateways::get_customer_field('company', $EM_Booking) != '') {
         $sale->company = EM_Gateways::get_customer_field('company', $EM_Booking);
     }
     //Itemized Billing
     $tax_enabled = get_option('dbem_bookings_tax') > 0 ? 'Y' : 'N';
     foreach ($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking) {
         $price = round($EM_Ticket_Booking->get_price() / $EM_Ticket_Booking->get_spaces(), 2);
         if ($price > 0) {
             $ticket_name = substr($EM_Ticket_Booking->get_ticket()->ticket_name, 0, 31);
             $sale->addLineItem($EM_Ticket_Booking->get_ticket()->ticket_id, $ticket_name, $EM_Ticket_Booking->get_ticket()->ticket_description, $EM_Ticket_Booking->get_spaces(), $price, $tax_enabled);
         }
     }
     if ($tax_enabled == 'Y') {
         $sale->tax = number_format($EM_Booking->get_price_taxes(), 2);
     }
     //Add discounts to itemized billing
     $discount = $EM_Booking->get_price_discounts_amount('pre') + $EM_Booking->get_price_discounts_amount('post');
     if ($discount > 0) {
         $sale->addLineItem(0, __('Discount', 'em-pro'), '', 1, $discount, 'N');
     }
     //Get Payment
     $sale = apply_filters('em_gateawy_authorize_aim_sale_var', $sale, $EM_Booking, $this);
     $response = $sale->authorizeAndCapture();
     //Handle result
     $result = $response->approved == true;
     if ($result) {
         $EM_Booking->booking_meta[$this->gateway] = array('txn_id' => $response->transaction_id, 'amount' => $amount);
         $this->record_transaction($EM_Booking, $amount, 'USD', date('Y-m-d H:i:s', current_time('timestamp')), $response->transaction_id, 'Completed', '');
     } else {
         $EM_Booking->add_error($response->response_reason_text);
     }
     //Return transaction_id or false
     return apply_filters('em_gateway_authorize_aim_authorize', $result, $EM_Booking, $this);
 }
コード例 #8
0
 public static function em_bookings_table_rows_col($value, $col, $EM_Booking, $EM_Bookings_Table, $csv)
 {
     global $EM_Event;
     if ($col == 'gateway') {
         //get latest transaction with an ID
         if (!empty($EM_Booking->booking_meta['gateway'])) {
             $gateway = EM_Gateways::get_gateway($EM_Booking->booking_meta['gateway']);
             $value = $gateway->title;
         } else {
             $value = __('None', 'em-pro');
         }
     }
     return $value;
 }
コード例 #9
0
    public static function handle_gateways_panel()
    {
        global $action, $page, $EM_Gateways, $EM_Pro;
        wp_reset_vars(array('action', 'page'));
        switch (addslashes($action)) {
            case 'edit':
                if (isset($EM_Gateways[addslashes($_GET['gateway'])])) {
                    $EM_Gateways[addslashes($_GET['gateway'])]->settings();
                }
                return;
                // so we don't show the list below
                break;
            case 'transactions':
                if (isset($EM_Gateways[addslashes($_GET['gateway'])])) {
                    global $EM_Gateways_Transactions;
                    $EM_Gateways_Transactions->output();
                }
                return;
                // so we don't show the list below
                break;
        }
        $messages = array();
        $messages[1] = __('Gateway activated.', 'em-pro');
        $messages[2] = __('Gateway not activated.', 'em-pro');
        $messages[3] = __('Gateway deactivated.', 'em-pro');
        $messages[4] = __('Gateway not deactivated.', 'em-pro');
        $messages[5] = __('Gateway activation toggled.', 'em-pro');
        ?>
		<div class='wrap'>
			<div class="icon32" id="icon-plugins"><br></div>
			<h2><?php 
        _e('Edit Gateways', 'em-pro');
        ?>
</h2>
			<?php 
        if (isset($_GET['msg']) && !empty($messages[$_GET['msg']])) {
            echo '<div id="message" class="updated fade"><p>' . $messages[$_GET['msg']] . '</p></div>';
        }
        ?>
			<form method="post" action="" id="posts-filter">
				<div class="tablenav">
					<div class="alignleft actions">
						<select name="action">
							<option selected="selected" value=""><?php 
        _e('Bulk Actions');
        ?>
</option>
							<option value="toggle"><?php 
        _e('Toggle activation');
        ?>
</option>
						</select>
						<input type="submit" class="button-secondary action" value="<?php 
        _e('Apply', 'em-pro');
        ?>
">		
					</div>		
					<div class="alignright actions"></div>		
					<br class="clear">
				</div>	
				<div class="clear"></div>	
				<?php 
        wp_original_referer_field(true, 'previous');
        wp_nonce_field('emp-gateways');
        $columns = array("name" => __('Gateway Name', 'em-pro'), "active" => __('Active', 'em-pro'), "transactions" => __('Transactions', 'em-pro'));
        $columns = apply_filters('em_gateways_columns', $columns);
        $gateways = EM_Gateways::gateways_list();
        $active = EM_Gateways::active_gateways();
        ?>
	
				<table class="widefat fixed">
					<thead>
					<tr>
					<th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"></th>
						<?php 
        foreach ($columns as $key => $col) {
            ?>
							<th style="" class="manage-column column-<?php 
            echo $key;
            ?>
" id="<?php 
            echo $key;
            ?>
" scope="col"><?php 
            echo $col;
            ?>
</th>
							<?php 
        }
        ?>
					</tr>
					</thead>	
					<tfoot>
					<tr>
					<th style="" class="manage-column column-cb check-column" scope="col"><input type="checkbox"></th>
						<?php 
        reset($columns);
        foreach ($columns as $key => $col) {
            ?>
							<th style="" class="manage-column column-<?php 
            echo $key;
            ?>
" id="<?php 
            echo $key;
            ?>
" scope="col"><?php 
            echo $col;
            ?>
</th>
							<?php 
        }
        ?>
					</tr>
					</tfoot>
					<tbody>
						<?php 
        if ($gateways) {
            foreach ($gateways as $key => $gateway) {
                if (!isset($EM_Gateways[$key])) {
                    continue;
                }
                $EM_Gateway = $EM_Gateways[$key];
                /* @var $EM_Gateway EM_Gateway */
                ?>
								<tr valign="middle" class="alternate">
									<th class="check-column" scope="row"><input type="checkbox" value="<?php 
                echo esc_attr($key);
                ?>
" name="gateways[]"></th>
									<td class="column-name">
										<strong><a title="Edit <?php 
                echo esc_attr($gateway);
                ?>
" href="<?php 
                echo EM_ADMIN_URL;
                ?>
&amp;page=<?php 
                echo $page;
                ?>
&amp;action=edit&amp;gateway=<?php 
                echo $key;
                ?>
" class="row-title"><?php 
                echo esc_html($gateway);
                ?>
</a></strong>
										<?php 
                //Check if Multi-Booking Ready
                if (get_option('dbem_multiple_bookings') && !$EM_Gateway->supports_multiple_bookings) {
                    echo '<br/><em>' . __('This gateway cannot be activated because it does not support multiple bookings mode.', 'em-pro') . '</em>';
                }
                $actions = array();
                $actions['edit'] = "<span class='edit'><a href='" . EM_ADMIN_URL . "&amp;page=" . $page . "&amp;action=edit&amp;gateway=" . $key . "'>" . __('Settings') . "</a></span>";
                if (array_key_exists($key, $active)) {
                    $actions['toggle'] = "<span class='edit activate'><a href='" . wp_nonce_url(EM_ADMIN_URL . "&amp;page=" . $page . "&amp;action=deactivate&amp;gateway=" . $key . "", 'toggle-gateway_' . $key) . "'>" . __('Deactivate') . "</a></span>";
                } else {
                    if (!get_option('dbem_multiple_bookings') || get_option('dbem_multiple_bookings') && $EM_Gateway->supports_multiple_bookings) {
                        $actions['toggle'] = "<span class='edit deactivate'><a href='" . wp_nonce_url(EM_ADMIN_URL . "&amp;page=" . $page . "&amp;action=activate&amp;gateway=" . $key . "", 'toggle-gateway_' . $key) . "'>" . __('Activate') . "</a></span>";
                    }
                }
                ?>
										<br><div class="row-actions"><?php 
                echo implode(" | ", $actions);
                ?>
</div>
										</td>
									<td class="column-active">
										<?php 
                if (array_key_exists($key, $active)) {
                    echo "<strong>" . __('Active', 'em-pro') . "</strong>";
                } else {
                    echo __('Inactive', 'em-pro');
                }
                ?>
									</td>
									<td class="column-transactions">
										<a href='<?php 
                echo EM_ADMIN_URL;
                ?>
&amp;page=<?php 
                echo $page;
                ?>
&amp;action=transactions&amp;gateway=<?php 
                echo $key;
                ?>
'><?php 
                _e('View transactions', 'em-pro');
                ?>
</a>
									</td>
							    </tr>
								<?php 
            }
        } else {
            $columncount = count($columns) + 1;
            ?>
							<tr valign="middle" class="alternate" >
								<td colspan="<?php 
            echo $columncount;
            ?>
" scope="row"><?php 
            _e('No Payment gateways were found for this install.', 'em-pro');
            ?>
</td>
						    </tr>
							<?php 
        }
        ?>
					</tbody>
				</table>
			</form>

		</div> <!-- wrap -->
		<?php 
    }
コード例 #10
0
 public static function gateway_admin_emails($emails, $EM_Booking)
 {
     if (empty($EM_Booking->booking_meta['gateway']) || $EM_Booking->get_price() == 0) {
         return $emails;
     }
     $gateway = $EM_Booking->booking_meta['gateway'];
     $EM_Gateway = EM_Gateways::get_gateway($gateway);
     $admin_emails_array = self::get_gateway_admin_emails($EM_Gateway);
     $admin_emails = array();
     if (get_class($EM_Booking) == 'EM_Booking') {
         if (!empty($admin_emails_array[$gateway])) {
             $admin_emails = explode(',', $admin_emails_array[$gateway]);
         }
     } elseif (get_class($EM_Booking) == 'EM_Multiple_Booking') {
         //if MB mode is on, we check the mb email templates instead
         if (!empty($admin_emails_array[$gateway . '-mb'])) {
             $admin_emails = explode(',', $admin_emails_array[$gateway . '-mb']);
         }
     }
     return array_merge($emails, $admin_emails);
 }
コード例 #11
0
			  <td>
			  	<input type="text" name="offline_booking_feedback" value="<?php 
        esc_attr_e(get_option('em_' . $this->gateway . "_booking_feedback"));
        ?>
" style='width: 40em;' /><br />
			  	<em><?php 
        _e('The message that is shown to a user when a booking with offline payments is successful.', 'em-pro');
        ?>
</em>
			  </td>
		  </tr>
		</tbody>
		</table>
		<?php 
    }
    /* 
     * Run when saving PayPal settings, saves the settings available in EM_Gateway_Paypal::mysettings()
     */
    function update()
    {
        parent::update();
        $gateway_options = array($this->gateway . "_button" => $_REQUEST['offline_button'], $this->gateway . "_form" => $_REQUEST['offline_form'], $this->gateway . "_booking_feedback" => $_REQUEST['offline_booking_feedback']);
        foreach ($gateway_options as $key => $option) {
            update_option('em_' . $key, stripslashes($option));
        }
        //default action is to return true
        return true;
    }
}
EM_Gateways::register_gateway('offline', 'EM_Gateway_Offline');
コード例 #12
0
	/**
	* attempt to process payment
	* @param EM_Booking $EM_Booking
	* @return boolean
	*/
	public function processPayment($EM_Booking){
		// process the payment
		$isLiveSite = !(get_option('em_' . EM_EWAY_GATEWAY . '_mode') == 'sandbox');
		if (!$isLiveSite && get_option('em_' . EM_EWAY_GATEWAY . '_test_force')) {
			$customerID = EWAY_PAYMENTS_TEST_CUSTOMER;
		}
		else {
			$customerID = get_option('em_' . EM_EWAY_GATEWAY . '_cust_id');
		}

		if (get_option('em_' . EM_EWAY_GATEWAY . '_stored')) {
			$eway = new EwayPaymentsStoredPayment($customerID, $isLiveSite);
		}
		else {
			$eway = new EwayPaymentsPayment($customerID, $isLiveSite);
		}

		$eway->invoiceDescription			= $EM_Booking->get_event()->event_name;
		//~ $eway->invoiceDescription		= $EM_Booking->output('#_BOOKINGTICKETDESCRIPTION');
		$eway->invoiceReference				= $EM_Booking->booking_id;						// customer invoice reference
		$eway->transactionNumber			= $EM_Booking->booking_id;						// transaction reference
		$eway->cardHoldersName				= self::getPostValue('x_card_name');
		$eway->cardNumber					= strtr(self::getPostValue('x_card_num'), array(' ' => '', '-' => ''));
		$eway->cardExpiryMonth				= self::getPostValue('x_exp_date_month');
		$eway->cardExpiryYear				= self::getPostValue('x_exp_date_year');
		$eway->cardVerificationNumber		= self::getPostValue('x_card_code');
		$eway->emailAddress					= $EM_Booking->get_person()->user_email;
		$eway->postcode						= self::getPostValue('zip');

		// for Beagle (free) security
		if (get_option('em_' . EM_EWAY_GATEWAY . '_beagle')) {
			$eway->customerCountryCode		= EM_Gateways::get_customer_field('country', $EM_Booking);
		}

		// attempt to split name into parts, and hope to not offend anyone!
		$names = explode(' ', $EM_Booking->get_person()->get_name());
		if (!empty($names[0])) {
			$eway->firstName				= array_shift($names);		// remove first name from array
		}
		$eway->lastName						= trim(implode(' ', $names));

		// use cardholder name for last name if no customer name entered
		if (empty($eway->firstName) && empty($eway->lastName)) {
			$eway->lastName = $eway->cardHoldersName;
		}

		// aggregate street, city, state, country into a single string
		$parts = array (
			EM_Gateways::get_customer_field('address', $EM_Booking),
			EM_Gateways::get_customer_field('address_2', $EM_Booking),
			EM_Gateways::get_customer_field('city', $EM_Booking),
			EM_Gateways::get_customer_field('state', $EM_Booking),
			self::getCountryName(EM_Gateways::get_customer_field('country', $EM_Booking)),
		);
		$eway->address						= implode(', ', array_filter($parts, 'strlen'));

		// if live, pass through amount exactly, but if using test site, round up to whole dollars or eWAY will fail
		$amount = $EM_Booking->get_price(false, false, true);
		$amount = apply_filters('em_eway_amount', $amount, $EM_Booking);
		$eway->amount						= $isLiveSite ? $amount : ceil($amount);

		// allow plugins/themes to modify invoice description and reference, and set option fields
		$eway->invoiceDescription			= apply_filters('em_eway_invoice_desc', $eway->invoiceDescription, $EM_Booking);
		$eway->invoiceReference				= apply_filters('em_eway_invoice_ref', $eway->invoiceReference, $EM_Booking);
		$eway->option1						= apply_filters('em_eway_option1', '', $EM_Booking);
		$eway->option2						= apply_filters('em_eway_option2', '', $EM_Booking);
		$eway->option3						= apply_filters('em_eway_option3', '', $EM_Booking);

		// Get Payment
		try {
			$result = false;
			$response = $eway->processPayment();

			if ($response->status) {
				// transaction was successful, so record transaction number and continue
				$EM_Booking->booking_meta[EM_EWAY_GATEWAY] = array(
					'txn_id'	=> $response->transactionNumber,
					'authcode'	=> $response->authCode,
					'amount'	=> $response->amount,
				);

				$notes = array();
				if (!empty($response->authCode)) {
					$notes[] = 'Authcode: ' . $response->authCode;
				}
				if (!empty($response->beagleScore)) {
					$notes[] = 'Beagle score: ' . $response->beagleScore;
				}
				$note = implode("\n", $notes);

				$status = get_option('em_' . EM_EWAY_GATEWAY . '_stored') ? 'Pending' : 'Completed';
				$this->record_transaction($EM_Booking, $response->amount, 'AUD', date('Y-m-d H:i:s', current_time('timestamp')), $response->transactionNumber, $status, $note);
				$result = true;
			}
			else {
				// transaction was unsuccessful, so record the error
				$EM_Booking->add_error($response->error);
			}
		}
		catch (Exception $e) {
			// an exception occured, so record the error
			$EM_Booking->add_error($e->getMessage());
			return;
		}

		// Return status
		return apply_filters('em_gateway_eway_authorize', $result, $EM_Booking, $this);
	}
コード例 #13
0
 public static function get_gateway_default_values($EM_Gateway = false)
 {
     global $EM_Gateways;
     $email_values = array();
     $gateways = is_object($EM_Gateway) ? array($EM_Gateway->gateway => $EM_Gateway->title) : EM_Gateways::active_gateways();
     foreach ($gateways as $gateway => $gateway_name) {
         $email_values[$gateway . '-admin'] = array(0 => array('subject' => get_option('dbem_bookings_contact_email_subject'), 'message' => get_option('dbem_bookings_contact_email_body'), 'status' => 0), 1 => array('subject' => get_option('dbem_bookings_contact_email_subject'), 'message' => get_option('dbem_bookings_contact_email_body'), 'status' => 0), 3 => array('subject' => get_option('dbem_contactperson_email_cancelled_subject'), 'message' => get_option('dbem_contactperson_email_cancelled_body'), 'status' => 0));
         $email_values[$gateway . '-user'] = array(0 => array('subject' => get_option('dbem_bookings_email_pending_subject'), 'message' => get_option('dbem_bookings_email_pending_body'), 'status' => 0), 1 => array('subject' => get_option('dbem_bookings_email_confirmed_subject'), 'message' => get_option('dbem_bookings_email_confirmed_body'), 'status' => 0), 2 => array('subject' => get_option('dbem_bookings_email_rejected_subject'), 'message' => get_option('dbem_bookings_email_rejected_body'), 'status' => 0), 3 => array('subject' => get_option('dbem_bookings_email_cancelled_subject'), 'message' => get_option('dbem_bookings_email_cancelled_body'), 'status' => 0));
         //temporary fix, we assume everything is online except for offline - maybe a good reason for split offline/online base gateway subclasses
         if ($gateway == 'offline') {
             $email_values[$gateway . '-admin'][5] = array('subject' => get_option('dbem_bookings_contact_email_subject'), 'message' => get_option('dbem_bookings_contact_email_body'), 'status' => 0);
             $email_values[$gateway . '-user'][5] = array('subject' => get_option('dbem_bookings_email_pending_subject'), 'message' => get_option('dbem_bookings_email_pending_body'), 'status' => 0);
         }
         //get custom values if applicable
         $possible_email_values = maybe_unserialize(get_option('em_' . $gateway . "_emails"));
         $email_values = self::merge_gateway_default_values($gateway, $email_values, $possible_email_values, count($gateways) > 1);
     }
     return $email_values;
 }