@@ -282,7 +282,7 @@ discard block |
||
| 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(); |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | /** |
| 370 | 370 | * Gets the order description that should generlly be sent to gateways |
| 371 | 371 | * @param EEI_Payment $payment |
| 372 | - * @return type |
|
| 372 | + * @return double |
|
| 373 | 373 | */ |
| 374 | 374 | protected function _format_order_description( EEI_Payment $payment ) { |
| 375 | 375 | return apply_filters( |
@@ -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,7 +340,7 @@ 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 | 346 | $line_item->name(), |
@@ -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 | ); |
@@ -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(); |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | // Item Name. 127 char max. |
| 103 | 103 | 'l_name' => |
| 104 | 104 | substr( |
| 105 | - $this->_format_line_item_name( $line_item, $payment ), |
|
| 106 | - 0,127), |
|
| 105 | + $this->_format_line_item_name($line_item, $payment), |
|
| 106 | + 0, 127), |
|
| 107 | 107 | // Item description. 127 char max. |
| 108 | - 'l_desc' => substr( $this->_format_line_item_desc( $line_item, $payment )), |
|
| 108 | + 'l_desc' => substr($this->_format_line_item_desc($line_item, $payment)), |
|
| 109 | 109 | // Cost of individual item. |
| 110 | 110 | 'l_amt' => $line_item->unit_price(), |
| 111 | 111 | // Item Number. 127 char max. |
@@ -126,20 +126,20 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | $item_amount = $total_line_item->get_items_total(); |
| 128 | 128 | $tax_amount = $total_line_item->get_total_tax(); |
| 129 | - }else{ |
|
| 129 | + } else { |
|
| 130 | 130 | $order_items = array(); |
| 131 | 131 | $item_amount = $payment->amount(); |
| 132 | 132 | $tax_amount = 0; |
| 133 | - array_push($order_items,array( |
|
| 133 | + array_push($order_items, array( |
|
| 134 | 134 | // Item Name. 127 char max. |
| 135 | 135 | 'l_name' => substr( |
| 136 | - $this->_format_partial_payment_line_item_name( $payment ), |
|
| 136 | + $this->_format_partial_payment_line_item_name($payment), |
|
| 137 | 137 | 0, |
| 138 | 138 | 127 |
| 139 | 139 | ), |
| 140 | 140 | // Item description. 127 char max. |
| 141 | 141 | 'l_desc' => substr( |
| 142 | - $this->_format_partial_payment_line_item_desc( $payment ), |
|
| 142 | + $this->_format_partial_payment_line_item_desc($payment), |
|
| 143 | 143 | 0, |
| 144 | 144 | 127 |
| 145 | 145 | ), |
@@ -187,11 +187,11 @@ discard block |
||
| 187 | 187 | // Payer's salutation. 20 char max. |
| 188 | 188 | 'salutation' => '', |
| 189 | 189 | // Payer's first name. 25 char max. |
| 190 | - 'firstname' => substr($billing_info['first_name'],0,25), |
|
| 190 | + 'firstname' => substr($billing_info['first_name'], 0, 25), |
|
| 191 | 191 | // Payer's middle name. 25 char max. |
| 192 | 192 | 'middlename' => '', |
| 193 | 193 | // Payer's last name. 25 char max. |
| 194 | - 'lastname' => substr($billing_info['last_name'],0,25), |
|
| 194 | + 'lastname' => substr($billing_info['last_name'], 0, 25), |
|
| 195 | 195 | // Payer's suffix. 12 char max. |
| 196 | 196 | 'suffix' => '' |
| 197 | 197 | ); |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | // Required. Name of City. |
| 205 | 205 | 'city' => $billing_info['city'], |
| 206 | 206 | // Required. Name of State or Province. |
| 207 | - 'state' => substr( $billing_info['state'], 0, 40 ), |
|
| 207 | + 'state' => substr($billing_info['state'], 0, 40), |
|
| 208 | 208 | // Required. Country code. |
| 209 | 209 | 'countrycode' => $billing_info['country'], |
| 210 | 210 | // Required. Postal code of payer. |
| 211 | 211 | 'zip' => $billing_info['zip'], |
| 212 | 212 | // Phone Number of payer. 20 char max. |
| 213 | - 'shiptophonenum' => substr($billing_info['phone'],0,20) |
|
| 213 | + 'shiptophonenum' => substr($billing_info['phone'], 0, 20) |
|
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | 216 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | // Required. Three-letter currency code. Default is USD. |
| 221 | 221 | 'currencycode' => $payment->currency_code(), |
| 222 | 222 | // Required if you include itemized cart details. (L_AMTn, etc.) Subtotal of items not including S&H, or tax. |
| 223 | - 'itemamt' => $this->format_currency($item_amount),// |
|
| 223 | + 'itemamt' => $this->format_currency($item_amount), // |
|
| 224 | 224 | // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
| 225 | 225 | 'shippingamt' => '', |
| 226 | 226 | // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
@@ -232,10 +232,10 @@ discard block |
||
| 232 | 232 | // Free-form field for your own use. 256 char max. |
| 233 | 233 | 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
| 234 | 234 | // Your own invoice or tracking number |
| 235 | - 'invnum' => wp_generate_password(12,false),//$transaction->ID(), |
|
| 235 | + 'invnum' => wp_generate_password(12, false), //$transaction->ID(), |
|
| 236 | 236 | // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
| 237 | 237 | 'notifyurl' => '', |
| 238 | - 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
| 238 | + 'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this |
|
| 239 | 239 | ); |
| 240 | 240 | // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
| 241 | 241 | $PayPalRequestData = array( |
@@ -248,32 +248,32 @@ discard block |
||
| 248 | 248 | 'OrderItems' => $order_items, |
| 249 | 249 | ); |
| 250 | 250 | $this->_log_clean_request($PayPalRequestData, $payment); |
| 251 | - try{ |
|
| 251 | + try { |
|
| 252 | 252 | $PayPalResult = $this->prep_and_curl_request($PayPalRequestData); |
| 253 | 253 | //remove PCI-sensitive data so it doesn't get stored |
| 254 | - $PayPalResult = $this->_log_clean_response($PayPalResult,$payment); |
|
| 254 | + $PayPalResult = $this->_log_clean_response($PayPalResult, $payment); |
|
| 255 | 255 | |
| 256 | 256 | $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK']; |
| 257 | - if( empty($PayPalResult[ 'RAWRESPONSE' ] ) ) { |
|
| 258 | - $payment->set_status( $this->_pay_model->failed_status() ) ; |
|
| 259 | - $payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) ); |
|
| 257 | + if (empty($PayPalResult['RAWRESPONSE'])) { |
|
| 258 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 259 | + $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso')); |
|
| 260 | 260 | $payment->set_details($PayPalResult); |
| 261 | - }else{ |
|
| 262 | - if($this->_APICallSuccessful($PayPalResult)){ |
|
| 261 | + } else { |
|
| 262 | + if ($this->_APICallSuccessful($PayPalResult)) { |
|
| 263 | 263 | $payment->set_status($this->_pay_model->approved_status()); |
| 264 | - }else{ |
|
| 264 | + } else { |
|
| 265 | 265 | $payment->set_status($this->_pay_model->declined_status()); |
| 266 | 266 | } |
| 267 | 267 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
| 268 | - $payment->set_amount(isset($PayPalResult['AMT']) ? floatval( $PayPalResult['AMT'] ) : 0); |
|
| 268 | + $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0); |
|
| 269 | 269 | $payment->set_gateway_response($message); |
| 270 | - $payment->set_txn_id_chq_nmbr(isset( $PayPalResult['TRANSACTIONID'] )? $PayPalResult['TRANSACTIONID'] : null); |
|
| 270 | + $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null); |
|
| 271 | 271 | |
| 272 | 272 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
| 273 | 273 | $payment->set_extra_accntng($primary_registration_code); |
| 274 | 274 | $payment->set_details($PayPalResult); |
| 275 | 275 | } |
| 276 | - }catch(Exception $e){ |
|
| 276 | + } catch (Exception $e) { |
|
| 277 | 277 | $payment->set_status($this->_pay_model->failed_status()); |
| 278 | 278 | $payment->set_gateway_response($e->getMessage()); |
| 279 | 279 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @param EEI_Payment $payment |
| 291 | 291 | * @return array |
| 292 | 292 | */ |
| 293 | - private function _log_clean_request($request,$payment){ |
|
| 293 | + private function _log_clean_request($request, $payment) { |
|
| 294 | 294 | $cleaned_request_data = $request; |
| 295 | 295 | unset($cleaned_request_data['CCDetails']['acct']); |
| 296 | 296 | unset($cleaned_request_data['CCDetails']['cvv2']); |
@@ -306,13 +306,13 @@ discard block |
||
| 306 | 306 | * @param EEI_Payment $payment |
| 307 | 307 | * @return array cleaned |
| 308 | 308 | */ |
| 309 | - private function _log_clean_response($response,$payment){ |
|
| 309 | + private function _log_clean_response($response, $payment) { |
|
| 310 | 310 | unset($response['REQUESTDATA']['CREDITCARDTYPE']); |
| 311 | 311 | unset($response['REQUESTDATA']['ACCT']); |
| 312 | 312 | unset($response['REQUESTDATA']['EXPDATE']); |
| 313 | 313 | unset($response['REQUESTDATA']['CVV2']); |
| 314 | 314 | unset($response['RAWREQUEST']); |
| 315 | - $this->log(array('Paypal Response'=>$response),$payment); |
|
| 315 | + $this->log(array('Paypal Response'=>$response), $payment); |
|
| 316 | 316 | return $response; |
| 317 | 317 | } |
| 318 | 318 | |
@@ -337,32 +337,32 @@ discard block |
||
| 337 | 337 | // DP Fields |
| 338 | 338 | $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
| 339 | 339 | foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) |
| 340 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
| 340 | + $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal); |
|
| 341 | 341 | |
| 342 | 342 | // CC Details Fields |
| 343 | 343 | $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
| 344 | 344 | foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) |
| 345 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
| 345 | + $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal); |
|
| 346 | 346 | |
| 347 | 347 | // PayerInfo Type Fields |
| 348 | 348 | $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
| 349 | 349 | foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) |
| 350 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
| 350 | + $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal); |
|
| 351 | 351 | |
| 352 | 352 | // Payer Name Fields |
| 353 | 353 | $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
| 354 | 354 | foreach ($PayerName as $PayerNameVar => $PayerNameVal) |
| 355 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
| 355 | + $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal); |
|
| 356 | 356 | |
| 357 | 357 | // Address Fields (Billing) |
| 358 | 358 | $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
| 359 | 359 | foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) |
| 360 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
| 360 | + $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal); |
|
| 361 | 361 | |
| 362 | 362 | // Payment Details Type Fields |
| 363 | 363 | $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
| 364 | 364 | foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) |
| 365 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
| 365 | + $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal); |
|
| 366 | 366 | |
| 367 | 367 | // Payment Details Item Type Fields |
| 368 | 368 | $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
@@ -370,22 +370,22 @@ discard block |
||
| 370 | 370 | foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
| 371 | 371 | $CurrentItem = $OrderItems[$OrderItemsVar]; |
| 372 | 372 | foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) |
| 373 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
| 373 | + $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal); |
|
| 374 | 374 | $n++; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | // Ship To Address Fields |
| 378 | 378 | $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
| 379 | 379 | foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) |
| 380 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
| 380 | + $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal); |
|
| 381 | 381 | |
| 382 | 382 | // 3D Secure Fields |
| 383 | 383 | $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
| 384 | 384 | foreach ($Secure3D as $Secure3DVar => $Secure3DVal) |
| 385 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
| 385 | + $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal); |
|
| 386 | 386 | |
| 387 | 387 | // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
| 388 | - $NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP; |
|
| 388 | + $NVPRequest = 'USER='.$this->_username.'&PWD='.$this->_password.'&VERSION=64.0'.'&SIGNATURE='.$this->_signature.$DPFieldsNVP.$CCDetailsNVP.$PayerInfoNVP.$PayerNameNVP.$BillingAddressNVP.$PaymentDetailsNVP.$OrderItemsNVP.$ShippingAddressNVP.$Secure3DNVP; |
|
| 389 | 389 | $NVPResponse = $this->_CURLRequest($NVPRequest); |
| 390 | 390 | $NVPRequestArray = $this->_NVPToArray($NVPRequest); |
| 391 | 391 | $NVPResponseArray = $this->_NVPToArray($NVPResponse); |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | private function _CURLRequest($Request) { |
| 410 | 410 | $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; |
| 411 | 411 | $curl = curl_init(); |
| 412 | - curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE ) ); |
|
| 412 | + curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE)); |
|
| 413 | 413 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); |
| 414 | 414 | curl_setopt($curl, CURLOPT_TIMEOUT, 60); |
| 415 | 415 | curl_setopt($curl, CURLOPT_URL, $EndPointURL); |
@@ -459,9 +459,9 @@ discard block |
||
| 459 | 459 | private function _APICallSuccessful($PayPalResult) { |
| 460 | 460 | $approved = false; |
| 461 | 461 | // check main response message from PayPal |
| 462 | - if (isset($PayPalResult['ACK']) && !empty($PayPalResult['ACK'])) { |
|
| 462 | + if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) { |
|
| 463 | 463 | $ack = strtoupper($PayPalResult['ACK']); |
| 464 | - $approved = ( $ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS' ) ? true : false; |
|
| 464 | + $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false; |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | return $approved; |
@@ -477,11 +477,11 @@ discard block |
||
| 477 | 477 | |
| 478 | 478 | $Errors = array(); |
| 479 | 479 | $n = 0; |
| 480 | - while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
| 481 | - $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
| 482 | - $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : ''; |
|
| 483 | - $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : ''; |
|
| 484 | - $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : ''; |
|
| 480 | + while (isset($DataArray['L_ERRORCODE'.$n.''])) { |
|
| 481 | + $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : ''; |
|
| 482 | + $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : ''; |
|
| 483 | + $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : ''; |
|
| 484 | + $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : ''; |
|
| 485 | 485 | |
| 486 | 486 | $CurrentItem = array( |
| 487 | 487 | 'L_ERRORCODE' => $LErrorCode, |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | elseif ($CurrentErrorVar == 'L_SEVERITYCODE') |
| 522 | 522 | $CurrentVarName = 'Severity Code'; |
| 523 | 523 | |
| 524 | - $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
| 524 | + $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal; |
|
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | return $error; |