/** * Creates the billing form for this payment method type * @param \EE_Transaction $transaction * @return EE_Billing_Info_Form */ public function generate_new_billing_form(EE_Transaction $transaction = NULL) { $billing_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, array('name' => 'AIM_Form', 'subsections' => array('credit_card' => new EE_Credit_Card_Input(array('required' => true, 'html_label_text' => __('Card Number', 'event_espresso'))), 'exp_month' => new EE_Credit_Card_Month_Input(true, array('required' => true, 'html_label_text' => __('Expiry Month', 'event_espresso'))), 'exp_year' => new EE_Credit_Card_Year_Input(array('required' => true, 'html_label_text' => __('Expiry Year', 'event_espresso'))), 'cvv' => new EE_CVV_Input(array('required' => true, 'html_label_text' => __('CVV', 'event_espresso')))))); $billing_form->add_subsections(array('company' => new EE_Text_Input(array('html_label_text' => __('Company', 'event_espresso')))), 'email', false); $billing_form->add_subsections(array('fax' => new EE_Text_Input(array('html_label_text' => __('Fax', 'event_espresso')))), 'phone', false); $settings_form = $this->settings_form(); if ($settings_form->get_input('excluded_billing_inputs') instanceof EE_Checkbox_Multi_Input) { $billing_form->exclude($settings_form->get_input('excluded_billing_inputs')->normalized_value()); } if ($settings_form->get_input('required_billing_inputs') instanceof EE_Checkbox_Multi_Input) { $required_inputs = array_merge(array('credit_card', 'exp_month', 'exp_year'), $settings_form->get_input('required_billing_inputs')->normalized_value()); foreach ($billing_form->inputs() as $input_name => $input) { if (in_array($input_name, $required_inputs)) { $input->set_required(true); } else { $input->set_required(false); } } } return $this->apply_billing_form_debug_settings($billing_form); }
/** * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to retrieve it * @param EE_Billing_Attendee_Info_Form $billing_form * @param EE_Payment_Method $payment_method * @return boolean */ public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) { if (!$billing_form instanceof EE_Billing_Attendee_Info_Form) { EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); return false; } $billing_form->clean_sensitive_data(); return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method), $billing_form->input_values(true)); }
/** * Sets the defaults for the billing form according to the attendee's details. * * @param int | \EE_Attendee $attendee */ public function populate_from_attendee($attendee) { parent::populate_from_attendee($attendee); $this->populate_defaults(array('state' => $attendee->state_abbrev(), 'country' => $attendee->country_ID())); }