@@ -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,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,30 +182,30 @@ 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 | 199 | $this->addLineItem( |
200 | 200 | $item_num++, |
201 | - $this->_format_line_item_name( $line_item, $payment ), |
|
202 | - $this->_format_line_item_desc( $line_item, $payment ), |
|
201 | + $this->_format_line_item_name($line_item, $payment), |
|
202 | + $this->_format_line_item_desc($line_item, $payment), |
|
203 | 203 | $line_item->quantity(), |
204 | 204 | $line_item->unit_price(), |
205 | 205 | 'N'); |
206 | 206 | $order_description .= $line_item->desc().', '; |
207 | 207 | } |
208 | - foreach($total_line_item->tax_descendants() as $tax_line_item){ |
|
208 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
209 | 209 | $this->addLineItem($item_num++, $tax_line_item->name(), $tax_line_item->desc(), 1, $tax_line_item->total(), 'N'); |
210 | 210 | } |
211 | 211 | } |
@@ -216,18 +216,18 @@ discard block |
||
216 | 216 | //start transaction |
217 | 217 | //if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id |
218 | 218 | $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363'; |
219 | - $this->setField( 'solution_id', $partner_id ); |
|
219 | + $this->setField('solution_id', $partner_id); |
|
220 | 220 | $this->setField('amount', $this->format_currency($payment->amount())); |
221 | - $this->setField('description',substr(rtrim($order_description, ', '), 0, 255)); |
|
222 | - $this->_set_sensitive_billing_data( $billing_info ); |
|
221 | + $this->setField('description', substr(rtrim($order_description, ', '), 0, 255)); |
|
222 | + $this->_set_sensitive_billing_data($billing_info); |
|
223 | 223 | $this->setField('first_name', $billing_info['first_name']); |
224 | 224 | $this->setField('last_name', $billing_info['last_name']); |
225 | 225 | $this->setField('email', $billing_info['email']); |
226 | 226 | $this->setField('company', $billing_info['company']); |
227 | 227 | $this->setField('address', $billing_info['address'].' '.$billing_info['address2']); |
228 | 228 | $this->setField('city', $billing_info['city']); |
229 | - $this->setField('state', $billing_info['state'] ); |
|
230 | - $this->setField('country', $billing_info['country'] ); |
|
229 | + $this->setField('state', $billing_info['state']); |
|
230 | + $this->setField('country', $billing_info['country']); |
|
231 | 231 | $this->setField('zip', $billing_info['zip']); |
232 | 232 | $this->setField('fax', $billing_info['fax']); |
233 | 233 | $this->setField('cust_id', $primary_registrant->ID()); |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | //invoice_num would be nice to have it be unique per SPCO page-load, that way if users |
236 | 236 | //press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page |
237 | 237 | //in which case, we need to generate teh invoice num per request right here... |
238 | - $this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
238 | + $this->setField('invoice_num', wp_generate_password(12, false)); //$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
239 | 239 | //tell AIM that any duplicates sent in the next 5 minutes are to be ignored |
240 | - $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS ); |
|
240 | + $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS); |
|
241 | 241 | |
242 | 242 | |
243 | 243 | if ($this->_test_transactions) { |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | //Capture response |
248 | 248 | $this->type = "AUTH_CAPTURE"; |
249 | 249 | $response = $this->_sendRequest($payment); |
250 | - if (!empty($response)){ |
|
250 | + if ( ! empty($response)) { |
|
251 | 251 | if ($this->_debug_mode) { |
252 | 252 | $txn_id = $response->invoice_number; |
253 | 253 | } else { |
@@ -256,15 +256,15 @@ discard block |
||
256 | 256 | $payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status(); |
257 | 257 | $payment->set_status($payment_status); |
258 | 258 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
259 | - $payment->set_amount( (float) $response->amount ); |
|
260 | - $payment->set_gateway_response(sprintf("%s (code: %s)",$response->response_reason_text,$response->response_reason_code)); |
|
261 | - $payment->set_txn_id_chq_nmbr( $txn_id ); |
|
259 | + $payment->set_amount((float) $response->amount); |
|
260 | + $payment->set_gateway_response(sprintf("%s (code: %s)", $response->response_reason_text, $response->response_reason_code)); |
|
261 | + $payment->set_txn_id_chq_nmbr($txn_id); |
|
262 | 262 | $payment->set_extra_accntng($primary_registrant->reg_code()); |
263 | - $payment->set_details(print_r($response,true)); |
|
263 | + $payment->set_details(print_r($response, true)); |
|
264 | 264 | } else { |
265 | 265 | $payment->set_status($this->_pay_model->failed_status()); |
266 | 266 | $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso')); |
267 | - $payment->set_details(print_r($response,true)); |
|
267 | + $payment->set_details(print_r($response, true)); |
|
268 | 268 | } |
269 | 269 | return $payment; |
270 | 270 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * what billing data gets sent |
276 | 276 | * @param array $billing_info |
277 | 277 | */ |
278 | - protected function _set_sensitive_billing_data( $billing_info ) { |
|
278 | + protected function _set_sensitive_billing_data($billing_info) { |
|
279 | 279 | $this->setField('card_num', $billing_info['credit_card']); |
280 | 280 | $this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']); |
281 | 281 | $this->setField('card_code', $billing_info['cvv']); |
@@ -334,22 +334,22 @@ discard block |
||
334 | 334 | $this->_x_post_fields['tran_key'] = $this->_transaction_key; |
335 | 335 | $x_keys = array(); |
336 | 336 | foreach ($this->_x_post_fields as $key => $value) { |
337 | - $x_keys[] = "x_$key=" . urlencode($value); |
|
337 | + $x_keys[] = "x_$key=".urlencode($value); |
|
338 | 338 | } |
339 | 339 | // Add line items |
340 | 340 | foreach ($this->_additional_line_items as $key => $value) { |
341 | - $x_keys[] = "x_line_item=" . urlencode($value); |
|
341 | + $x_keys[] = "x_line_item=".urlencode($value); |
|
342 | 342 | } |
343 | 343 | $this->_log_clean_request($x_keys, $payment); |
344 | 344 | $post_url = $this->_get_server_url(); |
345 | 345 | $curl_request = curl_init($post_url); |
346 | - curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&",$x_keys)); |
|
346 | + curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&", $x_keys)); |
|
347 | 347 | curl_setopt($curl_request, CURLOPT_HEADER, 0); |
348 | 348 | curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); |
349 | 349 | curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); |
350 | 350 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); |
351 | 351 | if ($this->VERIFY_PEER) { |
352 | - curl_setopt($curl_request, CURLOPT_CAINFO, dirname( __DIR__ ) . '/ssl/cert.pem'); |
|
352 | + curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem'); |
|
353 | 353 | } else { |
354 | 354 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); |
355 | 355 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | $response = curl_exec($curl_request); |
362 | 362 | |
363 | 363 | curl_close($curl_request); |
364 | - $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
364 | + $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
365 | 365 | |
366 | 366 | return $this->_log_and_clean_response($response_obj, $payment); |
367 | 367 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | * @param array $request_array |
371 | 371 | * @param EEI_Payment $payment |
372 | 372 | */ |
373 | - protected function _log_clean_request($request_array,$payment){ |
|
374 | - $keys_to_filter_out = array( 'x_card_num', 'x_card_code', 'x_exp_date' ); |
|
375 | - foreach($request_array as $index => $keyvaltogether ) { |
|
376 | - foreach( $keys_to_filter_out as $key ) { |
|
377 | - if( strpos( $keyvaltogether, $key ) === 0 ){ |
|
373 | + protected function _log_clean_request($request_array, $payment) { |
|
374 | + $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date'); |
|
375 | + foreach ($request_array as $index => $keyvaltogether) { |
|
376 | + foreach ($keys_to_filter_out as $key) { |
|
377 | + if (strpos($keyvaltogether, $key) === 0) { |
|
378 | 378 | //found it at the first character |
379 | 379 | //so its one of them |
380 | - unset( $request_array[ $index ] ); |
|
380 | + unset($request_array[$index]); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | } |
384 | - $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url() ),$payment); |
|
384 | + $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url()), $payment); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
@@ -393,9 +393,9 @@ discard block |
||
393 | 393 | * @param EE_Payment $payment |
394 | 394 | * @return \EE_AuthorizeNetAIM_Response |
395 | 395 | */ |
396 | - private function _log_and_clean_response($response_obj,$payment){ |
|
396 | + private function _log_and_clean_response($response_obj, $payment) { |
|
397 | 397 | $response_obj->account_number = ''; |
398 | - $this->log(array('AIM Response received:'=>$response_obj),$payment); |
|
398 | + $this->log(array('AIM Response received:'=>$response_obj), $payment); |
|
399 | 399 | return $response_obj; |
400 | 400 | } |
401 | 401 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | // Split Array |
495 | 495 | $this->response = $response; |
496 | 496 | if ($encap_char) { |
497 | - $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
497 | + $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
498 | 498 | } else { |
499 | 499 | $this->_response_array = explode($delimiter, $response); |
500 | 500 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | $this->held = ($this->response_code === self::HELD); |
565 | 565 | |
566 | 566 | if ($this->error || $this->declined || $this->held) { |
567 | - $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> '; |
|
567 | + $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> '; |
|
568 | 568 | |
569 | 569 | |
570 | 570 | /* $this->error_message = "AuthorizeNet Error: |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | |
584 | 584 | } |
585 | 585 | |
586 | -if ( ! class_exists( 'AuthorizeNetException' ) ) { |
|
586 | +if ( ! class_exists('AuthorizeNetException')) { |
|
587 | 587 | /** |
588 | 588 | * Class AuthorizeNetException |
589 | 589 | * |
@@ -599,8 +599,8 @@ discard block |
||
599 | 599 | * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0 |
600 | 600 | * @since 5.1.0 |
601 | 601 | */ |
602 | - public function __construct( $message = "", $code = 0, Exception $previous = null ) { |
|
603 | - parent::__construct( $message, $code, $previous ); |
|
602 | + public function __construct($message = "", $code = 0, Exception $previous = null) { |
|
603 | + parent::__construct($message, $code, $previous); |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | } |
@@ -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_Paypal_Pro extends EE_Onsite_Gateway{ |
|
28 | +class EEG_Paypal_Pro extends EE_Onsite_Gateway { |
|
29 | 29 | /** |
30 | 30 | * |
31 | 31 | * @var $_paypal_api_username string |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | * } @see parent::do_direct_payment for more info |
89 | 89 | * @return \EE_Payment|\EEI_Payment |
90 | 90 | */ |
91 | - public function do_direct_payment($payment,$billing_info = null){ |
|
91 | + public function do_direct_payment($payment, $billing_info = null) { |
|
92 | 92 | $transaction = $payment->transaction(); |
93 | 93 | $primary_registrant = $transaction->primary_registration(); |
94 | - $order_description = $this->_format_order_description( $payment ); |
|
94 | + $order_description = $this->_format_order_description($payment); |
|
95 | 95 | //charge for the full amount. Show itemized list |
96 | - if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
|
96 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
97 | 97 | $item_num = 1; |
98 | 98 | $total_line_item = $transaction->total_line_item(); |
99 | 99 | $order_items = array(); |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | $item = array( |
102 | 102 | // Item Name. 127 char max. |
103 | 103 | 'l_name' => substr( |
104 | - $this->_format_line_item_name( $line_item, $payment ), |
|
104 | + $this->_format_line_item_name($line_item, $payment), |
|
105 | 105 | 0, |
106 | 106 | 127 |
107 | 107 | ), |
108 | 108 | // Item description. 127 char max. |
109 | 109 | 'l_desc' => substr( |
110 | - $this->_format_line_item_desc( $line_item, $payment ), |
|
110 | + $this->_format_line_item_desc($line_item, $payment), |
|
111 | 111 | 0, |
112 | 112 | 127 |
113 | 113 | ), |
@@ -131,20 +131,20 @@ discard block |
||
131 | 131 | } |
132 | 132 | $item_amount = $total_line_item->get_items_total(); |
133 | 133 | $tax_amount = $total_line_item->get_total_tax(); |
134 | - }else{ |
|
134 | + } else { |
|
135 | 135 | $order_items = array(); |
136 | 136 | $item_amount = $payment->amount(); |
137 | 137 | $tax_amount = 0; |
138 | - array_push($order_items,array( |
|
138 | + array_push($order_items, array( |
|
139 | 139 | // Item Name. 127 char max. |
140 | 140 | 'l_name' => substr( |
141 | - $this->_format_partial_payment_line_item_name( $payment ), |
|
141 | + $this->_format_partial_payment_line_item_name($payment), |
|
142 | 142 | 0, |
143 | 143 | 127 |
144 | 144 | ), |
145 | 145 | // Item description. 127 char max. |
146 | 146 | 'l_desc' => substr( |
147 | - $this->_format_partial_payment_line_item_desc( $payment ), |
|
147 | + $this->_format_partial_payment_line_item_desc($payment), |
|
148 | 148 | 0, |
149 | 149 | 127 |
150 | 150 | ), |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | // Payer's salutation. 20 char max. |
193 | 193 | 'salutation' => '', |
194 | 194 | // Payer's first name. 25 char max. |
195 | - 'firstname' => substr($billing_info['first_name'],0,25), |
|
195 | + 'firstname' => substr($billing_info['first_name'], 0, 25), |
|
196 | 196 | // Payer's middle name. 25 char max. |
197 | 197 | 'middlename' => '', |
198 | 198 | // Payer's last name. 25 char max. |
199 | - 'lastname' => substr($billing_info['last_name'],0,25), |
|
199 | + 'lastname' => substr($billing_info['last_name'], 0, 25), |
|
200 | 200 | // Payer's suffix. 12 char max. |
201 | 201 | 'suffix' => '' |
202 | 202 | ); |
@@ -209,13 +209,13 @@ discard block |
||
209 | 209 | // Required. Name of City. |
210 | 210 | 'city' => $billing_info['city'], |
211 | 211 | // Required. Name of State or Province. |
212 | - 'state' => substr( $billing_info['state'], 0, 40 ), |
|
212 | + 'state' => substr($billing_info['state'], 0, 40), |
|
213 | 213 | // Required. Country code. |
214 | 214 | 'countrycode' => $billing_info['country'], |
215 | 215 | // Required. Postal code of payer. |
216 | 216 | 'zip' => $billing_info['zip'], |
217 | 217 | // Phone Number of payer. 20 char max. |
218 | - 'shiptophonenum' => substr($billing_info['phone'],0,20) |
|
218 | + 'shiptophonenum' => substr($billing_info['phone'], 0, 20) |
|
219 | 219 | ); |
220 | 220 | |
221 | 221 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | // Required. Three-letter currency code. Default is USD. |
226 | 226 | 'currencycode' => $payment->currency_code(), |
227 | 227 | // Required if you include itemized cart details. (L_AMTn, etc.) Subtotal of items not including S&H, or tax. |
228 | - 'itemamt' => $this->format_currency($item_amount),// |
|
228 | + 'itemamt' => $this->format_currency($item_amount), // |
|
229 | 229 | // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
230 | 230 | 'shippingamt' => '', |
231 | 231 | // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | // Free-form field for your own use. 256 char max. |
238 | 238 | 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
239 | 239 | // Your own invoice or tracking number |
240 | - 'invnum' => wp_generate_password(12,false),//$transaction->ID(), |
|
240 | + 'invnum' => wp_generate_password(12, false), //$transaction->ID(), |
|
241 | 241 | // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
242 | 242 | 'notifyurl' => '', |
243 | - 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
243 | + 'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this |
|
244 | 244 | ); |
245 | 245 | // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
246 | 246 | $PayPalRequestData = array( |
@@ -253,32 +253,32 @@ discard block |
||
253 | 253 | 'OrderItems' => $order_items, |
254 | 254 | ); |
255 | 255 | $this->_log_clean_request($PayPalRequestData, $payment); |
256 | - try{ |
|
256 | + try { |
|
257 | 257 | $PayPalResult = $this->prep_and_curl_request($PayPalRequestData); |
258 | 258 | //remove PCI-sensitive data so it doesn't get stored |
259 | - $PayPalResult = $this->_log_clean_response($PayPalResult,$payment); |
|
259 | + $PayPalResult = $this->_log_clean_response($PayPalResult, $payment); |
|
260 | 260 | |
261 | 261 | $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK']; |
262 | - if( empty($PayPalResult[ 'RAWRESPONSE' ] ) ) { |
|
263 | - $payment->set_status( $this->_pay_model->failed_status() ) ; |
|
264 | - $payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) ); |
|
262 | + if (empty($PayPalResult['RAWRESPONSE'])) { |
|
263 | + $payment->set_status($this->_pay_model->failed_status()); |
|
264 | + $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso')); |
|
265 | 265 | $payment->set_details($PayPalResult); |
266 | - }else{ |
|
267 | - if($this->_APICallSuccessful($PayPalResult)){ |
|
266 | + } else { |
|
267 | + if ($this->_APICallSuccessful($PayPalResult)) { |
|
268 | 268 | $payment->set_status($this->_pay_model->approved_status()); |
269 | - }else{ |
|
269 | + } else { |
|
270 | 270 | $payment->set_status($this->_pay_model->declined_status()); |
271 | 271 | } |
272 | 272 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
273 | - $payment->set_amount(isset($PayPalResult['AMT']) ? floatval( $PayPalResult['AMT'] ) : 0); |
|
273 | + $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0); |
|
274 | 274 | $payment->set_gateway_response($message); |
275 | - $payment->set_txn_id_chq_nmbr(isset( $PayPalResult['TRANSACTIONID'] )? $PayPalResult['TRANSACTIONID'] : null); |
|
275 | + $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null); |
|
276 | 276 | |
277 | 277 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
278 | 278 | $payment->set_extra_accntng($primary_registration_code); |
279 | 279 | $payment->set_details($PayPalResult); |
280 | 280 | } |
281 | - }catch(Exception $e){ |
|
281 | + } catch (Exception $e) { |
|
282 | 282 | $payment->set_status($this->_pay_model->failed_status()); |
283 | 283 | $payment->set_gateway_response($e->getMessage()); |
284 | 284 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * @param EEI_Payment $payment |
296 | 296 | * @return array |
297 | 297 | */ |
298 | - private function _log_clean_request($request,$payment){ |
|
298 | + private function _log_clean_request($request, $payment) { |
|
299 | 299 | $cleaned_request_data = $request; |
300 | 300 | unset($cleaned_request_data['CCDetails']['acct']); |
301 | 301 | unset($cleaned_request_data['CCDetails']['cvv2']); |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | * @param EEI_Payment $payment |
312 | 312 | * @return array cleaned |
313 | 313 | */ |
314 | - private function _log_clean_response($response,$payment){ |
|
314 | + private function _log_clean_response($response, $payment) { |
|
315 | 315 | unset($response['REQUESTDATA']['CREDITCARDTYPE']); |
316 | 316 | unset($response['REQUESTDATA']['ACCT']); |
317 | 317 | unset($response['REQUESTDATA']['EXPDATE']); |
318 | 318 | unset($response['REQUESTDATA']['CVV2']); |
319 | 319 | unset($response['RAWREQUEST']); |
320 | - $this->log(array('Paypal Response'=>$response),$payment); |
|
320 | + $this->log(array('Paypal Response'=>$response), $payment); |
|
321 | 321 | return $response; |
322 | 322 | } |
323 | 323 | |
@@ -342,32 +342,32 @@ discard block |
||
342 | 342 | // DP Fields |
343 | 343 | $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
344 | 344 | foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) |
345 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
345 | + $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal); |
|
346 | 346 | |
347 | 347 | // CC Details Fields |
348 | 348 | $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
349 | 349 | foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) |
350 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
350 | + $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal); |
|
351 | 351 | |
352 | 352 | // PayerInfo Type Fields |
353 | 353 | $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
354 | 354 | foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) |
355 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
355 | + $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal); |
|
356 | 356 | |
357 | 357 | // Payer Name Fields |
358 | 358 | $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
359 | 359 | foreach ($PayerName as $PayerNameVar => $PayerNameVal) |
360 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
360 | + $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal); |
|
361 | 361 | |
362 | 362 | // Address Fields (Billing) |
363 | 363 | $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
364 | 364 | foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) |
365 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
365 | + $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal); |
|
366 | 366 | |
367 | 367 | // Payment Details Type Fields |
368 | 368 | $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
369 | 369 | foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) |
370 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
370 | + $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal); |
|
371 | 371 | |
372 | 372 | // Payment Details Item Type Fields |
373 | 373 | $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
@@ -375,22 +375,22 @@ discard block |
||
375 | 375 | foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
376 | 376 | $CurrentItem = $OrderItems[$OrderItemsVar]; |
377 | 377 | foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) |
378 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
378 | + $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal); |
|
379 | 379 | $n++; |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Ship To Address Fields |
383 | 383 | $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
384 | 384 | foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) |
385 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
385 | + $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal); |
|
386 | 386 | |
387 | 387 | // 3D Secure Fields |
388 | 388 | $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
389 | 389 | foreach ($Secure3D as $Secure3DVar => $Secure3DVal) |
390 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
390 | + $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal); |
|
391 | 391 | |
392 | 392 | // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
393 | - $NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP; |
|
393 | + $NVPRequest = 'USER='.$this->_username.'&PWD='.$this->_password.'&VERSION=64.0'.'&SIGNATURE='.$this->_signature.$DPFieldsNVP.$CCDetailsNVP.$PayerInfoNVP.$PayerNameNVP.$BillingAddressNVP.$PaymentDetailsNVP.$OrderItemsNVP.$ShippingAddressNVP.$Secure3DNVP; |
|
394 | 394 | $NVPResponse = $this->_CURLRequest($NVPRequest); |
395 | 395 | $NVPRequestArray = $this->_NVPToArray($NVPRequest); |
396 | 396 | $NVPResponseArray = $this->_NVPToArray($NVPResponse); |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | private function _CURLRequest($Request) { |
415 | 415 | $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; |
416 | 416 | $curl = curl_init(); |
417 | - curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE ) ); |
|
417 | + curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE)); |
|
418 | 418 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); |
419 | 419 | curl_setopt($curl, CURLOPT_TIMEOUT, 60); |
420 | 420 | curl_setopt($curl, CURLOPT_URL, $EndPointURL); |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | private function _APICallSuccessful($PayPalResult) { |
465 | 465 | $approved = false; |
466 | 466 | // check main response message from PayPal |
467 | - if (isset($PayPalResult['ACK']) && !empty($PayPalResult['ACK'])) { |
|
467 | + if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) { |
|
468 | 468 | $ack = strtoupper($PayPalResult['ACK']); |
469 | - $approved = ( $ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS' ) ? true : false; |
|
469 | + $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | return $approved; |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | |
483 | 483 | $Errors = array(); |
484 | 484 | $n = 0; |
485 | - while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
486 | - $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
487 | - $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : ''; |
|
488 | - $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : ''; |
|
489 | - $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : ''; |
|
485 | + while (isset($DataArray['L_ERRORCODE'.$n.''])) { |
|
486 | + $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : ''; |
|
487 | + $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : ''; |
|
488 | + $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : ''; |
|
489 | + $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : ''; |
|
490 | 490 | |
491 | 491 | $CurrentItem = array( |
492 | 492 | 'L_ERRORCODE' => $LErrorCode, |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | elseif ($CurrentErrorVar == 'L_SEVERITYCODE') |
527 | 527 | $CurrentVarName = 'Severity Code'; |
528 | 528 | |
529 | - $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
529 | + $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal; |
|
530 | 530 | } |
531 | 531 | } |
532 | 532 | return $error; |