@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return bool |
24 | 24 | */ |
25 | -function give_paypal_standard_billing_fields( $form_id ) { |
|
25 | +function give_paypal_standard_billing_fields($form_id) { |
|
26 | 26 | |
27 | - if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) { |
|
28 | - give_default_cc_address_fields( $form_id ); |
|
27 | + if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
|
28 | + give_default_cc_address_fields($form_id); |
|
29 | 29 | |
30 | 30 | return true; |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | -add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' ); |
|
37 | +add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Process PayPal Payment. |
@@ -45,28 +45,28 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return void |
47 | 47 | */ |
48 | -function give_process_paypal_payment( $payment_data ) { |
|
48 | +function give_process_paypal_payment($payment_data) { |
|
49 | 49 | |
50 | 50 | // Validate nonce. |
51 | - give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' ); |
|
51 | + give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway'); |
|
52 | 52 | |
53 | - $payment_id = give_create_payment( $payment_data ); |
|
53 | + $payment_id = give_create_payment($payment_data); |
|
54 | 54 | |
55 | 55 | // Check payment. |
56 | - if ( empty( $payment_id ) ) { |
|
56 | + if (empty($payment_id)) { |
|
57 | 57 | // Record the error. |
58 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */ |
|
59 | - __( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id ); |
|
58 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */ |
|
59 | + __('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id); |
|
60 | 60 | // Problems? Send back. |
61 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
61 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | // Redirect to PayPal. |
65 | - wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) ); |
|
65 | + wp_redirect(give_build_paypal_url($payment_id, $payment_data)); |
|
66 | 66 | exit; |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
69 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Listens for a PayPal IPN requests and then sends to the processing function. |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | function give_listen_for_paypal_ipn() { |
78 | 78 | |
79 | 79 | // Regular PayPal IPN. |
80 | - if ( isset( $_GET['give-listener'] ) && 'IPN' === $_GET['give-listener'] ) { |
|
80 | + if (isset($_GET['give-listener']) && 'IPN' === $_GET['give-listener']) { |
|
81 | 81 | /** |
82 | 82 | * Fires while verifying PayPal IPN |
83 | 83 | * |
84 | 84 | * @since 1.0 |
85 | 85 | */ |
86 | - do_action( 'give_verify_paypal_ipn' ); |
|
86 | + do_action('give_verify_paypal_ipn'); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
90 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Process PayPal IPN |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | function give_process_paypal_ipn() { |
99 | 99 | |
100 | 100 | // Check the request method is POST. |
101 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
101 | + if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | $post_data = ''; |
107 | 107 | |
108 | 108 | // Fallback just in case post_max_size is lower than needed. |
109 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
110 | - $post_data = file_get_contents( 'php://input' ); |
|
109 | + if (ini_get('allow_url_fopen')) { |
|
110 | + $post_data = file_get_contents('php://input'); |
|
111 | 111 | } else { |
112 | 112 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough. |
113 | - ini_set( 'post_max_size', '12M' ); |
|
113 | + ini_set('post_max_size', '12M'); |
|
114 | 114 | } |
115 | 115 | // Start the encoded data collection with notification command. |
116 | 116 | $encoded_data = 'cmd=_notify-validate'; |
@@ -119,41 +119,41 @@ discard block |
||
119 | 119 | $arg_separator = give_get_php_arg_separator_output(); |
120 | 120 | |
121 | 121 | // Verify there is a post_data. |
122 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
122 | + if ($post_data || strlen($post_data) > 0) { |
|
123 | 123 | // Append the data. |
124 | - $encoded_data .= $arg_separator . $post_data; |
|
124 | + $encoded_data .= $arg_separator.$post_data; |
|
125 | 125 | } else { |
126 | 126 | // Check if POST is empty. |
127 | - if ( empty( $_POST ) ) { |
|
127 | + if (empty($_POST)) { |
|
128 | 128 | // Nothing to do. |
129 | 129 | return; |
130 | 130 | } else { |
131 | 131 | // Loop through each POST. |
132 | - foreach ( $_POST as $key => $value ) { |
|
132 | + foreach ($_POST as $key => $value) { |
|
133 | 133 | // Encode the value and append the data. |
134 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
134 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Convert collected post data to an array. |
140 | - parse_str( $encoded_data, $encoded_data_array ); |
|
140 | + parse_str($encoded_data, $encoded_data_array); |
|
141 | 141 | |
142 | - foreach ( $encoded_data_array as $key => $value ) { |
|
142 | + foreach ($encoded_data_array as $key => $value) { |
|
143 | 143 | |
144 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
145 | - $new_key = str_replace( '&', '&', $key ); |
|
146 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
144 | + if (false !== strpos($key, 'amp;')) { |
|
145 | + $new_key = str_replace('&', '&', $key); |
|
146 | + $new_key = str_replace('amp;', '&', $new_key); |
|
147 | 147 | |
148 | - unset( $encoded_data_array[ $key ] ); |
|
149 | - $encoded_data_array[ $new_key ] = $value; |
|
148 | + unset($encoded_data_array[$key]); |
|
149 | + $encoded_data_array[$new_key] = $value; |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | $api_response = false; |
154 | 154 | |
155 | 155 | // Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
156 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
156 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
157 | 157 | |
158 | 158 | $remote_post_vars = array( |
159 | 159 | 'method' => 'POST', |
@@ -173,25 +173,25 @@ discard block |
||
173 | 173 | ); |
174 | 174 | |
175 | 175 | // Validate the IPN. |
176 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
176 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
177 | 177 | |
178 | - if ( is_wp_error( $api_response ) ) { |
|
179 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
180 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
178 | + if (is_wp_error($api_response)) { |
|
179 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
180 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
181 | 181 | |
182 | 182 | return; // Something went wrong. |
183 | 183 | } |
184 | 184 | |
185 | - if ( 'VERIFIED' !== $api_response['body'] ) { |
|
186 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
187 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
185 | + if ('VERIFIED' !== $api_response['body']) { |
|
186 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
187 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
188 | 188 | |
189 | 189 | return; // Response not okay. |
190 | 190 | } |
191 | 191 | }// End if(). |
192 | 192 | |
193 | 193 | // Check if $post_data_array has been populated. |
194 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
194 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
@@ -200,28 +200,28 @@ discard block |
||
200 | 200 | 'payment_status' => '', |
201 | 201 | ); |
202 | 202 | |
203 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
203 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
204 | 204 | |
205 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
205 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
206 | 206 | $txn_type = $encoded_data_array['txn_type']; |
207 | 207 | |
208 | 208 | // Check for PayPal IPN Notifications and update data based on it. |
209 | - $current_timestamp = current_time( 'timestamp' ); |
|
209 | + $current_timestamp = current_time('timestamp'); |
|
210 | 210 | $paypal_ipn_vars = array( |
211 | - 'auth_status' => isset( $api_response['body'] ) ? $api_response['body'] : 'N/A', |
|
212 | - 'transaction_id' => isset( $encoded_data_array['txn_id'] ) ? $encoded_data_array['txn_id'] : 'N/A', |
|
211 | + 'auth_status' => isset($api_response['body']) ? $api_response['body'] : 'N/A', |
|
212 | + 'transaction_id' => isset($encoded_data_array['txn_id']) ? $encoded_data_array['txn_id'] : 'N/A', |
|
213 | 213 | 'payment_id' => $payment_id, |
214 | 214 | ); |
215 | - update_option( 'give_last_paypal_ipn_received', $paypal_ipn_vars, false ); |
|
216 | - give_insert_payment_note( $payment_id, sprintf( |
|
217 | - __( 'IPN received on %s at %s', 'give' ), |
|
218 | - date_i18n( 'm/d/Y', $current_timestamp ), |
|
219 | - date_i18n( 'H:i', $current_timestamp ) |
|
215 | + update_option('give_last_paypal_ipn_received', $paypal_ipn_vars, false); |
|
216 | + give_insert_payment_note($payment_id, sprintf( |
|
217 | + __('IPN received on %s at %s', 'give'), |
|
218 | + date_i18n('m/d/Y', $current_timestamp), |
|
219 | + date_i18n('H:i', $current_timestamp) |
|
220 | 220 | ) |
221 | 221 | ); |
222 | - give_update_meta( $payment_id, 'give_last_paypal_ipn_received', $current_timestamp ); |
|
222 | + give_update_meta($payment_id, 'give_last_paypal_ipn_received', $current_timestamp); |
|
223 | 223 | |
224 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
224 | + if (has_action('give_paypal_'.$txn_type)) { |
|
225 | 225 | /** |
226 | 226 | * Fires while processing PayPal IPN $txn_type. |
227 | 227 | * |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @param array $encoded_data_array Encoded data. |
233 | 233 | * @param int $payment_id Payment id. |
234 | 234 | */ |
235 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
235 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
236 | 236 | } else { |
237 | 237 | /** |
238 | 238 | * Fires while process PayPal IPN. |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | * @param array $encoded_data_array Encoded data. |
245 | 245 | * @param int $payment_id Payment id. |
246 | 246 | */ |
247 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
247 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
248 | 248 | } |
249 | 249 | exit; |
250 | 250 | } |
251 | 251 | |
252 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
252 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
253 | 253 | |
254 | 254 | /** |
255 | 255 | * Process web accept (one time) payment IPNs. |
@@ -261,99 +261,99 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return void |
263 | 263 | */ |
264 | -function give_process_paypal_web_accept( $data, $payment_id ) { |
|
264 | +function give_process_paypal_web_accept($data, $payment_id) { |
|
265 | 265 | |
266 | 266 | // Only allow through these transaction types. |
267 | - if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) { |
|
267 | + if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | |
271 | 271 | // Need $payment_id to continue. |
272 | - if ( empty( $payment_id ) ) { |
|
272 | + if (empty($payment_id)) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | 276 | // Collect donation payment details. |
277 | 277 | $paypal_amount = $data['mc_gross']; |
278 | - $payment_status = strtolower( $data['payment_status'] ); |
|
279 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
280 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
281 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
278 | + $payment_status = strtolower($data['payment_status']); |
|
279 | + $currency_code = strtolower($data['mc_currency']); |
|
280 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
281 | + $payment_meta = give_get_payment_meta($payment_id); |
|
282 | 282 | |
283 | 283 | // Must be a PayPal standard IPN. |
284 | - if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) { |
|
284 | + if ('paypal' !== give_get_payment_gateway($payment_id)) { |
|
285 | 285 | return; |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Verify payment recipient. |
289 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) { |
|
289 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) { |
|
290 | 290 | |
291 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
292 | - __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
293 | - give_update_payment_status( $payment_id, 'failed' ); |
|
294 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
291 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
292 | + __('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
293 | + give_update_payment_status($payment_id, 'failed'); |
|
294 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
295 | 295 | |
296 | 296 | return; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // Verify payment currency. |
300 | - if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) { |
|
300 | + if ($currency_code !== strtolower($payment_meta['currency'])) { |
|
301 | 301 | |
302 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
303 | - __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
304 | - give_update_payment_status( $payment_id, 'failed' ); |
|
305 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
302 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
303 | + __('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
304 | + give_update_payment_status($payment_id, 'failed'); |
|
305 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
306 | 306 | |
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | 310 | // Process refunds & reversed. |
311 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
312 | - give_process_paypal_refund( $data, $payment_id ); |
|
311 | + if ('refunded' === $payment_status || 'reversed' === $payment_status) { |
|
312 | + give_process_paypal_refund($data, $payment_id); |
|
313 | 313 | |
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Only complete payments once. |
318 | - if ( 'publish' === get_post_status( $payment_id ) ) { |
|
318 | + if ('publish' === get_post_status($payment_id)) { |
|
319 | 319 | return; |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Retrieve the total donation amount (before PayPal). |
323 | - $payment_amount = give_donation_amount( $payment_id ); |
|
323 | + $payment_amount = give_donation_amount($payment_id); |
|
324 | 324 | |
325 | 325 | // Check that the donation PP and local db amounts match. |
326 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
326 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
327 | 327 | // The prices don't match |
328 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
329 | - __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
330 | - give_update_payment_status( $payment_id, 'failed' ); |
|
331 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
328 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
329 | + __('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
330 | + give_update_payment_status($payment_id, 'failed'); |
|
331 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
332 | 332 | |
333 | 333 | return; |
334 | 334 | } |
335 | 335 | |
336 | 336 | // Process completed donations. |
337 | - if ( 'completed' === $payment_status || give_is_test_mode() ) { |
|
337 | + if ('completed' === $payment_status || give_is_test_mode()) { |
|
338 | 338 | |
339 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
340 | - __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
341 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
342 | - give_update_payment_status( $payment_id, 'publish' ); |
|
339 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
340 | + __('PayPal Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
341 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
342 | + give_update_payment_status($payment_id, 'publish'); |
|
343 | 343 | |
344 | - } elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) { |
|
344 | + } elseif ('pending' === $payment_status && isset($data['pending_reason'])) { |
|
345 | 345 | |
346 | 346 | // Look for possible pending reasons, such as an echeck. |
347 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
347 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
348 | 348 | |
349 | - if ( ! empty( $note ) ) { |
|
350 | - give_insert_payment_note( $payment_id, $note ); |
|
349 | + if ( ! empty($note)) { |
|
350 | + give_insert_payment_note($payment_id, $note); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | 354 | } |
355 | 355 | |
356 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 ); |
|
356 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2); |
|
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Process PayPal IPN Refunds |
@@ -365,35 +365,35 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return void |
367 | 367 | */ |
368 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
368 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
369 | 369 | |
370 | 370 | // Collect payment details. |
371 | - if ( empty( $payment_id ) ) { |
|
371 | + if (empty($payment_id)) { |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | 375 | // Only refund payments once. |
376 | - if ( 'refunded' === get_post_status( $payment_id ) ) { |
|
376 | + if ('refunded' === get_post_status($payment_id)) { |
|
377 | 377 | return; |
378 | 378 | } |
379 | 379 | |
380 | - $payment_amount = give_donation_amount( $payment_id ); |
|
380 | + $payment_amount = give_donation_amount($payment_id); |
|
381 | 381 | $refund_amount = $data['payment_gross'] * - 1; |
382 | 382 | |
383 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
383 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
384 | 384 | |
385 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
386 | - __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
385 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
386 | + __('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] )); |
|
387 | 387 | |
388 | 388 | return; // This is a partial refund |
389 | 389 | |
390 | 390 | } |
391 | 391 | |
392 | - give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
393 | - __( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
394 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
395 | - __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
396 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
392 | + give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
393 | + __('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] )); |
|
394 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
395 | + __('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
396 | + give_update_payment_status($payment_id, 'refunded'); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -405,24 +405,24 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return string |
407 | 407 | */ |
408 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
408 | +function give_get_paypal_redirect($ssl_check = false) { |
|
409 | 409 | |
410 | - if ( is_ssl() || ! $ssl_check ) { |
|
410 | + if (is_ssl() || ! $ssl_check) { |
|
411 | 411 | $protocol = 'https://'; |
412 | 412 | } else { |
413 | 413 | $protocol = 'http://'; |
414 | 414 | } |
415 | 415 | |
416 | 416 | // Check the current payment mode |
417 | - if ( give_is_test_mode() ) { |
|
417 | + if (give_is_test_mode()) { |
|
418 | 418 | // Test mode |
419 | - $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
419 | + $paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
420 | 420 | } else { |
421 | 421 | // Live mode |
422 | - $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
|
422 | + $paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr'; |
|
423 | 423 | } |
424 | 424 | |
425 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
425 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -432,9 +432,9 @@ discard block |
||
432 | 432 | * @return string |
433 | 433 | */ |
434 | 434 | function give_get_paypal_page_style() { |
435 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
435 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
436 | 436 | |
437 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
437 | + return apply_filters('give_paypal_page_style', $page_style); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
@@ -448,26 +448,26 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return string |
450 | 450 | */ |
451 | -function give_paypal_success_page_content( $content ) { |
|
451 | +function give_paypal_success_page_content($content) { |
|
452 | 452 | |
453 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
453 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
454 | 454 | return $content; |
455 | 455 | } |
456 | 456 | |
457 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
457 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
458 | 458 | |
459 | - if ( ! $payment_id ) { |
|
459 | + if ( ! $payment_id) { |
|
460 | 460 | $session = give_get_purchase_session(); |
461 | - $payment_id = give_get_donation_id_by_key( $session['purchase_key'] ); |
|
461 | + $payment_id = give_get_donation_id_by_key($session['purchase_key']); |
|
462 | 462 | } |
463 | 463 | |
464 | - $payment = get_post( $payment_id ); |
|
465 | - if ( $payment && 'pending' === $payment->post_status ) { |
|
464 | + $payment = get_post($payment_id); |
|
465 | + if ($payment && 'pending' === $payment->post_status) { |
|
466 | 466 | |
467 | 467 | // Payment is still pending so show processing indicator to fix the race condition. |
468 | 468 | ob_start(); |
469 | 469 | |
470 | - give_get_template_part( 'payment', 'processing' ); |
|
470 | + give_get_template_part('payment', 'processing'); |
|
471 | 471 | |
472 | 472 | $content = ob_get_clean(); |
473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | |
478 | 478 | } |
479 | 479 | |
480 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
480 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
481 | 481 | |
482 | 482 | /** |
483 | 483 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -489,16 +489,16 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return string A link to the PayPal transaction details |
491 | 491 | */ |
492 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
492 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
493 | 493 | |
494 | 494 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
495 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
495 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
496 | 496 | |
497 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
497 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
498 | 498 | |
499 | 499 | } |
500 | 500 | |
501 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
501 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
502 | 502 | |
503 | 503 | |
504 | 504 | /** |
@@ -510,64 +510,64 @@ discard block |
||
510 | 510 | * |
511 | 511 | * @return string |
512 | 512 | */ |
513 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
513 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
514 | 514 | |
515 | 515 | $note = ''; |
516 | 516 | |
517 | - switch ( $pending_reason ) { |
|
517 | + switch ($pending_reason) { |
|
518 | 518 | |
519 | 519 | case 'echeck' : |
520 | 520 | |
521 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
521 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
522 | 522 | |
523 | 523 | break; |
524 | 524 | |
525 | 525 | case 'address' : |
526 | 526 | |
527 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
527 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
528 | 528 | |
529 | 529 | break; |
530 | 530 | |
531 | 531 | case 'intl' : |
532 | 532 | |
533 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
533 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
534 | 534 | |
535 | 535 | break; |
536 | 536 | |
537 | 537 | case 'multi-currency' : |
538 | 538 | |
539 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
539 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
540 | 540 | |
541 | 541 | break; |
542 | 542 | |
543 | 543 | case 'paymentreview' : |
544 | 544 | case 'regulatory_review' : |
545 | 545 | |
546 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
546 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
547 | 547 | |
548 | 548 | break; |
549 | 549 | |
550 | 550 | case 'unilateral' : |
551 | 551 | |
552 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
552 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
553 | 553 | |
554 | 554 | break; |
555 | 555 | |
556 | 556 | case 'upgrade' : |
557 | 557 | |
558 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
558 | + $note = __('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
559 | 559 | |
560 | 560 | break; |
561 | 561 | |
562 | 562 | case 'verify' : |
563 | 563 | |
564 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
564 | + $note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
565 | 565 | |
566 | 566 | break; |
567 | 567 | |
568 | 568 | case 'other' : |
569 | 569 | |
570 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
570 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
571 | 571 | |
572 | 572 | break; |
573 | 573 | |
@@ -585,49 +585,49 @@ discard block |
||
585 | 585 | * |
586 | 586 | * @return mixed|string |
587 | 587 | */ |
588 | -function give_build_paypal_url( $payment_id, $payment_data ) { |
|
588 | +function give_build_paypal_url($payment_id, $payment_data) { |
|
589 | 589 | // Only send to PayPal if the pending payment is created successfully. |
590 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
590 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
591 | 591 | |
592 | 592 | // Get the success url. |
593 | - $return_url = add_query_arg( array( |
|
593 | + $return_url = add_query_arg(array( |
|
594 | 594 | 'payment-confirmation' => 'paypal', |
595 | 595 | 'payment-id' => $payment_id, |
596 | 596 | |
597 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
597 | + ), get_permalink(give_get_option('success_page'))); |
|
598 | 598 | |
599 | 599 | // Get the PayPal redirect uri. |
600 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
600 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
601 | 601 | |
602 | 602 | // Item name. |
603 | - $item_name = give_payment_gateway_item_title( $payment_data ); |
|
603 | + $item_name = give_payment_gateway_item_title($payment_data); |
|
604 | 604 | |
605 | 605 | // Setup PayPal API params. |
606 | 606 | $paypal_args = array( |
607 | - 'business' => give_get_option( 'paypal_email', false ), |
|
607 | + 'business' => give_get_option('paypal_email', false), |
|
608 | 608 | 'first_name' => $payment_data['user_info']['first_name'], |
609 | 609 | 'last_name' => $payment_data['user_info']['last_name'], |
610 | 610 | 'email' => $payment_data['user_email'], |
611 | 611 | 'invoice' => $payment_data['purchase_key'], |
612 | 612 | 'amount' => $payment_data['price'], |
613 | - 'item_name' => stripslashes( $item_name ), |
|
613 | + 'item_name' => stripslashes($item_name), |
|
614 | 614 | 'no_shipping' => '1', |
615 | 615 | 'shipping' => '0', |
616 | 616 | 'no_note' => '1', |
617 | - 'currency_code' => give_get_currency( $payment_id, $payment_data ), |
|
618 | - 'charset' => get_bloginfo( 'charset' ), |
|
617 | + 'currency_code' => give_get_currency($payment_id, $payment_data), |
|
618 | + 'charset' => get_bloginfo('charset'), |
|
619 | 619 | 'custom' => $payment_id, |
620 | 620 | 'rm' => '2', |
621 | 621 | 'return' => $return_url, |
622 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
622 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
623 | 623 | 'notify_url' => $listener_url, |
624 | 624 | 'page_style' => give_get_paypal_page_style(), |
625 | - 'cbt' => get_bloginfo( 'name' ), |
|
625 | + 'cbt' => get_bloginfo('name'), |
|
626 | 626 | 'bn' => 'givewp_SP', |
627 | 627 | ); |
628 | 628 | |
629 | 629 | // Add user address if present. |
630 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
630 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
631 | 631 | $default_address = array( |
632 | 632 | 'line1' => '', |
633 | 633 | 'line2' => '', |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | 'country' => '', |
638 | 638 | ); |
639 | 639 | |
640 | - $address = wp_parse_args( $payment_data['user_info']['address'], $default_address ); |
|
640 | + $address = wp_parse_args($payment_data['user_info']['address'], $default_address); |
|
641 | 641 | |
642 | 642 | $paypal_args['address1'] = $address['line1']; |
643 | 643 | $paypal_args['address2'] = $address['line2']; |
@@ -658,13 +658,13 @@ discard block |
||
658 | 658 | * |
659 | 659 | * @since 1.8 |
660 | 660 | */ |
661 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
661 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
662 | 662 | |
663 | 663 | // Build query. |
664 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
664 | + $paypal_redirect .= http_build_query($paypal_args); |
|
665 | 665 | |
666 | 666 | // Fix for some sites that encode the entities. |
667 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
667 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
668 | 668 | |
669 | 669 | return $paypal_redirect; |
670 | 670 | } |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | function give_get_paypal_button_type() { |
680 | 680 | // paypal_button_type can be donation or standard. |
681 | 681 | $paypal_button_type = '_donations'; |
682 | - if ( 'standard' === give_get_option( 'paypal_button_type' ) ) { |
|
682 | + if ('standard' === give_get_option('paypal_button_type')) { |
|
683 | 683 | $paypal_button_type = '_xclick'; |
684 | 684 | } |
685 | 685 | |
@@ -697,14 +697,14 @@ discard block |
||
697 | 697 | * |
698 | 698 | * @return string |
699 | 699 | */ |
700 | -function give_paypal_purchase_key( $custom_purchase_key, $gateway, $purchase_key ) { |
|
700 | +function give_paypal_purchase_key($custom_purchase_key, $gateway, $purchase_key) { |
|
701 | 701 | |
702 | - if ( 'paypal' === $gateway ) { |
|
703 | - $invoice_id_prefix = give_get_option( 'paypal_invoice_prefix', 'GIVE-' ); |
|
704 | - $custom_purchase_key = $invoice_id_prefix . $purchase_key; |
|
702 | + if ('paypal' === $gateway) { |
|
703 | + $invoice_id_prefix = give_get_option('paypal_invoice_prefix', 'GIVE-'); |
|
704 | + $custom_purchase_key = $invoice_id_prefix.$purchase_key; |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | return $custom_purchase_key; |
708 | 708 | } |
709 | 709 | |
710 | -add_filter( 'give_donation_purchase_key', 'give_paypal_purchase_key', 10, 3 ); |
|
710 | +add_filter('give_donation_purchase_key', 'give_paypal_purchase_key', 10, 3); |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Gateways' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Gateways')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Gateways. |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'gateways'; |
30 | - $this->label = esc_html__( 'Payment Gateways', 'give' ); |
|
30 | + $this->label = esc_html__('Payment Gateways', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'gateways-settings'; |
33 | 33 | |
34 | 34 | parent::__construct(); |
35 | 35 | |
36 | 36 | // Do not use main form for this tab. |
37 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
38 | - add_action( 'give_admin_field_enabled_gateways', array( $this, 'render_enabled_gateways' ), 10, 2 ); |
|
37 | + if (give_get_current_setting_tab() === $this->id) { |
|
38 | + add_action('give_admin_field_enabled_gateways', array($this, 'render_enabled_gateways'), 10, 2); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $settings = array(); |
50 | 50 | $current_section = give_get_current_setting_section(); |
51 | 51 | |
52 | - switch ( $current_section ) { |
|
52 | + switch ($current_section) { |
|
53 | 53 | case 'paypal-standard': |
54 | 54 | $settings = array( |
55 | 55 | // Section 2: PayPal Standard. |
@@ -58,62 +58,62 @@ discard block |
||
58 | 58 | 'id' => 'give_title_gateway_settings_2', |
59 | 59 | ), |
60 | 60 | array( |
61 | - 'name' => __( 'PayPal Email', 'give' ), |
|
62 | - 'desc' => __( 'Enter your PayPal account\'s email.', 'give' ), |
|
61 | + 'name' => __('PayPal Email', 'give'), |
|
62 | + 'desc' => __('Enter your PayPal account\'s email.', 'give'), |
|
63 | 63 | 'id' => 'paypal_email', |
64 | 64 | 'type' => 'email', |
65 | 65 | ), |
66 | 66 | array( |
67 | - 'name' => __( 'PayPal Page Style', 'give' ), |
|
68 | - 'desc' => __( 'Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give' ), |
|
67 | + 'name' => __('PayPal Page Style', 'give'), |
|
68 | + 'desc' => __('Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give'), |
|
69 | 69 | 'id' => 'paypal_page_style', |
70 | 70 | 'type' => 'text', |
71 | 71 | ), |
72 | 72 | array( |
73 | - 'name' => __( 'PayPal Transaction Type', 'give' ), |
|
74 | - 'desc' => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ), |
|
73 | + 'name' => __('PayPal Transaction Type', 'give'), |
|
74 | + 'desc' => __('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'), |
|
75 | 75 | 'id' => 'paypal_button_type', |
76 | 76 | 'type' => 'radio_inline', |
77 | 77 | 'options' => array( |
78 | - 'donation' => __( 'Donation', 'give' ), |
|
79 | - 'standard' => __( 'Standard Transaction', 'give' ) |
|
78 | + 'donation' => __('Donation', 'give'), |
|
79 | + 'standard' => __('Standard Transaction', 'give') |
|
80 | 80 | ), |
81 | 81 | 'default' => 'donation', |
82 | 82 | ), |
83 | 83 | array( |
84 | - 'name' => __( 'Billing Details', 'give' ), |
|
85 | - 'desc' => __( 'This option will enable the billing details section for PayPal Standard which requires the donor\'s address to complete the donation. These fields are not required by PayPal to process the transaction, but you may have a need to collect the data.', 'give' ), |
|
84 | + 'name' => __('Billing Details', 'give'), |
|
85 | + 'desc' => __('This option will enable the billing details section for PayPal Standard which requires the donor\'s address to complete the donation. These fields are not required by PayPal to process the transaction, but you may have a need to collect the data.', 'give'), |
|
86 | 86 | 'id' => 'paypal_standard_billing_details', |
87 | 87 | 'type' => 'radio_inline', |
88 | 88 | 'default' => 'disabled', |
89 | 89 | 'options' => array( |
90 | - 'enabled' => __( 'Enabled', 'give' ), |
|
91 | - 'disabled' => __( 'Disabled', 'give' ), |
|
90 | + 'enabled' => __('Enabled', 'give'), |
|
91 | + 'disabled' => __('Disabled', 'give'), |
|
92 | 92 | ) |
93 | 93 | ), |
94 | 94 | array( |
95 | - 'name' => __( 'PayPal IPN Verification', 'give' ), |
|
96 | - 'desc' => __( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ), |
|
95 | + 'name' => __('PayPal IPN Verification', 'give'), |
|
96 | + 'desc' => __('If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give'), |
|
97 | 97 | 'id' => 'paypal_verification', |
98 | 98 | 'type' => 'radio_inline', |
99 | 99 | 'default' => 'enabled', |
100 | 100 | 'options' => array( |
101 | - 'enabled' => __( 'Enabled', 'give' ), |
|
102 | - 'disabled' => __( 'Disabled', 'give' ), |
|
101 | + 'enabled' => __('Enabled', 'give'), |
|
102 | + 'disabled' => __('Disabled', 'give'), |
|
103 | 103 | ) |
104 | 104 | ), |
105 | 105 | array( |
106 | 106 | 'id' => 'paypal_invoice_prefix', |
107 | - 'name' => esc_html__( 'Invoice ID Prefix', 'give' ), |
|
108 | - 'desc' => esc_html__( 'Please enter a prefix for your invoice numbers. If you use your PayPal account for multiple stores ensure this prefix is unique as PayPal will not allow orders with the same invoice number.', 'give' ), |
|
107 | + 'name' => esc_html__('Invoice ID Prefix', 'give'), |
|
108 | + 'desc' => esc_html__('Please enter a prefix for your invoice numbers. If you use your PayPal account for multiple stores ensure this prefix is unique as PayPal will not allow orders with the same invoice number.', 'give'), |
|
109 | 109 | 'type' => 'text', |
110 | 110 | 'default' => 'GIVE-', |
111 | 111 | ), |
112 | 112 | array( |
113 | - 'name' => __( 'PayPal Standard Gateway Settings Docs Link', 'give' ), |
|
113 | + 'name' => __('PayPal Standard Gateway Settings Docs Link', 'give'), |
|
114 | 114 | 'id' => 'paypal_standard_gateway_settings_docs_link', |
115 | - 'url' => esc_url( 'http://docs.givewp.com/settings-gateway-paypal-standard' ), |
|
116 | - 'title' => __( 'PayPal Standard Gateway Settings', 'give' ), |
|
115 | + 'url' => esc_url('http://docs.givewp.com/settings-gateway-paypal-standard'), |
|
116 | + 'title' => __('PayPal Standard Gateway Settings', 'give'), |
|
117 | 117 | 'type' => 'give_docs_link', |
118 | 118 | ), |
119 | 119 | array( |
@@ -131,19 +131,19 @@ discard block |
||
131 | 131 | 'id' => 'give_title_gateway_settings_3', |
132 | 132 | ), |
133 | 133 | array( |
134 | - 'name' => __( 'Collect Billing Details', 'give' ), |
|
135 | - 'desc' => __( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ), |
|
134 | + 'name' => __('Collect Billing Details', 'give'), |
|
135 | + 'desc' => __('Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give'), |
|
136 | 136 | 'id' => 'give_offline_donation_enable_billing_fields', |
137 | 137 | 'type' => 'radio_inline', |
138 | 138 | 'default' => 'disabled', |
139 | 139 | 'options' => array( |
140 | - 'enabled' => __( 'Enabled', 'give' ), |
|
141 | - 'disabled' => __( 'Disabled', 'give' ) |
|
140 | + 'enabled' => __('Enabled', 'give'), |
|
141 | + 'disabled' => __('Disabled', 'give') |
|
142 | 142 | ) |
143 | 143 | ), |
144 | 144 | array( |
145 | - 'name' => __( 'Offline Donation Instructions', 'give' ), |
|
146 | - 'desc' => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ), |
|
145 | + 'name' => __('Offline Donation Instructions', 'give'), |
|
146 | + 'desc' => __('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'), |
|
147 | 147 | 'id' => 'global_offline_donation_content', |
148 | 148 | 'default' => give_get_default_offline_donation_content(), |
149 | 149 | 'type' => 'wysiwyg', |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | ) |
153 | 153 | ), |
154 | 154 | array( |
155 | - 'name' => esc_html__( 'Offline Donations Settings Docs Link', 'give' ), |
|
155 | + 'name' => esc_html__('Offline Donations Settings Docs Link', 'give'), |
|
156 | 156 | 'id' => 'offline_gateway_settings_docs_link', |
157 | - 'url' => esc_url( 'http://docs.givewp.com/offlinegateway' ), |
|
158 | - 'title' => __( 'Offline Gateway Settings', 'give' ), |
|
157 | + 'url' => esc_url('http://docs.givewp.com/offlinegateway'), |
|
158 | + 'title' => __('Offline Gateway Settings', 'give'), |
|
159 | 159 | 'type' => 'give_docs_link', |
160 | 160 | ), |
161 | 161 | array( |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | 'type' => 'title' |
174 | 174 | ), |
175 | 175 | array( |
176 | - 'name' => __( 'Test Mode', 'give' ), |
|
177 | - 'desc' => __( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ), |
|
176 | + 'name' => __('Test Mode', 'give'), |
|
177 | + 'desc' => __('While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'), |
|
178 | 178 | 'id' => 'test_mode', |
179 | 179 | 'type' => 'radio_inline', |
180 | 180 | 'default' => 'disabled', |
181 | 181 | 'options' => array( |
182 | - 'enabled' => __( 'Enabled', 'give' ), |
|
183 | - 'disabled' => __( 'Disabled', 'give' ), |
|
182 | + 'enabled' => __('Enabled', 'give'), |
|
183 | + 'disabled' => __('Disabled', 'give'), |
|
184 | 184 | ) |
185 | 185 | ), |
186 | 186 | array( |
187 | - 'name' => __( 'Enabled Gateways', 'give' ), |
|
188 | - 'desc' => __( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ), |
|
187 | + 'name' => __('Enabled Gateways', 'give'), |
|
188 | + 'desc' => __('Enable your payment gateway. Can be ordered by dragging.', 'give'), |
|
189 | 189 | 'id' => 'gateways', |
190 | 190 | 'type' => 'enabled_gateways' |
191 | 191 | ), |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * This setting will not render on admin setting screen but help internal code to recognize "gateways_label" setting and add them to give setting when save. |
198 | 198 | */ |
199 | 199 | array( |
200 | - 'name' => __( 'Gateways Label', 'give' ), |
|
200 | + 'name' => __('Gateways Label', 'give'), |
|
201 | 201 | 'desc' => '', |
202 | 202 | 'id' => 'gateways_label', |
203 | 203 | 'type' => 'gateways_label_hidden' |
@@ -210,17 +210,17 @@ discard block |
||
210 | 210 | * This setting will not render on admin setting screen but help internal code to recognize "default_gateway" setting and add them to give setting when save. |
211 | 211 | */ |
212 | 212 | array( |
213 | - 'name' => __( 'Default Gateway', 'give' ), |
|
214 | - 'desc' => __( 'The gateway that will be selected by default.', 'give' ), |
|
213 | + 'name' => __('Default Gateway', 'give'), |
|
214 | + 'desc' => __('The gateway that will be selected by default.', 'give'), |
|
215 | 215 | 'id' => 'default_gateway', |
216 | 216 | 'type' => 'default_gateway_hidden' |
217 | 217 | ), |
218 | 218 | |
219 | 219 | array( |
220 | - 'name' => __( 'Gateways Docs Link', 'give' ), |
|
220 | + 'name' => __('Gateways Docs Link', 'give'), |
|
221 | 221 | 'id' => 'gateway_settings_docs_link', |
222 | - 'url' => esc_url( 'http://docs.givewp.com/settings-gateways' ), |
|
223 | - 'title' => __( 'Gateway Settings', 'give' ), |
|
222 | + 'url' => esc_url('http://docs.givewp.com/settings-gateways'), |
|
223 | + 'title' => __('Gateway Settings', 'give'), |
|
224 | 224 | 'type' => 'give_docs_link', |
225 | 225 | ), |
226 | 226 | array( |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * Filter the payment gateways settings. |
236 | 236 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
237 | 237 | */ |
238 | - $settings = apply_filters( 'give_settings_gateways', $settings ); |
|
238 | + $settings = apply_filters('give_settings_gateways', $settings); |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Filter the settings. |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @param array $settings |
246 | 246 | */ |
247 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
247 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
248 | 248 | |
249 | 249 | // Output. |
250 | 250 | return $settings; |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function get_sections() { |
260 | 260 | $sections = array( |
261 | - 'gateways-settings' => __( 'Gateways', 'give' ), |
|
262 | - 'paypal-standard' => __( 'PayPal Standard', 'give' ), |
|
263 | - 'offline-donations' => __( 'Offline Donations', 'give' ) |
|
261 | + 'gateways-settings' => __('Gateways', 'give'), |
|
262 | + 'paypal-standard' => __('PayPal Standard', 'give'), |
|
263 | + 'offline-donations' => __('Offline Donations', 'give') |
|
264 | 264 | ); |
265 | 265 | |
266 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
266 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | * @param $field |
277 | 277 | * @param $settings |
278 | 278 | */ |
279 | - public function render_enabled_gateways( $field, $settings ) { |
|
279 | + public function render_enabled_gateways($field, $settings) { |
|
280 | 280 | $id = $field['id']; |
281 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
282 | - $gateways_label = give_get_option( 'gateways_label', array() ); |
|
283 | - $default_gateway = give_get_option( 'default_gateway', current( array_keys( $gateways ) ) ); |
|
281 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
282 | + $gateways_label = give_get_option('gateways_label', array()); |
|
283 | + $default_gateway = give_get_option('default_gateway', current(array_keys($gateways))); |
|
284 | 284 | |
285 | 285 | ob_start(); |
286 | 286 | |
@@ -295,51 +295,51 @@ discard block |
||
295 | 295 | <span>%3$s</span> |
296 | 296 | <span>%4$s</span> |
297 | 297 | ', |
298 | - __( 'Gateway', 'give' ), |
|
299 | - __( 'Label', 'give' ), |
|
300 | - __( 'Default', 'give' ), |
|
301 | - __( 'Enabled', 'give' ) |
|
298 | + __('Gateway', 'give'), |
|
299 | + __('Label', 'give'), |
|
300 | + __('Default', 'give'), |
|
301 | + __('Enabled', 'give') |
|
302 | 302 | ); |
303 | 303 | echo '</div>'; |
304 | 304 | |
305 | 305 | echo '<ul class="give-checklist-fields give-payment-gatways-list">'; |
306 | - foreach ( $gateways as $key => $option ) : |
|
306 | + foreach ($gateways as $key => $option) : |
|
307 | 307 | $enabled = null; |
308 | - if ( is_array( $settings ) && array_key_exists( $key, $settings ) ) { |
|
308 | + if (is_array($settings) && array_key_exists($key, $settings)) { |
|
309 | 309 | $enabled = '1'; |
310 | 310 | } |
311 | 311 | |
312 | 312 | echo '<li>'; |
313 | - printf( '<span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span>' ); |
|
314 | - printf( '<span class="admin-label">%s</span>', esc_html( $option['admin_label'] ) ); |
|
313 | + printf('<span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span>'); |
|
314 | + printf('<span class="admin-label">%s</span>', esc_html($option['admin_label'])); |
|
315 | 315 | |
316 | 316 | $label = ''; |
317 | - if ( ! empty( $gateways_label[ $key ] ) ) { |
|
318 | - $label = $gateways_label[ $key ]; |
|
317 | + if ( ! empty($gateways_label[$key])) { |
|
318 | + $label = $gateways_label[$key]; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | printf( |
322 | 322 | '<input class="checkout-label" type="text" id="%1$s[%2$s]" name="%1$s[%2$s]" value="%3$s" placeholder="%4$s"/>', |
323 | 323 | 'gateways_label', |
324 | - esc_attr( $key ), |
|
325 | - esc_html( $label ), |
|
326 | - esc_html( $option['checkout_label'] ) |
|
324 | + esc_attr($key), |
|
325 | + esc_html($label), |
|
326 | + esc_html($option['checkout_label']) |
|
327 | 327 | ); |
328 | 328 | |
329 | 329 | printf( |
330 | 330 | '<input class="gateways-radio" type="radio" name="%1$s" value="%2$s" %3$s %4$s>', |
331 | 331 | 'default_gateway', |
332 | 332 | $key, |
333 | - checked( $key, $default_gateway, false ), |
|
334 | - disabled( NULL, $enabled, false ) |
|
333 | + checked($key, $default_gateway, false), |
|
334 | + disabled(NULL, $enabled, false) |
|
335 | 335 | ); |
336 | 336 | |
337 | 337 | printf( |
338 | 338 | '<input class="gateways-checkbox" name="%1$s[%2$s]" id="%1$s[%2$s]" type="checkbox" value="1" %3$s data-payment-gateway="%4$s"/>', |
339 | - esc_attr( $id ), |
|
340 | - esc_attr( $key ), |
|
341 | - checked( '1', $enabled, false ), |
|
342 | - esc_html( $option['admin_label'] ) |
|
339 | + esc_attr($id), |
|
340 | + esc_attr($key), |
|
341 | + checked('1', $enabled, false), |
|
342 | + esc_html($option['admin_label']) |
|
343 | 343 | ); |
344 | 344 | echo '</li>'; |
345 | 345 | endforeach; |