@@ -24,39 +24,39 @@ |
||
24 | 24 | class EE_CPT_Attendee_Strategy |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * $CPT - the current page, if it utilizes CPTs |
|
29 | - * |
|
30 | - * @var array |
|
31 | - * @access protected |
|
32 | - */ |
|
33 | - protected $CPT = null; |
|
27 | + /** |
|
28 | + * $CPT - the current page, if it utilizes CPTs |
|
29 | + * |
|
30 | + * @var array |
|
31 | + * @access protected |
|
32 | + */ |
|
33 | + protected $CPT = null; |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * class constructor |
|
38 | - * |
|
39 | - * @access public |
|
40 | - * @param array $arguments |
|
41 | - * @return \EE_CPT_Attendee_Strategy |
|
42 | - */ |
|
43 | - public function __construct($arguments = array()) |
|
44 | - { |
|
45 | - $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : null; |
|
46 | - $WP_Query = isset($arguments['WP_Query']) ? $arguments['WP_Query'] : null; |
|
47 | - } |
|
36 | + /** |
|
37 | + * class constructor |
|
38 | + * |
|
39 | + * @access public |
|
40 | + * @param array $arguments |
|
41 | + * @return \EE_CPT_Attendee_Strategy |
|
42 | + */ |
|
43 | + public function __construct($arguments = array()) |
|
44 | + { |
|
45 | + $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : null; |
|
46 | + $WP_Query = isset($arguments['WP_Query']) ? $arguments['WP_Query'] : null; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * the_posts |
|
52 | - * |
|
53 | - * @access public |
|
54 | - * @param $posts |
|
55 | - * @param WP_Query $wp_query |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - public function the_posts($posts, WP_Query $wp_query) |
|
59 | - { |
|
60 | - return $posts; |
|
61 | - } |
|
50 | + /** |
|
51 | + * the_posts |
|
52 | + * |
|
53 | + * @access public |
|
54 | + * @param $posts |
|
55 | + * @param WP_Query $wp_query |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + public function the_posts($posts, WP_Query $wp_query) |
|
59 | + { |
|
60 | + return $posts; |
|
61 | + } |
|
62 | 62 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public static function instance() |
34 | 34 | { |
35 | 35 | // check if class object is instantiated |
36 | - if (! self::$_instance instanceof EE_Payment_Processor) { |
|
36 | + if ( ! self::$_instance instanceof EE_Payment_Processor) { |
|
37 | 37 | self::$_instance = new self(); |
38 | 38 | } |
39 | 39 | return self::$_instance; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | /** @type \EE_Transaction $transaction */ |
171 | 171 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
172 | 172 | $primary_reg = $transaction->primary_registration(); |
173 | - if (! $primary_reg instanceof EE_Registration) { |
|
173 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
174 | 174 | throw new EE_Error( |
175 | 175 | sprintf( |
176 | 176 | __( |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | EEM_Change_Log::instance()->log( |
266 | 266 | EEM_Change_Log::type_gateway, |
267 | 267 | array( |
268 | - 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
268 | + 'message' => 'IPN Exception: '.$e->getMessage(), |
|
269 | 269 | 'current_url' => EEH_URL::current_url(), |
270 | 270 | 'payment' => $e->getPaymentProperties(), |
271 | 271 | 'IPN_data' => $e->getIpnData(), |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | EEM_Change_Log::instance()->log( |
310 | 310 | EEM_Change_Log::type_gateway, |
311 | 311 | array( |
312 | - 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
312 | + 'message' => 'IPN Exception: '.$e->getMessage(), |
|
313 | 313 | 'current_url' => EEH_URL::current_url(), |
314 | 314 | 'payment' => $e->getPaymentProperties(), |
315 | 315 | 'IPN_data' => $e->getIpnData(), |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | { |
381 | 381 | $return_data = array(); |
382 | 382 | foreach ($request_data as $key => $value) { |
383 | - $return_data[ $this->_remove_unusable_characters($key) ] = $this->_remove_unusable_characters( |
|
383 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters( |
|
384 | 384 | $value |
385 | 385 | ); |
386 | 386 | } |
@@ -18,846 +18,846 @@ |
||
18 | 18 | class EE_Payment_Processor extends EE_Processor_Base implements ResettableInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var EE_Payment_Processor $_instance |
|
23 | - * @access private |
|
24 | - */ |
|
25 | - private static $_instance; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * @singleton method used to instantiate class object |
|
30 | - * @access public |
|
31 | - * @return EE_Payment_Processor instance |
|
32 | - */ |
|
33 | - public static function instance() |
|
34 | - { |
|
35 | - // check if class object is instantiated |
|
36 | - if (! self::$_instance instanceof EE_Payment_Processor) { |
|
37 | - self::$_instance = new self(); |
|
38 | - } |
|
39 | - return self::$_instance; |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * @return EE_Payment_Processor |
|
45 | - */ |
|
46 | - public static function reset() |
|
47 | - { |
|
48 | - self::$_instance = null; |
|
49 | - return self::instance(); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - *private constructor to prevent direct creation |
|
55 | - * |
|
56 | - * @Constructor |
|
57 | - * @access private |
|
58 | - */ |
|
59 | - private function __construct() |
|
60 | - { |
|
61 | - do_action('AHEE__EE_Payment_Processor__construct'); |
|
62 | - add_action('http_api_curl', array($this, '_curl_requests_to_paypal_use_tls'), 10, 3); |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * Using the selected gateway, processes the payment for that transaction, and updates the transaction |
|
68 | - * appropriately. Saves the payment that is generated |
|
69 | - * |
|
70 | - * @param EE_Payment_Method $payment_method |
|
71 | - * @param EE_Transaction $transaction |
|
72 | - * @param float $amount if only part of the transaction is to be paid for, how much. |
|
73 | - * Leave null if payment is for the full amount owing |
|
74 | - * @param EE_Billing_Info_Form $billing_form (or probably null, if it's an offline or offsite payment method). |
|
75 | - * Receive_form_submission() should have |
|
76 | - * already been called on the billing form |
|
77 | - * (ie, its inputs should have their normalized values set). |
|
78 | - * @param string $return_url string used mostly by offsite gateways to specify |
|
79 | - * where to go AFTER the offsite gateway |
|
80 | - * @param string $method like 'CART', indicates who the client who called this was |
|
81 | - * @param bool $by_admin TRUE if payment is being attempted from the admin |
|
82 | - * @param boolean $update_txn whether or not to call |
|
83 | - * EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() |
|
84 | - * @param string $cancel_url URL to return to if off-site payments are cancelled |
|
85 | - * @return EE_Payment |
|
86 | - * @throws EE_Error |
|
87 | - * @throws InvalidArgumentException |
|
88 | - * @throws ReflectionException |
|
89 | - * @throws RuntimeException |
|
90 | - * @throws InvalidDataTypeException |
|
91 | - * @throws InvalidInterfaceException |
|
92 | - */ |
|
93 | - public function process_payment( |
|
94 | - EE_Payment_Method $payment_method, |
|
95 | - EE_Transaction $transaction, |
|
96 | - $amount = null, |
|
97 | - $billing_form = null, |
|
98 | - $return_url = null, |
|
99 | - $method = 'CART', |
|
100 | - $by_admin = false, |
|
101 | - $update_txn = true, |
|
102 | - $cancel_url = '' |
|
103 | - ) { |
|
104 | - if ((float) $amount < 0) { |
|
105 | - throw new EE_Error( |
|
106 | - sprintf( |
|
107 | - __( |
|
108 | - 'Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', |
|
109 | - 'event_espresso' |
|
110 | - ), |
|
111 | - $amount, |
|
112 | - $transaction->ID() |
|
113 | - ) |
|
114 | - ); |
|
115 | - } |
|
116 | - // verify payment method |
|
117 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( |
|
118 | - $payment_method, |
|
119 | - true |
|
120 | - ); |
|
121 | - // verify transaction |
|
122 | - EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
123 | - $transaction->set_payment_method_ID($payment_method->ID()); |
|
124 | - // verify payment method type |
|
125 | - if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
126 | - $payment = $payment_method->type_obj()->process_payment( |
|
127 | - $transaction, |
|
128 | - min($amount, $transaction->remaining()), // make sure we don't overcharge |
|
129 | - $billing_form, |
|
130 | - $return_url, |
|
131 | - add_query_arg(array('ee_cancel_payment' => true), $cancel_url), |
|
132 | - $method, |
|
133 | - $by_admin |
|
134 | - ); |
|
135 | - // check if payment method uses an off-site gateway |
|
136 | - if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) { |
|
137 | - // don't process payments for off-site gateways yet because no payment has occurred yet |
|
138 | - $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
139 | - } |
|
140 | - return $payment; |
|
141 | - } |
|
142 | - EE_Error::add_error( |
|
143 | - sprintf( |
|
144 | - __( |
|
145 | - 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
146 | - 'event_espresso' |
|
147 | - ), |
|
148 | - '<br/>', |
|
149 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
150 | - ), |
|
151 | - __FILE__, |
|
152 | - __FUNCTION__, |
|
153 | - __LINE__ |
|
154 | - ); |
|
155 | - return null; |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * @param EE_Transaction|int $transaction |
|
161 | - * @param EE_Payment_Method $payment_method |
|
162 | - * @return string |
|
163 | - * @throws EE_Error |
|
164 | - * @throws InvalidArgumentException |
|
165 | - * @throws InvalidDataTypeException |
|
166 | - * @throws InvalidInterfaceException |
|
167 | - */ |
|
168 | - public function get_ipn_url_for_payment_method($transaction, $payment_method) |
|
169 | - { |
|
170 | - /** @type \EE_Transaction $transaction */ |
|
171 | - $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
172 | - $primary_reg = $transaction->primary_registration(); |
|
173 | - if (! $primary_reg instanceof EE_Registration) { |
|
174 | - throw new EE_Error( |
|
175 | - sprintf( |
|
176 | - __( |
|
177 | - 'Cannot get IPN URL for transaction with ID %d because it has no primary registration', |
|
178 | - 'event_espresso' |
|
179 | - ), |
|
180 | - $transaction->ID() |
|
181 | - ) |
|
182 | - ); |
|
183 | - } |
|
184 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( |
|
185 | - $payment_method, |
|
186 | - true |
|
187 | - ); |
|
188 | - $url = add_query_arg( |
|
189 | - array( |
|
190 | - 'e_reg_url_link' => $primary_reg->reg_url_link(), |
|
191 | - 'ee_payment_method' => $payment_method->slug(), |
|
192 | - ), |
|
193 | - EE_Registry::instance()->CFG->core->txn_page_url() |
|
194 | - ); |
|
195 | - return $url; |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * Process the IPN. Firstly, we'll hope we put the standard args into the IPN URL so |
|
201 | - * we can easily find what registration the IPN is for and what payment method. |
|
202 | - * However, if not, we'll give all payment methods a chance to claim it and process it. |
|
203 | - * If a payment is found for the IPN info, it is saved. |
|
204 | - * |
|
205 | - * @param array $_req_data eg $_REQUEST |
|
206 | - * @param EE_Transaction|int $transaction optional (or a transactions id) |
|
207 | - * @param EE_Payment_Method $payment_method (or a slug or id of one) |
|
208 | - * @param boolean $update_txn whether or not to call |
|
209 | - * EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() |
|
210 | - * @param bool $separate_IPN_request whether the IPN uses a separate request (true, like PayPal) |
|
211 | - * or is processed manually (false, like Authorize.net) |
|
212 | - * @throws EE_Error |
|
213 | - * @throws Exception |
|
214 | - * @return EE_Payment |
|
215 | - * @throws \RuntimeException |
|
216 | - * @throws \ReflectionException |
|
217 | - * @throws \InvalidArgumentException |
|
218 | - * @throws InvalidInterfaceException |
|
219 | - * @throws InvalidDataTypeException |
|
220 | - */ |
|
221 | - public function process_ipn( |
|
222 | - $_req_data, |
|
223 | - $transaction = null, |
|
224 | - $payment_method = null, |
|
225 | - $update_txn = true, |
|
226 | - $separate_IPN_request = true |
|
227 | - ) { |
|
228 | - EE_Registry::instance()->load_model('Change_Log'); |
|
229 | - $_req_data = $this->_remove_unusable_characters_from_array((array) $_req_data); |
|
230 | - EE_Processor_Base::set_IPN($separate_IPN_request); |
|
231 | - $obj_for_log = null; |
|
232 | - if ($transaction instanceof EE_Transaction) { |
|
233 | - $obj_for_log = $transaction; |
|
234 | - if ($payment_method instanceof EE_Payment_Method) { |
|
235 | - $obj_for_log = EEM_Payment::instance()->get_one( |
|
236 | - array( |
|
237 | - array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), |
|
238 | - 'order_by' => array('PAY_timestamp' => 'desc'), |
|
239 | - ) |
|
240 | - ); |
|
241 | - } |
|
242 | - } elseif ($payment_method instanceof EE_Payment) { |
|
243 | - $obj_for_log = $payment_method; |
|
244 | - } |
|
245 | - $log = EEM_Change_Log::instance()->log( |
|
246 | - EEM_Change_Log::type_gateway, |
|
247 | - array('IPN data received' => $_req_data), |
|
248 | - $obj_for_log |
|
249 | - ); |
|
250 | - try { |
|
251 | - /** |
|
252 | - * @var EE_Payment $payment |
|
253 | - */ |
|
254 | - $payment = null; |
|
255 | - if ($transaction && $payment_method) { |
|
256 | - /** @type EE_Transaction $transaction */ |
|
257 | - $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
258 | - /** @type EE_Payment_Method $payment_method */ |
|
259 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
|
260 | - if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
261 | - try { |
|
262 | - $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
263 | - $log->set_object($payment); |
|
264 | - } catch (EventEspresso\core\exceptions\IpnException $e) { |
|
265 | - EEM_Change_Log::instance()->log( |
|
266 | - EEM_Change_Log::type_gateway, |
|
267 | - array( |
|
268 | - 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
269 | - 'current_url' => EEH_URL::current_url(), |
|
270 | - 'payment' => $e->getPaymentProperties(), |
|
271 | - 'IPN_data' => $e->getIpnData(), |
|
272 | - ), |
|
273 | - $obj_for_log |
|
274 | - ); |
|
275 | - return $e->getPayment(); |
|
276 | - } |
|
277 | - } else { |
|
278 | - // not a payment |
|
279 | - EE_Error::add_error( |
|
280 | - sprintf( |
|
281 | - __( |
|
282 | - 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', |
|
283 | - 'event_espresso' |
|
284 | - ), |
|
285 | - '<br/>', |
|
286 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
287 | - ), |
|
288 | - __FILE__, |
|
289 | - __FUNCTION__, |
|
290 | - __LINE__ |
|
291 | - ); |
|
292 | - } |
|
293 | - } else { |
|
294 | - // that's actually pretty ok. The IPN just wasn't able |
|
295 | - // to identify which transaction or payment method this was for |
|
296 | - // give all active payment methods a chance to claim it |
|
297 | - $active_payment_methods = EEM_Payment_Method::instance()->get_all_active(); |
|
298 | - foreach ($active_payment_methods as $active_payment_method) { |
|
299 | - try { |
|
300 | - $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
301 | - $payment_method = $active_payment_method; |
|
302 | - EEM_Change_Log::instance()->log( |
|
303 | - EEM_Change_Log::type_gateway, |
|
304 | - array('IPN data' => $_req_data), |
|
305 | - $payment |
|
306 | - ); |
|
307 | - break; |
|
308 | - } catch (EventEspresso\core\exceptions\IpnException $e) { |
|
309 | - EEM_Change_Log::instance()->log( |
|
310 | - EEM_Change_Log::type_gateway, |
|
311 | - array( |
|
312 | - 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
313 | - 'current_url' => EEH_URL::current_url(), |
|
314 | - 'payment' => $e->getPaymentProperties(), |
|
315 | - 'IPN_data' => $e->getIpnData(), |
|
316 | - ), |
|
317 | - $obj_for_log |
|
318 | - ); |
|
319 | - return $e->getPayment(); |
|
320 | - } catch (EE_Error $e) { |
|
321 | - // that's fine- it apparently couldn't handle the IPN |
|
322 | - } |
|
323 | - } |
|
324 | - } |
|
325 | - // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
|
326 | - if ($payment instanceof EE_Payment) { |
|
327 | - $payment->save(); |
|
328 | - // update the TXN |
|
329 | - $this->update_txn_based_on_payment( |
|
330 | - $transaction, |
|
331 | - $payment, |
|
332 | - $update_txn, |
|
333 | - $separate_IPN_request |
|
334 | - ); |
|
335 | - } else { |
|
336 | - // we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
|
337 | - if ($payment_method) { |
|
338 | - EEM_Change_Log::instance()->log( |
|
339 | - EEM_Change_Log::type_gateway, |
|
340 | - array('IPN data' => $_req_data), |
|
341 | - $payment_method |
|
342 | - ); |
|
343 | - } elseif ($transaction) { |
|
344 | - EEM_Change_Log::instance()->log( |
|
345 | - EEM_Change_Log::type_gateway, |
|
346 | - array('IPN data' => $_req_data), |
|
347 | - $transaction |
|
348 | - ); |
|
349 | - } |
|
350 | - } |
|
351 | - return $payment; |
|
352 | - } catch (EE_Error $e) { |
|
353 | - do_action( |
|
354 | - 'AHEE__log', |
|
355 | - __FILE__, |
|
356 | - __FUNCTION__, |
|
357 | - sprintf( |
|
358 | - __( |
|
359 | - 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', |
|
360 | - 'event_espresso' |
|
361 | - ), |
|
362 | - print_r($transaction, true), |
|
363 | - print_r($_req_data, true), |
|
364 | - $e->getMessage() |
|
365 | - ) |
|
366 | - ); |
|
367 | - throw $e; |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - /** |
|
373 | - * Removes any non-printable illegal characters from the input, |
|
374 | - * which might cause a raucous when trying to insert into the database |
|
375 | - * |
|
376 | - * @param array $request_data |
|
377 | - * @return array |
|
378 | - */ |
|
379 | - protected function _remove_unusable_characters_from_array(array $request_data) |
|
380 | - { |
|
381 | - $return_data = array(); |
|
382 | - foreach ($request_data as $key => $value) { |
|
383 | - $return_data[ $this->_remove_unusable_characters($key) ] = $this->_remove_unusable_characters( |
|
384 | - $value |
|
385 | - ); |
|
386 | - } |
|
387 | - return $return_data; |
|
388 | - } |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * Removes any non-printable illegal characters from the input, |
|
393 | - * which might cause a raucous when trying to insert into the database |
|
394 | - * |
|
395 | - * @param string $request_data |
|
396 | - * @return string |
|
397 | - */ |
|
398 | - protected function _remove_unusable_characters($request_data) |
|
399 | - { |
|
400 | - return preg_replace('/[^[:print:]]/', '', $request_data); |
|
401 | - } |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * Should be called just before displaying the payment attempt results to the user, |
|
406 | - * when the payment attempt has finished. Some payment methods may have special |
|
407 | - * logic to perform here. For example, if process_payment() happens on a special request |
|
408 | - * and then the user is redirected to a page that displays the payment's status, this |
|
409 | - * should be called while loading the page that displays the payment's status. If the user is |
|
410 | - * sent to an offsite payment provider, this should be called upon returning from that offsite payment |
|
411 | - * provider. |
|
412 | - * |
|
413 | - * @param EE_Transaction|int $transaction |
|
414 | - * @param bool $update_txn whether or not to call |
|
415 | - * EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() |
|
416 | - * @return EE_Payment |
|
417 | - * @throws EE_Error |
|
418 | - * @throws InvalidArgumentException |
|
419 | - * @throws ReflectionException |
|
420 | - * @throws RuntimeException |
|
421 | - * @throws InvalidDataTypeException |
|
422 | - * @throws InvalidInterfaceException |
|
423 | - * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, |
|
424 | - * to call handle_ipn() for offsite gateways that don't receive separate IPNs |
|
425 | - */ |
|
426 | - public function finalize_payment_for($transaction, $update_txn = true) |
|
427 | - { |
|
428 | - /** @var $transaction EE_Transaction */ |
|
429 | - $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
430 | - $last_payment_method = $transaction->payment_method(); |
|
431 | - if ($last_payment_method instanceof EE_Payment_Method) { |
|
432 | - $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
433 | - $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
434 | - return $payment; |
|
435 | - } |
|
436 | - return null; |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * Processes a direct refund request, saves the payment, and updates the transaction appropriately. |
|
442 | - * |
|
443 | - * @param EE_Payment_Method $payment_method |
|
444 | - * @param EE_Payment $payment_to_refund |
|
445 | - * @param array $refund_info |
|
446 | - * @return EE_Payment |
|
447 | - * @throws EE_Error |
|
448 | - * @throws InvalidArgumentException |
|
449 | - * @throws ReflectionException |
|
450 | - * @throws RuntimeException |
|
451 | - * @throws InvalidDataTypeException |
|
452 | - * @throws InvalidInterfaceException |
|
453 | - */ |
|
454 | - public function process_refund( |
|
455 | - EE_Payment_Method $payment_method, |
|
456 | - EE_Payment $payment_to_refund, |
|
457 | - array $refund_info = array() |
|
458 | - ) { |
|
459 | - if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
460 | - $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
461 | - $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
462 | - } |
|
463 | - return $payment_to_refund; |
|
464 | - } |
|
465 | - |
|
466 | - |
|
467 | - /** |
|
468 | - * This should be called each time there may have been an update to a |
|
469 | - * payment on a transaction (ie, we asked for a payment to process a |
|
470 | - * payment for a transaction, or we told a payment method about an IPN, or |
|
471 | - * we told a payment method to |
|
472 | - * "finalize_payment_for" (a transaction), or we told a payment method to |
|
473 | - * process a refund. This should handle firing the correct hooks to |
|
474 | - * indicate |
|
475 | - * what exactly happened and updating the transaction appropriately). This |
|
476 | - * could be integrated directly into EE_Transaction upon save, but we want |
|
477 | - * this logic to be separate from 'normal' plain-jane saving and updating |
|
478 | - * of transactions and payments, and to be tied to payment processing. |
|
479 | - * Note: this method DOES NOT save the payment passed into it. It is the responsibility |
|
480 | - * of previous code to decide whether or not to save (because the payment passed into |
|
481 | - * this method might be a temporary, never-to-be-saved payment from an offline gateway, |
|
482 | - * in which case we only want that payment object for some temporary usage during this request, |
|
483 | - * but we don't want it to be saved). |
|
484 | - * |
|
485 | - * @param EE_Transaction|int $transaction |
|
486 | - * @param EE_Payment $payment |
|
487 | - * @param boolean $update_txn |
|
488 | - * whether or not to call |
|
489 | - * EE_Transaction_Processor:: |
|
490 | - * update_transaction_and_registrations_after_checkout_or_payment() |
|
491 | - * (you can save 1 DB query if you know you're going |
|
492 | - * to save it later instead) |
|
493 | - * @param bool $IPN |
|
494 | - * if processing IPNs or other similar payment |
|
495 | - * related activities that occur in alternate |
|
496 | - * requests than the main one that is processing the |
|
497 | - * TXN, then set this to true to check whether the |
|
498 | - * TXN is locked before updating |
|
499 | - * @throws EE_Error |
|
500 | - * @throws InvalidArgumentException |
|
501 | - * @throws ReflectionException |
|
502 | - * @throws RuntimeException |
|
503 | - * @throws InvalidDataTypeException |
|
504 | - * @throws InvalidInterfaceException |
|
505 | - */ |
|
506 | - public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) |
|
507 | - { |
|
508 | - $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
|
509 | - /** @type EE_Transaction $transaction */ |
|
510 | - $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
511 | - // can we freely update the TXN at this moment? |
|
512 | - if ($IPN && $transaction->is_locked()) { |
|
513 | - // don't update the transaction at this exact moment |
|
514 | - // because the TXN is active in another request |
|
515 | - EE_Cron_Tasks::schedule_update_transaction_with_payment( |
|
516 | - time(), |
|
517 | - $transaction->ID(), |
|
518 | - $payment->ID() |
|
519 | - ); |
|
520 | - } else { |
|
521 | - // verify payment and that it has been saved |
|
522 | - if ($payment instanceof EE_Payment && $payment->ID()) { |
|
523 | - if ( |
|
524 | - $payment->payment_method() instanceof EE_Payment_Method |
|
525 | - && $payment->payment_method()->type_obj() instanceof EE_PMT_Base |
|
526 | - ) { |
|
527 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
528 | - // update TXN registrations with payment info |
|
529 | - $this->process_registration_payments($transaction, $payment); |
|
530 | - } |
|
531 | - $do_action = $payment->just_approved() |
|
532 | - ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' |
|
533 | - : $do_action; |
|
534 | - } else { |
|
535 | - // send out notifications |
|
536 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
537 | - $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
|
538 | - } |
|
539 | - if ($payment instanceof EE_Payment && $payment->status() !== EEM_Payment::status_id_failed) { |
|
540 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
541 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
542 | - // set new value for total paid |
|
543 | - $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
544 | - // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
|
545 | - if ($update_txn) { |
|
546 | - $this->_post_payment_processing($transaction, $payment, $IPN); |
|
547 | - } |
|
548 | - } |
|
549 | - // granular hook for others to use. |
|
550 | - do_action($do_action, $transaction, $payment); |
|
551 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
552 | - // global hook for others to use. |
|
553 | - do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
554 | - } |
|
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * update registrations REG_paid field after successful payment and link registrations with payment |
|
560 | - * |
|
561 | - * @param EE_Transaction $transaction |
|
562 | - * @param EE_Payment $payment |
|
563 | - * @param EE_Registration[] $registrations |
|
564 | - * @throws EE_Error |
|
565 | - * @throws InvalidArgumentException |
|
566 | - * @throws RuntimeException |
|
567 | - * @throws InvalidDataTypeException |
|
568 | - * @throws InvalidInterfaceException |
|
569 | - */ |
|
570 | - public function process_registration_payments( |
|
571 | - EE_Transaction $transaction, |
|
572 | - EE_Payment $payment, |
|
573 | - array $registrations = array() |
|
574 | - ) { |
|
575 | - // only process if payment was successful |
|
576 | - if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
577 | - return; |
|
578 | - } |
|
579 | - // EEM_Registration::instance()->show_next_x_db_queries(); |
|
580 | - if (empty($registrations)) { |
|
581 | - // find registrations with monies owing that can receive a payment |
|
582 | - $registrations = $transaction->registrations( |
|
583 | - array( |
|
584 | - array( |
|
585 | - // only these reg statuses can receive payments |
|
586 | - 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
587 | - 'REG_final_price' => array('!=', 0), |
|
588 | - 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
589 | - ), |
|
590 | - ) |
|
591 | - ); |
|
592 | - } |
|
593 | - // still nothing ??!?? |
|
594 | - if (empty($registrations)) { |
|
595 | - return; |
|
596 | - } |
|
597 | - // todo: break out the following logic into a separate strategy class |
|
598 | - // todo: named something like "Sequential_Reg_Payment_Strategy" |
|
599 | - // todo: which would apply payments using the capitalist "first come first paid" approach |
|
600 | - // todo: then have another strategy class like "Distributed_Reg_Payment_Strategy" |
|
601 | - // todo: which would be the socialist "everybody gets a piece of pie" approach, |
|
602 | - // todo: which would be better for deposits, where you want a bit of the payment applied to each registration |
|
603 | - $refund = $payment->is_a_refund(); |
|
604 | - // how much is available to apply to registrations? |
|
605 | - $available_payment_amount = abs($payment->amount()); |
|
606 | - foreach ($registrations as $registration) { |
|
607 | - if ($registration instanceof EE_Registration) { |
|
608 | - // nothing left? |
|
609 | - if ($available_payment_amount <= 0) { |
|
610 | - break; |
|
611 | - } |
|
612 | - if ($refund) { |
|
613 | - $available_payment_amount = $this->process_registration_refund( |
|
614 | - $registration, |
|
615 | - $payment, |
|
616 | - $available_payment_amount |
|
617 | - ); |
|
618 | - } else { |
|
619 | - $available_payment_amount = $this->process_registration_payment( |
|
620 | - $registration, |
|
621 | - $payment, |
|
622 | - $available_payment_amount |
|
623 | - ); |
|
624 | - } |
|
625 | - } |
|
626 | - } |
|
627 | - if ( |
|
628 | - $available_payment_amount > 0 |
|
629 | - && apply_filters( |
|
630 | - 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', |
|
631 | - false |
|
632 | - ) |
|
633 | - ) { |
|
634 | - EE_Error::add_attention( |
|
635 | - sprintf( |
|
636 | - __( |
|
637 | - 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', |
|
638 | - 'event_espresso' |
|
639 | - ), |
|
640 | - EEH_Template::format_currency($available_payment_amount), |
|
641 | - implode(', ', array_keys($registrations)), |
|
642 | - '<br/>', |
|
643 | - EEH_Template::format_currency($payment->amount()) |
|
644 | - ), |
|
645 | - __FILE__, |
|
646 | - __FUNCTION__, |
|
647 | - __LINE__ |
|
648 | - ); |
|
649 | - } |
|
650 | - } |
|
651 | - |
|
652 | - |
|
653 | - /** |
|
654 | - * update registration REG_paid field after successful payment and link registration with payment |
|
655 | - * |
|
656 | - * @param EE_Registration $registration |
|
657 | - * @param EE_Payment $payment |
|
658 | - * @param float $available_payment_amount |
|
659 | - * @return float |
|
660 | - * @throws EE_Error |
|
661 | - * @throws InvalidArgumentException |
|
662 | - * @throws RuntimeException |
|
663 | - * @throws InvalidDataTypeException |
|
664 | - * @throws InvalidInterfaceException |
|
665 | - */ |
|
666 | - public function process_registration_payment( |
|
667 | - EE_Registration $registration, |
|
668 | - EE_Payment $payment, |
|
669 | - $available_payment_amount = 0.00 |
|
670 | - ) { |
|
671 | - $owing = $registration->final_price() - $registration->paid(); |
|
672 | - if ($owing > 0) { |
|
673 | - // don't allow payment amount to exceed the available payment amount, OR the amount owing |
|
674 | - $payment_amount = min($available_payment_amount, $owing); |
|
675 | - // update $available_payment_amount |
|
676 | - $available_payment_amount -= $payment_amount; |
|
677 | - // calculate and set new REG_paid |
|
678 | - $registration->set_paid($registration->paid() + $payment_amount); |
|
679 | - // now save it |
|
680 | - $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
681 | - } |
|
682 | - return $available_payment_amount; |
|
683 | - } |
|
684 | - |
|
685 | - |
|
686 | - /** |
|
687 | - * update registration REG_paid field after successful payment and link registration with payment |
|
688 | - * |
|
689 | - * @param EE_Registration $registration |
|
690 | - * @param EE_Payment $payment |
|
691 | - * @param float $payment_amount |
|
692 | - * @return void |
|
693 | - * @throws EE_Error |
|
694 | - * @throws InvalidArgumentException |
|
695 | - * @throws InvalidDataTypeException |
|
696 | - * @throws InvalidInterfaceException |
|
697 | - */ |
|
698 | - protected function _apply_registration_payment( |
|
699 | - EE_Registration $registration, |
|
700 | - EE_Payment $payment, |
|
701 | - $payment_amount = 0.00 |
|
702 | - ) { |
|
703 | - // find any existing reg payment records for this registration and payment |
|
704 | - $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
|
705 | - array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
706 | - ); |
|
707 | - // if existing registration payment exists |
|
708 | - if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
709 | - // then update that record |
|
710 | - $existing_reg_payment->set_amount($payment_amount); |
|
711 | - $existing_reg_payment->save(); |
|
712 | - } else { |
|
713 | - // or add new relation between registration and payment and set amount |
|
714 | - $registration->_add_relation_to( |
|
715 | - $payment, |
|
716 | - 'Payment', |
|
717 | - array('RPY_amount' => $payment_amount) |
|
718 | - ); |
|
719 | - // make it stick |
|
720 | - $registration->save(); |
|
721 | - } |
|
722 | - } |
|
723 | - |
|
724 | - |
|
725 | - /** |
|
726 | - * update registration REG_paid field after refund and link registration with payment |
|
727 | - * |
|
728 | - * @param EE_Registration $registration |
|
729 | - * @param EE_Payment $payment |
|
730 | - * @param float $available_refund_amount - IMPORTANT !!! SEND AVAILABLE REFUND AMOUNT AS A POSITIVE NUMBER |
|
731 | - * @return float |
|
732 | - * @throws EE_Error |
|
733 | - * @throws InvalidArgumentException |
|
734 | - * @throws RuntimeException |
|
735 | - * @throws InvalidDataTypeException |
|
736 | - * @throws InvalidInterfaceException |
|
737 | - */ |
|
738 | - public function process_registration_refund( |
|
739 | - EE_Registration $registration, |
|
740 | - EE_Payment $payment, |
|
741 | - $available_refund_amount = 0.00 |
|
742 | - ) { |
|
743 | - // EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
|
744 | - if ($registration->paid() > 0) { |
|
745 | - // ensure $available_refund_amount is NOT negative |
|
746 | - $available_refund_amount = (float) abs($available_refund_amount); |
|
747 | - // don't allow refund amount to exceed the available payment amount, OR the amount paid |
|
748 | - $refund_amount = min($available_refund_amount, (float) $registration->paid()); |
|
749 | - // update $available_payment_amount |
|
750 | - $available_refund_amount -= $refund_amount; |
|
751 | - // calculate and set new REG_paid |
|
752 | - $registration->set_paid($registration->paid() - $refund_amount); |
|
753 | - // convert payment amount back to a negative value for storage in the db |
|
754 | - $refund_amount = (float) abs($refund_amount) * -1; |
|
755 | - // now save it |
|
756 | - $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
757 | - } |
|
758 | - return $available_refund_amount; |
|
759 | - } |
|
760 | - |
|
761 | - |
|
762 | - /** |
|
763 | - * Process payments and transaction after payment process completed. |
|
764 | - * ultimately this will send the TXN and payment details off so that notifications can be sent out. |
|
765 | - * if this request happens to be processing an IPN, |
|
766 | - * then we will also set the Payment Options Reg Step to completed, |
|
767 | - * and attempt to completely finalize the TXN if all of the other Reg Steps are completed as well. |
|
768 | - * |
|
769 | - * @param EE_Transaction $transaction |
|
770 | - * @param EE_Payment $payment |
|
771 | - * @param bool $IPN |
|
772 | - * @throws EE_Error |
|
773 | - * @throws InvalidArgumentException |
|
774 | - * @throws ReflectionException |
|
775 | - * @throws RuntimeException |
|
776 | - * @throws InvalidDataTypeException |
|
777 | - * @throws InvalidInterfaceException |
|
778 | - */ |
|
779 | - protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) |
|
780 | - { |
|
781 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
782 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
783 | - // is the Payment Options Reg Step completed ? |
|
784 | - $payment_options_step_completed = $transaction->reg_step_completed('payment_options'); |
|
785 | - // if the Payment Options Reg Step is completed... |
|
786 | - $revisit = $payment_options_step_completed === true; |
|
787 | - // then this is kinda sorta a revisit with regards to payments at least |
|
788 | - $transaction_processor->set_revisit($revisit); |
|
789 | - // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
|
790 | - if ( |
|
791 | - $IPN |
|
792 | - && $payment_options_step_completed !== true |
|
793 | - && ($payment->is_approved() || $payment->is_pending()) |
|
794 | - ) { |
|
795 | - $payment_options_step_completed = $transaction->set_reg_step_completed( |
|
796 | - 'payment_options' |
|
797 | - ); |
|
798 | - } |
|
799 | - // maybe update status, but don't save transaction just yet |
|
800 | - $transaction->update_status_based_on_total_paid(false); |
|
801 | - // check if 'finalize_registration' step has been completed... |
|
802 | - $finalized = $transaction->reg_step_completed('finalize_registration'); |
|
803 | - // if this is an IPN and the final step has not been initiated |
|
804 | - if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
805 | - // and if it hasn't already been set as being started... |
|
806 | - $finalized = $transaction->set_reg_step_initiated('finalize_registration'); |
|
807 | - } |
|
808 | - $transaction->save(); |
|
809 | - // because the above will return false if the final step was not fully completed, we need to check again... |
|
810 | - if ($IPN && $finalized !== false) { |
|
811 | - // and if we are all good to go, then send out notifications |
|
812 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
813 | - // ok, now process the transaction according to the payment |
|
814 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
815 | - $transaction, |
|
816 | - $payment |
|
817 | - ); |
|
818 | - } |
|
819 | - // DEBUG LOG |
|
820 | - $payment_method = $payment->payment_method(); |
|
821 | - if ($payment_method instanceof EE_Payment_Method) { |
|
822 | - $payment_method_type_obj = $payment_method->type_obj(); |
|
823 | - if ($payment_method_type_obj instanceof EE_PMT_Base) { |
|
824 | - $gateway = $payment_method_type_obj->get_gateway(); |
|
825 | - if ($gateway instanceof EE_Gateway) { |
|
826 | - $gateway->log( |
|
827 | - array( |
|
828 | - 'message' => (string) __('Post Payment Transaction Details', 'event_espresso'), |
|
829 | - 'transaction' => $transaction->model_field_array(), |
|
830 | - 'finalized' => $finalized, |
|
831 | - 'IPN' => $IPN, |
|
832 | - 'deliver_notifications' => has_filter( |
|
833 | - 'FHEE__EED_Messages___maybe_registration__deliver_notifications' |
|
834 | - ), |
|
835 | - ), |
|
836 | - $payment |
|
837 | - ); |
|
838 | - } |
|
839 | - } |
|
840 | - } |
|
841 | - } |
|
842 | - |
|
843 | - |
|
844 | - /** |
|
845 | - * Force posts to PayPal to use TLS v1.2. See: |
|
846 | - * https://core.trac.wordpress.org/ticket/36320 |
|
847 | - * https://core.trac.wordpress.org/ticket/34924#comment:15 |
|
848 | - * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US |
|
849 | - * This will affect PayPal standard, pro, express, and Payflow. |
|
850 | - * |
|
851 | - * @param $handle |
|
852 | - * @param $r |
|
853 | - * @param $url |
|
854 | - */ |
|
855 | - public static function _curl_requests_to_paypal_use_tls($handle, $r, $url) |
|
856 | - { |
|
857 | - if (strpos($url, 'https://') !== false && strpos($url, '.paypal.com') !== false) { |
|
858 | - // Use the value of the constant CURL_SSLVERSION_TLSv1 = 1 |
|
859 | - // instead of the constant because it might not be defined |
|
860 | - curl_setopt($handle, CURLOPT_SSLVERSION, 6); |
|
861 | - } |
|
862 | - } |
|
21 | + /** |
|
22 | + * @var EE_Payment_Processor $_instance |
|
23 | + * @access private |
|
24 | + */ |
|
25 | + private static $_instance; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * @singleton method used to instantiate class object |
|
30 | + * @access public |
|
31 | + * @return EE_Payment_Processor instance |
|
32 | + */ |
|
33 | + public static function instance() |
|
34 | + { |
|
35 | + // check if class object is instantiated |
|
36 | + if (! self::$_instance instanceof EE_Payment_Processor) { |
|
37 | + self::$_instance = new self(); |
|
38 | + } |
|
39 | + return self::$_instance; |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * @return EE_Payment_Processor |
|
45 | + */ |
|
46 | + public static function reset() |
|
47 | + { |
|
48 | + self::$_instance = null; |
|
49 | + return self::instance(); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + *private constructor to prevent direct creation |
|
55 | + * |
|
56 | + * @Constructor |
|
57 | + * @access private |
|
58 | + */ |
|
59 | + private function __construct() |
|
60 | + { |
|
61 | + do_action('AHEE__EE_Payment_Processor__construct'); |
|
62 | + add_action('http_api_curl', array($this, '_curl_requests_to_paypal_use_tls'), 10, 3); |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * Using the selected gateway, processes the payment for that transaction, and updates the transaction |
|
68 | + * appropriately. Saves the payment that is generated |
|
69 | + * |
|
70 | + * @param EE_Payment_Method $payment_method |
|
71 | + * @param EE_Transaction $transaction |
|
72 | + * @param float $amount if only part of the transaction is to be paid for, how much. |
|
73 | + * Leave null if payment is for the full amount owing |
|
74 | + * @param EE_Billing_Info_Form $billing_form (or probably null, if it's an offline or offsite payment method). |
|
75 | + * Receive_form_submission() should have |
|
76 | + * already been called on the billing form |
|
77 | + * (ie, its inputs should have their normalized values set). |
|
78 | + * @param string $return_url string used mostly by offsite gateways to specify |
|
79 | + * where to go AFTER the offsite gateway |
|
80 | + * @param string $method like 'CART', indicates who the client who called this was |
|
81 | + * @param bool $by_admin TRUE if payment is being attempted from the admin |
|
82 | + * @param boolean $update_txn whether or not to call |
|
83 | + * EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() |
|
84 | + * @param string $cancel_url URL to return to if off-site payments are cancelled |
|
85 | + * @return EE_Payment |
|
86 | + * @throws EE_Error |
|
87 | + * @throws InvalidArgumentException |
|
88 | + * @throws ReflectionException |
|
89 | + * @throws RuntimeException |
|
90 | + * @throws InvalidDataTypeException |
|
91 | + * @throws InvalidInterfaceException |
|
92 | + */ |
|
93 | + public function process_payment( |
|
94 | + EE_Payment_Method $payment_method, |
|
95 | + EE_Transaction $transaction, |
|
96 | + $amount = null, |
|
97 | + $billing_form = null, |
|
98 | + $return_url = null, |
|
99 | + $method = 'CART', |
|
100 | + $by_admin = false, |
|
101 | + $update_txn = true, |
|
102 | + $cancel_url = '' |
|
103 | + ) { |
|
104 | + if ((float) $amount < 0) { |
|
105 | + throw new EE_Error( |
|
106 | + sprintf( |
|
107 | + __( |
|
108 | + 'Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', |
|
109 | + 'event_espresso' |
|
110 | + ), |
|
111 | + $amount, |
|
112 | + $transaction->ID() |
|
113 | + ) |
|
114 | + ); |
|
115 | + } |
|
116 | + // verify payment method |
|
117 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( |
|
118 | + $payment_method, |
|
119 | + true |
|
120 | + ); |
|
121 | + // verify transaction |
|
122 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
123 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
124 | + // verify payment method type |
|
125 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
126 | + $payment = $payment_method->type_obj()->process_payment( |
|
127 | + $transaction, |
|
128 | + min($amount, $transaction->remaining()), // make sure we don't overcharge |
|
129 | + $billing_form, |
|
130 | + $return_url, |
|
131 | + add_query_arg(array('ee_cancel_payment' => true), $cancel_url), |
|
132 | + $method, |
|
133 | + $by_admin |
|
134 | + ); |
|
135 | + // check if payment method uses an off-site gateway |
|
136 | + if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) { |
|
137 | + // don't process payments for off-site gateways yet because no payment has occurred yet |
|
138 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
139 | + } |
|
140 | + return $payment; |
|
141 | + } |
|
142 | + EE_Error::add_error( |
|
143 | + sprintf( |
|
144 | + __( |
|
145 | + 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
146 | + 'event_espresso' |
|
147 | + ), |
|
148 | + '<br/>', |
|
149 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
150 | + ), |
|
151 | + __FILE__, |
|
152 | + __FUNCTION__, |
|
153 | + __LINE__ |
|
154 | + ); |
|
155 | + return null; |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * @param EE_Transaction|int $transaction |
|
161 | + * @param EE_Payment_Method $payment_method |
|
162 | + * @return string |
|
163 | + * @throws EE_Error |
|
164 | + * @throws InvalidArgumentException |
|
165 | + * @throws InvalidDataTypeException |
|
166 | + * @throws InvalidInterfaceException |
|
167 | + */ |
|
168 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) |
|
169 | + { |
|
170 | + /** @type \EE_Transaction $transaction */ |
|
171 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
172 | + $primary_reg = $transaction->primary_registration(); |
|
173 | + if (! $primary_reg instanceof EE_Registration) { |
|
174 | + throw new EE_Error( |
|
175 | + sprintf( |
|
176 | + __( |
|
177 | + 'Cannot get IPN URL for transaction with ID %d because it has no primary registration', |
|
178 | + 'event_espresso' |
|
179 | + ), |
|
180 | + $transaction->ID() |
|
181 | + ) |
|
182 | + ); |
|
183 | + } |
|
184 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( |
|
185 | + $payment_method, |
|
186 | + true |
|
187 | + ); |
|
188 | + $url = add_query_arg( |
|
189 | + array( |
|
190 | + 'e_reg_url_link' => $primary_reg->reg_url_link(), |
|
191 | + 'ee_payment_method' => $payment_method->slug(), |
|
192 | + ), |
|
193 | + EE_Registry::instance()->CFG->core->txn_page_url() |
|
194 | + ); |
|
195 | + return $url; |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * Process the IPN. Firstly, we'll hope we put the standard args into the IPN URL so |
|
201 | + * we can easily find what registration the IPN is for and what payment method. |
|
202 | + * However, if not, we'll give all payment methods a chance to claim it and process it. |
|
203 | + * If a payment is found for the IPN info, it is saved. |
|
204 | + * |
|
205 | + * @param array $_req_data eg $_REQUEST |
|
206 | + * @param EE_Transaction|int $transaction optional (or a transactions id) |
|
207 | + * @param EE_Payment_Method $payment_method (or a slug or id of one) |
|
208 | + * @param boolean $update_txn whether or not to call |
|
209 | + * EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() |
|
210 | + * @param bool $separate_IPN_request whether the IPN uses a separate request (true, like PayPal) |
|
211 | + * or is processed manually (false, like Authorize.net) |
|
212 | + * @throws EE_Error |
|
213 | + * @throws Exception |
|
214 | + * @return EE_Payment |
|
215 | + * @throws \RuntimeException |
|
216 | + * @throws \ReflectionException |
|
217 | + * @throws \InvalidArgumentException |
|
218 | + * @throws InvalidInterfaceException |
|
219 | + * @throws InvalidDataTypeException |
|
220 | + */ |
|
221 | + public function process_ipn( |
|
222 | + $_req_data, |
|
223 | + $transaction = null, |
|
224 | + $payment_method = null, |
|
225 | + $update_txn = true, |
|
226 | + $separate_IPN_request = true |
|
227 | + ) { |
|
228 | + EE_Registry::instance()->load_model('Change_Log'); |
|
229 | + $_req_data = $this->_remove_unusable_characters_from_array((array) $_req_data); |
|
230 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
231 | + $obj_for_log = null; |
|
232 | + if ($transaction instanceof EE_Transaction) { |
|
233 | + $obj_for_log = $transaction; |
|
234 | + if ($payment_method instanceof EE_Payment_Method) { |
|
235 | + $obj_for_log = EEM_Payment::instance()->get_one( |
|
236 | + array( |
|
237 | + array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), |
|
238 | + 'order_by' => array('PAY_timestamp' => 'desc'), |
|
239 | + ) |
|
240 | + ); |
|
241 | + } |
|
242 | + } elseif ($payment_method instanceof EE_Payment) { |
|
243 | + $obj_for_log = $payment_method; |
|
244 | + } |
|
245 | + $log = EEM_Change_Log::instance()->log( |
|
246 | + EEM_Change_Log::type_gateway, |
|
247 | + array('IPN data received' => $_req_data), |
|
248 | + $obj_for_log |
|
249 | + ); |
|
250 | + try { |
|
251 | + /** |
|
252 | + * @var EE_Payment $payment |
|
253 | + */ |
|
254 | + $payment = null; |
|
255 | + if ($transaction && $payment_method) { |
|
256 | + /** @type EE_Transaction $transaction */ |
|
257 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
258 | + /** @type EE_Payment_Method $payment_method */ |
|
259 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
|
260 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
261 | + try { |
|
262 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
263 | + $log->set_object($payment); |
|
264 | + } catch (EventEspresso\core\exceptions\IpnException $e) { |
|
265 | + EEM_Change_Log::instance()->log( |
|
266 | + EEM_Change_Log::type_gateway, |
|
267 | + array( |
|
268 | + 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
269 | + 'current_url' => EEH_URL::current_url(), |
|
270 | + 'payment' => $e->getPaymentProperties(), |
|
271 | + 'IPN_data' => $e->getIpnData(), |
|
272 | + ), |
|
273 | + $obj_for_log |
|
274 | + ); |
|
275 | + return $e->getPayment(); |
|
276 | + } |
|
277 | + } else { |
|
278 | + // not a payment |
|
279 | + EE_Error::add_error( |
|
280 | + sprintf( |
|
281 | + __( |
|
282 | + 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', |
|
283 | + 'event_espresso' |
|
284 | + ), |
|
285 | + '<br/>', |
|
286 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
287 | + ), |
|
288 | + __FILE__, |
|
289 | + __FUNCTION__, |
|
290 | + __LINE__ |
|
291 | + ); |
|
292 | + } |
|
293 | + } else { |
|
294 | + // that's actually pretty ok. The IPN just wasn't able |
|
295 | + // to identify which transaction or payment method this was for |
|
296 | + // give all active payment methods a chance to claim it |
|
297 | + $active_payment_methods = EEM_Payment_Method::instance()->get_all_active(); |
|
298 | + foreach ($active_payment_methods as $active_payment_method) { |
|
299 | + try { |
|
300 | + $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
301 | + $payment_method = $active_payment_method; |
|
302 | + EEM_Change_Log::instance()->log( |
|
303 | + EEM_Change_Log::type_gateway, |
|
304 | + array('IPN data' => $_req_data), |
|
305 | + $payment |
|
306 | + ); |
|
307 | + break; |
|
308 | + } catch (EventEspresso\core\exceptions\IpnException $e) { |
|
309 | + EEM_Change_Log::instance()->log( |
|
310 | + EEM_Change_Log::type_gateway, |
|
311 | + array( |
|
312 | + 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
313 | + 'current_url' => EEH_URL::current_url(), |
|
314 | + 'payment' => $e->getPaymentProperties(), |
|
315 | + 'IPN_data' => $e->getIpnData(), |
|
316 | + ), |
|
317 | + $obj_for_log |
|
318 | + ); |
|
319 | + return $e->getPayment(); |
|
320 | + } catch (EE_Error $e) { |
|
321 | + // that's fine- it apparently couldn't handle the IPN |
|
322 | + } |
|
323 | + } |
|
324 | + } |
|
325 | + // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
|
326 | + if ($payment instanceof EE_Payment) { |
|
327 | + $payment->save(); |
|
328 | + // update the TXN |
|
329 | + $this->update_txn_based_on_payment( |
|
330 | + $transaction, |
|
331 | + $payment, |
|
332 | + $update_txn, |
|
333 | + $separate_IPN_request |
|
334 | + ); |
|
335 | + } else { |
|
336 | + // we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
|
337 | + if ($payment_method) { |
|
338 | + EEM_Change_Log::instance()->log( |
|
339 | + EEM_Change_Log::type_gateway, |
|
340 | + array('IPN data' => $_req_data), |
|
341 | + $payment_method |
|
342 | + ); |
|
343 | + } elseif ($transaction) { |
|
344 | + EEM_Change_Log::instance()->log( |
|
345 | + EEM_Change_Log::type_gateway, |
|
346 | + array('IPN data' => $_req_data), |
|
347 | + $transaction |
|
348 | + ); |
|
349 | + } |
|
350 | + } |
|
351 | + return $payment; |
|
352 | + } catch (EE_Error $e) { |
|
353 | + do_action( |
|
354 | + 'AHEE__log', |
|
355 | + __FILE__, |
|
356 | + __FUNCTION__, |
|
357 | + sprintf( |
|
358 | + __( |
|
359 | + 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', |
|
360 | + 'event_espresso' |
|
361 | + ), |
|
362 | + print_r($transaction, true), |
|
363 | + print_r($_req_data, true), |
|
364 | + $e->getMessage() |
|
365 | + ) |
|
366 | + ); |
|
367 | + throw $e; |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + /** |
|
373 | + * Removes any non-printable illegal characters from the input, |
|
374 | + * which might cause a raucous when trying to insert into the database |
|
375 | + * |
|
376 | + * @param array $request_data |
|
377 | + * @return array |
|
378 | + */ |
|
379 | + protected function _remove_unusable_characters_from_array(array $request_data) |
|
380 | + { |
|
381 | + $return_data = array(); |
|
382 | + foreach ($request_data as $key => $value) { |
|
383 | + $return_data[ $this->_remove_unusable_characters($key) ] = $this->_remove_unusable_characters( |
|
384 | + $value |
|
385 | + ); |
|
386 | + } |
|
387 | + return $return_data; |
|
388 | + } |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * Removes any non-printable illegal characters from the input, |
|
393 | + * which might cause a raucous when trying to insert into the database |
|
394 | + * |
|
395 | + * @param string $request_data |
|
396 | + * @return string |
|
397 | + */ |
|
398 | + protected function _remove_unusable_characters($request_data) |
|
399 | + { |
|
400 | + return preg_replace('/[^[:print:]]/', '', $request_data); |
|
401 | + } |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * Should be called just before displaying the payment attempt results to the user, |
|
406 | + * when the payment attempt has finished. Some payment methods may have special |
|
407 | + * logic to perform here. For example, if process_payment() happens on a special request |
|
408 | + * and then the user is redirected to a page that displays the payment's status, this |
|
409 | + * should be called while loading the page that displays the payment's status. If the user is |
|
410 | + * sent to an offsite payment provider, this should be called upon returning from that offsite payment |
|
411 | + * provider. |
|
412 | + * |
|
413 | + * @param EE_Transaction|int $transaction |
|
414 | + * @param bool $update_txn whether or not to call |
|
415 | + * EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() |
|
416 | + * @return EE_Payment |
|
417 | + * @throws EE_Error |
|
418 | + * @throws InvalidArgumentException |
|
419 | + * @throws ReflectionException |
|
420 | + * @throws RuntimeException |
|
421 | + * @throws InvalidDataTypeException |
|
422 | + * @throws InvalidInterfaceException |
|
423 | + * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, |
|
424 | + * to call handle_ipn() for offsite gateways that don't receive separate IPNs |
|
425 | + */ |
|
426 | + public function finalize_payment_for($transaction, $update_txn = true) |
|
427 | + { |
|
428 | + /** @var $transaction EE_Transaction */ |
|
429 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
430 | + $last_payment_method = $transaction->payment_method(); |
|
431 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
432 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
433 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
434 | + return $payment; |
|
435 | + } |
|
436 | + return null; |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * Processes a direct refund request, saves the payment, and updates the transaction appropriately. |
|
442 | + * |
|
443 | + * @param EE_Payment_Method $payment_method |
|
444 | + * @param EE_Payment $payment_to_refund |
|
445 | + * @param array $refund_info |
|
446 | + * @return EE_Payment |
|
447 | + * @throws EE_Error |
|
448 | + * @throws InvalidArgumentException |
|
449 | + * @throws ReflectionException |
|
450 | + * @throws RuntimeException |
|
451 | + * @throws InvalidDataTypeException |
|
452 | + * @throws InvalidInterfaceException |
|
453 | + */ |
|
454 | + public function process_refund( |
|
455 | + EE_Payment_Method $payment_method, |
|
456 | + EE_Payment $payment_to_refund, |
|
457 | + array $refund_info = array() |
|
458 | + ) { |
|
459 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
460 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
461 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
462 | + } |
|
463 | + return $payment_to_refund; |
|
464 | + } |
|
465 | + |
|
466 | + |
|
467 | + /** |
|
468 | + * This should be called each time there may have been an update to a |
|
469 | + * payment on a transaction (ie, we asked for a payment to process a |
|
470 | + * payment for a transaction, or we told a payment method about an IPN, or |
|
471 | + * we told a payment method to |
|
472 | + * "finalize_payment_for" (a transaction), or we told a payment method to |
|
473 | + * process a refund. This should handle firing the correct hooks to |
|
474 | + * indicate |
|
475 | + * what exactly happened and updating the transaction appropriately). This |
|
476 | + * could be integrated directly into EE_Transaction upon save, but we want |
|
477 | + * this logic to be separate from 'normal' plain-jane saving and updating |
|
478 | + * of transactions and payments, and to be tied to payment processing. |
|
479 | + * Note: this method DOES NOT save the payment passed into it. It is the responsibility |
|
480 | + * of previous code to decide whether or not to save (because the payment passed into |
|
481 | + * this method might be a temporary, never-to-be-saved payment from an offline gateway, |
|
482 | + * in which case we only want that payment object for some temporary usage during this request, |
|
483 | + * but we don't want it to be saved). |
|
484 | + * |
|
485 | + * @param EE_Transaction|int $transaction |
|
486 | + * @param EE_Payment $payment |
|
487 | + * @param boolean $update_txn |
|
488 | + * whether or not to call |
|
489 | + * EE_Transaction_Processor:: |
|
490 | + * update_transaction_and_registrations_after_checkout_or_payment() |
|
491 | + * (you can save 1 DB query if you know you're going |
|
492 | + * to save it later instead) |
|
493 | + * @param bool $IPN |
|
494 | + * if processing IPNs or other similar payment |
|
495 | + * related activities that occur in alternate |
|
496 | + * requests than the main one that is processing the |
|
497 | + * TXN, then set this to true to check whether the |
|
498 | + * TXN is locked before updating |
|
499 | + * @throws EE_Error |
|
500 | + * @throws InvalidArgumentException |
|
501 | + * @throws ReflectionException |
|
502 | + * @throws RuntimeException |
|
503 | + * @throws InvalidDataTypeException |
|
504 | + * @throws InvalidInterfaceException |
|
505 | + */ |
|
506 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) |
|
507 | + { |
|
508 | + $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
|
509 | + /** @type EE_Transaction $transaction */ |
|
510 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
511 | + // can we freely update the TXN at this moment? |
|
512 | + if ($IPN && $transaction->is_locked()) { |
|
513 | + // don't update the transaction at this exact moment |
|
514 | + // because the TXN is active in another request |
|
515 | + EE_Cron_Tasks::schedule_update_transaction_with_payment( |
|
516 | + time(), |
|
517 | + $transaction->ID(), |
|
518 | + $payment->ID() |
|
519 | + ); |
|
520 | + } else { |
|
521 | + // verify payment and that it has been saved |
|
522 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
523 | + if ( |
|
524 | + $payment->payment_method() instanceof EE_Payment_Method |
|
525 | + && $payment->payment_method()->type_obj() instanceof EE_PMT_Base |
|
526 | + ) { |
|
527 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
528 | + // update TXN registrations with payment info |
|
529 | + $this->process_registration_payments($transaction, $payment); |
|
530 | + } |
|
531 | + $do_action = $payment->just_approved() |
|
532 | + ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' |
|
533 | + : $do_action; |
|
534 | + } else { |
|
535 | + // send out notifications |
|
536 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
537 | + $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
|
538 | + } |
|
539 | + if ($payment instanceof EE_Payment && $payment->status() !== EEM_Payment::status_id_failed) { |
|
540 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
541 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
542 | + // set new value for total paid |
|
543 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
544 | + // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
|
545 | + if ($update_txn) { |
|
546 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
547 | + } |
|
548 | + } |
|
549 | + // granular hook for others to use. |
|
550 | + do_action($do_action, $transaction, $payment); |
|
551 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
552 | + // global hook for others to use. |
|
553 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
554 | + } |
|
555 | + } |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * update registrations REG_paid field after successful payment and link registrations with payment |
|
560 | + * |
|
561 | + * @param EE_Transaction $transaction |
|
562 | + * @param EE_Payment $payment |
|
563 | + * @param EE_Registration[] $registrations |
|
564 | + * @throws EE_Error |
|
565 | + * @throws InvalidArgumentException |
|
566 | + * @throws RuntimeException |
|
567 | + * @throws InvalidDataTypeException |
|
568 | + * @throws InvalidInterfaceException |
|
569 | + */ |
|
570 | + public function process_registration_payments( |
|
571 | + EE_Transaction $transaction, |
|
572 | + EE_Payment $payment, |
|
573 | + array $registrations = array() |
|
574 | + ) { |
|
575 | + // only process if payment was successful |
|
576 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
577 | + return; |
|
578 | + } |
|
579 | + // EEM_Registration::instance()->show_next_x_db_queries(); |
|
580 | + if (empty($registrations)) { |
|
581 | + // find registrations with monies owing that can receive a payment |
|
582 | + $registrations = $transaction->registrations( |
|
583 | + array( |
|
584 | + array( |
|
585 | + // only these reg statuses can receive payments |
|
586 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
587 | + 'REG_final_price' => array('!=', 0), |
|
588 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
589 | + ), |
|
590 | + ) |
|
591 | + ); |
|
592 | + } |
|
593 | + // still nothing ??!?? |
|
594 | + if (empty($registrations)) { |
|
595 | + return; |
|
596 | + } |
|
597 | + // todo: break out the following logic into a separate strategy class |
|
598 | + // todo: named something like "Sequential_Reg_Payment_Strategy" |
|
599 | + // todo: which would apply payments using the capitalist "first come first paid" approach |
|
600 | + // todo: then have another strategy class like "Distributed_Reg_Payment_Strategy" |
|
601 | + // todo: which would be the socialist "everybody gets a piece of pie" approach, |
|
602 | + // todo: which would be better for deposits, where you want a bit of the payment applied to each registration |
|
603 | + $refund = $payment->is_a_refund(); |
|
604 | + // how much is available to apply to registrations? |
|
605 | + $available_payment_amount = abs($payment->amount()); |
|
606 | + foreach ($registrations as $registration) { |
|
607 | + if ($registration instanceof EE_Registration) { |
|
608 | + // nothing left? |
|
609 | + if ($available_payment_amount <= 0) { |
|
610 | + break; |
|
611 | + } |
|
612 | + if ($refund) { |
|
613 | + $available_payment_amount = $this->process_registration_refund( |
|
614 | + $registration, |
|
615 | + $payment, |
|
616 | + $available_payment_amount |
|
617 | + ); |
|
618 | + } else { |
|
619 | + $available_payment_amount = $this->process_registration_payment( |
|
620 | + $registration, |
|
621 | + $payment, |
|
622 | + $available_payment_amount |
|
623 | + ); |
|
624 | + } |
|
625 | + } |
|
626 | + } |
|
627 | + if ( |
|
628 | + $available_payment_amount > 0 |
|
629 | + && apply_filters( |
|
630 | + 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', |
|
631 | + false |
|
632 | + ) |
|
633 | + ) { |
|
634 | + EE_Error::add_attention( |
|
635 | + sprintf( |
|
636 | + __( |
|
637 | + 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', |
|
638 | + 'event_espresso' |
|
639 | + ), |
|
640 | + EEH_Template::format_currency($available_payment_amount), |
|
641 | + implode(', ', array_keys($registrations)), |
|
642 | + '<br/>', |
|
643 | + EEH_Template::format_currency($payment->amount()) |
|
644 | + ), |
|
645 | + __FILE__, |
|
646 | + __FUNCTION__, |
|
647 | + __LINE__ |
|
648 | + ); |
|
649 | + } |
|
650 | + } |
|
651 | + |
|
652 | + |
|
653 | + /** |
|
654 | + * update registration REG_paid field after successful payment and link registration with payment |
|
655 | + * |
|
656 | + * @param EE_Registration $registration |
|
657 | + * @param EE_Payment $payment |
|
658 | + * @param float $available_payment_amount |
|
659 | + * @return float |
|
660 | + * @throws EE_Error |
|
661 | + * @throws InvalidArgumentException |
|
662 | + * @throws RuntimeException |
|
663 | + * @throws InvalidDataTypeException |
|
664 | + * @throws InvalidInterfaceException |
|
665 | + */ |
|
666 | + public function process_registration_payment( |
|
667 | + EE_Registration $registration, |
|
668 | + EE_Payment $payment, |
|
669 | + $available_payment_amount = 0.00 |
|
670 | + ) { |
|
671 | + $owing = $registration->final_price() - $registration->paid(); |
|
672 | + if ($owing > 0) { |
|
673 | + // don't allow payment amount to exceed the available payment amount, OR the amount owing |
|
674 | + $payment_amount = min($available_payment_amount, $owing); |
|
675 | + // update $available_payment_amount |
|
676 | + $available_payment_amount -= $payment_amount; |
|
677 | + // calculate and set new REG_paid |
|
678 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
679 | + // now save it |
|
680 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
681 | + } |
|
682 | + return $available_payment_amount; |
|
683 | + } |
|
684 | + |
|
685 | + |
|
686 | + /** |
|
687 | + * update registration REG_paid field after successful payment and link registration with payment |
|
688 | + * |
|
689 | + * @param EE_Registration $registration |
|
690 | + * @param EE_Payment $payment |
|
691 | + * @param float $payment_amount |
|
692 | + * @return void |
|
693 | + * @throws EE_Error |
|
694 | + * @throws InvalidArgumentException |
|
695 | + * @throws InvalidDataTypeException |
|
696 | + * @throws InvalidInterfaceException |
|
697 | + */ |
|
698 | + protected function _apply_registration_payment( |
|
699 | + EE_Registration $registration, |
|
700 | + EE_Payment $payment, |
|
701 | + $payment_amount = 0.00 |
|
702 | + ) { |
|
703 | + // find any existing reg payment records for this registration and payment |
|
704 | + $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
|
705 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
706 | + ); |
|
707 | + // if existing registration payment exists |
|
708 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
709 | + // then update that record |
|
710 | + $existing_reg_payment->set_amount($payment_amount); |
|
711 | + $existing_reg_payment->save(); |
|
712 | + } else { |
|
713 | + // or add new relation between registration and payment and set amount |
|
714 | + $registration->_add_relation_to( |
|
715 | + $payment, |
|
716 | + 'Payment', |
|
717 | + array('RPY_amount' => $payment_amount) |
|
718 | + ); |
|
719 | + // make it stick |
|
720 | + $registration->save(); |
|
721 | + } |
|
722 | + } |
|
723 | + |
|
724 | + |
|
725 | + /** |
|
726 | + * update registration REG_paid field after refund and link registration with payment |
|
727 | + * |
|
728 | + * @param EE_Registration $registration |
|
729 | + * @param EE_Payment $payment |
|
730 | + * @param float $available_refund_amount - IMPORTANT !!! SEND AVAILABLE REFUND AMOUNT AS A POSITIVE NUMBER |
|
731 | + * @return float |
|
732 | + * @throws EE_Error |
|
733 | + * @throws InvalidArgumentException |
|
734 | + * @throws RuntimeException |
|
735 | + * @throws InvalidDataTypeException |
|
736 | + * @throws InvalidInterfaceException |
|
737 | + */ |
|
738 | + public function process_registration_refund( |
|
739 | + EE_Registration $registration, |
|
740 | + EE_Payment $payment, |
|
741 | + $available_refund_amount = 0.00 |
|
742 | + ) { |
|
743 | + // EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
|
744 | + if ($registration->paid() > 0) { |
|
745 | + // ensure $available_refund_amount is NOT negative |
|
746 | + $available_refund_amount = (float) abs($available_refund_amount); |
|
747 | + // don't allow refund amount to exceed the available payment amount, OR the amount paid |
|
748 | + $refund_amount = min($available_refund_amount, (float) $registration->paid()); |
|
749 | + // update $available_payment_amount |
|
750 | + $available_refund_amount -= $refund_amount; |
|
751 | + // calculate and set new REG_paid |
|
752 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
753 | + // convert payment amount back to a negative value for storage in the db |
|
754 | + $refund_amount = (float) abs($refund_amount) * -1; |
|
755 | + // now save it |
|
756 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
757 | + } |
|
758 | + return $available_refund_amount; |
|
759 | + } |
|
760 | + |
|
761 | + |
|
762 | + /** |
|
763 | + * Process payments and transaction after payment process completed. |
|
764 | + * ultimately this will send the TXN and payment details off so that notifications can be sent out. |
|
765 | + * if this request happens to be processing an IPN, |
|
766 | + * then we will also set the Payment Options Reg Step to completed, |
|
767 | + * and attempt to completely finalize the TXN if all of the other Reg Steps are completed as well. |
|
768 | + * |
|
769 | + * @param EE_Transaction $transaction |
|
770 | + * @param EE_Payment $payment |
|
771 | + * @param bool $IPN |
|
772 | + * @throws EE_Error |
|
773 | + * @throws InvalidArgumentException |
|
774 | + * @throws ReflectionException |
|
775 | + * @throws RuntimeException |
|
776 | + * @throws InvalidDataTypeException |
|
777 | + * @throws InvalidInterfaceException |
|
778 | + */ |
|
779 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) |
|
780 | + { |
|
781 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
782 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
783 | + // is the Payment Options Reg Step completed ? |
|
784 | + $payment_options_step_completed = $transaction->reg_step_completed('payment_options'); |
|
785 | + // if the Payment Options Reg Step is completed... |
|
786 | + $revisit = $payment_options_step_completed === true; |
|
787 | + // then this is kinda sorta a revisit with regards to payments at least |
|
788 | + $transaction_processor->set_revisit($revisit); |
|
789 | + // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
|
790 | + if ( |
|
791 | + $IPN |
|
792 | + && $payment_options_step_completed !== true |
|
793 | + && ($payment->is_approved() || $payment->is_pending()) |
|
794 | + ) { |
|
795 | + $payment_options_step_completed = $transaction->set_reg_step_completed( |
|
796 | + 'payment_options' |
|
797 | + ); |
|
798 | + } |
|
799 | + // maybe update status, but don't save transaction just yet |
|
800 | + $transaction->update_status_based_on_total_paid(false); |
|
801 | + // check if 'finalize_registration' step has been completed... |
|
802 | + $finalized = $transaction->reg_step_completed('finalize_registration'); |
|
803 | + // if this is an IPN and the final step has not been initiated |
|
804 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
805 | + // and if it hasn't already been set as being started... |
|
806 | + $finalized = $transaction->set_reg_step_initiated('finalize_registration'); |
|
807 | + } |
|
808 | + $transaction->save(); |
|
809 | + // because the above will return false if the final step was not fully completed, we need to check again... |
|
810 | + if ($IPN && $finalized !== false) { |
|
811 | + // and if we are all good to go, then send out notifications |
|
812 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
813 | + // ok, now process the transaction according to the payment |
|
814 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
815 | + $transaction, |
|
816 | + $payment |
|
817 | + ); |
|
818 | + } |
|
819 | + // DEBUG LOG |
|
820 | + $payment_method = $payment->payment_method(); |
|
821 | + if ($payment_method instanceof EE_Payment_Method) { |
|
822 | + $payment_method_type_obj = $payment_method->type_obj(); |
|
823 | + if ($payment_method_type_obj instanceof EE_PMT_Base) { |
|
824 | + $gateway = $payment_method_type_obj->get_gateway(); |
|
825 | + if ($gateway instanceof EE_Gateway) { |
|
826 | + $gateway->log( |
|
827 | + array( |
|
828 | + 'message' => (string) __('Post Payment Transaction Details', 'event_espresso'), |
|
829 | + 'transaction' => $transaction->model_field_array(), |
|
830 | + 'finalized' => $finalized, |
|
831 | + 'IPN' => $IPN, |
|
832 | + 'deliver_notifications' => has_filter( |
|
833 | + 'FHEE__EED_Messages___maybe_registration__deliver_notifications' |
|
834 | + ), |
|
835 | + ), |
|
836 | + $payment |
|
837 | + ); |
|
838 | + } |
|
839 | + } |
|
840 | + } |
|
841 | + } |
|
842 | + |
|
843 | + |
|
844 | + /** |
|
845 | + * Force posts to PayPal to use TLS v1.2. See: |
|
846 | + * https://core.trac.wordpress.org/ticket/36320 |
|
847 | + * https://core.trac.wordpress.org/ticket/34924#comment:15 |
|
848 | + * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US |
|
849 | + * This will affect PayPal standard, pro, express, and Payflow. |
|
850 | + * |
|
851 | + * @param $handle |
|
852 | + * @param $r |
|
853 | + * @param $url |
|
854 | + */ |
|
855 | + public static function _curl_requests_to_paypal_use_tls($handle, $r, $url) |
|
856 | + { |
|
857 | + if (strpos($url, 'https://') !== false && strpos($url, '.paypal.com') !== false) { |
|
858 | + // Use the value of the constant CURL_SSLVERSION_TLSv1 = 1 |
|
859 | + // instead of the constant because it might not be defined |
|
860 | + curl_setopt($handle, CURLOPT_SSLVERSION, 6); |
|
861 | + } |
|
862 | + } |
|
863 | 863 | } |
@@ -13,82 +13,82 @@ |
||
13 | 13 | class EED_Invalid_Checkout_Access extends EED_Module |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @var InvalidCheckoutAccess $invalid_checkout_access_form |
|
18 | - */ |
|
19 | - private static $invalid_checkout_access_form; |
|
16 | + /** |
|
17 | + * @var InvalidCheckoutAccess $invalid_checkout_access_form |
|
18 | + */ |
|
19 | + private static $invalid_checkout_access_form; |
|
20 | 20 | |
21 | - /** |
|
22 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
23 | - */ |
|
24 | - public static function set_hooks() |
|
25 | - { |
|
26 | - } |
|
21 | + /** |
|
22 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
23 | + */ |
|
24 | + public static function set_hooks() |
|
25 | + { |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
31 | - */ |
|
32 | - public static function set_hooks_admin() |
|
33 | - { |
|
34 | - add_action( |
|
35 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
36 | - array('EED_Invalid_Checkout_Access', 'display_invalid_checkout_access_form'), |
|
37 | - 15 |
|
38 | - ); |
|
39 | - add_filter( |
|
40 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
41 | - array('EED_Invalid_Checkout_Access', 'process_invalid_checkout_access_form') |
|
42 | - ); |
|
43 | - } |
|
29 | + /** |
|
30 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
31 | + */ |
|
32 | + public static function set_hooks_admin() |
|
33 | + { |
|
34 | + add_action( |
|
35 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
36 | + array('EED_Invalid_Checkout_Access', 'display_invalid_checkout_access_form'), |
|
37 | + 15 |
|
38 | + ); |
|
39 | + add_filter( |
|
40 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
41 | + array('EED_Invalid_Checkout_Access', 'process_invalid_checkout_access_form') |
|
42 | + ); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * run - initial module setup |
|
48 | - * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
49 | - * |
|
50 | - * @var WP $WP |
|
51 | - */ |
|
52 | - public function run($WP) |
|
53 | - { |
|
54 | - // TODO: Implement run() method. |
|
55 | - } |
|
46 | + /** |
|
47 | + * run - initial module setup |
|
48 | + * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
49 | + * |
|
50 | + * @var WP $WP |
|
51 | + */ |
|
52 | + public function run($WP) |
|
53 | + { |
|
54 | + // TODO: Implement run() method. |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * @return InvalidCheckoutAccess |
|
60 | - */ |
|
61 | - public static function getInvalidCheckoutAccess() |
|
62 | - { |
|
63 | - if (! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
64 | - self::$invalid_checkout_access_form = new InvalidCheckoutAccess(); |
|
65 | - } |
|
66 | - return self::$invalid_checkout_access_form; |
|
67 | - } |
|
58 | + /** |
|
59 | + * @return InvalidCheckoutAccess |
|
60 | + */ |
|
61 | + public static function getInvalidCheckoutAccess() |
|
62 | + { |
|
63 | + if (! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
64 | + self::$invalid_checkout_access_form = new InvalidCheckoutAccess(); |
|
65 | + } |
|
66 | + return self::$invalid_checkout_access_form; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * email_validation_settings_form |
|
72 | - * |
|
73 | - * @return void |
|
74 | - * @throws \EE_Error |
|
75 | - */ |
|
76 | - public static function display_invalid_checkout_access_form() |
|
77 | - { |
|
78 | - $invalid_checkout_access_form = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
79 | - echo $invalid_checkout_access_form->getForm()->get_html(); |
|
80 | - } |
|
70 | + /** |
|
71 | + * email_validation_settings_form |
|
72 | + * |
|
73 | + * @return void |
|
74 | + * @throws \EE_Error |
|
75 | + */ |
|
76 | + public static function display_invalid_checkout_access_form() |
|
77 | + { |
|
78 | + $invalid_checkout_access_form = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
79 | + echo $invalid_checkout_access_form->getForm()->get_html(); |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * email_validation_settings_form |
|
85 | - * |
|
86 | - * @param \EE_Registration_Config $EE_Registration_Config |
|
87 | - * @return \EE_Registration_Config |
|
88 | - */ |
|
89 | - public static function process_invalid_checkout_access_form(\EE_Registration_Config $EE_Registration_Config) |
|
90 | - { |
|
91 | - $invalid_checkout_access_form = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
92 | - return $invalid_checkout_access_form->processForm($EE_Registration_Config); |
|
93 | - } |
|
83 | + /** |
|
84 | + * email_validation_settings_form |
|
85 | + * |
|
86 | + * @param \EE_Registration_Config $EE_Registration_Config |
|
87 | + * @return \EE_Registration_Config |
|
88 | + */ |
|
89 | + public static function process_invalid_checkout_access_form(\EE_Registration_Config $EE_Registration_Config) |
|
90 | + { |
|
91 | + $invalid_checkout_access_form = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
92 | + return $invalid_checkout_access_form->processForm($EE_Registration_Config); |
|
93 | + } |
|
94 | 94 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | */ |
61 | 61 | public static function getInvalidCheckoutAccess() |
62 | 62 | { |
63 | - if (! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
63 | + if ( ! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
64 | 64 | self::$invalid_checkout_access_form = new InvalidCheckoutAccess(); |
65 | 65 | } |
66 | 66 | return self::$invalid_checkout_access_form; |
@@ -12,69 +12,69 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * @return EED_Csv |
|
17 | - */ |
|
18 | - public static function instance() |
|
19 | - { |
|
20 | - return parent::get_instance(__CLASS__); |
|
21 | - } |
|
15 | + /** |
|
16 | + * @return EED_Csv |
|
17 | + */ |
|
18 | + public static function instance() |
|
19 | + { |
|
20 | + return parent::get_instance(__CLASS__); |
|
21 | + } |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
26 | - * |
|
27 | - * @access public |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public static function set_hooks() |
|
31 | - { |
|
32 | - } |
|
24 | + /** |
|
25 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
26 | + * |
|
27 | + * @access public |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public static function set_hooks() |
|
31 | + { |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
36 | - * |
|
37 | - * @access public |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public static function set_hooks_admin() |
|
41 | - { |
|
42 | - } |
|
34 | + /** |
|
35 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
36 | + * |
|
37 | + * @access public |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public static function set_hooks_admin() |
|
41 | + { |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * run - initial module setup |
|
47 | - * |
|
48 | - * @access public |
|
49 | - * @return void |
|
50 | - */ |
|
51 | - public function run($WP) |
|
52 | - { |
|
53 | - } |
|
45 | + /** |
|
46 | + * run - initial module setup |
|
47 | + * |
|
48 | + * @access public |
|
49 | + * @return void |
|
50 | + */ |
|
51 | + public function run($WP) |
|
52 | + { |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * export |
|
58 | - * |
|
59 | - * @access public |
|
60 | - * @return void |
|
61 | - */ |
|
62 | - public function export() |
|
63 | - { |
|
64 | - $Export = EE_Registry::instance()->load_class('Export'); |
|
65 | - $Export->export(); |
|
66 | - } |
|
56 | + /** |
|
57 | + * export |
|
58 | + * |
|
59 | + * @access public |
|
60 | + * @return void |
|
61 | + */ |
|
62 | + public function export() |
|
63 | + { |
|
64 | + $Export = EE_Registry::instance()->load_class('Export'); |
|
65 | + $Export->export(); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * import |
|
71 | - * |
|
72 | - * @access public |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - public function import() |
|
76 | - { |
|
77 | - $Import = EE_Registry::instance()->load_class('Import'); |
|
78 | - $Import->import(); |
|
79 | - } |
|
69 | + /** |
|
70 | + * import |
|
71 | + * |
|
72 | + * @access public |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + public function import() |
|
76 | + { |
|
77 | + $Import = EE_Registry::instance()->load_class('Import'); |
|
78 | + $Import->import(); |
|
79 | + } |
|
80 | 80 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | if ($ticket instanceof EE_Ticket) { |
15 | 15 | do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); |
16 | 16 | $ticket_description .= ! empty($ticket_description) |
17 | - ? '<br />' . $ticket_status_display |
|
17 | + ? '<br />'.$ticket_status_display |
|
18 | 18 | : $ticket_status_display; |
19 | 19 | if (strpos($ticket_description, '<div') === false) { |
20 | 20 | $ticket_description = "<p>{$ticket_description}</p>"; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv"> |
24 | 24 | <div class="no-tkt-slctr-ticket-content-dv"> |
25 | 25 | <h5><?php echo $ticket->name(); ?></h5> |
26 | - <?php if (! empty($ticket_description)) { ?> |
|
26 | + <?php if ( ! empty($ticket_description)) { ?> |
|
27 | 27 | <?php echo $ticket_description; ?> |
28 | 28 | <?php } ?> |
29 | 29 | </div><!-- .no-tkt-slctr-ticket-content-dv --> |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?>[]" value="<?php echo $TKT_ID; ?>"/> |
13 | 13 | <?php |
14 | 14 | if ($ticket instanceof EE_Ticket) { |
15 | - do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); |
|
16 | - $ticket_description .= ! empty($ticket_description) |
|
17 | - ? '<br />' . $ticket_status_display |
|
18 | - : $ticket_status_display; |
|
19 | - if (strpos($ticket_description, '<div') === false) { |
|
20 | - $ticket_description = "<p>{$ticket_description}</p>"; |
|
21 | - } |
|
22 | - ?> |
|
15 | + do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); |
|
16 | + $ticket_description .= ! empty($ticket_description) |
|
17 | + ? '<br />' . $ticket_status_display |
|
18 | + : $ticket_status_display; |
|
19 | + if (strpos($ticket_description, '<div') === false) { |
|
20 | + $ticket_description = "<p>{$ticket_description}</p>"; |
|
21 | + } |
|
22 | + ?> |
|
23 | 23 | <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv"> |
24 | 24 | <div class="no-tkt-slctr-ticket-content-dv"> |
25 | 25 | <h5><?php echo $ticket->name(); ?></h5> |
@@ -28,5 +28,5 @@ discard block |
||
28 | 28 | <?php } ?> |
29 | 29 | </div><!-- .no-tkt-slctr-ticket-content-dv --> |
30 | 30 | <?php |
31 | - do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event); |
|
31 | + do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event); |
|
32 | 32 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | esc_html__('Goes On Sale:', 'event_espresso') |
50 | 50 | ); ?></span> |
51 | 51 | <span class="dashicons dashicons-calendar"></span> |
52 | - <?php echo $ticket->get_i18n_datetime('TKT_start_date', $date_format) . ' '; ?> |
|
52 | + <?php echo $ticket->get_i18n_datetime('TKT_start_date', $date_format).' '; ?> |
|
53 | 53 | <span class="dashicons dashicons-clock"></span> |
54 | 54 | <?php echo $ticket->get_i18n_datetime('TKT_start_date', $time_format); ?> |
55 | 55 | <br/> |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | esc_html__('Sales End:', 'event_espresso') |
60 | 60 | ); ?></span> |
61 | 61 | <span class="dashicons dashicons-calendar"></span> |
62 | - <?php echo $ticket->get_i18n_datetime('TKT_end_date', $date_format) . ' '; ?> |
|
62 | + <?php echo $ticket->get_i18n_datetime('TKT_end_date', $date_format).' '; ?> |
|
63 | 63 | <span class="dashicons dashicons-clock"></span> |
64 | 64 | <?php echo $ticket->get_i18n_datetime('TKT_end_date', $time_format); ?> |
65 | 65 | <br/> |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | <br/> |
117 | 117 | <?php } ?> |
118 | 118 | |
119 | - <?php if ((! defined('EE_DECAF') || EE_DECAF !== true) && $ticket->uses() !== EE_INF) { ?> |
|
119 | + <?php if (( ! defined('EE_DECAF') || EE_DECAF !== true) && $ticket->uses() !== EE_INF) { ?> |
|
120 | 120 | <section class="tckt-slctr-tkt-uses-sctn"> |
121 | 121 | <h5> |
122 | 122 | <?php echo apply_filters( |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | <?php |
150 | 150 | $datetimes = $ticket->datetimes_ordered($event_is_expired, false); |
151 | 151 | $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
152 | - if (! empty($datetimes)) { ?> |
|
152 | + if ( ! empty($datetimes)) { ?> |
|
153 | 153 | <section class="tckt-slctr-tkt-datetimes-sctn"> |
154 | 154 | <h5> |
155 | 155 | <?php echo apply_filters( |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | esc_html__('Remaining', 'event_espresso') |
261 | 261 | ); ?>" class="cntr small-text"> |
262 | 262 | <?php echo $remaining === EE_INF |
263 | - ? '<span class="smaller-text">' . esc_html__( |
|
263 | + ? '<span class="smaller-text">'.esc_html__( |
|
264 | 264 | 'unlimited ', |
265 | 265 | 'event_espresso' |
266 | - ) . '</span>' : $remaining; ?> |
|
266 | + ).'</span>' : $remaining; ?> |
|
267 | 267 | </td> |
268 | 268 | <td data-th="<?php |
269 | 269 | echo apply_filters( |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | <?php echo $datetime->sold(); ?> |
274 | 274 | </td> |
275 | 275 | <?php $tkts_left = $datetime->sold_out() |
276 | - ? '<span class="sold-out smaller-text">' . esc_html__( |
|
276 | + ? '<span class="sold-out smaller-text">'.esc_html__( |
|
277 | 277 | 'Sold Out', |
278 | 278 | 'event_espresso' |
279 | - ) . '</span>' : $datetime->spaces_remaining(); ?> |
|
279 | + ).'</span>' : $datetime->spaces_remaining(); ?> |
|
280 | 280 | <td data-th="<?php |
281 | 281 | echo apply_filters( |
282 | 282 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
@@ -305,4 +305,4 @@ discard block |
||
305 | 305 | </div> |
306 | 306 | </td> |
307 | 307 | </tr> |
308 | -<?php endif; // end template_settings->show_ticket_details check |
|
308 | +<?php endif; // end template_settings->show_ticket_details check |
@@ -22,32 +22,32 @@ discard block |
||
22 | 22 | <p><?php echo $ticket->description(); ?></p> |
23 | 23 | |
24 | 24 | <?php |
25 | - do_action( |
|
26 | - 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
27 | - $ticket, |
|
28 | - $ticket_price, |
|
29 | - $display_ticket_price |
|
30 | - ); |
|
31 | - ?> |
|
25 | + do_action( |
|
26 | + 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
27 | + $ticket, |
|
28 | + $ticket_price, |
|
29 | + $display_ticket_price |
|
30 | + ); |
|
31 | + ?> |
|
32 | 32 | |
33 | 33 | <section class="tckt-slctr-tkt-sale-dates-sctn"> |
34 | 34 | <h5> |
35 | 35 | <?php echo apply_filters( |
36 | - 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', |
|
37 | - esc_html__('Sale Dates', 'event_espresso') |
|
38 | - ); ?> |
|
36 | + 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', |
|
37 | + esc_html__('Sale Dates', 'event_espresso') |
|
38 | + ); ?> |
|
39 | 39 | </h5> |
40 | 40 | <span class="drk-grey-text small-text no-bold"> - |
41 | 41 | <?php echo apply_filters( |
42 | - 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', |
|
43 | - esc_html__('The dates when this option is available for purchase.', 'event_espresso') |
|
44 | - ); ?></span> |
|
42 | + 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', |
|
43 | + esc_html__('The dates when this option is available for purchase.', 'event_espresso') |
|
44 | + ); ?></span> |
|
45 | 45 | <br/> |
46 | 46 | <span class="ticket-details-label-spn drk-grey-text"> |
47 | 47 | <?php echo apply_filters( |
48 | - 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', |
|
49 | - esc_html__('Goes On Sale:', 'event_espresso') |
|
50 | - ); ?></span> |
|
48 | + 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', |
|
49 | + esc_html__('Goes On Sale:', 'event_espresso') |
|
50 | + ); ?></span> |
|
51 | 51 | <span class="dashicons dashicons-calendar"></span> |
52 | 52 | <?php echo $ticket->get_i18n_datetime('TKT_start_date', $date_format) . ' '; ?> |
53 | 53 | <span class="dashicons dashicons-clock"></span> |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | <br/> |
56 | 56 | <span class="ticket-details-label-spn drk-grey-text"> |
57 | 57 | <?php echo apply_filters( |
58 | - 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', |
|
59 | - esc_html__('Sales End:', 'event_espresso') |
|
60 | - ); ?></span> |
|
58 | + 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', |
|
59 | + esc_html__('Sales End:', 'event_espresso') |
|
60 | + ); ?></span> |
|
61 | 61 | <span class="dashicons dashicons-calendar"></span> |
62 | 62 | <?php echo $ticket->get_i18n_datetime('TKT_end_date', $date_format) . ' '; ?> |
63 | 63 | <span class="dashicons dashicons-clock"></span> |
@@ -72,46 +72,46 @@ discard block |
||
72 | 72 | <section class="tckt-slctr-tkt-quantities-sctn"> |
73 | 73 | <h5> |
74 | 74 | <?php echo apply_filters( |
75 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', |
|
76 | - esc_html__('Purchasable Quantities', 'event_espresso') |
|
77 | - ); ?></h5> |
|
75 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', |
|
76 | + esc_html__('Purchasable Quantities', 'event_espresso') |
|
77 | + ); ?></h5> |
|
78 | 78 | <span class="drk-grey-text small-text no-bold"> - |
79 | 79 | <?php echo apply_filters( |
80 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', |
|
81 | - esc_html__( |
|
82 | - 'The number of tickets that can be purchased per transaction (if available).', |
|
83 | - 'event_espresso' |
|
84 | - ) |
|
85 | - ); ?></span><br/> |
|
80 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', |
|
81 | + esc_html__( |
|
82 | + 'The number of tickets that can be purchased per transaction (if available).', |
|
83 | + 'event_espresso' |
|
84 | + ) |
|
85 | + ); ?></span><br/> |
|
86 | 86 | <span class="ticket-details-label-spn drk-grey-text"> |
87 | 87 | <?php echo apply_filters( |
88 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', |
|
89 | - esc_html__('Minimum Qty:', 'event_espresso') |
|
90 | - ); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?> |
|
88 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', |
|
89 | + esc_html__('Minimum Qty:', 'event_espresso') |
|
90 | + ); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?> |
|
91 | 91 | <?php |
92 | - if ($ticket->min() > $remaining) { |
|
93 | - ?> <span |
|
92 | + if ($ticket->min() > $remaining) { |
|
93 | + ?> <span |
|
94 | 94 | class="important-notice small-text"> |
95 | 95 | <?php echo apply_filters( |
96 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', |
|
97 | - esc_html__( |
|
98 | - 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', |
|
99 | - 'event_espresso' |
|
100 | - ) |
|
101 | - ); ?></span> |
|
96 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', |
|
97 | + esc_html__( |
|
98 | + 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', |
|
99 | + 'event_espresso' |
|
100 | + ) |
|
101 | + ); ?></span> |
|
102 | 102 | <?php |
103 | - } ?><br/> |
|
103 | + } ?><br/> |
|
104 | 104 | <?php // $max = min( $max, $max_atndz );?> |
105 | 105 | <span class="ticket-details-label-spn drk-grey-text"> |
106 | 106 | <?php echo apply_filters( |
107 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', |
|
108 | - esc_html__('Maximum Qty:', 'event_espresso') |
|
109 | - ); ?></span> |
|
107 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', |
|
108 | + esc_html__('Maximum Qty:', 'event_espresso') |
|
109 | + ); ?></span> |
|
110 | 110 | <?php echo $ticket->max() === EE_INF ? esc_html__( |
111 | - 'no limit', |
|
112 | - 'event_espresso' |
|
113 | - ) |
|
114 | - : max($ticket->max(), 1); ?><br/> |
|
111 | + 'no limit', |
|
112 | + 'event_espresso' |
|
113 | + ) |
|
114 | + : max($ticket->max(), 1); ?><br/> |
|
115 | 115 | </section> |
116 | 116 | <br/> |
117 | 117 | <?php } ?> |
@@ -120,50 +120,50 @@ discard block |
||
120 | 120 | <section class="tckt-slctr-tkt-uses-sctn"> |
121 | 121 | <h5> |
122 | 122 | <?php echo apply_filters( |
123 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', |
|
124 | - esc_html__('Event Date Ticket Uses', 'event_espresso') |
|
125 | - ); ?></h5> |
|
123 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', |
|
124 | + esc_html__('Event Date Ticket Uses', 'event_espresso') |
|
125 | + ); ?></h5> |
|
126 | 126 | <span class="drk-grey-text small-text no-bold"> - |
127 | 127 | <?php |
128 | - echo apply_filters( |
|
129 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
|
130 | - sprintf( |
|
131 | - esc_html__( |
|
132 | - 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', |
|
133 | - 'event_espresso' |
|
134 | - ), |
|
135 | - '<br/>', |
|
136 | - '<strong>', |
|
137 | - '</strong>' |
|
138 | - ) |
|
139 | - ); |
|
140 | - ?></span><br/> |
|
128 | + echo apply_filters( |
|
129 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
|
130 | + sprintf( |
|
131 | + esc_html__( |
|
132 | + 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', |
|
133 | + 'event_espresso' |
|
134 | + ), |
|
135 | + '<br/>', |
|
136 | + '<strong>', |
|
137 | + '</strong>' |
|
138 | + ) |
|
139 | + ); |
|
140 | + ?></span><br/> |
|
141 | 141 | <span class="ticket-details-label-spn drk-grey-text"> |
142 | 142 | <?php echo apply_filters( |
143 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', |
|
144 | - esc_html__('# Datetimes:', 'event_espresso') |
|
145 | - ); ?></span><?php echo $ticket->uses(); ?><br/> |
|
143 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', |
|
144 | + esc_html__('# Datetimes:', 'event_espresso') |
|
145 | + ); ?></span><?php echo $ticket->uses(); ?><br/> |
|
146 | 146 | </section> |
147 | 147 | <?php } ?> |
148 | 148 | |
149 | 149 | <?php |
150 | - $datetimes = $ticket->datetimes_ordered($event_is_expired, false); |
|
151 | - $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
|
152 | - if (! empty($datetimes)) { ?> |
|
150 | + $datetimes = $ticket->datetimes_ordered($event_is_expired, false); |
|
151 | + $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
|
152 | + if (! empty($datetimes)) { ?> |
|
153 | 153 | <section class="tckt-slctr-tkt-datetimes-sctn"> |
154 | 154 | <h5> |
155 | 155 | <?php echo apply_filters( |
156 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', |
|
157 | - esc_html__('Access', 'event_espresso') |
|
158 | - ); ?></h5> |
|
156 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', |
|
157 | + esc_html__('Access', 'event_espresso') |
|
158 | + ); ?></h5> |
|
159 | 159 | <span class="drk-grey-text small-text no-bold"> - |
160 | 160 | <?php echo apply_filters( |
161 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', |
|
162 | - esc_html__( |
|
163 | - 'This option allows access to the following dates and times.', |
|
164 | - 'event_espresso' |
|
165 | - ) |
|
166 | - ); ?></span> |
|
161 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', |
|
162 | + esc_html__( |
|
163 | + 'This option allows access to the following dates and times.', |
|
164 | + 'event_espresso' |
|
165 | + ) |
|
166 | + ); ?></span> |
|
167 | 167 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
168 | 168 | <table class="tckt-slctr-tkt-details-tbl"> |
169 | 169 | <thead> |
@@ -172,122 +172,122 @@ discard block |
||
172 | 172 | <span class="dashicons dashicons-calendar"></span><span |
173 | 173 | class="small-text"> |
174 | 174 | <?php echo apply_filters( |
175 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
176 | - esc_html__('Date ', 'event_espresso') |
|
177 | - ); ?></span> |
|
175 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
176 | + esc_html__('Date ', 'event_espresso') |
|
177 | + ); ?></span> |
|
178 | 178 | </th> |
179 | 179 | <th class="tckt-slctr-tkt-details-time-th <?php echo $chart_column_width; ?>"> |
180 | 180 | <span class="dashicons dashicons-clock"></span><span |
181 | 181 | class="small-text"> |
182 | 182 | <?php esc_html_e( |
183 | - 'Time ', |
|
184 | - 'event_espresso' |
|
185 | - ); ?></span> |
|
183 | + 'Time ', |
|
184 | + 'event_espresso' |
|
185 | + ); ?></span> |
|
186 | 186 | </th> |
187 | 187 | <?php if ($show_ticket_sale_columns) : ?> |
188 | 188 | <th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr"> |
189 | 189 | <span class="smaller-text"> |
190 | 190 | <?php echo apply_filters( |
191 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
192 | - sprintf(esc_html__('Sold', 'event_espresso'), '<br/>') |
|
193 | - ); ?></span> |
|
191 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
192 | + sprintf(esc_html__('Sold', 'event_espresso'), '<br/>') |
|
193 | + ); ?></span> |
|
194 | 194 | </th> |
195 | 195 | <th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr"> |
196 | 196 | <span class="smaller-text"> |
197 | 197 | <?php echo apply_filters( |
198 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
199 | - sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>') |
|
200 | - ); ?></span> |
|
198 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
199 | + sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>') |
|
200 | + ); ?></span> |
|
201 | 201 | </th> |
202 | 202 | <th |
203 | 203 | class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr"> |
204 | 204 | <span class="smaller-text"> |
205 | 205 | <?php echo apply_filters( |
206 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
207 | - sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>') |
|
208 | - ); ?></span> |
|
206 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
207 | + sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>') |
|
208 | + ); ?></span> |
|
209 | 209 | </th> |
210 | 210 | <th |
211 | 211 | class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr"> |
212 | 212 | <span class="smaller-text"> |
213 | 213 | <?php echo apply_filters( |
214 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
215 | - sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>') |
|
216 | - ); ?></span> |
|
214 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
215 | + sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>') |
|
216 | + ); ?></span> |
|
217 | 217 | </th> |
218 | 218 | <?php endif; // end $show_ticket_sale_columns conditional ?> |
219 | 219 | </tr> |
220 | 220 | </thead> |
221 | 221 | <tbody> |
222 | 222 | <?php |
223 | - foreach ($datetimes as $datetime) { |
|
224 | - if ($datetime instanceof EE_Datetime) { |
|
225 | - ?> |
|
223 | + foreach ($datetimes as $datetime) { |
|
224 | + if ($datetime instanceof EE_Datetime) { |
|
225 | + ?> |
|
226 | 226 | |
227 | 227 | <tr> |
228 | 228 | <td data-th="<?php |
229 | - echo apply_filters( |
|
230 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
231 | - esc_html__('Event Date ', 'event_espresso') |
|
232 | - ); ?>" class="small-text"> |
|
229 | + echo apply_filters( |
|
230 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
231 | + esc_html__('Event Date ', 'event_espresso') |
|
232 | + ); ?>" class="small-text"> |
|
233 | 233 | <?php $datetime_name = $datetime->name(); ?> |
234 | 234 | <?php echo ! empty($datetime_name) ? '<b>' |
235 | - . $datetime_name |
|
236 | - . '</b><br/>' : ''; ?> |
|
235 | + . $datetime_name |
|
236 | + . '</b><br/>' : ''; ?> |
|
237 | 237 | <?php echo $datetime->date_range( |
238 | - $date_format, |
|
239 | - esc_html__(' to ', 'event_espresso') |
|
240 | - ); ?> |
|
238 | + $date_format, |
|
239 | + esc_html__(' to ', 'event_espresso') |
|
240 | + ); ?> |
|
241 | 241 | </td> |
242 | 242 | <td data-th="<?php esc_html_e('Time ', 'event_espresso'); ?>" |
243 | 243 | class="cntr small-text"> |
244 | 244 | <?php echo $datetime->time_range( |
245 | - $time_format, |
|
246 | - esc_html__(' to ', 'event_espresso') |
|
247 | - ); ?> |
|
245 | + $time_format, |
|
246 | + esc_html__(' to ', 'event_espresso') |
|
247 | + ); ?> |
|
248 | 248 | </td> |
249 | 249 | <?php if ($show_ticket_sale_columns) : ?> |
250 | 250 | <td data-th="<?php |
251 | - echo apply_filters( |
|
252 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
253 | - esc_html__('Sold', 'event_espresso') |
|
254 | - ); ?>" class="cntr small-text"> |
|
251 | + echo apply_filters( |
|
252 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
253 | + esc_html__('Sold', 'event_espresso') |
|
254 | + ); ?>" class="cntr small-text"> |
|
255 | 255 | <?php echo $ticket->sold(); ?> |
256 | 256 | </td> |
257 | 257 | <td data-th="<?php |
258 | - echo apply_filters( |
|
259 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
260 | - esc_html__('Remaining', 'event_espresso') |
|
261 | - ); ?>" class="cntr small-text"> |
|
258 | + echo apply_filters( |
|
259 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
260 | + esc_html__('Remaining', 'event_espresso') |
|
261 | + ); ?>" class="cntr small-text"> |
|
262 | 262 | <?php echo $remaining === EE_INF |
263 | - ? '<span class="smaller-text">' . esc_html__( |
|
264 | - 'unlimited ', |
|
265 | - 'event_espresso' |
|
266 | - ) . '</span>' : $remaining; ?> |
|
263 | + ? '<span class="smaller-text">' . esc_html__( |
|
264 | + 'unlimited ', |
|
265 | + 'event_espresso' |
|
266 | + ) . '</span>' : $remaining; ?> |
|
267 | 267 | </td> |
268 | 268 | <td data-th="<?php |
269 | - echo apply_filters( |
|
270 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
271 | - esc_html__('Total Sold', 'event_espresso') |
|
272 | - ); ?>" class="cntr small-text"> |
|
269 | + echo apply_filters( |
|
270 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
271 | + esc_html__('Total Sold', 'event_espresso') |
|
272 | + ); ?>" class="cntr small-text"> |
|
273 | 273 | <?php echo $datetime->sold(); ?> |
274 | 274 | </td> |
275 | 275 | <?php $tkts_left = $datetime->sold_out() |
276 | - ? '<span class="sold-out smaller-text">' . esc_html__( |
|
277 | - 'Sold Out', |
|
278 | - 'event_espresso' |
|
279 | - ) . '</span>' : $datetime->spaces_remaining(); ?> |
|
276 | + ? '<span class="sold-out smaller-text">' . esc_html__( |
|
277 | + 'Sold Out', |
|
278 | + 'event_espresso' |
|
279 | + ) . '</span>' : $datetime->spaces_remaining(); ?> |
|
280 | 280 | <td data-th="<?php |
281 | - echo apply_filters( |
|
282 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
283 | - esc_html__('Total Spaces Left', 'event_espresso') |
|
284 | - ); ?>" class="cntr small-text"> |
|
281 | + echo apply_filters( |
|
282 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
283 | + esc_html__('Total Spaces Left', 'event_espresso') |
|
284 | + ); ?>" class="cntr small-text"> |
|
285 | 285 | <?php echo $tkts_left === EE_INF ? '<span class="smaller-text">' |
286 | - . esc_html__( |
|
287 | - 'unlimited ', |
|
288 | - 'event_espresso' |
|
289 | - ) |
|
290 | - . '</span>' : $tkts_left; ?> |
|
286 | + . esc_html__( |
|
287 | + 'unlimited ', |
|
288 | + 'event_espresso' |
|
289 | + ) |
|
290 | + . '</span>' : $tkts_left; ?> |
|
291 | 291 | </td> |
292 | 292 | <?php endif; // end $show_ticket_sale_columns conditional ?> |
293 | 293 | </tr> |
@@ -65,20 +65,20 @@ discard block |
||
65 | 65 | </thead> |
66 | 66 | <tbody> |
67 | 67 | <?php |
68 | - /** |
|
69 | - * Recursive function for traversing all the sub-items of each line item |
|
70 | - * and displaying them in the table |
|
71 | - * |
|
72 | - * @param EE_Line_Item $line_item |
|
73 | - * @param boolean $odd for indicating whether to style this line item as an 'odd' or 'even' |
|
74 | - */ |
|
75 | - function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false) |
|
76 | - { |
|
77 | - switch ($line_item->type()) { |
|
78 | - case EEM_Line_Item::type_total: |
|
79 | - foreach ($line_item->children() as $child_line_item) { |
|
80 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description); |
|
81 | - } ?> |
|
68 | + /** |
|
69 | + * Recursive function for traversing all the sub-items of each line item |
|
70 | + * and displaying them in the table |
|
71 | + * |
|
72 | + * @param EE_Line_Item $line_item |
|
73 | + * @param boolean $odd for indicating whether to style this line item as an 'odd' or 'even' |
|
74 | + */ |
|
75 | + function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false) |
|
76 | + { |
|
77 | + switch ($line_item->type()) { |
|
78 | + case EEM_Line_Item::type_total: |
|
79 | + foreach ($line_item->children() as $child_line_item) { |
|
80 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description); |
|
81 | + } ?> |
|
82 | 82 | <tr> |
83 | 83 | <td colspan="<?php echo $show_line_item_description ? 5 : 4 ?>"> |
84 | 84 | <hr> |
@@ -90,50 +90,50 @@ discard block |
||
90 | 90 | <td class="total"><?php echo $line_item->total_no_code(); ?></td> |
91 | 91 | </tr> |
92 | 92 | <?php |
93 | - break; |
|
93 | + break; |
|
94 | 94 | |
95 | 95 | |
96 | - case EEM_Line_Item::type_sub_total: |
|
97 | - foreach ($line_item->children() as $child_line_item) { |
|
98 | - // $odd = !$odd; |
|
99 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
100 | - } ?> |
|
96 | + case EEM_Line_Item::type_sub_total: |
|
97 | + foreach ($line_item->children() as $child_line_item) { |
|
98 | + // $odd = !$odd; |
|
99 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
100 | + } ?> |
|
101 | 101 | <tr class="total_tr odd"> |
102 | 102 | <td colspan="<?php echo $show_line_item_description ? 2 : 1 ?>"> </td> |
103 | 103 | <td colspan="2" class="total" id="total_currency"> |
104 | 104 | <?php _e( |
105 | - 'Sub-Total', |
|
106 | - 'event_espresso' |
|
107 | - ); ?></td> |
|
105 | + 'Sub-Total', |
|
106 | + 'event_espresso' |
|
107 | + ); ?></td> |
|
108 | 108 | <td class="total"><?php echo $line_item->total_no_code(); ?></td> |
109 | 109 | </tr> |
110 | 110 | <?php |
111 | - break; |
|
111 | + break; |
|
112 | 112 | |
113 | 113 | |
114 | - case EEM_Line_Item::type_tax_sub_total: |
|
115 | - foreach ($line_item->children() as $child_line_item) { |
|
116 | - $odd = ! $odd; |
|
117 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
118 | - } ?> |
|
114 | + case EEM_Line_Item::type_tax_sub_total: |
|
115 | + foreach ($line_item->children() as $child_line_item) { |
|
116 | + $odd = ! $odd; |
|
117 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
118 | + } ?> |
|
119 | 119 | <tr class="total_tr odd"> |
120 | 120 | <td colspan="<?php echo $show_line_item_description ? 2 : 1 ?>"> </td> |
121 | 121 | <td colspan="2" class="total" id="total_currency"> |
122 | 122 | <?php _e( |
123 | - 'Tax Total', |
|
124 | - 'event_espresso' |
|
125 | - ); ?></td> |
|
123 | + 'Tax Total', |
|
124 | + 'event_espresso' |
|
125 | + ); ?></td> |
|
126 | 126 | <td class="total"><?php echo $line_item->total_no_code(); ?></td> |
127 | 127 | </tr> |
128 | 128 | <?php |
129 | - break; |
|
129 | + break; |
|
130 | 130 | |
131 | 131 | |
132 | - case EEM_Line_Item::type_line_item: |
|
133 | - $subitems = $line_item->children(); |
|
134 | - $has_subitems = count($subitems) > 1; |
|
135 | - if ($has_subitems) { |
|
136 | - ?> |
|
132 | + case EEM_Line_Item::type_line_item: |
|
133 | + $subitems = $line_item->children(); |
|
134 | + $has_subitems = count($subitems) > 1; |
|
135 | + if ($has_subitems) { |
|
136 | + ?> |
|
137 | 137 | <tr class="item <?php echo $odd ? 'odd' : ''; ?>"> |
138 | 138 | <td class="item_l"><?php echo $line_item->name() ?></td> |
139 | 139 | <?php if ($show_line_item_description) { ?> |
@@ -144,18 +144,18 @@ discard block |
||
144 | 144 | <td class="item_c"><?php echo $line_item->unit_price_no_code() ?></td> |
145 | 145 | |
146 | 146 | <td class="item_r"> <?php echo $line_item->total_no_code(); |
147 | - echo $line_item->is_taxable() ? '*' : '' ?> </td> |
|
147 | + echo $line_item->is_taxable() ? '*' : '' ?> </td> |
|
148 | 148 | <?php // <td class="item_l"><?php $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings); |
149 | - ?> |
|
149 | + ?> |
|
150 | 150 | </tr> |
151 | 151 | <?php |
152 | - if ($has_subitems) { |
|
153 | - foreach ($line_item->children() as $child_line_item) { |
|
154 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
155 | - } |
|
156 | - } |
|
157 | - } else {// no subitems - just show this line item |
|
158 | - ?> |
|
152 | + if ($has_subitems) { |
|
153 | + foreach ($line_item->children() as $child_line_item) { |
|
154 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
155 | + } |
|
156 | + } |
|
157 | + } else {// no subitems - just show this line item |
|
158 | + ?> |
|
159 | 159 | <tr class="item <?php echo $odd ? 'odd' : ''; ?>"> |
160 | 160 | <td class="item_l"><?php echo $line_item->name() ?></td> |
161 | 161 | <?php if ($show_line_item_description) { ?> |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | <td class="item_l"><?php echo $line_item->quantity() ?></td> |
165 | 165 | <td class="item_c"><?php echo $line_item->unit_price_no_code() ?></td> |
166 | 166 | <td class="item_r"> <?php echo $line_item->total_no_code(); |
167 | - echo $line_item->is_taxable() ? '*' : '' ?> </td> |
|
167 | + echo $line_item->is_taxable() ? '*' : '' ?> </td> |
|
168 | 168 | <?php // <td class="item_l"><?php $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings); |
169 | - ?> |
|
169 | + ?> |
|
170 | 170 | </tr> |
171 | 171 | <?php } |
172 | 172 | |
173 | - break; |
|
174 | - case EEM_Line_Item::type_sub_line_item: |
|
175 | - ?> |
|
173 | + break; |
|
174 | + case EEM_Line_Item::type_sub_line_item: |
|
175 | + ?> |
|
176 | 176 | <tr class="item subitem-row"> |
177 | 177 | <td class="item_l subitem"><?php echo $line_item->name(); ?></td> |
178 | 178 | <?php if ($show_line_item_description) { ?> |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | <td class="item_r"><?php echo $line_item->total_no_code(); ?></td> |
189 | 189 | </tr> |
190 | 190 | <?php |
191 | - break; |
|
192 | - case EEM_Line_Item::type_tax: |
|
193 | - ?> |
|
191 | + break; |
|
192 | + case EEM_Line_Item::type_tax: |
|
193 | + ?> |
|
194 | 194 | <tr class="item sub-item tax-total"> |
195 | 195 | <td class="item_l"><?php echo $line_item->name(); ?></td> |
196 | 196 | <?php if ($show_line_item_description) { ?> |
@@ -200,15 +200,15 @@ discard block |
||
200 | 200 | |
201 | 201 | <td class="item_r"><?php echo $line_item->total_no_code(); ?></td> |
202 | 202 | </tr><?php |
203 | - break; |
|
204 | - } |
|
205 | - } |
|
203 | + break; |
|
204 | + } |
|
205 | + } |
|
206 | 206 | |
207 | - $c = false; |
|
208 | - /* @var $transaction EE_Transaction */ |
|
209 | - $total_line_item = $transaction->total_line_item(); |
|
210 | - ee_invoice_display_line_item($total_line_item, $show_line_item_description); |
|
211 | - /* foreach($transaction->registrations() as $registration){ |
|
207 | + $c = false; |
|
208 | + /* @var $transaction EE_Transaction */ |
|
209 | + $total_line_item = $transaction->total_line_item(); |
|
210 | + ee_invoice_display_line_item($total_line_item, $show_line_item_description); |
|
211 | + /* foreach($transaction->registrations() as $registration){ |
|
212 | 212 | ?> |
213 | 213 | <tr class="item <?php echo ($c = !$c) ? ' odd' : ''; ?>"> |
214 | 214 | <td class="item_l">1</td> |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | </thead> |
238 | 238 | <tbody> |
239 | 239 | <?php |
240 | - $c = false; |
|
241 | - if (! empty($payments)) { |
|
242 | - foreach ($payments as $payment) { |
|
243 | - /* @var $payment EE_Payment */ |
|
244 | - ?> |
|
240 | + $c = false; |
|
241 | + if (! empty($payments)) { |
|
242 | + foreach ($payments as $payment) { |
|
243 | + /* @var $payment EE_Payment */ |
|
244 | + ?> |
|
245 | 245 | <tr class='item <?php echo(($c = ! $c) ? ' odd' : '') ?>'> |
246 | 246 | <td><?php $payment->e('PAY_gateway') ?></td> |
247 | 247 | <td><?php echo $payment->timestamp('D M j, Y') ?></td> |
@@ -251,17 +251,17 @@ discard block |
||
251 | 251 | <td class='item_r'><?php echo EEH_Template::format_currency($payment->amount()); ?></td> |
252 | 252 | </tr> |
253 | 253 | <?php } |
254 | - } else { |
|
255 | - ?> |
|
254 | + } else { |
|
255 | + ?> |
|
256 | 256 | <tr class='item'> |
257 | 257 | <td class='aln-cntr' colspan=6> |
258 | 258 | <?php _e( |
259 | - "No approved payments have been received", |
|
260 | - 'event_espresso' |
|
261 | - ) ?></td> |
|
259 | + "No approved payments have been received", |
|
260 | + 'event_espresso' |
|
261 | + ) ?></td> |
|
262 | 262 | </tr> |
263 | 263 | <?php } |
264 | - ?> |
|
264 | + ?> |
|
265 | 265 | </tbody> |
266 | 266 | <tfoot> |
267 | 267 | <tr class='total_tr'> |
@@ -238,7 +238,7 @@ |
||
238 | 238 | <tbody> |
239 | 239 | <?php |
240 | 240 | $c = false; |
241 | - if (! empty($payments)) { |
|
241 | + if ( ! empty($payments)) { |
|
242 | 242 | foreach ($payments as $payment) { |
243 | 243 | /* @var $payment EE_Payment */ |
244 | 244 | ?> |
@@ -8,9 +8,9 @@ |
||
8 | 8 | <head> |
9 | 9 | <title>[organization]<?php __(' Invoice #', 'event_espresso'); ?>[registration_code] |
10 | 10 | <?php __( |
11 | - ' for ', |
|
12 | - 'event_espresso' |
|
13 | - ); ?>[name]</title> |
|
11 | + ' for ', |
|
12 | + 'event_espresso' |
|
13 | + ); ?>[name]</title> |
|
14 | 14 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
15 | 15 | <!-- Base Stylesheet do not change or remove --> |
16 | 16 | <link rel="stylesheet" type="text/css" href="[base_url]base.css" media="screen"/> |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | <label><?php _e('Amount Owing: ', 'event_espresso'); ?></label> |
18 | 18 | </td> |
19 | 19 | <td class="<?php echo ($transaction->paid() == $transaction->total()) ? 'ee-transaction-paid' |
20 | - : 'ee-transaction-unpaid' ?>"> |
|
20 | + : 'ee-transaction-unpaid' ?>"> |
|
21 | 21 | <?php echo EEH_Template::format_currency($transaction->remaining()); ?> |
22 | 22 | </td> |
23 | 23 | </tr> |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | </td> |
28 | 28 | <td> |
29 | 29 | <?php $transaction->e_pretty_status(true); |
30 | - if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?> |
|
30 | + if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?> |
|
31 | 31 | <span class="small-text"><a href='<?php echo $SPCO_payment_options_url ?>'> |
32 | 32 | <?php _e( |
33 | - 'View Payment Options', |
|
34 | - 'event_espresso' |
|
35 | - ); ?></a></span> |
|
33 | + 'View Payment Options', |
|
34 | + 'event_espresso' |
|
35 | + ); ?></a></span> |
|
36 | 36 | <?php } ?> |
37 | 37 | </td> |
38 | 38 | </tr> |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | </td> |
46 | 46 | </tr> |
47 | 47 | <?php do_action( |
48 | - 'AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', |
|
49 | - $transaction |
|
50 | - ); ?> |
|
48 | + 'AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', |
|
49 | + $transaction |
|
50 | + ); ?> |
|
51 | 51 | </tbody> |
52 | 52 | </table> |
53 | 53 | |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | <p class="small-text jst-rght"> |
56 | 56 | <a href='<?php echo $SPCO_payment_options_url ?>'> |
57 | 57 | <?php _e( |
58 | - "Click here to view Payment Options", |
|
59 | - 'event_espresso' |
|
60 | - ); ?></a> |
|
58 | + "Click here to view Payment Options", |
|
59 | + 'event_espresso' |
|
60 | + ); ?></a> |
|
61 | 61 | </p> |
62 | 62 | <br/> |
63 | 63 |