@@ -14,139 +14,139 @@ |
||
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', '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', '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); |
|
50 | - /** @var $attendee EE_Attendee */ |
|
51 | - $this->populate_defaults( |
|
52 | - apply_filters( |
|
53 | - 'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee', |
|
54 | - array( |
|
55 | - 'first_name'=>$attendee->fname(), |
|
56 | - 'last_name'=>$attendee->lname(), |
|
57 | - 'email'=>$attendee->email(), |
|
58 | - 'address'=>$attendee->address(), |
|
59 | - 'address2'=>$attendee->address2(), |
|
60 | - 'city'=>$attendee->city(), |
|
61 | - 'state'=> $attendee->state_ID(), |
|
62 | - 'country'=> $attendee->country_ID(), |
|
63 | - 'zip'=>$attendee->zip(), |
|
64 | - 'phone'=>$attendee->phone(), |
|
65 | - ), |
|
66 | - $attendee, |
|
67 | - $this |
|
68 | - ) |
|
69 | - ); |
|
70 | - } |
|
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 | + /** @var $attendee EE_Attendee */ |
|
51 | + $this->populate_defaults( |
|
52 | + apply_filters( |
|
53 | + 'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee', |
|
54 | + array( |
|
55 | + 'first_name'=>$attendee->fname(), |
|
56 | + 'last_name'=>$attendee->lname(), |
|
57 | + 'email'=>$attendee->email(), |
|
58 | + 'address'=>$attendee->address(), |
|
59 | + 'address2'=>$attendee->address2(), |
|
60 | + 'city'=>$attendee->city(), |
|
61 | + 'state'=> $attendee->state_ID(), |
|
62 | + 'country'=> $attendee->country_ID(), |
|
63 | + 'zip'=>$attendee->zip(), |
|
64 | + 'phone'=>$attendee->phone(), |
|
65 | + ), |
|
66 | + $attendee, |
|
67 | + $this |
|
68 | + ) |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * copy_billing_form_data_to_attendee |
|
76 | - * copies info from the billing form to the attendee's details |
|
77 | - * @param \EE_Attendee $attendee - the attendee object to copy details to |
|
78 | - * @return \EE_Attendee |
|
79 | - */ |
|
80 | - public function copy_billing_form_data_to_attendee(EE_Attendee $attendee) |
|
81 | - { |
|
82 | - // grab billing form data |
|
83 | - $data = $this->valid_data(); |
|
84 | - // copy first_name |
|
85 | - if (! empty($data['first_name'])) { |
|
86 | - $attendee->set_fname($data['first_name']); |
|
87 | - } |
|
88 | - // copy last_name |
|
89 | - if (! empty($data['last_name'])) { |
|
90 | - $attendee->set_lname($data['last_name']); |
|
91 | - } |
|
92 | - // copy email |
|
93 | - if (! empty($data['email'])) { |
|
94 | - $attendee->set_email($data['email']); |
|
95 | - } |
|
96 | - // copy address |
|
97 | - if (! empty($data['address'])) { |
|
98 | - $attendee->set_address($data['address']); |
|
99 | - } |
|
100 | - // copy address2 |
|
101 | - if (! empty($data['address2'])) { |
|
102 | - $attendee->set_address2($data['address2']); |
|
103 | - } |
|
104 | - // copy city |
|
105 | - if (! empty($data['city'])) { |
|
106 | - $attendee->set_city($data['city']); |
|
107 | - } |
|
108 | - // copy state |
|
109 | - if (! empty($data['state'])) { |
|
110 | - $attendee->set_state($data['state']); |
|
111 | - } |
|
112 | - // copy country |
|
113 | - if (! empty($data['country'])) { |
|
114 | - $attendee->set_country($data['country']); |
|
115 | - } |
|
116 | - // copy zip |
|
117 | - if (! empty($data['zip'])) { |
|
118 | - $attendee->set_zip($data['zip']); |
|
119 | - } |
|
120 | - // copy phone |
|
121 | - if (! empty($data['phone'])) { |
|
122 | - $attendee->set_phone($data['phone']); |
|
123 | - } |
|
124 | - return $attendee; |
|
125 | - } |
|
74 | + /** |
|
75 | + * copy_billing_form_data_to_attendee |
|
76 | + * copies info from the billing form to the attendee's details |
|
77 | + * @param \EE_Attendee $attendee - the attendee object to copy details to |
|
78 | + * @return \EE_Attendee |
|
79 | + */ |
|
80 | + public function copy_billing_form_data_to_attendee(EE_Attendee $attendee) |
|
81 | + { |
|
82 | + // grab billing form data |
|
83 | + $data = $this->valid_data(); |
|
84 | + // copy first_name |
|
85 | + if (! empty($data['first_name'])) { |
|
86 | + $attendee->set_fname($data['first_name']); |
|
87 | + } |
|
88 | + // copy last_name |
|
89 | + if (! empty($data['last_name'])) { |
|
90 | + $attendee->set_lname($data['last_name']); |
|
91 | + } |
|
92 | + // copy email |
|
93 | + if (! empty($data['email'])) { |
|
94 | + $attendee->set_email($data['email']); |
|
95 | + } |
|
96 | + // copy address |
|
97 | + if (! empty($data['address'])) { |
|
98 | + $attendee->set_address($data['address']); |
|
99 | + } |
|
100 | + // copy address2 |
|
101 | + if (! empty($data['address2'])) { |
|
102 | + $attendee->set_address2($data['address2']); |
|
103 | + } |
|
104 | + // copy city |
|
105 | + if (! empty($data['city'])) { |
|
106 | + $attendee->set_city($data['city']); |
|
107 | + } |
|
108 | + // copy state |
|
109 | + if (! empty($data['state'])) { |
|
110 | + $attendee->set_state($data['state']); |
|
111 | + } |
|
112 | + // copy country |
|
113 | + if (! empty($data['country'])) { |
|
114 | + $attendee->set_country($data['country']); |
|
115 | + } |
|
116 | + // copy zip |
|
117 | + if (! empty($data['zip'])) { |
|
118 | + $attendee->set_zip($data['zip']); |
|
119 | + } |
|
120 | + // copy phone |
|
121 | + if (! empty($data['phone'])) { |
|
122 | + $attendee->set_phone($data['phone']); |
|
123 | + } |
|
124 | + return $attendee; |
|
125 | + } |
|
126 | 126 | |
127 | 127 | |
128 | - /** |
|
129 | - * create_attendee_from_billing_form_data |
|
130 | - * uses info from the billing form to create a new attendee |
|
131 | - * @return \EE_Attendee |
|
132 | - */ |
|
133 | - public function create_attendee_from_billing_form_data() |
|
134 | - { |
|
135 | - // grab billing form data |
|
136 | - $data = $this->valid_data(); |
|
137 | - return EE_Attendee::new_instance(array( |
|
138 | - 'ATT_fname' => ! empty($data['first_name']) ? $data['first_name'] : '', |
|
139 | - 'ATT_lname' => ! empty($data['last_name']) ? $data['last_name'] : '', |
|
140 | - 'ATT_email' => ! empty($data['email']) ? $data['email'] : '', |
|
141 | - 'ATT_address' => ! empty($data['address']) ? $data['address'] : '', |
|
142 | - 'ATT_address2' => ! empty($data['address2']) ? $data['address2'] : '', |
|
143 | - 'ATT_city' => ! empty($data['city']) ? $data['city'] : '', |
|
144 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : '', |
|
145 | - 'CNT_ISO' => ! empty($data['country']) ? $data['country'] : '', |
|
146 | - 'ATT_zip' => ! empty($data['zip']) ? $data['zip'] : '', |
|
147 | - 'ATT_phone' => ! empty($data['phone']) ? $data['phone'] : '', |
|
148 | - )); |
|
149 | - } |
|
128 | + /** |
|
129 | + * create_attendee_from_billing_form_data |
|
130 | + * uses info from the billing form to create a new attendee |
|
131 | + * @return \EE_Attendee |
|
132 | + */ |
|
133 | + public function create_attendee_from_billing_form_data() |
|
134 | + { |
|
135 | + // grab billing form data |
|
136 | + $data = $this->valid_data(); |
|
137 | + return EE_Attendee::new_instance(array( |
|
138 | + 'ATT_fname' => ! empty($data['first_name']) ? $data['first_name'] : '', |
|
139 | + 'ATT_lname' => ! empty($data['last_name']) ? $data['last_name'] : '', |
|
140 | + 'ATT_email' => ! empty($data['email']) ? $data['email'] : '', |
|
141 | + 'ATT_address' => ! empty($data['address']) ? $data['address'] : '', |
|
142 | + 'ATT_address2' => ! empty($data['address2']) ? $data['address2'] : '', |
|
143 | + 'ATT_city' => ! empty($data['city']) ? $data['city'] : '', |
|
144 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : '', |
|
145 | + 'CNT_ISO' => ! empty($data['country']) ? $data['country'] : '', |
|
146 | + 'ATT_zip' => ! empty($data['zip']) ? $data['zip'] : '', |
|
147 | + 'ATT_phone' => ! empty($data['phone']) ? $data['phone'] : '', |
|
148 | + )); |
|
149 | + } |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | // 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', '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', '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 | ); |
@@ -82,43 +82,43 @@ discard block |
||
82 | 82 | // grab billing form data |
83 | 83 | $data = $this->valid_data(); |
84 | 84 | // copy first_name |
85 | - if (! empty($data['first_name'])) { |
|
85 | + if ( ! empty($data['first_name'])) { |
|
86 | 86 | $attendee->set_fname($data['first_name']); |
87 | 87 | } |
88 | 88 | // copy last_name |
89 | - if (! empty($data['last_name'])) { |
|
89 | + if ( ! empty($data['last_name'])) { |
|
90 | 90 | $attendee->set_lname($data['last_name']); |
91 | 91 | } |
92 | 92 | // copy email |
93 | - if (! empty($data['email'])) { |
|
93 | + if ( ! empty($data['email'])) { |
|
94 | 94 | $attendee->set_email($data['email']); |
95 | 95 | } |
96 | 96 | // copy address |
97 | - if (! empty($data['address'])) { |
|
97 | + if ( ! empty($data['address'])) { |
|
98 | 98 | $attendee->set_address($data['address']); |
99 | 99 | } |
100 | 100 | // copy address2 |
101 | - if (! empty($data['address2'])) { |
|
101 | + if ( ! empty($data['address2'])) { |
|
102 | 102 | $attendee->set_address2($data['address2']); |
103 | 103 | } |
104 | 104 | // copy city |
105 | - if (! empty($data['city'])) { |
|
105 | + if ( ! empty($data['city'])) { |
|
106 | 106 | $attendee->set_city($data['city']); |
107 | 107 | } |
108 | 108 | // copy state |
109 | - if (! empty($data['state'])) { |
|
109 | + if ( ! empty($data['state'])) { |
|
110 | 110 | $attendee->set_state($data['state']); |
111 | 111 | } |
112 | 112 | // copy country |
113 | - if (! empty($data['country'])) { |
|
113 | + if ( ! empty($data['country'])) { |
|
114 | 114 | $attendee->set_country($data['country']); |
115 | 115 | } |
116 | 116 | // copy zip |
117 | - if (! empty($data['zip'])) { |
|
117 | + if ( ! empty($data['zip'])) { |
|
118 | 118 | $attendee->set_zip($data['zip']); |
119 | 119 | } |
120 | 120 | // copy phone |
121 | - if (! empty($data['phone'])) { |
|
121 | + if ( ! empty($data['phone'])) { |
|
122 | 122 | $attendee->set_phone($data['phone']); |
123 | 123 | } |
124 | 124 | return $attendee; |
@@ -2,47 +2,47 @@ |
||
2 | 2 | |
3 | 3 | class EE_Validation_Error extends Exception |
4 | 4 | { |
5 | - /** |
|
6 | - * Form Section from which this error originated. |
|
7 | - * @var EE_Form_Section |
|
8 | - */ |
|
9 | - protected $_form_section; |
|
10 | - /** |
|
11 | - * a short string for uniquely identifying the error, which isn't internationalized and |
|
12 | - * machines can use to identify the error |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $_string_code; |
|
5 | + /** |
|
6 | + * Form Section from which this error originated. |
|
7 | + * @var EE_Form_Section |
|
8 | + */ |
|
9 | + protected $_form_section; |
|
10 | + /** |
|
11 | + * a short string for uniquely identifying the error, which isn't internationalized and |
|
12 | + * machines can use to identify the error |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $_string_code; |
|
16 | 16 | |
17 | - /** |
|
18 | - * When creating a validation error, we need to know which field the error relates to. |
|
19 | - * @param string $message message you want to display about this error |
|
20 | - * @param string $string_code a code for uniquely identifying the exception |
|
21 | - * @param EE_Form_Section_Validatable $form_section |
|
22 | - * @param Exception $previous if there was an exception that caused this exception |
|
23 | - */ |
|
24 | - public function __construct($message = null, $string_code = null, $form_section = null, $previous = null) |
|
25 | - { |
|
26 | - $this->_form_section = $form_section; |
|
27 | - $this->_string_code = $string_code; |
|
28 | - parent::__construct($message, 500, $previous); |
|
29 | - } |
|
17 | + /** |
|
18 | + * When creating a validation error, we need to know which field the error relates to. |
|
19 | + * @param string $message message you want to display about this error |
|
20 | + * @param string $string_code a code for uniquely identifying the exception |
|
21 | + * @param EE_Form_Section_Validatable $form_section |
|
22 | + * @param Exception $previous if there was an exception that caused this exception |
|
23 | + */ |
|
24 | + public function __construct($message = null, $string_code = null, $form_section = null, $previous = null) |
|
25 | + { |
|
26 | + $this->_form_section = $form_section; |
|
27 | + $this->_string_code = $string_code; |
|
28 | + parent::__construct($message, 500, $previous); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * returns teh form section which caused the error. |
|
33 | - * @return EE_Form_Section_Validatable |
|
34 | - */ |
|
35 | - public function get_form_section() |
|
36 | - { |
|
37 | - return $this->_form_section; |
|
38 | - } |
|
39 | - /** |
|
40 | - * Sets teh form seciton of the error, in case it wasnt set previously |
|
41 | - * @param EE_Form_Section_Validatable $form_section |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public function set_form_section($form_section) |
|
45 | - { |
|
46 | - $this->_form_section = $form_section; |
|
47 | - } |
|
31 | + /** |
|
32 | + * returns teh form section which caused the error. |
|
33 | + * @return EE_Form_Section_Validatable |
|
34 | + */ |
|
35 | + public function get_form_section() |
|
36 | + { |
|
37 | + return $this->_form_section; |
|
38 | + } |
|
39 | + /** |
|
40 | + * Sets teh form seciton of the error, in case it wasnt set previously |
|
41 | + * @param EE_Form_Section_Validatable $form_section |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public function set_form_section($form_section) |
|
45 | + { |
|
46 | + $this->_form_section = $form_section; |
|
47 | + } |
|
48 | 48 | } |
@@ -1,60 +1,60 @@ |
||
1 | 1 | <?php |
2 | 2 | class EE_Sample_Form extends EE_Form_Section_Proper |
3 | 3 | { |
4 | - public function __construct() |
|
5 | - { |
|
6 | - $this->_subsections = array( |
|
7 | - 'h1'=>new EE_Form_Section_HTML('hello wordl'), |
|
8 | - 'name'=>new EE_Text_Input(array('required'=>true,'default'=>'your name here')), |
|
9 | - 'email'=>new EE_Email_Input(array('required'=>false)), |
|
10 | - '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')), |
|
11 | - 'month_normal'=>new EE_Month_Input(), |
|
12 | - 'month_leading_zero'=>new EE_Month_Input(true), |
|
13 | - 'year_2'=>new EE_Year_Input(false, 1, 1), |
|
14 | - 'year_4'=>new EE_Year_Input(true, 0, 10, array('default'=>'2017')), |
|
15 | - 'yes_no'=>new EE_Yes_No_Input(array('html_label_text'=> __("Yes or No", "event_espresso"))), |
|
16 | - 'credit_card'=>new EE_Credit_Card_Input(), |
|
17 | - 'image_1'=>new EE_Admin_File_Uploader_Input(), |
|
18 | - 'image_2'=>new EE_Admin_File_Uploader_Input(), |
|
19 | - 'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP','mysql'=>'MYSQL'), array('default'=>array('php'))), |
|
20 | - 'float'=>new EE_Float_Input(), |
|
21 | - 'essay'=>new EE_Text_Area_Input(), |
|
22 | - 'amenities'=>new EE_Select_Multiple_Input( |
|
23 | - array( |
|
24 | - 'hottub'=>'Hot Tub', |
|
25 | - 'balcony'=>"Balcony", |
|
26 | - 'skylight'=>'SkyLight', |
|
27 | - 'no_axe'=>'No Axe Murderers' |
|
28 | - ), |
|
29 | - array( |
|
30 | - 'default'=>array( |
|
31 | - 'hottub', |
|
32 | - 'no_axe' ), |
|
33 | - ) |
|
34 | - ), |
|
35 | - 'payment_methods'=>new EE_Select_Multi_Model_Input(EEM_Payment_Method::instance()->get_all()), |
|
36 | - ); |
|
37 | - $this->_layout_strategy = new EE_Div_Per_Section_Layout(); |
|
38 | - parent::__construct(); |
|
39 | - } |
|
4 | + public function __construct() |
|
5 | + { |
|
6 | + $this->_subsections = array( |
|
7 | + 'h1'=>new EE_Form_Section_HTML('hello wordl'), |
|
8 | + 'name'=>new EE_Text_Input(array('required'=>true,'default'=>'your name here')), |
|
9 | + 'email'=>new EE_Email_Input(array('required'=>false)), |
|
10 | + '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')), |
|
11 | + 'month_normal'=>new EE_Month_Input(), |
|
12 | + 'month_leading_zero'=>new EE_Month_Input(true), |
|
13 | + 'year_2'=>new EE_Year_Input(false, 1, 1), |
|
14 | + 'year_4'=>new EE_Year_Input(true, 0, 10, array('default'=>'2017')), |
|
15 | + 'yes_no'=>new EE_Yes_No_Input(array('html_label_text'=> __("Yes or No", "event_espresso"))), |
|
16 | + 'credit_card'=>new EE_Credit_Card_Input(), |
|
17 | + 'image_1'=>new EE_Admin_File_Uploader_Input(), |
|
18 | + 'image_2'=>new EE_Admin_File_Uploader_Input(), |
|
19 | + 'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP','mysql'=>'MYSQL'), array('default'=>array('php'))), |
|
20 | + 'float'=>new EE_Float_Input(), |
|
21 | + 'essay'=>new EE_Text_Area_Input(), |
|
22 | + 'amenities'=>new EE_Select_Multiple_Input( |
|
23 | + array( |
|
24 | + 'hottub'=>'Hot Tub', |
|
25 | + 'balcony'=>"Balcony", |
|
26 | + 'skylight'=>'SkyLight', |
|
27 | + 'no_axe'=>'No Axe Murderers' |
|
28 | + ), |
|
29 | + array( |
|
30 | + 'default'=>array( |
|
31 | + 'hottub', |
|
32 | + 'no_axe' ), |
|
33 | + ) |
|
34 | + ), |
|
35 | + 'payment_methods'=>new EE_Select_Multi_Model_Input(EEM_Payment_Method::instance()->get_all()), |
|
36 | + ); |
|
37 | + $this->_layout_strategy = new EE_Div_Per_Section_Layout(); |
|
38 | + parent::__construct(); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Extra validation for the 'name' input. |
|
43 | - * @param EE_Text_Input $form_input |
|
44 | - */ |
|
45 | - public function _validate_name($form_input) |
|
46 | - { |
|
47 | - if ($form_input->raw_value() != 'Mike') { |
|
48 | - $form_input->add_validation_error(__("You are not mike. You must be brent or darren. Thats ok, I guess", 'event_espresso'), 'not-mike'); |
|
49 | - } |
|
50 | - } |
|
41 | + /** |
|
42 | + * Extra validation for the 'name' input. |
|
43 | + * @param EE_Text_Input $form_input |
|
44 | + */ |
|
45 | + public function _validate_name($form_input) |
|
46 | + { |
|
47 | + if ($form_input->raw_value() != 'Mike') { |
|
48 | + $form_input->add_validation_error(__("You are not mike. You must be brent or darren. Thats ok, I guess", 'event_espresso'), 'not-mike'); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - public function _validate() |
|
53 | - { |
|
54 | - parent::_validate(); |
|
55 | - if ($this->_subsections['shirt_size']->normalized_value() =='s' |
|
56 | - && $this->_subsections['year_4']->normalized_value() < 2010) { |
|
57 | - $this->add_validation_error(__("If you want a small shirt, you should be born after 2010. Otherwise theyre just too big", 'event_espresso'), 'too-old'); |
|
58 | - } |
|
59 | - } |
|
52 | + public function _validate() |
|
53 | + { |
|
54 | + parent::_validate(); |
|
55 | + if ($this->_subsections['shirt_size']->normalized_value() =='s' |
|
56 | + && $this->_subsections['year_4']->normalized_value() < 2010) { |
|
57 | + $this->add_validation_error(__("If you want a small shirt, you should be born after 2010. Otherwise theyre just too big", 'event_espresso'), 'too-old'); |
|
58 | + } |
|
59 | + } |
|
60 | 60 | } |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | { |
6 | 6 | $this->_subsections = array( |
7 | 7 | 'h1'=>new EE_Form_Section_HTML('hello wordl'), |
8 | - 'name'=>new EE_Text_Input(array('required'=>true,'default'=>'your name here')), |
|
8 | + 'name'=>new EE_Text_Input(array('required'=>true, 'default'=>'your name here')), |
|
9 | 9 | 'email'=>new EE_Email_Input(array('required'=>false)), |
10 | - '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')), |
|
10 | + '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')), |
|
11 | 11 | 'month_normal'=>new EE_Month_Input(), |
12 | 12 | 'month_leading_zero'=>new EE_Month_Input(true), |
13 | 13 | 'year_2'=>new EE_Year_Input(false, 1, 1), |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | 'credit_card'=>new EE_Credit_Card_Input(), |
17 | 17 | 'image_1'=>new EE_Admin_File_Uploader_Input(), |
18 | 18 | 'image_2'=>new EE_Admin_File_Uploader_Input(), |
19 | - 'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP','mysql'=>'MYSQL'), array('default'=>array('php'))), |
|
19 | + 'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP', 'mysql'=>'MYSQL'), array('default'=>array('php'))), |
|
20 | 20 | 'float'=>new EE_Float_Input(), |
21 | 21 | 'essay'=>new EE_Text_Area_Input(), |
22 | 22 | 'amenities'=>new EE_Select_Multiple_Input( |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function _validate() |
53 | 53 | { |
54 | 54 | parent::_validate(); |
55 | - if ($this->_subsections['shirt_size']->normalized_value() =='s' |
|
55 | + if ($this->_subsections['shirt_size']->normalized_value() == 's' |
|
56 | 56 | && $this->_subsections['year_4']->normalized_value() < 2010) { |
57 | 57 | $this->add_validation_error(__("If you want a small shirt, you should be born after 2010. Otherwise theyre just too big", 'event_espresso'), 'too-old'); |
58 | 58 | } |
@@ -15,117 +15,117 @@ |
||
15 | 15 | abstract class EE_Offsite_Gateway extends EE_Gateway |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * whether or not the gateway uses an IPN |
|
20 | - * that is sent in a separate request than the returning registrant. |
|
21 | - * if false, then we need to process the payment results manually |
|
22 | - * as soon as the registrant returns from the off-site gateway |
|
23 | - * |
|
24 | - * @type bool |
|
25 | - */ |
|
26 | - protected $_uses_separate_IPN_request = false; |
|
18 | + /** |
|
19 | + * whether or not the gateway uses an IPN |
|
20 | + * that is sent in a separate request than the returning registrant. |
|
21 | + * if false, then we need to process the payment results manually |
|
22 | + * as soon as the registrant returns from the off-site gateway |
|
23 | + * |
|
24 | + * @type bool |
|
25 | + */ |
|
26 | + protected $_uses_separate_IPN_request = false; |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @return EE_Offsite_Gateway |
|
31 | - */ |
|
32 | - public function __construct() |
|
33 | - { |
|
34 | - $this->_supports_receiving_refunds = true; |
|
35 | - parent::__construct(); |
|
36 | - } |
|
29 | + /** |
|
30 | + * @return EE_Offsite_Gateway |
|
31 | + */ |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | + $this->_supports_receiving_refunds = true; |
|
35 | + parent::__construct(); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Adds information into the payment object's redirect_url and redirect_args so |
|
41 | - * client code can use that payment to know where (and with what information) |
|
42 | - * to redirect the user to in order to make the payment on the offsite gateway's website. |
|
43 | - * Saving the payment from within this method is unnecessary, |
|
44 | - * as it is the responsibility of client code to save it. |
|
45 | - * |
|
46 | - * @param EE_Payment $payment to process |
|
47 | - * @param array $billing_info |
|
48 | - * @param string $return_url URL to send the user to after a successful payment on the payment provider's |
|
49 | - * website |
|
50 | - * @param string $notify_url URL to send the instant payment notification |
|
51 | - * @param string $cancel_url URL to send the user to after a cancelled payment attempt on teh payment |
|
52 | - * provider's website |
|
53 | - * @return EE_Payment |
|
54 | - */ |
|
55 | - abstract public function set_redirection_info( |
|
56 | - $payment, |
|
57 | - $billing_info = array(), |
|
58 | - $return_url = null, |
|
59 | - $notify_url = null, |
|
60 | - $cancel_url = null |
|
61 | - ); |
|
39 | + /** |
|
40 | + * Adds information into the payment object's redirect_url and redirect_args so |
|
41 | + * client code can use that payment to know where (and with what information) |
|
42 | + * to redirect the user to in order to make the payment on the offsite gateway's website. |
|
43 | + * Saving the payment from within this method is unnecessary, |
|
44 | + * as it is the responsibility of client code to save it. |
|
45 | + * |
|
46 | + * @param EE_Payment $payment to process |
|
47 | + * @param array $billing_info |
|
48 | + * @param string $return_url URL to send the user to after a successful payment on the payment provider's |
|
49 | + * website |
|
50 | + * @param string $notify_url URL to send the instant payment notification |
|
51 | + * @param string $cancel_url URL to send the user to after a cancelled payment attempt on teh payment |
|
52 | + * provider's website |
|
53 | + * @return EE_Payment |
|
54 | + */ |
|
55 | + abstract public function set_redirection_info( |
|
56 | + $payment, |
|
57 | + $billing_info = array(), |
|
58 | + $return_url = null, |
|
59 | + $notify_url = null, |
|
60 | + $cancel_url = null |
|
61 | + ); |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * Often used for IPNs. But applies the info in $update_info to the payment. |
|
66 | - * What is $update_info? Often the contents of $_REQUEST, but not necessarily. Whatever |
|
67 | - * the payment method passes in. Saving the payment from within this method is unnecessary, |
|
68 | - * as it is the responsibility of client code to save it. |
|
69 | - * |
|
70 | - * @param array $update_info of whatever |
|
71 | - * @param EEI_Transaction $transaction |
|
72 | - * @return EEI_Payment updated |
|
73 | - */ |
|
74 | - abstract public function handle_payment_update($update_info, $transaction); |
|
64 | + /** |
|
65 | + * Often used for IPNs. But applies the info in $update_info to the payment. |
|
66 | + * What is $update_info? Often the contents of $_REQUEST, but not necessarily. Whatever |
|
67 | + * the payment method passes in. Saving the payment from within this method is unnecessary, |
|
68 | + * as it is the responsibility of client code to save it. |
|
69 | + * |
|
70 | + * @param array $update_info of whatever |
|
71 | + * @param EEI_Transaction $transaction |
|
72 | + * @return EEI_Payment updated |
|
73 | + */ |
|
74 | + abstract public function handle_payment_update($update_info, $transaction); |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * uses_separate_IPN_request |
|
79 | - * |
|
80 | - * return true or false for whether or not the gateway uses an IPN |
|
81 | - * that is sent in a separate request than the returning registrant. |
|
82 | - * if false, then we need to process the payment results manually |
|
83 | - * as soon as the registrant returns from the off-site gateway |
|
84 | - * |
|
85 | - * @deprecated since version 4.8.39.rc.001 please use handle_IPN_in_this_request() instead |
|
86 | - * |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - public function uses_separate_IPN_request() |
|
90 | - { |
|
91 | - return $this->_uses_separate_IPN_request; |
|
92 | - } |
|
77 | + /** |
|
78 | + * uses_separate_IPN_request |
|
79 | + * |
|
80 | + * return true or false for whether or not the gateway uses an IPN |
|
81 | + * that is sent in a separate request than the returning registrant. |
|
82 | + * if false, then we need to process the payment results manually |
|
83 | + * as soon as the registrant returns from the off-site gateway |
|
84 | + * |
|
85 | + * @deprecated since version 4.8.39.rc.001 please use handle_IPN_in_this_request() instead |
|
86 | + * |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + public function uses_separate_IPN_request() |
|
90 | + { |
|
91 | + return $this->_uses_separate_IPN_request; |
|
92 | + } |
|
93 | 93 | |
94 | 94 | |
95 | - /** |
|
96 | - * set_uses_separate_IPN_request |
|
97 | - * |
|
98 | - * @access protected |
|
99 | - * @param boolean $uses_separate_IPN_request |
|
100 | - */ |
|
101 | - protected function set_uses_separate_IPN_request($uses_separate_IPN_request) |
|
102 | - { |
|
103 | - $this->_uses_separate_IPN_request = filter_var($uses_separate_IPN_request, FILTER_VALIDATE_BOOLEAN); |
|
104 | - } |
|
95 | + /** |
|
96 | + * set_uses_separate_IPN_request |
|
97 | + * |
|
98 | + * @access protected |
|
99 | + * @param boolean $uses_separate_IPN_request |
|
100 | + */ |
|
101 | + protected function set_uses_separate_IPN_request($uses_separate_IPN_request) |
|
102 | + { |
|
103 | + $this->_uses_separate_IPN_request = filter_var($uses_separate_IPN_request, FILTER_VALIDATE_BOOLEAN); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Allows gateway to dynamically decide whether or not to handle a payment update |
|
108 | - * by overriding this method. By default, if this is a "true" IPN (meaning |
|
109 | - * it's a separate request from when the user returns from the offsite gateway) |
|
110 | - * and this gateway class is setup to handle IPNs in separate "true" IPNs, then |
|
111 | - * this will return true, otherwise it will return false. |
|
112 | - * If however, this is a request when the user is returning |
|
113 | - * from an offsite gateway, and this gateway class is setup to process the payment |
|
114 | - * data when the user returns, then this will return true. |
|
115 | - * |
|
116 | - * @param array $request_data |
|
117 | - * @param boolean $separate_IPN_request |
|
118 | - * @return boolean |
|
119 | - */ |
|
120 | - public function handle_IPN_in_this_request($request_data, $separate_IPN_request) |
|
121 | - { |
|
122 | - if ($separate_IPN_request) { |
|
123 | - // payment data being sent in a request separate from the user |
|
124 | - // it is this other request that will update the TXN and payment info |
|
125 | - return $this->_uses_separate_IPN_request; |
|
126 | - } else { |
|
127 | - // it's a request where the user returned from an offsite gateway WITH the payment data |
|
128 | - return ! $this->_uses_separate_IPN_request; |
|
129 | - } |
|
130 | - } |
|
106 | + /** |
|
107 | + * Allows gateway to dynamically decide whether or not to handle a payment update |
|
108 | + * by overriding this method. By default, if this is a "true" IPN (meaning |
|
109 | + * it's a separate request from when the user returns from the offsite gateway) |
|
110 | + * and this gateway class is setup to handle IPNs in separate "true" IPNs, then |
|
111 | + * this will return true, otherwise it will return false. |
|
112 | + * If however, this is a request when the user is returning |
|
113 | + * from an offsite gateway, and this gateway class is setup to process the payment |
|
114 | + * data when the user returns, then this will return true. |
|
115 | + * |
|
116 | + * @param array $request_data |
|
117 | + * @param boolean $separate_IPN_request |
|
118 | + * @return boolean |
|
119 | + */ |
|
120 | + public function handle_IPN_in_this_request($request_data, $separate_IPN_request) |
|
121 | + { |
|
122 | + if ($separate_IPN_request) { |
|
123 | + // payment data being sent in a request separate from the user |
|
124 | + // it is this other request that will update the TXN and payment info |
|
125 | + return $this->_uses_separate_IPN_request; |
|
126 | + } else { |
|
127 | + // it's a request where the user returned from an offsite gateway WITH the payment data |
|
128 | + return ! $this->_uses_separate_IPN_request; |
|
129 | + } |
|
130 | + } |
|
131 | 131 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
118 | 118 | do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
119 | 119 | } |
120 | - if (! isset($this->_has_billing_form)) { |
|
120 | + if ( ! isset($this->_has_billing_form)) { |
|
121 | 121 | // by default, On Site gateways have a billing form |
122 | 122 | if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
123 | 123 | $this->set_has_billing_form(true); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | - if (! $this->_pretty_name) { |
|
129 | + if ( ! $this->_pretty_name) { |
|
130 | 130 | throw new EE_Error( |
131 | 131 | sprintf( |
132 | 132 | __( |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | // if the child didn't specify a default button, use the credit card one |
140 | 140 | if ($this->_default_button_url === null) { |
141 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png'; |
|
141 | + $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods'.DS.'pay-by-credit-card.png'; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | { |
160 | 160 | $reflector = new ReflectionClass(get_class($this)); |
161 | 161 | $fn = $reflector->getFileName(); |
162 | - $this->_file_folder = dirname($fn) . DS; |
|
162 | + $this->_file_folder = dirname($fn).DS; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function file_folder() |
194 | 194 | { |
195 | - if (! $this->_file_folder) { |
|
195 | + if ( ! $this->_file_folder) { |
|
196 | 196 | $this->_set_file_folder(); |
197 | 197 | } |
198 | 198 | return $this->_file_folder; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function file_url() |
206 | 206 | { |
207 | - if (! $this->_file_url) { |
|
207 | + if ( ! $this->_file_url) { |
|
208 | 208 | $this->_set_file_url(); |
209 | 209 | } |
210 | 210 | return $this->_file_url; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function settings_form() |
240 | 240 | { |
241 | - if (! $this->_settings_form) { |
|
241 | + if ( ! $this->_settings_form) { |
|
242 | 242 | $this->_settings_form = $this->generate_new_settings_form(); |
243 | 243 | $this->_settings_form->set_payment_method_type($this); |
244 | 244 | // if we have already assigned a model object to this pmt, make |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
293 | 293 | { |
294 | 294 | // has billing form already been regenerated ? or overwrite cache? |
295 | - if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
295 | + if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
296 | 296 | $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
297 | 297 | } |
298 | 298 | // if we know who the attendee is, and this is a billing form |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
395 | 395 | // if we didn't already have a payment in progress for the same thing, |
396 | 396 | // then we actually want to make a new payment |
397 | - if (! $payment instanceof EE_Payment) { |
|
397 | + if ( ! $payment instanceof EE_Payment) { |
|
398 | 398 | $payment = EE_Payment::new_instance( |
399 | 399 | array_merge( |
400 | 400 | $duplicate_properties, |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | public function handle_ipn($req_data, $transaction) |
496 | 496 | { |
497 | 497 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
498 | - if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
498 | + if ( ! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
499 | 499 | throw new EE_Error( |
500 | 500 | sprintf( |
501 | 501 | __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | */ |
519 | 519 | protected function _save_billing_info_to_attendee($billing_form, $transaction) |
520 | 520 | { |
521 | - if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
521 | + if ( ! $transaction || ! $transaction instanceof EE_Transaction) { |
|
522 | 522 | EE_Error::add_error( |
523 | 523 | __("Cannot save billing info because no transaction was specified", "event_espresso"), |
524 | 524 | __FILE__, |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | return false; |
529 | 529 | } |
530 | 530 | $primary_reg = $transaction->primary_registration(); |
531 | - if (! $primary_reg) { |
|
531 | + if ( ! $primary_reg) { |
|
532 | 532 | EE_Error::add_error( |
533 | 533 | __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
534 | 534 | __FILE__, |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | return false; |
539 | 539 | } |
540 | 540 | $attendee = $primary_reg->attendee(); |
541 | - if (! $attendee) { |
|
541 | + if ( ! $attendee) { |
|
542 | 542 | EE_Error::add_error( |
543 | 543 | __( |
544 | 544 | "Cannot save billing info because the transaction's primary registration has no attendee!", |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | */ |
652 | 652 | public function payment_occurs() |
653 | 653 | { |
654 | - if (! $this->_gateway) { |
|
654 | + if ( ! $this->_gateway) { |
|
655 | 655 | return EE_PMT_Base::offline; |
656 | 656 | } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
657 | 657 | return EE_PMT_Base::onsite; |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | public function payment_overview_content(EE_Payment $payment) |
683 | 683 | { |
684 | 684 | return EEH_Template::display_template( |
685 | - EE_LIBRARIES . 'payment_methods' . DS . 'templates' . DS . 'payment_details_content.template.php', |
|
685 | + EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', |
|
686 | 686 | array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
687 | 687 | true |
688 | 688 | ); |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | */ |
770 | 770 | public function get_help_tab_name() |
771 | 771 | { |
772 | - return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
772 | + return 'ee_'.strtolower($this->system_name()).'_help_tab'; |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | */ |
781 | 781 | public function cap_name() |
782 | 782 | { |
783 | - return 'ee_payment_method_' . strtolower($this->system_name()); |
|
783 | + return 'ee_payment_method_'.strtolower($this->system_name()); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | /** |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | public function introductory_html() |
815 | 815 | { |
816 | 816 | return EEH_Template::locate_template( |
817 | - $this->file_folder() . 'templates' . DS . strtolower($this->system_name()) . '_intro.template.php', |
|
817 | + $this->file_folder().'templates'.DS.strtolower($this->system_name()).'_intro.template.php', |
|
818 | 818 | array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
819 | 819 | ); |
820 | 820 | } |
@@ -21,812 +21,812 @@ |
||
21 | 21 | abstract class EE_PMT_Base |
22 | 22 | { |
23 | 23 | |
24 | - const onsite = 'on-site'; |
|
25 | - const offsite = 'off-site'; |
|
26 | - const offline = 'off-line'; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var EE_Payment_Method |
|
30 | - */ |
|
31 | - protected $_pm_instance = null; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var boolean |
|
35 | - */ |
|
36 | - protected $_requires_https = false; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var boolean |
|
40 | - */ |
|
41 | - protected $_has_billing_form; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var EE_Gateway |
|
45 | - */ |
|
46 | - protected $_gateway = null; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var EE_Payment_Method_Form |
|
50 | - */ |
|
51 | - protected $_settings_form = null; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var EE_Form_Section_Proper |
|
55 | - */ |
|
56 | - protected $_billing_form = null; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var boolean |
|
60 | - */ |
|
61 | - protected $_cache_billing_form = true; |
|
62 | - |
|
63 | - /** |
|
64 | - * String of the absolute path to the folder containing this file, with a trailing slash. |
|
65 | - * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/' |
|
66 | - * |
|
67 | - * @var string |
|
68 | - */ |
|
69 | - protected $_file_folder = null; |
|
70 | - |
|
71 | - /** |
|
72 | - * String to the absolute URL to this file (useful for getting its web-accessible resources |
|
73 | - * like images, js, or css) |
|
74 | - * |
|
75 | - * @var string |
|
76 | - */ |
|
77 | - protected $_file_url = null; |
|
78 | - |
|
79 | - /** |
|
80 | - * Pretty name for the payment method |
|
81 | - * |
|
82 | - * @var string |
|
83 | - */ |
|
84 | - protected $_pretty_name = null; |
|
85 | - |
|
86 | - /** |
|
87 | - * |
|
88 | - * @var string |
|
89 | - */ |
|
90 | - protected $_default_button_url = null; |
|
91 | - |
|
92 | - /** |
|
93 | - * |
|
94 | - * @var string |
|
95 | - */ |
|
96 | - protected $_default_description = null; |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * |
|
101 | - * @param EE_Payment_Method $pm_instance |
|
102 | - * @throws EE_Error |
|
103 | - * @return EE_PMT_Base |
|
104 | - */ |
|
105 | - public function __construct($pm_instance = null) |
|
106 | - { |
|
107 | - if ($pm_instance instanceof EE_Payment_Method) { |
|
108 | - $this->set_instance($pm_instance); |
|
109 | - } |
|
110 | - if ($this->_gateway) { |
|
111 | - $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
112 | - $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
113 | - $this->_gateway->set_template_helper(new EEH_Template()); |
|
114 | - $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
115 | - $this->_gateway->set_money_helper(new EEH_Money()); |
|
116 | - $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
117 | - $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
118 | - do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
|
119 | - } |
|
120 | - if (! isset($this->_has_billing_form)) { |
|
121 | - // by default, On Site gateways have a billing form |
|
122 | - if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
123 | - $this->set_has_billing_form(true); |
|
124 | - } else { |
|
125 | - $this->set_has_billing_form(false); |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - if (! $this->_pretty_name) { |
|
130 | - throw new EE_Error( |
|
131 | - sprintf( |
|
132 | - __( |
|
133 | - "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", |
|
134 | - "event_espresso" |
|
135 | - ) |
|
136 | - ) |
|
137 | - ); |
|
138 | - } |
|
139 | - // if the child didn't specify a default button, use the credit card one |
|
140 | - if ($this->_default_button_url === null) { |
|
141 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png'; |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @param boolean $has_billing_form |
|
148 | - */ |
|
149 | - public function set_has_billing_form($has_billing_form) |
|
150 | - { |
|
151 | - $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * sets the file_folder property |
|
157 | - */ |
|
158 | - protected function _set_file_folder() |
|
159 | - { |
|
160 | - $reflector = new ReflectionClass(get_class($this)); |
|
161 | - $fn = $reflector->getFileName(); |
|
162 | - $this->_file_folder = dirname($fn) . DS; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * sets the file URL with a trailing slash for this PMT |
|
168 | - */ |
|
169 | - protected function _set_file_url() |
|
170 | - { |
|
171 | - $plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR); |
|
172 | - $file_folder_fixed = str_replace('\\', DS, $this->file_folder()); |
|
173 | - $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
174 | - $this->_file_url = $file_path; |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * Gets the default description on all payment methods of this type |
|
179 | - * |
|
180 | - * @return string |
|
181 | - */ |
|
182 | - public function default_description() |
|
183 | - { |
|
184 | - return $this->_default_description; |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * Returns the folder containing the PMT child class, with a trailing slash |
|
190 | - * |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public function file_folder() |
|
194 | - { |
|
195 | - if (! $this->_file_folder) { |
|
196 | - $this->_set_file_folder(); |
|
197 | - } |
|
198 | - return $this->_file_folder; |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * @return string |
|
204 | - */ |
|
205 | - public function file_url() |
|
206 | - { |
|
207 | - if (! $this->_file_url) { |
|
208 | - $this->_set_file_url(); |
|
209 | - } |
|
210 | - return $this->_file_url; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * Sets the payment method instance this payment method type is for. |
|
216 | - * Its important teh payment method instance is set before |
|
217 | - * |
|
218 | - * @param EE_Payment_Method $payment_method_instance |
|
219 | - */ |
|
220 | - public function set_instance($payment_method_instance) |
|
221 | - { |
|
222 | - $this->_pm_instance = $payment_method_instance; |
|
223 | - // if they have already requested the settings form, make sure its |
|
224 | - // data matches this model object |
|
225 | - if ($this->_settings_form) { |
|
226 | - $this->settings_form()->populate_model_obj($payment_method_instance); |
|
227 | - } |
|
228 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
229 | - $this->_gateway->set_settings($payment_method_instance->settings_array()); |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - /** |
|
235 | - * Gets teh form for displaying to admins where they setup the payment method |
|
236 | - * |
|
237 | - * @return EE_Payment_Method_Form |
|
238 | - */ |
|
239 | - public function settings_form() |
|
240 | - { |
|
241 | - if (! $this->_settings_form) { |
|
242 | - $this->_settings_form = $this->generate_new_settings_form(); |
|
243 | - $this->_settings_form->set_payment_method_type($this); |
|
244 | - // if we have already assigned a model object to this pmt, make |
|
245 | - // sure its reflected in teh form we just generated |
|
246 | - if ($this->_pm_instance) { |
|
247 | - $this->_settings_form->populate_model_obj($this->_pm_instance); |
|
248 | - } |
|
249 | - } |
|
250 | - return $this->_settings_form; |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - /** |
|
255 | - * Gets the form for all the settings related to this payment method type |
|
256 | - * |
|
257 | - * @return EE_Payment_Method_Form |
|
258 | - */ |
|
259 | - abstract public function generate_new_settings_form(); |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * Sets the form for settings. This may be useful if we have already received |
|
264 | - * a form submission and have form data it in, and want to use it anytime we're showing |
|
265 | - * this payment method type's settings form later in the request |
|
266 | - * |
|
267 | - * @param EE_Payment_Method_Form $form |
|
268 | - */ |
|
269 | - public function set_settings_form($form) |
|
270 | - { |
|
271 | - $this->_settings_form = $form; |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * @return boolean |
|
277 | - */ |
|
278 | - public function has_billing_form() |
|
279 | - { |
|
280 | - return $this->_has_billing_form; |
|
281 | - } |
|
282 | - |
|
283 | - |
|
284 | - /** |
|
285 | - * Gets the form for displaying to attendees where they can enter their billing info |
|
286 | - * which will be sent to teh gateway (can be null) |
|
287 | - * |
|
288 | - * @param \EE_Transaction $transaction |
|
289 | - * @param array $extra_args |
|
290 | - * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
|
291 | - */ |
|
292 | - public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
|
293 | - { |
|
294 | - // has billing form already been regenerated ? or overwrite cache? |
|
295 | - if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
296 | - $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
297 | - } |
|
298 | - // if we know who the attendee is, and this is a billing form |
|
299 | - // that uses attendee info, populate it |
|
300 | - if (apply_filters( |
|
301 | - 'FHEE__populate_billing_form_fields_from_attendee', |
|
302 | - ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
303 | - && $transaction instanceof EE_Transaction |
|
304 | - && $transaction->primary_registration() instanceof EE_Registration |
|
305 | - && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
306 | - ), |
|
307 | - $this->_billing_form, |
|
308 | - $transaction |
|
309 | - )) { |
|
310 | - $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
311 | - } |
|
312 | - return $this->_billing_form; |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * Creates the billing form for this payment method type |
|
318 | - * |
|
319 | - * @param \EE_Transaction $transaction |
|
320 | - * @return \EE_Billing_Info_Form |
|
321 | - */ |
|
322 | - abstract public function generate_new_billing_form(EE_Transaction $transaction = null); |
|
323 | - |
|
324 | - |
|
325 | - /** |
|
326 | - * apply_billing_form_debug_settings |
|
327 | - * applies debug data to the form |
|
328 | - * |
|
329 | - * @param \EE_Billing_Info_Form $billing_form |
|
330 | - * @return \EE_Billing_Info_Form |
|
331 | - */ |
|
332 | - public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
333 | - { |
|
334 | - return $billing_form; |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * Sets the billing form for this payment method type. You may want to use this |
|
340 | - * if you have form |
|
341 | - * |
|
342 | - * @param EE_Payment_Method $form |
|
343 | - */ |
|
344 | - public function set_billing_form($form) |
|
345 | - { |
|
346 | - $this->_billing_form = $form; |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * Returns whether or not this payment method requires HTTPS to be used |
|
352 | - * |
|
353 | - * @return boolean |
|
354 | - */ |
|
355 | - public function requires_https() |
|
356 | - { |
|
357 | - return $this->_requires_https; |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * |
|
363 | - * @param EE_Transaction $transaction |
|
364 | - * @param float $amount |
|
365 | - * @param EE_Billing_Info_Form $billing_info |
|
366 | - * @param string $return_url |
|
367 | - * @param string $fail_url |
|
368 | - * @param string $method |
|
369 | - * @param bool $by_admin |
|
370 | - * @return EE_Payment |
|
371 | - * @throws EE_Error |
|
372 | - */ |
|
373 | - public function process_payment( |
|
374 | - EE_Transaction $transaction, |
|
375 | - $amount = null, |
|
376 | - $billing_info = null, |
|
377 | - $return_url = null, |
|
378 | - $fail_url = '', |
|
379 | - $method = 'CART', |
|
380 | - $by_admin = false |
|
381 | - ) { |
|
382 | - // @todo: add surcharge for the payment method, if any |
|
383 | - if ($this->_gateway) { |
|
384 | - // there is a gateway, so we're going to make a payment object |
|
385 | - // but wait! do they already have a payment in progress that we thought was failed? |
|
386 | - $duplicate_properties = array( |
|
387 | - 'STS_ID' => EEM_Payment::status_id_failed, |
|
388 | - 'TXN_ID' => $transaction->ID(), |
|
389 | - 'PMD_ID' => $this->_pm_instance->ID(), |
|
390 | - 'PAY_source' => $method, |
|
391 | - 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
|
392 | - 'PAY_gateway_response' => null, |
|
393 | - ); |
|
394 | - $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
395 | - // if we didn't already have a payment in progress for the same thing, |
|
396 | - // then we actually want to make a new payment |
|
397 | - if (! $payment instanceof EE_Payment) { |
|
398 | - $payment = EE_Payment::new_instance( |
|
399 | - array_merge( |
|
400 | - $duplicate_properties, |
|
401 | - array( |
|
402 | - 'PAY_timestamp' => time(), |
|
403 | - 'PAY_txn_id_chq_nmbr' => null, |
|
404 | - 'PAY_po_number' => null, |
|
405 | - 'PAY_extra_accntng' => null, |
|
406 | - 'PAY_details' => null, |
|
407 | - ) |
|
408 | - ) |
|
409 | - ); |
|
410 | - } |
|
411 | - // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
|
412 | - $payment->save(); |
|
413 | - $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
414 | - |
|
415 | - // Offsite Gateway |
|
416 | - if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
417 | - $payment = $this->_gateway->set_redirection_info( |
|
418 | - $payment, |
|
419 | - $billing_values, |
|
420 | - $return_url, |
|
421 | - EE_Config::instance()->core->txn_page_url( |
|
422 | - array( |
|
423 | - 'e_reg_url_link' => $transaction->primary_registration()->reg_url_link(), |
|
424 | - 'ee_payment_method' => $this->_pm_instance->slug(), |
|
425 | - ) |
|
426 | - ), |
|
427 | - $fail_url |
|
428 | - ); |
|
429 | - $payment->save(); |
|
430 | - // Onsite Gateway |
|
431 | - } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
432 | - $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
433 | - $payment->save(); |
|
434 | - } else { |
|
435 | - throw new EE_Error( |
|
436 | - sprintf( |
|
437 | - __( |
|
438 | - 'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', |
|
439 | - 'event_espresso' |
|
440 | - ), |
|
441 | - get_class($this), |
|
442 | - gettype($this->_gateway) |
|
443 | - ) |
|
444 | - ); |
|
445 | - } |
|
446 | - } else { |
|
447 | - // no gateway provided |
|
448 | - // there is no payment. Must be an offline gateway |
|
449 | - // create a payment object anyways, but dont save it |
|
450 | - $payment = EE_Payment::new_instance( |
|
451 | - array( |
|
452 | - 'STS_ID' => EEM_Payment::status_id_pending, |
|
453 | - 'TXN_ID' => $transaction->ID(), |
|
454 | - 'PMD_ID' => $transaction->payment_method_ID(), |
|
455 | - 'PAY_amount' => 0.00, |
|
456 | - 'PAY_timestamp' => time(), |
|
457 | - ) |
|
458 | - ); |
|
459 | - } |
|
460 | - |
|
461 | - // if there is billing info, clean it and save it now |
|
462 | - if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
463 | - $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
464 | - } |
|
465 | - |
|
466 | - return $payment; |
|
467 | - } |
|
468 | - |
|
469 | - /** |
|
470 | - * Gets the values we want to pass onto the gateway. Normally these |
|
471 | - * are just the 'pretty' values, but there may be times the data may need |
|
472 | - * a little massaging. Proper subsections will become arrays of inputs |
|
473 | - * |
|
474 | - * @param EE_Billing_Info_Form $billing_form |
|
475 | - * @return array |
|
476 | - */ |
|
477 | - protected function _get_billing_values_from_form($billing_form) |
|
478 | - { |
|
479 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
480 | - return $billing_form->input_pretty_values(true); |
|
481 | - } else { |
|
482 | - return null; |
|
483 | - } |
|
484 | - } |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
488 | - * Handles an instant payment notification when the transaction is known (by default). |
|
489 | - * |
|
490 | - * @param array $req_data |
|
491 | - * @param EE_Transaction $transaction |
|
492 | - * @return EE_Payment |
|
493 | - * @throws EE_Error |
|
494 | - */ |
|
495 | - public function handle_ipn($req_data, $transaction) |
|
496 | - { |
|
497 | - $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
498 | - if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
499 | - throw new EE_Error( |
|
500 | - sprintf( |
|
501 | - __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
|
502 | - print_r($this->_gateway, true) |
|
503 | - ) |
|
504 | - ); |
|
505 | - } |
|
506 | - $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
507 | - return $payment; |
|
508 | - } |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * Saves the billing info onto the attendee of the primary registrant on this transaction, and |
|
513 | - * cleans it first. |
|
514 | - * |
|
515 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
516 | - * @param EE_Transaction $transaction |
|
517 | - * @return boolean success |
|
518 | - */ |
|
519 | - protected function _save_billing_info_to_attendee($billing_form, $transaction) |
|
520 | - { |
|
521 | - if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
522 | - EE_Error::add_error( |
|
523 | - __("Cannot save billing info because no transaction was specified", "event_espresso"), |
|
524 | - __FILE__, |
|
525 | - __FUNCTION__, |
|
526 | - __LINE__ |
|
527 | - ); |
|
528 | - return false; |
|
529 | - } |
|
530 | - $primary_reg = $transaction->primary_registration(); |
|
531 | - if (! $primary_reg) { |
|
532 | - EE_Error::add_error( |
|
533 | - __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
|
534 | - __FILE__, |
|
535 | - __FUNCTION__, |
|
536 | - __LINE__ |
|
537 | - ); |
|
538 | - return false; |
|
539 | - } |
|
540 | - $attendee = $primary_reg->attendee(); |
|
541 | - if (! $attendee) { |
|
542 | - EE_Error::add_error( |
|
543 | - __( |
|
544 | - "Cannot save billing info because the transaction's primary registration has no attendee!", |
|
545 | - "event_espresso" |
|
546 | - ), |
|
547 | - __FILE__, |
|
548 | - __FUNCTION__, |
|
549 | - __LINE__ |
|
550 | - ); |
|
551 | - return false; |
|
552 | - } |
|
553 | - return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * Gets the payment this IPN is for. Children may often want to |
|
559 | - * override this to inspect the request |
|
560 | - * |
|
561 | - * @param EE_Transaction $transaction |
|
562 | - * @param array $req_data |
|
563 | - * @return EE_Payment |
|
564 | - */ |
|
565 | - protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) |
|
566 | - { |
|
567 | - return $transaction->last_payment(); |
|
568 | - } |
|
569 | - |
|
570 | - |
|
571 | - /** |
|
572 | - * In case generic code cannot provide the payment processor with a specific payment method |
|
573 | - * and transaction, it will try calling this method on each activate payment method. |
|
574 | - * If the payment method is able to identify the request as being for it, it should fetch |
|
575 | - * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot |
|
576 | - * handle the IPN |
|
577 | - * |
|
578 | - * @param array $req_data |
|
579 | - * @return EE_Payment only if this payment method can find the info its needs from $req_data |
|
580 | - * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
|
581 | - * @throws EE_Error |
|
582 | - */ |
|
583 | - public function handle_unclaimed_ipn($req_data = array()) |
|
584 | - { |
|
585 | - throw new EE_Error( |
|
586 | - sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this)) |
|
587 | - ); |
|
588 | - } |
|
589 | - |
|
590 | - |
|
591 | - /** |
|
592 | - * Logic to be accomplished when the payment attempt is complete. |
|
593 | - * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
594 | - * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
595 | - * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
596 | - * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
597 | - * we're dealing with. Returns that last payment (if there is one) |
|
598 | - * |
|
599 | - * @param EE_Transaction $transaction |
|
600 | - * @return EE_Payment |
|
601 | - */ |
|
602 | - public function finalize_payment_for($transaction) |
|
603 | - { |
|
604 | - return $transaction->last_payment(); |
|
605 | - } |
|
606 | - |
|
607 | - |
|
608 | - /** |
|
609 | - * Whether or not this payment method's gateway supports sending refund requests |
|
610 | - * |
|
611 | - * @return boolean |
|
612 | - */ |
|
613 | - public function supports_sending_refunds() |
|
614 | - { |
|
615 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
616 | - return $this->_gateway->supports_sending_refunds(); |
|
617 | - } else { |
|
618 | - return false; |
|
619 | - } |
|
620 | - } |
|
621 | - |
|
622 | - |
|
623 | - /** |
|
624 | - * |
|
625 | - * @param EE_Payment $payment |
|
626 | - * @param array $refund_info |
|
627 | - * @throws EE_Error |
|
628 | - * @return EE_Payment |
|
629 | - */ |
|
630 | - public function process_refund(EE_Payment $payment, $refund_info = array()) |
|
631 | - { |
|
632 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
633 | - return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
634 | - } else { |
|
635 | - throw new EE_Error( |
|
636 | - sprintf( |
|
637 | - __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
638 | - get_class($this) |
|
639 | - ) |
|
640 | - ); |
|
641 | - } |
|
642 | - } |
|
643 | - |
|
644 | - |
|
645 | - /** |
|
646 | - * Returns one the class's constants onsite,offsite, or offline, depending on this |
|
647 | - * payment method's gateway. |
|
648 | - * |
|
649 | - * @return string |
|
650 | - * @throws EE_Error |
|
651 | - */ |
|
652 | - public function payment_occurs() |
|
653 | - { |
|
654 | - if (! $this->_gateway) { |
|
655 | - return EE_PMT_Base::offline; |
|
656 | - } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
657 | - return EE_PMT_Base::onsite; |
|
658 | - } elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
659 | - return EE_PMT_Base::offsite; |
|
660 | - } else { |
|
661 | - throw new EE_Error( |
|
662 | - sprintf( |
|
663 | - __( |
|
664 | - "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", |
|
665 | - "event_espresso" |
|
666 | - ), |
|
667 | - get_class($this) |
|
668 | - ) |
|
669 | - ); |
|
670 | - } |
|
671 | - } |
|
672 | - |
|
673 | - |
|
674 | - /** |
|
675 | - * For adding any html output ab ove the payment overview. |
|
676 | - * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
677 | - * Other gateways may want to override this, such as offline gateways. |
|
678 | - * |
|
679 | - * @param EE_Payment $payment |
|
680 | - * @return string |
|
681 | - */ |
|
682 | - public function payment_overview_content(EE_Payment $payment) |
|
683 | - { |
|
684 | - return EEH_Template::display_template( |
|
685 | - EE_LIBRARIES . 'payment_methods' . DS . 'templates' . DS . 'payment_details_content.template.php', |
|
686 | - array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
|
687 | - true |
|
688 | - ); |
|
689 | - } |
|
690 | - |
|
691 | - |
|
692 | - /** |
|
693 | - * @return array where keys are the help tab name, |
|
694 | - * values are: array { |
|
695 | - * @type string $title i18n name for the help tab |
|
696 | - * @type string $filename name of the file located in ./help_tabs/ (ie, in a folder next to this file) |
|
697 | - * @type array $template_args any arguments you want passed to the template file while rendering. |
|
698 | - * Keys will be variable names and values with be their values. |
|
699 | - */ |
|
700 | - public function help_tabs_config() |
|
701 | - { |
|
702 | - return array(); |
|
703 | - } |
|
704 | - |
|
705 | - |
|
706 | - /** |
|
707 | - * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into |
|
708 | - * the payment method's table's PMT_type column) |
|
709 | - * |
|
710 | - * @return string |
|
711 | - */ |
|
712 | - public function system_name() |
|
713 | - { |
|
714 | - $classname = get_class($this); |
|
715 | - return str_replace("EE_PMT_", '', $classname); |
|
716 | - } |
|
717 | - |
|
718 | - |
|
719 | - /** |
|
720 | - * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding |
|
721 | - * this method. |
|
722 | - * @return string |
|
723 | - */ |
|
724 | - public function defaultFrontendName() |
|
725 | - { |
|
726 | - return $this->pretty_name(); |
|
727 | - } |
|
728 | - |
|
729 | - |
|
730 | - /** |
|
731 | - * A pretty i18n version of the PMT name |
|
732 | - * |
|
733 | - * @return string |
|
734 | - */ |
|
735 | - public function pretty_name() |
|
736 | - { |
|
737 | - return $this->_pretty_name; |
|
738 | - } |
|
739 | - |
|
740 | - |
|
741 | - /** |
|
742 | - * Gets the default absolute URL to the payment method type's button |
|
743 | - * |
|
744 | - * @return string |
|
745 | - */ |
|
746 | - public function default_button_url() |
|
747 | - { |
|
748 | - return $this->_default_button_url; |
|
749 | - } |
|
750 | - |
|
751 | - |
|
752 | - /** |
|
753 | - * Gets the gateway used by this payment method (if any) |
|
754 | - * |
|
755 | - * @return EE_Gateway |
|
756 | - */ |
|
757 | - public function get_gateway() |
|
758 | - { |
|
759 | - return $this->_gateway; |
|
760 | - } |
|
761 | - |
|
762 | - |
|
763 | - /** |
|
764 | - * @return string html for the link to a help tab |
|
765 | - */ |
|
766 | - public function get_help_tab_link() |
|
767 | - { |
|
768 | - return EEH_Template::get_help_tab_link( |
|
769 | - $this->get_help_tab_name(), |
|
770 | - 'espresso_payment_settings', |
|
771 | - 'default' |
|
772 | - ); |
|
773 | - } |
|
774 | - |
|
775 | - |
|
776 | - /** |
|
777 | - * Returns the name of the help tab for this PMT |
|
778 | - * |
|
779 | - * @return string |
|
780 | - */ |
|
781 | - public function get_help_tab_name() |
|
782 | - { |
|
783 | - return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
784 | - } |
|
785 | - |
|
786 | - /** |
|
787 | - * The name of the wp capability that should be associated with the usage of |
|
788 | - * this PMT by an admin |
|
789 | - * |
|
790 | - * @return string |
|
791 | - */ |
|
792 | - public function cap_name() |
|
793 | - { |
|
794 | - return 'ee_payment_method_' . strtolower($this->system_name()); |
|
795 | - } |
|
796 | - |
|
797 | - /** |
|
798 | - * Called by client code to tell the gateway that if it wants to change |
|
799 | - * the transaction or line items or registrations related to teh payment it already |
|
800 | - * processed (we think, but possibly not) that now's the time to do it. |
|
801 | - * It is expected that gateways will store any info they need for this on the PAY_details, |
|
802 | - * or maybe an extra meta value |
|
803 | - * |
|
804 | - * @param EE_Payment $payment |
|
805 | - * @return void |
|
806 | - */ |
|
807 | - public function update_txn_based_on_payment($payment) |
|
808 | - { |
|
809 | - if ($this->_gateway instanceof EE_Gateway) { |
|
810 | - $this->_gateway->update_txn_based_on_payment($payment); |
|
811 | - } |
|
812 | - } |
|
813 | - |
|
814 | - /** |
|
815 | - * Returns a string of HTML describing this payment method type for an admin, |
|
816 | - * primarily intended for them to read before activating it. |
|
817 | - * The easiest way to set this is to create a folder 'templates' alongside |
|
818 | - * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php". |
|
819 | - * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php", |
|
820 | - * then you'd create a file named "templates" in the same folder as it, and name the file |
|
821 | - * "foo_bar_intro.template.php", and its content will be returned by this method |
|
822 | - * |
|
823 | - * @return string |
|
824 | - */ |
|
825 | - public function introductory_html() |
|
826 | - { |
|
827 | - return EEH_Template::locate_template( |
|
828 | - $this->file_folder() . 'templates' . DS . strtolower($this->system_name()) . '_intro.template.php', |
|
829 | - array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
|
830 | - ); |
|
831 | - } |
|
24 | + const onsite = 'on-site'; |
|
25 | + const offsite = 'off-site'; |
|
26 | + const offline = 'off-line'; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var EE_Payment_Method |
|
30 | + */ |
|
31 | + protected $_pm_instance = null; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var boolean |
|
35 | + */ |
|
36 | + protected $_requires_https = false; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var boolean |
|
40 | + */ |
|
41 | + protected $_has_billing_form; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var EE_Gateway |
|
45 | + */ |
|
46 | + protected $_gateway = null; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var EE_Payment_Method_Form |
|
50 | + */ |
|
51 | + protected $_settings_form = null; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var EE_Form_Section_Proper |
|
55 | + */ |
|
56 | + protected $_billing_form = null; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var boolean |
|
60 | + */ |
|
61 | + protected $_cache_billing_form = true; |
|
62 | + |
|
63 | + /** |
|
64 | + * String of the absolute path to the folder containing this file, with a trailing slash. |
|
65 | + * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/' |
|
66 | + * |
|
67 | + * @var string |
|
68 | + */ |
|
69 | + protected $_file_folder = null; |
|
70 | + |
|
71 | + /** |
|
72 | + * String to the absolute URL to this file (useful for getting its web-accessible resources |
|
73 | + * like images, js, or css) |
|
74 | + * |
|
75 | + * @var string |
|
76 | + */ |
|
77 | + protected $_file_url = null; |
|
78 | + |
|
79 | + /** |
|
80 | + * Pretty name for the payment method |
|
81 | + * |
|
82 | + * @var string |
|
83 | + */ |
|
84 | + protected $_pretty_name = null; |
|
85 | + |
|
86 | + /** |
|
87 | + * |
|
88 | + * @var string |
|
89 | + */ |
|
90 | + protected $_default_button_url = null; |
|
91 | + |
|
92 | + /** |
|
93 | + * |
|
94 | + * @var string |
|
95 | + */ |
|
96 | + protected $_default_description = null; |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * |
|
101 | + * @param EE_Payment_Method $pm_instance |
|
102 | + * @throws EE_Error |
|
103 | + * @return EE_PMT_Base |
|
104 | + */ |
|
105 | + public function __construct($pm_instance = null) |
|
106 | + { |
|
107 | + if ($pm_instance instanceof EE_Payment_Method) { |
|
108 | + $this->set_instance($pm_instance); |
|
109 | + } |
|
110 | + if ($this->_gateway) { |
|
111 | + $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
112 | + $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
113 | + $this->_gateway->set_template_helper(new EEH_Template()); |
|
114 | + $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
115 | + $this->_gateway->set_money_helper(new EEH_Money()); |
|
116 | + $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
117 | + $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
118 | + do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
|
119 | + } |
|
120 | + if (! isset($this->_has_billing_form)) { |
|
121 | + // by default, On Site gateways have a billing form |
|
122 | + if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
123 | + $this->set_has_billing_form(true); |
|
124 | + } else { |
|
125 | + $this->set_has_billing_form(false); |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + if (! $this->_pretty_name) { |
|
130 | + throw new EE_Error( |
|
131 | + sprintf( |
|
132 | + __( |
|
133 | + "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", |
|
134 | + "event_espresso" |
|
135 | + ) |
|
136 | + ) |
|
137 | + ); |
|
138 | + } |
|
139 | + // if the child didn't specify a default button, use the credit card one |
|
140 | + if ($this->_default_button_url === null) { |
|
141 | + $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png'; |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @param boolean $has_billing_form |
|
148 | + */ |
|
149 | + public function set_has_billing_form($has_billing_form) |
|
150 | + { |
|
151 | + $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * sets the file_folder property |
|
157 | + */ |
|
158 | + protected function _set_file_folder() |
|
159 | + { |
|
160 | + $reflector = new ReflectionClass(get_class($this)); |
|
161 | + $fn = $reflector->getFileName(); |
|
162 | + $this->_file_folder = dirname($fn) . DS; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * sets the file URL with a trailing slash for this PMT |
|
168 | + */ |
|
169 | + protected function _set_file_url() |
|
170 | + { |
|
171 | + $plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR); |
|
172 | + $file_folder_fixed = str_replace('\\', DS, $this->file_folder()); |
|
173 | + $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
174 | + $this->_file_url = $file_path; |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * Gets the default description on all payment methods of this type |
|
179 | + * |
|
180 | + * @return string |
|
181 | + */ |
|
182 | + public function default_description() |
|
183 | + { |
|
184 | + return $this->_default_description; |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * Returns the folder containing the PMT child class, with a trailing slash |
|
190 | + * |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public function file_folder() |
|
194 | + { |
|
195 | + if (! $this->_file_folder) { |
|
196 | + $this->_set_file_folder(); |
|
197 | + } |
|
198 | + return $this->_file_folder; |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * @return string |
|
204 | + */ |
|
205 | + public function file_url() |
|
206 | + { |
|
207 | + if (! $this->_file_url) { |
|
208 | + $this->_set_file_url(); |
|
209 | + } |
|
210 | + return $this->_file_url; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * Sets the payment method instance this payment method type is for. |
|
216 | + * Its important teh payment method instance is set before |
|
217 | + * |
|
218 | + * @param EE_Payment_Method $payment_method_instance |
|
219 | + */ |
|
220 | + public function set_instance($payment_method_instance) |
|
221 | + { |
|
222 | + $this->_pm_instance = $payment_method_instance; |
|
223 | + // if they have already requested the settings form, make sure its |
|
224 | + // data matches this model object |
|
225 | + if ($this->_settings_form) { |
|
226 | + $this->settings_form()->populate_model_obj($payment_method_instance); |
|
227 | + } |
|
228 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
229 | + $this->_gateway->set_settings($payment_method_instance->settings_array()); |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + /** |
|
235 | + * Gets teh form for displaying to admins where they setup the payment method |
|
236 | + * |
|
237 | + * @return EE_Payment_Method_Form |
|
238 | + */ |
|
239 | + public function settings_form() |
|
240 | + { |
|
241 | + if (! $this->_settings_form) { |
|
242 | + $this->_settings_form = $this->generate_new_settings_form(); |
|
243 | + $this->_settings_form->set_payment_method_type($this); |
|
244 | + // if we have already assigned a model object to this pmt, make |
|
245 | + // sure its reflected in teh form we just generated |
|
246 | + if ($this->_pm_instance) { |
|
247 | + $this->_settings_form->populate_model_obj($this->_pm_instance); |
|
248 | + } |
|
249 | + } |
|
250 | + return $this->_settings_form; |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + /** |
|
255 | + * Gets the form for all the settings related to this payment method type |
|
256 | + * |
|
257 | + * @return EE_Payment_Method_Form |
|
258 | + */ |
|
259 | + abstract public function generate_new_settings_form(); |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * Sets the form for settings. This may be useful if we have already received |
|
264 | + * a form submission and have form data it in, and want to use it anytime we're showing |
|
265 | + * this payment method type's settings form later in the request |
|
266 | + * |
|
267 | + * @param EE_Payment_Method_Form $form |
|
268 | + */ |
|
269 | + public function set_settings_form($form) |
|
270 | + { |
|
271 | + $this->_settings_form = $form; |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * @return boolean |
|
277 | + */ |
|
278 | + public function has_billing_form() |
|
279 | + { |
|
280 | + return $this->_has_billing_form; |
|
281 | + } |
|
282 | + |
|
283 | + |
|
284 | + /** |
|
285 | + * Gets the form for displaying to attendees where they can enter their billing info |
|
286 | + * which will be sent to teh gateway (can be null) |
|
287 | + * |
|
288 | + * @param \EE_Transaction $transaction |
|
289 | + * @param array $extra_args |
|
290 | + * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
|
291 | + */ |
|
292 | + public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
|
293 | + { |
|
294 | + // has billing form already been regenerated ? or overwrite cache? |
|
295 | + if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
296 | + $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
297 | + } |
|
298 | + // if we know who the attendee is, and this is a billing form |
|
299 | + // that uses attendee info, populate it |
|
300 | + if (apply_filters( |
|
301 | + 'FHEE__populate_billing_form_fields_from_attendee', |
|
302 | + ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
303 | + && $transaction instanceof EE_Transaction |
|
304 | + && $transaction->primary_registration() instanceof EE_Registration |
|
305 | + && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
306 | + ), |
|
307 | + $this->_billing_form, |
|
308 | + $transaction |
|
309 | + )) { |
|
310 | + $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
311 | + } |
|
312 | + return $this->_billing_form; |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * Creates the billing form for this payment method type |
|
318 | + * |
|
319 | + * @param \EE_Transaction $transaction |
|
320 | + * @return \EE_Billing_Info_Form |
|
321 | + */ |
|
322 | + abstract public function generate_new_billing_form(EE_Transaction $transaction = null); |
|
323 | + |
|
324 | + |
|
325 | + /** |
|
326 | + * apply_billing_form_debug_settings |
|
327 | + * applies debug data to the form |
|
328 | + * |
|
329 | + * @param \EE_Billing_Info_Form $billing_form |
|
330 | + * @return \EE_Billing_Info_Form |
|
331 | + */ |
|
332 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
333 | + { |
|
334 | + return $billing_form; |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * Sets the billing form for this payment method type. You may want to use this |
|
340 | + * if you have form |
|
341 | + * |
|
342 | + * @param EE_Payment_Method $form |
|
343 | + */ |
|
344 | + public function set_billing_form($form) |
|
345 | + { |
|
346 | + $this->_billing_form = $form; |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * Returns whether or not this payment method requires HTTPS to be used |
|
352 | + * |
|
353 | + * @return boolean |
|
354 | + */ |
|
355 | + public function requires_https() |
|
356 | + { |
|
357 | + return $this->_requires_https; |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * |
|
363 | + * @param EE_Transaction $transaction |
|
364 | + * @param float $amount |
|
365 | + * @param EE_Billing_Info_Form $billing_info |
|
366 | + * @param string $return_url |
|
367 | + * @param string $fail_url |
|
368 | + * @param string $method |
|
369 | + * @param bool $by_admin |
|
370 | + * @return EE_Payment |
|
371 | + * @throws EE_Error |
|
372 | + */ |
|
373 | + public function process_payment( |
|
374 | + EE_Transaction $transaction, |
|
375 | + $amount = null, |
|
376 | + $billing_info = null, |
|
377 | + $return_url = null, |
|
378 | + $fail_url = '', |
|
379 | + $method = 'CART', |
|
380 | + $by_admin = false |
|
381 | + ) { |
|
382 | + // @todo: add surcharge for the payment method, if any |
|
383 | + if ($this->_gateway) { |
|
384 | + // there is a gateway, so we're going to make a payment object |
|
385 | + // but wait! do they already have a payment in progress that we thought was failed? |
|
386 | + $duplicate_properties = array( |
|
387 | + 'STS_ID' => EEM_Payment::status_id_failed, |
|
388 | + 'TXN_ID' => $transaction->ID(), |
|
389 | + 'PMD_ID' => $this->_pm_instance->ID(), |
|
390 | + 'PAY_source' => $method, |
|
391 | + 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
|
392 | + 'PAY_gateway_response' => null, |
|
393 | + ); |
|
394 | + $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
395 | + // if we didn't already have a payment in progress for the same thing, |
|
396 | + // then we actually want to make a new payment |
|
397 | + if (! $payment instanceof EE_Payment) { |
|
398 | + $payment = EE_Payment::new_instance( |
|
399 | + array_merge( |
|
400 | + $duplicate_properties, |
|
401 | + array( |
|
402 | + 'PAY_timestamp' => time(), |
|
403 | + 'PAY_txn_id_chq_nmbr' => null, |
|
404 | + 'PAY_po_number' => null, |
|
405 | + 'PAY_extra_accntng' => null, |
|
406 | + 'PAY_details' => null, |
|
407 | + ) |
|
408 | + ) |
|
409 | + ); |
|
410 | + } |
|
411 | + // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
|
412 | + $payment->save(); |
|
413 | + $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
414 | + |
|
415 | + // Offsite Gateway |
|
416 | + if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
417 | + $payment = $this->_gateway->set_redirection_info( |
|
418 | + $payment, |
|
419 | + $billing_values, |
|
420 | + $return_url, |
|
421 | + EE_Config::instance()->core->txn_page_url( |
|
422 | + array( |
|
423 | + 'e_reg_url_link' => $transaction->primary_registration()->reg_url_link(), |
|
424 | + 'ee_payment_method' => $this->_pm_instance->slug(), |
|
425 | + ) |
|
426 | + ), |
|
427 | + $fail_url |
|
428 | + ); |
|
429 | + $payment->save(); |
|
430 | + // Onsite Gateway |
|
431 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
432 | + $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
433 | + $payment->save(); |
|
434 | + } else { |
|
435 | + throw new EE_Error( |
|
436 | + sprintf( |
|
437 | + __( |
|
438 | + 'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', |
|
439 | + 'event_espresso' |
|
440 | + ), |
|
441 | + get_class($this), |
|
442 | + gettype($this->_gateway) |
|
443 | + ) |
|
444 | + ); |
|
445 | + } |
|
446 | + } else { |
|
447 | + // no gateway provided |
|
448 | + // there is no payment. Must be an offline gateway |
|
449 | + // create a payment object anyways, but dont save it |
|
450 | + $payment = EE_Payment::new_instance( |
|
451 | + array( |
|
452 | + 'STS_ID' => EEM_Payment::status_id_pending, |
|
453 | + 'TXN_ID' => $transaction->ID(), |
|
454 | + 'PMD_ID' => $transaction->payment_method_ID(), |
|
455 | + 'PAY_amount' => 0.00, |
|
456 | + 'PAY_timestamp' => time(), |
|
457 | + ) |
|
458 | + ); |
|
459 | + } |
|
460 | + |
|
461 | + // if there is billing info, clean it and save it now |
|
462 | + if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
463 | + $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
464 | + } |
|
465 | + |
|
466 | + return $payment; |
|
467 | + } |
|
468 | + |
|
469 | + /** |
|
470 | + * Gets the values we want to pass onto the gateway. Normally these |
|
471 | + * are just the 'pretty' values, but there may be times the data may need |
|
472 | + * a little massaging. Proper subsections will become arrays of inputs |
|
473 | + * |
|
474 | + * @param EE_Billing_Info_Form $billing_form |
|
475 | + * @return array |
|
476 | + */ |
|
477 | + protected function _get_billing_values_from_form($billing_form) |
|
478 | + { |
|
479 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
480 | + return $billing_form->input_pretty_values(true); |
|
481 | + } else { |
|
482 | + return null; |
|
483 | + } |
|
484 | + } |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | + * Handles an instant payment notification when the transaction is known (by default). |
|
489 | + * |
|
490 | + * @param array $req_data |
|
491 | + * @param EE_Transaction $transaction |
|
492 | + * @return EE_Payment |
|
493 | + * @throws EE_Error |
|
494 | + */ |
|
495 | + public function handle_ipn($req_data, $transaction) |
|
496 | + { |
|
497 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
498 | + if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
499 | + throw new EE_Error( |
|
500 | + sprintf( |
|
501 | + __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
|
502 | + print_r($this->_gateway, true) |
|
503 | + ) |
|
504 | + ); |
|
505 | + } |
|
506 | + $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
507 | + return $payment; |
|
508 | + } |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * Saves the billing info onto the attendee of the primary registrant on this transaction, and |
|
513 | + * cleans it first. |
|
514 | + * |
|
515 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
516 | + * @param EE_Transaction $transaction |
|
517 | + * @return boolean success |
|
518 | + */ |
|
519 | + protected function _save_billing_info_to_attendee($billing_form, $transaction) |
|
520 | + { |
|
521 | + if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
522 | + EE_Error::add_error( |
|
523 | + __("Cannot save billing info because no transaction was specified", "event_espresso"), |
|
524 | + __FILE__, |
|
525 | + __FUNCTION__, |
|
526 | + __LINE__ |
|
527 | + ); |
|
528 | + return false; |
|
529 | + } |
|
530 | + $primary_reg = $transaction->primary_registration(); |
|
531 | + if (! $primary_reg) { |
|
532 | + EE_Error::add_error( |
|
533 | + __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
|
534 | + __FILE__, |
|
535 | + __FUNCTION__, |
|
536 | + __LINE__ |
|
537 | + ); |
|
538 | + return false; |
|
539 | + } |
|
540 | + $attendee = $primary_reg->attendee(); |
|
541 | + if (! $attendee) { |
|
542 | + EE_Error::add_error( |
|
543 | + __( |
|
544 | + "Cannot save billing info because the transaction's primary registration has no attendee!", |
|
545 | + "event_espresso" |
|
546 | + ), |
|
547 | + __FILE__, |
|
548 | + __FUNCTION__, |
|
549 | + __LINE__ |
|
550 | + ); |
|
551 | + return false; |
|
552 | + } |
|
553 | + return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * Gets the payment this IPN is for. Children may often want to |
|
559 | + * override this to inspect the request |
|
560 | + * |
|
561 | + * @param EE_Transaction $transaction |
|
562 | + * @param array $req_data |
|
563 | + * @return EE_Payment |
|
564 | + */ |
|
565 | + protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) |
|
566 | + { |
|
567 | + return $transaction->last_payment(); |
|
568 | + } |
|
569 | + |
|
570 | + |
|
571 | + /** |
|
572 | + * In case generic code cannot provide the payment processor with a specific payment method |
|
573 | + * and transaction, it will try calling this method on each activate payment method. |
|
574 | + * If the payment method is able to identify the request as being for it, it should fetch |
|
575 | + * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot |
|
576 | + * handle the IPN |
|
577 | + * |
|
578 | + * @param array $req_data |
|
579 | + * @return EE_Payment only if this payment method can find the info its needs from $req_data |
|
580 | + * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
|
581 | + * @throws EE_Error |
|
582 | + */ |
|
583 | + public function handle_unclaimed_ipn($req_data = array()) |
|
584 | + { |
|
585 | + throw new EE_Error( |
|
586 | + sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this)) |
|
587 | + ); |
|
588 | + } |
|
589 | + |
|
590 | + |
|
591 | + /** |
|
592 | + * Logic to be accomplished when the payment attempt is complete. |
|
593 | + * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
594 | + * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
595 | + * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
596 | + * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
597 | + * we're dealing with. Returns that last payment (if there is one) |
|
598 | + * |
|
599 | + * @param EE_Transaction $transaction |
|
600 | + * @return EE_Payment |
|
601 | + */ |
|
602 | + public function finalize_payment_for($transaction) |
|
603 | + { |
|
604 | + return $transaction->last_payment(); |
|
605 | + } |
|
606 | + |
|
607 | + |
|
608 | + /** |
|
609 | + * Whether or not this payment method's gateway supports sending refund requests |
|
610 | + * |
|
611 | + * @return boolean |
|
612 | + */ |
|
613 | + public function supports_sending_refunds() |
|
614 | + { |
|
615 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
616 | + return $this->_gateway->supports_sending_refunds(); |
|
617 | + } else { |
|
618 | + return false; |
|
619 | + } |
|
620 | + } |
|
621 | + |
|
622 | + |
|
623 | + /** |
|
624 | + * |
|
625 | + * @param EE_Payment $payment |
|
626 | + * @param array $refund_info |
|
627 | + * @throws EE_Error |
|
628 | + * @return EE_Payment |
|
629 | + */ |
|
630 | + public function process_refund(EE_Payment $payment, $refund_info = array()) |
|
631 | + { |
|
632 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
633 | + return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
634 | + } else { |
|
635 | + throw new EE_Error( |
|
636 | + sprintf( |
|
637 | + __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
638 | + get_class($this) |
|
639 | + ) |
|
640 | + ); |
|
641 | + } |
|
642 | + } |
|
643 | + |
|
644 | + |
|
645 | + /** |
|
646 | + * Returns one the class's constants onsite,offsite, or offline, depending on this |
|
647 | + * payment method's gateway. |
|
648 | + * |
|
649 | + * @return string |
|
650 | + * @throws EE_Error |
|
651 | + */ |
|
652 | + public function payment_occurs() |
|
653 | + { |
|
654 | + if (! $this->_gateway) { |
|
655 | + return EE_PMT_Base::offline; |
|
656 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
657 | + return EE_PMT_Base::onsite; |
|
658 | + } elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
659 | + return EE_PMT_Base::offsite; |
|
660 | + } else { |
|
661 | + throw new EE_Error( |
|
662 | + sprintf( |
|
663 | + __( |
|
664 | + "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", |
|
665 | + "event_espresso" |
|
666 | + ), |
|
667 | + get_class($this) |
|
668 | + ) |
|
669 | + ); |
|
670 | + } |
|
671 | + } |
|
672 | + |
|
673 | + |
|
674 | + /** |
|
675 | + * For adding any html output ab ove the payment overview. |
|
676 | + * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
677 | + * Other gateways may want to override this, such as offline gateways. |
|
678 | + * |
|
679 | + * @param EE_Payment $payment |
|
680 | + * @return string |
|
681 | + */ |
|
682 | + public function payment_overview_content(EE_Payment $payment) |
|
683 | + { |
|
684 | + return EEH_Template::display_template( |
|
685 | + EE_LIBRARIES . 'payment_methods' . DS . 'templates' . DS . 'payment_details_content.template.php', |
|
686 | + array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
|
687 | + true |
|
688 | + ); |
|
689 | + } |
|
690 | + |
|
691 | + |
|
692 | + /** |
|
693 | + * @return array where keys are the help tab name, |
|
694 | + * values are: array { |
|
695 | + * @type string $title i18n name for the help tab |
|
696 | + * @type string $filename name of the file located in ./help_tabs/ (ie, in a folder next to this file) |
|
697 | + * @type array $template_args any arguments you want passed to the template file while rendering. |
|
698 | + * Keys will be variable names and values with be their values. |
|
699 | + */ |
|
700 | + public function help_tabs_config() |
|
701 | + { |
|
702 | + return array(); |
|
703 | + } |
|
704 | + |
|
705 | + |
|
706 | + /** |
|
707 | + * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into |
|
708 | + * the payment method's table's PMT_type column) |
|
709 | + * |
|
710 | + * @return string |
|
711 | + */ |
|
712 | + public function system_name() |
|
713 | + { |
|
714 | + $classname = get_class($this); |
|
715 | + return str_replace("EE_PMT_", '', $classname); |
|
716 | + } |
|
717 | + |
|
718 | + |
|
719 | + /** |
|
720 | + * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding |
|
721 | + * this method. |
|
722 | + * @return string |
|
723 | + */ |
|
724 | + public function defaultFrontendName() |
|
725 | + { |
|
726 | + return $this->pretty_name(); |
|
727 | + } |
|
728 | + |
|
729 | + |
|
730 | + /** |
|
731 | + * A pretty i18n version of the PMT name |
|
732 | + * |
|
733 | + * @return string |
|
734 | + */ |
|
735 | + public function pretty_name() |
|
736 | + { |
|
737 | + return $this->_pretty_name; |
|
738 | + } |
|
739 | + |
|
740 | + |
|
741 | + /** |
|
742 | + * Gets the default absolute URL to the payment method type's button |
|
743 | + * |
|
744 | + * @return string |
|
745 | + */ |
|
746 | + public function default_button_url() |
|
747 | + { |
|
748 | + return $this->_default_button_url; |
|
749 | + } |
|
750 | + |
|
751 | + |
|
752 | + /** |
|
753 | + * Gets the gateway used by this payment method (if any) |
|
754 | + * |
|
755 | + * @return EE_Gateway |
|
756 | + */ |
|
757 | + public function get_gateway() |
|
758 | + { |
|
759 | + return $this->_gateway; |
|
760 | + } |
|
761 | + |
|
762 | + |
|
763 | + /** |
|
764 | + * @return string html for the link to a help tab |
|
765 | + */ |
|
766 | + public function get_help_tab_link() |
|
767 | + { |
|
768 | + return EEH_Template::get_help_tab_link( |
|
769 | + $this->get_help_tab_name(), |
|
770 | + 'espresso_payment_settings', |
|
771 | + 'default' |
|
772 | + ); |
|
773 | + } |
|
774 | + |
|
775 | + |
|
776 | + /** |
|
777 | + * Returns the name of the help tab for this PMT |
|
778 | + * |
|
779 | + * @return string |
|
780 | + */ |
|
781 | + public function get_help_tab_name() |
|
782 | + { |
|
783 | + return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
784 | + } |
|
785 | + |
|
786 | + /** |
|
787 | + * The name of the wp capability that should be associated with the usage of |
|
788 | + * this PMT by an admin |
|
789 | + * |
|
790 | + * @return string |
|
791 | + */ |
|
792 | + public function cap_name() |
|
793 | + { |
|
794 | + return 'ee_payment_method_' . strtolower($this->system_name()); |
|
795 | + } |
|
796 | + |
|
797 | + /** |
|
798 | + * Called by client code to tell the gateway that if it wants to change |
|
799 | + * the transaction or line items or registrations related to teh payment it already |
|
800 | + * processed (we think, but possibly not) that now's the time to do it. |
|
801 | + * It is expected that gateways will store any info they need for this on the PAY_details, |
|
802 | + * or maybe an extra meta value |
|
803 | + * |
|
804 | + * @param EE_Payment $payment |
|
805 | + * @return void |
|
806 | + */ |
|
807 | + public function update_txn_based_on_payment($payment) |
|
808 | + { |
|
809 | + if ($this->_gateway instanceof EE_Gateway) { |
|
810 | + $this->_gateway->update_txn_based_on_payment($payment); |
|
811 | + } |
|
812 | + } |
|
813 | + |
|
814 | + /** |
|
815 | + * Returns a string of HTML describing this payment method type for an admin, |
|
816 | + * primarily intended for them to read before activating it. |
|
817 | + * The easiest way to set this is to create a folder 'templates' alongside |
|
818 | + * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php". |
|
819 | + * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php", |
|
820 | + * then you'd create a file named "templates" in the same folder as it, and name the file |
|
821 | + * "foo_bar_intro.template.php", and its content will be returned by this method |
|
822 | + * |
|
823 | + * @return string |
|
824 | + */ |
|
825 | + public function introductory_html() |
|
826 | + { |
|
827 | + return EEH_Template::locate_template( |
|
828 | + $this->file_folder() . 'templates' . DS . strtolower($this->system_name()) . '_intro.template.php', |
|
829 | + array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
|
830 | + ); |
|
831 | + } |
|
832 | 832 | } |
@@ -15,36 +15,36 @@ |
||
15 | 15 | abstract class EE_Onsite_Gateway extends EE_Gateway |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @return EE_Onsite_Gateway |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - $this->_supports_sending_refunds = true; |
|
24 | - parent::__construct(); |
|
25 | - } |
|
18 | + /** |
|
19 | + * @return EE_Onsite_Gateway |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + $this->_supports_sending_refunds = true; |
|
24 | + parent::__construct(); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Asks the gateway to do whatever it does to process the payment. Onsite gateways will |
|
29 | - * usually send a request directly to the payment provider and update the payment's status based on that; |
|
30 | - * whereas offsite gateways will usually just update the payment with the URL and query parameters to use |
|
31 | - * for sending the request via http_remote_request(). Saving the payment from within this method is unnecessary, |
|
32 | - * as it is the responsibility of client code to save it. |
|
33 | - * |
|
34 | - * @param EEI_Payment $payment |
|
35 | - * @param array $billing_info { |
|
36 | - * @type $first_name string |
|
37 | - * @type $last_name string |
|
38 | - * @type $email string |
|
39 | - * @type $address string |
|
40 | - * @type $address2 string |
|
41 | - * @type $city string |
|
42 | - * @type $state string name of the state (NOT int) |
|
43 | - * @type $country string 2-character ISO code see http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 |
|
44 | - * @type $zip string |
|
45 | - * @type $phone string |
|
46 | - * } unless a child class specifies these array keys are NOT present |
|
47 | - * @return EE_Payment updated |
|
48 | - */ |
|
49 | - abstract public function do_direct_payment($payment, $billing_info = null); |
|
27 | + /** |
|
28 | + * Asks the gateway to do whatever it does to process the payment. Onsite gateways will |
|
29 | + * usually send a request directly to the payment provider and update the payment's status based on that; |
|
30 | + * whereas offsite gateways will usually just update the payment with the URL and query parameters to use |
|
31 | + * for sending the request via http_remote_request(). Saving the payment from within this method is unnecessary, |
|
32 | + * as it is the responsibility of client code to save it. |
|
33 | + * |
|
34 | + * @param EEI_Payment $payment |
|
35 | + * @param array $billing_info { |
|
36 | + * @type $first_name string |
|
37 | + * @type $last_name string |
|
38 | + * @type $email string |
|
39 | + * @type $address string |
|
40 | + * @type $address2 string |
|
41 | + * @type $city string |
|
42 | + * @type $state string name of the state (NOT int) |
|
43 | + * @type $country string 2-character ISO code see http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 |
|
44 | + * @type $zip string |
|
45 | + * @type $phone string |
|
46 | + * } unless a child class specifies these array keys are NOT present |
|
47 | + * @return EE_Payment updated |
|
48 | + */ |
|
49 | + abstract public function do_direct_payment($payment, $billing_info = null); |
|
50 | 50 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('No direct script access allowed'); |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * payment_details_content |
@@ -10,5 +10,5 @@ discard block |
||
10 | 10 | */ |
11 | 11 | $gateway_response = $payment->gateway_response(); |
12 | 12 | if (! empty($gateway_response)) { |
13 | - echo '<span class="error payment-problem">' . $gateway_response . '</span>'; |
|
13 | + echo '<span class="error payment-problem">' . $gateway_response . '</span>'; |
|
14 | 14 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | } |
5 | 5 | /** |
@@ -9,6 +9,6 @@ discard block |
||
9 | 9 | * @var EE_Payment_Method $payment_method |
10 | 10 | */ |
11 | 11 | $gateway_response = $payment->gateway_response(); |
12 | -if (! empty($gateway_response)) { |
|
13 | - echo '<span class="error payment-problem">' . $gateway_response . '</span>'; |
|
12 | +if ( ! empty($gateway_response)) { |
|
13 | + echo '<span class="error payment-problem">'.$gateway_response.'</span>'; |
|
14 | 14 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $html = ''; |
85 | 85 | // set some default options and merge with incoming |
86 | 86 | $default_options = array( |
87 | - 'show_desc' => true, // true false |
|
87 | + 'show_desc' => true, // true false |
|
88 | 88 | 'odd' => false, |
89 | 89 | ); |
90 | 90 | $options = array_merge($default_options, (array) $options); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $text = esc_html__('Sub-Total', 'event_espresso'); |
119 | 119 | if ($line_item->OBJ_type() === 'Event') { |
120 | 120 | $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
121 | - if (! isset($this->_events[ $options['event_id'] ])) { |
|
121 | + if ( ! isset($this->_events[$options['event_id']])) { |
|
122 | 122 | $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
123 | 123 | // if event has default reg status of Not Approved, then don't display info on it |
124 | 124 | if ($event instanceof EE_Event |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | // unless there are registrations for it that are returning to pay |
129 | 129 | if (isset($options['registrations']) && is_array($options['registrations'])) { |
130 | 130 | foreach ($options['registrations'] as $registration) { |
131 | - if (! $registration instanceof EE_Registration) { |
|
131 | + if ( ! $registration instanceof EE_Registration) { |
|
132 | 132 | continue; |
133 | 133 | } |
134 | 134 | $display_event = $registration->event_ID() === $options['event_id'] |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | : $display_event; |
138 | 138 | } |
139 | 139 | } |
140 | - if (! $display_event) { |
|
140 | + if ( ! $display_event) { |
|
141 | 141 | return ''; |
142 | 142 | } |
143 | 143 | } |
144 | - $this->_events[ $options['event_id'] ] = 0; |
|
144 | + $this->_events[$options['event_id']] = 0; |
|
145 | 145 | $html .= $this->_event_row($line_item); |
146 | 146 | $text = esc_html__('Event Sub-Total', 'event_espresso'); |
147 | 147 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | // recursively feed children back into this method |
153 | 153 | $html .= $this->display_line_item($child_line_item, $options, $line_item); |
154 | 154 | } |
155 | - $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0; |
|
155 | + $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
156 | 156 | $sub_total += $event_sub_total; |
157 | 157 | if (( |
158 | 158 | // event subtotals |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
261 | 261 | ( |
262 | 262 | $options['show_desc'] |
263 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
263 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
264 | 264 | : '' |
265 | 265 | ), |
266 | 266 | $line_item, |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $this->_total_items += $line_item->quantity(); |
281 | 281 | // determine total for line item |
282 | 282 | $total = $line_item->total(); |
283 | - $this->_events[ $options['event_id'] ] += $total; |
|
283 | + $this->_events[$options['event_id']] += $total; |
|
284 | 284 | // total td |
285 | 285 | $html .= EEH_HTML::td( |
286 | 286 | EEH_Template::format_currency($total, false, false), |
@@ -307,18 +307,18 @@ discard block |
||
307 | 307 | // start of row |
308 | 308 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
309 | 309 | $html = EEH_HTML::tr('', '', $row_class); |
310 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
310 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : ''; |
|
311 | 311 | // name && desc |
312 | 312 | $name_and_desc = apply_filters( |
313 | 313 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
314 | - $obj_name . $line_item->name(), |
|
314 | + $obj_name.$line_item->name(), |
|
315 | 315 | $line_item |
316 | 316 | ); |
317 | 317 | $name_and_desc .= apply_filters( |
318 | 318 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
319 | 319 | ( |
320 | 320 | $options['show_desc'] |
321 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
321 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
322 | 322 | : '' |
323 | 323 | ), |
324 | 324 | $line_item, |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
330 | 330 | // price td |
331 | 331 | if ($line_item->is_percent()) { |
332 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
332 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght'); |
|
333 | 333 | } else { |
334 | 334 | $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
335 | 335 | } |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
338 | 338 | // $total = $line_item->total() * $line_item->quantity(); |
339 | 339 | $total = $line_item->total(); |
340 | - if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) { |
|
341 | - $this->_events[ $options['event_id'] ] += $total; |
|
340 | + if (isset($options['event_id'], $this->_events[$options['event_id']])) { |
|
341 | + $this->_events[$options['event_id']] += $total; |
|
342 | 342 | } |
343 | 343 | // total td |
344 | 344 | $html .= EEH_HTML::td( |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | // name && desc |
422 | 422 | $name_and_desc = $line_item->name(); |
423 | 423 | $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
424 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
425 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
424 | + . esc_html__(' * taxable items', 'event_espresso').'</span>'; |
|
425 | + $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : ''; |
|
426 | 426 | // name td |
427 | 427 | $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
428 | 428 | $name_and_desc, |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | 'item_l sub-item' |
431 | 431 | ); |
432 | 432 | // percent td |
433 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
433 | + $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', ''); |
|
434 | 434 | // empty td (price) |
435 | 435 | $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
436 | 436 | // total td |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | $registration_payments += $registration->registration_payments(); |
576 | 576 | } |
577 | 577 | } |
578 | - if (! empty($registration_payments)) { |
|
578 | + if ( ! empty($registration_payments)) { |
|
579 | 579 | foreach ($registration_payments as $registration_payment) { |
580 | 580 | if ($registration_payment instanceof EE_Registration_Payment) { |
581 | 581 | $owing -= $registration_payment->amount(); |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | $payment_desc = sprintf( |
586 | 586 | esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
587 | 587 | $payment->txn_id_chq_nmbr() !== '' |
588 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
588 | + ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> ' |
|
589 | 589 | : '', |
590 | 590 | $payment->timestamp() |
591 | 591 | ); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param EE_Line_Item $line_item |
74 | 74 | * @param array $options |
75 | 75 | * @param EE_Line_Item $parent_line_item |
76 | - * @return mixed |
|
76 | + * @return string |
|
77 | 77 | * @throws EE_Error |
78 | 78 | */ |
79 | 79 | public function display_line_item( |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * _event_row - basically a Heading row displayed once above each event's ticket rows |
217 | 217 | * |
218 | 218 | * @param EE_Line_Item $line_item |
219 | - * @return mixed |
|
219 | + * @return string |
|
220 | 220 | */ |
221 | 221 | private function _event_row(EE_Line_Item $line_item) |
222 | 222 | { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @param EE_Line_Item $line_item |
244 | 244 | * @param array $options |
245 | - * @return mixed |
|
245 | + * @return string |
|
246 | 246 | * @throws EE_Error |
247 | 247 | */ |
248 | 248 | private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @param EE_Line_Item $line_item |
301 | 301 | * @param array $options |
302 | - * @return mixed |
|
302 | + * @return string |
|
303 | 303 | * @throws EE_Error |
304 | 304 | */ |
305 | 305 | private function _item_row(EE_Line_Item $line_item, $options = array()) |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @param EE_Line_Item $line_item |
424 | 424 | * @param array $options |
425 | - * @return mixed |
|
425 | + * @return string |
|
426 | 426 | * @throws EE_Error |
427 | 427 | */ |
428 | 428 | private function _tax_row(EE_Line_Item $line_item, $options = array()) |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @param EE_Line_Item $line_item |
468 | 468 | * @param string $text |
469 | - * @return mixed |
|
469 | + * @return string |
|
470 | 470 | * @throws EE_Error |
471 | 471 | */ |
472 | 472 | private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | * @param EE_Line_Item $line_item |
506 | 506 | * @param string $text |
507 | 507 | * @param array $options |
508 | - * @return mixed |
|
508 | + * @return string |
|
509 | 509 | * @throws EE_Error |
510 | 510 | */ |
511 | 511 | private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * |
542 | 542 | * @param EE_Line_Item $line_item |
543 | 543 | * @param string $text |
544 | - * @return mixed |
|
544 | + * @return string |
|
545 | 545 | * @throws EE_Error |
546 | 546 | */ |
547 | 547 | private function _total_row(EE_Line_Item $line_item, $text = '') |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @param EE_Line_Item $line_item |
570 | 570 | * @param array $options |
571 | - * @return mixed |
|
571 | + * @return string |
|
572 | 572 | * @throws EE_Error |
573 | 573 | */ |
574 | 574 | private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
@@ -12,636 +12,636 @@ |
||
12 | 12 | class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * array of events |
|
17 | - * |
|
18 | - * @type EE_Line_Item[] $_events |
|
19 | - */ |
|
20 | - private $_events = array(); |
|
21 | - |
|
22 | - /** |
|
23 | - * whether to display the taxes row or not |
|
24 | - * |
|
25 | - * @type bool $_show_taxes |
|
26 | - */ |
|
27 | - private $_show_taxes = false; |
|
28 | - |
|
29 | - /** |
|
30 | - * html for any tax rows |
|
31 | - * |
|
32 | - * @type string $_show_taxes |
|
33 | - */ |
|
34 | - private $_taxes_html = ''; |
|
35 | - |
|
36 | - /** |
|
37 | - * total amount including tax we can bill for at this time |
|
38 | - * |
|
39 | - * @type float $_grand_total |
|
40 | - */ |
|
41 | - private $_grand_total = 0.00; |
|
42 | - |
|
43 | - /** |
|
44 | - * total number of items being billed for |
|
45 | - * |
|
46 | - * @type int $_total_items |
|
47 | - */ |
|
48 | - private $_total_items = 0; |
|
49 | - |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * @return float |
|
54 | - */ |
|
55 | - public function grand_total() |
|
56 | - { |
|
57 | - return $this->_grand_total; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @return int |
|
64 | - */ |
|
65 | - public function total_items() |
|
66 | - { |
|
67 | - return $this->_total_items; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @param EE_Line_Item $line_item |
|
74 | - * @param array $options |
|
75 | - * @param EE_Line_Item $parent_line_item |
|
76 | - * @return mixed |
|
77 | - * @throws EE_Error |
|
78 | - */ |
|
79 | - public function display_line_item( |
|
80 | - EE_Line_Item $line_item, |
|
81 | - $options = array(), |
|
82 | - EE_Line_Item $parent_line_item = null |
|
83 | - ) { |
|
84 | - $html = ''; |
|
85 | - // set some default options and merge with incoming |
|
86 | - $default_options = array( |
|
87 | - 'show_desc' => true, // true false |
|
88 | - 'odd' => false, |
|
89 | - ); |
|
90 | - $options = array_merge($default_options, (array) $options); |
|
91 | - switch ($line_item->type()) { |
|
92 | - case EEM_Line_Item::type_line_item: |
|
93 | - $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
94 | - if ($line_item->OBJ_type() === 'Ticket') { |
|
95 | - // item row |
|
96 | - $html .= $this->_ticket_row($line_item, $options); |
|
97 | - } else { |
|
98 | - // item row |
|
99 | - $html .= $this->_item_row($line_item, $options); |
|
100 | - } |
|
101 | - if (apply_filters( |
|
102 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
103 | - true |
|
104 | - ) |
|
105 | - ) { |
|
106 | - // got any kids? |
|
107 | - foreach ($line_item->children() as $child_line_item) { |
|
108 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
109 | - } |
|
110 | - } |
|
111 | - break; |
|
112 | - case EEM_Line_Item::type_sub_line_item: |
|
113 | - $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
114 | - break; |
|
115 | - case EEM_Line_Item::type_sub_total: |
|
116 | - static $sub_total = 0; |
|
117 | - $event_sub_total = 0; |
|
118 | - $text = esc_html__('Sub-Total', 'event_espresso'); |
|
119 | - if ($line_item->OBJ_type() === 'Event') { |
|
120 | - $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
121 | - if (! isset($this->_events[ $options['event_id'] ])) { |
|
122 | - $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
123 | - // if event has default reg status of Not Approved, then don't display info on it |
|
124 | - if ($event instanceof EE_Event |
|
125 | - && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
126 | - ) { |
|
127 | - $display_event = false; |
|
128 | - // unless there are registrations for it that are returning to pay |
|
129 | - if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
130 | - foreach ($options['registrations'] as $registration) { |
|
131 | - if (! $registration instanceof EE_Registration) { |
|
132 | - continue; |
|
133 | - } |
|
134 | - $display_event = $registration->event_ID() === $options['event_id'] |
|
135 | - && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
136 | - ? true |
|
137 | - : $display_event; |
|
138 | - } |
|
139 | - } |
|
140 | - if (! $display_event) { |
|
141 | - return ''; |
|
142 | - } |
|
143 | - } |
|
144 | - $this->_events[ $options['event_id'] ] = 0; |
|
145 | - $html .= $this->_event_row($line_item); |
|
146 | - $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
147 | - } |
|
148 | - } |
|
149 | - $child_line_items = $line_item->children(); |
|
150 | - // loop thru children |
|
151 | - foreach ($child_line_items as $child_line_item) { |
|
152 | - // recursively feed children back into this method |
|
153 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
154 | - } |
|
155 | - $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0; |
|
156 | - $sub_total += $event_sub_total; |
|
157 | - if (( |
|
158 | - // event subtotals |
|
159 | - $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
160 | - ) |
|
161 | - || ( |
|
162 | - // pre-tax subtotals |
|
163 | - $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
164 | - ) |
|
165 | - ) { |
|
166 | - $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
167 | - $html .= $this->_sub_total_row($line_item, $text, $options); |
|
168 | - } |
|
169 | - break; |
|
170 | - case EEM_Line_Item::type_tax: |
|
171 | - if ($this->_show_taxes) { |
|
172 | - $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
173 | - } |
|
174 | - break; |
|
175 | - case EEM_Line_Item::type_tax_sub_total: |
|
176 | - if ($this->_show_taxes) { |
|
177 | - $child_line_items = $line_item->children(); |
|
178 | - // loop thru children |
|
179 | - foreach ($child_line_items as $child_line_item) { |
|
180 | - // recursively feed children back into this method |
|
181 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
182 | - } |
|
183 | - if (count($child_line_items) > 1) { |
|
184 | - $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
185 | - } |
|
186 | - } |
|
187 | - break; |
|
188 | - case EEM_Line_Item::type_total: |
|
189 | - // get all child line items |
|
190 | - $children = $line_item->children(); |
|
191 | - // loop thru all non-tax child line items |
|
192 | - foreach ($children as $child_line_item) { |
|
193 | - if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
194 | - // recursively feed children back into this method |
|
195 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
196 | - } |
|
197 | - } |
|
198 | - // now loop thru tax child line items |
|
199 | - foreach ($children as $child_line_item) { |
|
200 | - if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
201 | - // recursively feed children back into this method |
|
202 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
203 | - } |
|
204 | - } |
|
205 | - $html .= $this->_taxes_html; |
|
206 | - $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
207 | - $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
208 | - break; |
|
209 | - } |
|
210 | - return $html; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
217 | - * |
|
218 | - * @param EE_Line_Item $line_item |
|
219 | - * @return mixed |
|
220 | - */ |
|
221 | - private function _event_row(EE_Line_Item $line_item) |
|
222 | - { |
|
223 | - // start of row |
|
224 | - $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
225 | - // event name td |
|
226 | - $html .= EEH_HTML::td( |
|
227 | - EEH_HTML::strong($line_item->name()), |
|
228 | - '', |
|
229 | - 'event-header', |
|
230 | - '', |
|
231 | - ' colspan="4"' |
|
232 | - ); |
|
233 | - // end of row |
|
234 | - $html .= EEH_HTML::trx(); |
|
235 | - return $html; |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * _ticket_row |
|
242 | - * |
|
243 | - * @param EE_Line_Item $line_item |
|
244 | - * @param array $options |
|
245 | - * @return mixed |
|
246 | - * @throws EE_Error |
|
247 | - */ |
|
248 | - private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
249 | - { |
|
250 | - // start of row |
|
251 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
252 | - $html = EEH_HTML::tr('', '', $row_class); |
|
253 | - // name && desc |
|
254 | - $name_and_desc = apply_filters( |
|
255 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
256 | - $line_item->name(), |
|
257 | - $line_item |
|
258 | - ); |
|
259 | - $name_and_desc .= apply_filters( |
|
260 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
261 | - ( |
|
262 | - $options['show_desc'] |
|
263 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
264 | - : '' |
|
265 | - ), |
|
266 | - $line_item, |
|
267 | - $options |
|
268 | - ); |
|
269 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
270 | - // name td |
|
271 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
272 | - $name_and_desc, |
|
273 | - '', |
|
274 | - 'item_l' |
|
275 | - ); |
|
276 | - // price td |
|
277 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
278 | - // quantity td |
|
279 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
280 | - $this->_total_items += $line_item->quantity(); |
|
281 | - // determine total for line item |
|
282 | - $total = $line_item->total(); |
|
283 | - $this->_events[ $options['event_id'] ] += $total; |
|
284 | - // total td |
|
285 | - $html .= EEH_HTML::td( |
|
286 | - EEH_Template::format_currency($total, false, false), |
|
287 | - '', |
|
288 | - 'item_r jst-rght' |
|
289 | - ); |
|
290 | - // end of row |
|
291 | - $html .= EEH_HTML::trx(); |
|
292 | - return $html; |
|
293 | - } |
|
294 | - |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * _item_row |
|
299 | - * |
|
300 | - * @param EE_Line_Item $line_item |
|
301 | - * @param array $options |
|
302 | - * @return mixed |
|
303 | - * @throws EE_Error |
|
304 | - */ |
|
305 | - private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
306 | - { |
|
307 | - // start of row |
|
308 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
309 | - $html = EEH_HTML::tr('', '', $row_class); |
|
310 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
311 | - // name && desc |
|
312 | - $name_and_desc = apply_filters( |
|
313 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
314 | - $obj_name . $line_item->name(), |
|
315 | - $line_item |
|
316 | - ); |
|
317 | - $name_and_desc .= apply_filters( |
|
318 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
319 | - ( |
|
320 | - $options['show_desc'] |
|
321 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
322 | - : '' |
|
323 | - ), |
|
324 | - $line_item, |
|
325 | - $options |
|
326 | - ); |
|
327 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
328 | - // name td |
|
329 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
330 | - // price td |
|
331 | - if ($line_item->is_percent()) { |
|
332 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
333 | - } else { |
|
334 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
335 | - } |
|
336 | - // quantity td |
|
337 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
338 | - // $total = $line_item->total() * $line_item->quantity(); |
|
339 | - $total = $line_item->total(); |
|
340 | - if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) { |
|
341 | - $this->_events[ $options['event_id'] ] += $total; |
|
342 | - } |
|
343 | - // total td |
|
344 | - $html .= EEH_HTML::td( |
|
345 | - EEH_Template::format_currency($total, false, false), |
|
346 | - '', |
|
347 | - 'item_r jst-rght' |
|
348 | - ); |
|
349 | - // end of row |
|
350 | - $html .= EEH_HTML::trx(); |
|
351 | - return $html; |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * _sub_item_row |
|
358 | - * |
|
359 | - * @param EE_Line_Item $line_item |
|
360 | - * @param array $options |
|
361 | - * @param EE_Line_Item $parent_line_item |
|
362 | - * @return mixed |
|
363 | - * @throws EE_Error |
|
364 | - */ |
|
365 | - private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
366 | - { |
|
367 | - if ($parent_line_item instanceof EE_Line_Item |
|
368 | - && $line_item->children() === array() |
|
369 | - && $line_item->name() === $parent_line_item->name() |
|
370 | - && apply_filters( |
|
371 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item', |
|
372 | - true |
|
373 | - ) |
|
374 | - ) { |
|
375 | - return ''; |
|
376 | - } |
|
377 | - // start of row |
|
378 | - $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
379 | - // name && desc |
|
380 | - $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
381 | - . $line_item->name(); |
|
382 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
383 | - . $line_item->desc() |
|
384 | - . '</span>' : ''; |
|
385 | - // name td |
|
386 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item'); |
|
387 | - $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
388 | - // discount/surcharge td |
|
389 | - if ($line_item->is_percent()) { |
|
390 | - $html .= EEH_HTML::td( |
|
391 | - EEH_Template::format_currency( |
|
392 | - $line_item->total() / $qty, |
|
393 | - false, |
|
394 | - false |
|
395 | - ), |
|
396 | - '', |
|
397 | - 'item_c jst-rght' |
|
398 | - ); |
|
399 | - } else { |
|
400 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
401 | - } |
|
402 | - // no quantity td |
|
403 | - $html .= EEH_HTML::td(); |
|
404 | - // no total td |
|
405 | - $html .= EEH_HTML::td(); |
|
406 | - // end of row |
|
407 | - $html .= EEH_HTML::trx(); |
|
408 | - $html = apply_filters( |
|
409 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html', |
|
410 | - $html, |
|
411 | - $line_item, |
|
412 | - $options, |
|
413 | - $parent_line_item |
|
414 | - ); |
|
415 | - return $html; |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - |
|
420 | - /** |
|
421 | - * _tax_row |
|
422 | - * |
|
423 | - * @param EE_Line_Item $line_item |
|
424 | - * @param array $options |
|
425 | - * @return mixed |
|
426 | - * @throws EE_Error |
|
427 | - */ |
|
428 | - private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
429 | - { |
|
430 | - // start of row |
|
431 | - $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
432 | - // name && desc |
|
433 | - $name_and_desc = $line_item->name(); |
|
434 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
435 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
436 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
437 | - // name td |
|
438 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
439 | - $name_and_desc, |
|
440 | - '', |
|
441 | - 'item_l sub-item' |
|
442 | - ); |
|
443 | - // percent td |
|
444 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
445 | - // empty td (price) |
|
446 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
447 | - // total td |
|
448 | - $html .= EEH_HTML::td( |
|
449 | - EEH_Template::format_currency( |
|
450 | - $line_item->total(), |
|
451 | - false, |
|
452 | - false |
|
453 | - ), |
|
454 | - '', |
|
455 | - 'item_r jst-rght' |
|
456 | - ); |
|
457 | - // end of row |
|
458 | - $html .= EEH_HTML::trx(); |
|
459 | - return $html; |
|
460 | - } |
|
461 | - |
|
462 | - |
|
463 | - |
|
464 | - /** |
|
465 | - * _total_row |
|
466 | - * |
|
467 | - * @param EE_Line_Item $line_item |
|
468 | - * @param string $text |
|
469 | - * @return mixed |
|
470 | - * @throws EE_Error |
|
471 | - */ |
|
472 | - private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
473 | - { |
|
474 | - $html = ''; |
|
475 | - if ($line_item->total()) { |
|
476 | - // start of row |
|
477 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
478 | - // total td |
|
479 | - $html .= EEH_HTML::td( |
|
480 | - $text, |
|
481 | - '', |
|
482 | - 'total_currency total jst-rght', |
|
483 | - '', |
|
484 | - ' colspan="2"' |
|
485 | - ); |
|
486 | - // empty td (price) |
|
487 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
488 | - // total td |
|
489 | - $html .= EEH_HTML::td( |
|
490 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
491 | - '', |
|
492 | - 'total jst-rght' |
|
493 | - ); |
|
494 | - // end of row |
|
495 | - $html .= EEH_HTML::trx(); |
|
496 | - } |
|
497 | - return $html; |
|
498 | - } |
|
499 | - |
|
500 | - |
|
501 | - |
|
502 | - /** |
|
503 | - * _total_row |
|
504 | - * |
|
505 | - * @param EE_Line_Item $line_item |
|
506 | - * @param string $text |
|
507 | - * @param array $options |
|
508 | - * @return mixed |
|
509 | - * @throws EE_Error |
|
510 | - */ |
|
511 | - private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
512 | - { |
|
513 | - $html = ''; |
|
514 | - if ($line_item->total()) { |
|
515 | - // start of row |
|
516 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
517 | - // total td |
|
518 | - $html .= EEH_HTML::td( |
|
519 | - $text, |
|
520 | - '', |
|
521 | - 'total_currency total jst-rght', |
|
522 | - '', |
|
523 | - ' colspan="3"' |
|
524 | - ); |
|
525 | - // total td |
|
526 | - $html .= EEH_HTML::td( |
|
527 | - EEH_Template::format_currency($options['sub_total'], false, false), |
|
528 | - '', |
|
529 | - 'total jst-rght' |
|
530 | - ); |
|
531 | - // end of row |
|
532 | - $html .= EEH_HTML::trx(); |
|
533 | - } |
|
534 | - return $html; |
|
535 | - } |
|
536 | - |
|
537 | - |
|
538 | - |
|
539 | - /** |
|
540 | - * _total_row |
|
541 | - * |
|
542 | - * @param EE_Line_Item $line_item |
|
543 | - * @param string $text |
|
544 | - * @return mixed |
|
545 | - * @throws EE_Error |
|
546 | - */ |
|
547 | - private function _total_row(EE_Line_Item $line_item, $text = '') |
|
548 | - { |
|
549 | - // start of row |
|
550 | - $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
551 | - // total td |
|
552 | - $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
553 | - // total td |
|
554 | - $html .= EEH_HTML::td( |
|
555 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
556 | - '', |
|
557 | - 'total jst-rght' |
|
558 | - ); |
|
559 | - // end of row |
|
560 | - $html .= EEH_HTML::trx(); |
|
561 | - return $html; |
|
562 | - } |
|
563 | - |
|
564 | - |
|
565 | - |
|
566 | - /** |
|
567 | - * _payments_and_amount_owing_rows |
|
568 | - * |
|
569 | - * @param EE_Line_Item $line_item |
|
570 | - * @param array $options |
|
571 | - * @return mixed |
|
572 | - * @throws EE_Error |
|
573 | - */ |
|
574 | - private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
575 | - { |
|
576 | - $html = ''; |
|
577 | - $owing = $line_item->total(); |
|
578 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
579 | - if ($transaction instanceof EE_Transaction) { |
|
580 | - $registration_payments = array(); |
|
581 | - $registrations = ! empty($options['registrations']) |
|
582 | - ? $options['registrations'] |
|
583 | - : $transaction->registrations(); |
|
584 | - foreach ($registrations as $registration) { |
|
585 | - if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
586 | - $registration_payments += $registration->registration_payments(); |
|
587 | - } |
|
588 | - } |
|
589 | - if (! empty($registration_payments)) { |
|
590 | - foreach ($registration_payments as $registration_payment) { |
|
591 | - if ($registration_payment instanceof EE_Registration_Payment) { |
|
592 | - $owing -= $registration_payment->amount(); |
|
593 | - $payment = $registration_payment->payment(); |
|
594 | - $payment_desc = ''; |
|
595 | - if ($payment instanceof EE_Payment) { |
|
596 | - $payment_desc = sprintf( |
|
597 | - esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
598 | - $payment->txn_id_chq_nmbr() !== '' |
|
599 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
600 | - : '', |
|
601 | - $payment->timestamp() |
|
602 | - ); |
|
603 | - } |
|
604 | - // start of row |
|
605 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
606 | - // payment desc |
|
607 | - $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
608 | - // total td |
|
609 | - $html .= EEH_HTML::td( |
|
610 | - EEH_Template::format_currency( |
|
611 | - $registration_payment->amount(), |
|
612 | - false, |
|
613 | - false |
|
614 | - ), |
|
615 | - '', |
|
616 | - 'total jst-rght' |
|
617 | - ); |
|
618 | - // end of row |
|
619 | - $html .= EEH_HTML::trx(); |
|
620 | - } |
|
621 | - } |
|
622 | - if ($line_item->total()) { |
|
623 | - // start of row |
|
624 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
625 | - // total td |
|
626 | - $html .= EEH_HTML::td( |
|
627 | - esc_html__('Amount Owing', 'event_espresso'), |
|
628 | - '', |
|
629 | - 'total_currency total jst-rght', |
|
630 | - '', |
|
631 | - ' colspan="3"' |
|
632 | - ); |
|
633 | - // total td |
|
634 | - $html .= EEH_HTML::td( |
|
635 | - EEH_Template::format_currency($owing, false, false), |
|
636 | - '', |
|
637 | - 'total jst-rght' |
|
638 | - ); |
|
639 | - // end of row |
|
640 | - $html .= EEH_HTML::trx(); |
|
641 | - } |
|
642 | - } |
|
643 | - } |
|
644 | - $this->_grand_total = $owing; |
|
645 | - return $html; |
|
646 | - } |
|
15 | + /** |
|
16 | + * array of events |
|
17 | + * |
|
18 | + * @type EE_Line_Item[] $_events |
|
19 | + */ |
|
20 | + private $_events = array(); |
|
21 | + |
|
22 | + /** |
|
23 | + * whether to display the taxes row or not |
|
24 | + * |
|
25 | + * @type bool $_show_taxes |
|
26 | + */ |
|
27 | + private $_show_taxes = false; |
|
28 | + |
|
29 | + /** |
|
30 | + * html for any tax rows |
|
31 | + * |
|
32 | + * @type string $_show_taxes |
|
33 | + */ |
|
34 | + private $_taxes_html = ''; |
|
35 | + |
|
36 | + /** |
|
37 | + * total amount including tax we can bill for at this time |
|
38 | + * |
|
39 | + * @type float $_grand_total |
|
40 | + */ |
|
41 | + private $_grand_total = 0.00; |
|
42 | + |
|
43 | + /** |
|
44 | + * total number of items being billed for |
|
45 | + * |
|
46 | + * @type int $_total_items |
|
47 | + */ |
|
48 | + private $_total_items = 0; |
|
49 | + |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * @return float |
|
54 | + */ |
|
55 | + public function grand_total() |
|
56 | + { |
|
57 | + return $this->_grand_total; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @return int |
|
64 | + */ |
|
65 | + public function total_items() |
|
66 | + { |
|
67 | + return $this->_total_items; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @param EE_Line_Item $line_item |
|
74 | + * @param array $options |
|
75 | + * @param EE_Line_Item $parent_line_item |
|
76 | + * @return mixed |
|
77 | + * @throws EE_Error |
|
78 | + */ |
|
79 | + public function display_line_item( |
|
80 | + EE_Line_Item $line_item, |
|
81 | + $options = array(), |
|
82 | + EE_Line_Item $parent_line_item = null |
|
83 | + ) { |
|
84 | + $html = ''; |
|
85 | + // set some default options and merge with incoming |
|
86 | + $default_options = array( |
|
87 | + 'show_desc' => true, // true false |
|
88 | + 'odd' => false, |
|
89 | + ); |
|
90 | + $options = array_merge($default_options, (array) $options); |
|
91 | + switch ($line_item->type()) { |
|
92 | + case EEM_Line_Item::type_line_item: |
|
93 | + $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
94 | + if ($line_item->OBJ_type() === 'Ticket') { |
|
95 | + // item row |
|
96 | + $html .= $this->_ticket_row($line_item, $options); |
|
97 | + } else { |
|
98 | + // item row |
|
99 | + $html .= $this->_item_row($line_item, $options); |
|
100 | + } |
|
101 | + if (apply_filters( |
|
102 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
103 | + true |
|
104 | + ) |
|
105 | + ) { |
|
106 | + // got any kids? |
|
107 | + foreach ($line_item->children() as $child_line_item) { |
|
108 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
109 | + } |
|
110 | + } |
|
111 | + break; |
|
112 | + case EEM_Line_Item::type_sub_line_item: |
|
113 | + $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
114 | + break; |
|
115 | + case EEM_Line_Item::type_sub_total: |
|
116 | + static $sub_total = 0; |
|
117 | + $event_sub_total = 0; |
|
118 | + $text = esc_html__('Sub-Total', 'event_espresso'); |
|
119 | + if ($line_item->OBJ_type() === 'Event') { |
|
120 | + $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
121 | + if (! isset($this->_events[ $options['event_id'] ])) { |
|
122 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
123 | + // if event has default reg status of Not Approved, then don't display info on it |
|
124 | + if ($event instanceof EE_Event |
|
125 | + && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
126 | + ) { |
|
127 | + $display_event = false; |
|
128 | + // unless there are registrations for it that are returning to pay |
|
129 | + if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
130 | + foreach ($options['registrations'] as $registration) { |
|
131 | + if (! $registration instanceof EE_Registration) { |
|
132 | + continue; |
|
133 | + } |
|
134 | + $display_event = $registration->event_ID() === $options['event_id'] |
|
135 | + && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
136 | + ? true |
|
137 | + : $display_event; |
|
138 | + } |
|
139 | + } |
|
140 | + if (! $display_event) { |
|
141 | + return ''; |
|
142 | + } |
|
143 | + } |
|
144 | + $this->_events[ $options['event_id'] ] = 0; |
|
145 | + $html .= $this->_event_row($line_item); |
|
146 | + $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
147 | + } |
|
148 | + } |
|
149 | + $child_line_items = $line_item->children(); |
|
150 | + // loop thru children |
|
151 | + foreach ($child_line_items as $child_line_item) { |
|
152 | + // recursively feed children back into this method |
|
153 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
154 | + } |
|
155 | + $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0; |
|
156 | + $sub_total += $event_sub_total; |
|
157 | + if (( |
|
158 | + // event subtotals |
|
159 | + $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
160 | + ) |
|
161 | + || ( |
|
162 | + // pre-tax subtotals |
|
163 | + $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
164 | + ) |
|
165 | + ) { |
|
166 | + $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
167 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
168 | + } |
|
169 | + break; |
|
170 | + case EEM_Line_Item::type_tax: |
|
171 | + if ($this->_show_taxes) { |
|
172 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
173 | + } |
|
174 | + break; |
|
175 | + case EEM_Line_Item::type_tax_sub_total: |
|
176 | + if ($this->_show_taxes) { |
|
177 | + $child_line_items = $line_item->children(); |
|
178 | + // loop thru children |
|
179 | + foreach ($child_line_items as $child_line_item) { |
|
180 | + // recursively feed children back into this method |
|
181 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
182 | + } |
|
183 | + if (count($child_line_items) > 1) { |
|
184 | + $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
185 | + } |
|
186 | + } |
|
187 | + break; |
|
188 | + case EEM_Line_Item::type_total: |
|
189 | + // get all child line items |
|
190 | + $children = $line_item->children(); |
|
191 | + // loop thru all non-tax child line items |
|
192 | + foreach ($children as $child_line_item) { |
|
193 | + if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
194 | + // recursively feed children back into this method |
|
195 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
196 | + } |
|
197 | + } |
|
198 | + // now loop thru tax child line items |
|
199 | + foreach ($children as $child_line_item) { |
|
200 | + if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
201 | + // recursively feed children back into this method |
|
202 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
203 | + } |
|
204 | + } |
|
205 | + $html .= $this->_taxes_html; |
|
206 | + $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
207 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
208 | + break; |
|
209 | + } |
|
210 | + return $html; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
217 | + * |
|
218 | + * @param EE_Line_Item $line_item |
|
219 | + * @return mixed |
|
220 | + */ |
|
221 | + private function _event_row(EE_Line_Item $line_item) |
|
222 | + { |
|
223 | + // start of row |
|
224 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
225 | + // event name td |
|
226 | + $html .= EEH_HTML::td( |
|
227 | + EEH_HTML::strong($line_item->name()), |
|
228 | + '', |
|
229 | + 'event-header', |
|
230 | + '', |
|
231 | + ' colspan="4"' |
|
232 | + ); |
|
233 | + // end of row |
|
234 | + $html .= EEH_HTML::trx(); |
|
235 | + return $html; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * _ticket_row |
|
242 | + * |
|
243 | + * @param EE_Line_Item $line_item |
|
244 | + * @param array $options |
|
245 | + * @return mixed |
|
246 | + * @throws EE_Error |
|
247 | + */ |
|
248 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
249 | + { |
|
250 | + // start of row |
|
251 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
252 | + $html = EEH_HTML::tr('', '', $row_class); |
|
253 | + // name && desc |
|
254 | + $name_and_desc = apply_filters( |
|
255 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
256 | + $line_item->name(), |
|
257 | + $line_item |
|
258 | + ); |
|
259 | + $name_and_desc .= apply_filters( |
|
260 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
261 | + ( |
|
262 | + $options['show_desc'] |
|
263 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
264 | + : '' |
|
265 | + ), |
|
266 | + $line_item, |
|
267 | + $options |
|
268 | + ); |
|
269 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
270 | + // name td |
|
271 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
272 | + $name_and_desc, |
|
273 | + '', |
|
274 | + 'item_l' |
|
275 | + ); |
|
276 | + // price td |
|
277 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
278 | + // quantity td |
|
279 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
280 | + $this->_total_items += $line_item->quantity(); |
|
281 | + // determine total for line item |
|
282 | + $total = $line_item->total(); |
|
283 | + $this->_events[ $options['event_id'] ] += $total; |
|
284 | + // total td |
|
285 | + $html .= EEH_HTML::td( |
|
286 | + EEH_Template::format_currency($total, false, false), |
|
287 | + '', |
|
288 | + 'item_r jst-rght' |
|
289 | + ); |
|
290 | + // end of row |
|
291 | + $html .= EEH_HTML::trx(); |
|
292 | + return $html; |
|
293 | + } |
|
294 | + |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * _item_row |
|
299 | + * |
|
300 | + * @param EE_Line_Item $line_item |
|
301 | + * @param array $options |
|
302 | + * @return mixed |
|
303 | + * @throws EE_Error |
|
304 | + */ |
|
305 | + private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
306 | + { |
|
307 | + // start of row |
|
308 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
309 | + $html = EEH_HTML::tr('', '', $row_class); |
|
310 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
311 | + // name && desc |
|
312 | + $name_and_desc = apply_filters( |
|
313 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
314 | + $obj_name . $line_item->name(), |
|
315 | + $line_item |
|
316 | + ); |
|
317 | + $name_and_desc .= apply_filters( |
|
318 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
319 | + ( |
|
320 | + $options['show_desc'] |
|
321 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
322 | + : '' |
|
323 | + ), |
|
324 | + $line_item, |
|
325 | + $options |
|
326 | + ); |
|
327 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
328 | + // name td |
|
329 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
330 | + // price td |
|
331 | + if ($line_item->is_percent()) { |
|
332 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
333 | + } else { |
|
334 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
335 | + } |
|
336 | + // quantity td |
|
337 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
338 | + // $total = $line_item->total() * $line_item->quantity(); |
|
339 | + $total = $line_item->total(); |
|
340 | + if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) { |
|
341 | + $this->_events[ $options['event_id'] ] += $total; |
|
342 | + } |
|
343 | + // total td |
|
344 | + $html .= EEH_HTML::td( |
|
345 | + EEH_Template::format_currency($total, false, false), |
|
346 | + '', |
|
347 | + 'item_r jst-rght' |
|
348 | + ); |
|
349 | + // end of row |
|
350 | + $html .= EEH_HTML::trx(); |
|
351 | + return $html; |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * _sub_item_row |
|
358 | + * |
|
359 | + * @param EE_Line_Item $line_item |
|
360 | + * @param array $options |
|
361 | + * @param EE_Line_Item $parent_line_item |
|
362 | + * @return mixed |
|
363 | + * @throws EE_Error |
|
364 | + */ |
|
365 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
366 | + { |
|
367 | + if ($parent_line_item instanceof EE_Line_Item |
|
368 | + && $line_item->children() === array() |
|
369 | + && $line_item->name() === $parent_line_item->name() |
|
370 | + && apply_filters( |
|
371 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item', |
|
372 | + true |
|
373 | + ) |
|
374 | + ) { |
|
375 | + return ''; |
|
376 | + } |
|
377 | + // start of row |
|
378 | + $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
379 | + // name && desc |
|
380 | + $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
381 | + . $line_item->name(); |
|
382 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
383 | + . $line_item->desc() |
|
384 | + . '</span>' : ''; |
|
385 | + // name td |
|
386 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item'); |
|
387 | + $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
388 | + // discount/surcharge td |
|
389 | + if ($line_item->is_percent()) { |
|
390 | + $html .= EEH_HTML::td( |
|
391 | + EEH_Template::format_currency( |
|
392 | + $line_item->total() / $qty, |
|
393 | + false, |
|
394 | + false |
|
395 | + ), |
|
396 | + '', |
|
397 | + 'item_c jst-rght' |
|
398 | + ); |
|
399 | + } else { |
|
400 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
401 | + } |
|
402 | + // no quantity td |
|
403 | + $html .= EEH_HTML::td(); |
|
404 | + // no total td |
|
405 | + $html .= EEH_HTML::td(); |
|
406 | + // end of row |
|
407 | + $html .= EEH_HTML::trx(); |
|
408 | + $html = apply_filters( |
|
409 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html', |
|
410 | + $html, |
|
411 | + $line_item, |
|
412 | + $options, |
|
413 | + $parent_line_item |
|
414 | + ); |
|
415 | + return $html; |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + |
|
420 | + /** |
|
421 | + * _tax_row |
|
422 | + * |
|
423 | + * @param EE_Line_Item $line_item |
|
424 | + * @param array $options |
|
425 | + * @return mixed |
|
426 | + * @throws EE_Error |
|
427 | + */ |
|
428 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
429 | + { |
|
430 | + // start of row |
|
431 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
432 | + // name && desc |
|
433 | + $name_and_desc = $line_item->name(); |
|
434 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
435 | + . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
436 | + $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
437 | + // name td |
|
438 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
439 | + $name_and_desc, |
|
440 | + '', |
|
441 | + 'item_l sub-item' |
|
442 | + ); |
|
443 | + // percent td |
|
444 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
445 | + // empty td (price) |
|
446 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
447 | + // total td |
|
448 | + $html .= EEH_HTML::td( |
|
449 | + EEH_Template::format_currency( |
|
450 | + $line_item->total(), |
|
451 | + false, |
|
452 | + false |
|
453 | + ), |
|
454 | + '', |
|
455 | + 'item_r jst-rght' |
|
456 | + ); |
|
457 | + // end of row |
|
458 | + $html .= EEH_HTML::trx(); |
|
459 | + return $html; |
|
460 | + } |
|
461 | + |
|
462 | + |
|
463 | + |
|
464 | + /** |
|
465 | + * _total_row |
|
466 | + * |
|
467 | + * @param EE_Line_Item $line_item |
|
468 | + * @param string $text |
|
469 | + * @return mixed |
|
470 | + * @throws EE_Error |
|
471 | + */ |
|
472 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
473 | + { |
|
474 | + $html = ''; |
|
475 | + if ($line_item->total()) { |
|
476 | + // start of row |
|
477 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
478 | + // total td |
|
479 | + $html .= EEH_HTML::td( |
|
480 | + $text, |
|
481 | + '', |
|
482 | + 'total_currency total jst-rght', |
|
483 | + '', |
|
484 | + ' colspan="2"' |
|
485 | + ); |
|
486 | + // empty td (price) |
|
487 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
488 | + // total td |
|
489 | + $html .= EEH_HTML::td( |
|
490 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
491 | + '', |
|
492 | + 'total jst-rght' |
|
493 | + ); |
|
494 | + // end of row |
|
495 | + $html .= EEH_HTML::trx(); |
|
496 | + } |
|
497 | + return $html; |
|
498 | + } |
|
499 | + |
|
500 | + |
|
501 | + |
|
502 | + /** |
|
503 | + * _total_row |
|
504 | + * |
|
505 | + * @param EE_Line_Item $line_item |
|
506 | + * @param string $text |
|
507 | + * @param array $options |
|
508 | + * @return mixed |
|
509 | + * @throws EE_Error |
|
510 | + */ |
|
511 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
512 | + { |
|
513 | + $html = ''; |
|
514 | + if ($line_item->total()) { |
|
515 | + // start of row |
|
516 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
517 | + // total td |
|
518 | + $html .= EEH_HTML::td( |
|
519 | + $text, |
|
520 | + '', |
|
521 | + 'total_currency total jst-rght', |
|
522 | + '', |
|
523 | + ' colspan="3"' |
|
524 | + ); |
|
525 | + // total td |
|
526 | + $html .= EEH_HTML::td( |
|
527 | + EEH_Template::format_currency($options['sub_total'], false, false), |
|
528 | + '', |
|
529 | + 'total jst-rght' |
|
530 | + ); |
|
531 | + // end of row |
|
532 | + $html .= EEH_HTML::trx(); |
|
533 | + } |
|
534 | + return $html; |
|
535 | + } |
|
536 | + |
|
537 | + |
|
538 | + |
|
539 | + /** |
|
540 | + * _total_row |
|
541 | + * |
|
542 | + * @param EE_Line_Item $line_item |
|
543 | + * @param string $text |
|
544 | + * @return mixed |
|
545 | + * @throws EE_Error |
|
546 | + */ |
|
547 | + private function _total_row(EE_Line_Item $line_item, $text = '') |
|
548 | + { |
|
549 | + // start of row |
|
550 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
551 | + // total td |
|
552 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
553 | + // total td |
|
554 | + $html .= EEH_HTML::td( |
|
555 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
556 | + '', |
|
557 | + 'total jst-rght' |
|
558 | + ); |
|
559 | + // end of row |
|
560 | + $html .= EEH_HTML::trx(); |
|
561 | + return $html; |
|
562 | + } |
|
563 | + |
|
564 | + |
|
565 | + |
|
566 | + /** |
|
567 | + * _payments_and_amount_owing_rows |
|
568 | + * |
|
569 | + * @param EE_Line_Item $line_item |
|
570 | + * @param array $options |
|
571 | + * @return mixed |
|
572 | + * @throws EE_Error |
|
573 | + */ |
|
574 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
575 | + { |
|
576 | + $html = ''; |
|
577 | + $owing = $line_item->total(); |
|
578 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
579 | + if ($transaction instanceof EE_Transaction) { |
|
580 | + $registration_payments = array(); |
|
581 | + $registrations = ! empty($options['registrations']) |
|
582 | + ? $options['registrations'] |
|
583 | + : $transaction->registrations(); |
|
584 | + foreach ($registrations as $registration) { |
|
585 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
586 | + $registration_payments += $registration->registration_payments(); |
|
587 | + } |
|
588 | + } |
|
589 | + if (! empty($registration_payments)) { |
|
590 | + foreach ($registration_payments as $registration_payment) { |
|
591 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
592 | + $owing -= $registration_payment->amount(); |
|
593 | + $payment = $registration_payment->payment(); |
|
594 | + $payment_desc = ''; |
|
595 | + if ($payment instanceof EE_Payment) { |
|
596 | + $payment_desc = sprintf( |
|
597 | + esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
598 | + $payment->txn_id_chq_nmbr() !== '' |
|
599 | + ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
600 | + : '', |
|
601 | + $payment->timestamp() |
|
602 | + ); |
|
603 | + } |
|
604 | + // start of row |
|
605 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
606 | + // payment desc |
|
607 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
608 | + // total td |
|
609 | + $html .= EEH_HTML::td( |
|
610 | + EEH_Template::format_currency( |
|
611 | + $registration_payment->amount(), |
|
612 | + false, |
|
613 | + false |
|
614 | + ), |
|
615 | + '', |
|
616 | + 'total jst-rght' |
|
617 | + ); |
|
618 | + // end of row |
|
619 | + $html .= EEH_HTML::trx(); |
|
620 | + } |
|
621 | + } |
|
622 | + if ($line_item->total()) { |
|
623 | + // start of row |
|
624 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
625 | + // total td |
|
626 | + $html .= EEH_HTML::td( |
|
627 | + esc_html__('Amount Owing', 'event_espresso'), |
|
628 | + '', |
|
629 | + 'total_currency total jst-rght', |
|
630 | + '', |
|
631 | + ' colspan="3"' |
|
632 | + ); |
|
633 | + // total td |
|
634 | + $html .= EEH_HTML::td( |
|
635 | + EEH_Template::format_currency($owing, false, false), |
|
636 | + '', |
|
637 | + 'total jst-rght' |
|
638 | + ); |
|
639 | + // end of row |
|
640 | + $html .= EEH_HTML::trx(); |
|
641 | + } |
|
642 | + } |
|
643 | + } |
|
644 | + $this->_grand_total = $owing; |
|
645 | + return $html; |
|
646 | + } |
|
647 | 647 | } |
@@ -13,183 +13,183 @@ |
||
13 | 13 | class EE_Admin_Table_Registration_Line_Item_Display_Strategy extends EE_Admin_Table_Line_Item_Display_Strategy |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Table header for display. |
|
18 | - * @since 4.8 |
|
19 | - * @param array $options |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - protected function _table_header($options) |
|
23 | - { |
|
24 | - $html = EEH_HTML::table('', '', $options['table_css_class']); |
|
25 | - $html .= EEH_HTML::thead(); |
|
26 | - $html .= EEH_HTML::tr(); |
|
27 | - $html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left'); |
|
28 | - $html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left'); |
|
29 | - $html .= EEH_HTML::th(__('Date(s)', 'event_espresso'), '', 'jst-left'); |
|
30 | - $html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr'); |
|
31 | - $html .= EEH_HTML::tbody(); |
|
32 | - return $html; |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * _item_row |
|
41 | - * |
|
42 | - * @param EE_Line_Item $line_item |
|
43 | - * @param array $options |
|
44 | - * @return mixed |
|
45 | - */ |
|
46 | - protected function _item_row(EE_Line_Item $line_item, $options = array()) |
|
47 | - { |
|
48 | - $line_item_related_object = $line_item->get_object(); |
|
49 | - $parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item |
|
50 | - ? $line_item->parent()->get_object() |
|
51 | - : null; |
|
52 | - // start of row |
|
53 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
54 | - $html = EEH_HTML::tr('', '', $row_class); |
|
55 | - |
|
56 | - |
|
57 | - // Name Column |
|
58 | - $name_link = $line_item_related_object instanceof EEI_Admin_Links ? $line_item_related_object->get_admin_details_link() : ''; |
|
59 | - |
|
60 | - // related object scope. |
|
61 | - $parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object |
|
62 | - ? $parent_line_item_related_object->name() |
|
63 | - : ''; |
|
64 | - $parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item |
|
65 | - ? $line_item->parent()->name() |
|
66 | - : $parent_related_object_name; |
|
67 | - $parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links |
|
68 | - ? $parent_line_item_related_object->get_admin_details_link() |
|
69 | - : ''; |
|
70 | - |
|
71 | - |
|
72 | - $name_html = $line_item_related_object instanceof EEI_Line_Item_Object |
|
73 | - ? $line_item_related_object->name() : $line_item->name(); |
|
74 | - $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' |
|
75 | - : $name_html; |
|
76 | - $name_html .= $line_item->is_taxable() ? ' *' : ''; |
|
77 | - // maybe preface with icon? |
|
78 | - $name_html = $line_item_related_object instanceof EEI_Has_Icon |
|
79 | - ? $line_item_related_object->get_icon() . $name_html |
|
80 | - : $name_html; |
|
81 | - $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>'; |
|
82 | - $name_html .= sprintf( |
|
83 | - _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
84 | - '<span class="ee-line-item-related-parent-object">', |
|
85 | - $line_item->parent() instanceof EE_Line_Item |
|
86 | - ? $line_item->parent()->OBJ_type_i18n() |
|
87 | - : __('Item:', 'event_espresso'), |
|
88 | - $parent_related_object_link |
|
89 | - ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' |
|
90 | - : $parent_related_object_name, |
|
91 | - '</span>' |
|
92 | - ); |
|
93 | - $html .= EEH_HTML::td($name_html, '', 'jst-left'); |
|
94 | - // Type Column |
|
95 | - $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : ''; |
|
96 | - $type_html .= $this->_get_cancellations($line_item); |
|
97 | - $type_html .= $line_item->OBJ_type() ? '<br />' : ''; |
|
98 | - $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : ''; |
|
99 | - $type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(__('Code: %s', 'event_espresso'), $code) . '</span>' : ''; |
|
100 | - $html .= EEH_HTML::td($type_html, '', 'jst-left'); |
|
101 | - |
|
102 | - // Date column |
|
103 | - $datetime_content = ''; |
|
104 | - if ($line_item_related_object instanceof EE_Ticket) { |
|
105 | - $datetimes = $line_item_related_object->datetimes(); |
|
106 | - foreach ($datetimes as $datetime) { |
|
107 | - if ($datetime instanceof EE_Datetime) { |
|
108 | - $datetime_content .= $datetime->get_dtt_display_name() . '<br>'; |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
112 | - $html .= EEH_HTML::td($datetime_content, '', 'jst-left'); |
|
113 | - |
|
114 | - // Amount Column |
|
115 | - if ($line_item->is_percent()) { |
|
116 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'jst-rght'); |
|
117 | - } else { |
|
118 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght'); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - // finish things off and return |
|
123 | - $html .= EEH_HTML::trx(); |
|
124 | - return $html; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * _tax_row |
|
131 | - * |
|
132 | - * @param EE_Line_Item $line_item |
|
133 | - * @param array $options |
|
134 | - * @return mixed |
|
135 | - */ |
|
136 | - protected function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
137 | - { |
|
138 | - // start of row |
|
139 | - $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr'); |
|
140 | - // name th |
|
141 | - $html .= EEH_HTML::th($line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)', '', 'jst-rght', '', ' colspan="3"'); |
|
142 | - // total th |
|
143 | - $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
144 | - // end of row |
|
145 | - $html .= EEH_HTML::trx(); |
|
146 | - return $html; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * _total_row |
|
155 | - * |
|
156 | - * @param EE_Line_Item $line_item |
|
157 | - * @param array $options |
|
158 | - * @return mixed |
|
159 | - */ |
|
160 | - protected function _total_row(EE_Line_Item $line_item, $options = array()) |
|
161 | - { |
|
162 | - |
|
163 | - $registration = isset($options['EE_Registration']) ? $options['EE_Registration'] : null; |
|
164 | - $registration_total = $registration instanceof EE_Registration ? $registration->pretty_final_price() : 0; |
|
165 | - // if no valid registration object then we're not going to show the approximate text. |
|
166 | - $total_match = $registration instanceof EE_Registration |
|
167 | - ? $registration->final_price() === $line_item->total() |
|
168 | - : true; |
|
169 | - |
|
170 | - // start of row |
|
171 | - $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr'); |
|
172 | - // Total th label |
|
173 | - if ($total_match) { |
|
174 | - $total_label = sprintf(__('This registration\'s total %s:', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')'); |
|
175 | - } else { |
|
176 | - $total_label = sprintf(__('This registration\'s approximate total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')'); |
|
177 | - $total_label .= '<br>'; |
|
178 | - $total_label .= '<p class="ee-footnote-text">' |
|
179 | - . sprintf( |
|
180 | - __('The registrations\' share of the transaction total is approximate because it might not be possible to evenly divide the transaction total among each registration, and so some registrations may need to pay a penny more than others. This registration\'s final share is actually %1$s%2$s%3$s.', 'event_espresso'), |
|
181 | - '<strong>', |
|
182 | - $registration_total, |
|
183 | - '</strong>' |
|
184 | - ) |
|
185 | - . '</p>'; |
|
186 | - } |
|
187 | - $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="3"'); |
|
188 | - // total th |
|
189 | - |
|
190 | - $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
191 | - // end of row |
|
192 | - $html .= EEH_HTML::trx(); |
|
193 | - return $html; |
|
194 | - } |
|
16 | + /** |
|
17 | + * Table header for display. |
|
18 | + * @since 4.8 |
|
19 | + * @param array $options |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + protected function _table_header($options) |
|
23 | + { |
|
24 | + $html = EEH_HTML::table('', '', $options['table_css_class']); |
|
25 | + $html .= EEH_HTML::thead(); |
|
26 | + $html .= EEH_HTML::tr(); |
|
27 | + $html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left'); |
|
28 | + $html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left'); |
|
29 | + $html .= EEH_HTML::th(__('Date(s)', 'event_espresso'), '', 'jst-left'); |
|
30 | + $html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr'); |
|
31 | + $html .= EEH_HTML::tbody(); |
|
32 | + return $html; |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * _item_row |
|
41 | + * |
|
42 | + * @param EE_Line_Item $line_item |
|
43 | + * @param array $options |
|
44 | + * @return mixed |
|
45 | + */ |
|
46 | + protected function _item_row(EE_Line_Item $line_item, $options = array()) |
|
47 | + { |
|
48 | + $line_item_related_object = $line_item->get_object(); |
|
49 | + $parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item |
|
50 | + ? $line_item->parent()->get_object() |
|
51 | + : null; |
|
52 | + // start of row |
|
53 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
54 | + $html = EEH_HTML::tr('', '', $row_class); |
|
55 | + |
|
56 | + |
|
57 | + // Name Column |
|
58 | + $name_link = $line_item_related_object instanceof EEI_Admin_Links ? $line_item_related_object->get_admin_details_link() : ''; |
|
59 | + |
|
60 | + // related object scope. |
|
61 | + $parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object |
|
62 | + ? $parent_line_item_related_object->name() |
|
63 | + : ''; |
|
64 | + $parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item |
|
65 | + ? $line_item->parent()->name() |
|
66 | + : $parent_related_object_name; |
|
67 | + $parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links |
|
68 | + ? $parent_line_item_related_object->get_admin_details_link() |
|
69 | + : ''; |
|
70 | + |
|
71 | + |
|
72 | + $name_html = $line_item_related_object instanceof EEI_Line_Item_Object |
|
73 | + ? $line_item_related_object->name() : $line_item->name(); |
|
74 | + $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' |
|
75 | + : $name_html; |
|
76 | + $name_html .= $line_item->is_taxable() ? ' *' : ''; |
|
77 | + // maybe preface with icon? |
|
78 | + $name_html = $line_item_related_object instanceof EEI_Has_Icon |
|
79 | + ? $line_item_related_object->get_icon() . $name_html |
|
80 | + : $name_html; |
|
81 | + $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>'; |
|
82 | + $name_html .= sprintf( |
|
83 | + _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
84 | + '<span class="ee-line-item-related-parent-object">', |
|
85 | + $line_item->parent() instanceof EE_Line_Item |
|
86 | + ? $line_item->parent()->OBJ_type_i18n() |
|
87 | + : __('Item:', 'event_espresso'), |
|
88 | + $parent_related_object_link |
|
89 | + ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' |
|
90 | + : $parent_related_object_name, |
|
91 | + '</span>' |
|
92 | + ); |
|
93 | + $html .= EEH_HTML::td($name_html, '', 'jst-left'); |
|
94 | + // Type Column |
|
95 | + $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : ''; |
|
96 | + $type_html .= $this->_get_cancellations($line_item); |
|
97 | + $type_html .= $line_item->OBJ_type() ? '<br />' : ''; |
|
98 | + $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : ''; |
|
99 | + $type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(__('Code: %s', 'event_espresso'), $code) . '</span>' : ''; |
|
100 | + $html .= EEH_HTML::td($type_html, '', 'jst-left'); |
|
101 | + |
|
102 | + // Date column |
|
103 | + $datetime_content = ''; |
|
104 | + if ($line_item_related_object instanceof EE_Ticket) { |
|
105 | + $datetimes = $line_item_related_object->datetimes(); |
|
106 | + foreach ($datetimes as $datetime) { |
|
107 | + if ($datetime instanceof EE_Datetime) { |
|
108 | + $datetime_content .= $datetime->get_dtt_display_name() . '<br>'; |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | + $html .= EEH_HTML::td($datetime_content, '', 'jst-left'); |
|
113 | + |
|
114 | + // Amount Column |
|
115 | + if ($line_item->is_percent()) { |
|
116 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'jst-rght'); |
|
117 | + } else { |
|
118 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght'); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + // finish things off and return |
|
123 | + $html .= EEH_HTML::trx(); |
|
124 | + return $html; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * _tax_row |
|
131 | + * |
|
132 | + * @param EE_Line_Item $line_item |
|
133 | + * @param array $options |
|
134 | + * @return mixed |
|
135 | + */ |
|
136 | + protected function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
137 | + { |
|
138 | + // start of row |
|
139 | + $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr'); |
|
140 | + // name th |
|
141 | + $html .= EEH_HTML::th($line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)', '', 'jst-rght', '', ' colspan="3"'); |
|
142 | + // total th |
|
143 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
144 | + // end of row |
|
145 | + $html .= EEH_HTML::trx(); |
|
146 | + return $html; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * _total_row |
|
155 | + * |
|
156 | + * @param EE_Line_Item $line_item |
|
157 | + * @param array $options |
|
158 | + * @return mixed |
|
159 | + */ |
|
160 | + protected function _total_row(EE_Line_Item $line_item, $options = array()) |
|
161 | + { |
|
162 | + |
|
163 | + $registration = isset($options['EE_Registration']) ? $options['EE_Registration'] : null; |
|
164 | + $registration_total = $registration instanceof EE_Registration ? $registration->pretty_final_price() : 0; |
|
165 | + // if no valid registration object then we're not going to show the approximate text. |
|
166 | + $total_match = $registration instanceof EE_Registration |
|
167 | + ? $registration->final_price() === $line_item->total() |
|
168 | + : true; |
|
169 | + |
|
170 | + // start of row |
|
171 | + $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr'); |
|
172 | + // Total th label |
|
173 | + if ($total_match) { |
|
174 | + $total_label = sprintf(__('This registration\'s total %s:', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')'); |
|
175 | + } else { |
|
176 | + $total_label = sprintf(__('This registration\'s approximate total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')'); |
|
177 | + $total_label .= '<br>'; |
|
178 | + $total_label .= '<p class="ee-footnote-text">' |
|
179 | + . sprintf( |
|
180 | + __('The registrations\' share of the transaction total is approximate because it might not be possible to evenly divide the transaction total among each registration, and so some registrations may need to pay a penny more than others. This registration\'s final share is actually %1$s%2$s%3$s.', 'event_espresso'), |
|
181 | + '<strong>', |
|
182 | + $registration_total, |
|
183 | + '</strong>' |
|
184 | + ) |
|
185 | + . '</p>'; |
|
186 | + } |
|
187 | + $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="3"'); |
|
188 | + // total th |
|
189 | + |
|
190 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
191 | + // end of row |
|
192 | + $html .= EEH_HTML::trx(); |
|
193 | + return $html; |
|
194 | + } |
|
195 | 195 | } |
@@ -71,22 +71,22 @@ discard block |
||
71 | 71 | |
72 | 72 | $name_html = $line_item_related_object instanceof EEI_Line_Item_Object |
73 | 73 | ? $line_item_related_object->name() : $line_item->name(); |
74 | - $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' |
|
74 | + $name_html = $name_link ? '<a href="'.$name_link.'">'.$name_html.'</a>' |
|
75 | 75 | : $name_html; |
76 | 76 | $name_html .= $line_item->is_taxable() ? ' *' : ''; |
77 | 77 | // maybe preface with icon? |
78 | 78 | $name_html = $line_item_related_object instanceof EEI_Has_Icon |
79 | - ? $line_item_related_object->get_icon() . $name_html |
|
79 | + ? $line_item_related_object->get_icon().$name_html |
|
80 | 80 | : $name_html; |
81 | - $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>'; |
|
82 | - $name_html .= sprintf( |
|
81 | + $name_html = '<span class="ee-line-item-name linked">'.$name_html.'</span><br>'; |
|
82 | + $name_html .= sprintf( |
|
83 | 83 | _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
84 | 84 | '<span class="ee-line-item-related-parent-object">', |
85 | 85 | $line_item->parent() instanceof EE_Line_Item |
86 | 86 | ? $line_item->parent()->OBJ_type_i18n() |
87 | 87 | : __('Item:', 'event_espresso'), |
88 | 88 | $parent_related_object_link |
89 | - ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' |
|
89 | + ? '<a href="'.$parent_related_object_link.'">'.$parent_related_object_name.'</a>' |
|
90 | 90 | : $parent_related_object_name, |
91 | 91 | '</span>' |
92 | 92 | ); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $type_html .= $this->_get_cancellations($line_item); |
97 | 97 | $type_html .= $line_item->OBJ_type() ? '<br />' : ''; |
98 | 98 | $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : ''; |
99 | - $type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(__('Code: %s', 'event_espresso'), $code) . '</span>' : ''; |
|
99 | + $type_html .= ! empty($code) ? '<span class="ee-line-item-id">'.sprintf(__('Code: %s', 'event_espresso'), $code).'</span>' : ''; |
|
100 | 100 | $html .= EEH_HTML::td($type_html, '', 'jst-left'); |
101 | 101 | |
102 | 102 | // Date column |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $datetimes = $line_item_related_object->datetimes(); |
106 | 106 | foreach ($datetimes as $datetime) { |
107 | 107 | if ($datetime instanceof EE_Datetime) { |
108 | - $datetime_content .= $datetime->get_dtt_display_name() . '<br>'; |
|
108 | + $datetime_content .= $datetime->get_dtt_display_name().'<br>'; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | // Amount Column |
115 | 115 | if ($line_item->is_percent()) { |
116 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'jst-rght'); |
|
116 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'jst-rght'); |
|
117 | 117 | } else { |
118 | 118 | $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght'); |
119 | 119 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | // start of row |
139 | 139 | $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr'); |
140 | 140 | // name th |
141 | - $html .= EEH_HTML::th($line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)', '', 'jst-rght', '', ' colspan="3"'); |
|
141 | + $html .= EEH_HTML::th($line_item->name().'('.$line_item->get_pretty('LIN_percent').'%)', '', 'jst-rght', '', ' colspan="3"'); |
|
142 | 142 | // total th |
143 | 143 | $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
144 | 144 | // end of row |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr'); |
172 | 172 | // Total th label |
173 | 173 | if ($total_match) { |
174 | - $total_label = sprintf(__('This registration\'s total %s:', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')'); |
|
174 | + $total_label = sprintf(__('This registration\'s total %s:', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); |
|
175 | 175 | } else { |
176 | - $total_label = sprintf(__('This registration\'s approximate total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')'); |
|
176 | + $total_label = sprintf(__('This registration\'s approximate total %s', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); |
|
177 | 177 | $total_label .= '<br>'; |
178 | 178 | $total_label .= '<p class="ee-footnote-text">' |
179 | 179 | . sprintf( |