@@ -12,274 +12,274 @@ |
||
| 12 | 12 | { |
| 13 | 13 | |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @param EE_Payment_Method $pm_instance |
|
| 17 | - * @return EE_PMT_Aim |
|
| 18 | - * @throws \EE_Error |
|
| 19 | - */ |
|
| 20 | - public function __construct($pm_instance = null) |
|
| 21 | - { |
|
| 22 | - $this->_setup_properties(); |
|
| 23 | - parent::__construct($pm_instance); |
|
| 24 | - } |
|
| 15 | + /** |
|
| 16 | + * @param EE_Payment_Method $pm_instance |
|
| 17 | + * @return EE_PMT_Aim |
|
| 18 | + * @throws \EE_Error |
|
| 19 | + */ |
|
| 20 | + public function __construct($pm_instance = null) |
|
| 21 | + { |
|
| 22 | + $this->_setup_properties(); |
|
| 23 | + parent::__construct($pm_instance); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Sets up payment method type properties for this gateway, which is normally |
|
| 28 | - * done in the constructor, but we want this to be easy for similar gateways to override |
|
| 29 | - * while still calling the parent constructor. |
|
| 30 | - * So children should override this method instead of __construct |
|
| 31 | - */ |
|
| 32 | - protected function _setup_properties() |
|
| 33 | - { |
|
| 34 | - require_once($this->file_folder().'EEG_Aim.gateway.php'); |
|
| 35 | - $this->_gateway = new EEG_Aim(); |
|
| 36 | - $this->_pretty_name = __("Authorize.net AIM", 'event_espresso'); |
|
| 37 | - $this->_default_description = __('Please provide the following billing information.', 'event_espresso'); |
|
| 38 | - $this->_requires_https = true; |
|
| 39 | - } |
|
| 26 | + /** |
|
| 27 | + * Sets up payment method type properties for this gateway, which is normally |
|
| 28 | + * done in the constructor, but we want this to be easy for similar gateways to override |
|
| 29 | + * while still calling the parent constructor. |
|
| 30 | + * So children should override this method instead of __construct |
|
| 31 | + */ |
|
| 32 | + protected function _setup_properties() |
|
| 33 | + { |
|
| 34 | + require_once($this->file_folder().'EEG_Aim.gateway.php'); |
|
| 35 | + $this->_gateway = new EEG_Aim(); |
|
| 36 | + $this->_pretty_name = __("Authorize.net AIM", 'event_espresso'); |
|
| 37 | + $this->_default_description = __('Please provide the following billing information.', 'event_espresso'); |
|
| 38 | + $this->_requires_https = true; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Creates the billing form for this payment method type |
|
| 45 | - * |
|
| 46 | - * @param \EE_Transaction $transaction |
|
| 47 | - * @return EE_Billing_Info_Form |
|
| 48 | - * @throws \EE_Error |
|
| 49 | - */ |
|
| 50 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
| 51 | - { |
|
| 52 | - $billing_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, array( |
|
| 53 | - 'name'=>'AIM_Form', |
|
| 54 | - 'subsections'=>array( |
|
| 55 | - 'credit_card'=>new EE_Credit_Card_Input(array( |
|
| 56 | - 'required'=>true |
|
| 57 | - )), |
|
| 58 | - 'exp_month'=>new EE_Credit_Card_Month_Input(true, array( |
|
| 59 | - 'required'=>true, |
|
| 60 | - 'html_label_text' => __('Expiry Month', 'event_espresso') |
|
| 61 | - )), |
|
| 62 | - 'exp_year'=>new EE_Credit_Card_Year_Input(array( |
|
| 63 | - 'required'=>true, |
|
| 64 | - 'html_label_text' => __('Expiry Year', 'event_espresso') |
|
| 65 | - )), |
|
| 66 | - 'cvv'=>new EE_CVV_Input(array( |
|
| 67 | - 'required'=>true |
|
| 68 | - )), |
|
| 69 | - ) |
|
| 70 | - )); |
|
| 71 | - $billing_form->add_subsections(array( |
|
| 72 | - 'company' => new EE_Text_Input(array( |
|
| 73 | - 'html_label_text' => __('Company', 'event_espresso') |
|
| 74 | - )) |
|
| 75 | - ), 'email', false); |
|
| 76 | - $billing_form->add_subsections( |
|
| 77 | - array( |
|
| 78 | - 'fax' => new EE_Text_Input(array( |
|
| 79 | - 'html_label_text' => __('Fax', 'event_espresso') |
|
| 80 | - )) |
|
| 81 | - ), |
|
| 82 | - 'phone', |
|
| 83 | - false |
|
| 84 | - ); |
|
| 85 | - $settings_form = $this->settings_form(); |
|
| 86 | - if ($settings_form->get_input('excluded_billing_inputs') instanceof EE_Checkbox_Multi_Input) { |
|
| 87 | - $billing_form->exclude($settings_form->get_input('excluded_billing_inputs')->normalized_value()); |
|
| 88 | - } |
|
| 89 | - if ($settings_form->get_input('required_billing_inputs') instanceof EE_Checkbox_Multi_Input) { |
|
| 90 | - $required_inputs = $settings_form->get_input('required_billing_inputs')->normalized_value(); |
|
| 91 | - // only change the requirement of inputs which are allowed to be changed |
|
| 92 | - /** @var EE_Form_Input_Base[] $inputs_to_evaluate */ |
|
| 93 | - $inputs_to_evaluate = array_intersect_key( |
|
| 94 | - $billing_form->inputs(), |
|
| 95 | - $this->billing_input_names() |
|
| 96 | - ); |
|
| 97 | - foreach ($inputs_to_evaluate as $input_name => $input) { |
|
| 98 | - if (in_array($input_name, $required_inputs)) { |
|
| 99 | - $input->set_required(true); |
|
| 100 | - } else { |
|
| 101 | - $input->set_required(false); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - return $this->apply_billing_form_debug_settings($billing_form); |
|
| 106 | - } |
|
| 43 | + /** |
|
| 44 | + * Creates the billing form for this payment method type |
|
| 45 | + * |
|
| 46 | + * @param \EE_Transaction $transaction |
|
| 47 | + * @return EE_Billing_Info_Form |
|
| 48 | + * @throws \EE_Error |
|
| 49 | + */ |
|
| 50 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
| 51 | + { |
|
| 52 | + $billing_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, array( |
|
| 53 | + 'name'=>'AIM_Form', |
|
| 54 | + 'subsections'=>array( |
|
| 55 | + 'credit_card'=>new EE_Credit_Card_Input(array( |
|
| 56 | + 'required'=>true |
|
| 57 | + )), |
|
| 58 | + 'exp_month'=>new EE_Credit_Card_Month_Input(true, array( |
|
| 59 | + 'required'=>true, |
|
| 60 | + 'html_label_text' => __('Expiry Month', 'event_espresso') |
|
| 61 | + )), |
|
| 62 | + 'exp_year'=>new EE_Credit_Card_Year_Input(array( |
|
| 63 | + 'required'=>true, |
|
| 64 | + 'html_label_text' => __('Expiry Year', 'event_espresso') |
|
| 65 | + )), |
|
| 66 | + 'cvv'=>new EE_CVV_Input(array( |
|
| 67 | + 'required'=>true |
|
| 68 | + )), |
|
| 69 | + ) |
|
| 70 | + )); |
|
| 71 | + $billing_form->add_subsections(array( |
|
| 72 | + 'company' => new EE_Text_Input(array( |
|
| 73 | + 'html_label_text' => __('Company', 'event_espresso') |
|
| 74 | + )) |
|
| 75 | + ), 'email', false); |
|
| 76 | + $billing_form->add_subsections( |
|
| 77 | + array( |
|
| 78 | + 'fax' => new EE_Text_Input(array( |
|
| 79 | + 'html_label_text' => __('Fax', 'event_espresso') |
|
| 80 | + )) |
|
| 81 | + ), |
|
| 82 | + 'phone', |
|
| 83 | + false |
|
| 84 | + ); |
|
| 85 | + $settings_form = $this->settings_form(); |
|
| 86 | + if ($settings_form->get_input('excluded_billing_inputs') instanceof EE_Checkbox_Multi_Input) { |
|
| 87 | + $billing_form->exclude($settings_form->get_input('excluded_billing_inputs')->normalized_value()); |
|
| 88 | + } |
|
| 89 | + if ($settings_form->get_input('required_billing_inputs') instanceof EE_Checkbox_Multi_Input) { |
|
| 90 | + $required_inputs = $settings_form->get_input('required_billing_inputs')->normalized_value(); |
|
| 91 | + // only change the requirement of inputs which are allowed to be changed |
|
| 92 | + /** @var EE_Form_Input_Base[] $inputs_to_evaluate */ |
|
| 93 | + $inputs_to_evaluate = array_intersect_key( |
|
| 94 | + $billing_form->inputs(), |
|
| 95 | + $this->billing_input_names() |
|
| 96 | + ); |
|
| 97 | + foreach ($inputs_to_evaluate as $input_name => $input) { |
|
| 98 | + if (in_array($input_name, $required_inputs)) { |
|
| 99 | + $input->set_required(true); |
|
| 100 | + } else { |
|
| 101 | + $input->set_required(false); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + return $this->apply_billing_form_debug_settings($billing_form); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * apply_billing_form_debug_settings |
|
| 112 | - * applies debug data to the form |
|
| 113 | - * |
|
| 114 | - * @param \EE_Billing_Info_Form $billing_form |
|
| 115 | - * @return \EE_Billing_Info_Form |
|
| 116 | - * @throws \EE_Error |
|
| 117 | - */ |
|
| 118 | - public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
| 119 | - { |
|
| 120 | - if ($this->_pm_instance->debug_mode() |
|
| 121 | - || $this->_pm_instance->get_extra_meta('test_transactions', true, false) |
|
| 122 | - ) { |
|
| 123 | - $billing_form->get_input('credit_card')->set_default('4007000000027'); |
|
| 124 | - $billing_form->get_input('exp_year')->set_default('2020'); |
|
| 125 | - if ($billing_form->get_subsection('cvv') instanceof EE_Form_Input_Base) { |
|
| 126 | - $billing_form->get_input('cvv')->set_default('123'); |
|
| 127 | - } |
|
| 128 | - $billing_form->add_subsections( |
|
| 129 | - array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ), |
|
| 130 | - 'credit_card' |
|
| 131 | - ); |
|
| 132 | - $billing_form->add_subsections( |
|
| 133 | - array( |
|
| 134 | - 'debug_content' => new EE_Form_Section_HTML_From_Template( |
|
| 135 | - __DIR__.'/templates/authorize_net_aim_debug_info.template.php' |
|
| 136 | - ) |
|
| 137 | - ), |
|
| 138 | - 'first_name' |
|
| 139 | - ); |
|
| 140 | - } |
|
| 141 | - return $billing_form; |
|
| 142 | - } |
|
| 110 | + /** |
|
| 111 | + * apply_billing_form_debug_settings |
|
| 112 | + * applies debug data to the form |
|
| 113 | + * |
|
| 114 | + * @param \EE_Billing_Info_Form $billing_form |
|
| 115 | + * @return \EE_Billing_Info_Form |
|
| 116 | + * @throws \EE_Error |
|
| 117 | + */ |
|
| 118 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
| 119 | + { |
|
| 120 | + if ($this->_pm_instance->debug_mode() |
|
| 121 | + || $this->_pm_instance->get_extra_meta('test_transactions', true, false) |
|
| 122 | + ) { |
|
| 123 | + $billing_form->get_input('credit_card')->set_default('4007000000027'); |
|
| 124 | + $billing_form->get_input('exp_year')->set_default('2020'); |
|
| 125 | + if ($billing_form->get_subsection('cvv') instanceof EE_Form_Input_Base) { |
|
| 126 | + $billing_form->get_input('cvv')->set_default('123'); |
|
| 127 | + } |
|
| 128 | + $billing_form->add_subsections( |
|
| 129 | + array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ), |
|
| 130 | + 'credit_card' |
|
| 131 | + ); |
|
| 132 | + $billing_form->add_subsections( |
|
| 133 | + array( |
|
| 134 | + 'debug_content' => new EE_Form_Section_HTML_From_Template( |
|
| 135 | + __DIR__.'/templates/authorize_net_aim_debug_info.template.php' |
|
| 136 | + ) |
|
| 137 | + ), |
|
| 138 | + 'first_name' |
|
| 139 | + ); |
|
| 140 | + } |
|
| 141 | + return $billing_form; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | |
| 145 | 145 | |
| 146 | - /** |
|
| 147 | - * Gets the form for all the settings related to this payment method type |
|
| 148 | - * @return EE_Payment_Method_Form |
|
| 149 | - */ |
|
| 150 | - public function generate_new_settings_form() |
|
| 151 | - { |
|
| 152 | - $billing_input_names = $this->billing_input_names(); |
|
| 153 | - return new EE_Payment_Method_Form( |
|
| 154 | - array( |
|
| 155 | - 'extra_meta_inputs'=>array( |
|
| 156 | - 'login_id'=>new EE_Text_Input( |
|
| 157 | - array( |
|
| 158 | - 'html_label_text'=> sprintf(__("Authorize.net API Login ID %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 159 | - 'required' => true ) |
|
| 160 | - ), |
|
| 161 | - 'transaction_key'=>new EE_Text_Input( |
|
| 162 | - array( |
|
| 163 | - 'html_label_text'=> sprintf(__("Authorize.net Transaction Key %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 164 | - 'required' => true ) |
|
| 165 | - ), |
|
| 166 | - 'test_transactions'=>new EE_Yes_No_Input( |
|
| 167 | - array( |
|
| 168 | - 'html_label_text'=> sprintf(__("Send test transactions? %s", 'event_espresso'), $this->get_help_tab_link()), |
|
| 169 | - 'html_help_text'=> __("Send test transactions, even to live server", 'event_espresso'), |
|
| 170 | - 'default' => false, |
|
| 171 | - 'required' => true |
|
| 172 | - ) |
|
| 173 | - ), |
|
| 174 | - 'excluded_billing_inputs' => new EE_Checkbox_Multi_Input( |
|
| 175 | - $billing_input_names, |
|
| 176 | - array( |
|
| 177 | - 'html_label_text' => sprintf(__("Excluded Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), |
|
| 178 | - 'default' => array( |
|
| 179 | - 'company', |
|
| 180 | - 'fax', |
|
| 181 | - ) |
|
| 182 | - ) |
|
| 183 | - ), |
|
| 184 | - 'required_billing_inputs' => new EE_Checkbox_Multi_Input( |
|
| 185 | - $billing_input_names, |
|
| 186 | - array( |
|
| 187 | - 'html_label_text' => sprintf(__("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), |
|
| 188 | - 'default' => array_diff( |
|
| 189 | - array_keys($billing_input_names), |
|
| 190 | - array( 'address2', 'phone', 'company', 'fax' ) |
|
| 191 | - ), |
|
| 192 | - 'html_help_text' => __('Note: if fields are excluded they cannot be required.', 'event_espresso') |
|
| 193 | - ) |
|
| 194 | - ), |
|
| 195 | - 'server' => new EE_Select_Input( |
|
| 196 | - apply_filters( |
|
| 197 | - 'FHEE__EE_PMT_Aim__generate_new_settings_form__server_select_input__options', |
|
| 198 | - array( |
|
| 199 | - 'akamai' => __('Authorize.net/Akamai (default)', 'event_espresso'), |
|
| 200 | - 'authorize.net' => __('Authorize.net (deprecated)', 'event_espresso'), |
|
| 201 | - ), |
|
| 202 | - $this |
|
| 203 | - ), |
|
| 204 | - array( |
|
| 205 | - 'html_label_text' => __('Server', 'event_espresso'), |
|
| 206 | - 'html_help_text' => __('The Gateway Server where payment requests will be sent', 'event_espresso') |
|
| 207 | - ) |
|
| 208 | - ) |
|
| 146 | + /** |
|
| 147 | + * Gets the form for all the settings related to this payment method type |
|
| 148 | + * @return EE_Payment_Method_Form |
|
| 149 | + */ |
|
| 150 | + public function generate_new_settings_form() |
|
| 151 | + { |
|
| 152 | + $billing_input_names = $this->billing_input_names(); |
|
| 153 | + return new EE_Payment_Method_Form( |
|
| 154 | + array( |
|
| 155 | + 'extra_meta_inputs'=>array( |
|
| 156 | + 'login_id'=>new EE_Text_Input( |
|
| 157 | + array( |
|
| 158 | + 'html_label_text'=> sprintf(__("Authorize.net API Login ID %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 159 | + 'required' => true ) |
|
| 160 | + ), |
|
| 161 | + 'transaction_key'=>new EE_Text_Input( |
|
| 162 | + array( |
|
| 163 | + 'html_label_text'=> sprintf(__("Authorize.net Transaction Key %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 164 | + 'required' => true ) |
|
| 165 | + ), |
|
| 166 | + 'test_transactions'=>new EE_Yes_No_Input( |
|
| 167 | + array( |
|
| 168 | + 'html_label_text'=> sprintf(__("Send test transactions? %s", 'event_espresso'), $this->get_help_tab_link()), |
|
| 169 | + 'html_help_text'=> __("Send test transactions, even to live server", 'event_espresso'), |
|
| 170 | + 'default' => false, |
|
| 171 | + 'required' => true |
|
| 172 | + ) |
|
| 173 | + ), |
|
| 174 | + 'excluded_billing_inputs' => new EE_Checkbox_Multi_Input( |
|
| 175 | + $billing_input_names, |
|
| 176 | + array( |
|
| 177 | + 'html_label_text' => sprintf(__("Excluded Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), |
|
| 178 | + 'default' => array( |
|
| 179 | + 'company', |
|
| 180 | + 'fax', |
|
| 181 | + ) |
|
| 182 | + ) |
|
| 183 | + ), |
|
| 184 | + 'required_billing_inputs' => new EE_Checkbox_Multi_Input( |
|
| 185 | + $billing_input_names, |
|
| 186 | + array( |
|
| 187 | + 'html_label_text' => sprintf(__("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), |
|
| 188 | + 'default' => array_diff( |
|
| 189 | + array_keys($billing_input_names), |
|
| 190 | + array( 'address2', 'phone', 'company', 'fax' ) |
|
| 191 | + ), |
|
| 192 | + 'html_help_text' => __('Note: if fields are excluded they cannot be required.', 'event_espresso') |
|
| 193 | + ) |
|
| 194 | + ), |
|
| 195 | + 'server' => new EE_Select_Input( |
|
| 196 | + apply_filters( |
|
| 197 | + 'FHEE__EE_PMT_Aim__generate_new_settings_form__server_select_input__options', |
|
| 198 | + array( |
|
| 199 | + 'akamai' => __('Authorize.net/Akamai (default)', 'event_espresso'), |
|
| 200 | + 'authorize.net' => __('Authorize.net (deprecated)', 'event_espresso'), |
|
| 201 | + ), |
|
| 202 | + $this |
|
| 203 | + ), |
|
| 204 | + array( |
|
| 205 | + 'html_label_text' => __('Server', 'event_espresso'), |
|
| 206 | + 'html_help_text' => __('The Gateway Server where payment requests will be sent', 'event_espresso') |
|
| 207 | + ) |
|
| 208 | + ) |
|
| 209 | 209 | |
| 210 | - ) |
|
| 211 | - ) |
|
| 212 | - ); |
|
| 213 | - } |
|
| 210 | + ) |
|
| 211 | + ) |
|
| 212 | + ); |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Returns an array where keys are the slugs for billing inputs, and values |
|
| 217 | - * are their i18n names |
|
| 218 | - * @return array |
|
| 219 | - */ |
|
| 220 | - public function billing_input_names() |
|
| 221 | - { |
|
| 222 | - return array( |
|
| 223 | - 'first_name' => __('First Name', 'event_espresso'), |
|
| 224 | - 'last_name' => __('Last Name', 'event_espresso'), |
|
| 225 | - 'email' => __('Email', 'event_espresso'), |
|
| 226 | - 'company' => __('Company', 'event_espresso'), |
|
| 227 | - 'address' => __('Address', 'event_espresso'), |
|
| 228 | - 'address2' => __('Address2', 'event_espresso'), |
|
| 229 | - 'city' => __('City', 'event_espresso'), |
|
| 230 | - 'state' => __('State', 'event_espresso'), |
|
| 231 | - 'country' => __('Country', 'event_espresso'), |
|
| 232 | - 'zip' => __('Zip', 'event_espresso'), |
|
| 233 | - 'phone' => __('Phone', 'event_espresso'), |
|
| 234 | - 'fax' => __('Fax', 'event_espresso'), |
|
| 235 | - 'cvv' => __('CVV', 'event_espresso') |
|
| 236 | - ); |
|
| 237 | - } |
|
| 215 | + /** |
|
| 216 | + * Returns an array where keys are the slugs for billing inputs, and values |
|
| 217 | + * are their i18n names |
|
| 218 | + * @return array |
|
| 219 | + */ |
|
| 220 | + public function billing_input_names() |
|
| 221 | + { |
|
| 222 | + return array( |
|
| 223 | + 'first_name' => __('First Name', 'event_espresso'), |
|
| 224 | + 'last_name' => __('Last Name', 'event_espresso'), |
|
| 225 | + 'email' => __('Email', 'event_espresso'), |
|
| 226 | + 'company' => __('Company', 'event_espresso'), |
|
| 227 | + 'address' => __('Address', 'event_espresso'), |
|
| 228 | + 'address2' => __('Address2', 'event_espresso'), |
|
| 229 | + 'city' => __('City', 'event_espresso'), |
|
| 230 | + 'state' => __('State', 'event_espresso'), |
|
| 231 | + 'country' => __('Country', 'event_espresso'), |
|
| 232 | + 'zip' => __('Zip', 'event_espresso'), |
|
| 233 | + 'phone' => __('Phone', 'event_espresso'), |
|
| 234 | + 'fax' => __('Fax', 'event_espresso'), |
|
| 235 | + 'cvv' => __('CVV', 'event_espresso') |
|
| 236 | + ); |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - /** |
|
| 240 | - * Overrides parent so we always have all billing inputs in the returned array, |
|
| 241 | - * not just the ones included at the time. This helps simplify the gateway code |
|
| 242 | - * |
|
| 243 | - * @param EE_Billing_Info_Form $billing_form |
|
| 244 | - * @return array |
|
| 245 | - */ |
|
| 246 | - protected function _get_billing_values_from_form($billing_form) |
|
| 247 | - { |
|
| 248 | - $all_billing_values_empty = array(); |
|
| 249 | - foreach (array_keys($this->billing_input_names()) as $input_name) { |
|
| 250 | - $all_billing_values_empty[ $input_name ] = ''; |
|
| 251 | - } |
|
| 252 | - return array_merge( |
|
| 253 | - $all_billing_values_empty, |
|
| 254 | - parent::_get_billing_values_from_form($billing_form) |
|
| 255 | - ); |
|
| 256 | - } |
|
| 239 | + /** |
|
| 240 | + * Overrides parent so we always have all billing inputs in the returned array, |
|
| 241 | + * not just the ones included at the time. This helps simplify the gateway code |
|
| 242 | + * |
|
| 243 | + * @param EE_Billing_Info_Form $billing_form |
|
| 244 | + * @return array |
|
| 245 | + */ |
|
| 246 | + protected function _get_billing_values_from_form($billing_form) |
|
| 247 | + { |
|
| 248 | + $all_billing_values_empty = array(); |
|
| 249 | + foreach (array_keys($this->billing_input_names()) as $input_name) { |
|
| 250 | + $all_billing_values_empty[ $input_name ] = ''; |
|
| 251 | + } |
|
| 252 | + return array_merge( |
|
| 253 | + $all_billing_values_empty, |
|
| 254 | + parent::_get_billing_values_from_form($billing_form) |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | 258 | |
| 259 | 259 | |
| 260 | - /** |
|
| 261 | - * Adds the help tab |
|
| 262 | - * @see EE_PMT_Base::help_tabs_config() |
|
| 263 | - * @return array |
|
| 264 | - */ |
|
| 265 | - public function help_tabs_config() |
|
| 266 | - { |
|
| 267 | - return array( |
|
| 268 | - $this->get_help_tab_name() => array( |
|
| 269 | - 'title' => __('Authorize.net AIM Settings', 'event_espresso'), |
|
| 270 | - 'filename' => 'payment_methods_overview_aim' |
|
| 271 | - ), |
|
| 272 | - ); |
|
| 273 | - } |
|
| 260 | + /** |
|
| 261 | + * Adds the help tab |
|
| 262 | + * @see EE_PMT_Base::help_tabs_config() |
|
| 263 | + * @return array |
|
| 264 | + */ |
|
| 265 | + public function help_tabs_config() |
|
| 266 | + { |
|
| 267 | + return array( |
|
| 268 | + $this->get_help_tab_name() => array( |
|
| 269 | + 'title' => __('Authorize.net AIM Settings', 'event_espresso'), |
|
| 270 | + 'filename' => 'payment_methods_overview_aim' |
|
| 271 | + ), |
|
| 272 | + ); |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | 275 | |
| 276 | 276 | |
| 277 | - /** |
|
| 278 | - * Gets a list of instructions and/or information regarding how the payment is to be completed |
|
| 279 | - * @return string |
|
| 280 | - */ |
|
| 281 | - public function payment_information() |
|
| 282 | - { |
|
| 283 | - // TODO: Implement payment_information() method. |
|
| 284 | - } |
|
| 277 | + /** |
|
| 278 | + * Gets a list of instructions and/or information regarding how the payment is to be completed |
|
| 279 | + * @return string |
|
| 280 | + */ |
|
| 281 | + public function payment_information() |
|
| 282 | + { |
|
| 283 | + // TODO: Implement payment_information() method. |
|
| 284 | + } |
|
| 285 | 285 | } |
@@ -14,182 +14,182 @@ |
||
| 14 | 14 | class EE_PMT_Paypal_Pro extends EE_PMT_Base |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @param EE_Payment_Method $pm_instance |
|
| 19 | - * @return EE_PMT_Paypal_Pro |
|
| 20 | - */ |
|
| 21 | - public function __construct($pm_instance = null) |
|
| 22 | - { |
|
| 23 | - require_once($this->file_folder().'EEG_Paypal_Pro.gateway.php'); |
|
| 24 | - $this->_gateway = new EEG_Paypal_Pro(); |
|
| 25 | - $this->_pretty_name = __("Paypal Pro", 'event_espresso'); |
|
| 26 | - $this->_default_description = __('Please provide the following billing information.', 'event_espresso'); |
|
| 27 | - $this->_requires_https = true; |
|
| 28 | - parent::__construct($pm_instance); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Gets the form for all the settings related to this payment method type |
|
| 34 | - * @return EE_Payment_Method_Form |
|
| 35 | - * @throws InvalidArgumentException |
|
| 36 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 37 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 38 | - */ |
|
| 39 | - public function generate_new_settings_form() |
|
| 40 | - { |
|
| 41 | - return new PayPalProSettingsForm(array(), $this->get_help_tab_link()); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Creates the billing form for this payment method type |
|
| 47 | - * @param \EE_Transaction $transaction |
|
| 48 | - * @throws \EE_Error |
|
| 49 | - * @return EE_Billing_Info_Form |
|
| 50 | - */ |
|
| 51 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
| 52 | - { |
|
| 53 | - $allowed_types = $this->_pm_instance->get_extra_meta('credit_card_types', true); |
|
| 54 | - // if allowed types is a string or empty array or null... |
|
| 55 | - if (empty($allowed_types)) { |
|
| 56 | - $allowed_types = array(); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - $billing_form = new EE_Billing_Attendee_Info_Form( |
|
| 60 | - $this->_pm_instance, |
|
| 61 | - array( |
|
| 62 | - 'name'=> 'Paypal_Pro_Billing_Form', |
|
| 63 | - // 'html_id'=> 'ee-Paypal_Pro-billing-form', |
|
| 64 | - 'subsections'=>array( |
|
| 65 | - 'credit_card'=>new EE_Credit_Card_Input( |
|
| 66 | - array( 'required'=>true, 'html_class' => 'ee-billing-qstn') |
|
| 67 | - ), |
|
| 68 | - 'credit_card_type'=>new EE_Select_Input( |
|
| 69 | - // the options are set dynamically |
|
| 70 | - array_intersect_key(EE_PMT_Paypal_Pro::card_types_supported(), array_flip($allowed_types)), |
|
| 71 | - array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Type', 'event_espresso')) |
|
| 72 | - ), |
|
| 73 | - 'exp_month'=>new EE_Credit_Card_Month_Input( |
|
| 74 | - true, |
|
| 75 | - array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Month', 'event_espresso') ) |
|
| 76 | - ), |
|
| 77 | - 'exp_year'=>new EE_Credit_Card_Year_Input( |
|
| 78 | - array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Year', 'event_espresso') ) |
|
| 79 | - ), |
|
| 80 | - 'cvv'=>new EE_CVV_Input( |
|
| 81 | - array( 'required'=>true, 'html_class' => 'ee-billing-qstn' ) |
|
| 82 | - ), |
|
| 83 | - ) |
|
| 84 | - ) |
|
| 85 | - ); |
|
| 86 | - return $this->apply_billing_form_debug_settings($billing_form); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * apply_billing_form_debug_settings |
|
| 93 | - * applies debug data to the form |
|
| 94 | - * |
|
| 95 | - * @param \EE_Billing_Info_Form $billing_form |
|
| 96 | - * @return \EE_Billing_Info_Form |
|
| 97 | - */ |
|
| 98 | - public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
| 99 | - { |
|
| 100 | - if ($this->_pm_instance->debug_mode()) { |
|
| 101 | - $billing_form->add_subsections( |
|
| 102 | - array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ), |
|
| 103 | - 'credit_card' |
|
| 104 | - ); |
|
| 105 | - $billing_form->add_subsections( |
|
| 106 | - array( 'debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__).'/templates/paypal_pro_debug_info.template.php')), |
|
| 107 | - 'first_name' |
|
| 108 | - ); |
|
| 109 | - $billing_form->get_input('credit_card_type')->set_default('Visa'); |
|
| 110 | - $billing_form->get_input('exp_year')->set_default(2018); |
|
| 111 | - $billing_form->get_input('cvv')->set_default('115'); |
|
| 112 | - } |
|
| 113 | - return $billing_form; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * Returns an array of all the payment cards possibly supported by paypal pro. |
|
| 120 | - * Keys are their values, values are their pretty names. |
|
| 121 | - * @return array |
|
| 122 | - */ |
|
| 123 | - public static function card_types_supported() |
|
| 124 | - { |
|
| 125 | - return array( |
|
| 126 | - 'Visa'=> __("Visa", 'event_espresso'), |
|
| 127 | - 'MasterCard'=> __("MasterCard", 'event_espresso'), |
|
| 128 | - 'Amex'=> __("American Express", 'event_espresso'), |
|
| 129 | - 'Discover'=> __("Discover", 'event_espresso') |
|
| 130 | - ); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Adds the help tab |
|
| 137 | - * @see EE_PMT_Base::help_tabs_config() |
|
| 138 | - * @return array |
|
| 139 | - */ |
|
| 140 | - public function help_tabs_config() |
|
| 141 | - { |
|
| 142 | - return array( |
|
| 143 | - $this->get_help_tab_name() => array( |
|
| 144 | - 'title' => __('PayPal Pro Settings', 'event_espresso'), |
|
| 145 | - 'filename' => 'payment_methods_overview_paypalpro' |
|
| 146 | - ), |
|
| 147 | - ); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * Overrides parent's _get_billing_values_from_form because we want to |
|
| 152 | - * get the country's 2-character ISO code, not the name like most gateways |
|
| 153 | - * @param EE_Billing_Info_Form $billing_form |
|
| 154 | - * @return array |
|
| 155 | - */ |
|
| 156 | - protected function _get_billing_values_from_form($billing_form) |
|
| 157 | - { |
|
| 158 | - $billing_values = parent::_get_billing_values_from_form($billing_form); |
|
| 159 | - $billing_values['country'] = $billing_form->get_input_value('country'); |
|
| 160 | - $billing_values['credit_card_type'] = $billing_form->get_input_value('credit_card_type'); |
|
| 161 | - return $billing_values; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Override parent to account for a change in extra meta inputs in 4.9.75.p |
|
| 166 | - * @since 4.9.79.p |
|
| 167 | - * @param EE_Payment_Method $payment_method_instance |
|
| 168 | - * @throws EE_Error |
|
| 169 | - * @throws InvalidArgumentException |
|
| 170 | - * @throws ReflectionException |
|
| 171 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 172 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 173 | - */ |
|
| 174 | - public function set_instance($payment_method_instance) |
|
| 175 | - { |
|
| 176 | - // Check for the old extra meta inputs |
|
| 177 | - $old_extra_metas = EEM_Extra_Meta::instance()->get_all( |
|
| 178 | - [ |
|
| 179 | - [ |
|
| 180 | - 'EXM_type' => 'Payment_Method', |
|
| 181 | - 'OBJ_ID' => $payment_method_instance->ID(), |
|
| 182 | - 'EXM_key' => ['IN', ['username', 'password', 'signature']], |
|
| 183 | - ] |
|
| 184 | - ] |
|
| 185 | - ); |
|
| 186 | - // If they existed, set the new ones instead |
|
| 187 | - if (!empty($old_extra_metas)) { |
|
| 188 | - foreach ($old_extra_metas as $old_extra_meta) { |
|
| 189 | - $old_extra_meta->set('EXM_key', 'api_' . $old_extra_meta->get('EXM_key')); |
|
| 190 | - $old_extra_meta->save(); |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - return parent::set_instance($payment_method_instance); |
|
| 194 | - } |
|
| 17 | + /** |
|
| 18 | + * @param EE_Payment_Method $pm_instance |
|
| 19 | + * @return EE_PMT_Paypal_Pro |
|
| 20 | + */ |
|
| 21 | + public function __construct($pm_instance = null) |
|
| 22 | + { |
|
| 23 | + require_once($this->file_folder().'EEG_Paypal_Pro.gateway.php'); |
|
| 24 | + $this->_gateway = new EEG_Paypal_Pro(); |
|
| 25 | + $this->_pretty_name = __("Paypal Pro", 'event_espresso'); |
|
| 26 | + $this->_default_description = __('Please provide the following billing information.', 'event_espresso'); |
|
| 27 | + $this->_requires_https = true; |
|
| 28 | + parent::__construct($pm_instance); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Gets the form for all the settings related to this payment method type |
|
| 34 | + * @return EE_Payment_Method_Form |
|
| 35 | + * @throws InvalidArgumentException |
|
| 36 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 37 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 38 | + */ |
|
| 39 | + public function generate_new_settings_form() |
|
| 40 | + { |
|
| 41 | + return new PayPalProSettingsForm(array(), $this->get_help_tab_link()); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Creates the billing form for this payment method type |
|
| 47 | + * @param \EE_Transaction $transaction |
|
| 48 | + * @throws \EE_Error |
|
| 49 | + * @return EE_Billing_Info_Form |
|
| 50 | + */ |
|
| 51 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
| 52 | + { |
|
| 53 | + $allowed_types = $this->_pm_instance->get_extra_meta('credit_card_types', true); |
|
| 54 | + // if allowed types is a string or empty array or null... |
|
| 55 | + if (empty($allowed_types)) { |
|
| 56 | + $allowed_types = array(); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + $billing_form = new EE_Billing_Attendee_Info_Form( |
|
| 60 | + $this->_pm_instance, |
|
| 61 | + array( |
|
| 62 | + 'name'=> 'Paypal_Pro_Billing_Form', |
|
| 63 | + // 'html_id'=> 'ee-Paypal_Pro-billing-form', |
|
| 64 | + 'subsections'=>array( |
|
| 65 | + 'credit_card'=>new EE_Credit_Card_Input( |
|
| 66 | + array( 'required'=>true, 'html_class' => 'ee-billing-qstn') |
|
| 67 | + ), |
|
| 68 | + 'credit_card_type'=>new EE_Select_Input( |
|
| 69 | + // the options are set dynamically |
|
| 70 | + array_intersect_key(EE_PMT_Paypal_Pro::card_types_supported(), array_flip($allowed_types)), |
|
| 71 | + array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Type', 'event_espresso')) |
|
| 72 | + ), |
|
| 73 | + 'exp_month'=>new EE_Credit_Card_Month_Input( |
|
| 74 | + true, |
|
| 75 | + array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Month', 'event_espresso') ) |
|
| 76 | + ), |
|
| 77 | + 'exp_year'=>new EE_Credit_Card_Year_Input( |
|
| 78 | + array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Year', 'event_espresso') ) |
|
| 79 | + ), |
|
| 80 | + 'cvv'=>new EE_CVV_Input( |
|
| 81 | + array( 'required'=>true, 'html_class' => 'ee-billing-qstn' ) |
|
| 82 | + ), |
|
| 83 | + ) |
|
| 84 | + ) |
|
| 85 | + ); |
|
| 86 | + return $this->apply_billing_form_debug_settings($billing_form); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * apply_billing_form_debug_settings |
|
| 93 | + * applies debug data to the form |
|
| 94 | + * |
|
| 95 | + * @param \EE_Billing_Info_Form $billing_form |
|
| 96 | + * @return \EE_Billing_Info_Form |
|
| 97 | + */ |
|
| 98 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
| 99 | + { |
|
| 100 | + if ($this->_pm_instance->debug_mode()) { |
|
| 101 | + $billing_form->add_subsections( |
|
| 102 | + array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ), |
|
| 103 | + 'credit_card' |
|
| 104 | + ); |
|
| 105 | + $billing_form->add_subsections( |
|
| 106 | + array( 'debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__).'/templates/paypal_pro_debug_info.template.php')), |
|
| 107 | + 'first_name' |
|
| 108 | + ); |
|
| 109 | + $billing_form->get_input('credit_card_type')->set_default('Visa'); |
|
| 110 | + $billing_form->get_input('exp_year')->set_default(2018); |
|
| 111 | + $billing_form->get_input('cvv')->set_default('115'); |
|
| 112 | + } |
|
| 113 | + return $billing_form; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * Returns an array of all the payment cards possibly supported by paypal pro. |
|
| 120 | + * Keys are their values, values are their pretty names. |
|
| 121 | + * @return array |
|
| 122 | + */ |
|
| 123 | + public static function card_types_supported() |
|
| 124 | + { |
|
| 125 | + return array( |
|
| 126 | + 'Visa'=> __("Visa", 'event_espresso'), |
|
| 127 | + 'MasterCard'=> __("MasterCard", 'event_espresso'), |
|
| 128 | + 'Amex'=> __("American Express", 'event_espresso'), |
|
| 129 | + 'Discover'=> __("Discover", 'event_espresso') |
|
| 130 | + ); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Adds the help tab |
|
| 137 | + * @see EE_PMT_Base::help_tabs_config() |
|
| 138 | + * @return array |
|
| 139 | + */ |
|
| 140 | + public function help_tabs_config() |
|
| 141 | + { |
|
| 142 | + return array( |
|
| 143 | + $this->get_help_tab_name() => array( |
|
| 144 | + 'title' => __('PayPal Pro Settings', 'event_espresso'), |
|
| 145 | + 'filename' => 'payment_methods_overview_paypalpro' |
|
| 146 | + ), |
|
| 147 | + ); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * Overrides parent's _get_billing_values_from_form because we want to |
|
| 152 | + * get the country's 2-character ISO code, not the name like most gateways |
|
| 153 | + * @param EE_Billing_Info_Form $billing_form |
|
| 154 | + * @return array |
|
| 155 | + */ |
|
| 156 | + protected function _get_billing_values_from_form($billing_form) |
|
| 157 | + { |
|
| 158 | + $billing_values = parent::_get_billing_values_from_form($billing_form); |
|
| 159 | + $billing_values['country'] = $billing_form->get_input_value('country'); |
|
| 160 | + $billing_values['credit_card_type'] = $billing_form->get_input_value('credit_card_type'); |
|
| 161 | + return $billing_values; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Override parent to account for a change in extra meta inputs in 4.9.75.p |
|
| 166 | + * @since 4.9.79.p |
|
| 167 | + * @param EE_Payment_Method $payment_method_instance |
|
| 168 | + * @throws EE_Error |
|
| 169 | + * @throws InvalidArgumentException |
|
| 170 | + * @throws ReflectionException |
|
| 171 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 172 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 173 | + */ |
|
| 174 | + public function set_instance($payment_method_instance) |
|
| 175 | + { |
|
| 176 | + // Check for the old extra meta inputs |
|
| 177 | + $old_extra_metas = EEM_Extra_Meta::instance()->get_all( |
|
| 178 | + [ |
|
| 179 | + [ |
|
| 180 | + 'EXM_type' => 'Payment_Method', |
|
| 181 | + 'OBJ_ID' => $payment_method_instance->ID(), |
|
| 182 | + 'EXM_key' => ['IN', ['username', 'password', 'signature']], |
|
| 183 | + ] |
|
| 184 | + ] |
|
| 185 | + ); |
|
| 186 | + // If they existed, set the new ones instead |
|
| 187 | + if (!empty($old_extra_metas)) { |
|
| 188 | + foreach ($old_extra_metas as $old_extra_meta) { |
|
| 189 | + $old_extra_meta->set('EXM_key', 'api_' . $old_extra_meta->get('EXM_key')); |
|
| 190 | + $old_extra_meta->save(); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + return parent::set_instance($payment_method_instance); |
|
| 194 | + } |
|
| 195 | 195 | } |
@@ -63,22 +63,22 @@ discard block |
||
| 63 | 63 | // 'html_id'=> 'ee-Paypal_Pro-billing-form', |
| 64 | 64 | 'subsections'=>array( |
| 65 | 65 | 'credit_card'=>new EE_Credit_Card_Input( |
| 66 | - array( 'required'=>true, 'html_class' => 'ee-billing-qstn') |
|
| 66 | + array('required'=>true, 'html_class' => 'ee-billing-qstn') |
|
| 67 | 67 | ), |
| 68 | 68 | 'credit_card_type'=>new EE_Select_Input( |
| 69 | 69 | // the options are set dynamically |
| 70 | 70 | array_intersect_key(EE_PMT_Paypal_Pro::card_types_supported(), array_flip($allowed_types)), |
| 71 | - array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Type', 'event_espresso')) |
|
| 71 | + array('required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Type', 'event_espresso')) |
|
| 72 | 72 | ), |
| 73 | 73 | 'exp_month'=>new EE_Credit_Card_Month_Input( |
| 74 | 74 | true, |
| 75 | - array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Month', 'event_espresso') ) |
|
| 75 | + array('required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Month', 'event_espresso')) |
|
| 76 | 76 | ), |
| 77 | 77 | 'exp_year'=>new EE_Credit_Card_Year_Input( |
| 78 | - array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Year', 'event_espresso') ) |
|
| 78 | + array('required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Year', 'event_espresso')) |
|
| 79 | 79 | ), |
| 80 | 80 | 'cvv'=>new EE_CVV_Input( |
| 81 | - array( 'required'=>true, 'html_class' => 'ee-billing-qstn' ) |
|
| 81 | + array('required'=>true, 'html_class' => 'ee-billing-qstn') |
|
| 82 | 82 | ), |
| 83 | 83 | ) |
| 84 | 84 | ) |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | if ($this->_pm_instance->debug_mode()) { |
| 101 | 101 | $billing_form->add_subsections( |
| 102 | - array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ), |
|
| 102 | + array('fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html()), |
|
| 103 | 103 | 'credit_card' |
| 104 | 104 | ); |
| 105 | 105 | $billing_form->add_subsections( |
| 106 | - array( 'debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__).'/templates/paypal_pro_debug_info.template.php')), |
|
| 106 | + array('debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__).'/templates/paypal_pro_debug_info.template.php')), |
|
| 107 | 107 | 'first_name' |
| 108 | 108 | ); |
| 109 | 109 | $billing_form->get_input('credit_card_type')->set_default('Visa'); |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | ] |
| 185 | 185 | ); |
| 186 | 186 | // If they existed, set the new ones instead |
| 187 | - if (!empty($old_extra_metas)) { |
|
| 187 | + if ( ! empty($old_extra_metas)) { |
|
| 188 | 188 | foreach ($old_extra_metas as $old_extra_meta) { |
| 189 | - $old_extra_meta->set('EXM_key', 'api_' . $old_extra_meta->get('EXM_key')); |
|
| 189 | + $old_extra_meta->set('EXM_key', 'api_'.$old_extra_meta->get('EXM_key')); |
|
| 190 | 190 | $old_extra_meta->save(); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -10,22 +10,22 @@ |
||
| 10 | 10 | class EE_Credit_Card_Input extends EE_Form_Input_Base |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @param array $input_settings |
|
| 15 | - */ |
|
| 16 | - public function __construct($input_settings = array()) |
|
| 17 | - { |
|
| 18 | - $input_settings['required'] = isset($input_settings['required']) ? $input_settings['required'] : true; |
|
| 19 | - $this->_set_display_strategy(new EE_Text_Input_Display_Strategy()); |
|
| 20 | - $this->_set_normalization_strategy(new EE_Credit_Card_Normalization()); |
|
| 21 | - $this->_add_validation_strategy(new EE_Credit_Card_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null)); |
|
| 22 | - $this->set_sensitive_data_removal_strategy(new EE_Credit_Card_Sensitive_Data_Removal()); |
|
| 23 | - parent::__construct($input_settings); |
|
| 24 | - // Don't allow the label text to be overridden. This is the text you want because it works for |
|
| 25 | - // credit cards, debit cards, and bank cards. |
|
| 26 | - $this->_html_label_text = esc_html__( |
|
| 27 | - 'Card Number', |
|
| 28 | - 'event_espresso' |
|
| 29 | - ); |
|
| 30 | - } |
|
| 13 | + /** |
|
| 14 | + * @param array $input_settings |
|
| 15 | + */ |
|
| 16 | + public function __construct($input_settings = array()) |
|
| 17 | + { |
|
| 18 | + $input_settings['required'] = isset($input_settings['required']) ? $input_settings['required'] : true; |
|
| 19 | + $this->_set_display_strategy(new EE_Text_Input_Display_Strategy()); |
|
| 20 | + $this->_set_normalization_strategy(new EE_Credit_Card_Normalization()); |
|
| 21 | + $this->_add_validation_strategy(new EE_Credit_Card_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null)); |
|
| 22 | + $this->set_sensitive_data_removal_strategy(new EE_Credit_Card_Sensitive_Data_Removal()); |
|
| 23 | + parent::__construct($input_settings); |
|
| 24 | + // Don't allow the label text to be overridden. This is the text you want because it works for |
|
| 25 | + // credit cards, debit cards, and bank cards. |
|
| 26 | + $this->_html_label_text = esc_html__( |
|
| 27 | + 'Card Number', |
|
| 28 | + 'event_espresso' |
|
| 29 | + ); |
|
| 30 | + } |
|
| 31 | 31 | } |
@@ -11,41 +11,41 @@ |
||
| 11 | 11 | class EE_CVV_Input extends EE_Text_Input |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @param array $input_settings { |
|
| 16 | - * @type boolean $include_whats_this_link defaults to true |
|
| 17 | - * } |
|
| 18 | - */ |
|
| 19 | - public function __construct($input_settings = array()) |
|
| 20 | - { |
|
| 21 | - $this->set_sensitive_data_removal_strategy(new EE_CCV_Sensitive_Data_Removal()); |
|
| 22 | - $this->_add_validation_strategy( |
|
| 23 | - new EE_Text_Validation_Strategy( |
|
| 24 | - isset($input_settings['validation_error_message']) |
|
| 25 | - ? $input_settings['validation_error_message'] |
|
| 26 | - : esc_html__( |
|
| 27 | - 'The CVV is either a 3 digit number on the back of your card, or 4 digit number on the front', |
|
| 28 | - 'event_espresso' |
|
| 29 | - ), |
|
| 30 | - '~^\d{3,4}$~' |
|
| 31 | - ) |
|
| 32 | - ); |
|
| 33 | - parent::__construct($input_settings); |
|
| 34 | - if (! isset($input_settings['include_whats_this_link']) |
|
| 35 | - || ( |
|
| 36 | - isset($input_settings['include_whats_this_link']) |
|
| 37 | - && $input_settings['include_whats_this_link'] === true |
|
| 38 | - ) |
|
| 39 | - ) { |
|
| 40 | - $this->_html_label_text = sprintf( |
|
| 41 | - esc_html_x( |
|
| 42 | - 'Card Security Code %1$s(What\'s this?)%2$s', |
|
| 43 | - 'CVV (What\'s this?)', |
|
| 44 | - 'event_espresso' |
|
| 45 | - ), |
|
| 46 | - '<a href="https://www.cvvnumber.com/" target="_blank" rel="noopener noreferrer">', |
|
| 47 | - '</a>' |
|
| 48 | - ); |
|
| 49 | - } |
|
| 50 | - } |
|
| 14 | + /** |
|
| 15 | + * @param array $input_settings { |
|
| 16 | + * @type boolean $include_whats_this_link defaults to true |
|
| 17 | + * } |
|
| 18 | + */ |
|
| 19 | + public function __construct($input_settings = array()) |
|
| 20 | + { |
|
| 21 | + $this->set_sensitive_data_removal_strategy(new EE_CCV_Sensitive_Data_Removal()); |
|
| 22 | + $this->_add_validation_strategy( |
|
| 23 | + new EE_Text_Validation_Strategy( |
|
| 24 | + isset($input_settings['validation_error_message']) |
|
| 25 | + ? $input_settings['validation_error_message'] |
|
| 26 | + : esc_html__( |
|
| 27 | + 'The CVV is either a 3 digit number on the back of your card, or 4 digit number on the front', |
|
| 28 | + 'event_espresso' |
|
| 29 | + ), |
|
| 30 | + '~^\d{3,4}$~' |
|
| 31 | + ) |
|
| 32 | + ); |
|
| 33 | + parent::__construct($input_settings); |
|
| 34 | + if (! isset($input_settings['include_whats_this_link']) |
|
| 35 | + || ( |
|
| 36 | + isset($input_settings['include_whats_this_link']) |
|
| 37 | + && $input_settings['include_whats_this_link'] === true |
|
| 38 | + ) |
|
| 39 | + ) { |
|
| 40 | + $this->_html_label_text = sprintf( |
|
| 41 | + esc_html_x( |
|
| 42 | + 'Card Security Code %1$s(What\'s this?)%2$s', |
|
| 43 | + 'CVV (What\'s this?)', |
|
| 44 | + 'event_espresso' |
|
| 45 | + ), |
|
| 46 | + '<a href="https://www.cvvnumber.com/" target="_blank" rel="noopener noreferrer">', |
|
| 47 | + '</a>' |
|
| 48 | + ); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -14,172 +14,172 @@ |
||
| 14 | 14 | class EE_Billing_Attendee_Info_Form extends EE_Billing_Info_Form |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * |
|
| 19 | - * @param EE_Payment_Method $payment_method |
|
| 20 | - * @param array $options_array @see EE_Form_Section_Proper::__construct() |
|
| 21 | - */ |
|
| 22 | - public function __construct(EE_Payment_Method $payment_method, $options_array = array()) |
|
| 23 | - { |
|
| 24 | - $options_array['subsections'] = array_merge( |
|
| 25 | - array( |
|
| 26 | - 'first_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso') )), |
|
| 27 | - 'last_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso') )), |
|
| 28 | - 'email' => new EE_Email_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email Address', 'event_espresso') )), |
|
| 29 | - 'address' => new EE_Text_Input(array( 'html_label_text'=> __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address' )), |
|
| 30 | - 'address2' => new EE_Text_Input(array( 'html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2' )), |
|
| 31 | - 'city' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso') )), |
|
| 32 | - 'state' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso') ))), |
|
| 33 | - 'country' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso') ))), |
|
| 34 | - 'zip' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso') )), |
|
| 35 | - 'phone' => new EE_Text_Input(array( 'html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso') )), |
|
| 36 | - ), |
|
| 37 | - isset($options_array['subsections']) ? $options_array['subsections'] : array() |
|
| 38 | - ); |
|
| 17 | + /** |
|
| 18 | + * |
|
| 19 | + * @param EE_Payment_Method $payment_method |
|
| 20 | + * @param array $options_array @see EE_Form_Section_Proper::__construct() |
|
| 21 | + */ |
|
| 22 | + public function __construct(EE_Payment_Method $payment_method, $options_array = array()) |
|
| 23 | + { |
|
| 24 | + $options_array['subsections'] = array_merge( |
|
| 25 | + array( |
|
| 26 | + 'first_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso') )), |
|
| 27 | + 'last_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso') )), |
|
| 28 | + 'email' => new EE_Email_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email Address', 'event_espresso') )), |
|
| 29 | + 'address' => new EE_Text_Input(array( 'html_label_text'=> __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address' )), |
|
| 30 | + 'address2' => new EE_Text_Input(array( 'html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2' )), |
|
| 31 | + 'city' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso') )), |
|
| 32 | + 'state' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso') ))), |
|
| 33 | + 'country' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso') ))), |
|
| 34 | + 'zip' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso') )), |
|
| 35 | + 'phone' => new EE_Text_Input(array( 'html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso') )), |
|
| 36 | + ), |
|
| 37 | + isset($options_array['subsections']) ? $options_array['subsections'] : array() |
|
| 38 | + ); |
|
| 39 | 39 | |
| 40 | - parent::__construct($payment_method, $options_array); |
|
| 41 | - } |
|
| 40 | + parent::__construct($payment_method, $options_array); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Sets the defaults for the billing form according to the attendee's details |
|
| 45 | - * @param EE_Attendee $attendee |
|
| 46 | - */ |
|
| 47 | - public function populate_from_attendee($attendee) |
|
| 48 | - { |
|
| 49 | - $attendee = EEM_Attendee::instance()->ensure_is_obj($attendee); |
|
| 43 | + /** |
|
| 44 | + * Sets the defaults for the billing form according to the attendee's details |
|
| 45 | + * @param EE_Attendee $attendee |
|
| 46 | + */ |
|
| 47 | + public function populate_from_attendee($attendee) |
|
| 48 | + { |
|
| 49 | + $attendee = EEM_Attendee::instance()->ensure_is_obj($attendee); |
|
| 50 | 50 | |
| 51 | - /** @var $attendee EE_Attendee */ |
|
| 52 | - $this->populate_defaults( |
|
| 53 | - apply_filters( |
|
| 54 | - 'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee', |
|
| 55 | - array( |
|
| 56 | - 'first_name'=>$attendee->fname(), |
|
| 57 | - 'last_name'=>$attendee->lname(), |
|
| 58 | - 'email'=>$attendee->email(), |
|
| 59 | - 'address'=>$attendee->address(), |
|
| 60 | - 'address2'=>$attendee->address2(), |
|
| 61 | - 'city'=>$attendee->city(), |
|
| 62 | - 'state'=> $this->getAttendeeStateValueForForm($attendee), |
|
| 63 | - 'country'=> $attendee->country_ID(), |
|
| 64 | - 'zip'=>$attendee->zip(), |
|
| 65 | - 'phone'=>$attendee->phone(), |
|
| 66 | - ), |
|
| 67 | - $attendee, |
|
| 68 | - $this |
|
| 69 | - ) |
|
| 70 | - ); |
|
| 71 | - } |
|
| 51 | + /** @var $attendee EE_Attendee */ |
|
| 52 | + $this->populate_defaults( |
|
| 53 | + apply_filters( |
|
| 54 | + 'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee', |
|
| 55 | + array( |
|
| 56 | + 'first_name'=>$attendee->fname(), |
|
| 57 | + 'last_name'=>$attendee->lname(), |
|
| 58 | + 'email'=>$attendee->email(), |
|
| 59 | + 'address'=>$attendee->address(), |
|
| 60 | + 'address2'=>$attendee->address2(), |
|
| 61 | + 'city'=>$attendee->city(), |
|
| 62 | + 'state'=> $this->getAttendeeStateValueForForm($attendee), |
|
| 63 | + 'country'=> $attendee->country_ID(), |
|
| 64 | + 'zip'=>$attendee->zip(), |
|
| 65 | + 'phone'=>$attendee->phone(), |
|
| 66 | + ), |
|
| 67 | + $attendee, |
|
| 68 | + $this |
|
| 69 | + ) |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Gets the default value to use for the billing form's state value. |
|
| 75 | - * @since 4.10.0.p |
|
| 76 | - * @param EE_Attendee $attendee |
|
| 77 | - * @return string |
|
| 78 | - * @throws EE_Error2 |
|
| 79 | - */ |
|
| 80 | - protected function getAttendeeStateValueForForm(EE_Attendee $attendee) |
|
| 81 | - { |
|
| 82 | - // If the state input was removed, just return a blank string. |
|
| 83 | - if (! $this->has_subsection('state')) { |
|
| 84 | - return ''; |
|
| 85 | - } |
|
| 86 | - $state_input = $this->get_input('state', false); |
|
| 87 | - if ($state_input instanceof EE_State_Select_Input) { |
|
| 88 | - $state_field_to_use = $state_input->valueFieldName(); |
|
| 89 | - } else { |
|
| 90 | - $state_field_to_use = 'STA_ID'; |
|
| 91 | - } |
|
| 92 | - switch ($state_field_to_use) { |
|
| 93 | - case 'STA_abbrev': |
|
| 94 | - $state_value = $attendee->state_abbrev(); |
|
| 95 | - break; |
|
| 96 | - case 'STA_name': |
|
| 97 | - $state_value = $attendee->state_name(); |
|
| 98 | - break; |
|
| 99 | - default: |
|
| 100 | - $state_value = $attendee->state_ID(); |
|
| 101 | - } |
|
| 102 | - return $state_value; |
|
| 103 | - } |
|
| 73 | + /** |
|
| 74 | + * Gets the default value to use for the billing form's state value. |
|
| 75 | + * @since 4.10.0.p |
|
| 76 | + * @param EE_Attendee $attendee |
|
| 77 | + * @return string |
|
| 78 | + * @throws EE_Error2 |
|
| 79 | + */ |
|
| 80 | + protected function getAttendeeStateValueForForm(EE_Attendee $attendee) |
|
| 81 | + { |
|
| 82 | + // If the state input was removed, just return a blank string. |
|
| 83 | + if (! $this->has_subsection('state')) { |
|
| 84 | + return ''; |
|
| 85 | + } |
|
| 86 | + $state_input = $this->get_input('state', false); |
|
| 87 | + if ($state_input instanceof EE_State_Select_Input) { |
|
| 88 | + $state_field_to_use = $state_input->valueFieldName(); |
|
| 89 | + } else { |
|
| 90 | + $state_field_to_use = 'STA_ID'; |
|
| 91 | + } |
|
| 92 | + switch ($state_field_to_use) { |
|
| 93 | + case 'STA_abbrev': |
|
| 94 | + $state_value = $attendee->state_abbrev(); |
|
| 95 | + break; |
|
| 96 | + case 'STA_name': |
|
| 97 | + $state_value = $attendee->state_name(); |
|
| 98 | + break; |
|
| 99 | + default: |
|
| 100 | + $state_value = $attendee->state_ID(); |
|
| 101 | + } |
|
| 102 | + return $state_value; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * copy_billing_form_data_to_attendee |
|
| 109 | - * copies info from the billing form to the attendee's details |
|
| 110 | - * @param \EE_Attendee $attendee - the attendee object to copy details to |
|
| 111 | - * @return \EE_Attendee |
|
| 112 | - */ |
|
| 113 | - public function copy_billing_form_data_to_attendee(EE_Attendee $attendee) |
|
| 114 | - { |
|
| 115 | - // grab billing form data |
|
| 116 | - $data = $this->valid_data(); |
|
| 117 | - // copy first_name |
|
| 118 | - if (! empty($data['first_name'])) { |
|
| 119 | - $attendee->set_fname($data['first_name']); |
|
| 120 | - } |
|
| 121 | - // copy last_name |
|
| 122 | - if (! empty($data['last_name'])) { |
|
| 123 | - $attendee->set_lname($data['last_name']); |
|
| 124 | - } |
|
| 125 | - // copy email |
|
| 126 | - if (! empty($data['email'])) { |
|
| 127 | - $attendee->set_email($data['email']); |
|
| 128 | - } |
|
| 129 | - // copy address |
|
| 130 | - if (! empty($data['address'])) { |
|
| 131 | - $attendee->set_address($data['address']); |
|
| 132 | - } |
|
| 133 | - // copy address2 |
|
| 134 | - if (! empty($data['address2'])) { |
|
| 135 | - $attendee->set_address2($data['address2']); |
|
| 136 | - } |
|
| 137 | - // copy city |
|
| 138 | - if (! empty($data['city'])) { |
|
| 139 | - $attendee->set_city($data['city']); |
|
| 140 | - } |
|
| 141 | - // copy state |
|
| 142 | - if (! empty($data['state'])) { |
|
| 143 | - $attendee->set_state($data['state']); |
|
| 144 | - } |
|
| 145 | - // copy country |
|
| 146 | - if (! empty($data['country'])) { |
|
| 147 | - $attendee->set_country($data['country']); |
|
| 148 | - } |
|
| 149 | - // copy zip |
|
| 150 | - if (! empty($data['zip'])) { |
|
| 151 | - $attendee->set_zip($data['zip']); |
|
| 152 | - } |
|
| 153 | - // copy phone |
|
| 154 | - if (! empty($data['phone'])) { |
|
| 155 | - $attendee->set_phone($data['phone']); |
|
| 156 | - } |
|
| 157 | - return $attendee; |
|
| 158 | - } |
|
| 107 | + /** |
|
| 108 | + * copy_billing_form_data_to_attendee |
|
| 109 | + * copies info from the billing form to the attendee's details |
|
| 110 | + * @param \EE_Attendee $attendee - the attendee object to copy details to |
|
| 111 | + * @return \EE_Attendee |
|
| 112 | + */ |
|
| 113 | + public function copy_billing_form_data_to_attendee(EE_Attendee $attendee) |
|
| 114 | + { |
|
| 115 | + // grab billing form data |
|
| 116 | + $data = $this->valid_data(); |
|
| 117 | + // copy first_name |
|
| 118 | + if (! empty($data['first_name'])) { |
|
| 119 | + $attendee->set_fname($data['first_name']); |
|
| 120 | + } |
|
| 121 | + // copy last_name |
|
| 122 | + if (! empty($data['last_name'])) { |
|
| 123 | + $attendee->set_lname($data['last_name']); |
|
| 124 | + } |
|
| 125 | + // copy email |
|
| 126 | + if (! empty($data['email'])) { |
|
| 127 | + $attendee->set_email($data['email']); |
|
| 128 | + } |
|
| 129 | + // copy address |
|
| 130 | + if (! empty($data['address'])) { |
|
| 131 | + $attendee->set_address($data['address']); |
|
| 132 | + } |
|
| 133 | + // copy address2 |
|
| 134 | + if (! empty($data['address2'])) { |
|
| 135 | + $attendee->set_address2($data['address2']); |
|
| 136 | + } |
|
| 137 | + // copy city |
|
| 138 | + if (! empty($data['city'])) { |
|
| 139 | + $attendee->set_city($data['city']); |
|
| 140 | + } |
|
| 141 | + // copy state |
|
| 142 | + if (! empty($data['state'])) { |
|
| 143 | + $attendee->set_state($data['state']); |
|
| 144 | + } |
|
| 145 | + // copy country |
|
| 146 | + if (! empty($data['country'])) { |
|
| 147 | + $attendee->set_country($data['country']); |
|
| 148 | + } |
|
| 149 | + // copy zip |
|
| 150 | + if (! empty($data['zip'])) { |
|
| 151 | + $attendee->set_zip($data['zip']); |
|
| 152 | + } |
|
| 153 | + // copy phone |
|
| 154 | + if (! empty($data['phone'])) { |
|
| 155 | + $attendee->set_phone($data['phone']); |
|
| 156 | + } |
|
| 157 | + return $attendee; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * create_attendee_from_billing_form_data |
|
| 163 | - * uses info from the billing form to create a new attendee |
|
| 164 | - * @return \EE_Attendee |
|
| 165 | - */ |
|
| 166 | - public function create_attendee_from_billing_form_data() |
|
| 167 | - { |
|
| 168 | - // grab billing form data |
|
| 169 | - $data = $this->valid_data(); |
|
| 170 | - return EE_Attendee::new_instance(array( |
|
| 171 | - 'ATT_fname' => ! empty($data['first_name']) ? $data['first_name'] : '', |
|
| 172 | - 'ATT_lname' => ! empty($data['last_name']) ? $data['last_name'] : '', |
|
| 173 | - 'ATT_email' => ! empty($data['email']) ? $data['email'] : '', |
|
| 174 | - 'ATT_address' => ! empty($data['address']) ? $data['address'] : '', |
|
| 175 | - 'ATT_address2' => ! empty($data['address2']) ? $data['address2'] : '', |
|
| 176 | - 'ATT_city' => ! empty($data['city']) ? $data['city'] : '', |
|
| 177 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : '', |
|
| 178 | - 'CNT_ISO' => ! empty($data['country']) ? $data['country'] : '', |
|
| 179 | - 'ATT_zip' => ! empty($data['zip']) ? $data['zip'] : '', |
|
| 180 | - 'ATT_phone' => ! empty($data['phone']) ? $data['phone'] : '', |
|
| 181 | - )); |
|
| 182 | - } |
|
| 161 | + /** |
|
| 162 | + * create_attendee_from_billing_form_data |
|
| 163 | + * uses info from the billing form to create a new attendee |
|
| 164 | + * @return \EE_Attendee |
|
| 165 | + */ |
|
| 166 | + public function create_attendee_from_billing_form_data() |
|
| 167 | + { |
|
| 168 | + // grab billing form data |
|
| 169 | + $data = $this->valid_data(); |
|
| 170 | + return EE_Attendee::new_instance(array( |
|
| 171 | + 'ATT_fname' => ! empty($data['first_name']) ? $data['first_name'] : '', |
|
| 172 | + 'ATT_lname' => ! empty($data['last_name']) ? $data['last_name'] : '', |
|
| 173 | + 'ATT_email' => ! empty($data['email']) ? $data['email'] : '', |
|
| 174 | + 'ATT_address' => ! empty($data['address']) ? $data['address'] : '', |
|
| 175 | + 'ATT_address2' => ! empty($data['address2']) ? $data['address2'] : '', |
|
| 176 | + 'ATT_city' => ! empty($data['city']) ? $data['city'] : '', |
|
| 177 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : '', |
|
| 178 | + 'CNT_ISO' => ! empty($data['country']) ? $data['country'] : '', |
|
| 179 | + 'ATT_zip' => ! empty($data['zip']) ? $data['zip'] : '', |
|
| 180 | + 'ATT_phone' => ! empty($data['phone']) ? $data['phone'] : '', |
|
| 181 | + )); |
|
| 182 | + } |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // End of file EE_Billing_Attendee_Info_Form.form.php |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $options_array['subsections'] = array_merge( |
| 25 | 25 | array( |
| 26 | - 'first_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso') )), |
|
| 27 | - 'last_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso') )), |
|
| 28 | - 'email' => new EE_Email_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email Address', 'event_espresso') )), |
|
| 29 | - 'address' => new EE_Text_Input(array( 'html_label_text'=> __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address' )), |
|
| 30 | - 'address2' => new EE_Text_Input(array( 'html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2' )), |
|
| 31 | - 'city' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso') )), |
|
| 32 | - 'state' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso') ))), |
|
| 33 | - 'country' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso') ))), |
|
| 34 | - 'zip' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso') )), |
|
| 35 | - 'phone' => new EE_Text_Input(array( 'html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso') )), |
|
| 26 | + 'first_name' => new EE_Text_Input(array('required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso'))), |
|
| 27 | + 'last_name' => new EE_Text_Input(array('required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso'))), |
|
| 28 | + 'email' => new EE_Email_Input(array('required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email Address', 'event_espresso'))), |
|
| 29 | + 'address' => new EE_Text_Input(array('html_label_text'=> __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address')), |
|
| 30 | + 'address2' => new EE_Text_Input(array('html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2')), |
|
| 31 | + 'city' => new EE_Text_Input(array('required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso'))), |
|
| 32 | + 'state' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array('required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso')))), |
|
| 33 | + 'country' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array('required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso')))), |
|
| 34 | + 'zip' => new EE_Text_Input(array('required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso'))), |
|
| 35 | + 'phone' => new EE_Text_Input(array('html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso'))), |
|
| 36 | 36 | ), |
| 37 | 37 | isset($options_array['subsections']) ? $options_array['subsections'] : array() |
| 38 | 38 | ); |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | protected function getAttendeeStateValueForForm(EE_Attendee $attendee) |
| 81 | 81 | { |
| 82 | 82 | // If the state input was removed, just return a blank string. |
| 83 | - if (! $this->has_subsection('state')) { |
|
| 83 | + if ( ! $this->has_subsection('state')) { |
|
| 84 | 84 | return ''; |
| 85 | 85 | } |
| 86 | - $state_input = $this->get_input('state', false); |
|
| 86 | + $state_input = $this->get_input('state', false); |
|
| 87 | 87 | if ($state_input instanceof EE_State_Select_Input) { |
| 88 | - $state_field_to_use = $state_input->valueFieldName(); |
|
| 88 | + $state_field_to_use = $state_input->valueFieldName(); |
|
| 89 | 89 | } else { |
| 90 | 90 | $state_field_to_use = 'STA_ID'; |
| 91 | 91 | } |
@@ -115,43 +115,43 @@ discard block |
||
| 115 | 115 | // grab billing form data |
| 116 | 116 | $data = $this->valid_data(); |
| 117 | 117 | // copy first_name |
| 118 | - if (! empty($data['first_name'])) { |
|
| 118 | + if ( ! empty($data['first_name'])) { |
|
| 119 | 119 | $attendee->set_fname($data['first_name']); |
| 120 | 120 | } |
| 121 | 121 | // copy last_name |
| 122 | - if (! empty($data['last_name'])) { |
|
| 122 | + if ( ! empty($data['last_name'])) { |
|
| 123 | 123 | $attendee->set_lname($data['last_name']); |
| 124 | 124 | } |
| 125 | 125 | // copy email |
| 126 | - if (! empty($data['email'])) { |
|
| 126 | + if ( ! empty($data['email'])) { |
|
| 127 | 127 | $attendee->set_email($data['email']); |
| 128 | 128 | } |
| 129 | 129 | // copy address |
| 130 | - if (! empty($data['address'])) { |
|
| 130 | + if ( ! empty($data['address'])) { |
|
| 131 | 131 | $attendee->set_address($data['address']); |
| 132 | 132 | } |
| 133 | 133 | // copy address2 |
| 134 | - if (! empty($data['address2'])) { |
|
| 134 | + if ( ! empty($data['address2'])) { |
|
| 135 | 135 | $attendee->set_address2($data['address2']); |
| 136 | 136 | } |
| 137 | 137 | // copy city |
| 138 | - if (! empty($data['city'])) { |
|
| 138 | + if ( ! empty($data['city'])) { |
|
| 139 | 139 | $attendee->set_city($data['city']); |
| 140 | 140 | } |
| 141 | 141 | // copy state |
| 142 | - if (! empty($data['state'])) { |
|
| 142 | + if ( ! empty($data['state'])) { |
|
| 143 | 143 | $attendee->set_state($data['state']); |
| 144 | 144 | } |
| 145 | 145 | // copy country |
| 146 | - if (! empty($data['country'])) { |
|
| 146 | + if ( ! empty($data['country'])) { |
|
| 147 | 147 | $attendee->set_country($data['country']); |
| 148 | 148 | } |
| 149 | 149 | // copy zip |
| 150 | - if (! empty($data['zip'])) { |
|
| 150 | + if ( ! empty($data['zip'])) { |
|
| 151 | 151 | $attendee->set_zip($data['zip']); |
| 152 | 152 | } |
| 153 | 153 | // copy phone |
| 154 | - if (! empty($data['phone'])) { |
|
| 154 | + if ( ! empty($data['phone'])) { |
|
| 155 | 155 | $attendee->set_phone($data['phone']); |
| 156 | 156 | } |
| 157 | 157 | return $attendee; |