@@ -90,19 +90,19 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function do_direct_payment($payment,$billing_info = null){ |
92 | 92 | $transaction = $payment->transaction(); |
93 | - if (! $transaction instanceof EEI_Transaction) { |
|
94 | - throw new EE_Error(esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')); |
|
95 | - } |
|
96 | - $primary_registrant = $transaction->primary_registration(); |
|
97 | - if (! $primary_registrant instanceof EEI_Registration) { |
|
98 | - throw new EE_Error(esc_html__('No primary registration on transaction while paying with PayPal Pro.', |
|
99 | - 'event_espresso')); |
|
100 | - } |
|
101 | - $attendee = $primary_registrant->attendee(); |
|
102 | - if (! $attendee instanceof EEI_Attendee) { |
|
103 | - throw new EE_Error(esc_html__('No attendee on primary registration while paying with PayPal Pro.', |
|
104 | - 'event_espresso')); |
|
105 | - } |
|
93 | + if (! $transaction instanceof EEI_Transaction) { |
|
94 | + throw new EE_Error(esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')); |
|
95 | + } |
|
96 | + $primary_registrant = $transaction->primary_registration(); |
|
97 | + if (! $primary_registrant instanceof EEI_Registration) { |
|
98 | + throw new EE_Error(esc_html__('No primary registration on transaction while paying with PayPal Pro.', |
|
99 | + 'event_espresso')); |
|
100 | + } |
|
101 | + $attendee = $primary_registrant->attendee(); |
|
102 | + if (! $attendee instanceof EEI_Attendee) { |
|
103 | + throw new EE_Error(esc_html__('No attendee on primary registration while paying with PayPal Pro.', |
|
104 | + 'event_espresso')); |
|
105 | + } |
|
106 | 106 | $order_description = substr( $this->_format_order_description( $payment ), 0,127 ); |
107 | 107 | //charge for the full amount. Show itemized list |
108 | 108 | if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
@@ -232,23 +232,23 @@ discard block |
||
232 | 232 | 'zip' => $billing_info['zip'], |
233 | 233 | ); |
234 | 234 | |
235 | - //check if the registration info contains the needed fields for paypal pro (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/) |
|
236 | - if($attendee->address() && $attendee->city() && $attendee->country_ID()){ |
|
237 | - $use_registration_address_info = true; |
|
238 | - } else { |
|
239 | - $use_registration_address_info = false; |
|
240 | - } |
|
241 | - //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it. If not, use the billing info again |
|
242 | - $ShippingAddress = array( |
|
243 | - 'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32), |
|
244 | - 'shiptostreet' => substr($use_registration_address_info ? $attendee->address() : $billing_info['address'], 0, 100), |
|
245 | - 'shiptostreet2' => substr($use_registration_address_info ? $attendee->address2() : $billing_info['address2'],0,100), |
|
246 | - 'shiptocity' => substr($use_registration_address_info ? $attendee->city() : $billing_info['city'],0,40), |
|
247 | - 'state' => substr($use_registration_address_info ? $attendee->state_name() : $billing_info['state'],0,40), |
|
248 | - 'shiptocountry' => $use_registration_address_info ? $attendee->country_ID() : $billing_info['country'], |
|
249 | - 'shiptozip' => substr($use_registration_address_info ? $attendee->zip() : $billing_info['zip'],0,20), |
|
250 | - 'shiptophonenum' => substr($use_registration_address_info ? $attendee->phone() : $billing_info['phone'],0,20), |
|
251 | - ); |
|
235 | + //check if the registration info contains the needed fields for paypal pro (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/) |
|
236 | + if($attendee->address() && $attendee->city() && $attendee->country_ID()){ |
|
237 | + $use_registration_address_info = true; |
|
238 | + } else { |
|
239 | + $use_registration_address_info = false; |
|
240 | + } |
|
241 | + //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it. If not, use the billing info again |
|
242 | + $ShippingAddress = array( |
|
243 | + 'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32), |
|
244 | + 'shiptostreet' => substr($use_registration_address_info ? $attendee->address() : $billing_info['address'], 0, 100), |
|
245 | + 'shiptostreet2' => substr($use_registration_address_info ? $attendee->address2() : $billing_info['address2'],0,100), |
|
246 | + 'shiptocity' => substr($use_registration_address_info ? $attendee->city() : $billing_info['city'],0,40), |
|
247 | + 'state' => substr($use_registration_address_info ? $attendee->state_name() : $billing_info['state'],0,40), |
|
248 | + 'shiptocountry' => $use_registration_address_info ? $attendee->country_ID() : $billing_info['country'], |
|
249 | + 'shiptozip' => substr($use_registration_address_info ? $attendee->zip() : $billing_info['zip'],0,20), |
|
250 | + 'shiptophonenum' => substr($use_registration_address_info ? $attendee->phone() : $billing_info['phone'],0,20), |
|
251 | + ); |
|
252 | 252 | |
253 | 253 | $PaymentDetails = array( |
254 | 254 | // Required. Total amount of order, including shipping, handling, and tax. |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | 'PayerInfo' => $PayerInfo, |
281 | 281 | 'PayerName' => $PayerName, |
282 | 282 | 'BillingAddress' => $BillingAddress, |
283 | - 'ShippingAddress' => $ShippingAddress, |
|
283 | + 'ShippingAddress' => $ShippingAddress, |
|
284 | 284 | 'PaymentDetails' => $PaymentDetails, |
285 | 285 | 'OrderItems' => $order_items, |
286 | 286 | ); |
@@ -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,42 +88,42 @@ 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 | - if (! $transaction instanceof EEI_Transaction) { |
|
93 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
94 | 94 | throw new EE_Error(esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')); |
95 | 95 | } |
96 | 96 | $primary_registrant = $transaction->primary_registration(); |
97 | - if (! $primary_registrant instanceof EEI_Registration) { |
|
97 | + if ( ! $primary_registrant instanceof EEI_Registration) { |
|
98 | 98 | throw new EE_Error(esc_html__('No primary registration on transaction while paying with PayPal Pro.', |
99 | 99 | 'event_espresso')); |
100 | 100 | } |
101 | 101 | $attendee = $primary_registrant->attendee(); |
102 | - if (! $attendee instanceof EEI_Attendee) { |
|
102 | + if ( ! $attendee instanceof EEI_Attendee) { |
|
103 | 103 | throw new EE_Error(esc_html__('No attendee on primary registration while paying with PayPal Pro.', |
104 | 104 | 'event_espresso')); |
105 | 105 | } |
106 | - $order_description = substr( $this->_format_order_description( $payment ), 0,127 ); |
|
106 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
107 | 107 | //charge for the full amount. Show itemized list |
108 | - if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
|
108 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
109 | 109 | $item_num = 1; |
110 | 110 | $total_line_item = $transaction->total_line_item(); |
111 | 111 | $order_items = array(); |
112 | 112 | foreach ($total_line_item->get_items() as $line_item) { |
113 | 113 | //ignore line items with a quantity of 0 |
114 | - if( $line_item->quantity() == 0 ) { |
|
114 | + if ($line_item->quantity() == 0) { |
|
115 | 115 | continue; |
116 | 116 | } |
117 | 117 | $item = array( |
118 | 118 | // Item Name. 127 char max. |
119 | 119 | 'l_name' => substr( |
120 | - $this->_format_line_item_name( $line_item, $payment ), |
|
120 | + $this->_format_line_item_name($line_item, $payment), |
|
121 | 121 | 0, |
122 | 122 | 127 |
123 | 123 | ), |
124 | 124 | // Item description. 127 char max. |
125 | 125 | 'l_desc' => substr( |
126 | - $this->_format_line_item_desc( $line_item, $payment ), |
|
126 | + $this->_format_line_item_desc($line_item, $payment), |
|
127 | 127 | 0, |
128 | 128 | 127 |
129 | 129 | ), |
@@ -147,20 +147,20 @@ discard block |
||
147 | 147 | } |
148 | 148 | $item_amount = $total_line_item->get_items_total(); |
149 | 149 | $tax_amount = $total_line_item->get_total_tax(); |
150 | - }else{ |
|
150 | + } else { |
|
151 | 151 | $order_items = array(); |
152 | 152 | $item_amount = $payment->amount(); |
153 | 153 | $tax_amount = 0; |
154 | - array_push($order_items,array( |
|
154 | + array_push($order_items, array( |
|
155 | 155 | // Item Name. 127 char max. |
156 | 156 | 'l_name' => substr( |
157 | - $this->_format_partial_payment_line_item_name( $payment ), |
|
157 | + $this->_format_partial_payment_line_item_name($payment), |
|
158 | 158 | 0, |
159 | 159 | 127 |
160 | 160 | ), |
161 | 161 | // Item description. 127 char max. |
162 | 162 | 'l_desc' => substr( |
163 | - $this->_format_partial_payment_line_item_desc( $payment ), |
|
163 | + $this->_format_partial_payment_line_item_desc($payment), |
|
164 | 164 | 0, |
165 | 165 | 127 |
166 | 166 | ), |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | // Payer's salutation. 20 char max. |
209 | 209 | 'salutation' => '', |
210 | 210 | // Payer's first name. 25 char max. |
211 | - 'firstname' => substr($billing_info['first_name'],0,25), |
|
211 | + 'firstname' => substr($billing_info['first_name'], 0, 25), |
|
212 | 212 | // Payer's middle name. 25 char max. |
213 | 213 | 'middlename' => '', |
214 | 214 | // Payer's last name. 25 char max. |
215 | - 'lastname' => substr($billing_info['last_name'],0,25), |
|
215 | + 'lastname' => substr($billing_info['last_name'], 0, 25), |
|
216 | 216 | // Payer's suffix. 12 char max. |
217 | 217 | 'suffix' => '' |
218 | 218 | ); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | // Required. Name of City. |
226 | 226 | 'city' => $billing_info['city'], |
227 | 227 | // Required. Name of State or Province. |
228 | - 'state' => substr( $billing_info['state'], 0, 40 ), |
|
228 | + 'state' => substr($billing_info['state'], 0, 40), |
|
229 | 229 | // Required. Country code. |
230 | 230 | 'countrycode' => $billing_info['country'], |
231 | 231 | // Required. Postal code of payer. |
@@ -233,21 +233,21 @@ discard block |
||
233 | 233 | ); |
234 | 234 | |
235 | 235 | //check if the registration info contains the needed fields for paypal pro (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/) |
236 | - if($attendee->address() && $attendee->city() && $attendee->country_ID()){ |
|
236 | + if ($attendee->address() && $attendee->city() && $attendee->country_ID()) { |
|
237 | 237 | $use_registration_address_info = true; |
238 | 238 | } else { |
239 | 239 | $use_registration_address_info = false; |
240 | 240 | } |
241 | 241 | //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it. If not, use the billing info again |
242 | 242 | $ShippingAddress = array( |
243 | - 'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32), |
|
243 | + 'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'].' '.$billing_info['last_name'], 0, 32), |
|
244 | 244 | 'shiptostreet' => substr($use_registration_address_info ? $attendee->address() : $billing_info['address'], 0, 100), |
245 | - 'shiptostreet2' => substr($use_registration_address_info ? $attendee->address2() : $billing_info['address2'],0,100), |
|
246 | - 'shiptocity' => substr($use_registration_address_info ? $attendee->city() : $billing_info['city'],0,40), |
|
247 | - 'state' => substr($use_registration_address_info ? $attendee->state_name() : $billing_info['state'],0,40), |
|
245 | + 'shiptostreet2' => substr($use_registration_address_info ? $attendee->address2() : $billing_info['address2'], 0, 100), |
|
246 | + 'shiptocity' => substr($use_registration_address_info ? $attendee->city() : $billing_info['city'], 0, 40), |
|
247 | + 'state' => substr($use_registration_address_info ? $attendee->state_name() : $billing_info['state'], 0, 40), |
|
248 | 248 | 'shiptocountry' => $use_registration_address_info ? $attendee->country_ID() : $billing_info['country'], |
249 | - 'shiptozip' => substr($use_registration_address_info ? $attendee->zip() : $billing_info['zip'],0,20), |
|
250 | - 'shiptophonenum' => substr($use_registration_address_info ? $attendee->phone() : $billing_info['phone'],0,20), |
|
249 | + 'shiptozip' => substr($use_registration_address_info ? $attendee->zip() : $billing_info['zip'], 0, 20), |
|
250 | + 'shiptophonenum' => substr($use_registration_address_info ? $attendee->phone() : $billing_info['phone'], 0, 20), |
|
251 | 251 | ); |
252 | 252 | |
253 | 253 | $PaymentDetails = array( |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | // Required. Three-letter currency code. Default is USD. |
257 | 257 | 'currencycode' => $payment->currency_code(), |
258 | 258 | // Required if you include itemized cart details. (L_AMTn, etc.) Subtotal of items not including S&H, or tax. |
259 | - 'itemamt' => $this->format_currency($item_amount),// |
|
259 | + 'itemamt' => $this->format_currency($item_amount), // |
|
260 | 260 | // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
261 | 261 | 'shippingamt' => '', |
262 | 262 | // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | // Free-form field for your own use. 256 char max. |
269 | 269 | 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
270 | 270 | // Your own invoice or tracking number |
271 | - 'invnum' => wp_generate_password(12,false),//$transaction->ID(), |
|
271 | + 'invnum' => wp_generate_password(12, false), //$transaction->ID(), |
|
272 | 272 | // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
273 | 273 | 'notifyurl' => '', |
274 | - 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
274 | + 'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this |
|
275 | 275 | ); |
276 | 276 | // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
277 | 277 | $PayPalRequestData = array( |
@@ -285,32 +285,32 @@ discard block |
||
285 | 285 | 'OrderItems' => $order_items, |
286 | 286 | ); |
287 | 287 | $this->_log_clean_request($PayPalRequestData, $payment); |
288 | - try{ |
|
288 | + try { |
|
289 | 289 | $PayPalResult = $this->prep_and_curl_request($PayPalRequestData); |
290 | 290 | //remove PCI-sensitive data so it doesn't get stored |
291 | - $PayPalResult = $this->_log_clean_response($PayPalResult,$payment); |
|
291 | + $PayPalResult = $this->_log_clean_response($PayPalResult, $payment); |
|
292 | 292 | |
293 | 293 | $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK']; |
294 | - if( empty($PayPalResult[ 'RAWRESPONSE' ] ) ) { |
|
295 | - $payment->set_status( $this->_pay_model->failed_status() ) ; |
|
296 | - $payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) ); |
|
294 | + if (empty($PayPalResult['RAWRESPONSE'])) { |
|
295 | + $payment->set_status($this->_pay_model->failed_status()); |
|
296 | + $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso')); |
|
297 | 297 | $payment->set_details($PayPalResult); |
298 | - }else{ |
|
299 | - if($this->_APICallSuccessful($PayPalResult)){ |
|
298 | + } else { |
|
299 | + if ($this->_APICallSuccessful($PayPalResult)) { |
|
300 | 300 | $payment->set_status($this->_pay_model->approved_status()); |
301 | - }else{ |
|
301 | + } else { |
|
302 | 302 | $payment->set_status($this->_pay_model->declined_status()); |
303 | 303 | } |
304 | 304 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
305 | - $payment->set_amount(isset($PayPalResult['AMT']) ? floatval( $PayPalResult['AMT'] ) : 0); |
|
305 | + $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0); |
|
306 | 306 | $payment->set_gateway_response($message); |
307 | - $payment->set_txn_id_chq_nmbr(isset( $PayPalResult['TRANSACTIONID'] )? $PayPalResult['TRANSACTIONID'] : null); |
|
307 | + $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null); |
|
308 | 308 | |
309 | 309 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
310 | 310 | $payment->set_extra_accntng($primary_registration_code); |
311 | 311 | $payment->set_details($PayPalResult); |
312 | 312 | } |
313 | - }catch(Exception $e){ |
|
313 | + } catch (Exception $e) { |
|
314 | 314 | $payment->set_status($this->_pay_model->failed_status()); |
315 | 315 | $payment->set_gateway_response($e->getMessage()); |
316 | 316 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @param EEI_Payment $payment |
328 | 328 | * @return array |
329 | 329 | */ |
330 | - private function _log_clean_request($request,$payment){ |
|
330 | + private function _log_clean_request($request, $payment) { |
|
331 | 331 | $cleaned_request_data = $request; |
332 | 332 | unset($cleaned_request_data['CCDetails']['acct']); |
333 | 333 | unset($cleaned_request_data['CCDetails']['cvv2']); |
@@ -343,13 +343,13 @@ discard block |
||
343 | 343 | * @param EEI_Payment $payment |
344 | 344 | * @return array cleaned |
345 | 345 | */ |
346 | - private function _log_clean_response($response,$payment){ |
|
346 | + private function _log_clean_response($response, $payment) { |
|
347 | 347 | unset($response['REQUESTDATA']['CREDITCARDTYPE']); |
348 | 348 | unset($response['REQUESTDATA']['ACCT']); |
349 | 349 | unset($response['REQUESTDATA']['EXPDATE']); |
350 | 350 | unset($response['REQUESTDATA']['CVV2']); |
351 | 351 | unset($response['RAWREQUEST']); |
352 | - $this->log(array('Paypal Response'=>$response),$payment); |
|
352 | + $this->log(array('Paypal Response'=>$response), $payment); |
|
353 | 353 | return $response; |
354 | 354 | } |
355 | 355 | |
@@ -374,32 +374,32 @@ discard block |
||
374 | 374 | // DP Fields |
375 | 375 | $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
376 | 376 | foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) |
377 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
377 | + $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal); |
|
378 | 378 | |
379 | 379 | // CC Details Fields |
380 | 380 | $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
381 | 381 | foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) |
382 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
382 | + $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal); |
|
383 | 383 | |
384 | 384 | // PayerInfo Type Fields |
385 | 385 | $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
386 | 386 | foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) |
387 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
387 | + $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal); |
|
388 | 388 | |
389 | 389 | // Payer Name Fields |
390 | 390 | $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
391 | 391 | foreach ($PayerName as $PayerNameVar => $PayerNameVal) |
392 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
392 | + $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal); |
|
393 | 393 | |
394 | 394 | // Address Fields (Billing) |
395 | 395 | $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
396 | 396 | foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) |
397 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
397 | + $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal); |
|
398 | 398 | |
399 | 399 | // Payment Details Type Fields |
400 | 400 | $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
401 | 401 | foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) |
402 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
402 | + $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal); |
|
403 | 403 | |
404 | 404 | // Payment Details Item Type Fields |
405 | 405 | $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
@@ -407,22 +407,22 @@ discard block |
||
407 | 407 | foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
408 | 408 | $CurrentItem = $OrderItems[$OrderItemsVar]; |
409 | 409 | foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) |
410 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
410 | + $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal); |
|
411 | 411 | $n++; |
412 | 412 | } |
413 | 413 | |
414 | 414 | // Ship To Address Fields |
415 | 415 | $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
416 | 416 | foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) |
417 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
417 | + $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal); |
|
418 | 418 | |
419 | 419 | // 3D Secure Fields |
420 | 420 | $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
421 | 421 | foreach ($Secure3D as $Secure3DVar => $Secure3DVal) |
422 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
422 | + $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal); |
|
423 | 423 | |
424 | 424 | // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
425 | - $NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP; |
|
425 | + $NVPRequest = 'USER='.$this->_username.'&PWD='.$this->_password.'&VERSION=64.0'.'&SIGNATURE='.$this->_signature.$DPFieldsNVP.$CCDetailsNVP.$PayerInfoNVP.$PayerNameNVP.$BillingAddressNVP.$PaymentDetailsNVP.$OrderItemsNVP.$ShippingAddressNVP.$Secure3DNVP; |
|
426 | 426 | $NVPResponse = $this->_CURLRequest($NVPRequest); |
427 | 427 | $NVPRequestArray = $this->_NVPToArray($NVPRequest); |
428 | 428 | $NVPResponseArray = $this->_NVPToArray($NVPResponse); |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | private function _CURLRequest($Request) { |
447 | 447 | $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; |
448 | 448 | $curl = curl_init(); |
449 | - curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE ) ); |
|
449 | + curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE)); |
|
450 | 450 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); |
451 | 451 | curl_setopt($curl, CURLOPT_TIMEOUT, 60); |
452 | 452 | curl_setopt($curl, CURLOPT_URL, $EndPointURL); |
@@ -496,9 +496,9 @@ discard block |
||
496 | 496 | private function _APICallSuccessful($PayPalResult) { |
497 | 497 | $approved = false; |
498 | 498 | // check main response message from PayPal |
499 | - if (isset($PayPalResult['ACK']) && !empty($PayPalResult['ACK'])) { |
|
499 | + if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) { |
|
500 | 500 | $ack = strtoupper($PayPalResult['ACK']); |
501 | - $approved = ( $ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS' ) ? true : false; |
|
501 | + $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false; |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | return $approved; |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | |
515 | 515 | $Errors = array(); |
516 | 516 | $n = 0; |
517 | - while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
518 | - $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
519 | - $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : ''; |
|
520 | - $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : ''; |
|
521 | - $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : ''; |
|
517 | + while (isset($DataArray['L_ERRORCODE'.$n.''])) { |
|
518 | + $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : ''; |
|
519 | + $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : ''; |
|
520 | + $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : ''; |
|
521 | + $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : ''; |
|
522 | 522 | |
523 | 523 | $CurrentItem = array( |
524 | 524 | 'L_ERRORCODE' => $LErrorCode, |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | elseif ($CurrentErrorVar == 'L_SEVERITYCODE') |
559 | 559 | $CurrentVarName = 'Severity Code'; |
560 | 560 | |
561 | - $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
561 | + $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal; |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | return $error; |