/** * @param array $input_settings { * @type string $model_name the name of model to be used for searching, both via the REST API and server-side model queries * @type array $query_params default query parameters which will apply to both REST API queries and server-side queries. This should be * in the exact format that will be used for server-side model usage (eg use index 0 for where conditions, not * the string "where") * @type string $value_field_name the name of the model field on this model to * be used for the HTML select's option's values * @type string $display_field_name the name of the model field on this model * to be used for the HTML select's option's display text * @type array $select2_args arguments to be passed directly into the select2's JS constructor * } * And the arguments accepted by EE_Form_Input_With_Options_Base * @throws \EE_Error */ public function __construct($input_settings = array()) { //needed input settings: //select2_args $this->_model_name = EEH_Array::is_set($input_settings, 'model_name', null); $model = $this->_get_model(); $query_params = EEH_Array::is_set($input_settings, 'query_params', array('limit' => 10, 'caps' => EEM_Base::caps_read_admin)); $this->_value_field_name = EEH_Array::is_set($input_settings, 'value_field_name', $model->primary_key_name()); $this->_display_field_name = EEH_Array::is_set($input_settings, 'display_field_name', $model->get_a_field_of_type('EE_Text_Field_Base')->get_name()); $this->_add_validation_strategy(new EE_Model_Matching_Query_Validation_Strategy('', $this->_model_name, $query_params, $this->_value_field_name)); //get resource endpoint $rest_controller = new EventEspresso\core\libraries\rest_api\controllers\model\Read(); $rest_controller->set_requested_version(EED_Core_Rest_Api::latest_rest_api_version()); $url = $rest_controller->get_versioned_link_to(EEH_Inflector::pluralize_and_lower($this->_model_name)); $default_select2_args = array('ajax' => array('url' => $url, 'dataType' => 'json', 'delay' => '250', 'data_interface' => 'EE_Select2_REST_API_Interface', 'data_interface_args' => array('default_query_params' => (object) Model_Data_Translator::prepare_query_params_for_rest_api($query_params, $model), 'display_field' => $this->_display_field_name, 'value_field' => $this->_value_field_name, 'nonce' => wp_create_nonce('wp_rest'))), 'cache' => true, 'width' => '100'); $select2_args = array_replace_recursive($default_select2_args, (array) EEH_Array::is_set($input_settings, 'select2_args', array())); $this->set_display_strategy(new EE_Select2_Display_Strategy($select2_args)); parent::__construct(array(), $input_settings); }
public function test_process_payment__offline() { /** @type EE_Payment_Method $pm */ $pm = $this->new_model_obj_with_dependencies('Payment_Method', array('PMD_type' => 'Admin_Only')); $transaction = $this->_new_typical_transaction(); global $wp_actions; EE_Registry::instance()->load_helper('Array'); $successful_payment_actions = EEH_Array::is_set($wp_actions, 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made', 0); /** @type EE_Payment_Processor $payment_processor */ $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); $payment = $payment_processor->process_payment($pm, $transaction, NULL, NULL, 'success', 'CART', TRUE, TRUE); // offline payments are not saved... because no payment ever actually happened $this->assertEquals(0, $payment->ID()); $this->assertEquals(EEM_Transaction::incomplete_status_code, $transaction->status_ID()); $this->assertEquals($successful_payment_actions + 1, $wp_actions['AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made']); }
/** * Returns TRUE is this payment was set to approved during this request (or * is approved and was created during this request). False otherwise. * @return boolean */ public function just_approved() { EE_Registry::instance()->load_helper('Array'); $original_status = EEH_Array::is_set($this->_props_n_values_provided_in_constructor, 'STS_ID', $this->get_model()->field_settings_for('STS_ID')->get_default_value()); $current_status = $this->status(); if ($original_status !== EEM_Payment::status_id_approved && $current_status === EEM_Payment::status_id_approved) { return TRUE; } else { return FALSE; } }
/** * Returns TRUE is this payment was set to approved during this request (or * is approved and was created during this request). False otherwise. * * @return boolean * @throws \EE_Error */ public function just_approved() { $original_status = EEH_Array::is_set($this->_props_n_values_provided_in_constructor, 'STS_ID', $this->get_model()->field_settings_for('STS_ID')->get_default_value()); $current_status = $this->status(); if ($original_status !== EEM_Payment::status_id_approved && $current_status === EEM_Payment::status_id_approved) { return true; } else { return false; } }