/**
  * Construct 
  */
 function __construct()
 {
     // Default settings
     $defaults = array('setup' => 'off', 'type' => 'mycred_default', 'rate' => 100, 'share' => 0, 'log' => array('purchase' => __('Payment for tickets to %link_with_title%', 'mycred'), 'refund' => __('Ticket refund for %link_with_title%', 'mycred')), 'refund' => 0, 'labels' => array('header' => __('Pay using your %_plural% balance', 'mycred'), 'button' => __('Pay Now', 'mycred'), 'link' => __('Pay', 'mycred'), 'checkout' => __('%plural% Cost', 'mycred')), 'messages' => array('success' => __('Thank you for your payment!', 'mycred'), 'error' => __("I'm sorry but you can not pay for these tickets using %_plural%", 'mycred')));
     // Settings
     $settings = get_option('mycred_eventsmanager_gateway_prefs');
     $this->prefs = mycred_apply_defaults($defaults, $settings);
     $this->mycred_type = $this->prefs['type'];
     // Load myCRED
     $this->core = mycred($this->mycred_type);
     // Apply Whitelabeling
     $this->label = mycred_label();
     $this->title = strip_tags($this->label);
     $this->status_txt = 'Paid using ' . strip_tags($this->label);
     parent::__construct();
     if (!$this->is_active()) {
         return;
     }
     // Currency
     add_filter('em_get_currencies', array($this, 'add_currency'));
     if ($this->single_currency()) {
         add_filter('em_get_currency_formatted', array($this, 'format_price'), 10, 4);
     }
     // Adjust Ticket Columns
     add_filter('em_booking_form_tickets_cols', array($this, 'ticket_columns'), 10, 2);
     add_action('em_booking_form_tickets_col_mycred', array($this, 'ticket_col'), 10, 2);
     add_filter('em_bookings_table_cols_col_action', array($this, 'bookings_table_actions'), 10, 2);
     add_action('em_cart_form_after_totals', array($this, 'checkout_total'));
     // Refund
     if ($this->prefs['refund'] != 0) {
         add_filter('em_booking_set_status', array($this, 'refunds'), 10, 2);
     }
 }
 /**
  * Sets up gateaway and adds relevant actions/filters
  */
 function __construct()
 {
     //Booking Interception
     if ($this->is_active() && absint(get_option('em_' . $this->gateway . '_booking_timeout')) > 0) {
         $this->count_pending_spaces = true;
     }
     parent::__construct();
     $this->status_txt = __('Awaiting PayPal Payment', 'em-pro');
     add_action('admin_enqueue_scripts', array(&$this, 'gateway_admin_js'));
     if ($this->is_active()) {
         add_action('em_gateway_js', array(&$this, 'em_gateway_js'));
         //Gateway-Specific
         add_action('em_template_my_bookings_header', array(&$this, 'say_thanks'));
         //say thanks on my_bookings page
         add_filter('em_bookings_table_booking_actions_4', array(&$this, 'bookings_table_actions'), 1, 2);
         //add_filter('em_my_bookings_booking_actions', array(&$this,'em_my_bookings_booking_actions'),1,2);
         //set up cron
         $timestamp = wp_next_scheduled('emp_paypal_cron');
         if (absint(get_option('em_paypal_booking_timeout')) > 0 && !$timestamp) {
             $result = wp_schedule_event(time(), 'em_minute', 'emp_paypal_cron');
         } elseif (!$timestamp) {
             wp_unschedule_event($timestamp, 'emp_paypal_cron');
         }
     } else {
         //unschedule the cron
         wp_clear_scheduled_hook('emp_paypal_cron');
     }
 }
	/**
	* Set up gateaway and add relevant actions/filters
	*/
	public function __construct() {
		$this->gateway						= EM_EWAY_GATEWAY;
		$this->title						= 'eWAY';
		$this->status						= 4;
		$this->status_txt					= 'Processing (eWAY)';
		$this->button_enabled				= false;
		$this->supports_multiple_bookings	= true;

		// ensure options are present, set to defaults if not
		$defaults = array (
			'em_' . EM_EWAY_GATEWAY . '_option_name'			=> 'Credit Card',
			'em_' . EM_EWAY_GATEWAY . '_booking_feedback'		=> 'Booking successful.',
			'em_' . EM_EWAY_GATEWAY . '_booking_feedback_free'	=> 'Booking successful. You have not been charged for this booking.',
			'em_' . EM_EWAY_GATEWAY . '_cust_id'				=> EWAY_PAYMENTS_TEST_CUSTOMER,
			'em_' . EM_EWAY_GATEWAY . '_stored'					=> '0',
			'em_' . EM_EWAY_GATEWAY . '_beagle'					=> '0',
			'em_' . EM_EWAY_GATEWAY . '_test_force'				=> '1',
			'em_' . EM_EWAY_GATEWAY . '_ssl_force'				=> '1',
			'em_' . EM_EWAY_GATEWAY . '_mode'					=> 'sandbox',
		);
		foreach ($defaults as $option => $value) {
			if (get_option($option) === false) {
				add_option($option, $value);
			}
		}

		// initialise parent class
		parent::__construct();

		if ($this->is_active()) {
			// force SSL for booking submissions on live site, because credit card details need to be encrypted
			if (get_option('em_'.EM_EWAY_GATEWAY.'_mode') == 'live') {
				add_filter('em_wp_localize_script', array(__CLASS__, 'forceBookingAjaxSSL'));
				add_filter('em_booking_form_action_url', array(__CLASS__, 'force_ssl'));
			}

			// force whole bookings page to SSL if settings require
			if (get_option('em_'.EM_EWAY_GATEWAY.'_ssl_force')) {
				add_action('template_redirect', array(__CLASS__, 'redirect_ssl'));
			}

			// perform additional form post validation
			// but only from front -- payment form won't be there in Bookings admin!
			if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
				add_filter('em_booking_validate', array(__CLASS__, 'emBookingValidate'), 10, 2);
				add_filter('em_multiple_booking_validate', array(__CLASS__, 'emBookingValidate'), 10, 2);
			}
		}
	}
 /**
  * Sets up gateaway and adds relevant actions/filters 
  */
 function __construct()
 {
     parent::__construct();
     if ($this->is_active()) {
         //Force SSL for booking submissions, since we have card info
         if (get_option('em_' . $this->gateway . '_mode') == 'live') {
             //no need if in sandbox mode
             add_filter('em_wp_localize_script', array(&$this, 'em_wp_localize_script'), 10, 1);
             //modify booking script, force SSL for all
             add_filter('em_booking_form_action_url', array(&$this, 'force_ssl'), 10, 1);
             //modify booking script, force SSL for all
         }
         //Gateway-Specific
         add_action('em_handle_payment_return_' . $this->gateway, array(&$this, 'handle_payment_return'));
         //handle Silent returns
     }
 }
 /**
  * Sets up gateaway and adds relevant actions/filters 
  */
 function __construct()
 {
     parent::__construct();
     if ($this->is_active()) {
         //Force SSL for booking submissions, since we have card info
         if (get_option('em_' . $this->gateway . '_mode') == 'live') {
             //no need if in sandbox mode
             $this->testmode = "no";
         } else {
             $this->testmode = "yes";
         }
         $this->test_publishable_key = get_option('em_' . $this->gateway . '_test_publishable_key');
         $this->test_secret_key = get_option('em_' . $this->gateway . '_test_secret_key');
         $this->live_publishable_key = get_option('em_' . $this->gateway . '_live_publishable_key');
         $this->live_secret_key = get_option('em_' . $this->gateway . '_live_secret_key');
         $this->SecretKey = $this->testmode == 'yes' ? $this->test_secret_key : $this->live_secret_key;
         $this->debug = get_option('em_' . $this->gateway . '_debug', false);
     }
 }
 /**
  * Sets up gateway and registers actions/filters
  */
 function __construct()
 {
     parent::__construct();
     add_action('init', array(&$this, 'actions'), 10);
     if (!empty($_REQUEST['manual_booking']) && wp_verify_nonce($_REQUEST['manual_booking'], 'em_manual_booking_' . $_REQUEST['event_id'])) {
         add_action('pre_option_dbem_bookings_double', create_function('', 'return true;'));
         //so we don't get a you're already booked here message
     }
     //Booking Interception
     add_filter('em_booking_set_status', array(&$this, 'em_booking_set_status'), 1, 2);
     add_filter('em_bookings_pending_count', array(&$this, 'em_bookings_pending_count'), 1, 1);
     add_filter('em_bookings_get_pending_spaces', array(&$this, 'em_bookings_get_pending_spaces'), 1, 2);
     add_filter('em_bookings_table_booking_actions_5', array(&$this, 'bookings_table_actions'), 1, 2);
     add_filter('em_wp_localize_script', array(&$this, 'em_wp_localize_script'), 1, 1);
     add_action('em_admin_event_booking_options_buttons', array(&$this, 'event_booking_options_buttons'), 10);
     add_action('em_admin_event_booking_options', array(&$this, 'event_booking_options'), 10);
     add_action('em_bookings_single_metabox_footer', array(&$this, 'add_payment_form'), 1, 1);
     //add payment to booking
     //Manual Booking - not necessary for Multi-Booking
     add_action('em_bookings_manual_booking', array(&$this, 'add_booking_form'), 1, 1);
     add_filter('em_booking_get_post', array(&$this, 'em_booking_get_post'), 1, 2);
     add_filter('em_booking_validate', array(&$this, 'em_booking_validate'), 9, 2);
     //before EM_Bookings_Form hooks in
 }