@@ -453,18 +453,18 @@ |
||
453 | 453 | //} else { |
454 | 454 | // $current_tax_amount = 0; |
455 | 455 | //} |
456 | - //always add paypal's taxes |
|
456 | + //always add paypal's taxes |
|
457 | 457 | if( $this->_paypal_taxes ){ |
458 | - //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable |
|
459 | - $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' ); |
|
460 | - $this->_line_item->set_total_tax_to( |
|
461 | - $transaction->total_line_item(), |
|
462 | - floatval( $update_info['tax'] ), |
|
463 | - __( 'Taxes', 'event_espresso' ), |
|
464 | - __( 'Calculated by Paypal', 'event_espresso' ), |
|
465 | - 'paypal_tax' |
|
466 | - ); |
|
467 | - $grand_total_needs_resaving = TRUE; |
|
458 | + //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable |
|
459 | + $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' ); |
|
460 | + $this->_line_item->set_total_tax_to( |
|
461 | + $transaction->total_line_item(), |
|
462 | + floatval( $update_info['tax'] ), |
|
463 | + __( 'Taxes', 'event_espresso' ), |
|
464 | + __( 'Calculated by Paypal', 'event_espresso' ), |
|
465 | + 'paypal_tax' |
|
466 | + ); |
|
467 | + $grand_total_needs_resaving = TRUE; |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | $shipping_amount = floatval( $update_info[ 'mc_shipping' ] ); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return EEG_Paypal_Standard |
64 | 64 | */ |
65 | 65 | public function __construct() { |
66 | - $this->set_uses_separate_IPN_request( true ) ; |
|
66 | + $this->set_uses_separate_IPN_request(true); |
|
67 | 67 | parent::__construct(); |
68 | 68 | } |
69 | 69 | |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | * Also sets the gateway url class variable based on whether debug mode is enabled or not |
74 | 74 | * @param array $settings_array |
75 | 75 | */ |
76 | - public function set_settings($settings_array){ |
|
76 | + public function set_settings($settings_array) { |
|
77 | 77 | parent::set_settings($settings_array); |
78 | - if($this->_debug_mode){ |
|
78 | + if ($this->_debug_mode) { |
|
79 | 79 | $this->_gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; |
80 | - }else{ |
|
80 | + } else { |
|
81 | 81 | $this->_gateway_url = 'https://www.paypal.com/cgi-bin/webscr'; |
82 | 82 | } |
83 | 83 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param string $cancel_url URL to send the user to after a cancelled payment attempt on teh payment provider's website |
93 | 93 | * @return EEI_Payment |
94 | 94 | */ |
95 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ){ |
|
95 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
96 | 96 | $redirect_args = array(); |
97 | 97 | $transaction = $payment->transaction(); |
98 | 98 | $primary_registrant = $transaction->primary_registration(); |
@@ -102,87 +102,87 @@ discard block |
||
102 | 102 | |
103 | 103 | $total_discounts_to_cart_total = $transaction->paid(); |
104 | 104 | //only itemize the order if we're paying for the rest of the order's amount |
105 | - if( $payment->amount() == $transaction->total() ) { |
|
105 | + if ($payment->amount() == $transaction->total()) { |
|
106 | 106 | //this payment is for the remaining transaction amount, |
107 | 107 | //keep track of exactly how much the itemized order amount equals |
108 | 108 | $itemized_sum = 0; |
109 | 109 | $shipping_previously_added = 0; |
110 | 110 | //so let's show all the line items |
111 | - foreach($total_line_item->get_items() as $line_item){ |
|
112 | - if ( $line_item instanceof EE_Line_Item ) { |
|
111 | + foreach ($total_line_item->get_items() as $line_item) { |
|
112 | + if ($line_item instanceof EE_Line_Item) { |
|
113 | 113 | //it's some kind of discount |
114 | - if( $line_item->total() < 0 ) { |
|
115 | - $total_discounts_to_cart_total += abs( $line_item->total() ); |
|
114 | + if ($line_item->total() < 0) { |
|
115 | + $total_discounts_to_cart_total += abs($line_item->total()); |
|
116 | 116 | $itemized_sum += $line_item->total(); |
117 | 117 | continue; |
118 | 118 | } |
119 | 119 | //dont include shipping again. |
120 | - if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) { |
|
120 | + if (strpos($line_item->code(), 'paypal_shipping_') === 0) { |
|
121 | 121 | $shipping_previously_added = $line_item->total(); |
122 | 122 | continue; |
123 | 123 | } |
124 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
125 | - sprintf( _x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ), $line_item->name(), $line_item->ticket_event_name() ), |
|
124 | + $redirect_args['item_name_'.$item_num] = substr( |
|
125 | + sprintf(_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), $line_item->name(), $line_item->ticket_event_name()), |
|
126 | 126 | 0, 127 |
127 | 127 | ); |
128 | - $redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price(); |
|
129 | - $redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity(); |
|
128 | + $redirect_args['amount_'.$item_num] = $line_item->unit_price(); |
|
129 | + $redirect_args['quantity_'.$item_num] = $line_item->quantity(); |
|
130 | 130 | //if we're not letting PayPal calculate shipping, tell them its 0 |
131 | - if ( ! $this->_paypal_shipping ) { |
|
132 | - $redirect_args[ 'shipping_' . $item_num ] = '0'; |
|
133 | - $redirect_args[ 'shipping2_' . $item_num ] = '0'; |
|
131 | + if ( ! $this->_paypal_shipping) { |
|
132 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
133 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
134 | 134 | } |
135 | 135 | $item_num++; |
136 | 136 | $itemized_sum += $line_item->total(); |
137 | 137 | } |
138 | 138 | } |
139 | - $taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item ); |
|
139 | + $taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item); |
|
140 | 140 | //ideally itemized sum equals the transaction total. but if not (which is weird) |
141 | 141 | //and the itemized sum is LESS than the transaction total |
142 | 142 | //add another line item |
143 | 143 | //if the itemized sum is MORE than the transaction total, |
144 | 144 | //add the difference it to the discounts |
145 | 145 | $itemized_sum_diff_from_txn_total = $transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added; |
146 | - if( $itemized_sum_diff_from_txn_total < 0 ) { |
|
146 | + if ($itemized_sum_diff_from_txn_total < 0) { |
|
147 | 147 | //itemized sum is too big |
148 | - $total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total ); |
|
149 | - } elseif( $itemized_sum_diff_from_txn_total > 0 ) { |
|
150 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
151 | - __( 'Other charges', 'event_espresso' ), 0, 127 ); |
|
152 | - $redirect_args[ 'amount_' . $item_num ] = $itemized_sum_diff_from_txn_total; |
|
153 | - $redirect_args[ 'quantity_' . $item_num ] = 1; |
|
148 | + $total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total); |
|
149 | + } elseif ($itemized_sum_diff_from_txn_total > 0) { |
|
150 | + $redirect_args['item_name_'.$item_num] = substr( |
|
151 | + __('Other charges', 'event_espresso'), 0, 127 ); |
|
152 | + $redirect_args['amount_'.$item_num] = $itemized_sum_diff_from_txn_total; |
|
153 | + $redirect_args['quantity_'.$item_num] = 1; |
|
154 | 154 | $item_num++; |
155 | 155 | } |
156 | - if( $total_discounts_to_cart_total > 0 ) { |
|
157 | - $redirect_args[ 'discount_amount_cart' ] = $total_discounts_to_cart_total; |
|
156 | + if ($total_discounts_to_cart_total > 0) { |
|
157 | + $redirect_args['discount_amount_cart'] = $total_discounts_to_cart_total; |
|
158 | 158 | } |
159 | 159 | //add our taxes to the order if we're NOT using PayPal's |
160 | - if( ! $this->_paypal_taxes ){ |
|
160 | + if ( ! $this->_paypal_taxes) { |
|
161 | 161 | $redirect_args['tax_cart'] = $total_line_item->get_total_tax(); |
162 | 162 | } |
163 | 163 | } else { |
164 | 164 | //partial payment that's not for the remaining amount, so we can't send an itemized list |
165 | - $redirect_args['item_name_' . $item_num] = substr( |
|
166 | - sprintf( __('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code() ), |
|
165 | + $redirect_args['item_name_'.$item_num] = substr( |
|
166 | + sprintf(__('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code()), |
|
167 | 167 | 0, 127 |
168 | 168 | ); |
169 | - $redirect_args['amount_' . $item_num] = $payment->amount(); |
|
170 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
171 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
169 | + $redirect_args['amount_'.$item_num] = $payment->amount(); |
|
170 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
171 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
172 | 172 | $redirect_args['tax_cart'] = '0'; |
173 | 173 | $item_num++; |
174 | 174 | } |
175 | 175 | |
176 | - if($this->_debug_mode){ |
|
177 | - $redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
178 | - $redirect_args['amount_' . $item_num] = 0; |
|
176 | + if ($this->_debug_mode) { |
|
177 | + $redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
178 | + $redirect_args['amount_'.$item_num] = 0; |
|
179 | 179 | $redirect_args['on0_'.$item_num] = 'NOTIFY URL'; |
180 | - $redirect_args['os0_' . $item_num] = $notify_url; |
|
180 | + $redirect_args['os0_'.$item_num] = $notify_url; |
|
181 | 181 | $redirect_args['on1_'.$item_num] = 'RETURN URL'; |
182 | - $redirect_args['os1_' . $item_num] = $return_url; |
|
182 | + $redirect_args['os1_'.$item_num] = $return_url; |
|
183 | 183 | // $redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ? |
184 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
185 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
184 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
185 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | $redirect_args['business'] = $this->_paypal_id; |
@@ -192,14 +192,14 @@ discard block |
||
192 | 192 | $redirect_args['cmd'] = '_cart'; |
193 | 193 | $redirect_args['upload'] = 1; |
194 | 194 | $redirect_args['currency_code'] = $payment->currency_code(); |
195 | - $redirect_args['rm'] = 2;//makes the user return with method=POST |
|
196 | - if($this->_image_url){ |
|
195 | + $redirect_args['rm'] = 2; //makes the user return with method=POST |
|
196 | + if ($this->_image_url) { |
|
197 | 197 | $redirect_args['image_url'] = $this->_image_url; |
198 | 198 | } |
199 | 199 | $redirect_args['no_shipping'] = $this->_shipping_details; |
200 | - $redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this |
|
200 | + $redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this |
|
201 | 201 | |
202 | - $redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this ); |
|
202 | + $redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this); |
|
203 | 203 | |
204 | 204 | $payment->set_redirect_url($this->_gateway_url); |
205 | 205 | $payment->set_redirect_args($redirect_args); |
@@ -220,55 +220,55 @@ discard block |
||
220 | 220 | * @return \EEI_Payment updated |
221 | 221 | * @throws \EE_Error |
222 | 222 | */ |
223 | - public function handle_payment_update( $update_info, $transaction ){ |
|
223 | + public function handle_payment_update($update_info, $transaction) { |
|
224 | 224 | //verify there's payment data that's been sent |
225 | - if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) { |
|
225 | + if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) { |
|
226 | 226 | // waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/) |
227 | 227 | // indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes |
228 | - if ( isset( $update_info[ 'tx' ] ) ) { |
|
228 | + if (isset($update_info['tx'])) { |
|
229 | 229 | return $transaction->last_payment(); |
230 | 230 | } else { |
231 | 231 | return null; |
232 | 232 | } |
233 | 233 | } |
234 | - $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
235 | - if ( ! $payment instanceof EEI_Payment ) { |
|
234 | + $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']); |
|
235 | + if ( ! $payment instanceof EEI_Payment) { |
|
236 | 236 | $payment = $transaction->last_payment(); |
237 | 237 | } |
238 | 238 | // ok, then validate the IPN. Even if we've already processed this payment, |
239 | 239 | // let PayPal know we don't want to hear from them anymore! |
240 | - if ( ! $this->validate_ipn( $update_info, $payment ) ) { |
|
240 | + if ( ! $this->validate_ipn($update_info, $payment)) { |
|
241 | 241 | return $payment; |
242 | 242 | } |
243 | 243 | //ok, well let's process this payment then! |
244 | - switch ( $update_info[ 'payment_status' ] ) { |
|
244 | + switch ($update_info['payment_status']) { |
|
245 | 245 | |
246 | 246 | case 'Completed' : |
247 | 247 | $status = $this->_pay_model->approved_status(); |
248 | - $gateway_response = __( 'The payment is approved.', 'event_espresso' ); |
|
248 | + $gateway_response = __('The payment is approved.', 'event_espresso'); |
|
249 | 249 | break; |
250 | 250 | |
251 | 251 | case 'Pending' : |
252 | 252 | $status = $this->_pay_model->pending_status(); |
253 | - $gateway_response = __( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' ); |
|
253 | + $gateway_response = __('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso'); |
|
254 | 254 | break; |
255 | 255 | |
256 | 256 | case 'Denied' : |
257 | 257 | $status = $this->_pay_model->declined_status(); |
258 | - $gateway_response = __( 'The payment has been declined.', 'event_espresso' ); |
|
258 | + $gateway_response = __('The payment has been declined.', 'event_espresso'); |
|
259 | 259 | break; |
260 | 260 | |
261 | 261 | case 'Expired' : |
262 | 262 | case 'Failed' : |
263 | 263 | $status = $this->_pay_model->failed_status(); |
264 | - $gateway_response = __( 'The payment failed for technical reasons or expired.', 'event_espresso' ); |
|
264 | + $gateway_response = __('The payment failed for technical reasons or expired.', 'event_espresso'); |
|
265 | 265 | break; |
266 | 266 | |
267 | 267 | case 'Refunded' : |
268 | 268 | case 'Partially_Refunded' : |
269 | 269 | // even though it's a refund, we consider the payment as approved, it just has a negative value |
270 | 270 | $status = $this->_pay_model->approved_status(); |
271 | - $gateway_response = __( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' ); |
|
271 | + $gateway_response = __('The payment has been refunded. Please update registrations accordingly.', 'event_espresso'); |
|
272 | 272 | break; |
273 | 273 | |
274 | 274 | case 'Voided' : |
@@ -276,25 +276,25 @@ discard block |
||
276 | 276 | case 'Canceled_Reversal' : |
277 | 277 | default : |
278 | 278 | $status = $this->_pay_model->cancelled_status(); |
279 | - $gateway_response = __( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' ); |
|
279 | + $gateway_response = __('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso'); |
|
280 | 280 | break; |
281 | 281 | |
282 | 282 | } |
283 | 283 | |
284 | 284 | //check if we've already processed this payment |
285 | - if ( $payment instanceof EEI_Payment ) { |
|
285 | + if ($payment instanceof EEI_Payment) { |
|
286 | 286 | //payment exists. if this has the exact same status and amount, don't bother updating. just return |
287 | - if ( $payment->status() == $status && $payment->amount() == $update_info[ 'mc_gross' ] ) { |
|
287 | + if ($payment->status() == $status && $payment->amount() == $update_info['mc_gross']) { |
|
288 | 288 | // DUPLICATED IPN! dont bother updating transaction foo!; |
289 | - $message_log = sprintf( __( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ), $payment->ID() ); |
|
289 | + $message_log = sprintf(__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'), $payment->ID()); |
|
290 | 290 | } else { |
291 | 291 | // new payment yippee !!! |
292 | - $payment->set_status( $status ); |
|
293 | - $payment->set_amount( floatval( $update_info[ 'mc_gross' ] ) ); |
|
294 | - $payment->set_gateway_response( $gateway_response ); |
|
295 | - $payment->set_details( $update_info ); |
|
296 | - $payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
297 | - $message_log = sprintf( __( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ) ); |
|
292 | + $payment->set_status($status); |
|
293 | + $payment->set_amount(floatval($update_info['mc_gross'])); |
|
294 | + $payment->set_gateway_response($gateway_response); |
|
295 | + $payment->set_details($update_info); |
|
296 | + $payment->set_txn_id_chq_nmbr($update_info['txn_id']); |
|
297 | + $message_log = sprintf(__('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso')); |
|
298 | 298 | } |
299 | 299 | $this->log( |
300 | 300 | array( |
@@ -306,11 +306,11 @@ discard block |
||
306 | 306 | $payment |
307 | 307 | ); |
308 | 308 | } |
309 | - do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this ); |
|
309 | + do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this); |
|
310 | 310 | // kill request here if this is a refund |
311 | - if ( $update_info[ 'payment_status' ] == 'Refunded' || $update_info[ 'payment_status' ] == 'Partially_Refunded' ) { |
|
312 | - if ( apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) ) { |
|
313 | - status_header( 200 ); |
|
311 | + if ($update_info['payment_status'] == 'Refunded' || $update_info['payment_status'] == 'Partially_Refunded') { |
|
312 | + if (apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)) { |
|
313 | + status_header(200); |
|
314 | 314 | exit(); |
315 | 315 | } |
316 | 316 | } |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | * @param EE_Payment|EEI_Payment $payment |
327 | 327 | * @return boolean |
328 | 328 | */ |
329 | - public function validate_ipn( $update_info, $payment ) { |
|
329 | + public function validate_ipn($update_info, $payment) { |
|
330 | 330 | //allow us to skip validating IPNs with PayPal (useful for testing) |
331 | - if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) { |
|
331 | + if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) { |
|
332 | 332 | return true; |
333 | 333 | } |
334 | 334 | //...otherwise, we actually don't care what the $update_info is, we need to look |
@@ -336,22 +336,22 @@ discard block |
||
336 | 336 | // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST. |
337 | 337 | // Instead, read raw POST data from the input stream. |
338 | 338 | // @see https://gist.github.com/xcommerce-gists/3440401 |
339 | - $raw_post_data = file_get_contents( 'php://input' ); |
|
340 | - $raw_post_array = explode( '&', $raw_post_data ); |
|
339 | + $raw_post_data = file_get_contents('php://input'); |
|
340 | + $raw_post_array = explode('&', $raw_post_data); |
|
341 | 341 | $update_info = array(); |
342 | - foreach ( $raw_post_array as $keyval ) { |
|
343 | - $keyval = explode( '=', $keyval ); |
|
344 | - if ( count( $keyval ) == 2 ) |
|
345 | - $update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] ); |
|
342 | + foreach ($raw_post_array as $keyval) { |
|
343 | + $keyval = explode('=', $keyval); |
|
344 | + if (count($keyval) == 2) |
|
345 | + $update_info[$keyval[0]] = urldecode($keyval[1]); |
|
346 | 346 | } |
347 | 347 | // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' |
348 | 348 | $req = 'cmd=_notify-validate'; |
349 | - $get_magic_quotes_exists = function_exists( 'get_magic_quotes_gpc' ) ? true : false; |
|
350 | - foreach ( $update_info as $key => $value ) { |
|
351 | - if ( $get_magic_quotes_exists && get_magic_quotes_gpc() == 1 ) { |
|
352 | - $value = urlencode( stripslashes( $value ) ); |
|
349 | + $get_magic_quotes_exists = function_exists('get_magic_quotes_gpc') ? true : false; |
|
350 | + foreach ($update_info as $key => $value) { |
|
351 | + if ($get_magic_quotes_exists && get_magic_quotes_gpc() == 1) { |
|
352 | + $value = urlencode(stripslashes($value)); |
|
353 | 353 | } else { |
354 | - $value = urlencode( $value ); |
|
354 | + $value = urlencode($value); |
|
355 | 355 | } |
356 | 356 | $req .= "&$key=$value"; |
357 | 357 | } |
@@ -361,21 +361,21 @@ discard block |
||
361 | 361 | array( |
362 | 362 | 'body' => $req, |
363 | 363 | 'sslverify' => false, |
364 | - 'timeout' => 60 , |
|
364 | + 'timeout' => 60, |
|
365 | 365 | // make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal |
366 | 366 | // plz see: https://github.com/websharks/s2member/issues/610 |
367 | - 'user-agent' => 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(), |
|
367 | + 'user-agent' => 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(), |
|
368 | 368 | ) |
369 | 369 | ); |
370 | 370 | // then check the response |
371 | - if ( ! is_wp_error( $response ) && array_key_exists( 'body', $response ) && strcmp( $response[ 'body' ], "VERIFIED" ) == 0 ) { |
|
371 | + if ( ! is_wp_error($response) && array_key_exists('body', $response) && strcmp($response['body'], "VERIFIED") == 0) { |
|
372 | 372 | return true; |
373 | 373 | } else { |
374 | 374 | // huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly, |
375 | 375 | // or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html |
376 | - $payment->set_gateway_response( sprintf( __( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $response[ 'body' ] ) ); |
|
377 | - $payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) ); |
|
378 | - $payment->set_status( EEM_Payment::status_id_failed ); |
|
376 | + $payment->set_gateway_response(sprintf(__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $response['body'])); |
|
377 | + $payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response)); |
|
378 | + $payment->set_status(EEM_Payment::status_id_failed); |
|
379 | 379 | // log the results |
380 | 380 | $this->log( |
381 | 381 | array( |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | */ |
398 | 398 | protected function _process_response_url() { |
399 | 399 | EE_Registry::instance()->load_helper('URL'); |
400 | - if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) { |
|
400 | + if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { |
|
401 | 401 | $url = is_ssl() ? 'https://' : 'http://'; |
402 | - $url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' ); |
|
402 | + $url .= EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
403 | 403 | $url .= EEH_URL::filter_input_server_url(); |
404 | 404 | } else { |
405 | 405 | $url = 'unknown'; |
@@ -415,29 +415,29 @@ discard block |
||
415 | 415 | * like the taxes or shipping |
416 | 416 | * @param EEI_Payment $payment |
417 | 417 | */ |
418 | - public function update_txn_based_on_payment( $payment ) { |
|
418 | + public function update_txn_based_on_payment($payment) { |
|
419 | 419 | $update_info = $payment->details(); |
420 | 420 | $transaction = $payment->transaction(); |
421 | - if( ! $transaction ){ |
|
422 | - $this->log( __( 'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso' ), $payment ); |
|
421 | + if ( ! $transaction) { |
|
422 | + $this->log(__('Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso'), $payment); |
|
423 | 423 | return; |
424 | 424 | } |
425 | - if( ! is_array( $update_info ) || ! isset( $update_info[ 'mc_shipping' ] ) || ! isset( $update_info[ 'tax' ] ) ) { |
|
425 | + if ( ! is_array($update_info) || ! isset($update_info['mc_shipping']) || ! isset($update_info['tax'])) { |
|
426 | 426 | $this->log( |
427 | 427 | array( |
428 | 428 | 'url' => $this->_process_response_url(), |
429 | - 'message' => __( 'Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso' ), |
|
429 | + 'message' => __('Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso'), |
|
430 | 430 | 'payment' => $payment->model_field_array() |
431 | 431 | ), |
432 | 432 | $payment |
433 | 433 | ); |
434 | 434 | return; |
435 | 435 | } |
436 | - if( $payment->status() !== $this->_pay_model->approved_status() ) { |
|
436 | + if ($payment->status() !== $this->_pay_model->approved_status()) { |
|
437 | 437 | $this->log( |
438 | 438 | array( |
439 | 439 | 'url' => $this->_process_response_url(), |
440 | - 'message' => __( 'We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso' ), |
|
440 | + 'message' => __('We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso'), |
|
441 | 441 | 'payment' => $payment->model_field_array() |
442 | 442 | ), |
443 | 443 | $payment |
@@ -454,43 +454,43 @@ discard block |
||
454 | 454 | // $current_tax_amount = 0; |
455 | 455 | //} |
456 | 456 | //always add paypal's taxes |
457 | - if( $this->_paypal_taxes ){ |
|
457 | + if ($this->_paypal_taxes) { |
|
458 | 458 | //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable |
459 | - $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' ); |
|
459 | + $this->_line_item->set_line_items_taxable($transaction->total_line_item(), true, 'paypal_shipping'); |
|
460 | 460 | $this->_line_item->set_total_tax_to( |
461 | 461 | $transaction->total_line_item(), |
462 | - floatval( $update_info['tax'] ), |
|
463 | - __( 'Taxes', 'event_espresso' ), |
|
464 | - __( 'Calculated by Paypal', 'event_espresso' ), |
|
462 | + floatval($update_info['tax']), |
|
463 | + __('Taxes', 'event_espresso'), |
|
464 | + __('Calculated by Paypal', 'event_espresso'), |
|
465 | 465 | 'paypal_tax' |
466 | 466 | ); |
467 | 467 | $grand_total_needs_resaving = TRUE; |
468 | 468 | } |
469 | 469 | |
470 | - $shipping_amount = floatval( $update_info[ 'mc_shipping' ] ); |
|
470 | + $shipping_amount = floatval($update_info['mc_shipping']); |
|
471 | 471 | //might paypal have added shipping? |
472 | - if( $this->_paypal_shipping && $shipping_amount ){ |
|
472 | + if ($this->_paypal_shipping && $shipping_amount) { |
|
473 | 473 | $this->_line_item->add_unrelated_item( |
474 | 474 | $transaction->total_line_item(), |
475 | - sprintf( __('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ), |
|
475 | + sprintf(__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()), |
|
476 | 476 | $shipping_amount, |
477 | 477 | __('Shipping charges calculated by Paypal', 'event_espresso'), |
478 | 478 | 1, |
479 | 479 | false, |
480 | - 'paypal_shipping_' . $transaction->ID() |
|
480 | + 'paypal_shipping_'.$transaction->ID() |
|
481 | 481 | ); |
482 | 482 | $grand_total_needs_resaving = true; |
483 | 483 | } |
484 | 484 | |
485 | - if( $grand_total_needs_resaving ){ |
|
486 | - $transaction->total_line_item()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
487 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
488 | - $registration_processor->update_registration_final_prices( $transaction ); |
|
485 | + if ($grand_total_needs_resaving) { |
|
486 | + $transaction->total_line_item()->save_this_and_descendants_to_txn($transaction->ID()); |
|
487 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
488 | + $registration_processor->update_registration_final_prices($transaction); |
|
489 | 489 | } |
490 | 490 | $this->log( |
491 | 491 | array( |
492 | 492 | 'url' => $this->_process_response_url(), |
493 | - 'message' => __( 'Updated transaction related to payment', 'event_espresso' ), |
|
493 | + 'message' => __('Updated transaction related to payment', 'event_espresso'), |
|
494 | 494 | 'transaction (updated)' => $transaction->model_field_array(), |
495 | 495 | 'payment (updated)' => $payment->model_field_array(), |
496 | 496 | 'use_paypal_shipping' => $this->_paypal_shipping, |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | <?php _e('Adjust the settings for the PayPal Standard payment gateway.', 'event_espresso'); ?> |
4 | 4 | </p> |
5 | 5 | <p> |
6 | -<?php printf( __( 'See %1$shere%2$s for list of currencies supported by Paypal Standard.', 'event_espresso' ), "<a href='https://www.paypal.com/multicurrency' target='_blank'>","</a>" ); ?> |
|
6 | +<?php printf(__('See %1$shere%2$s for list of currencies supported by Paypal Standard.', 'event_espresso'), "<a href='https://www.paypal.com/multicurrency' target='_blank'>", "</a>"); ?> |
|
7 | 7 | </p> |
8 | 8 | <h3><?php _e('PayPal Standard Settings', 'event_espresso'); ?></h3> |
9 | 9 | <ul> |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | </li> |
22 | 22 | <li> |
23 | 23 | <strong><?php _e('PayPal Calculates Taxes', 'event_espresso'); ?></strong><br /> |
24 | -<?php printf( __('If set to "Yes", we will indicate to PayPal that it ought to calculate the taxes on the order and add it. This means PayPal\'s tax calculations will be used on the order instead of Event Espresso\'s. %1$sRead here for more information.%2$s', 'event_espresso'), "<a href='https://www.paypal.com/ca/cgi-bin/webscr?cmd=xpt/Marketing/shipping/EasyCalculateShipAndTax-outside' target='_blank'>", '</a>' ); ?><br/> |
|
25 | -<?php _e( 'Note: It may confuse users if Event Espresso initially calculates taxes on the order, and then they go to PayPal and it calculates taxes differently. So it is recommended that if PayPal is calculating taxes, that you do not set any taxes in Event Espresso.', 'event_espresso' );?> |
|
24 | +<?php printf(__('If set to "Yes", we will indicate to PayPal that it ought to calculate the taxes on the order and add it. This means PayPal\'s tax calculations will be used on the order instead of Event Espresso\'s. %1$sRead here for more information.%2$s', 'event_espresso'), "<a href='https://www.paypal.com/ca/cgi-bin/webscr?cmd=xpt/Marketing/shipping/EasyCalculateShipAndTax-outside' target='_blank'>", '</a>'); ?><br/> |
|
25 | +<?php _e('Note: It may confuse users if Event Espresso initially calculates taxes on the order, and then they go to PayPal and it calculates taxes differently. So it is recommended that if PayPal is calculating taxes, that you do not set any taxes in Event Espresso.', 'event_espresso'); ?> |
|
26 | 26 | </li> |
27 | 27 | <li> |
28 | 28 | <strong><?php _e('PayPal Calculates Shipping', 'event_espresso'); ?></strong><br /> |
29 | 29 | <?php _e('Similar to the "PayPal Calculates Taxes" setting, if this is set to "Yes", we will indicate to PayPal that it ought to calculate the shipping on each payment (if there are multiple payments for a single transaction, PayPal is permitted to add shipping charges to each payment.)', 'event_espresso'); ?><br/> |
30 | -<?php _e( 'Important Note: PayPal will ONLY calculate shipping on an order if "Shipping Address Options" is set to "Prompt for an Address" (otherwise how will PayPal know how much to charge for shipping if it doesn\'t know where it\'s shipping to?)', 'event_espresso' );?> |
|
30 | +<?php _e('Important Note: PayPal will ONLY calculate shipping on an order if "Shipping Address Options" is set to "Prompt for an Address" (otherwise how will PayPal know how much to charge for shipping if it doesn\'t know where it\'s shipping to?)', 'event_espresso'); ?> |
|
31 | 31 | <li> |
32 | -<strong><?php _e( 'Notes Regarding Paypal Taxes and Shipping', 'event_espresso' );?></strong><br/> |
|
33 | -<?php _e( 'If you want PayPal to calculate taxes and shipping on an order, those changes will NOT appear during the initial registration process until the user is redirected to PayPal for payment.', 'event_espresso' );?><br/> |
|
34 | -<?php _e( 'However, after the user has returned from PayPal, their order in Event Espresso will be updated with the new taxes and added shipping charges (e.g. it will appear on their receipt.)', 'event_espresso' );?><br/> |
|
35 | -<?php _e( 'Also Note: In order for PayPal to properly calculate taxes and shipping, they need to receive the entire order at the same time. So if a user goes to make a payment using PayPal, and their order somehow already has a payment on it, PayPal CANNOT calculate taxes or shipping on that order.', 'event_espresso' );?> |
|
32 | +<strong><?php _e('Notes Regarding Paypal Taxes and Shipping', 'event_espresso'); ?></strong><br/> |
|
33 | +<?php _e('If you want PayPal to calculate taxes and shipping on an order, those changes will NOT appear during the initial registration process until the user is redirected to PayPal for payment.', 'event_espresso'); ?><br/> |
|
34 | +<?php _e('However, after the user has returned from PayPal, their order in Event Espresso will be updated with the new taxes and added shipping charges (e.g. it will appear on their receipt.)', 'event_espresso'); ?><br/> |
|
35 | +<?php _e('Also Note: In order for PayPal to properly calculate taxes and shipping, they need to receive the entire order at the same time. So if a user goes to make a payment using PayPal, and their order somehow already has a payment on it, PayPal CANNOT calculate taxes or shipping on that order.', 'event_espresso'); ?> |
|
36 | 36 | </li> |
37 | 37 | <li> |
38 | 38 | <strong><?php _e('Shipping Address Options', 'event_espresso'); ?></strong><br /> |