@@ -282,7 +282,7 @@ |
||
282 | 282 | /** |
283 | 283 | * Gets the first event for this payment (it's possible that it could be for multiple) |
284 | 284 | * @param EEI_Payment $payment |
285 | - * @return EEI_Event|null |
|
285 | + * @return EE_Event|null |
|
286 | 286 | */ |
287 | 287 | protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
288 | 288 | $transaction = $payment->transaction(); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @subpackage core/libraries/payment_methods |
16 | 16 | * @author Mike Nelson |
17 | 17 | */ |
18 | -abstract class EE_Gateway{ |
|
18 | +abstract class EE_Gateway { |
|
19 | 19 | /** |
20 | 20 | * a constant used as a possible value for $_currencies_supported to indicate |
21 | 21 | * that ALL currencies are supported by this gateway |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | /** |
94 | 94 | * @return EE_Gateway |
95 | 95 | */ |
96 | - public function __construct(){ |
|
96 | + public function __construct() { |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * beginning again) |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public function __sleep(){ |
|
108 | + public function __sleep() { |
|
109 | 109 | $properties = get_object_vars($this); |
110 | - unset( $properties[ '_pay_model' ], $properties[ '_pay_log' ] ); |
|
110 | + unset($properties['_pay_model'], $properties['_pay_log']); |
|
111 | 111 | return array_keys($properties); |
112 | 112 | } |
113 | 113 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * see $_supports_sending_refunds |
116 | 116 | * @return boolean |
117 | 117 | */ |
118 | - public function supports_sending_refunds(){ |
|
118 | + public function supports_sending_refunds() { |
|
119 | 119 | return $this->_supports_sending_refunds; |
120 | 120 | } |
121 | 121 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * see $_supports_receiving_refunds |
124 | 124 | * @return boolean |
125 | 125 | */ |
126 | - public function supports_receiving_refunds(){ |
|
126 | + public function supports_receiving_refunds() { |
|
127 | 127 | return $this->_supports_receiving_refunds; |
128 | 128 | } |
129 | 129 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return EE_Payment for the refund |
139 | 139 | * @throws EE_Error |
140 | 140 | */ |
141 | - public function do_direct_refund( EE_Payment $payment, $refund_info = null ) { |
|
141 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) { |
|
142 | 142 | return NULL; |
143 | 143 | } |
144 | 144 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * etc |
150 | 150 | * @param array $settings_array |
151 | 151 | */ |
152 | - public function set_settings($settings_array){ |
|
153 | - foreach($settings_array as $name => $value){ |
|
152 | + public function set_settings($settings_array) { |
|
153 | + foreach ($settings_array as $name => $value) { |
|
154 | 154 | $property_name = "_".$name; |
155 | 155 | $this->{$property_name} = $value; |
156 | 156 | } |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | * See this class description |
160 | 160 | * @param EEMI_Payment $payment_model |
161 | 161 | */ |
162 | - public function set_payment_model($payment_model){ |
|
162 | + public function set_payment_model($payment_model) { |
|
163 | 163 | $this->_pay_model = $payment_model; |
164 | 164 | } |
165 | 165 | /** |
166 | 166 | * See this class description |
167 | 167 | * @param EEMI_Payment_Log $payment_log_model |
168 | 168 | */ |
169 | - public function set_payment_log($payment_log_model){ |
|
169 | + public function set_payment_log($payment_log_model) { |
|
170 | 170 | $this->_pay_log = $payment_log_model; |
171 | 171 | } |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * See this class description |
175 | 175 | * @param EEHI_Template $template_helper |
176 | 176 | */ |
177 | - public function set_template_helper($template_helper){ |
|
177 | + public function set_template_helper($template_helper) { |
|
178 | 178 | $this->_template = $template_helper; |
179 | 179 | } |
180 | 180 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * See this class description |
183 | 183 | * @param EEHI_Line_Item $line_item_helper |
184 | 184 | */ |
185 | - public function set_line_item_helper( $line_item_helper ){ |
|
185 | + public function set_line_item_helper($line_item_helper) { |
|
186 | 186 | $this->_line_item = $line_item_helper; |
187 | 187 | } |
188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * See this class description |
191 | 191 | * @param EEHI_Money $money_helper |
192 | 192 | */ |
193 | - public function set_money_helper( $money_helper ){ |
|
193 | + public function set_money_helper($money_helper) { |
|
194 | 194 | $this->_money = $money_helper; |
195 | 195 | } |
196 | 196 | |
@@ -199,23 +199,23 @@ discard block |
||
199 | 199 | * @param $message |
200 | 200 | * @param $payment |
201 | 201 | */ |
202 | - public function log($message,$payment){ |
|
203 | - if($payment instanceof EEI_Payment){ |
|
204 | - $type='Payment'; |
|
202 | + public function log($message, $payment) { |
|
203 | + if ($payment instanceof EEI_Payment) { |
|
204 | + $type = 'Payment'; |
|
205 | 205 | $id = $payment->ID(); |
206 | - }else{ |
|
206 | + } else { |
|
207 | 207 | $type = 'Payment_Method'; |
208 | 208 | $id = $this->_ID; |
209 | 209 | } |
210 | - $this->_pay_log->gateway_log($message,$id,$type); |
|
210 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
211 | 211 | } |
212 | 212 | /** |
213 | 213 | * Formats the amount so it can generally be sent to gateways |
214 | 214 | * @param float $amount |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - public function format_currency($amount){ |
|
218 | - return number_format( $amount, 2, '.', '' ); |
|
217 | + public function format_currency($amount) { |
|
218 | + return number_format($amount, 2, '.', ''); |
|
219 | 219 | // return $this->_template->format_currency($amount, true); |
220 | 220 | } |
221 | 221 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
225 | 225 | * @return mixed array or string |
226 | 226 | */ |
227 | - public function currencies_supported(){ |
|
227 | + public function currencies_supported() { |
|
228 | 228 | return $this->_currencies_supported; |
229 | 229 | } |
230 | 230 | |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | * @param EE_Transaction $transaction |
237 | 237 | * @return float |
238 | 238 | */ |
239 | - protected function _sum_items_and_taxes( EE_Transaction $transaction){ |
|
239 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) { |
|
240 | 240 | $total_line_item = $transaction->total_line_item(); |
241 | 241 | $total = 0; |
242 | - foreach($total_line_item->get_items() as $item_line_item ){ |
|
243 | - $total += max( $item_line_item->total(), 0 ); |
|
242 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
243 | + $total += max($item_line_item->total(), 0); |
|
244 | 244 | } |
245 | - foreach($total_line_item->tax_descendants() as $tax_line_item ){ |
|
246 | - $total += max( $tax_line_item->total(), 0 ); |
|
245 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
246 | + $total += max($tax_line_item->total(), 0); |
|
247 | 247 | } |
248 | 248 | return $total; |
249 | 249 | } |
@@ -254,9 +254,9 @@ discard block |
||
254 | 254 | * @param EEI_Payment $payment |
255 | 255 | * @return boolean |
256 | 256 | */ |
257 | - protected function _can_easily_itemize_transaction_for( EEI_Payment $payment ){ |
|
257 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) { |
|
258 | 258 | return $this->_money->compare_floats( |
259 | - $this->_sum_items_and_taxes( $payment->transaction() ), |
|
259 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
260 | 260 | $payment->transaction()->total() ) && |
261 | 261 | $this->_money->compare_floats( |
262 | 262 | $payment->amount(), |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param EE_Payment $payment |
275 | 275 | * @return void |
276 | 276 | */ |
277 | - public function update_txn_based_on_payment( $payment ){ |
|
277 | + public function update_txn_based_on_payment($payment) { |
|
278 | 278 | //maybe update the transaction or line items or registrations |
279 | 279 | //but most gateways don't need to do this, because they only update the payment |
280 | 280 | } |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | * @param EEI_Payment $payment |
285 | 285 | * @return EEI_Event|null |
286 | 286 | */ |
287 | - protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
|
287 | + protected function _get_first_event_for_payment(EEI_Payment $payment) { |
|
288 | 288 | $transaction = $payment->transaction(); |
289 | - if( $transaction instanceof EEI_Transaction ) { |
|
289 | + if ($transaction instanceof EEI_Transaction) { |
|
290 | 290 | $primary_registrant = $transaction->primary_registration(); |
291 | - if( $primary_registrant instanceof EE_Registration ) { |
|
291 | + if ($primary_registrant instanceof EE_Registration) { |
|
292 | 292 | return $primary_registrant->event_obj(); |
293 | 293 | } |
294 | 294 | } |
@@ -300,19 +300,19 @@ discard block |
||
300 | 300 | * @param EEI_Payment $payment |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - protected function _get_first_event_name_for_payment( EEI_Payment $payment ) { |
|
304 | - $event = $this->_get_first_event_for_payment( $payment ); |
|
305 | - return $event instanceof EEI_Event ? $event->name() : __( 'Event', 'event_espresso' ); |
|
303 | + protected function _get_first_event_name_for_payment(EEI_Payment $payment) { |
|
304 | + $event = $this->_get_first_event_for_payment($payment); |
|
305 | + return $event instanceof EEI_Event ? $event->name() : __('Event', 'event_espresso'); |
|
306 | 306 | } |
307 | 307 | /** |
308 | 308 | * Gets the text to use for a gateway's line item name when this is a partial payment |
309 | 309 | * @param EE_Payment $payment |
310 | 310 | * @return string |
311 | 311 | */ |
312 | - protected function _format_partial_payment_line_item_name( EEI_Payment $payment ){ |
|
312 | + protected function _format_partial_payment_line_item_name(EEI_Payment $payment) { |
|
313 | 313 | return apply_filters( |
314 | 314 | 'EEG_Paypal_Pro__do_direct_payment__partial_amount_line_item_name', |
315 | - $this->_get_first_event_name_for_payment( $payment ), |
|
315 | + $this->_get_first_event_name_for_payment($payment), |
|
316 | 316 | $this, |
317 | 317 | $payment |
318 | 318 | ); |
@@ -322,13 +322,13 @@ discard block |
||
322 | 322 | * @param EEI_Payment $payment |
323 | 323 | * @return string |
324 | 324 | */ |
325 | - protected function _format_partial_payment_line_item_desc( EEI_Payment $payment ) { |
|
325 | + protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) { |
|
326 | 326 | return apply_filters( |
327 | 327 | 'FHEE__EE_Gateway___partial_payment_desc', |
328 | 328 | sprintf( |
329 | 329 | __("Payment of %s for %s", "event_espresso"), |
330 | - $payment->get_pretty( 'PAY_amount', 'no_currency_code' ), |
|
331 | - $this->_get_first_event_name_for_payment( $payment ) ), |
|
330 | + $payment->get_pretty('PAY_amount', 'no_currency_code'), |
|
331 | + $this->_get_first_event_name_for_payment($payment) ), |
|
332 | 332 | $this, |
333 | 333 | $payment |
334 | 334 | ); |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | * @param EEI_Payment $payment |
341 | 341 | * @return string |
342 | 342 | */ |
343 | - protected function _format_line_item_name( EEI_Line_Item $line_item, EEI_Payment $payment ) { |
|
343 | + protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) { |
|
344 | 344 | return apply_filters( |
345 | 345 | 'FHEE__EE_gateway___line_item_name', |
346 | - sprintf( _x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ), $line_item->name(), $line_item->ticket_event_name() ), |
|
346 | + sprintf(_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), $line_item->name(), $line_item->ticket_event_name()), |
|
347 | 347 | $this, |
348 | 348 | $line_item, |
349 | 349 | $payment |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @param EEI_Payment $payment |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - protected function _format_line_item_desc( EEI_Line_Item $line_item, EEI_Payment $payment ) { |
|
359 | + protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) { |
|
360 | 360 | return apply_filters( |
361 | 361 | 'FHEE__EE_Gateway___line_item_desc', |
362 | 362 | $line_item->desc(), |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | * @param EEI_Payment $payment |
372 | 372 | * @return type |
373 | 373 | */ |
374 | - protected function _format_order_description( EEI_Payment $payment ) { |
|
374 | + protected function _format_order_description(EEI_Payment $payment) { |
|
375 | 375 | return apply_filters( |
376 | 376 | 'FHEE__EE_Gateway___order_description', |
377 | 377 | sprintf( |
378 | 378 | __('Event Registrations from %1$s for %2$s', "event_espresso"), |
379 | 379 | get_bloginfo('name'), |
380 | - $this->_get_first_event_name_for_payment( $payment ) ), |
|
380 | + $this->_get_first_event_name_for_payment($payment) ), |
|
381 | 381 | $this, |
382 | 382 | $payment |
383 | 383 | ); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return EEG_Paypal_Standard |
69 | 69 | */ |
70 | 70 | public function __construct() { |
71 | - $this->set_uses_separate_IPN_request( true ) ; |
|
71 | + $this->set_uses_separate_IPN_request(true); |
|
72 | 72 | parent::__construct(); |
73 | 73 | } |
74 | 74 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * Also sets the gateway url class variable based on whether debug mode is enabled or not |
79 | 79 | * @param array $settings_array |
80 | 80 | */ |
81 | - public function set_settings($settings_array){ |
|
81 | + public function set_settings($settings_array) { |
|
82 | 82 | parent::set_settings($settings_array); |
83 | 83 | $this->_gateway_url = $this->_debug_mode |
84 | 84 | ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' |
@@ -112,42 +112,42 @@ discard block |
||
112 | 112 | |
113 | 113 | $total_discounts_to_cart_total = $transaction->paid(); |
114 | 114 | //only itemize the order if we're paying for the rest of the order's amount |
115 | - if( EEH_Money::compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
116 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true ); |
|
115 | + if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
116 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true); |
|
117 | 117 | //this payment is for the remaining transaction amount, |
118 | 118 | //keep track of exactly how much the itemized order amount equals |
119 | 119 | $itemized_sum = 0; |
120 | 120 | $shipping_previously_added = 0; |
121 | 121 | //so let's show all the line items |
122 | - foreach($total_line_item->get_items() as $line_item){ |
|
123 | - if ( $line_item instanceof EE_Line_Item ) { |
|
122 | + foreach ($total_line_item->get_items() as $line_item) { |
|
123 | + if ($line_item instanceof EE_Line_Item) { |
|
124 | 124 | //it's some kind of discount |
125 | - if( $line_item->total() < 0 ) { |
|
126 | - $total_discounts_to_cart_total += abs( $line_item->total() ); |
|
125 | + if ($line_item->total() < 0) { |
|
126 | + $total_discounts_to_cart_total += abs($line_item->total()); |
|
127 | 127 | $itemized_sum += $line_item->total(); |
128 | 128 | continue; |
129 | 129 | } |
130 | 130 | //dont include shipping again. |
131 | - if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) { |
|
131 | + if (strpos($line_item->code(), 'paypal_shipping_') === 0) { |
|
132 | 132 | $shipping_previously_added = $line_item->total(); |
133 | 133 | continue; |
134 | 134 | } |
135 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
136 | - $this->_format_line_item_name( $line_item, $payment ), |
|
135 | + $redirect_args['item_name_'.$item_num] = substr( |
|
136 | + $this->_format_line_item_name($line_item, $payment), |
|
137 | 137 | 0, 127 |
138 | 138 | ); |
139 | - $redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price(); |
|
140 | - $redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity(); |
|
139 | + $redirect_args['amount_'.$item_num] = $line_item->unit_price(); |
|
140 | + $redirect_args['quantity_'.$item_num] = $line_item->quantity(); |
|
141 | 141 | //if we're not letting PayPal calculate shipping, tell them its 0 |
142 | - if ( ! $this->_paypal_shipping ) { |
|
143 | - $redirect_args[ 'shipping_' . $item_num ] = '0'; |
|
144 | - $redirect_args[ 'shipping2_' . $item_num ] = '0'; |
|
142 | + if ( ! $this->_paypal_shipping) { |
|
143 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
144 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
145 | 145 | } |
146 | 146 | $item_num++; |
147 | 147 | $itemized_sum += $line_item->total(); |
148 | 148 | } |
149 | 149 | } |
150 | - $taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item ); |
|
150 | + $taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item); |
|
151 | 151 | //ideally itemized sum equals the transaction total. but if not (which is weird) |
152 | 152 | //and the itemized sum is LESS than the transaction total |
153 | 153 | //add another line item |
@@ -157,47 +157,47 @@ discard block |
||
157 | 157 | $transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added, |
158 | 158 | 2 |
159 | 159 | ); |
160 | - if( $itemized_sum_diff_from_txn_total < 0 ) { |
|
160 | + if ($itemized_sum_diff_from_txn_total < 0) { |
|
161 | 161 | //itemized sum is too big |
162 | - $total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total ); |
|
163 | - } elseif( $itemized_sum_diff_from_txn_total > 0 ) { |
|
164 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
165 | - __( 'Other charges', 'event_espresso' ), 0, 127 ); |
|
166 | - $redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
167 | - $redirect_args[ 'quantity_' . $item_num ] = 1; |
|
162 | + $total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total); |
|
163 | + } elseif ($itemized_sum_diff_from_txn_total > 0) { |
|
164 | + $redirect_args['item_name_'.$item_num] = substr( |
|
165 | + __('Other charges', 'event_espresso'), 0, 127 ); |
|
166 | + $redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
167 | + $redirect_args['quantity_'.$item_num] = 1; |
|
168 | 168 | $item_num++; |
169 | 169 | } |
170 | - if( $total_discounts_to_cart_total > 0 ) { |
|
171 | - $redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total ); |
|
170 | + if ($total_discounts_to_cart_total > 0) { |
|
171 | + $redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total); |
|
172 | 172 | } |
173 | 173 | //add our taxes to the order if we're NOT using PayPal's |
174 | - if( ! $this->_paypal_taxes ){ |
|
174 | + if ( ! $this->_paypal_taxes) { |
|
175 | 175 | $redirect_args['tax_cart'] = $total_line_item->get_total_tax(); |
176 | 176 | } |
177 | 177 | } else { |
178 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false ); |
|
178 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false); |
|
179 | 179 | //partial payment that's not for the remaining amount, so we can't send an itemized list |
180 | - $redirect_args['item_name_' . $item_num] = substr( |
|
181 | - $this->_format_partial_payment_line_item_name( $payment ), |
|
180 | + $redirect_args['item_name_'.$item_num] = substr( |
|
181 | + $this->_format_partial_payment_line_item_name($payment), |
|
182 | 182 | 0, 127 |
183 | 183 | ); |
184 | - $redirect_args['amount_' . $item_num] = $payment->amount(); |
|
185 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
186 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
184 | + $redirect_args['amount_'.$item_num] = $payment->amount(); |
|
185 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
186 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
187 | 187 | $redirect_args['tax_cart'] = '0'; |
188 | 188 | $item_num++; |
189 | 189 | } |
190 | 190 | |
191 | - if($this->_debug_mode){ |
|
192 | - $redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
193 | - $redirect_args['amount_' . $item_num] = 0; |
|
191 | + if ($this->_debug_mode) { |
|
192 | + $redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
193 | + $redirect_args['amount_'.$item_num] = 0; |
|
194 | 194 | $redirect_args['on0_'.$item_num] = 'NOTIFY URL'; |
195 | - $redirect_args['os0_' . $item_num] = $notify_url; |
|
195 | + $redirect_args['os0_'.$item_num] = $notify_url; |
|
196 | 196 | $redirect_args['on1_'.$item_num] = 'RETURN URL'; |
197 | - $redirect_args['os1_' . $item_num] = $return_url; |
|
197 | + $redirect_args['os1_'.$item_num] = $return_url; |
|
198 | 198 | // $redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ? |
199 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
200 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
199 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
200 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | $redirect_args['business'] = $this->_paypal_id; |
@@ -207,14 +207,14 @@ discard block |
||
207 | 207 | $redirect_args['cmd'] = '_cart'; |
208 | 208 | $redirect_args['upload'] = 1; |
209 | 209 | $redirect_args['currency_code'] = $payment->currency_code(); |
210 | - $redirect_args['rm'] = 2;//makes the user return with method=POST |
|
211 | - if($this->_image_url){ |
|
210 | + $redirect_args['rm'] = 2; //makes the user return with method=POST |
|
211 | + if ($this->_image_url) { |
|
212 | 212 | $redirect_args['image_url'] = $this->_image_url; |
213 | 213 | } |
214 | 214 | $redirect_args['no_shipping'] = $this->_shipping_details; |
215 | - $redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this |
|
215 | + $redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this |
|
216 | 216 | |
217 | - $redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this ); |
|
217 | + $redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this); |
|
218 | 218 | |
219 | 219 | $payment->set_redirect_url($this->_gateway_url); |
220 | 220 | $payment->set_redirect_args($redirect_args); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $this->log( |
223 | 223 | array( |
224 | 224 | 'message' => sprintf( |
225 | - __( 'PayPal payment request initiated.', 'event_espresso' ) |
|
225 | + __('PayPal payment request initiated.', 'event_espresso') |
|
226 | 226 | ), |
227 | 227 | 'transaction' => $transaction->model_field_array(), |
228 | 228 | ), |
@@ -242,14 +242,14 @@ discard block |
||
242 | 242 | * @return \EEI_Payment updated |
243 | 243 | * @throws \EE_Error |
244 | 244 | */ |
245 | - public function handle_payment_update( $update_info, $transaction ){ |
|
245 | + public function handle_payment_update($update_info, $transaction) { |
|
246 | 246 | // verify there's payment data that's been sent |
247 | - if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) { |
|
247 | + if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) { |
|
248 | 248 | // log the results |
249 | 249 | $this->log( |
250 | 250 | array( |
251 | 251 | 'message' => sprintf( |
252 | - __( 'PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso' ) |
|
252 | + __('PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso') |
|
253 | 253 | ), |
254 | 254 | 'update_info' => $update_info, |
255 | 255 | ), |
@@ -257,50 +257,50 @@ discard block |
||
257 | 257 | ); |
258 | 258 | // waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/) |
259 | 259 | // indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes |
260 | - if ( isset( $update_info[ 'tx' ] ) ) { |
|
260 | + if (isset($update_info['tx'])) { |
|
261 | 261 | return $transaction->last_payment(); |
262 | 262 | } else { |
263 | 263 | return null; |
264 | 264 | } |
265 | 265 | } |
266 | - $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
267 | - if ( ! $payment instanceof EEI_Payment ) { |
|
266 | + $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']); |
|
267 | + if ( ! $payment instanceof EEI_Payment) { |
|
268 | 268 | $payment = $transaction->last_payment(); |
269 | 269 | } |
270 | 270 | // ok, then validate the IPN. Even if we've already processed this payment, |
271 | 271 | // let PayPal know we don't want to hear from them anymore! |
272 | - if ( ! $this->validate_ipn( $update_info, $payment ) ) { |
|
272 | + if ( ! $this->validate_ipn($update_info, $payment)) { |
|
273 | 273 | return $payment; |
274 | 274 | } |
275 | 275 | //ok, well let's process this payment then! |
276 | - switch ( $update_info[ 'payment_status' ] ) { |
|
276 | + switch ($update_info['payment_status']) { |
|
277 | 277 | |
278 | 278 | case 'Completed' : |
279 | 279 | $status = $this->_pay_model->approved_status(); |
280 | - $gateway_response = __( 'The payment is approved.', 'event_espresso' ); |
|
280 | + $gateway_response = __('The payment is approved.', 'event_espresso'); |
|
281 | 281 | break; |
282 | 282 | |
283 | 283 | case 'Pending' : |
284 | 284 | $status = $this->_pay_model->pending_status(); |
285 | - $gateway_response = __( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' ); |
|
285 | + $gateway_response = __('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso'); |
|
286 | 286 | break; |
287 | 287 | |
288 | 288 | case 'Denied' : |
289 | 289 | $status = $this->_pay_model->declined_status(); |
290 | - $gateway_response = __( 'The payment has been declined.', 'event_espresso' ); |
|
290 | + $gateway_response = __('The payment has been declined.', 'event_espresso'); |
|
291 | 291 | break; |
292 | 292 | |
293 | 293 | case 'Expired' : |
294 | 294 | case 'Failed' : |
295 | 295 | $status = $this->_pay_model->failed_status(); |
296 | - $gateway_response = __( 'The payment failed for technical reasons or expired.', 'event_espresso' ); |
|
296 | + $gateway_response = __('The payment failed for technical reasons or expired.', 'event_espresso'); |
|
297 | 297 | break; |
298 | 298 | |
299 | 299 | case 'Refunded' : |
300 | 300 | case 'Partially_Refunded' : |
301 | 301 | // even though it's a refund, we consider the payment as approved, it just has a negative value |
302 | 302 | $status = $this->_pay_model->approved_status(); |
303 | - $gateway_response = __( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' ); |
|
303 | + $gateway_response = __('The payment has been refunded. Please update registrations accordingly.', 'event_espresso'); |
|
304 | 304 | break; |
305 | 305 | |
306 | 306 | case 'Voided' : |
@@ -308,28 +308,28 @@ discard block |
||
308 | 308 | case 'Canceled_Reversal' : |
309 | 309 | default : |
310 | 310 | $status = $this->_pay_model->cancelled_status(); |
311 | - $gateway_response = __( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' ); |
|
311 | + $gateway_response = __('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso'); |
|
312 | 312 | break; |
313 | 313 | |
314 | 314 | } |
315 | 315 | |
316 | 316 | //check if we've already processed this payment |
317 | - if ( $payment instanceof EEI_Payment ) { |
|
317 | + if ($payment instanceof EEI_Payment) { |
|
318 | 318 | //payment exists. if this has the exact same status and amount, don't bother updating. just return |
319 | - if ( $payment->status() === $status && (float)$payment->amount() === (float)$update_info[ 'mc_gross' ] ) { |
|
319 | + if ($payment->status() === $status && (float) $payment->amount() === (float) $update_info['mc_gross']) { |
|
320 | 320 | // DUPLICATED IPN! dont bother updating transaction foo!; |
321 | 321 | $message_log = sprintf( |
322 | - __( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ), |
|
322 | + __('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'), |
|
323 | 323 | $payment->ID() |
324 | 324 | ); |
325 | 325 | } else { |
326 | 326 | // new payment yippee !!! |
327 | - $payment->set_status( $status ); |
|
328 | - $payment->set_amount( (float)$update_info[ 'mc_gross' ] ); |
|
329 | - $payment->set_gateway_response( $gateway_response ); |
|
330 | - $payment->set_details( $update_info ); |
|
331 | - $payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
332 | - $message_log = __( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ); |
|
327 | + $payment->set_status($status); |
|
328 | + $payment->set_amount((float) $update_info['mc_gross']); |
|
329 | + $payment->set_gateway_response($gateway_response); |
|
330 | + $payment->set_details($update_info); |
|
331 | + $payment->set_txn_id_chq_nmbr($update_info['txn_id']); |
|
332 | + $message_log = __('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso'); |
|
333 | 333 | } |
334 | 334 | $this->log( |
335 | 335 | array( |
@@ -341,16 +341,16 @@ discard block |
||
341 | 341 | $payment |
342 | 342 | ); |
343 | 343 | } |
344 | - do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this ); |
|
344 | + do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this); |
|
345 | 345 | // kill request here if this is a refund |
346 | 346 | if ( |
347 | 347 | ( |
348 | - $update_info[ 'payment_status' ] === 'Refunded' |
|
349 | - || $update_info[ 'payment_status' ] === 'Partially_Refunded' |
|
348 | + $update_info['payment_status'] === 'Refunded' |
|
349 | + || $update_info['payment_status'] === 'Partially_Refunded' |
|
350 | 350 | ) |
351 | - && apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) |
|
351 | + && apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true) |
|
352 | 352 | ) { |
353 | - status_header( 200 ); |
|
353 | + status_header(200); |
|
354 | 354 | exit(); |
355 | 355 | } |
356 | 356 | return $payment; |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | * @return boolean |
368 | 368 | * @throws \EE_Error |
369 | 369 | */ |
370 | - public function validate_ipn( $update_info, $payment ) { |
|
370 | + public function validate_ipn($update_info, $payment) { |
|
371 | 371 | //allow us to skip validating IPNs with PayPal (useful for testing) |
372 | - if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) { |
|
372 | + if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) { |
|
373 | 373 | return true; |
374 | 374 | } |
375 | 375 | //...otherwise, we actually don't care what the $update_info is, we need to look |
@@ -377,22 +377,22 @@ discard block |
||
377 | 377 | // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST. |
378 | 378 | // Instead, read raw POST data from the input stream. |
379 | 379 | // @see https://gist.github.com/xcommerce-gists/3440401 |
380 | - $raw_post_data = file_get_contents( 'php://input' ); |
|
381 | - $raw_post_array = explode( '&', $raw_post_data ); |
|
380 | + $raw_post_data = file_get_contents('php://input'); |
|
381 | + $raw_post_array = explode('&', $raw_post_data); |
|
382 | 382 | $update_info = array(); |
383 | - foreach ( $raw_post_array as $keyval ) { |
|
384 | - $keyval = explode( '=', $keyval ); |
|
385 | - if ( count( $keyval ) === 2 ) { |
|
386 | - $update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] ); |
|
383 | + foreach ($raw_post_array as $keyval) { |
|
384 | + $keyval = explode('=', $keyval); |
|
385 | + if (count($keyval) === 2) { |
|
386 | + $update_info[$keyval[0]] = urldecode($keyval[1]); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' |
390 | 390 | $req = 'cmd=_notify-validate'; |
391 | - $uses_get_magic_quotes = function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() === 1 |
|
391 | + $uses_get_magic_quotes = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() === 1 |
|
392 | 392 | ? true |
393 | 393 | : false; |
394 | - foreach ( $update_info as $key => $value ) { |
|
395 | - $value = $uses_get_magic_quotes ? urlencode( stripslashes( $value ) ) : urlencode( $value ); |
|
394 | + foreach ($update_info as $key => $value) { |
|
395 | + $value = $uses_get_magic_quotes ? urlencode(stripslashes($value)) : urlencode($value); |
|
396 | 396 | $req .= "&$key=$value"; |
397 | 397 | } |
398 | 398 | // HTTP POST the complete, unaltered IPN back to PayPal |
@@ -401,38 +401,38 @@ discard block |
||
401 | 401 | array( |
402 | 402 | 'body' => $req, |
403 | 403 | 'sslverify' => false, |
404 | - 'timeout' => 60 , |
|
404 | + 'timeout' => 60, |
|
405 | 405 | // make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal |
406 | 406 | // plz see: https://github.com/websharks/s2member/issues/610 |
407 | - 'user-agent' => 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(), |
|
407 | + 'user-agent' => 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(), |
|
408 | 408 | 'httpversion' => '1.1' |
409 | 409 | ) |
410 | 410 | ); |
411 | 411 | // then check the response |
412 | 412 | if ( |
413 | - array_key_exists( 'body', $response ) |
|
414 | - && ! is_wp_error( $response ) |
|
415 | - && strcmp( $response[ 'body' ], "VERIFIED" ) === 0 |
|
413 | + array_key_exists('body', $response) |
|
414 | + && ! is_wp_error($response) |
|
415 | + && strcmp($response['body'], "VERIFIED") === 0 |
|
416 | 416 | ) { |
417 | 417 | return true; |
418 | 418 | } |
419 | 419 | // huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly, |
420 | 420 | // or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html |
421 | - if( $response instanceof WP_Error ) { |
|
421 | + if ($response instanceof WP_Error) { |
|
422 | 422 | $error_msg = sprintf( |
423 | - __( 'WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso' ), |
|
423 | + __('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'), |
|
424 | 424 | $response->get_error_code(), |
425 | 425 | $response->get_error_message(), |
426 | - print_r( $response->get_error_data(), true ) |
|
426 | + print_r($response->get_error_data(), true) |
|
427 | 427 | ); |
428 | - } elseif( is_array( $response ) && isset( $response[ 'body' ] ) ) { |
|
429 | - $error_msg = $response[ 'body' ]; |
|
428 | + } elseif (is_array($response) && isset($response['body'])) { |
|
429 | + $error_msg = $response['body']; |
|
430 | 430 | } else { |
431 | - $error_msg = print_r( $response, true ); |
|
431 | + $error_msg = print_r($response, true); |
|
432 | 432 | } |
433 | - $payment->set_gateway_response( sprintf( __( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $error_msg ) ); |
|
434 | - $payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) ); |
|
435 | - $payment->set_status( EEM_Payment::status_id_failed ); |
|
433 | + $payment->set_gateway_response(sprintf(__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $error_msg)); |
|
434 | + $payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response)); |
|
435 | + $payment->set_status(EEM_Payment::status_id_failed); |
|
436 | 436 | // log the results |
437 | 437 | $this->log( |
438 | 438 | array( |
@@ -452,9 +452,9 @@ discard block |
||
452 | 452 | * @return string |
453 | 453 | */ |
454 | 454 | protected function _process_response_url() { |
455 | - if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) { |
|
455 | + if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { |
|
456 | 456 | $url = is_ssl() ? 'https://' : 'http://'; |
457 | - $url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' ); |
|
457 | + $url .= EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
458 | 458 | $url .= EEH_URL::filter_input_server_url(); |
459 | 459 | } else { |
460 | 460 | $url = 'unknown'; |
@@ -471,12 +471,12 @@ discard block |
||
471 | 471 | * @param EEI_Payment $payment |
472 | 472 | * @throws \EE_Error |
473 | 473 | */ |
474 | - public function update_txn_based_on_payment( $payment ) { |
|
474 | + public function update_txn_based_on_payment($payment) { |
|
475 | 475 | $update_info = $payment->details(); |
476 | 476 | /** @var EE_Transaction $transaction */ |
477 | 477 | $transaction = $payment->transaction(); |
478 | - $payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false ); |
|
479 | - if( ! $transaction ){ |
|
478 | + $payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false); |
|
479 | + if ( ! $transaction) { |
|
480 | 480 | $this->log( |
481 | 481 | __( |
482 | 482 | 'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | ); |
487 | 487 | return; |
488 | 488 | } |
489 | - if( |
|
490 | - ! is_array( $update_info ) |
|
491 | - || ! isset( $update_info[ 'mc_shipping' ] ) |
|
492 | - || ! isset( $update_info[ 'tax' ] ) |
|
489 | + if ( |
|
490 | + ! is_array($update_info) |
|
491 | + || ! isset($update_info['mc_shipping']) |
|
492 | + || ! isset($update_info['tax']) |
|
493 | 493 | ) { |
494 | 494 | $this->log( |
495 | 495 | array( |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | ); |
505 | 505 | return; |
506 | 506 | } |
507 | - if( $payment->status() !== $this->_pay_model->approved_status() ) { |
|
507 | + if ($payment->status() !== $this->_pay_model->approved_status()) { |
|
508 | 508 | $this->log( |
509 | 509 | array( |
510 | 510 | 'message' => __( |
@@ -523,44 +523,44 @@ discard block |
||
523 | 523 | $transaction_total_line_item = $transaction->total_line_item(); |
524 | 524 | |
525 | 525 | //might paypal have changed the taxes? |
526 | - if( $this->_paypal_taxes && $payment_was_itemized ) { |
|
526 | + if ($this->_paypal_taxes && $payment_was_itemized) { |
|
527 | 527 | // note that we're doing this BEFORE adding shipping; |
528 | 528 | // we actually want PayPal's shipping to remain non-taxable |
529 | - $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' ); |
|
529 | + $this->_line_item->set_line_items_taxable($transaction_total_line_item, true, 'paypal_shipping'); |
|
530 | 530 | $this->_line_item->set_total_tax_to( |
531 | 531 | $transaction_total_line_item, |
532 | - (float)$update_info['tax'], |
|
533 | - __( 'Taxes', 'event_espresso' ), |
|
534 | - __( 'Calculated by Paypal', 'event_espresso' ), |
|
532 | + (float) $update_info['tax'], |
|
533 | + __('Taxes', 'event_espresso'), |
|
534 | + __('Calculated by Paypal', 'event_espresso'), |
|
535 | 535 | 'paypal_tax' |
536 | 536 | ); |
537 | 537 | $grand_total_needs_resaving = TRUE; |
538 | 538 | } |
539 | 539 | |
540 | - $shipping_amount = (float)$update_info[ 'mc_shipping' ]; |
|
540 | + $shipping_amount = (float) $update_info['mc_shipping']; |
|
541 | 541 | //might paypal have added shipping? |
542 | - if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){ |
|
542 | + if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) { |
|
543 | 543 | $this->_line_item->add_unrelated_item( |
544 | 544 | $transaction_total_line_item, |
545 | - sprintf( __('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ), |
|
545 | + sprintf(__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()), |
|
546 | 546 | $shipping_amount, |
547 | 547 | __('Shipping charges calculated by Paypal', 'event_espresso'), |
548 | 548 | 1, |
549 | 549 | false, |
550 | - 'paypal_shipping_' . $transaction->ID() |
|
550 | + 'paypal_shipping_'.$transaction->ID() |
|
551 | 551 | ); |
552 | 552 | $grand_total_needs_resaving = true; |
553 | 553 | } |
554 | 554 | |
555 | - if( $grand_total_needs_resaving ){ |
|
556 | - $transaction_total_line_item->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
555 | + if ($grand_total_needs_resaving) { |
|
556 | + $transaction_total_line_item->save_this_and_descendants_to_txn($transaction->ID()); |
|
557 | 557 | /** @var EE_Registration_Processor $registration_processor */ |
558 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
559 | - $registration_processor->update_registration_final_prices( $transaction ); |
|
558 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
559 | + $registration_processor->update_registration_final_prices($transaction); |
|
560 | 560 | } |
561 | 561 | $this->log( |
562 | 562 | array( |
563 | - 'message' => __( 'Updated transaction related to payment', 'event_espresso' ), |
|
563 | + 'message' => __('Updated transaction related to payment', 'event_espresso'), |
|
564 | 564 | 'url' => $this->_process_response_url(), |
565 | 565 | 'transaction (updated)' => $transaction->model_field_array(), |
566 | 566 | 'payment (updated)' => $payment->model_field_array(), |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @author Mike Nelson |
9 | 9 | * |
10 | 10 | */ |
11 | -class EEG_Mijireh extends EE_Offsite_Gateway{ |
|
11 | +class EEG_Mijireh extends EE_Offsite_Gateway { |
|
12 | 12 | |
13 | 13 | protected $_access_key; |
14 | 14 | |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | $primary_attendee = $primary_registrant->attendee(); |
38 | 38 | $items = array(); |
39 | 39 | //if we're are charging for the full amount, show the normal line items |
40 | - if( $this->_can_easily_itemize_transaction_for( $payment )){ |
|
40 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
41 | 41 | $total_line_item = $transaction->total_line_item(); |
42 | 42 | $tax_total = $total_line_item->get_total_tax(); |
43 | - foreach($total_line_item->get_items() as $line_item){ |
|
43 | + foreach ($total_line_item->get_items() as $line_item) { |
|
44 | 44 | $items[] = array( |
45 | 45 | 'name'=>apply_filters( |
46 | 46 | 'FHEE__EEG_Mijireh__set_redirection_info__full_amount_line_item_name', |
47 | - $this->_format_line_item_name( $line_item, $payment ), |
|
47 | + $this->_format_line_item_name($line_item, $payment), |
|
48 | 48 | $line_item, |
49 | 49 | $payment, |
50 | 50 | $primary_registrant |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | 'quantity'=>$line_item->quantity() |
55 | 55 | ); |
56 | 56 | } |
57 | - }else{//its a partial payment |
|
57 | + } else {//its a partial payment |
|
58 | 58 | $tax_total = 0; |
59 | 59 | //partial payment, so just add 1 item |
60 | 60 | $items[] = array( |
61 | 61 | 'name'=> apply_filters( |
62 | 62 | 'FHEE__EEG_Mijireh__set_redirection_info__partial_amount_line_item_name', |
63 | - $this->_format_partial_payment_line_item_name( $payment ), |
|
63 | + $this->_format_partial_payment_line_item_name($payment), |
|
64 | 64 | $payment, |
65 | 65 | $primary_registrant |
66 | 66 | ), |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | $order = array( |
73 | 73 | 'total'=>$this->format_currency($payment->amount()), |
74 | 74 | 'return_url'=>$return_url, |
75 | - 'items'=>$this->_prepare_for_mijireh( $items ), |
|
75 | + 'items'=>$this->_prepare_for_mijireh($items), |
|
76 | 76 | 'email'=>$primary_attendee->email(), |
77 | 77 | 'first_name'=>$primary_attendee->fname(), |
78 | 78 | 'last_name'=>$primary_attendee->lname(), |
79 | 79 | 'tax'=>$this->format_currency($tax_total), |
80 | 80 | 'partner_id'=>'ee'); |
81 | 81 | //setup address? |
82 | - if( $primary_attendee->address() && |
|
83 | - $primary_attendee->city() && |
|
84 | - $primary_attendee->state_ID() && |
|
85 | - $primary_attendee->country_ID() && |
|
86 | - $primary_attendee->zip() ){ |
|
82 | + if ($primary_attendee->address() && |
|
83 | + $primary_attendee->city() && |
|
84 | + $primary_attendee->state_ID() && |
|
85 | + $primary_attendee->country_ID() && |
|
86 | + $primary_attendee->zip()) { |
|
87 | 87 | $shipping_address = array( |
88 | 88 | 'first_name'=>$primary_attendee->fname(), |
89 | 89 | 'last_name'=>$primary_attendee->lname(), |
@@ -93,62 +93,62 @@ discard block |
||
93 | 93 | 'zip_code' => $primary_attendee->zip(), |
94 | 94 | 'country' => $primary_attendee->country_ID() |
95 | 95 | ); |
96 | - if( $primary_attendee->address2() ){ |
|
97 | - $shipping_address[ 'apt_suite' ] = $primary_attendee->address2(); |
|
96 | + if ($primary_attendee->address2()) { |
|
97 | + $shipping_address['apt_suite'] = $primary_attendee->address2(); |
|
98 | 98 | } |
99 | - if( $primary_attendee->phone() ){ |
|
100 | - $shipping_address[ 'phone' ] = $primary_attendee->phone(); |
|
99 | + if ($primary_attendee->phone()) { |
|
100 | + $shipping_address['phone'] = $primary_attendee->phone(); |
|
101 | 101 | } |
102 | - $order[ 'shipping_address' ] = $shipping_address; |
|
102 | + $order['shipping_address'] = $shipping_address; |
|
103 | 103 | } |
104 | - $order = apply_filters( 'FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant ); |
|
105 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this)) ); |
|
104 | + $order = apply_filters('FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant); |
|
105 | + do_action('AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this))); |
|
106 | 106 | $args = array( |
107 | 107 | 'headers' => array( |
108 | - 'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ), |
|
108 | + 'Authorization' => 'Basic '.base64_encode($this->_access_key.':'), |
|
109 | 109 | 'Accept'=>'application/json' |
110 | 110 | ), |
111 | 111 | 'body'=> json_encode($order) |
112 | 112 | ); |
113 | - $response = wp_remote_post( $this->_mijireh_api_orders_url, $args ); |
|
113 | + $response = wp_remote_post($this->_mijireh_api_orders_url, $args); |
|
114 | 114 | $problems_string = false; |
115 | - $this->log(array('get checkout url request_args' => $args, 'response' => $response ), $payment); |
|
116 | - if( ! $response instanceof WP_Error ){ |
|
115 | + $this->log(array('get checkout url request_args' => $args, 'response' => $response), $payment); |
|
116 | + if ( ! $response instanceof WP_Error) { |
|
117 | 117 | $response_body = json_decode($response['body']); |
118 | - if($response_body && isset($response_body->checkout_url)){ |
|
118 | + if ($response_body && isset($response_body->checkout_url)) { |
|
119 | 119 | $payment->set_redirect_url($response_body->checkout_url); |
120 | 120 | $payment->set_txn_id_chq_nmbr($response_body->order_number); |
121 | 121 | $payment->set_details($response['body']); |
122 | 122 | } else { |
123 | - if( is_array( $response_body ) || is_object( $response_body)){ |
|
124 | - $response_body_as_array = (array)$response_body; |
|
125 | - foreach($response_body_as_array as $problem_parameter => $problems){ |
|
126 | - $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems)); |
|
123 | + if (is_array($response_body) || is_object($response_body)) { |
|
124 | + $response_body_as_array = (array) $response_body; |
|
125 | + foreach ($response_body_as_array as $problem_parameter => $problems) { |
|
126 | + $problems_string .= sprintf(__('\nProblems with %s: %s', 'event_espresso'), $problem_parameter, implode(", ", $problems)); |
|
127 | 127 | } |
128 | - }else{ |
|
128 | + } else { |
|
129 | 129 | $problems_string = $response['body']; |
130 | 130 | } |
131 | - if( ! $problems_string ) { |
|
131 | + if ( ! $problems_string) { |
|
132 | 132 | //no message to show? wack |
133 | - if( isset( $response[ 'headers' ][ 'status' ] ) ){ |
|
134 | - $problems_string = $response[ 'headers' ][ 'status' ]; |
|
135 | - }else{ |
|
136 | - $problems_string = __( 'No response from Mijireh', 'event_espresso' ); |
|
133 | + if (isset($response['headers']['status'])) { |
|
134 | + $problems_string = $response['headers']['status']; |
|
135 | + } else { |
|
136 | + $problems_string = __('No response from Mijireh', 'event_espresso'); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | } |
140 | - }else{ |
|
141 | - $problems_string = implode( ",", $response->get_error_messages() ); |
|
140 | + } else { |
|
141 | + $problems_string = implode(",", $response->get_error_messages()); |
|
142 | 142 | } |
143 | 143 | |
144 | - if( $problems_string ) { |
|
145 | - $payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) ); |
|
146 | - $payment->set_details( $response ); |
|
147 | - $payment->set_redirect_url( null ); |
|
144 | + if ($problems_string) { |
|
145 | + $payment->set_gateway_response(sprintf(__('Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string)); |
|
146 | + $payment->set_details($response); |
|
147 | + $payment->set_redirect_url(null); |
|
148 | 148 | //even though the payment's status is failed at this point anyways, |
149 | 149 | //let's be explicit about it. The fact that the redirect url is null |
150 | 150 | //should be enough to client code that they can't redirect the user |
151 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
151 | + $payment->set_status($this->_pay_model->failed_status()); |
|
152 | 152 | } |
153 | 153 | return $payment; |
154 | 154 | } |
@@ -161,16 +161,16 @@ discard block |
||
161 | 161 | * @param mixed $data |
162 | 162 | * @return mixed same type as $data |
163 | 163 | */ |
164 | - private function _prepare_for_mijireh( $data ){ |
|
165 | - if( is_array( $data ) ){ |
|
164 | + private function _prepare_for_mijireh($data) { |
|
165 | + if (is_array($data)) { |
|
166 | 166 | $prepared_data = array(); |
167 | - foreach($data as $key => $datum ){ |
|
168 | - $prepared_data[ $key ] = $this->_prepare_for_mijireh( $datum ); |
|
167 | + foreach ($data as $key => $datum) { |
|
168 | + $prepared_data[$key] = $this->_prepare_for_mijireh($datum); |
|
169 | 169 | } |
170 | 170 | return $prepared_data; |
171 | - }elseif(is_string( $data ) ){ |
|
172 | - return str_replace( '%', 'percent', $data ); |
|
173 | - }else{ |
|
171 | + }elseif (is_string($data)) { |
|
172 | + return str_replace('%', 'percent', $data); |
|
173 | + } else { |
|
174 | 174 | return $data; |
175 | 175 | } |
176 | 176 | } |
@@ -191,30 +191,30 @@ discard block |
||
191 | 191 | |
192 | 192 | $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : NULL; |
193 | 193 | |
194 | - if ( ! $payment instanceof EEI_Payment ){ |
|
195 | - throw new EE_Error( sprintf( __( "Could not find Mijireh payment for transaction %s", 'event_espresso' ), $transaction->ID() ) ); |
|
194 | + if ( ! $payment instanceof EEI_Payment) { |
|
195 | + throw new EE_Error(sprintf(__("Could not find Mijireh payment for transaction %s", 'event_espresso'), $transaction->ID())); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $request_args = array( |
199 | 199 | 'headers' => array( |
200 | - 'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ), |
|
200 | + 'Authorization' => 'Basic '.base64_encode($this->_access_key.':'), |
|
201 | 201 | 'Accept'=>'application/json' |
202 | 202 | ) |
203 | 203 | ); |
204 | 204 | |
205 | 205 | $response = wp_remote_get( |
206 | - $this->_mijireh_api_orders_url . '/' . $payment->txn_id_chq_nmbr(), |
|
206 | + $this->_mijireh_api_orders_url.'/'.$payment->txn_id_chq_nmbr(), |
|
207 | 207 | $request_args |
208 | 208 | ); |
209 | 209 | |
210 | 210 | $this->log( |
211 | - array( 'get payment status request_args' => $request_args, 'response' => $response ), |
|
211 | + array('get payment status request_args' => $request_args, 'response' => $response), |
|
212 | 212 | $payment |
213 | 213 | ); |
214 | 214 | // validate response |
215 | - $response_body = isset( $response[ 'body' ] ) ? json_decode( $response[ 'body' ] ) : ''; |
|
216 | - if( $response && $response_body ){ |
|
217 | - switch( $response_body->status ){ |
|
215 | + $response_body = isset($response['body']) ? json_decode($response['body']) : ''; |
|
216 | + if ($response && $response_body) { |
|
217 | + switch ($response_body->status) { |
|
218 | 218 | case 'paid': |
219 | 219 | $payment->set_status($this->_pay_model->approved_status()); |
220 | 220 | break; |
@@ -226,9 +226,9 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | } else { |
229 | - $payment->set_gateway_response( __( 'Response from Mijireh could not be understood.', 'event_espresso' ) ); |
|
230 | - $payment->set_details( $response ); |
|
231 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
229 | + $payment->set_gateway_response(__('Response from Mijireh could not be understood.', 'event_espresso')); |
|
230 | + $payment->set_details($response); |
|
231 | + $payment->set_status($this->_pay_model->failed_status()); |
|
232 | 232 | } |
233 | 233 | // the following is ONLY for testing the Mijireh IPN and should NEVER be uncommented for real usage |
234 | 234 | // $payment->set_status( $this->_pay_model->pending_status() ); |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | /** |
6 | 7 | * Event Espresso |
7 | 8 | * |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEG_Aim extends EE_Onsite_Gateway{ |
|
28 | +class EEG_Aim extends EE_Onsite_Gateway { |
|
29 | 29 | |
30 | 30 | const LIVE_URL = 'https://secure2.authorize.net/gateway/transact.dll'; //Authnet URL |
31 | 31 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @param EEG_Aim $gateway_object |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public function possibly_use_deprecated_aim_server( $url, EEG_Aim $gateway_object ) { |
|
161 | - if( $gateway_object->_server === 'authorize.net' |
|
162 | - && ! $gateway_object->_debug_mode ) { |
|
160 | + public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object) { |
|
161 | + if ($gateway_object->_server === 'authorize.net' |
|
162 | + && ! $gateway_object->_debug_mode) { |
|
163 | 163 | return 'https://secure.authorize.net/gateway/transact.dll'; |
164 | 164 | } else { |
165 | 165 | return $url; |
@@ -182,33 +182,33 @@ discard block |
||
182 | 182 | */ |
183 | 183 | |
184 | 184 | public function do_direct_payment($payment, $billing_info = null) { |
185 | - add_filter( 'FHEE__EEG_Aim___get_server_url', array( $this, 'possibly_use_deprecated_aim_server' ), 10, 2 ); |
|
185 | + add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2); |
|
186 | 186 | // Enable test mode if needed |
187 | 187 | //4007000000027 <-- test successful visa |
188 | 188 | //4222222222222 <-- test failure card number |
189 | 189 | |
190 | 190 | $item_num = 1; |
191 | 191 | $transaction = $payment->transaction(); |
192 | - $order_description = $this->_format_order_description( $payment ); |
|
192 | + $order_description = $this->_format_order_description($payment); |
|
193 | 193 | $primary_registrant = $transaction->primary_registration(); |
194 | 194 | //if we're are charging for the full amount, show the normal line items |
195 | 195 | //and the itemized total adds up properly |
196 | - if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
|
196 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
197 | 197 | $total_line_item = $transaction->total_line_item(); |
198 | 198 | foreach ($total_line_item->get_items() as $line_item) { |
199 | - if( $line_item->quantity() == 0 ){ |
|
199 | + if ($line_item->quantity() == 0) { |
|
200 | 200 | continue; |
201 | 201 | } |
202 | 202 | $this->addLineItem( |
203 | 203 | $item_num++, |
204 | - $this->_format_line_item_name( $line_item, $payment ), |
|
205 | - $this->_format_line_item_desc( $line_item, $payment ), |
|
204 | + $this->_format_line_item_name($line_item, $payment), |
|
205 | + $this->_format_line_item_desc($line_item, $payment), |
|
206 | 206 | $line_item->quantity(), |
207 | 207 | $line_item->unit_price(), |
208 | 208 | 'N'); |
209 | 209 | $order_description .= $line_item->desc().', '; |
210 | 210 | } |
211 | - foreach($total_line_item->tax_descendants() as $tax_line_item){ |
|
211 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
212 | 212 | $this->addLineItem($item_num++, $tax_line_item->name(), $tax_line_item->desc(), 1, $tax_line_item->total(), 'N'); |
213 | 213 | } |
214 | 214 | } |
@@ -219,18 +219,18 @@ discard block |
||
219 | 219 | //start transaction |
220 | 220 | //if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id |
221 | 221 | $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363'; |
222 | - $this->setField( 'solution_id', $partner_id ); |
|
222 | + $this->setField('solution_id', $partner_id); |
|
223 | 223 | $this->setField('amount', $this->format_currency($payment->amount())); |
224 | - $this->setField('description',substr(rtrim($order_description, ', '), 0, 255)); |
|
225 | - $this->_set_sensitive_billing_data( $billing_info ); |
|
224 | + $this->setField('description', substr(rtrim($order_description, ', '), 0, 255)); |
|
225 | + $this->_set_sensitive_billing_data($billing_info); |
|
226 | 226 | $this->setField('first_name', $billing_info['first_name']); |
227 | 227 | $this->setField('last_name', $billing_info['last_name']); |
228 | 228 | $this->setField('email', $billing_info['email']); |
229 | 229 | $this->setField('company', $billing_info['company']); |
230 | 230 | $this->setField('address', $billing_info['address'].' '.$billing_info['address2']); |
231 | 231 | $this->setField('city', $billing_info['city']); |
232 | - $this->setField('state', $billing_info['state'] ); |
|
233 | - $this->setField('country', $billing_info['country'] ); |
|
232 | + $this->setField('state', $billing_info['state']); |
|
233 | + $this->setField('country', $billing_info['country']); |
|
234 | 234 | $this->setField('zip', $billing_info['zip']); |
235 | 235 | $this->setField('fax', $billing_info['fax']); |
236 | 236 | $this->setField('cust_id', $primary_registrant->ID()); |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | //invoice_num would be nice to have it be unique per SPCO page-load, that way if users |
239 | 239 | //press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page |
240 | 240 | //in which case, we need to generate teh invoice num per request right here... |
241 | - $this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
241 | + $this->setField('invoice_num', wp_generate_password(12, false)); //$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
242 | 242 | //tell AIM that any duplicates sent in the next 5 minutes are to be ignored |
243 | - $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS ); |
|
243 | + $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS); |
|
244 | 244 | |
245 | 245 | |
246 | 246 | if ($this->_test_transactions) { |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | //Capture response |
251 | 251 | $this->type = "AUTH_CAPTURE"; |
252 | 252 | $response = $this->_sendRequest($payment); |
253 | - if (!empty($response)){ |
|
253 | + if ( ! empty($response)) { |
|
254 | 254 | if ($this->_debug_mode) { |
255 | 255 | $txn_id = $response->invoice_number; |
256 | 256 | } else { |
@@ -259,15 +259,15 @@ discard block |
||
259 | 259 | $payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status(); |
260 | 260 | $payment->set_status($payment_status); |
261 | 261 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
262 | - $payment->set_amount( (float) $response->amount ); |
|
263 | - $payment->set_gateway_response(sprintf("%s (code: %s)",$response->response_reason_text,$response->response_reason_code)); |
|
264 | - $payment->set_txn_id_chq_nmbr( $txn_id ); |
|
262 | + $payment->set_amount((float) $response->amount); |
|
263 | + $payment->set_gateway_response(sprintf("%s (code: %s)", $response->response_reason_text, $response->response_reason_code)); |
|
264 | + $payment->set_txn_id_chq_nmbr($txn_id); |
|
265 | 265 | $payment->set_extra_accntng($primary_registrant->reg_code()); |
266 | - $payment->set_details(print_r($response,true)); |
|
266 | + $payment->set_details(print_r($response, true)); |
|
267 | 267 | } else { |
268 | 268 | $payment->set_status($this->_pay_model->failed_status()); |
269 | 269 | $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso')); |
270 | - $payment->set_details(print_r($response,true)); |
|
270 | + $payment->set_details(print_r($response, true)); |
|
271 | 271 | } |
272 | 272 | return $payment; |
273 | 273 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * what billing data gets sent |
279 | 279 | * @param array $billing_info |
280 | 280 | */ |
281 | - protected function _set_sensitive_billing_data( $billing_info ) { |
|
281 | + protected function _set_sensitive_billing_data($billing_info) { |
|
282 | 282 | $this->setField('card_num', $billing_info['credit_card']); |
283 | 283 | $this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']); |
284 | 284 | $this->setField('card_code', $billing_info['cvv']); |
@@ -337,22 +337,22 @@ discard block |
||
337 | 337 | $this->_x_post_fields['tran_key'] = $this->_transaction_key; |
338 | 338 | $x_keys = array(); |
339 | 339 | foreach ($this->_x_post_fields as $key => $value) { |
340 | - $x_keys[] = "x_$key=" . urlencode($value); |
|
340 | + $x_keys[] = "x_$key=".urlencode($value); |
|
341 | 341 | } |
342 | 342 | // Add line items |
343 | 343 | foreach ($this->_additional_line_items as $key => $value) { |
344 | - $x_keys[] = "x_line_item=" . urlencode($value); |
|
344 | + $x_keys[] = "x_line_item=".urlencode($value); |
|
345 | 345 | } |
346 | 346 | $this->_log_clean_request($x_keys, $payment); |
347 | 347 | $post_url = $this->_get_server_url(); |
348 | 348 | $curl_request = curl_init($post_url); |
349 | - curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&",$x_keys)); |
|
349 | + curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&", $x_keys)); |
|
350 | 350 | curl_setopt($curl_request, CURLOPT_HEADER, 0); |
351 | 351 | curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); |
352 | 352 | curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); |
353 | 353 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); |
354 | 354 | if ($this->VERIFY_PEER) { |
355 | - curl_setopt($curl_request, CURLOPT_CAINFO, dirname( __DIR__ ) . '/ssl/cert.pem'); |
|
355 | + curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem'); |
|
356 | 356 | } else { |
357 | 357 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); |
358 | 358 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $response = curl_exec($curl_request); |
365 | 365 | |
366 | 366 | curl_close($curl_request); |
367 | - $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
367 | + $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
368 | 368 | |
369 | 369 | return $this->_log_and_clean_response($response_obj, $payment); |
370 | 370 | } |
@@ -373,18 +373,18 @@ discard block |
||
373 | 373 | * @param array $request_array |
374 | 374 | * @param EEI_Payment $payment |
375 | 375 | */ |
376 | - protected function _log_clean_request($request_array,$payment){ |
|
377 | - $keys_to_filter_out = array( 'x_card_num', 'x_card_code', 'x_exp_date' ); |
|
378 | - foreach($request_array as $index => $keyvaltogether ) { |
|
379 | - foreach( $keys_to_filter_out as $key ) { |
|
380 | - if( strpos( $keyvaltogether, $key ) === 0 ){ |
|
376 | + protected function _log_clean_request($request_array, $payment) { |
|
377 | + $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date'); |
|
378 | + foreach ($request_array as $index => $keyvaltogether) { |
|
379 | + foreach ($keys_to_filter_out as $key) { |
|
380 | + if (strpos($keyvaltogether, $key) === 0) { |
|
381 | 381 | //found it at the first character |
382 | 382 | //so its one of them |
383 | - unset( $request_array[ $index ] ); |
|
383 | + unset($request_array[$index]); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | } |
387 | - $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url() ),$payment); |
|
387 | + $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url()), $payment); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | * @param EE_Payment $payment |
397 | 397 | * @return \EE_AuthorizeNetAIM_Response |
398 | 398 | */ |
399 | - private function _log_and_clean_response($response_obj,$payment){ |
|
399 | + private function _log_and_clean_response($response_obj, $payment) { |
|
400 | 400 | $response_obj->account_number = ''; |
401 | - $this->log(array('AIM Response received:'=>$response_obj),$payment); |
|
401 | + $this->log(array('AIM Response received:'=>$response_obj), $payment); |
|
402 | 402 | return $response_obj; |
403 | 403 | } |
404 | 404 | |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | // Split Array |
498 | 498 | $this->response = $response; |
499 | 499 | if ($encap_char) { |
500 | - $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
500 | + $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
501 | 501 | } else { |
502 | 502 | $this->_response_array = explode($delimiter, $response); |
503 | 503 | } |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | $this->held = ($this->response_code === self::HELD); |
568 | 568 | |
569 | 569 | if ($this->error || $this->declined || $this->held) { |
570 | - $this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />' . $this->response_reason_text . '<br /><span class="response_code">Response Code: ' . $this->response_code . '<br /></span><span class="response_subcode">Response Subcode: ' . $this->response_subcode . '</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> '; |
|
570 | + $this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />'.$this->response_reason_text.'<br /><span class="response_code">Response Code: '.$this->response_code.'<br /></span><span class="response_subcode">Response Subcode: '.$this->response_subcode.'</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> '; |
|
571 | 571 | |
572 | 572 | |
573 | 573 | /* $this->error_message = "AuthorizeNet Error: |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | |
587 | 587 | } |
588 | 588 | |
589 | -if ( ! class_exists( 'AuthorizeNetException' ) ) { |
|
589 | +if ( ! class_exists('AuthorizeNetException')) { |
|
590 | 590 | /** |
591 | 591 | * Class AuthorizeNetException |
592 | 592 | * |
@@ -602,8 +602,8 @@ discard block |
||
602 | 602 | * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0 |
603 | 603 | * @since 5.1.0 |
604 | 604 | */ |
605 | - public function __construct( $message = "", $code = 0, Exception $previous = null ) { |
|
606 | - parent::__construct( $message, $code, $previous ); |
|
605 | + public function __construct($message = "", $code = 0, Exception $previous = null) { |
|
606 | + parent::__construct($message, $code, $previous); |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Class EE_Country_Select_Input |
4 | 4 | * |
@@ -11,23 +11,23 @@ discard block |
||
11 | 11 | * @since $VID:$ |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Country_Select_Input extends EE_Select_Input{ |
|
14 | +class EE_Country_Select_Input extends EE_Select_Input { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param array $country_options |
18 | 18 | * @param array $input_settings |
19 | 19 | * @return EE_Country_Select_Input |
20 | 20 | */ |
21 | - public function __construct( $country_options = NULL, $input_settings = array() ){ |
|
21 | + public function __construct($country_options = NULL, $input_settings = array()) { |
|
22 | 22 | $country_options = apply_filters( |
23 | 23 | 'FHEE__EE_Country_Select_Input____construct__country_options', |
24 | - $this->get_country_answer_options( $country_options ), |
|
24 | + $this->get_country_answer_options($country_options), |
|
25 | 25 | $this |
26 | 26 | ); |
27 | - $input_settings['html_class'] = isset( $input_settings['html_class'] ) |
|
28 | - ? $input_settings['html_class'] . ' ee-country-select-js' |
|
27 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
28 | + ? $input_settings['html_class'].' ee-country-select-js' |
|
29 | 29 | : 'ee-country-select-js'; |
30 | - parent::__construct( $country_options, $input_settings ); |
|
30 | + parent::__construct($country_options, $input_settings); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @param array $country_options |
39 | 39 | * @return array |
40 | 40 | */ |
41 | - public function get_country_answer_options( $country_options = NULL ){ |
|
41 | + public function get_country_answer_options($country_options = NULL) { |
|
42 | 42 | // if passed something that is NOT an array |
43 | - if ( ! is_array( $country_options )) { |
|
43 | + if ( ! is_array($country_options)) { |
|
44 | 44 | // get possibly cached list of countries |
45 | 45 | $countries = EEM_Country::instance()->get_all_active_countries(); |
46 | - if ( ! empty( $countries )) { |
|
47 | - $country_options[ '' ] = ''; |
|
48 | - foreach( $countries as $country ){ |
|
49 | - if ( $country instanceof EE_Country ) { |
|
50 | - $country_options[ $country->ID() ] = $country->name(); |
|
46 | + if ( ! empty($countries)) { |
|
47 | + $country_options[''] = ''; |
|
48 | + foreach ($countries as $country) { |
|
49 | + if ($country instanceof EE_Country) { |
|
50 | + $country_options[$country->ID()] = $country->name(); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | } else { |
@@ -6,22 +6,22 @@ discard block |
||
6 | 6 | * @subpackage |
7 | 7 | * @author Mike Nelson |
8 | 8 | */ |
9 | -class EE_State_Select_Input extends EE_Select_Input{ |
|
9 | +class EE_State_Select_Input extends EE_Select_Input { |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @param array $state_options |
13 | 13 | * @param array $input_settings |
14 | 14 | */ |
15 | - function __construct( $state_options, $input_settings = array() ){ |
|
15 | + function __construct($state_options, $input_settings = array()) { |
|
16 | 16 | $state_options = apply_filters( |
17 | 17 | 'FHEE__EE_State_Select_Input____construct__state_options', |
18 | - $this->get_state_answer_options( $state_options ), |
|
18 | + $this->get_state_answer_options($state_options), |
|
19 | 19 | $this |
20 | 20 | ); |
21 | - $input_settings['html_class'] = isset( $input_settings['html_class'] ) |
|
22 | - ? $input_settings['html_class'] . ' ee-state-select-js' |
|
21 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
22 | + ? $input_settings['html_class'].' ee-state-select-js' |
|
23 | 23 | : 'ee-state-select-js'; |
24 | - parent::__construct( $state_options, $input_settings ); |
|
24 | + parent::__construct($state_options, $input_settings); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | * @param array $state_options |
33 | 33 | * @return array |
34 | 34 | */ |
35 | - public function get_state_answer_options( $state_options = NULL ){ |
|
35 | + public function get_state_answer_options($state_options = NULL) { |
|
36 | 36 | // if passed something that is NOT an array |
37 | - if ( ! is_array( $state_options )) { |
|
37 | + if ( ! is_array($state_options)) { |
|
38 | 38 | // get possibly cached list of states |
39 | 39 | $states = EEM_State::instance()->get_all_active_states(); |
40 | - if ( ! empty( $states )) { |
|
40 | + if ( ! empty($states)) { |
|
41 | 41 | //set the default |
42 | 42 | $state_options[''][''] = ''; |
43 | - foreach( $states as $state ){ |
|
44 | - if ( $state instanceof EE_State ) { |
|
45 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
43 | + foreach ($states as $state) { |
|
44 | + if ($state instanceof EE_State) { |
|
45 | + $state_options[$state->country()->name()][$state->ID()] = $state->name(); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | } else { |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class EE_Payment_Processor extends EE_Processor_Base { |
15 | 15 | /** |
16 | - * @var EE_Payment_Processor $_instance |
|
16 | + * @var EE_Payment_Processor $_instance |
|
17 | 17 | * @access private |
18 | - */ |
|
18 | + */ |
|
19 | 19 | private static $_instance; |
20 | 20 | |
21 | 21 | |
@@ -51,7 +51,6 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately. |
53 | 53 | * Saves the payment that is generated |
54 | - |
|
55 | 54 | * |
56 | 55 | *@param EE_Payment_Method $payment_method |
57 | 56 | * @param EE_Transaction $transaction |
@@ -131,7 +130,6 @@ discard block |
||
131 | 130 | |
132 | 131 | |
133 | 132 | /** |
134 | - |
|
135 | 133 | * @param EE_Transaction|int $transaction |
136 | 134 | * @param EE_Payment_Method $payment_method |
137 | 135 | * @throws EE_Error |
@@ -694,12 +692,12 @@ discard block |
||
694 | 692 | } |
695 | 693 | |
696 | 694 | /** |
697 | - * Force posts to PayPal to use TLS v1.2. See: |
|
698 | - * https://core.trac.wordpress.org/ticket/36320 |
|
699 | - * https://core.trac.wordpress.org/ticket/34924#comment:15 |
|
700 | - * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US |
|
695 | + * Force posts to PayPal to use TLS v1.2. See: |
|
696 | + * https://core.trac.wordpress.org/ticket/36320 |
|
697 | + * https://core.trac.wordpress.org/ticket/34924#comment:15 |
|
698 | + * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US |
|
701 | 699 | * This will affect paypal standard, pro, express, and payflow. |
702 | - */ |
|
700 | + */ |
|
703 | 701 | public static function _curl_requests_to_paypal_use_tls( $handle, $r, $url ) { |
704 | 702 | if ( strstr( $url, 'https://' ) && strstr( $url, '.paypal.com' ) ) { |
705 | 703 | //Use the value of the constant CURL_SSLVERSION_TLSv1 = 1 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EE_Payment_Processor |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function instance() { |
29 | 29 | // check if class object is instantiated |
30 | - if ( ! self::$_instance instanceof EE_Payment_Processor ) { |
|
30 | + if ( ! self::$_instance instanceof EE_Payment_Processor) { |
|
31 | 31 | self::$_instance = new self(); |
32 | 32 | } |
33 | 33 | return self::$_instance; |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | *@access private |
42 | 42 | */ |
43 | 43 | private function __construct() { |
44 | - do_action( 'AHEE__EE_Payment_Processor__construct' ); |
|
45 | - add_action( 'http_api_curl', array( $this, '_curl_requests_to_paypal_use_tls' ), 10, 3 ); |
|
44 | + do_action('AHEE__EE_Payment_Processor__construct'); |
|
45 | + add_action('http_api_curl', array($this, '_curl_requests_to_paypal_use_tls'), 10, 3); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $update_txn = true, |
82 | 82 | $cancel_url = '' |
83 | 83 | ) { |
84 | - if( (float)$amount < 0 ) { |
|
84 | + if ((float) $amount < 0) { |
|
85 | 85 | throw new EE_Error( |
86 | 86 | sprintf( |
87 | 87 | __( |
@@ -94,33 +94,33 @@ discard block |
||
94 | 94 | ); |
95 | 95 | } |
96 | 96 | // verify payment method |
97 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE ); |
|
97 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE); |
|
98 | 98 | // verify transaction |
99 | - EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
100 | - $transaction->set_payment_method_ID( $payment_method->ID() ); |
|
99 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
100 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
101 | 101 | // verify payment method type |
102 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
102 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
103 | 103 | $payment = $payment_method->type_obj()->process_payment( |
104 | 104 | $transaction, |
105 | - min( $amount, $transaction->remaining() ),//make sure we don't overcharge |
|
105 | + min($amount, $transaction->remaining()), //make sure we don't overcharge |
|
106 | 106 | $billing_form, |
107 | 107 | $return_url, |
108 | - add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ), |
|
108 | + add_query_arg(array('ee_cancel_payment' => true), $cancel_url), |
|
109 | 109 | $method, |
110 | 110 | $by_admin |
111 | 111 | ); |
112 | 112 | // check if payment method uses an off-site gateway |
113 | - if ( $payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite ) { |
|
113 | + if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) { |
|
114 | 114 | // don't process payments for off-site gateways yet because no payment has occurred yet |
115 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
115 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
116 | 116 | } |
117 | 117 | return $payment; |
118 | 118 | } else { |
119 | 119 | EE_Error::add_error( |
120 | 120 | sprintf( |
121 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
121 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
122 | 122 | '<br/>', |
123 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
123 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
124 | 124 | ), __FILE__, __FUNCTION__, __LINE__ |
125 | 125 | ); |
126 | 126 | return NULL; |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | * @throws EE_Error |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - public function get_ipn_url_for_payment_method( $transaction, $payment_method ){ |
|
139 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) { |
|
140 | 140 | /** @type \EE_Transaction $transaction */ |
141 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
141 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
142 | 142 | $primary_reg = $transaction->primary_registration(); |
143 | - if( ! $primary_reg instanceof EE_Registration ){ |
|
143 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
144 | 144 | throw new EE_Error( |
145 | 145 | sprintf( |
146 | 146 | __( |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ) |
152 | 152 | ); |
153 | 153 | } |
154 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true); |
|
154 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true); |
|
155 | 155 | $url = add_query_arg( |
156 | 156 | array( |
157 | 157 | 'e_reg_url_link'=>$primary_reg->reg_url_link(), |
@@ -188,92 +188,92 @@ discard block |
||
188 | 188 | $update_txn = true, |
189 | 189 | $separate_IPN_request = true |
190 | 190 | ) { |
191 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
192 | - $_req_data = $this->_remove_unusable_characters_from_array( (array)$_req_data ); |
|
193 | - EE_Processor_Base::set_IPN( $separate_IPN_request ); |
|
191 | + EE_Registry::instance()->load_model('Change_Log'); |
|
192 | + $_req_data = $this->_remove_unusable_characters_from_array((array) $_req_data); |
|
193 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
194 | 194 | $obj_for_log = null; |
195 | - if( $transaction instanceof EE_Transaction ){ |
|
195 | + if ($transaction instanceof EE_Transaction) { |
|
196 | 196 | $obj_for_log = $transaction; |
197 | - if( $payment_method instanceof EE_Payment_Method ) { |
|
197 | + if ($payment_method instanceof EE_Payment_Method) { |
|
198 | 198 | $obj_for_log = EEM_Payment::instance()->get_one( |
199 | 199 | array( |
200 | - array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), |
|
201 | - 'order_by' => array( 'PAY_timestamp' => 'desc' ) |
|
200 | + array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), |
|
201 | + 'order_by' => array('PAY_timestamp' => 'desc') |
|
202 | 202 | ) |
203 | 203 | ); |
204 | 204 | } |
205 | - } else if( $payment_method instanceof EE_Payment ) { |
|
205 | + } else if ($payment_method instanceof EE_Payment) { |
|
206 | 206 | $obj_for_log = $payment_method; |
207 | 207 | } |
208 | 208 | $log = EEM_Change_Log::instance()->log( |
209 | 209 | EEM_Change_Log::type_gateway, |
210 | - array( 'IPN data received' => $_req_data ), |
|
210 | + array('IPN data received' => $_req_data), |
|
211 | 211 | $obj_for_log |
212 | 212 | ); |
213 | - try{ |
|
213 | + try { |
|
214 | 214 | /** |
215 | 215 | * @var EE_Payment $payment |
216 | 216 | */ |
217 | 217 | $payment = NULL; |
218 | - if($transaction && $payment_method){ |
|
218 | + if ($transaction && $payment_method) { |
|
219 | 219 | /** @type EE_Transaction $transaction */ |
220 | 220 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
221 | 221 | /** @type EE_Payment_Method $payment_method */ |
222 | 222 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
223 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
224 | - $payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction ); |
|
223 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
224 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
225 | 225 | $log->set_object($payment); |
226 | 226 | } else { |
227 | 227 | // not a payment |
228 | 228 | EE_Error::add_error( |
229 | 229 | sprintf( |
230 | - __( '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.', 'event_espresso' ), |
|
230 | + __('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.', 'event_espresso'), |
|
231 | 231 | '<br/>', |
232 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
232 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
233 | 233 | ), |
234 | 234 | __FILE__, __FUNCTION__, __LINE__ |
235 | 235 | ); |
236 | 236 | } |
237 | - }else{ |
|
237 | + } else { |
|
238 | 238 | //that's actually pretty ok. The IPN just wasn't able |
239 | 239 | //to identify which transaction or payment method this was for |
240 | 240 | // give all active payment methods a chance to claim it |
241 | 241 | $active_payment_methods = EEM_Payment_Method::instance()->get_all_active(); |
242 | - foreach( $active_payment_methods as $active_payment_method ){ |
|
243 | - try{ |
|
244 | - $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn( $_req_data ); |
|
242 | + foreach ($active_payment_methods as $active_payment_method) { |
|
243 | + try { |
|
244 | + $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
245 | 245 | $payment_method = $active_payment_method; |
246 | 246 | EEM_Change_Log::instance()->log( |
247 | 247 | EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment |
248 | 248 | ); |
249 | 249 | break; |
250 | - } catch( EE_Error $e ) { |
|
250 | + } catch (EE_Error $e) { |
|
251 | 251 | //that's fine- it apparently couldn't handle the IPN |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | } |
256 | 256 | // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
257 | - if( $payment instanceof EE_Payment){ |
|
257 | + if ($payment instanceof EE_Payment) { |
|
258 | 258 | $payment->save(); |
259 | 259 | // update the TXN |
260 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
|
261 | - }else{ |
|
260 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request); |
|
261 | + } else { |
|
262 | 262 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
263 | - if($payment_method){ |
|
263 | + if ($payment_method) { |
|
264 | 264 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
265 | - }elseif($transaction){ |
|
265 | + }elseif ($transaction) { |
|
266 | 266 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
267 | 267 | } |
268 | 268 | } |
269 | 269 | return $payment; |
270 | 270 | |
271 | - } catch( EE_Error $e ) { |
|
271 | + } catch (EE_Error $e) { |
|
272 | 272 | do_action( |
273 | 273 | 'AHEE__log', __FILE__, __FUNCTION__, sprintf( |
274 | - __( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ), |
|
275 | - print_r( $transaction, TRUE ), |
|
276 | - print_r( $_req_data, TRUE ), |
|
274 | + __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), |
|
275 | + print_r($transaction, TRUE), |
|
276 | + print_r($_req_data, TRUE), |
|
277 | 277 | $e->getMessage() |
278 | 278 | ) |
279 | 279 | ); |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | * @param array $request_data |
289 | 289 | * @return array |
290 | 290 | */ |
291 | - protected function _remove_unusable_characters_from_array( array $request_data ) { |
|
291 | + protected function _remove_unusable_characters_from_array(array $request_data) { |
|
292 | 292 | $return_data = array(); |
293 | - foreach( $request_data as $key => $value ) { |
|
294 | - $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
|
293 | + foreach ($request_data as $key => $value) { |
|
294 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value); |
|
295 | 295 | } |
296 | 296 | return $return_data; |
297 | 297 | } |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * @param string $request_data |
304 | 304 | * @return string |
305 | 305 | */ |
306 | - protected function _remove_unusable_characters( $request_data ) { |
|
307 | - return preg_replace( '/[^[:print:]]/', '', $request_data ); |
|
306 | + protected function _remove_unusable_characters($request_data) { |
|
307 | + return preg_replace('/[^[:print:]]/', '', $request_data); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, |
327 | 327 | * to call handle_ipn() for offsite gateways that don't receive separate IPNs |
328 | 328 | */ |
329 | - public function finalize_payment_for( $transaction, $update_txn = TRUE ){ |
|
329 | + public function finalize_payment_for($transaction, $update_txn = TRUE) { |
|
330 | 330 | /** @var $transaction EE_Transaction */ |
331 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
331 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
332 | 332 | $last_payment_method = $transaction->payment_method(); |
333 | - if ( $last_payment_method instanceof EE_Payment_Method ) { |
|
334 | - $payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction ); |
|
335 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
333 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
334 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
335 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
336 | 336 | return $payment; |
337 | 337 | } else { |
338 | 338 | return NULL; |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | EE_Payment $payment_to_refund, |
356 | 356 | $refund_info = array() |
357 | 357 | ) { |
358 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) { |
|
359 | - $payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info ); |
|
360 | - $this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund ); |
|
358 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
359 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
360 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
361 | 361 | } |
362 | 362 | return $payment_to_refund; |
363 | 363 | } |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | * TXN is locked before updating |
399 | 399 | * @throws \EE_Error |
400 | 400 | */ |
401 | - public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){ |
|
401 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) { |
|
402 | 402 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
403 | 403 | /** @type EE_Transaction $transaction */ |
404 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
404 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
405 | 405 | // can we freely update the TXN at this moment? |
406 | - if ( $IPN && $transaction->is_locked() ) { |
|
406 | + if ($IPN && $transaction->is_locked()) { |
|
407 | 407 | // don't update the transaction at this exact moment |
408 | 408 | // because the TXN is active in another request |
409 | 409 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
@@ -413,38 +413,38 @@ discard block |
||
413 | 413 | ); |
414 | 414 | } else { |
415 | 415 | // verify payment and that it has been saved |
416 | - if ( $payment instanceof EE_Payment && $payment->ID() ) { |
|
417 | - if( |
|
416 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
417 | + if ( |
|
418 | 418 | $payment->payment_method() instanceof EE_Payment_Method |
419 | 419 | && $payment->payment_method()->type_obj() instanceof EE_PMT_Base |
420 | - ){ |
|
421 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment ); |
|
420 | + ) { |
|
421 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
422 | 422 | // update TXN registrations with payment info |
423 | - $this->process_registration_payments( $transaction, $payment ); |
|
423 | + $this->process_registration_payments($transaction, $payment); |
|
424 | 424 | } |
425 | 425 | $do_action = $payment->just_approved() |
426 | 426 | ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' |
427 | 427 | : $do_action; |
428 | 428 | } else { |
429 | 429 | // send out notifications |
430 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
430 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
431 | 431 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
432 | 432 | } |
433 | - if ( $payment->status() !== EEM_Payment::status_id_failed ) { |
|
433 | + if ($payment->status() !== EEM_Payment::status_id_failed) { |
|
434 | 434 | /** @type EE_Transaction_Payments $transaction_payments */ |
435 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
435 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
436 | 436 | // set new value for total paid |
437 | - $transaction_payments->calculate_total_payments_and_update_status( $transaction ); |
|
437 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
438 | 438 | // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
439 | - if ( $update_txn ) { |
|
440 | - $this->_post_payment_processing( $transaction, $payment, $IPN ); |
|
439 | + if ($update_txn) { |
|
440 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | // granular hook for others to use. |
444 | - do_action( $do_action, $transaction, $payment ); |
|
445 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' ); |
|
444 | + do_action($do_action, $transaction, $payment); |
|
445 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
446 | 446 | //global hook for others to use. |
447 | - do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment ); |
|
447 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
@@ -464,25 +464,25 @@ discard block |
||
464 | 464 | $registrations = array() |
465 | 465 | ) { |
466 | 466 | // only process if payment was successful |
467 | - if ( $payment->status() !== EEM_Payment::status_id_approved ) { |
|
467 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
468 | 468 | return; |
469 | 469 | } |
470 | 470 | //EEM_Registration::instance()->show_next_x_db_queries(); |
471 | - if ( empty( $registrations )) { |
|
471 | + if (empty($registrations)) { |
|
472 | 472 | // find registrations with monies owing that can receive a payment |
473 | 473 | $registrations = $transaction->registrations( |
474 | 474 | array( |
475 | 475 | array( |
476 | 476 | // only these reg statuses can receive payments |
477 | - 'STS_ID' => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ), |
|
478 | - 'REG_final_price' => array( '!=', 0 ), |
|
479 | - 'REG_final_price*' => array( '!=', 'REG_paid', true ), |
|
477 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
478 | + 'REG_final_price' => array('!=', 0), |
|
479 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
480 | 480 | ) |
481 | 481 | ) |
482 | 482 | ); |
483 | 483 | } |
484 | 484 | // still nothing ??!?? |
485 | - if ( empty( $registrations )) { |
|
485 | + if (empty($registrations)) { |
|
486 | 486 | return; |
487 | 487 | } |
488 | 488 | // todo: break out the following logic into a separate strategy class |
@@ -494,28 +494,28 @@ discard block |
||
494 | 494 | |
495 | 495 | $refund = $payment->is_a_refund(); |
496 | 496 | // how much is available to apply to registrations? |
497 | - $available_payment_amount = abs( $payment->amount() ); |
|
498 | - foreach ( $registrations as $registration ) { |
|
499 | - if ( $registration instanceof EE_Registration ) { |
|
497 | + $available_payment_amount = abs($payment->amount()); |
|
498 | + foreach ($registrations as $registration) { |
|
499 | + if ($registration instanceof EE_Registration) { |
|
500 | 500 | // nothing left? |
501 | - if ( $available_payment_amount <= 0 ) { |
|
501 | + if ($available_payment_amount <= 0) { |
|
502 | 502 | break; |
503 | 503 | } |
504 | - if ( $refund ) { |
|
505 | - $available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount ); |
|
504 | + if ($refund) { |
|
505 | + $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount); |
|
506 | 506 | } else { |
507 | - $available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount ); |
|
507 | + $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount); |
|
508 | 508 | } |
509 | 509 | } |
510 | 510 | } |
511 | - if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) { |
|
511 | + if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) { |
|
512 | 512 | EE_Error::add_attention( |
513 | 513 | sprintf( |
514 | - __( '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).', 'event_espresso' ), |
|
515 | - EEH_Template::format_currency( $available_payment_amount ), |
|
516 | - implode( ', ', array_keys( $registrations ) ), |
|
514 | + __('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).', 'event_espresso'), |
|
515 | + EEH_Template::format_currency($available_payment_amount), |
|
516 | + implode(', ', array_keys($registrations)), |
|
517 | 517 | '<br/>', |
518 | - EEH_Template::format_currency( $payment->amount() ) |
|
518 | + EEH_Template::format_currency($payment->amount()) |
|
519 | 519 | ), |
520 | 520 | __FILE__, __FUNCTION__, __LINE__ |
521 | 521 | ); |
@@ -533,17 +533,17 @@ discard block |
||
533 | 533 | * @return float |
534 | 534 | * @throws \EE_Error |
535 | 535 | */ |
536 | - public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) { |
|
536 | + public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) { |
|
537 | 537 | $owing = $registration->final_price() - $registration->paid(); |
538 | - if ( $owing > 0 ) { |
|
538 | + if ($owing > 0) { |
|
539 | 539 | // don't allow payment amount to exceed the available payment amount, OR the amount owing |
540 | - $payment_amount = min( $available_payment_amount, $owing ); |
|
540 | + $payment_amount = min($available_payment_amount, $owing); |
|
541 | 541 | // update $available_payment_amount |
542 | 542 | $available_payment_amount -= $payment_amount; |
543 | 543 | //calculate and set new REG_paid |
544 | - $registration->set_paid( $registration->paid() + $payment_amount ); |
|
544 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
545 | 545 | // now save it |
546 | - $this->_apply_registration_payment( $registration, $payment, $payment_amount ); |
|
546 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
547 | 547 | } |
548 | 548 | return $available_payment_amount; |
549 | 549 | } |
@@ -559,19 +559,19 @@ discard block |
||
559 | 559 | * @return void |
560 | 560 | * @throws \EE_Error |
561 | 561 | */ |
562 | - protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) { |
|
562 | + protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) { |
|
563 | 563 | // find any existing reg payment records for this registration and payment |
564 | 564 | $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
565 | - array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) ) |
|
565 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
566 | 566 | ); |
567 | 567 | // if existing registration payment exists |
568 | - if ( $existing_reg_payment instanceof EE_Registration_Payment ) { |
|
568 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
569 | 569 | // then update that record |
570 | - $existing_reg_payment->set_amount( $payment_amount ); |
|
570 | + $existing_reg_payment->set_amount($payment_amount); |
|
571 | 571 | $existing_reg_payment->save(); |
572 | 572 | } else { |
573 | 573 | // or add new relation between registration and payment and set amount |
574 | - $registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) ); |
|
574 | + $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount)); |
|
575 | 575 | // make it stick |
576 | 576 | $registration->save(); |
577 | 577 | } |
@@ -588,21 +588,21 @@ discard block |
||
588 | 588 | * @return float |
589 | 589 | * @throws \EE_Error |
590 | 590 | */ |
591 | - public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) { |
|
591 | + public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) { |
|
592 | 592 | //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
593 | - if ( $registration->paid() > 0 ) { |
|
593 | + if ($registration->paid() > 0) { |
|
594 | 594 | // ensure $available_refund_amount is NOT negative |
595 | - $available_refund_amount = (float)abs( $available_refund_amount ); |
|
595 | + $available_refund_amount = (float) abs($available_refund_amount); |
|
596 | 596 | // don't allow refund amount to exceed the available payment amount, OR the amount paid |
597 | - $refund_amount = min( $available_refund_amount, (float)$registration->paid() ); |
|
597 | + $refund_amount = min($available_refund_amount, (float) $registration->paid()); |
|
598 | 598 | // update $available_payment_amount |
599 | 599 | $available_refund_amount -= $refund_amount; |
600 | 600 | //calculate and set new REG_paid |
601 | - $registration->set_paid( $registration->paid() - $refund_amount ); |
|
601 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
602 | 602 | // convert payment amount back to a negative value for storage in the db |
603 | - $refund_amount = (float)abs( $refund_amount ) * -1; |
|
603 | + $refund_amount = (float) abs($refund_amount) * -1; |
|
604 | 604 | // now save it |
605 | - $this->_apply_registration_payment( $registration, $payment, $refund_amount ); |
|
605 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
606 | 606 | } |
607 | 607 | return $available_refund_amount; |
608 | 608 | } |
@@ -621,53 +621,53 @@ discard block |
||
621 | 621 | * @param bool $IPN |
622 | 622 | * @throws \EE_Error |
623 | 623 | */ |
624 | - protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) { |
|
624 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) { |
|
625 | 625 | |
626 | 626 | /** @type EE_Transaction_Processor $transaction_processor */ |
627 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
627 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
628 | 628 | // is the Payment Options Reg Step completed ? |
629 | - $payment_options_step_completed = $transaction->reg_step_completed( 'payment_options' ); |
|
629 | + $payment_options_step_completed = $transaction->reg_step_completed('payment_options'); |
|
630 | 630 | // if the Payment Options Reg Step is completed... |
631 | 631 | $revisit = $payment_options_step_completed === true ? true : false; |
632 | 632 | // then this is kinda sorta a revisit with regards to payments at least |
633 | - $transaction_processor->set_revisit( $revisit ); |
|
633 | + $transaction_processor->set_revisit($revisit); |
|
634 | 634 | // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
635 | 635 | if ( |
636 | 636 | $IPN && |
637 | 637 | $payment_options_step_completed !== true && |
638 | - ( $payment->is_approved() || $payment->is_pending() ) |
|
638 | + ($payment->is_approved() || $payment->is_pending()) |
|
639 | 639 | ) { |
640 | 640 | $payment_options_step_completed = $transaction->set_reg_step_completed( |
641 | 641 | 'payment_options' |
642 | 642 | ); |
643 | 643 | } |
644 | 644 | // maybe update status, but don't save transaction just yet |
645 | - $transaction->update_status_based_on_total_paid( false ); |
|
645 | + $transaction->update_status_based_on_total_paid(false); |
|
646 | 646 | // check if 'finalize_registration' step has been completed... |
647 | - $finalized = $transaction->reg_step_completed( 'finalize_registration' ); |
|
647 | + $finalized = $transaction->reg_step_completed('finalize_registration'); |
|
648 | 648 | // if this is an IPN and the final step has not been initiated |
649 | - if ( $IPN && $payment_options_step_completed && $finalized === false ) { |
|
649 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
650 | 650 | // and if it hasn't already been set as being started... |
651 | - $finalized = $transaction->set_reg_step_initiated( 'finalize_registration' ); |
|
651 | + $finalized = $transaction->set_reg_step_initiated('finalize_registration'); |
|
652 | 652 | } |
653 | 653 | $transaction->save(); |
654 | 654 | // because the above will return false if the final step was not fully completed, we need to check again... |
655 | - if ( $IPN && $finalized !== false ) { |
|
655 | + if ($IPN && $finalized !== false) { |
|
656 | 656 | // and if we are all good to go, then send out notifications |
657 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
657 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
658 | 658 | //ok, now process the transaction according to the payment |
659 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment ); |
|
659 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment); |
|
660 | 660 | } |
661 | 661 | // DEBUG LOG |
662 | 662 | $payment_method = $payment->payment_method(); |
663 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
663 | + if ($payment_method instanceof EE_Payment_Method) { |
|
664 | 664 | $payment_method_type_obj = $payment_method->type_obj(); |
665 | - if ( $payment_method_type_obj instanceof EE_PMT_Base ) { |
|
665 | + if ($payment_method_type_obj instanceof EE_PMT_Base) { |
|
666 | 666 | $gateway = $payment_method_type_obj->get_gateway(); |
667 | - if ( $gateway instanceof EE_Gateway ){ |
|
667 | + if ($gateway instanceof EE_Gateway) { |
|
668 | 668 | $gateway->log( |
669 | 669 | array( |
670 | - 'message' => __( 'Post Payment Transaction Details', 'event_espresso' ), |
|
670 | + 'message' => __('Post Payment Transaction Details', 'event_espresso'), |
|
671 | 671 | 'transaction' => $transaction->model_field_array(), |
672 | 672 | 'finalized' => $finalized, |
673 | 673 | 'IPN' => $IPN, |
@@ -689,11 +689,11 @@ discard block |
||
689 | 689 | * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US |
690 | 690 | * This will affect paypal standard, pro, express, and payflow. |
691 | 691 | */ |
692 | - public static function _curl_requests_to_paypal_use_tls( $handle, $r, $url ) { |
|
693 | - if ( strstr( $url, 'https://' ) && strstr( $url, '.paypal.com' ) ) { |
|
692 | + public static function _curl_requests_to_paypal_use_tls($handle, $r, $url) { |
|
693 | + if (strstr($url, 'https://') && strstr($url, '.paypal.com')) { |
|
694 | 694 | //Use the value of the constant CURL_SSLVERSION_TLSv1 = 1 |
695 | 695 | //instead of the constant because it might not be defined |
696 | - curl_setopt( $handle, CURLOPT_SSLVERSION, 1 ); |
|
696 | + curl_setopt($handle, CURLOPT_SSLVERSION, 1); |
|
697 | 697 | } |
698 | 698 | } |
699 | 699 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <div class="padding"> |
2 | - <p><?php _e( 'We need your help to continue maintaining and providing this plugin for free. You can help by leaving a positive review in the WordPress plugin directory. 5 star ratings bring Event Espresso Decaf to the attention of more users which increases our support and features for this version of Event Espresso.', 'event_espresso' ); ?></p> |
|
3 | - <p><?php _e( 'Rate it five stars today!', 'event_espresso' ); ?></p><span class="ee-wp-blue dashicons dashicons-star-filled"></span><span class="ee-wp-blue dashicons dashicons-star-filled"></span><span class="ee-wp-blue dashicons dashicons-star-filled"></span><span class="ee-wp-blue dashicons dashicons-star-filled"></span><span class="ee-wp-blue dashicons dashicons-star-filled"></span> |
|
4 | - <p><a class="button button-primary" href="https://events.codebasehq.com/redirect?https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Fview%2Fplugin-reviews%2Fevent-espresso-decaf%3Frate%3D5%23postform"><?php _e( 'Rate It!', 'event_espresso' ); ?></a></p> |
|
2 | + <p><?php _e('We need your help to continue maintaining and providing this plugin for free. You can help by leaving a positive review in the WordPress plugin directory. 5 star ratings bring Event Espresso Decaf to the attention of more users which increases our support and features for this version of Event Espresso.', 'event_espresso'); ?></p> |
|
3 | + <p><?php _e('Rate it five stars today!', 'event_espresso'); ?></p><span class="ee-wp-blue dashicons dashicons-star-filled"></span><span class="ee-wp-blue dashicons dashicons-star-filled"></span><span class="ee-wp-blue dashicons dashicons-star-filled"></span><span class="ee-wp-blue dashicons dashicons-star-filled"></span><span class="ee-wp-blue dashicons dashicons-star-filled"></span> |
|
4 | + <p><a class="button button-primary" href="https://events.codebasehq.com/redirect?https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Fview%2Fplugin-reviews%2Fevent-espresso-decaf%3Frate%3D5%23postform"><?php _e('Rate It!', 'event_espresso'); ?></a></p> |
|
5 | 5 | </div> |
6 | 6 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * |
11 | 11 | */ |
12 | 12 | |
13 | -class EE_Admin_Table_Registration_Line_Item_Display_Strategy extends EE_Admin_Table_Line_Item_Display_Strategy { |
|
13 | +class EE_Admin_Table_Registration_Line_Item_Display_Strategy extends EE_Admin_Table_Line_Item_Display_Strategy { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Table header for display. |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | * @param array $options |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - protected function _table_header( $options ) { |
|
22 | - $html = EEH_HTML::table( '','', $options['table_css_class'] ); |
|
21 | + protected function _table_header($options) { |
|
22 | + $html = EEH_HTML::table('', '', $options['table_css_class']); |
|
23 | 23 | $html .= EEH_HTML::thead(); |
24 | 24 | $html .= EEH_HTML::tr(); |
25 | - $html .= EEH_HTML::th( __( 'Name', 'event_espresso' ), '', 'jst-left' ); |
|
26 | - $html .= EEH_HTML::th( __( 'Type', 'event_espresso'), '', 'jst-left' ); |
|
27 | - $html .= EEH_HTML::th( __( 'Date(s)', 'event_espresso' ), '', 'jst-left' ); |
|
28 | - $html .= EEH_HTML::th( __( 'Amount', 'event_espresso' ), '', 'jst-cntr' ); |
|
25 | + $html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left'); |
|
26 | + $html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left'); |
|
27 | + $html .= EEH_HTML::th(__('Date(s)', 'event_espresso'), '', 'jst-left'); |
|
28 | + $html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr'); |
|
29 | 29 | $html .= EEH_HTML::tbody(); |
30 | 30 | return $html; |
31 | 31 | } |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | * @param array $options |
42 | 42 | * @return mixed |
43 | 43 | */ |
44 | - protected function _item_row( EE_Line_Item $line_item, $options = array() ) { |
|
44 | + protected function _item_row(EE_Line_Item $line_item, $options = array()) { |
|
45 | 45 | $line_item_related_object = $line_item->get_object(); |
46 | 46 | $parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item |
47 | 47 | ? $line_item->parent()->get_object() |
48 | 48 | : null; |
49 | 49 | // start of row |
50 | 50 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
51 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
51 | + $html = EEH_HTML::tr('', '', $row_class); |
|
52 | 52 | |
53 | 53 | |
54 | 54 | //Name Column |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object |
59 | 59 | ? $parent_line_item_related_object->name() |
60 | 60 | : ''; |
61 | - $parent_related_object_name = empty( $parent_related_object_name ) && $line_item->parent() instanceof EE_Line_Item |
|
61 | + $parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item |
|
62 | 62 | ? $line_item->parent()->name() |
63 | 63 | : $parent_related_object_name; |
64 | 64 | $parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links |
@@ -68,51 +68,51 @@ discard block |
||
68 | 68 | |
69 | 69 | $name_html = $line_item_related_object instanceof EEI_Line_Item_Object |
70 | 70 | ? $line_item_related_object->name() : $line_item->name(); |
71 | - $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' |
|
71 | + $name_html = $name_link ? '<a href="'.$name_link.'">'.$name_html.'</a>' |
|
72 | 72 | : $name_html; |
73 | 73 | $name_html .= $line_item->is_taxable() ? ' *' : ''; |
74 | 74 | //maybe preface with icon? |
75 | 75 | $name_html = $line_item_related_object instanceof EEI_Has_Icon |
76 | - ? $line_item_related_object->get_icon() . $name_html |
|
76 | + ? $line_item_related_object->get_icon().$name_html |
|
77 | 77 | : $name_html; |
78 | - $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>'; |
|
79 | - $name_html .= sprintf( |
|
80 | - _x( '%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
78 | + $name_html = '<span class="ee-line-item-name linked">'.$name_html.'</span><br>'; |
|
79 | + $name_html .= sprintf( |
|
80 | + _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
81 | 81 | '<span class="ee-line-item-related-parent-object">', |
82 | 82 | $line_item->parent() instanceof EE_Line_Item |
83 | 83 | ? $line_item->parent()->OBJ_type_i18n() |
84 | - : __( 'Item:', 'event_espresso' ), |
|
84 | + : __('Item:', 'event_espresso'), |
|
85 | 85 | $parent_related_object_link |
86 | - ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' |
|
86 | + ? '<a href="'.$parent_related_object_link.'">'.$parent_related_object_name.'</a>' |
|
87 | 87 | : $parent_related_object_name, |
88 | 88 | '</span>' |
89 | 89 | ); |
90 | - $html .= EEH_HTML::td( $name_html, '', 'jst-left' ); |
|
90 | + $html .= EEH_HTML::td($name_html, '', 'jst-left'); |
|
91 | 91 | //Type Column |
92 | 92 | $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : ''; |
93 | - $type_html .= $this->_get_cancellations( $line_item ); |
|
93 | + $type_html .= $this->_get_cancellations($line_item); |
|
94 | 94 | $type_html .= $line_item->OBJ_type() ? '<br />' : ''; |
95 | 95 | $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : ''; |
96 | - $type_html .= ! empty( $code ) ? '<span class="ee-line-item-id">' . sprintf( __( 'Code: %s', 'event_espresso' ), $code ) . '</span>' : ''; |
|
97 | - $html .= EEH_HTML::td( $type_html, '', 'jst-left' ); |
|
96 | + $type_html .= ! empty($code) ? '<span class="ee-line-item-id">'.sprintf(__('Code: %s', 'event_espresso'), $code).'</span>' : ''; |
|
97 | + $html .= EEH_HTML::td($type_html, '', 'jst-left'); |
|
98 | 98 | |
99 | 99 | //Date column |
100 | 100 | $datetime_content = ''; |
101 | - if ( $line_item_related_object instanceof EE_Ticket ) { |
|
101 | + if ($line_item_related_object instanceof EE_Ticket) { |
|
102 | 102 | $datetimes = $line_item_related_object->datetimes(); |
103 | - foreach ( $datetimes as $datetime ) { |
|
104 | - if ( $datetime instanceof EE_Datetime ) { |
|
105 | - $datetime_content .= $datetime->get_dtt_display_name() . '<br>'; |
|
103 | + foreach ($datetimes as $datetime) { |
|
104 | + if ($datetime instanceof EE_Datetime) { |
|
105 | + $datetime_content .= $datetime->get_dtt_display_name().'<br>'; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
109 | - $html .= EEH_HTML::td( $datetime_content, '', 'jst-left' ); |
|
109 | + $html .= EEH_HTML::td($datetime_content, '', 'jst-left'); |
|
110 | 110 | |
111 | 111 | //Amount Column |
112 | - if ( $line_item->is_percent() ) { |
|
113 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'jst-rght' ); |
|
112 | + if ($line_item->is_percent()) { |
|
113 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'jst-rght'); |
|
114 | 114 | } else { |
115 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'jst-rght' ); |
|
115 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght'); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | * @param array $options |
131 | 131 | * @return mixed |
132 | 132 | */ |
133 | - protected function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
|
133 | + protected function _tax_row(EE_Line_Item $line_item, $options = array()) { |
|
134 | 134 | // start of row |
135 | - $html = EEH_HTML::tr( '', 'admin-primary-mbox-taxes-tr' ); |
|
135 | + $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr'); |
|
136 | 136 | // name th |
137 | - $html .= EEH_HTML::th( $line_item->name() . '(' . $line_item->get_pretty( 'LIN_percent' ) . '%)', '', 'jst-rght', '', ' colspan="3"' ); |
|
137 | + $html .= EEH_HTML::th($line_item->name().'('.$line_item->get_pretty('LIN_percent').'%)', '', 'jst-rght', '', ' colspan="3"'); |
|
138 | 138 | // total th |
139 | - $html .= EEH_HTML::th( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'jst-rght' ); |
|
139 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
140 | 140 | // end of row |
141 | 141 | $html .= EEH_HTML::trx(); |
142 | 142 | return $html; |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | * @param array $options |
154 | 154 | * @return mixed |
155 | 155 | */ |
156 | - protected function _total_row( EE_Line_Item $line_item, $options = array() ) { |
|
156 | + protected function _total_row(EE_Line_Item $line_item, $options = array()) { |
|
157 | 157 | |
158 | - $registration = isset( $options['EE_Registration'] ) ? $options['EE_Registration'] : null; |
|
158 | + $registration = isset($options['EE_Registration']) ? $options['EE_Registration'] : null; |
|
159 | 159 | $registration_total = $registration instanceof EE_Registration ? $registration->pretty_final_price() : 0; |
160 | 160 | //if no valid registration object then we're not going to show the approximate text. |
161 | 161 | $total_match = $registration instanceof EE_Registration |
@@ -163,26 +163,26 @@ discard block |
||
163 | 163 | : true; |
164 | 164 | |
165 | 165 | // start of row |
166 | - $html = EEH_HTML::tr( '', '', 'admin-primary-mbox-total-tr' ); |
|
166 | + $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr'); |
|
167 | 167 | // Total th label |
168 | - if ( $total_match ) { |
|
169 | - $total_label = sprintf( __( 'This registration\'s total %s:', 'event_espresso' ), '(' . EE_Registry::instance()->CFG->currency->code . ')' ); |
|
168 | + if ($total_match) { |
|
169 | + $total_label = sprintf(__('This registration\'s total %s:', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); |
|
170 | 170 | } else { |
171 | - $total_label = sprintf( __( 'This registration\'s approximate total %s', 'event_espresso' ), '(' . EE_Registry::instance()->CFG->currency->code . ')' ); |
|
171 | + $total_label = sprintf(__('This registration\'s approximate total %s', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); |
|
172 | 172 | $total_label .= '<br>'; |
173 | 173 | $total_label .= '<p class="ee-footnote-text">' |
174 | 174 | . sprintf( |
175 | - __( 'The registrations\' share of the transaction total is approximate because it might not be possible to evenly divide the transaction total among each registration, and so some registrations may need to pay a penny more than others. This registration\'s final share is actually %1$s%2$s%3$s.', 'event_espresso' ), |
|
175 | + __('The registrations\' share of the transaction total is approximate because it might not be possible to evenly divide the transaction total among each registration, and so some registrations may need to pay a penny more than others. This registration\'s final share is actually %1$s%2$s%3$s.', 'event_espresso'), |
|
176 | 176 | '<strong>', |
177 | 177 | $registration_total, |
178 | 178 | '</strong>' |
179 | 179 | ) |
180 | 180 | . '</p>'; |
181 | 181 | } |
182 | - $html .= EEH_HTML::th( $total_label, '', 'jst-rght', '', ' colspan="3"' ); |
|
182 | + $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="3"'); |
|
183 | 183 | // total th |
184 | 184 | |
185 | - $html .= EEH_HTML::th( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'jst-rght' ); |
|
185 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
186 | 186 | // end of row |
187 | 187 | $html .= EEH_HTML::trx(); |
188 | 188 | return $html; |