@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * ---------------------------------------------- |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Class constructor. |
19 | 19 | */ |
20 | - public function __construct( $pm_instance = NULL ) { |
|
21 | - require_once( $this->file_folder() . 'EEG_Paypal_Express.gateway.php' ); |
|
20 | + public function __construct($pm_instance = NULL) { |
|
21 | + require_once($this->file_folder().'EEG_Paypal_Express.gateway.php'); |
|
22 | 22 | $this->_gateway = new EEG_Paypal_Express(); |
23 | 23 | |
24 | - $this->_pretty_name = __( 'PayPal Express', 'event_espresso' ); |
|
25 | - $this->_template_path = $this->file_folder() . 'templates' . DS; |
|
26 | - $this->_default_description = __( 'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', 'event_espresso' ); |
|
27 | - $this->_default_button_url = $this->file_url() . 'lib' . DS . 'paypal-express-checkout-logo.png'; |
|
24 | + $this->_pretty_name = __('PayPal Express', 'event_espresso'); |
|
25 | + $this->_template_path = $this->file_folder().'templates'.DS; |
|
26 | + $this->_default_description = __('After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', 'event_espresso'); |
|
27 | + $this->_default_button_url = $this->file_url().'lib'.DS.'paypal-express-checkout-logo.png'; |
|
28 | 28 | |
29 | - parent::__construct( $pm_instance ); |
|
29 | + parent::__construct($pm_instance); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
@@ -58,34 +58,34 @@ discard block |
||
58 | 58 | 'extra_meta_inputs' => array( |
59 | 59 | 'api_username' => new EE_Text_Input( |
60 | 60 | array( |
61 | - 'html_label_text'=> sprintf( __( 'API Username %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
61 | + 'html_label_text'=> sprintf(__('API Username %s', 'event_espresso'), $this->get_help_tab_link()), |
|
62 | 62 | 'required' => true, |
63 | 63 | ) |
64 | 64 | ), |
65 | 65 | 'api_password' => new EE_Text_Input( |
66 | 66 | array( |
67 | - 'html_label_text' => sprintf( __( 'API Password %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
67 | + 'html_label_text' => sprintf(__('API Password %s', 'event_espresso'), $this->get_help_tab_link()), |
|
68 | 68 | 'required' => true |
69 | 69 | ) |
70 | 70 | ), |
71 | 71 | 'api_signature' => new EE_Text_Input( |
72 | 72 | array( |
73 | - 'html_label_text' => sprintf( __( 'API Signature %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
73 | + 'html_label_text' => sprintf(__('API Signature %s', 'event_espresso'), $this->get_help_tab_link()), |
|
74 | 74 | 'required' => true |
75 | 75 | ) |
76 | 76 | ), |
77 | 77 | 'request_shipping_addr' => new EE_Yes_No_Input( |
78 | 78 | array( |
79 | - 'html_label_text' => sprintf( __( 'Request Shipping Address %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
80 | - 'html_help_text' => __( 'If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', 'event_espresso' ), |
|
79 | + 'html_label_text' => sprintf(__('Request Shipping Address %s', 'event_espresso'), $this->get_help_tab_link()), |
|
80 | + 'html_help_text' => __('If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', 'event_espresso'), |
|
81 | 81 | 'required' => true, |
82 | 82 | 'default' => true, |
83 | 83 | ) |
84 | 84 | ), |
85 | 85 | 'image_url' => new EE_Admin_File_Uploader_Input( |
86 | 86 | array( |
87 | - 'html_label_text' => sprintf( __( 'Image URL %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
88 | - 'html_help_text' => __( 'Used for your business/personal logo on the PayPal page', 'event_espresso' ), |
|
87 | + 'html_label_text' => sprintf(__('Image URL %s', 'event_espresso'), $this->get_help_tab_link()), |
|
88 | + 'html_help_text' => __('Used for your business/personal logo on the PayPal page', 'event_espresso'), |
|
89 | 89 | 'required' => false |
90 | 90 | ) |
91 | 91 | ), |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @param \EE_Transaction $transaction |
103 | 103 | * @return \EE_Billing_Info_Form |
104 | 104 | */ |
105 | - public function generate_new_billing_form( EE_Transaction $transaction = null ) { |
|
106 | - if ( $this->_pm_instance->debug_mode() ) { |
|
105 | + public function generate_new_billing_form(EE_Transaction $transaction = null) { |
|
106 | + if ($this->_pm_instance->debug_mode()) { |
|
107 | 107 | $form = new EE_Billing_Info_Form( |
108 | 108 | $this->_pm_instance, |
109 | 109 | array( |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | array( |
114 | 114 | 'layout_strategy' => new EE_Template_Layout( |
115 | 115 | array( |
116 | - 'layout_template_file' => $this->_template_path . 'paypal_express_debug_info.template.php', |
|
117 | - 'template_args' => array( 'debug_mode' => $this->_pm_instance->debug_mode() ) |
|
116 | + 'layout_template_file' => $this->_template_path.'paypal_express_debug_info.template.php', |
|
117 | + 'template_args' => array('debug_mode' => $this->_pm_instance->debug_mode()) |
|
118 | 118 | ) |
119 | 119 | ) |
120 | 120 | ) |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <p> |
2 | - <strong><?php _e( 'PayPal Express Checkout', 'event_espresso' ); ?></strong> |
|
2 | + <strong><?php _e('PayPal Express Checkout', 'event_espresso'); ?></strong> |
|
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php _e('Please be sure to update the settings for the PayPal Express Checkout payment method.', 'event_espresso'); ?> |
6 | 6 | </p> |
7 | 7 | <p> |
8 | - <?php printf( __('For more information on how to get your API credentials, please view the %1$sPayPal Documentation%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com/docs/classic/api/apiCredentials/#create-an-api-signature">', '</a>' ); ?> |
|
8 | + <?php printf(__('For more information on how to get your API credentials, please view the %1$sPayPal Documentation%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com/docs/classic/api/apiCredentials/#create-an-api-signature">', '</a>'); ?> |
|
9 | 9 | </p> |
10 | 10 | |
11 | 11 | |
@@ -14,25 +14,25 @@ discard block |
||
14 | 14 | </p> |
15 | 15 | <ul> |
16 | 16 | <li> |
17 | - <strong><?php _e( 'API Username', 'event_espresso' ); ?></strong><br/> |
|
18 | - <?php _e( 'Your PayPal API Username.'); ?> |
|
17 | + <strong><?php _e('API Username', 'event_espresso'); ?></strong><br/> |
|
18 | + <?php _e('Your PayPal API Username.'); ?> |
|
19 | 19 | </li> |
20 | 20 | <li> |
21 | - <strong><?php _e( 'API Password', 'event_espresso' ); ?></strong><br/> |
|
22 | - <?php _e( 'Your PayPal API Password.' ); ?> |
|
21 | + <strong><?php _e('API Password', 'event_espresso'); ?></strong><br/> |
|
22 | + <?php _e('Your PayPal API Password.'); ?> |
|
23 | 23 | </li> |
24 | 24 | <li> |
25 | - <strong><?php _e( 'API Signature', 'event_espresso' ); ?></strong><br/> |
|
26 | - <?php _e( 'Your PayPal Account Signature.' ); ?> |
|
25 | + <strong><?php _e('API Signature', 'event_espresso'); ?></strong><br/> |
|
26 | + <?php _e('Your PayPal Account Signature.'); ?> |
|
27 | 27 | </li> |
28 | 28 | <li> |
29 | - <strong><?php _e( 'Request Shipping Address', 'event_espresso' ); ?></strong><br/> |
|
30 | - <?php _e( 'Indicates whether or not you require the buyer\'s shipping address on file with PayPal be a confirmed address.' ); ?> |
|
29 | + <strong><?php _e('Request Shipping Address', 'event_espresso'); ?></strong><br/> |
|
30 | + <?php _e('Indicates whether or not you require the buyer\'s shipping address on file with PayPal be a confirmed address.'); ?> |
|
31 | 31 | </li> |
32 | 32 | </ul> |
33 | 33 | <p> |
34 | - <?php printf( __('For testing please use a %1$s PaypPal Sandbox account%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com">', '</a>' ); ?> |
|
34 | + <?php printf(__('For testing please use a %1$s PaypPal Sandbox account%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com">', '</a>'); ?> |
|
35 | 35 | </p> |
36 | 36 | <p> |
37 | - <?php printf( __('Don\'t have PayPal? %1$sSign up for an account%2$s to get start right away.', 'event_espresso'), '<a target="_blank" href="hhttps://eventespresso.com/go/paypalstandard/">', '</a>' ); ?> |
|
37 | + <?php printf(__('Don\'t have PayPal? %1$sSign up for an account%2$s to get start right away.', 'event_espresso'), '<a target="_blank" href="hhttps://eventespresso.com/go/paypalstandard/">', '</a>'); ?> |
|
38 | 38 | </p> |
39 | 39 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * ---------------------------------------------- |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @param type $settings_array |
84 | 84 | */ |
85 | - public function set_settings( $settings_array ) { |
|
85 | + public function set_settings($settings_array) { |
|
86 | 86 | parent::set_settings($settings_array); |
87 | 87 | // Redirect URL. |
88 | - if ( $this->_debug_mode ) { |
|
88 | + if ($this->_debug_mode) { |
|
89 | 89 | $this->_base_gateway_url = 'https://api-3t.sandbox.paypal.com/nvp'; |
90 | 90 | } else { |
91 | 91 | $this->_base_gateway_url = 'https://api-3t.paypal.com/nvp'; |
@@ -100,19 +100,19 @@ discard block |
||
100 | 100 | * @param type $return_url |
101 | 101 | * @param type $cancel_url |
102 | 102 | */ |
103 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
|
104 | - if ( ! $payment instanceof EEI_Payment ) { |
|
105 | - $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
|
106 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
103 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
104 | + if ( ! $payment instanceof EEI_Payment) { |
|
105 | + $payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso')); |
|
106 | + $payment->set_status($this->_pay_model->failed_status()); |
|
107 | 107 | return $payment; |
108 | 108 | } |
109 | 109 | $transaction = $payment->transaction(); |
110 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
111 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
112 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
110 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
111 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
112 | + $payment->set_status($this->_pay_model->failed_status()); |
|
113 | 113 | return $payment; |
114 | 114 | } |
115 | - $order_description = substr( sprintf( __('Event Registrations from %s', 'event_espresso'), get_bloginfo('name') ), 0, 127 ); |
|
115 | + $order_description = substr(sprintf(__('Event Registrations from %s', 'event_espresso'), get_bloginfo('name')), 0, 127); |
|
116 | 116 | $primary_registration = $transaction->primary_registration(); |
117 | 117 | $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false; |
118 | 118 | $locale = explode('-', get_bloginfo('language')); |
@@ -126,28 +126,28 @@ discard block |
||
126 | 126 | 'RETURNURL' => $return_url, |
127 | 127 | 'CANCELURL' => $cancel_url, |
128 | 128 | 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
129 | - 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
130 | - 'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this |
|
129 | + 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
130 | + 'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this |
|
131 | 131 | 'LOCALECODE' => $locale[1] // Locale of the pages displayed by PayPal during Express Checkout. |
132 | 132 | ); |
133 | 133 | |
134 | 134 | // Show itemized list. |
135 | - if ( EEH_Money::compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
135 | + if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
136 | 136 | $item_num = 0; |
137 | 137 | $itemized_sum = 0; |
138 | 138 | $total_line_items = $transaction->total_line_item(); |
139 | 139 | // Go through each item in the list. |
140 | - foreach ( $total_line_items->get_items() as $line_item ) { |
|
141 | - if ( $line_item instanceof EE_Line_Item ) { |
|
140 | + foreach ($total_line_items->get_items() as $line_item) { |
|
141 | + if ($line_item instanceof EE_Line_Item) { |
|
142 | 142 | // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
143 | - if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) { |
|
143 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
147 | 147 | $unit_price = $line_item->unit_price(); |
148 | 148 | $line_item_quantity = $line_item->quantity(); |
149 | 149 | // This is a discount. |
150 | - if ( $line_item->is_percent() ) { |
|
150 | + if ($line_item->is_percent()) { |
|
151 | 151 | $unit_price = $line_item->total(); |
152 | 152 | $line_item_quantity = 1; |
153 | 153 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | // Item description. |
157 | 157 | $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($line_item->desc(), 0, 127); |
158 | 158 | // Cost of individual item. |
159 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price ); |
|
159 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price); |
|
160 | 160 | // Item Number. |
161 | 161 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
162 | 162 | // Item quantity. |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
174 | 174 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
175 | 175 | |
176 | - $itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 ); |
|
176 | + $itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2); |
|
177 | 177 | // If we were not able to recognize some item like promotion, surcharge or cancellation, |
178 | 178 | // add the difference as an extra line item. |
179 | - if ( $itemized_sum_diff_from_txn_total != 0 ) { |
|
179 | + if ($itemized_sum_diff_from_txn_total != 0) { |
|
180 | 180 | // Item Name. |
181 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 ); |
|
181 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127); |
|
182 | 182 | // Item description. |
183 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr( $line_item->desc(), 0, 127 ); |
|
183 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($line_item->desc(), 0, 127); |
|
184 | 184 | // Cost of individual item. |
185 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
185 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
186 | 186 | // Item Number. |
187 | 187 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
188 | 188 | // Item quantity. |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | } else { |
193 | 193 | // Just one Item. |
194 | 194 | // Item Name. |
195 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( sprintf( __('Payment for %1$s', 'event_espresso'), $primary_registration->reg_code() ), 0, 127 ); |
|
195 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr(sprintf(__('Payment for %1$s', 'event_espresso'), $primary_registration->reg_code()), 0, 127); |
|
196 | 196 | // Item description. |
197 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( sprintf( __('Payment of %1$s for %2$s', 'event_espresso'), $payment->amount(), $primary_registration->reg_code() ), 0, 127 ); |
|
197 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr(sprintf(__('Payment of %1$s for %2$s', 'event_espresso'), $payment->amount(), $primary_registration->reg_code()), 0, 127); |
|
198 | 198 | // Cost of individual item. |
199 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() ); |
|
199 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
200 | 200 | // Item Number. |
201 | 201 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
202 | 202 | // Item quantity. |
@@ -204,14 +204,14 @@ discard block |
||
204 | 204 | // Digital item is sold. |
205 | 205 | $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
206 | 206 | // Item's sales S/H and tax amount. |
207 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() ); |
|
207 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
208 | 208 | $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
209 | 209 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
210 | 210 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
211 | 211 | } |
212 | 212 | // Automatically filling out shipping and contact information. |
213 | - if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) { |
|
214 | - $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
213 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
214 | + $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
215 | 215 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
216 | 216 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
217 | 217 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
@@ -220,34 +220,34 @@ discard block |
||
220 | 220 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
221 | 221 | $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
222 | 222 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
223 | - } elseif ( ! $this->_request_shipping_addr ) { |
|
223 | + } elseif ( ! $this->_request_shipping_addr) { |
|
224 | 224 | // Do not request shipping details on the PP Checkout page. |
225 | 225 | $token_request_dtls['NOSHIPPING'] = '1'; |
226 | 226 | $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
227 | 227 | |
228 | 228 | } |
229 | 229 | // Used a business/personal logo on the PayPal page. |
230 | - if ( ! empty($this->_image_url) ) { |
|
230 | + if ( ! empty($this->_image_url)) { |
|
231 | 231 | $token_request_dtls['LOGOIMG'] = $this->_image_url; |
232 | 232 | } |
233 | 233 | // Request PayPal token. |
234 | - $token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment ); |
|
235 | - $token_rstatus = $this->_ppExpress_check_response( $token_request_response ); |
|
236 | - $response_args = ( isset($token_rstatus['args']) ) ? $token_rstatus['args'] : array(); |
|
237 | - if ( $token_rstatus['status'] ) { |
|
234 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
235 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
236 | + $response_args = (isset($token_rstatus['args'])) ? $token_rstatus['args'] : array(); |
|
237 | + if ($token_rstatus['status']) { |
|
238 | 238 | // We got the Token so we may continue with the payment and redirect the client. |
239 | - $payment->set_details( $response_args ); |
|
239 | + $payment->set_details($response_args); |
|
240 | 240 | |
241 | - $gateway_url = ( $this->_debug_mode ) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
|
242 | - $payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] ); |
|
241 | + $gateway_url = ($this->_debug_mode) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
|
242 | + $payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']); |
|
243 | 243 | } else { |
244 | - if ( isset($response_args['L_ERRORCODE']) ) { |
|
245 | - $payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] ); |
|
244 | + if (isset($response_args['L_ERRORCODE'])) { |
|
245 | + $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']); |
|
246 | 246 | } else { |
247 | - $payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) ); |
|
247 | + $payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso')); |
|
248 | 248 | } |
249 | - $payment->set_details( $response_args ); |
|
250 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
249 | + $payment->set_details($response_args); |
|
250 | + $payment->set_status($this->_pay_model->failed_status()); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | return $payment; |
@@ -263,24 +263,24 @@ discard block |
||
263 | 263 | * @param type $transaction |
264 | 264 | * @return EEI_Payment |
265 | 265 | */ |
266 | - public function handle_payment_update( $update_info, $transaction ) { |
|
267 | - $payment = ( $transaction instanceof EEI_Transaction ) ? $transaction->last_payment() : null; |
|
266 | + public function handle_payment_update($update_info, $transaction) { |
|
267 | + $payment = ($transaction instanceof EEI_Transaction) ? $transaction->last_payment() : null; |
|
268 | 268 | |
269 | - if ( $payment instanceof EEI_Payment ) { |
|
270 | - $this->log( array( 'Return from Authorization' => $update_info ), $payment ); |
|
269 | + if ($payment instanceof EEI_Payment) { |
|
270 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
271 | 271 | |
272 | 272 | $payment_details = $payment->details(); |
273 | 273 | $transaction = $payment->transaction(); |
274 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
275 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
276 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
274 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
275 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
276 | + $payment->set_status($this->_pay_model->failed_status()); |
|
277 | 277 | return $payment; |
278 | 278 | } |
279 | 279 | $primary_registrant = $transaction->primary_registration(); |
280 | 280 | |
281 | 281 | // Check if we still have the token. |
282 | - if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
|
283 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
282 | + if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
283 | + $payment->set_status($this->_pay_model->failed_status()); |
|
284 | 284 | return $payment; |
285 | 285 | } |
286 | 286 | |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | 'TOKEN' => $payment_details['TOKEN'] |
290 | 290 | ); |
291 | 291 | // Request Customer Details. |
292 | - $cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment ); |
|
293 | - $cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response ); |
|
294 | - $cdata_response_args = ( isset($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array(); |
|
295 | - if ( $cdetails_rstatus['status'] ) { |
|
292 | + $cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment); |
|
293 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
294 | + $cdata_response_args = (isset($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array(); |
|
295 | + if ($cdetails_rstatus['status']) { |
|
296 | 296 | // We got the PayerID so now we can Complete the transaction. |
297 | 297 | $docheckout_request_dtls = array( |
298 | 298 | 'METHOD' => 'DoExpressCheckoutPayment', |
@@ -303,39 +303,39 @@ discard block |
||
303 | 303 | 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code() |
304 | 304 | ); |
305 | 305 | // Payment Checkout/Capture. |
306 | - $docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment ); |
|
307 | - $docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response ); |
|
308 | - $docheckout_response_args = ( isset($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array(); |
|
309 | - if ( $docheckout_rstatus['status'] ) { |
|
306 | + $docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment); |
|
307 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
308 | + $docheckout_response_args = (isset($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array(); |
|
309 | + if ($docheckout_rstatus['status']) { |
|
310 | 310 | // All is well, payment approved. |
311 | 311 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
312 | - $payment->set_extra_accntng( $primary_registration_code ); |
|
313 | - $payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? floatval( $docheckout_response_args['PAYMENTINFO_0_AMT'] ) : 0 ); |
|
314 | - $payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null ); |
|
315 | - $payment->set_details( $cdata_response_args ); |
|
316 | - $payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' ); |
|
317 | - $payment->set_status( $this->_pay_model->approved_status() ); |
|
312 | + $payment->set_extra_accntng($primary_registration_code); |
|
313 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? floatval($docheckout_response_args['PAYMENTINFO_0_AMT']) : 0); |
|
314 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null); |
|
315 | + $payment->set_details($cdata_response_args); |
|
316 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : ''); |
|
317 | + $payment->set_status($this->_pay_model->approved_status()); |
|
318 | 318 | } else { |
319 | - if ( isset($docheckout_response_args['L_ERRORCODE']) ) { |
|
320 | - $payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] ); |
|
319 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
320 | + $payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']); |
|
321 | 321 | } else { |
322 | - $payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) ); |
|
322 | + $payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso')); |
|
323 | 323 | } |
324 | - $payment->set_details( $docheckout_response_args ); |
|
325 | - $payment->set_status( $this->_pay_model->declined_status() ); |
|
324 | + $payment->set_details($docheckout_response_args); |
|
325 | + $payment->set_status($this->_pay_model->declined_status()); |
|
326 | 326 | } |
327 | 327 | } else { |
328 | - if ( isset($cdata_response_args['L_ERRORCODE']) ) { |
|
329 | - $payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] ); |
|
328 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
329 | + $payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']); |
|
330 | 330 | } else { |
331 | - $payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) ); |
|
331 | + $payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso')); |
|
332 | 332 | } |
333 | - $payment->set_details( $cdata_response_args ); |
|
334 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
333 | + $payment->set_details($cdata_response_args); |
|
334 | + $payment->set_status($this->_pay_model->failed_status()); |
|
335 | 335 | } |
336 | 336 | } else { |
337 | - $payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) ); |
|
338 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
337 | + $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
338 | + $payment->set_status($this->_pay_model->failed_status()); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $payment; |
@@ -350,16 +350,16 @@ discard block |
||
350 | 350 | * @param EEI_Payment $payment |
351 | 351 | * @return mixed |
352 | 352 | */ |
353 | - public function _ppExpress_request( $request_params, $request_text, $payment ) { |
|
353 | + public function _ppExpress_request($request_params, $request_text, $payment) { |
|
354 | 354 | $request_dtls = array( |
355 | 355 | 'VERSION' => '204.0', |
356 | - 'USER' => urlencode( $this->_api_username ), |
|
357 | - 'PWD' => urlencode( $this->_api_password ), |
|
358 | - 'SIGNATURE' => urlencode( $this->_api_signature ) |
|
356 | + 'USER' => urlencode($this->_api_username), |
|
357 | + 'PWD' => urlencode($this->_api_password), |
|
358 | + 'SIGNATURE' => urlencode($this->_api_signature) |
|
359 | 359 | ); |
360 | - $dtls = array_merge( $request_dtls, $request_params ); |
|
360 | + $dtls = array_merge($request_dtls, $request_params); |
|
361 | 361 | |
362 | - $this->_log_clean_request( $dtls, $payment, $request_text . ' Request' ); |
|
362 | + $this->_log_clean_request($dtls, $payment, $request_text.' Request'); |
|
363 | 363 | // Request Customer Details. |
364 | 364 | $request_response = wp_remote_post( |
365 | 365 | $this->_base_gateway_url, |
@@ -369,11 +369,11 @@ discard block |
||
369 | 369 | 'httpversion' => '1.1', |
370 | 370 | 'cookies' => array(), |
371 | 371 | 'headers' => array(), |
372 | - 'body' => http_build_query( $dtls ) |
|
372 | + 'body' => http_build_query($dtls) |
|
373 | 373 | ) |
374 | 374 | ); |
375 | 375 | // Log the response. |
376 | - $this->log( array( $request_text . ' Response' => $request_response), $payment ); |
|
376 | + $this->log(array($request_text.' Response' => $request_response), $payment); |
|
377 | 377 | |
378 | 378 | return $request_response; |
379 | 379 | } |
@@ -385,31 +385,31 @@ discard block |
||
385 | 385 | * @param mixed $request_response |
386 | 386 | * @return array |
387 | 387 | */ |
388 | - public function _ppExpress_check_response( $request_response ) { |
|
389 | - if ( ! is_wp_error( $request_response ) && $request_response['body'] && ! empty($request_response['body'] ) ) { |
|
388 | + public function _ppExpress_check_response($request_response) { |
|
389 | + if ( ! is_wp_error($request_response) && $request_response['body'] && ! empty($request_response['body'])) { |
|
390 | 390 | $response_args = array(); |
391 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
392 | - if ( isset($response_args['ACK']) |
|
391 | + parse_str(urldecode($request_response['body']), $response_args); |
|
392 | + if (isset($response_args['ACK']) |
|
393 | 393 | && $response_args['ACK'] === 'Success' |
394 | - && ( isset($response_args['PAYERID']) |
|
394 | + && (isset($response_args['PAYERID']) |
|
395 | 395 | || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
396 | - || ( isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed' ) |
|
396 | + || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
397 | 397 | || isset($response_args['TOKEN']) |
398 | 398 | ) |
399 | 399 | ) { |
400 | 400 | // Response status OK, return response parameters for further processing. |
401 | 401 | return array('status' => true, 'args' => $response_args); |
402 | 402 | } else { |
403 | - if ( isset($response_args['ACK']) ) { |
|
403 | + if (isset($response_args['ACK'])) { |
|
404 | 404 | $errors = $this->_get_errors($response_args); |
405 | - return array( 'status' => false, 'args' => $errors ); |
|
405 | + return array('status' => false, 'args' => $errors); |
|
406 | 406 | } else { |
407 | - return array( 'status' => false, 'args' => $request_response ); |
|
407 | + return array('status' => false, 'args' => $request_response); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } else { |
411 | 411 | // If we got here then there was an error in this request. |
412 | - return array( 'status' => false, 'args' => $request_response ); |
|
412 | + return array('status' => false, 'args' => $request_response); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -422,12 +422,12 @@ discard block |
||
422 | 422 | * @param string $info |
423 | 423 | * @return void |
424 | 424 | */ |
425 | - private function _log_clean_request( $request_prms, $payment, $info ) { |
|
425 | + private function _log_clean_request($request_prms, $payment, $info) { |
|
426 | 426 | $cleaned_request_data = $request_prms; |
427 | 427 | unset($cleaned_request_data['PWD']); |
428 | 428 | unset($cleaned_request_data['USER']); |
429 | 429 | unset($cleaned_request_data['SIGNATURE']); |
430 | - $this->log( array($info => $cleaned_request_data), $payment ); |
|
430 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | |
@@ -437,16 +437,16 @@ discard block |
||
437 | 437 | * @param array $data_array |
438 | 438 | * @return array |
439 | 439 | */ |
440 | - private function _get_errors( $data_array ) { |
|
440 | + private function _get_errors($data_array) { |
|
441 | 441 | $errors = array(); |
442 | 442 | $n = 0; |
443 | - while ( isset($data_array['L_ERRORCODE' . $n . '']) ) { |
|
444 | - $l_error_code = isset($data_array['L_ERRORCODE' . $n . '']) ? $data_array['L_ERRORCODE' . $n . ''] : ''; |
|
445 | - $l_severity_code = isset($data_array['L_SEVERITYCODE' . $n . '']) ? $data_array['L_SEVERITYCODE' . $n . ''] : ''; |
|
446 | - $l_short_message = isset($data_array['L_SHORTMESSAGE' . $n . '']) ? $data_array['L_SHORTMESSAGE' . $n . ''] : ''; |
|
447 | - $l_long_message = isset($data_array['L_LONGMESSAGE' . $n . '']) ? $data_array['L_LONGMESSAGE' . $n . ''] : ''; |
|
443 | + while (isset($data_array['L_ERRORCODE'.$n.''])) { |
|
444 | + $l_error_code = isset($data_array['L_ERRORCODE'.$n.'']) ? $data_array['L_ERRORCODE'.$n.''] : ''; |
|
445 | + $l_severity_code = isset($data_array['L_SEVERITYCODE'.$n.'']) ? $data_array['L_SEVERITYCODE'.$n.''] : ''; |
|
446 | + $l_short_message = isset($data_array['L_SHORTMESSAGE'.$n.'']) ? $data_array['L_SHORTMESSAGE'.$n.''] : ''; |
|
447 | + $l_long_message = isset($data_array['L_LONGMESSAGE'.$n.'']) ? $data_array['L_LONGMESSAGE'.$n.''] : ''; |
|
448 | 448 | |
449 | - if ( $n == 0 ) { |
|
449 | + if ($n == 0) { |
|
450 | 450 | $errors = array( |
451 | 451 | 'L_ERRORCODE' => $l_error_code, |
452 | 452 | 'L_SHORTMESSAGE' => $l_short_message, |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | 'L_SEVERITYCODE' => $l_severity_code |
455 | 455 | ); |
456 | 456 | } else { |
457 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
458 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
459 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
460 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
457 | + $errors['L_ERRORCODE'] .= ', '.$l_error_code; |
|
458 | + $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message; |
|
459 | + $errors['L_LONGMESSAGE'] .= ', '.$l_long_message; |
|
460 | + $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code; |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | $n++; |