@@ -21,150 +21,150 @@ |
||
21 | 21 | abstract class EE_Form_Section_Validatable extends EE_Form_Section_Base |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Array of validation errors in this section. Does not contain validation errors in subsections, however. |
|
26 | - * Those are stored individually on each subsection. |
|
27 | - * |
|
28 | - * @var EE_Validation_Error[] |
|
29 | - */ |
|
30 | - protected $_validation_errors = array(); |
|
31 | - |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Errors on this form section. Note: EE_Form_Section_Proper |
|
36 | - * has another function for getting all errors in this form section and subsections |
|
37 | - * called get_validation_errors_accumulated |
|
38 | - * |
|
39 | - * @return EE_Validation_Error[] |
|
40 | - */ |
|
41 | - public function get_validation_errors() |
|
42 | - { |
|
43 | - return $this->_validation_errors; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * returns a comma-separated list of all the validation errors in it. |
|
50 | - * If we want this to be customizable, we may decide to create a strategy for displaying it |
|
51 | - * |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function get_validation_error_string() |
|
55 | - { |
|
56 | - $validation_error_messages = array(); |
|
57 | - if ($this->get_validation_errors()) { |
|
58 | - foreach ($this->get_validation_errors() as $validation_error) { |
|
59 | - if ($validation_error instanceof EE_Validation_Error) { |
|
60 | - $validation_error_messages[] = $validation_error->getMessage(); |
|
61 | - } |
|
62 | - } |
|
63 | - } |
|
64 | - return implode(", ", $validation_error_messages); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Performs validation on this form section (and subsections). Should be called after _normalize() |
|
71 | - * |
|
72 | - * @return boolean of whether or not the form section is valid |
|
73 | - */ |
|
74 | - abstract protected function _validate(); |
|
75 | - |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * Checks if this field has any validation errors |
|
80 | - * |
|
81 | - * @return boolean |
|
82 | - */ |
|
83 | - public function is_valid() |
|
84 | - { |
|
85 | - if (count($this->_validation_errors)) { |
|
86 | - return false; |
|
87 | - } else { |
|
88 | - return true; |
|
89 | - } |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * Sanitizes input for this form section |
|
96 | - * |
|
97 | - * @param array $req_data is the full request data like $_POST |
|
98 | - * @return boolean of whether a normalization error occurred |
|
99 | - */ |
|
100 | - abstract protected function _normalize($req_data); |
|
101 | - |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * Creates a validation error from the arguments provided, and adds it to the form section's list. |
|
106 | - * If such an EE_Validation_Error object is passed in as the first arg, simply sets this as its form section, and |
|
107 | - * adds it to the list of validation errors of errors |
|
108 | - * |
|
109 | - * @param mixed $message_or_object internationalized string describing the validation error; or it could be a |
|
110 | - * proper EE_Validation_Error object |
|
111 | - * @param string $error_code a short key which can be used to uniquely identify the error |
|
112 | - * @param Exception $previous_exception if there was an exception that caused the error, that exception |
|
113 | - * @return void |
|
114 | - */ |
|
115 | - public function add_validation_error($message_or_object, $error_code = null, $previous_exception = null) |
|
116 | - { |
|
117 | - if ($message_or_object instanceof EE_Validation_Error) { |
|
118 | - $validation_error = $message_or_object; |
|
119 | - $validation_error->set_form_section($this); |
|
120 | - } else { |
|
121 | - $validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception); |
|
122 | - } |
|
123 | - $this->_validation_errors[] = $validation_error; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * When generating the JS for the jquery validation rules like<br> |
|
130 | - * <code>$( "#myform" ).validate({ |
|
131 | - * rules: { |
|
132 | - * password: "required", |
|
133 | - * password_again: { |
|
134 | - * equalTo: "#password" |
|
135 | - * } |
|
136 | - * } |
|
137 | - * });</code> |
|
138 | - * gets the sections like |
|
139 | - * <br><code>password: "required", |
|
140 | - * password_again: { |
|
141 | - * equalTo: "#password" |
|
142 | - * }</code> |
|
143 | - * except we leave it as a PHP object, and leave wp_localize_script to |
|
144 | - * turn it into a JSON object which can be used by the js |
|
145 | - * |
|
146 | - * @return array |
|
147 | - */ |
|
148 | - abstract public function get_jquery_validation_rules(); |
|
149 | - |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * Checks if this form section's data is present in the req data specified |
|
154 | - * |
|
155 | - * @param array $req_data usually $_POST, if null that's what's used |
|
156 | - * @return boolean |
|
157 | - */ |
|
158 | - abstract public function form_data_present_in($req_data = null); |
|
159 | - |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * Removes teh sensitive data from this form section (usually done after |
|
164 | - * utilizing the data business function, but before saving it somewhere. Eg, |
|
165 | - * may remove a password from the form after verifying it was correct) |
|
166 | - * |
|
167 | - * @return void |
|
168 | - */ |
|
169 | - abstract public function clean_sensitive_data(); |
|
24 | + /** |
|
25 | + * Array of validation errors in this section. Does not contain validation errors in subsections, however. |
|
26 | + * Those are stored individually on each subsection. |
|
27 | + * |
|
28 | + * @var EE_Validation_Error[] |
|
29 | + */ |
|
30 | + protected $_validation_errors = array(); |
|
31 | + |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Errors on this form section. Note: EE_Form_Section_Proper |
|
36 | + * has another function for getting all errors in this form section and subsections |
|
37 | + * called get_validation_errors_accumulated |
|
38 | + * |
|
39 | + * @return EE_Validation_Error[] |
|
40 | + */ |
|
41 | + public function get_validation_errors() |
|
42 | + { |
|
43 | + return $this->_validation_errors; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * returns a comma-separated list of all the validation errors in it. |
|
50 | + * If we want this to be customizable, we may decide to create a strategy for displaying it |
|
51 | + * |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function get_validation_error_string() |
|
55 | + { |
|
56 | + $validation_error_messages = array(); |
|
57 | + if ($this->get_validation_errors()) { |
|
58 | + foreach ($this->get_validation_errors() as $validation_error) { |
|
59 | + if ($validation_error instanceof EE_Validation_Error) { |
|
60 | + $validation_error_messages[] = $validation_error->getMessage(); |
|
61 | + } |
|
62 | + } |
|
63 | + } |
|
64 | + return implode(", ", $validation_error_messages); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Performs validation on this form section (and subsections). Should be called after _normalize() |
|
71 | + * |
|
72 | + * @return boolean of whether or not the form section is valid |
|
73 | + */ |
|
74 | + abstract protected function _validate(); |
|
75 | + |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * Checks if this field has any validation errors |
|
80 | + * |
|
81 | + * @return boolean |
|
82 | + */ |
|
83 | + public function is_valid() |
|
84 | + { |
|
85 | + if (count($this->_validation_errors)) { |
|
86 | + return false; |
|
87 | + } else { |
|
88 | + return true; |
|
89 | + } |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * Sanitizes input for this form section |
|
96 | + * |
|
97 | + * @param array $req_data is the full request data like $_POST |
|
98 | + * @return boolean of whether a normalization error occurred |
|
99 | + */ |
|
100 | + abstract protected function _normalize($req_data); |
|
101 | + |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * Creates a validation error from the arguments provided, and adds it to the form section's list. |
|
106 | + * If such an EE_Validation_Error object is passed in as the first arg, simply sets this as its form section, and |
|
107 | + * adds it to the list of validation errors of errors |
|
108 | + * |
|
109 | + * @param mixed $message_or_object internationalized string describing the validation error; or it could be a |
|
110 | + * proper EE_Validation_Error object |
|
111 | + * @param string $error_code a short key which can be used to uniquely identify the error |
|
112 | + * @param Exception $previous_exception if there was an exception that caused the error, that exception |
|
113 | + * @return void |
|
114 | + */ |
|
115 | + public function add_validation_error($message_or_object, $error_code = null, $previous_exception = null) |
|
116 | + { |
|
117 | + if ($message_or_object instanceof EE_Validation_Error) { |
|
118 | + $validation_error = $message_or_object; |
|
119 | + $validation_error->set_form_section($this); |
|
120 | + } else { |
|
121 | + $validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception); |
|
122 | + } |
|
123 | + $this->_validation_errors[] = $validation_error; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * When generating the JS for the jquery validation rules like<br> |
|
130 | + * <code>$( "#myform" ).validate({ |
|
131 | + * rules: { |
|
132 | + * password: "required", |
|
133 | + * password_again: { |
|
134 | + * equalTo: "#password" |
|
135 | + * } |
|
136 | + * } |
|
137 | + * });</code> |
|
138 | + * gets the sections like |
|
139 | + * <br><code>password: "required", |
|
140 | + * password_again: { |
|
141 | + * equalTo: "#password" |
|
142 | + * }</code> |
|
143 | + * except we leave it as a PHP object, and leave wp_localize_script to |
|
144 | + * turn it into a JSON object which can be used by the js |
|
145 | + * |
|
146 | + * @return array |
|
147 | + */ |
|
148 | + abstract public function get_jquery_validation_rules(); |
|
149 | + |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * Checks if this form section's data is present in the req data specified |
|
154 | + * |
|
155 | + * @param array $req_data usually $_POST, if null that's what's used |
|
156 | + * @return boolean |
|
157 | + */ |
|
158 | + abstract public function form_data_present_in($req_data = null); |
|
159 | + |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * Removes teh sensitive data from this form section (usually done after |
|
164 | + * utilizing the data business function, but before saving it somewhere. Eg, |
|
165 | + * may remove a password from the form after verifying it was correct) |
|
166 | + * |
|
167 | + * @return void |
|
168 | + */ |
|
169 | + abstract public function clean_sensitive_data(); |
|
170 | 170 | } |
@@ -14,74 +14,74 @@ |
||
14 | 14 | class EE_Billing_Info_Form extends EE_Form_Section_Proper |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * The payment method this billing form is for |
|
19 | - * @var EE_Payment_Method |
|
20 | - */ |
|
21 | - protected $_pm_instance; |
|
22 | - |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * |
|
27 | - * @param EE_Payment_Method $payment_method |
|
28 | - * @param array $options_array @see EE_Form_Section_Proper::__construct() |
|
29 | - */ |
|
30 | - public function __construct(EE_Payment_Method $payment_method, $options_array = array()) |
|
31 | - { |
|
32 | - $this->_pm_instance = $payment_method; |
|
33 | - $this->_layout_strategy = new EE_Div_Per_Section_Layout(); |
|
34 | - parent::__construct($options_array); |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * Sets the payment method for this billing form |
|
41 | - * @param EE_Payment_Method $payment_method |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public function set_payment_method(EE_Payment_Method $payment_method) |
|
45 | - { |
|
46 | - $this->_pm_instance = $payment_method; |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Returns the instance of the payment method this billing form is for |
|
53 | - * @return EE_Payment_Method |
|
54 | - */ |
|
55 | - public function payment_method() |
|
56 | - { |
|
57 | - return $this->_pm_instance; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * payment_fields_autofilled_notice_html |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function payment_fields_autofilled_notice_html() |
|
67 | - { |
|
68 | - return new EE_Form_Section_HTML( |
|
69 | - EEH_HTML::p( |
|
70 | - apply_filters('FHEE__EE_Billing_Info_Form__payment_fields_autofilled_notice_html_text', __('Payment fields have been autofilled because you are in debug mode', 'event_espresso')), |
|
71 | - '', |
|
72 | - 'important-notice' |
|
73 | - ) |
|
74 | - ); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function html_class() |
|
83 | - { |
|
84 | - return ! empty($this->_html_class) ? $this->_html_class . ' ee-billing-form' : 'ee-billing-form'; |
|
85 | - } |
|
17 | + /** |
|
18 | + * The payment method this billing form is for |
|
19 | + * @var EE_Payment_Method |
|
20 | + */ |
|
21 | + protected $_pm_instance; |
|
22 | + |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * |
|
27 | + * @param EE_Payment_Method $payment_method |
|
28 | + * @param array $options_array @see EE_Form_Section_Proper::__construct() |
|
29 | + */ |
|
30 | + public function __construct(EE_Payment_Method $payment_method, $options_array = array()) |
|
31 | + { |
|
32 | + $this->_pm_instance = $payment_method; |
|
33 | + $this->_layout_strategy = new EE_Div_Per_Section_Layout(); |
|
34 | + parent::__construct($options_array); |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * Sets the payment method for this billing form |
|
41 | + * @param EE_Payment_Method $payment_method |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public function set_payment_method(EE_Payment_Method $payment_method) |
|
45 | + { |
|
46 | + $this->_pm_instance = $payment_method; |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Returns the instance of the payment method this billing form is for |
|
53 | + * @return EE_Payment_Method |
|
54 | + */ |
|
55 | + public function payment_method() |
|
56 | + { |
|
57 | + return $this->_pm_instance; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * payment_fields_autofilled_notice_html |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function payment_fields_autofilled_notice_html() |
|
67 | + { |
|
68 | + return new EE_Form_Section_HTML( |
|
69 | + EEH_HTML::p( |
|
70 | + apply_filters('FHEE__EE_Billing_Info_Form__payment_fields_autofilled_notice_html_text', __('Payment fields have been autofilled because you are in debug mode', 'event_espresso')), |
|
71 | + '', |
|
72 | + 'important-notice' |
|
73 | + ) |
|
74 | + ); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function html_class() |
|
83 | + { |
|
84 | + return ! empty($this->_html_class) ? $this->_html_class . ' ee-billing-form' : 'ee-billing-form'; |
|
85 | + } |
|
86 | 86 | } |
87 | 87 | // End of file EE_Billing_Info_Form.form.php |
@@ -81,7 +81,7 @@ |
||
81 | 81 | */ |
82 | 82 | public function html_class() |
83 | 83 | { |
84 | - return ! empty($this->_html_class) ? $this->_html_class . ' ee-billing-form' : 'ee-billing-form'; |
|
84 | + return ! empty($this->_html_class) ? $this->_html_class.' ee-billing-form' : 'ee-billing-form'; |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | // End of file EE_Billing_Info_Form.form.php |
@@ -9,195 +9,195 @@ |
||
9 | 9 | class EE_Payment_Method_Form extends EE_Model_Form_Section |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * All the subsection inputs that correspond ot extra meta rows |
|
14 | - * for this payment method |
|
15 | - * |
|
16 | - * @var EE_Form_Input_Base[] |
|
17 | - */ |
|
18 | - protected $_extra_meta_inputs = array(); |
|
19 | - |
|
20 | - /** |
|
21 | - * Because payment method form might DELAY part of construction, we want to remember |
|
22 | - * what options were passed in |
|
23 | - * |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - protected $_options_array = array(); |
|
27 | - |
|
28 | - /** |
|
29 | - * The payment method type for this form |
|
30 | - * |
|
31 | - * @var EE_PMT_Base |
|
32 | - */ |
|
33 | - protected $_payment_method_type; |
|
34 | - |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @param array $options_array { |
|
39 | - * @type string $extra_meta_inputs should be EE_Form_Section_Validatable[] which |
|
40 | - * will be _subsections and will be saved as extra meta on the payment |
|
41 | - * method object; |
|
42 | - * @type EE_PMT_Base $payment_method_type the payment method type this form is for |
|
43 | - * @see EE_Model_Form_Section::__construct() for more |
|
44 | - * } |
|
45 | - */ |
|
46 | - public function __construct($options_array = array()) |
|
47 | - { |
|
48 | - $this->_model = EEM_Payment_Method::instance(); |
|
49 | - $this->_options_array = $options_array; |
|
50 | - if (isset($options_array['payment_method_type'])) { |
|
51 | - $this->_payment_method_type = $options_array['payment_method_type']; |
|
52 | - } |
|
53 | - $options_array = $this->_options_array; |
|
54 | - if (isset($options_array['extra_meta_inputs'])) { |
|
55 | - $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']); |
|
56 | - } |
|
57 | - if ($this->_extra_meta_inputs) { |
|
58 | - $this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs); |
|
59 | - } |
|
60 | - $this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input( |
|
61 | - array('html_label_text' => __('Button URL', 'event_espresso')) |
|
62 | - ); |
|
63 | - $this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input( |
|
64 | - EEM_Payment_Method::instance()->scopes(), |
|
65 | - array( |
|
66 | - 'html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename() |
|
67 | - . EEH_Template::get_help_tab_link('payment_methods_overview'), |
|
68 | - ) |
|
69 | - ); |
|
70 | - // setup the currency options |
|
71 | - $this->_subsections['Currency'] = new EE_Select_Multi_Model_Input( |
|
72 | - EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type), |
|
73 | - array( |
|
74 | - 'html_label_text' => __('Currencies Supported', 'event_espresso'), |
|
75 | - 'required' => true, |
|
76 | - ) |
|
77 | - ); |
|
78 | - $this->_subsections['PMD_order'] = new EE_Text_Input(array( |
|
79 | - 'html_label_text' => __('Order', 'event_espresso'), |
|
80 | - 'html_help_text' => __('Lowest numbers will be shown first', 'event_espresso'), |
|
81 | - 'normalization_strategy' => new EE_Int_Normalization(), |
|
82 | - 'validation_strategies' => array( |
|
83 | - new EE_Int_Validation_Strategy(), |
|
84 | - ), |
|
85 | - 'default' => 0, |
|
86 | - )); |
|
87 | - $this->_layout_strategy = new EE_Admin_Two_Column_Layout(); |
|
88 | - parent::__construct($options_array); |
|
89 | - $debug_mode = isset($this->_subsections['PMD_debug_mode']) ? $this->_subsections['PMD_debug_mode'] : null; |
|
90 | - if ($debug_mode instanceof EE_Form_Input_Base) { |
|
91 | - $debug_mode->set_html_help_text(__( |
|
92 | - 'This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.', |
|
93 | - 'event_espresso' |
|
94 | - )); |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * Finishes construction given the parent form section and this form section's name |
|
102 | - * |
|
103 | - * @param EE_Form_Section_Proper $parent_form_section |
|
104 | - * @param string $name |
|
105 | - * @throws EE_Error |
|
106 | - */ |
|
107 | - public function _construct_finalize($parent_form_section, $name) |
|
108 | - { |
|
109 | - if (! $this->_payment_method_type instanceof EE_PMT_Base) { |
|
110 | - throw new EE_Error(sprintf(__( |
|
111 | - 'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', |
|
112 | - 'event_espresso' |
|
113 | - ))); |
|
114 | - } |
|
115 | - // set the name of this form based on the payment method type |
|
116 | - if (! $this->_name && ! $name) { |
|
117 | - $name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name())))) |
|
118 | - . "_Settings_Form"; |
|
119 | - } |
|
120 | - parent::_construct_finalize($parent_form_section, $name); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @param $payment_method_type |
|
127 | - * @throws EE_Error |
|
128 | - */ |
|
129 | - public function set_payment_method_type($payment_method_type) |
|
130 | - { |
|
131 | - if (! $payment_method_type instanceof EE_PMT_Base) { |
|
132 | - throw new EE_Error(sprintf(__( |
|
133 | - "Payment Method forms MUST set a payment method type by using _set_payment_method_type", |
|
134 | - "event_espresso" |
|
135 | - ))); |
|
136 | - } |
|
137 | - $this->_payment_method_type = $payment_method_type; |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * extends the model form section's save method to also save the extra meta field values |
|
144 | - * |
|
145 | - * @return int ID of the payment method inserted, or true on update |
|
146 | - */ |
|
147 | - public function save() |
|
148 | - { |
|
149 | - $parent_save_val = parent::save(); |
|
150 | - if ($this->_model_object && $this->_model_object->ID()) { |
|
151 | - foreach ($this->_extra_meta_inputs as $input_name => $input) { |
|
152 | - $this->_model_object->update_extra_meta($input_name, $input->normalized_value()); |
|
153 | - } |
|
154 | - } |
|
155 | - return $parent_save_val; |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * Overrides parent's populate_model_obj to also populate the extra meta fields |
|
162 | - * |
|
163 | - * @param EE_Base_Class $model_obj |
|
164 | - */ |
|
165 | - public function populate_model_obj($model_obj) |
|
166 | - { |
|
167 | - $model_obj = $this->_model->ensure_is_obj($model_obj); |
|
168 | - parent::populate_model_obj($model_obj); |
|
169 | - $extra_meta = $model_obj->all_extra_meta_array(); |
|
170 | - foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) { |
|
171 | - if (isset($extra_meta[ $input_name ])) { |
|
172 | - $extra_meta_input->set_default($extra_meta[ $input_name ]); |
|
173 | - } |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * gets the default name of this form section if none is specified |
|
181 | - * |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - protected function _set_default_name_if_empty() |
|
185 | - { |
|
186 | - if (! $this->_name) { |
|
187 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
188 | - $this->_name = $default_name; |
|
189 | - } |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * Gets all the extra meta inputs in this form |
|
196 | - * |
|
197 | - * @return EE_Form_Input_Base[] |
|
198 | - */ |
|
199 | - public function extra_meta_inputs() |
|
200 | - { |
|
201 | - return $this->_extra_meta_inputs; |
|
202 | - } |
|
12 | + /** |
|
13 | + * All the subsection inputs that correspond ot extra meta rows |
|
14 | + * for this payment method |
|
15 | + * |
|
16 | + * @var EE_Form_Input_Base[] |
|
17 | + */ |
|
18 | + protected $_extra_meta_inputs = array(); |
|
19 | + |
|
20 | + /** |
|
21 | + * Because payment method form might DELAY part of construction, we want to remember |
|
22 | + * what options were passed in |
|
23 | + * |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + protected $_options_array = array(); |
|
27 | + |
|
28 | + /** |
|
29 | + * The payment method type for this form |
|
30 | + * |
|
31 | + * @var EE_PMT_Base |
|
32 | + */ |
|
33 | + protected $_payment_method_type; |
|
34 | + |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @param array $options_array { |
|
39 | + * @type string $extra_meta_inputs should be EE_Form_Section_Validatable[] which |
|
40 | + * will be _subsections and will be saved as extra meta on the payment |
|
41 | + * method object; |
|
42 | + * @type EE_PMT_Base $payment_method_type the payment method type this form is for |
|
43 | + * @see EE_Model_Form_Section::__construct() for more |
|
44 | + * } |
|
45 | + */ |
|
46 | + public function __construct($options_array = array()) |
|
47 | + { |
|
48 | + $this->_model = EEM_Payment_Method::instance(); |
|
49 | + $this->_options_array = $options_array; |
|
50 | + if (isset($options_array['payment_method_type'])) { |
|
51 | + $this->_payment_method_type = $options_array['payment_method_type']; |
|
52 | + } |
|
53 | + $options_array = $this->_options_array; |
|
54 | + if (isset($options_array['extra_meta_inputs'])) { |
|
55 | + $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']); |
|
56 | + } |
|
57 | + if ($this->_extra_meta_inputs) { |
|
58 | + $this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs); |
|
59 | + } |
|
60 | + $this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input( |
|
61 | + array('html_label_text' => __('Button URL', 'event_espresso')) |
|
62 | + ); |
|
63 | + $this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input( |
|
64 | + EEM_Payment_Method::instance()->scopes(), |
|
65 | + array( |
|
66 | + 'html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename() |
|
67 | + . EEH_Template::get_help_tab_link('payment_methods_overview'), |
|
68 | + ) |
|
69 | + ); |
|
70 | + // setup the currency options |
|
71 | + $this->_subsections['Currency'] = new EE_Select_Multi_Model_Input( |
|
72 | + EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type), |
|
73 | + array( |
|
74 | + 'html_label_text' => __('Currencies Supported', 'event_espresso'), |
|
75 | + 'required' => true, |
|
76 | + ) |
|
77 | + ); |
|
78 | + $this->_subsections['PMD_order'] = new EE_Text_Input(array( |
|
79 | + 'html_label_text' => __('Order', 'event_espresso'), |
|
80 | + 'html_help_text' => __('Lowest numbers will be shown first', 'event_espresso'), |
|
81 | + 'normalization_strategy' => new EE_Int_Normalization(), |
|
82 | + 'validation_strategies' => array( |
|
83 | + new EE_Int_Validation_Strategy(), |
|
84 | + ), |
|
85 | + 'default' => 0, |
|
86 | + )); |
|
87 | + $this->_layout_strategy = new EE_Admin_Two_Column_Layout(); |
|
88 | + parent::__construct($options_array); |
|
89 | + $debug_mode = isset($this->_subsections['PMD_debug_mode']) ? $this->_subsections['PMD_debug_mode'] : null; |
|
90 | + if ($debug_mode instanceof EE_Form_Input_Base) { |
|
91 | + $debug_mode->set_html_help_text(__( |
|
92 | + 'This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.', |
|
93 | + 'event_espresso' |
|
94 | + )); |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * Finishes construction given the parent form section and this form section's name |
|
102 | + * |
|
103 | + * @param EE_Form_Section_Proper $parent_form_section |
|
104 | + * @param string $name |
|
105 | + * @throws EE_Error |
|
106 | + */ |
|
107 | + public function _construct_finalize($parent_form_section, $name) |
|
108 | + { |
|
109 | + if (! $this->_payment_method_type instanceof EE_PMT_Base) { |
|
110 | + throw new EE_Error(sprintf(__( |
|
111 | + 'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', |
|
112 | + 'event_espresso' |
|
113 | + ))); |
|
114 | + } |
|
115 | + // set the name of this form based on the payment method type |
|
116 | + if (! $this->_name && ! $name) { |
|
117 | + $name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name())))) |
|
118 | + . "_Settings_Form"; |
|
119 | + } |
|
120 | + parent::_construct_finalize($parent_form_section, $name); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @param $payment_method_type |
|
127 | + * @throws EE_Error |
|
128 | + */ |
|
129 | + public function set_payment_method_type($payment_method_type) |
|
130 | + { |
|
131 | + if (! $payment_method_type instanceof EE_PMT_Base) { |
|
132 | + throw new EE_Error(sprintf(__( |
|
133 | + "Payment Method forms MUST set a payment method type by using _set_payment_method_type", |
|
134 | + "event_espresso" |
|
135 | + ))); |
|
136 | + } |
|
137 | + $this->_payment_method_type = $payment_method_type; |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * extends the model form section's save method to also save the extra meta field values |
|
144 | + * |
|
145 | + * @return int ID of the payment method inserted, or true on update |
|
146 | + */ |
|
147 | + public function save() |
|
148 | + { |
|
149 | + $parent_save_val = parent::save(); |
|
150 | + if ($this->_model_object && $this->_model_object->ID()) { |
|
151 | + foreach ($this->_extra_meta_inputs as $input_name => $input) { |
|
152 | + $this->_model_object->update_extra_meta($input_name, $input->normalized_value()); |
|
153 | + } |
|
154 | + } |
|
155 | + return $parent_save_val; |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * Overrides parent's populate_model_obj to also populate the extra meta fields |
|
162 | + * |
|
163 | + * @param EE_Base_Class $model_obj |
|
164 | + */ |
|
165 | + public function populate_model_obj($model_obj) |
|
166 | + { |
|
167 | + $model_obj = $this->_model->ensure_is_obj($model_obj); |
|
168 | + parent::populate_model_obj($model_obj); |
|
169 | + $extra_meta = $model_obj->all_extra_meta_array(); |
|
170 | + foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) { |
|
171 | + if (isset($extra_meta[ $input_name ])) { |
|
172 | + $extra_meta_input->set_default($extra_meta[ $input_name ]); |
|
173 | + } |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * gets the default name of this form section if none is specified |
|
181 | + * |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + protected function _set_default_name_if_empty() |
|
185 | + { |
|
186 | + if (! $this->_name) { |
|
187 | + $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
188 | + $this->_name = $default_name; |
|
189 | + } |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * Gets all the extra meta inputs in this form |
|
196 | + * |
|
197 | + * @return EE_Form_Input_Base[] |
|
198 | + */ |
|
199 | + public function extra_meta_inputs() |
|
200 | + { |
|
201 | + return $this->_extra_meta_inputs; |
|
202 | + } |
|
203 | 203 | } |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function _construct_finalize($parent_form_section, $name) |
108 | 108 | { |
109 | - if (! $this->_payment_method_type instanceof EE_PMT_Base) { |
|
109 | + if ( ! $this->_payment_method_type instanceof EE_PMT_Base) { |
|
110 | 110 | throw new EE_Error(sprintf(__( |
111 | 111 | 'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', |
112 | 112 | 'event_espresso' |
113 | 113 | ))); |
114 | 114 | } |
115 | 115 | // set the name of this form based on the payment method type |
116 | - if (! $this->_name && ! $name) { |
|
116 | + if ( ! $this->_name && ! $name) { |
|
117 | 117 | $name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name())))) |
118 | 118 | . "_Settings_Form"; |
119 | 119 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function set_payment_method_type($payment_method_type) |
130 | 130 | { |
131 | - if (! $payment_method_type instanceof EE_PMT_Base) { |
|
131 | + if ( ! $payment_method_type instanceof EE_PMT_Base) { |
|
132 | 132 | throw new EE_Error(sprintf(__( |
133 | 133 | "Payment Method forms MUST set a payment method type by using _set_payment_method_type", |
134 | 134 | "event_espresso" |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | parent::populate_model_obj($model_obj); |
169 | 169 | $extra_meta = $model_obj->all_extra_meta_array(); |
170 | 170 | foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) { |
171 | - if (isset($extra_meta[ $input_name ])) { |
|
172 | - $extra_meta_input->set_default($extra_meta[ $input_name ]); |
|
171 | + if (isset($extra_meta[$input_name])) { |
|
172 | + $extra_meta_input->set_default($extra_meta[$input_name]); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | */ |
184 | 184 | protected function _set_default_name_if_empty() |
185 | 185 | { |
186 | - if (! $this->_name) { |
|
187 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
186 | + if ( ! $this->_name) { |
|
187 | + $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form"; |
|
188 | 188 | $this->_name = $default_name; |
189 | 189 | } |
190 | 190 | } |
@@ -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 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | public function set_settings($settings_array) |
188 | 188 | { |
189 | 189 | foreach ($settings_array as $name => $value) { |
190 | - $property_name = "_" . $name; |
|
190 | + $property_name = "_".$name; |
|
191 | 191 | $this->{$property_name} = $value; |
192 | 192 | } |
193 | 193 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function set_gateway_data_formatter(GatewayDataFormatterInterface $gateway_data_formatter) |
253 | 253 | { |
254 | - if (! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
254 | + if ( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
255 | 255 | throw new InvalidEntityException( |
256 | 256 | is_object($gateway_data_formatter) |
257 | 257 | ? get_class($gateway_data_formatter) |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | */ |
271 | 271 | protected function _get_gateway_formatter() |
272 | 272 | { |
273 | - if (! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
273 | + if ( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
274 | 274 | throw new InvalidEntityException( |
275 | 275 | is_object($this->_gateway_data_formatter) |
276 | 276 | ? get_class($this->_gateway_data_formatter) |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function set_unsupported_character_remover(FormatterInterface $formatter) |
293 | 293 | { |
294 | - if (! $formatter instanceof FormatterInterface) { |
|
294 | + if ( ! $formatter instanceof FormatterInterface) { |
|
295 | 295 | throw new InvalidEntityException( |
296 | 296 | is_object($formatter) |
297 | 297 | ? get_class($formatter) |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | */ |
311 | 311 | protected function _get_unsupported_character_remover() |
312 | 312 | { |
313 | - if (! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
313 | + if ( ! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
314 | 314 | throw new InvalidEntityException( |
315 | 315 | is_object($this->_unsupported_character_remover) |
316 | 316 | ? get_class($this->_unsupported_character_remover) |
@@ -23,495 +23,495 @@ |
||
23 | 23 | */ |
24 | 24 | abstract class EE_Gateway |
25 | 25 | { |
26 | - /** |
|
27 | - * a constant used as a possible value for $_currencies_supported to indicate |
|
28 | - * that ALL currencies are supported by this gateway |
|
29 | - */ |
|
30 | - const all_currencies_supported = 'all_currencies_supported'; |
|
31 | - /** |
|
32 | - * Where values are 3-letter currency codes |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - protected $_currencies_supported = array(); |
|
37 | - /** |
|
38 | - * Whether or not this gateway can support SENDING a refund request (ie, initiated by |
|
39 | - * admin in EE's wp-admin page) |
|
40 | - * |
|
41 | - * @var boolean |
|
42 | - */ |
|
43 | - protected $_supports_sending_refunds = false; |
|
44 | - |
|
45 | - /** |
|
46 | - * Whether or not this gateway can support RECEIVING a refund request from the payment |
|
47 | - * provider (ie, initiated by admin on the payment prover's website who sends an IPN to EE) |
|
48 | - * |
|
49 | - * @var boolean |
|
50 | - */ |
|
51 | - protected $_supports_receiving_refunds = false; |
|
52 | - /** |
|
53 | - * Model for querying for existing payments |
|
54 | - * |
|
55 | - * @var EEMI_Payment |
|
56 | - */ |
|
57 | - protected $_pay_model; |
|
58 | - |
|
59 | - /** |
|
60 | - * Model used for adding to the payments log |
|
61 | - * |
|
62 | - * @var EEMI_Payment_Log |
|
63 | - */ |
|
64 | - protected $_pay_log; |
|
65 | - |
|
66 | - /** |
|
67 | - * Used for formatting some input to gateways |
|
68 | - * |
|
69 | - * @var EEHI_Template |
|
70 | - */ |
|
71 | - protected $_template; |
|
72 | - |
|
73 | - /** |
|
74 | - * Concrete class that implements EEHI_Money, used by most gateways |
|
75 | - * |
|
76 | - * @var EEHI_Money |
|
77 | - */ |
|
78 | - protected $_money; |
|
79 | - |
|
80 | - /** |
|
81 | - * Concrete class that implements EEHI_Line_Item, used for manipulating the line item tree |
|
82 | - * |
|
83 | - * @var EEHI_Line_Item |
|
84 | - */ |
|
85 | - protected $_line_item; |
|
86 | - |
|
87 | - /** |
|
88 | - * @var GatewayDataFormatterInterface |
|
89 | - */ |
|
90 | - protected $_gateway_data_formatter; |
|
91 | - |
|
92 | - /** |
|
93 | - * @var FormatterInterface |
|
94 | - */ |
|
95 | - protected $_unsupported_character_remover; |
|
96 | - |
|
97 | - /** |
|
98 | - * The ID of the payment method using this gateway |
|
99 | - * |
|
100 | - * @var int |
|
101 | - */ |
|
102 | - protected $_ID; |
|
103 | - |
|
104 | - /** |
|
105 | - * @var $_debug_mode boolean whether to send requests to teh sandbox site or not |
|
106 | - */ |
|
107 | - protected $_debug_mode; |
|
108 | - /** |
|
109 | - * |
|
110 | - * @var string $_name name to show for this payment method |
|
111 | - */ |
|
112 | - protected $_name; |
|
113 | - /** |
|
114 | - * |
|
115 | - * @var string name to show fir this payment method to admin-type users |
|
116 | - */ |
|
117 | - protected $_admin_name; |
|
118 | - |
|
119 | - /** |
|
120 | - * @return EE_Gateway |
|
121 | - */ |
|
122 | - public function __construct() |
|
123 | - { |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * We don't want to serialize models as they often have circular structures |
|
128 | - * (eg a payment model has a reference to each payment model object; and most |
|
129 | - * payments have a transaction, most transactions have a payment method; |
|
130 | - * most payment methods have a payment method type; most payment method types |
|
131 | - * have a gateway. And if a gateway serializes its models, we start at the |
|
132 | - * beginning again) |
|
133 | - * |
|
134 | - * @return array |
|
135 | - */ |
|
136 | - public function __sleep() |
|
137 | - { |
|
138 | - $properties = get_object_vars($this); |
|
139 | - unset($properties['_pay_model'], $properties['_pay_log']); |
|
140 | - return array_keys($properties); |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Returns whether or not this gateway should support SENDING refunds |
|
145 | - * see $_supports_sending_refunds |
|
146 | - * |
|
147 | - * @return boolean |
|
148 | - */ |
|
149 | - public function supports_sending_refunds() |
|
150 | - { |
|
151 | - return $this->_supports_sending_refunds; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Returns whether or not this gateway should support RECEIVING refunds |
|
156 | - * see $_supports_receiving_refunds |
|
157 | - * |
|
158 | - * @return boolean |
|
159 | - */ |
|
160 | - public function supports_receiving_refunds() |
|
161 | - { |
|
162 | - return $this->_supports_receiving_refunds; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * Tries to refund the payment specified, taking into account the extra |
|
168 | - * refund info. Note that if the gateway's _supports_sending_refunds is false, |
|
169 | - * this should just throw an exception. |
|
170 | - * |
|
171 | - * @param EE_Payment $payment |
|
172 | - * @param array $refund_info |
|
173 | - * @return EE_Payment for the refund |
|
174 | - * @throws EE_Error |
|
175 | - */ |
|
176 | - public function do_direct_refund(EE_Payment $payment, $refund_info = null) |
|
177 | - { |
|
178 | - return null; |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * Sets the payment method's settings so the gateway knows where to send the request |
|
184 | - * etc |
|
185 | - * |
|
186 | - * @param array $settings_array |
|
187 | - */ |
|
188 | - public function set_settings($settings_array) |
|
189 | - { |
|
190 | - foreach ($settings_array as $name => $value) { |
|
191 | - $property_name = "_" . $name; |
|
192 | - $this->{$property_name} = $value; |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * See this class description |
|
198 | - * |
|
199 | - * @param EEMI_Payment $payment_model |
|
200 | - */ |
|
201 | - public function set_payment_model($payment_model) |
|
202 | - { |
|
203 | - $this->_pay_model = $payment_model; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * See this class description |
|
208 | - * |
|
209 | - * @param EEMI_Payment_Log $payment_log_model |
|
210 | - */ |
|
211 | - public function set_payment_log($payment_log_model) |
|
212 | - { |
|
213 | - $this->_pay_log = $payment_log_model; |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * See this class description |
|
218 | - * |
|
219 | - * @param EEHI_Template $template_helper |
|
220 | - */ |
|
221 | - public function set_template_helper($template_helper) |
|
222 | - { |
|
223 | - $this->_template = $template_helper; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * See this class description |
|
228 | - * |
|
229 | - * @param EEHI_Line_Item $line_item_helper |
|
230 | - */ |
|
231 | - public function set_line_item_helper($line_item_helper) |
|
232 | - { |
|
233 | - $this->_line_item = $line_item_helper; |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * See this class description |
|
238 | - * |
|
239 | - * @param EEHI_Money $money_helper |
|
240 | - */ |
|
241 | - public function set_money_helper($money_helper) |
|
242 | - { |
|
243 | - $this->_money = $money_helper; |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * Sets the gateway data formatter helper |
|
249 | - * |
|
250 | - * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
251 | - * @throws InvalidEntityException if it's not set properly |
|
252 | - */ |
|
253 | - public function set_gateway_data_formatter(GatewayDataFormatterInterface $gateway_data_formatter) |
|
254 | - { |
|
255 | - if (! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
256 | - throw new InvalidEntityException( |
|
257 | - is_object($gateway_data_formatter) |
|
258 | - ? get_class($gateway_data_formatter) |
|
259 | - : esc_html__('Not an object', 'event_espresso'), |
|
260 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
261 | - ); |
|
262 | - } |
|
263 | - $this->_gateway_data_formatter = $gateway_data_formatter; |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * Gets the gateway data formatter |
|
268 | - * |
|
269 | - * @return GatewayDataFormatterInterface |
|
270 | - * @throws InvalidEntityException if it's not set properly |
|
271 | - */ |
|
272 | - protected function _get_gateway_formatter() |
|
273 | - { |
|
274 | - if (! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
275 | - throw new InvalidEntityException( |
|
276 | - is_object($this->_gateway_data_formatter) |
|
277 | - ? get_class($this->_gateway_data_formatter) |
|
278 | - : esc_html__('Not an object', 'event_espresso'), |
|
279 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
280 | - ); |
|
281 | - } |
|
282 | - return $this->_gateway_data_formatter; |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * Sets the helper which will remove unsupported characters for most gateways |
|
288 | - * |
|
289 | - * @param FormatterInterface $formatter |
|
290 | - * @return FormatterInterface |
|
291 | - * @throws InvalidEntityException |
|
292 | - */ |
|
293 | - public function set_unsupported_character_remover(FormatterInterface $formatter) |
|
294 | - { |
|
295 | - if (! $formatter instanceof FormatterInterface) { |
|
296 | - throw new InvalidEntityException( |
|
297 | - is_object($formatter) |
|
298 | - ? get_class($formatter) |
|
299 | - : esc_html__('Not an object', 'event_espresso'), |
|
300 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
301 | - ); |
|
302 | - } |
|
303 | - $this->_unsupported_character_remover = $formatter; |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
308 | - * |
|
309 | - * @return FormatterInterface |
|
310 | - * @throws InvalidEntityException |
|
311 | - */ |
|
312 | - protected function _get_unsupported_character_remover() |
|
313 | - { |
|
314 | - if (! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
315 | - throw new InvalidEntityException( |
|
316 | - is_object($this->_unsupported_character_remover) |
|
317 | - ? get_class($this->_unsupported_character_remover) |
|
318 | - : esc_html__('Not an object', 'event_espresso'), |
|
319 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
320 | - ); |
|
321 | - } |
|
322 | - return $this->_unsupported_character_remover; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * @param $message |
|
328 | - * @param $payment |
|
329 | - */ |
|
330 | - public function log($message, $object_logged) |
|
331 | - { |
|
332 | - if ($object_logged instanceof EEI_Payment) { |
|
333 | - $type = 'Payment'; |
|
334 | - $id = $object_logged->ID(); |
|
335 | - } elseif ($object_logged instanceof EEI_Transaction) { |
|
336 | - $type = 'Transaction'; |
|
337 | - $id = $object_logged->ID(); |
|
338 | - } else { |
|
339 | - $type = 'Payment_Method'; |
|
340 | - $id = $this->_ID; |
|
341 | - } |
|
342 | - // only log if we're going to store it for longer than the minimum time |
|
343 | - $reg_config = LoaderFactory::getLoader()->load('EE_Registration_Config'); |
|
344 | - if ($reg_config->gateway_log_lifespan !== '1 second') { |
|
345 | - $this->_pay_log->gateway_log($message, $id, $type); |
|
346 | - } |
|
347 | - } |
|
348 | - |
|
349 | - /** |
|
350 | - * Formats the amount so it can generally be sent to gateways |
|
351 | - * |
|
352 | - * @param float $amount |
|
353 | - * @return string |
|
354 | - * @deprecated since 4.9.31 insetad use |
|
355 | - * EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
356 | - */ |
|
357 | - public function format_currency($amount) |
|
358 | - { |
|
359 | - return $this->_get_gateway_formatter()->formatCurrency($amount); |
|
360 | - } |
|
361 | - |
|
362 | - /** |
|
363 | - * Returns either an array of all the currency codes supported, |
|
364 | - * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
|
365 | - * |
|
366 | - * @return mixed array or string |
|
367 | - */ |
|
368 | - public function currencies_supported() |
|
369 | - { |
|
370 | - return $this->_currencies_supported; |
|
371 | - } |
|
372 | - |
|
373 | - /** |
|
374 | - * Returns what a simple summing of items and taxes for this transaction. This |
|
375 | - * can be used to determine if some more complex line items, like promotions, |
|
376 | - * surcharges, or cancellations occurred (in which case we might want to forget |
|
377 | - * about creating an itemized list of purchases and instead only send the total due) |
|
378 | - * |
|
379 | - * @param EE_Transaction $transaction |
|
380 | - * @return float |
|
381 | - */ |
|
382 | - protected function _sum_items_and_taxes(EE_Transaction $transaction) |
|
383 | - { |
|
384 | - $total_line_item = $transaction->total_line_item(); |
|
385 | - $total = 0; |
|
386 | - foreach ($total_line_item->get_items() as $item_line_item) { |
|
387 | - $total += max($item_line_item->total(), 0); |
|
388 | - } |
|
389 | - foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
390 | - $total += max($tax_line_item->total(), 0); |
|
391 | - } |
|
392 | - return $total; |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Determines whether or not we can easily itemize the transaction using only |
|
397 | - * items and taxes (ie, no promotions or surcharges or cancellations needed) |
|
398 | - * |
|
399 | - * @param EEI_Payment $payment |
|
400 | - * @return boolean |
|
401 | - */ |
|
402 | - protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) |
|
403 | - { |
|
404 | - return $this->_money->compare_floats( |
|
405 | - $this->_sum_items_and_taxes($payment->transaction()), |
|
406 | - $payment->transaction()->total() |
|
407 | - ) |
|
408 | - && $this->_money->compare_floats( |
|
409 | - $payment->amount(), |
|
410 | - $payment->transaction()->total() |
|
411 | - ); |
|
412 | - } |
|
413 | - |
|
414 | - /** |
|
415 | - * Handles updating the transaction and any other related data based on the payment. |
|
416 | - * You may be tempted to do this as part of do_direct_payment or handle_payment_update, |
|
417 | - * but doing so on those functions might be too early. It's possible that the changes |
|
418 | - * you make to teh transaction or registration or line items may just get overwritten |
|
419 | - * at that point. Instead, you should store any info you need on the payment during those |
|
420 | - * functions, and use that information at this step, which client code will decide |
|
421 | - * for you when it should be called. |
|
422 | - * |
|
423 | - * @param EE_Payment $payment |
|
424 | - * @return void |
|
425 | - */ |
|
426 | - public function update_txn_based_on_payment($payment) |
|
427 | - { |
|
428 | - // maybe update the transaction or line items or registrations |
|
429 | - // but most gateways don't need to do this, because they only update the payment |
|
430 | - } |
|
431 | - |
|
432 | - /** |
|
433 | - * Gets the first event for this payment (it's possible that it could be for multiple) |
|
434 | - * |
|
435 | - * @param EEI_Payment $payment |
|
436 | - * @return EEI_Event|null |
|
437 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
438 | - */ |
|
439 | - protected function _get_first_event_for_payment(EEI_Payment $payment) |
|
440 | - { |
|
441 | - return $payment->get_first_event(); |
|
442 | - } |
|
443 | - |
|
444 | - /** |
|
445 | - * Gets the name of the first event for which is being paid |
|
446 | - * |
|
447 | - * @param EEI_Payment $payment |
|
448 | - * @return string |
|
449 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
450 | - */ |
|
451 | - protected function _get_first_event_name_for_payment(EEI_Payment $payment) |
|
452 | - { |
|
453 | - return $payment->get_first_event_name(); |
|
454 | - } |
|
455 | - |
|
456 | - /** |
|
457 | - * Gets the text to use for a gateway's line item name when this is a partial payment |
|
458 | - * |
|
459 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
460 | - * @param EE_Payment $payment |
|
461 | - * @return string |
|
462 | - */ |
|
463 | - protected function _format_partial_payment_line_item_name(EEI_Payment $payment) |
|
464 | - { |
|
465 | - return $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment); |
|
466 | - } |
|
467 | - |
|
468 | - /** |
|
469 | - * Gets the text to use for a gateway's line item description when this is a partial payment |
|
470 | - * |
|
471 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
472 | - * @param EEI_Payment $payment |
|
473 | - * @return string |
|
474 | - */ |
|
475 | - protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) |
|
476 | - { |
|
477 | - return $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc($payment); |
|
478 | - } |
|
479 | - |
|
480 | - /** |
|
481 | - * Gets the name to use for a line item when sending line items to the gateway |
|
482 | - * |
|
483 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
484 | - * @param EEI_Line_Item $line_item |
|
485 | - * @param EEI_Payment $payment |
|
486 | - * @return string |
|
487 | - */ |
|
488 | - protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
489 | - { |
|
490 | - return $this->_get_gateway_formatter()->formatLineItemName($line_item, $payment); |
|
491 | - } |
|
492 | - |
|
493 | - /** |
|
494 | - * Gets the description to use for a line item when sending line items to the gateway |
|
495 | - * |
|
496 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
497 | - * @param EEI_Line_Item $line_item |
|
498 | - * @param EEI_Payment $payment |
|
499 | - * @return string |
|
500 | - */ |
|
501 | - protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
502 | - { |
|
503 | - return $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment); |
|
504 | - } |
|
505 | - |
|
506 | - /** |
|
507 | - * Gets the order description that should generlly be sent to gateways |
|
508 | - * |
|
509 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
510 | - * @param EEI_Payment $payment |
|
511 | - * @return type |
|
512 | - */ |
|
513 | - protected function _format_order_description(EEI_Payment $payment) |
|
514 | - { |
|
515 | - return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
|
516 | - } |
|
26 | + /** |
|
27 | + * a constant used as a possible value for $_currencies_supported to indicate |
|
28 | + * that ALL currencies are supported by this gateway |
|
29 | + */ |
|
30 | + const all_currencies_supported = 'all_currencies_supported'; |
|
31 | + /** |
|
32 | + * Where values are 3-letter currency codes |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + protected $_currencies_supported = array(); |
|
37 | + /** |
|
38 | + * Whether or not this gateway can support SENDING a refund request (ie, initiated by |
|
39 | + * admin in EE's wp-admin page) |
|
40 | + * |
|
41 | + * @var boolean |
|
42 | + */ |
|
43 | + protected $_supports_sending_refunds = false; |
|
44 | + |
|
45 | + /** |
|
46 | + * Whether or not this gateway can support RECEIVING a refund request from the payment |
|
47 | + * provider (ie, initiated by admin on the payment prover's website who sends an IPN to EE) |
|
48 | + * |
|
49 | + * @var boolean |
|
50 | + */ |
|
51 | + protected $_supports_receiving_refunds = false; |
|
52 | + /** |
|
53 | + * Model for querying for existing payments |
|
54 | + * |
|
55 | + * @var EEMI_Payment |
|
56 | + */ |
|
57 | + protected $_pay_model; |
|
58 | + |
|
59 | + /** |
|
60 | + * Model used for adding to the payments log |
|
61 | + * |
|
62 | + * @var EEMI_Payment_Log |
|
63 | + */ |
|
64 | + protected $_pay_log; |
|
65 | + |
|
66 | + /** |
|
67 | + * Used for formatting some input to gateways |
|
68 | + * |
|
69 | + * @var EEHI_Template |
|
70 | + */ |
|
71 | + protected $_template; |
|
72 | + |
|
73 | + /** |
|
74 | + * Concrete class that implements EEHI_Money, used by most gateways |
|
75 | + * |
|
76 | + * @var EEHI_Money |
|
77 | + */ |
|
78 | + protected $_money; |
|
79 | + |
|
80 | + /** |
|
81 | + * Concrete class that implements EEHI_Line_Item, used for manipulating the line item tree |
|
82 | + * |
|
83 | + * @var EEHI_Line_Item |
|
84 | + */ |
|
85 | + protected $_line_item; |
|
86 | + |
|
87 | + /** |
|
88 | + * @var GatewayDataFormatterInterface |
|
89 | + */ |
|
90 | + protected $_gateway_data_formatter; |
|
91 | + |
|
92 | + /** |
|
93 | + * @var FormatterInterface |
|
94 | + */ |
|
95 | + protected $_unsupported_character_remover; |
|
96 | + |
|
97 | + /** |
|
98 | + * The ID of the payment method using this gateway |
|
99 | + * |
|
100 | + * @var int |
|
101 | + */ |
|
102 | + protected $_ID; |
|
103 | + |
|
104 | + /** |
|
105 | + * @var $_debug_mode boolean whether to send requests to teh sandbox site or not |
|
106 | + */ |
|
107 | + protected $_debug_mode; |
|
108 | + /** |
|
109 | + * |
|
110 | + * @var string $_name name to show for this payment method |
|
111 | + */ |
|
112 | + protected $_name; |
|
113 | + /** |
|
114 | + * |
|
115 | + * @var string name to show fir this payment method to admin-type users |
|
116 | + */ |
|
117 | + protected $_admin_name; |
|
118 | + |
|
119 | + /** |
|
120 | + * @return EE_Gateway |
|
121 | + */ |
|
122 | + public function __construct() |
|
123 | + { |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * We don't want to serialize models as they often have circular structures |
|
128 | + * (eg a payment model has a reference to each payment model object; and most |
|
129 | + * payments have a transaction, most transactions have a payment method; |
|
130 | + * most payment methods have a payment method type; most payment method types |
|
131 | + * have a gateway. And if a gateway serializes its models, we start at the |
|
132 | + * beginning again) |
|
133 | + * |
|
134 | + * @return array |
|
135 | + */ |
|
136 | + public function __sleep() |
|
137 | + { |
|
138 | + $properties = get_object_vars($this); |
|
139 | + unset($properties['_pay_model'], $properties['_pay_log']); |
|
140 | + return array_keys($properties); |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Returns whether or not this gateway should support SENDING refunds |
|
145 | + * see $_supports_sending_refunds |
|
146 | + * |
|
147 | + * @return boolean |
|
148 | + */ |
|
149 | + public function supports_sending_refunds() |
|
150 | + { |
|
151 | + return $this->_supports_sending_refunds; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Returns whether or not this gateway should support RECEIVING refunds |
|
156 | + * see $_supports_receiving_refunds |
|
157 | + * |
|
158 | + * @return boolean |
|
159 | + */ |
|
160 | + public function supports_receiving_refunds() |
|
161 | + { |
|
162 | + return $this->_supports_receiving_refunds; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * Tries to refund the payment specified, taking into account the extra |
|
168 | + * refund info. Note that if the gateway's _supports_sending_refunds is false, |
|
169 | + * this should just throw an exception. |
|
170 | + * |
|
171 | + * @param EE_Payment $payment |
|
172 | + * @param array $refund_info |
|
173 | + * @return EE_Payment for the refund |
|
174 | + * @throws EE_Error |
|
175 | + */ |
|
176 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) |
|
177 | + { |
|
178 | + return null; |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * Sets the payment method's settings so the gateway knows where to send the request |
|
184 | + * etc |
|
185 | + * |
|
186 | + * @param array $settings_array |
|
187 | + */ |
|
188 | + public function set_settings($settings_array) |
|
189 | + { |
|
190 | + foreach ($settings_array as $name => $value) { |
|
191 | + $property_name = "_" . $name; |
|
192 | + $this->{$property_name} = $value; |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * See this class description |
|
198 | + * |
|
199 | + * @param EEMI_Payment $payment_model |
|
200 | + */ |
|
201 | + public function set_payment_model($payment_model) |
|
202 | + { |
|
203 | + $this->_pay_model = $payment_model; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * See this class description |
|
208 | + * |
|
209 | + * @param EEMI_Payment_Log $payment_log_model |
|
210 | + */ |
|
211 | + public function set_payment_log($payment_log_model) |
|
212 | + { |
|
213 | + $this->_pay_log = $payment_log_model; |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * See this class description |
|
218 | + * |
|
219 | + * @param EEHI_Template $template_helper |
|
220 | + */ |
|
221 | + public function set_template_helper($template_helper) |
|
222 | + { |
|
223 | + $this->_template = $template_helper; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * See this class description |
|
228 | + * |
|
229 | + * @param EEHI_Line_Item $line_item_helper |
|
230 | + */ |
|
231 | + public function set_line_item_helper($line_item_helper) |
|
232 | + { |
|
233 | + $this->_line_item = $line_item_helper; |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * See this class description |
|
238 | + * |
|
239 | + * @param EEHI_Money $money_helper |
|
240 | + */ |
|
241 | + public function set_money_helper($money_helper) |
|
242 | + { |
|
243 | + $this->_money = $money_helper; |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * Sets the gateway data formatter helper |
|
249 | + * |
|
250 | + * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
251 | + * @throws InvalidEntityException if it's not set properly |
|
252 | + */ |
|
253 | + public function set_gateway_data_formatter(GatewayDataFormatterInterface $gateway_data_formatter) |
|
254 | + { |
|
255 | + if (! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
256 | + throw new InvalidEntityException( |
|
257 | + is_object($gateway_data_formatter) |
|
258 | + ? get_class($gateway_data_formatter) |
|
259 | + : esc_html__('Not an object', 'event_espresso'), |
|
260 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
261 | + ); |
|
262 | + } |
|
263 | + $this->_gateway_data_formatter = $gateway_data_formatter; |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * Gets the gateway data formatter |
|
268 | + * |
|
269 | + * @return GatewayDataFormatterInterface |
|
270 | + * @throws InvalidEntityException if it's not set properly |
|
271 | + */ |
|
272 | + protected function _get_gateway_formatter() |
|
273 | + { |
|
274 | + if (! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
275 | + throw new InvalidEntityException( |
|
276 | + is_object($this->_gateway_data_formatter) |
|
277 | + ? get_class($this->_gateway_data_formatter) |
|
278 | + : esc_html__('Not an object', 'event_espresso'), |
|
279 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
280 | + ); |
|
281 | + } |
|
282 | + return $this->_gateway_data_formatter; |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * Sets the helper which will remove unsupported characters for most gateways |
|
288 | + * |
|
289 | + * @param FormatterInterface $formatter |
|
290 | + * @return FormatterInterface |
|
291 | + * @throws InvalidEntityException |
|
292 | + */ |
|
293 | + public function set_unsupported_character_remover(FormatterInterface $formatter) |
|
294 | + { |
|
295 | + if (! $formatter instanceof FormatterInterface) { |
|
296 | + throw new InvalidEntityException( |
|
297 | + is_object($formatter) |
|
298 | + ? get_class($formatter) |
|
299 | + : esc_html__('Not an object', 'event_espresso'), |
|
300 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
301 | + ); |
|
302 | + } |
|
303 | + $this->_unsupported_character_remover = $formatter; |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
308 | + * |
|
309 | + * @return FormatterInterface |
|
310 | + * @throws InvalidEntityException |
|
311 | + */ |
|
312 | + protected function _get_unsupported_character_remover() |
|
313 | + { |
|
314 | + if (! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
315 | + throw new InvalidEntityException( |
|
316 | + is_object($this->_unsupported_character_remover) |
|
317 | + ? get_class($this->_unsupported_character_remover) |
|
318 | + : esc_html__('Not an object', 'event_espresso'), |
|
319 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
320 | + ); |
|
321 | + } |
|
322 | + return $this->_unsupported_character_remover; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * @param $message |
|
328 | + * @param $payment |
|
329 | + */ |
|
330 | + public function log($message, $object_logged) |
|
331 | + { |
|
332 | + if ($object_logged instanceof EEI_Payment) { |
|
333 | + $type = 'Payment'; |
|
334 | + $id = $object_logged->ID(); |
|
335 | + } elseif ($object_logged instanceof EEI_Transaction) { |
|
336 | + $type = 'Transaction'; |
|
337 | + $id = $object_logged->ID(); |
|
338 | + } else { |
|
339 | + $type = 'Payment_Method'; |
|
340 | + $id = $this->_ID; |
|
341 | + } |
|
342 | + // only log if we're going to store it for longer than the minimum time |
|
343 | + $reg_config = LoaderFactory::getLoader()->load('EE_Registration_Config'); |
|
344 | + if ($reg_config->gateway_log_lifespan !== '1 second') { |
|
345 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
346 | + } |
|
347 | + } |
|
348 | + |
|
349 | + /** |
|
350 | + * Formats the amount so it can generally be sent to gateways |
|
351 | + * |
|
352 | + * @param float $amount |
|
353 | + * @return string |
|
354 | + * @deprecated since 4.9.31 insetad use |
|
355 | + * EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
356 | + */ |
|
357 | + public function format_currency($amount) |
|
358 | + { |
|
359 | + return $this->_get_gateway_formatter()->formatCurrency($amount); |
|
360 | + } |
|
361 | + |
|
362 | + /** |
|
363 | + * Returns either an array of all the currency codes supported, |
|
364 | + * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
|
365 | + * |
|
366 | + * @return mixed array or string |
|
367 | + */ |
|
368 | + public function currencies_supported() |
|
369 | + { |
|
370 | + return $this->_currencies_supported; |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * Returns what a simple summing of items and taxes for this transaction. This |
|
375 | + * can be used to determine if some more complex line items, like promotions, |
|
376 | + * surcharges, or cancellations occurred (in which case we might want to forget |
|
377 | + * about creating an itemized list of purchases and instead only send the total due) |
|
378 | + * |
|
379 | + * @param EE_Transaction $transaction |
|
380 | + * @return float |
|
381 | + */ |
|
382 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) |
|
383 | + { |
|
384 | + $total_line_item = $transaction->total_line_item(); |
|
385 | + $total = 0; |
|
386 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
387 | + $total += max($item_line_item->total(), 0); |
|
388 | + } |
|
389 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
390 | + $total += max($tax_line_item->total(), 0); |
|
391 | + } |
|
392 | + return $total; |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Determines whether or not we can easily itemize the transaction using only |
|
397 | + * items and taxes (ie, no promotions or surcharges or cancellations needed) |
|
398 | + * |
|
399 | + * @param EEI_Payment $payment |
|
400 | + * @return boolean |
|
401 | + */ |
|
402 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) |
|
403 | + { |
|
404 | + return $this->_money->compare_floats( |
|
405 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
406 | + $payment->transaction()->total() |
|
407 | + ) |
|
408 | + && $this->_money->compare_floats( |
|
409 | + $payment->amount(), |
|
410 | + $payment->transaction()->total() |
|
411 | + ); |
|
412 | + } |
|
413 | + |
|
414 | + /** |
|
415 | + * Handles updating the transaction and any other related data based on the payment. |
|
416 | + * You may be tempted to do this as part of do_direct_payment or handle_payment_update, |
|
417 | + * but doing so on those functions might be too early. It's possible that the changes |
|
418 | + * you make to teh transaction or registration or line items may just get overwritten |
|
419 | + * at that point. Instead, you should store any info you need on the payment during those |
|
420 | + * functions, and use that information at this step, which client code will decide |
|
421 | + * for you when it should be called. |
|
422 | + * |
|
423 | + * @param EE_Payment $payment |
|
424 | + * @return void |
|
425 | + */ |
|
426 | + public function update_txn_based_on_payment($payment) |
|
427 | + { |
|
428 | + // maybe update the transaction or line items or registrations |
|
429 | + // but most gateways don't need to do this, because they only update the payment |
|
430 | + } |
|
431 | + |
|
432 | + /** |
|
433 | + * Gets the first event for this payment (it's possible that it could be for multiple) |
|
434 | + * |
|
435 | + * @param EEI_Payment $payment |
|
436 | + * @return EEI_Event|null |
|
437 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
438 | + */ |
|
439 | + protected function _get_first_event_for_payment(EEI_Payment $payment) |
|
440 | + { |
|
441 | + return $payment->get_first_event(); |
|
442 | + } |
|
443 | + |
|
444 | + /** |
|
445 | + * Gets the name of the first event for which is being paid |
|
446 | + * |
|
447 | + * @param EEI_Payment $payment |
|
448 | + * @return string |
|
449 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
450 | + */ |
|
451 | + protected function _get_first_event_name_for_payment(EEI_Payment $payment) |
|
452 | + { |
|
453 | + return $payment->get_first_event_name(); |
|
454 | + } |
|
455 | + |
|
456 | + /** |
|
457 | + * Gets the text to use for a gateway's line item name when this is a partial payment |
|
458 | + * |
|
459 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
460 | + * @param EE_Payment $payment |
|
461 | + * @return string |
|
462 | + */ |
|
463 | + protected function _format_partial_payment_line_item_name(EEI_Payment $payment) |
|
464 | + { |
|
465 | + return $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment); |
|
466 | + } |
|
467 | + |
|
468 | + /** |
|
469 | + * Gets the text to use for a gateway's line item description when this is a partial payment |
|
470 | + * |
|
471 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
472 | + * @param EEI_Payment $payment |
|
473 | + * @return string |
|
474 | + */ |
|
475 | + protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) |
|
476 | + { |
|
477 | + return $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc($payment); |
|
478 | + } |
|
479 | + |
|
480 | + /** |
|
481 | + * Gets the name to use for a line item when sending line items to the gateway |
|
482 | + * |
|
483 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
484 | + * @param EEI_Line_Item $line_item |
|
485 | + * @param EEI_Payment $payment |
|
486 | + * @return string |
|
487 | + */ |
|
488 | + protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
489 | + { |
|
490 | + return $this->_get_gateway_formatter()->formatLineItemName($line_item, $payment); |
|
491 | + } |
|
492 | + |
|
493 | + /** |
|
494 | + * Gets the description to use for a line item when sending line items to the gateway |
|
495 | + * |
|
496 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
497 | + * @param EEI_Line_Item $line_item |
|
498 | + * @param EEI_Payment $payment |
|
499 | + * @return string |
|
500 | + */ |
|
501 | + protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
502 | + { |
|
503 | + return $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment); |
|
504 | + } |
|
505 | + |
|
506 | + /** |
|
507 | + * Gets the order description that should generlly be sent to gateways |
|
508 | + * |
|
509 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
510 | + * @param EEI_Payment $payment |
|
511 | + * @return type |
|
512 | + */ |
|
513 | + protected function _format_order_description(EEI_Payment $payment) |
|
514 | + { |
|
515 | + return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
|
516 | + } |
|
517 | 517 | } |
@@ -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 | } |
@@ -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 | } |
@@ -14,88 +14,88 @@ |
||
14 | 14 | * ------------------------------------------------------------------------ |
15 | 15 | */ |
16 | 16 | /** |
17 | - * |
|
18 | - * Class EE_Receipt_Line_Item_Display_Strategy |
|
19 | - * |
|
20 | - * Description |
|
21 | - * |
|
22 | - * @package Event Espresso |
|
23 | - * @subpackage core |
|
24 | - * @author Brent Christensen |
|
25 | - * |
|
26 | - * |
|
27 | - */ |
|
17 | + * |
|
18 | + * Class EE_Receipt_Line_Item_Display_Strategy |
|
19 | + * |
|
20 | + * Description |
|
21 | + * |
|
22 | + * @package Event Espresso |
|
23 | + * @subpackage core |
|
24 | + * @author Brent Christensen |
|
25 | + * |
|
26 | + * |
|
27 | + */ |
|
28 | 28 | |
29 | 29 | class EE_Receipt_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @param EE_Line_Item $line_item |
|
34 | - * @param array $options |
|
35 | - * @return mixed |
|
36 | - */ |
|
37 | - public function display_line_item(EE_Line_Item $line_item, $options = array()) |
|
38 | - { |
|
32 | + /** |
|
33 | + * @param EE_Line_Item $line_item |
|
34 | + * @param array $options |
|
35 | + * @return mixed |
|
36 | + */ |
|
37 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) |
|
38 | + { |
|
39 | 39 | |
40 | - $html = ''; |
|
41 | - // set some default options and merge with incoming |
|
42 | - $default_options = array( |
|
43 | - 'show_desc' => true, |
|
44 | - 'odd' => false |
|
45 | - ); |
|
46 | - $options = array_merge($default_options, (array) $options); |
|
47 | - switch ($line_item->type()) { |
|
48 | - case EEM_Line_Item::type_total: |
|
49 | - // loop thru children |
|
50 | - foreach ($line_item->children() as $child_line_item) { |
|
51 | - // recursively feed children back into this method |
|
40 | + $html = ''; |
|
41 | + // set some default options and merge with incoming |
|
42 | + $default_options = array( |
|
43 | + 'show_desc' => true, |
|
44 | + 'odd' => false |
|
45 | + ); |
|
46 | + $options = array_merge($default_options, (array) $options); |
|
47 | + switch ($line_item->type()) { |
|
48 | + case EEM_Line_Item::type_total: |
|
49 | + // loop thru children |
|
50 | + foreach ($line_item->children() as $child_line_item) { |
|
51 | + // recursively feed children back into this method |
|
52 | 52 | // $html .= $this->display_line_item( $child_line_item, $options ); |
53 | - } |
|
53 | + } |
|
54 | 54 | // $html .= $this->_separator_row( $options ); |
55 | 55 | // $html .= $this->_total_row( $line_item, __('Total', 'event_espresso'), $options ); |
56 | - break; |
|
56 | + break; |
|
57 | 57 | |
58 | 58 | |
59 | - case EEM_Line_Item::type_sub_total: |
|
60 | - // loop thru children |
|
61 | - foreach ($line_item->children() as $child_line_item) { |
|
62 | - // recursively feed children back into this method |
|
59 | + case EEM_Line_Item::type_sub_total: |
|
60 | + // loop thru children |
|
61 | + foreach ($line_item->children() as $child_line_item) { |
|
62 | + // recursively feed children back into this method |
|
63 | 63 | // $html .= $this->display_line_item( $child_line_item, $options ); |
64 | - } |
|
64 | + } |
|
65 | 65 | // $html .= $this->_total_row( $line_item, __('Sub-Total', 'event_espresso'), $options ); |
66 | - break; |
|
66 | + break; |
|
67 | 67 | |
68 | 68 | |
69 | - case EEM_Line_Item::type_tax_sub_total: |
|
70 | - // loop thru children |
|
71 | - foreach ($line_item->children() as $child_line_item) { |
|
72 | - // recursively feed children back into this method |
|
69 | + case EEM_Line_Item::type_tax_sub_total: |
|
70 | + // loop thru children |
|
71 | + foreach ($line_item->children() as $child_line_item) { |
|
72 | + // recursively feed children back into this method |
|
73 | 73 | // $html .= $this->display_line_item( $child_line_item, $options ); |
74 | - } |
|
74 | + } |
|
75 | 75 | // $html .= $this->_total_row( $line_item, __('Tax Total', 'event_espresso'), $options ); |
76 | - break; |
|
76 | + break; |
|
77 | 77 | |
78 | 78 | |
79 | - case EEM_Line_Item::type_line_item: |
|
80 | - // item row |
|
79 | + case EEM_Line_Item::type_line_item: |
|
80 | + // item row |
|
81 | 81 | // $html .= $this->_item_row( $line_item, $options ); |
82 | - // got any kids? |
|
83 | - foreach ($line_item->children() as $child_line_item) { |
|
82 | + // got any kids? |
|
83 | + foreach ($line_item->children() as $child_line_item) { |
|
84 | 84 | // $this->display_line_item( $child_line_item, $options ); |
85 | - } |
|
86 | - break; |
|
85 | + } |
|
86 | + break; |
|
87 | 87 | |
88 | 88 | |
89 | - case EEM_Line_Item::type_sub_line_item: |
|
89 | + case EEM_Line_Item::type_sub_line_item: |
|
90 | 90 | // $html .= $this->_sub_item_row( $line_item, $options ); |
91 | - break; |
|
91 | + break; |
|
92 | 92 | |
93 | 93 | |
94 | - case EEM_Line_Item::type_tax: |
|
94 | + case EEM_Line_Item::type_tax: |
|
95 | 95 | // $html .= $this->_tax_row( $line_item, $options ); |
96 | - break; |
|
97 | - } |
|
96 | + break; |
|
97 | + } |
|
98 | 98 | |
99 | - return $html; |
|
100 | - } |
|
99 | + return $html; |
|
100 | + } |
|
101 | 101 | } |