/**
  * run
  *
  * initial shortcode module setup called during "wp_loaded" hook
  * this method is primarily used for loading resources that will be required by the shortcode when it is actually processed
  *
  * @access public
  * @param  WP $WP
  * @return void
  * @throws \Exception
  * @throws \EE_Error
  */
 public function run(WP $WP)
 {
     $this->_current_txn = null;
     if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
         /** @var EEM_Transaction $EEM_Transaction */
         $EEM_Transaction = EE_Registry::instance()->load_model('Transaction');
         $this->_current_txn = $EEM_Transaction->get_transaction_from_reg_url_link();
     }
     if ($this->_current_txn instanceof EE_Transaction) {
         $payment_method = null;
         $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null);
         if ($payment_method_slug) {
             $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug);
         }
         if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) {
             $gateway = $payment_method->type_obj()->get_gateway();
             if ($gateway instanceof EE_Offsite_Gateway && $gateway->handle_IPN_in_this_request(\EE_Registry::instance()->REQ->params(), true)) {
                 /** @type EE_Payment_Processor $payment_processor */
                 $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
                 $payment_processor->process_ipn($_REQUEST, $this->_current_txn, $payment_method);
             }
         }
         //allow gateways to add a filter to stop rendering the page
         if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', FALSE)) {
             exit;
         }
     }
 }
 /**
  * @group 7201
  */
 function test_get_one_by_slug()
 {
     $pm = $this->new_model_obj_with_dependencies('Payment_Method', array('PMD_type' => 'Invoice'));
     $this->assertNotEmpty($pm->ID());
     $this->assertEquals($pm, EEM_Payment_Method::instance()->get_one_by_ID($pm->ID()));
     $this->assertEquals($pm, EEM_Payment_Method::instance()->get_one_by_slug($pm->slug()));
 }
    /**
     * _get_table_filters
     * @return array
     */
    protected function _get_table_filters()
    {
        $filters = array();
        //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
        EE_Registry::instance()->load_helper('Form_Fields');
        $payment_methods = EEM_Payment_Method::instance()->get_all();
        $payment_method_names = array(array('id' => 'all', 'text' => __("All", 'event_espresso')), array('id' => '0', 'text' => __("Unknown Payment Method", 'event_espresso')));
        foreach ($payment_methods as $payment_method) {
            $payment_method_names[] = array('id' => $payment_method->ID(), 'text' => $payment_method->admin_name());
        }
        $filters[] = EEH_Form_Fields::select_input('_payment_method', $payment_method_names, isset($this->_req_data['_payment_method']) ? $this->_req_data['_payment_method'] : 'all');
        $start_date = isset($this->_req_data['payment-filter-start-date']) ? wp_strip_all_tags($this->_req_data['payment-filter-start-date']) : date('m/d/Y', strtotime('-6 months'));
        $end_date = isset($this->_req_data['payment-filter-end-date']) ? wp_strip_all_tags($this->_req_data['payment-filter-end-date']) : date('m/d/Y');
        ob_start();
        ?>
		<label for="txn-filter-start-date"><?php 
        _e('Display Transactions from ', 'event_espresso');
        ?>
</label>
		<input id="payment-filter-start-date" class="datepicker" type="text" value="<?php 
        echo $start_date;
        ?>
" name="payment-filter-start-date" size="15"/>
		<label for="txn-filter-end-date"><?php 
        _e(' until ', 'event_espresso');
        ?>
</label>
		<input id="payment-filter-end-date" class="datepicker" type="text" value="<?php 
        echo $end_date;
        ?>
" name="payment-filter-end-date" size="15"/>
		<?php 
        $filters[] = ob_get_clean();
        return $filters;
    }
 public function __construct($url_link = 0)
 {
     if ($this->registration = EE_Registry::instance()->load_model('Registration')->get_registration_for_reg_url_link($url_link)) {
         $this->transaction = $this->registration->transaction();
         $payment_settings = EE_Config::instance()->gateway->payment_settings;
         //get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
         $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
     } else {
         EE_Error::add_error(__('Your request appears to be missing some required data, and no information for your transaction could be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
     }
 }
    /**
     * Checks that there is at least one active gateway. If not, add a notice
     */
    public function check_payment_gateway_setup()
    {
        //ONLY do this check if models can query
        //and avoid a bug where when we nuke EE4's data that this causes a fatal error
        //because the tables are deleted just before this request runs. see https://events.codebasehq.com/projects/event-espresso/tickets/7539
        if (!EE_Maintenance_Mode::instance()->models_can_query() || !EEH_Activation::table_exists(EEM_Payment_Method::instance()->table())) {
            return;
        }
        // ensure Payment_Method model is loaded
        EE_Registry::instance()->load_model('Payment_Method');
        $actives = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart);
        if ($actives < 1) {
            $url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_PAYMENTS_ADMIN_URL);
            echo '<div class="error">
				 <p>' . sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"), "<a href='{$url}'>", "</a>") . '</p>
			 </div>';
        }
    }
 /**
  *
  * @param array $options_array {
  *	@type string $extra_meta_inputs should be EE_Form_Section_Validatable[] which
  *		will be _subsections and will be saved as extra meta on the payment method object;
  *	@type EE_PMT_Base $payment_method_type the payment method type this form is for
  *	@see EE_Model_Form_Section::__construct() for more
  * }
  */
 public function __construct($options_array = array())
 {
     $this->_model = EEM_Payment_Method::instance();
     $this->_options_array = $options_array;
     if (isset($options_array['payment_method_type'])) {
         $this->_payment_method_type = $options_array['payment_method_type'];
     }
     $options_array = $this->_options_array;
     if (isset($options_array['extra_meta_inputs'])) {
         $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']);
     }
     if ($this->_extra_meta_inputs) {
         $this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs);
     }
     $this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input(array('html_label_text' => __('Button URL', 'event_espresso')));
     $this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input(EEM_Payment_Method::instance()->scopes(), array('html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename() . EEH_Template::get_help_tab_link('payment_methods_overview')));
     //setup the currency options
     $this->_subsections['Currency'] = new EE_Select_Multi_Model_Input(EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type), array('html_label_text' => __('Currencies Supported', 'event_espresso'), 'required' => TRUE));
     $this->_subsections['PMD_order'] = new EE_Text_Input(array('html_help_text' => __('Lowest numbers will be shown first', 'event_espresso'), 'normalization_strategy' => new EE_Int_Normalization(), 'validation_strategies' => array(new EE_Int_Validation_Strategy()), 'default' => 0));
     $this->_layout_strategy = new EE_Admin_Two_Column_Layout();
     parent::__construct($options_array);
 }
 /**
  * This grabs the payment method corresponding to the last payment made for the amount owing on the registration.
  * Note: if there are no payments on the registration there will be no payment method returned.
  *
  * @return EE_Payment_Method|null
  */
 public function payment_method()
 {
     return EEM_Payment_Method::instance()->get_last_used_for_registration($this);
 }
 /**
  * Process the IPN. Firstly, we'll hope we put the standard args into the IPN URL so
  * we can easily find what registration the IPN is for and what payment method.
  * However, if not, we'll give all payment methods a chance to claim it and process it.
  * If a payment is found for the IPN info, it is saved.
  *
  * @param array             $_req_data eg $_REQUEST
  * @param EE_Transaction|int $transaction          optional (or a transactions id)
  * @param EE_Payment_Method $payment_method       (or a slug or id of one)
  * @param boolean           $update_txn           whether or not to call
  *                                                EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()
  * @param bool              $separate_IPN_request whether the IPN uses a separate request ( true like PayPal )
  *                                                or is processed manually ( false like Mijireh )
  * @throws EE_Error
  * @throws Exception
  * @return EE_Payment
  */
 public function process_ipn($_req_data, $transaction = null, $payment_method = null, $update_txn = true, $separate_IPN_request = true)
 {
     EE_Registry::instance()->load_model('Change_Log');
     $_req_data = $this->_remove_unusable_characters_from_array((array) $_req_data);
     EE_Processor_Base::set_IPN($separate_IPN_request);
     $obj_for_log = null;
     if ($transaction instanceof EE_Transaction) {
         $obj_for_log = $transaction;
         if ($payment_method instanceof EE_Payment_Method) {
             $obj_for_log = EEM_Payment::instance()->get_one(array(array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), 'order_by' => array('PAY_timestamp' => 'desc')));
         }
     } else {
         if ($payment_method instanceof EE_Payment) {
             $obj_for_log = $payment_method;
         }
     }
     $log = EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data received' => $_req_data), $obj_for_log);
     try {
         /**
          * @var EE_Payment $payment
          */
         $payment = NULL;
         if ($transaction && $payment_method) {
             /** @type EE_Transaction $transaction */
             $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
             /** @type EE_Payment_Method $payment_method */
             $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method);
             if ($payment_method->type_obj() instanceof EE_PMT_Base) {
                 $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction);
                 $log->set_object($payment);
             } else {
                 // not a payment
                 EE_Error::add_error(sprintf(__('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'), '<br/>', EE_Registry::instance()->CFG->organization->get_pretty('email')), __FILE__, __FUNCTION__, __LINE__);
             }
         } else {
             //that's actually pretty ok. The IPN just wasn't able
             //to identify which transaction or payment method this was for
             // give all active payment methods a chance to claim it
             $active_payment_methods = EEM_Payment_Method::instance()->get_all_active();
             foreach ($active_payment_methods as $active_payment_method) {
                 try {
                     $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data);
                     $payment_method = $active_payment_method;
                     EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data' => $_req_data), $payment);
                     break;
                 } catch (EE_Error $e) {
                     //that's fine- it apparently couldn't handle the IPN
                 }
             }
         }
         // 			EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method);
         if ($payment instanceof EE_Payment) {
             $payment->save();
             //  update the TXN
             $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request);
         } else {
             //we couldn't find the payment for this IPN... let's try and log at least SOMETHING
             if ($payment_method) {
                 EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data' => $_req_data), $payment_method);
             } elseif ($transaction) {
                 EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data' => $_req_data), $transaction);
             }
         }
         return $payment;
     } catch (EE_Error $e) {
         do_action('AHEE__log', __FILE__, __FUNCTION__, sprintf(__('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), print_r($transaction, TRUE), print_r($_req_data, TRUE), $e->getMessage()));
         throw $e;
     }
 }
 /**
  *   _get_active_payment_method_slug
  * 	@return string
  */
 protected function _get_active_payment_method_slug()
 {
     $payment_method_slug = FALSE;
     //decide which payment method tab to open first, as dictated by the request's 'payment_method'
     if (isset($this->_req_data['payment_method'])) {
         // if they provided the current payment method, use it
         $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
     }
     $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
     // if that didn't work or wasn't provided, find another way to select the current pm
     if (!$this->_verify_payment_method($payment_method)) {
         // like, looking for an active one
         $payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
         // test that one as well
         if ($this->_verify_payment_method($payment_method)) {
             $payment_method_slug = $payment_method->slug();
         } else {
             $payment_method_slug = 'paypal_standard';
         }
     }
     return $payment_method_slug;
 }
 protected function _get_started_steps()
 {
     $steps = '<h2>' . __('Getting Started') . '</h2>';
     $step_one = '<p>' . sprintf(__('%sStep 1%s: Visit your %sOrganization Settings%s and add/update your details.', 'event_espresso'), '<strong>', '</strong>', '<a href="admin.php?page=espresso_general_settings">', '</a>') . '</strong></p>';
     $step_two = '<p>' . sprintf(__('%sStep 2%s: Setup your %sPayment Methods%s.', 'event_espresso'), '<strong>', '</strong>', '<a href="admin.php?page=espresso_payment_settings">', '</a>') . '</strong></p>';
     $step_three = '<p>' . sprintf(__('%sStep 3%s: Create your %sFirst Event%s.', 'event_espresso'), '<strong>', '</strong>', '<a href="admin.php?page=espresso_events&action=create_new">', '</a>') . '</strong></p>';
     //done?
     $done_step_one = EE_Registry::instance()->CFG->organization->address_1 == '123 Onna Road' ? FALSE : TRUE;
     $active_invoice_pm = EEM_Payment_Method::instance()->get_one_active(EEM_Payment_Method::scope_cart, array(array('PMD_type' => 'Invoice')));
     $active_pms_count = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart);
     //done step two if a non-invoice paymetn method is active; or there is more than one PM active, or
     //if only the invoice is active but it's clearly been updated
     $done_step_two = $active_pms_count > 1 || $active_pms_count === 1 && !$active_invoice_pm || $active_invoice_pm instanceof EE_Payment_Method && ($active_invoice_pm->get_extra_meta('pdf_payee_name', TRUE, '') || $active_invoice_pm->get_extra_meta('pdf_payee_email', TRUE, '') || $active_invoice_pm->get_extra_meta('pdf_payee_tax_number', TRUE, '') || $active_invoice_pm->get_extra_meta('pdf_payee_address', TRUE, '') || $active_invoice_pm->get_extra_meta('page_extra_info', TRUE, ''));
     $done_step_three = EE_Registry::instance()->load_model('Event')->count() > 0 ? TRUE : FALSE;
     //if ALL steps are done, let's just return FALSE so we don't display anything
     if ($done_step_one && $done_step_two && $done_step_three) {
         return FALSE;
     }
     //now let's put it together
     $steps .= sprintf('%s' . $step_one . '%s', $done_step_one ? '<strike>' : '', $done_step_one ? '</strike>' : '');
     $steps .= sprintf('%s' . $step_two . '%s', $done_step_two ? '<strike>' : '', $done_step_two ? '</strike>' : '');
     $steps .= sprintf('%s' . $step_three . '%s', $done_step_three ? '<strike>' : '', $done_step_three ? '</strike>' : '');
     return $steps;
 }
 /**
  * 	_get_payment_methods
  * Gets all the payment methods available generally, or the ones that are already
  * selected on these payments (in case their payment methods are no longer active).
  * Has the side-effect of updating the template args' payment_methods item
  *	@access private
  * @param EE_Payment[] to show on this page
  *	@return void
  */
 private function _get_payment_methods($payments = array())
 {
     $payment_methods_of_payments = array();
     foreach ($payments as $payment) {
         if ($payment instanceof EE_Payment) {
             $payment_methods_of_payments[] = $payment->get('PMD_ID');
         }
     }
     if ($payment_methods_of_payments) {
         $query_args = array(array('OR*payment_method_for_payment' => array('PMD_ID' => array('IN', $payment_methods_of_payments), 'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'))));
     } else {
         $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
     }
     $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
 }
 /**
  * initialize_reg_step
  * @return boolean
  */
 public function initialize_reg_step()
 {
     // TODO: if /when we implement donations, then this will need overriding
     if (!$this->checkout->payment_required() && !is_callable(array($this, $this->checkout->action)) && !$this->completed()) {
         // and if so, then we no longer need the Payment Options step
         if ($this->is_current_step()) {
             $this->checkout->generate_reg_form = false;
         }
         $this->checkout->remove_reg_step($this->_slug);
         // DEBUG LOG
         //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
         return false;
     }
     // load EEM_Payment_Method
     EE_Registry::instance()->load_model('Payment_Method');
     // get all active payment methods
     $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction($this->checkout->transaction, EEM_Payment_Method::scope_cart);
     return true;
 }
 /**
  * Gets whether this payment method can be used anywhere at all (ie frontend cart, admin, etc)
  * @return boolean
  */
 public function active()
 {
     return array_intersect(array_keys(EEM_Payment_Method::instance()->scopes()), $this->scope());
 }
 /**
  * 	run - initial shortcode module setup called during "wp_loaded" hook
  * 	this method is primarily used for loading resources that will be required by the shortcode when it is actually processed
  *
  *  @access 	public
  *  @param 	 WP $WP
  *  @return 	void
  */
 public function run(WP $WP)
 {
     if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
         $this->_current_txn = EE_Registry::instance()->load_model('Transaction')->get_transaction_from_reg_url_link();
     } else {
         $this->_current_txn = null;
     }
     if ($this->_current_txn instanceof EE_Transaction) {
         //EE_Registry::instance()->load_helper( 'Debug_Tools' );
         //EEH_Debug_Tools::log( __CLASS__, __FUNCTION__, __LINE__, array( $this->_current_txn ), true, 	'EE_Transaction: ' . $this->_current_txn->ID() );
         $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', NULL);
         if ($payment_method_slug) {
             $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug);
         } else {
             $payment_method = null;
         }
         /** @type EE_Payment_Processor $payment_processor */
         $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
         $payment_processor->process_ipn($_REQUEST, $this->_current_txn, $payment_method);
         //allow gateways to add a filter to stop rendering the page
         if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', FALSE)) {
             exit;
         }
     }
 }
 /**
  * set_transaction_payment_method_based_on_registration_statuses
  *
  * sets or unsets the PMD_ID field on the TXN based on the related REG statuses
  * basically if ALL Registrations are "Not Approved", then the EE_Transaction.PMD_ID is set to null,
  * but if any Registration has a different status, then EE_Transaction.PMD_ID is set to either:
  * 		the first "default" Payment Method
  * 		the first active Payment Method
  * 	whichever is found first.
  *
  * @param  EE_Registration $edited_registration
  * @return void
  */
 public function set_transaction_payment_method_based_on_registration_statuses(EE_Registration $edited_registration)
 {
     if ($edited_registration instanceof EE_Registration) {
         $transaction = $edited_registration->transaction();
         if ($transaction instanceof EE_Transaction) {
             $all_not_approved = true;
             foreach ($transaction->registrations() as $registration) {
                 if ($registration instanceof EE_Registration) {
                     // if any REG != "Not Approved" then toggle to false
                     $all_not_approved = $registration->is_not_approved() ? $all_not_approved : false;
                 }
             }
             // if ALL Registrations are "Not Approved"
             if ($all_not_approved) {
                 $transaction->set_payment_method_ID(null);
                 $transaction->save();
             } else {
                 $available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart);
                 if (!empty($available_payment_methods)) {
                     $PMD_ID = 0;
                     foreach ($available_payment_methods as $available_payment_method) {
                         if ($available_payment_method instanceof EE_Payment_Method && $available_payment_method->open_by_default()) {
                             $PMD_ID = $available_payment_method->ID();
                             break;
                         }
                     }
                     if (!$PMD_ID) {
                         $first_payment_method = reset($available_payment_methods);
                         if ($first_payment_method instanceof EE_Payment_Method) {
                             $PMD_ID = $first_payment_method->ID();
                         } else {
                             EE_Error::add_error(__('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
                         }
                     }
                     $transaction->set_payment_method_ID($PMD_ID);
                     $transaction->save();
                 } else {
                     EE_Error::add_error(__('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
                 }
             }
         }
     }
 }
 /**
  * Deactivates a payment method of the given payment method slug.
  *
  * @param string $payment_method_slug The slug for the payment method to deactivate.
  *
  * @return int count of rows updated.
  */
 public function deactivate_payment_method($payment_method_slug)
 {
     EE_Log::instance()->log(__FILE__, __FUNCTION__, sprintf(__('Payment method with slug %1$s is being deactivated by site admin', 'event_espresso'), $payment_method_slug), 'payment_method_change');
     $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope' => array()), array(array('PMD_slug' => $payment_method_slug)));
     return $count_updated;
 }
 /**
  * Processes a direct refund request, saves the payment, and updates the transaction appropriately.
  * @param EE_Payment_Method $payment_method
  * @param EE_Payment        $payment_to_refund
  * @param array             $refund_info
  * @internal param float $amount
  * @return EE_Payment
  */
 public function process_refund($payment_method, $payment_to_refund, $refund_info = array())
 {
     /** @type EE_Payment_Method $payment_method */
     $payment_method = EEM_Payment_Method::instance()->ensure_is_ID($payment_method);
     if ($payment_method->type_obj()->supports_sending_refunds()) {
         $payment_method->do_direct_refund($payment_to_refund, $refund_info);
         $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund);
     }
     return $payment_to_refund;
 }
 /**
  * Deactivates a payment method of the given payment method slug.
  *
  * @param string $payment_method_slug The slug for the payment method to deactivate.
  *
  * @return int count of rows updated.
  */
 public function deactivate_payment_method($payment_method_slug)
 {
     $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope' => array()), array(array('PMD_slug' => $payment_method_slug)));
     return $count_updated;
 }
 function __construct()
 {
     $this->_subsections = array('h1' => new EE_Form_Section_HTML('hello wordl'), 'name' => new EE_Text_Input(array('required' => true, 'default' => 'your name here')), 'email' => new EE_Email_Input(array('required' => false)), 'shirt_size' => new EE_Select_Input(array('' => 'Please select...', 's' => __("Small", "event_espresso"), 'm' => __("Medium", "event_espresso"), 'l' => __("Large", "event_espresso")), array('required' => true, 'default' => 's')), 'month_normal' => new EE_Month_Input(), 'month_leading_zero' => new EE_Month_Input(true), 'year_2' => new EE_Year_Input(false, 1, 1), 'year_4' => new EE_Year_Input(true, 0, 10, array('default' => '2017')), 'yes_no' => new EE_Yes_No_Input(array('html_label_text' => __("Yes or No", "event_espresso"))), 'credit_card' => new EE_Credit_Card_Input(), 'image_1' => new EE_Admin_File_Uploader_Input(), 'image_2' => new EE_Admin_File_Uploader_Input(), 'skillz' => new EE_Checkbox_Multi_Input(array('php' => 'PHP', 'mysql' => 'MYSQL'), array('default' => array('php'))), 'float' => new EE_Float_Input(), 'essay' => new EE_Text_Area_Input(), 'amenities' => new EE_Select_Multiple_Input(array('hottub' => 'Hot Tub', 'balcony' => "Balcony", 'skylight' => 'SkyLight', 'no_axe' => 'No Axe Murderers'), array('default' => array('hottub', 'no_axe'))), 'payment_methods' => new EE_Select_Multi_Model_Input(EEM_Payment_Method::instance()->get_all()));
     $this->_layout_strategy = new EE_Div_Per_Section_Layout();
     parent::__construct();
 }
 /**
  * gets the payment method for this transaction. Otherwise gets a default one.
  */
 private function _get_payment_method($transaction = null)
 {
     if ($transaction instanceof EE_Transaction) {
         $payment_method = $transaction->payment_method();
         if (empty($payment_method)) {
             return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'));
         }
         return $payment_method;
     } else {
         //get the first payment method we can find
         return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'));
     }
 }
 /**
  * Makes sure the default payment method (Invoice) is active.
  * This used to be done automatically as part of constructing the old gateways config
  */
 public static function insert_default_payment_methods()
 {
     if (!EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
         EE_Registry::instance()->load_lib('Payment_Method_Manager');
         EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
     } else {
         EEM_Payment_Method::instance()->verify_button_urls();
     }
 }
 /**
  * Sends a request to mijireh to slurp the current $post, and then redirects the user back to the current page without the
  * special querystring arg indicating to slurp. Also, should temporarily make the current post published, then revert it to its previous status
  */
 public static function slurp_now()
 {
     global $post;
     if ($post->post_status != 'publish') {
         //make sure the post is published at least while slurping
         $post->post_status = 'publish';
         wp_update_post($post);
     }
     $mijireh_gateway = EEM_Payment_Method::instance()->get_one_of_type('Mijireh');
     $access_key = $mijireh_gateway->get_extra_meta('access_key', TRUE);
     // 'slurp_url'=>get_permalink($post),
     // 'page_id'=>$post->ID,
     // 'return_url'=>$return_url
     $url = 'https://secure.mijireh.com/api/1/slurps';
     $args = array('headers' => array('Authorization' => 'Basic ' . base64_encode($access_key . ':'), 'Accept' => 'application/json'), 'body' => json_encode(array('url' => get_permalink($post->ID), 'page_id' => $post->ID, 'return_url' => '')));
     $response = wp_remote_post($url, $args);
     //now redirect the user back to the same page
     $redirect_args = $_GET;
     unset($redirect_args['mijireh_slurp_now']);
     $url = add_query_arg($redirect_args, admin_url('post.php'));
     set_transient(EED_Mijireh_Slurper::slurp_started_transient_name, true);
     // echo "redirect to $url";
     wp_redirect($url);
 }