@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | public function __construct() { |
107 | 107 | $this->retry_interval = 1; |
108 | 108 | $this->id = 'stripe'; |
109 | - $this->method_title = __( 'Stripe', 'woocommerce-gateway-stripe' ); |
|
109 | + $this->method_title = __('Stripe', 'woocommerce-gateway-stripe'); |
|
110 | 110 | /* translators: 1) link to Stripe register page 2) link to Stripe api keys page */ |
111 | - $this->method_description = sprintf( __( 'Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification. <a href="%1$s" target="_blank">Sign up</a> for a Stripe account, and <a href="%2$s" target="_blank">get your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), 'https://dashboard.stripe.com/register', 'https://dashboard.stripe.com/account/apikeys' ); |
|
111 | + $this->method_description = sprintf(__('Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification. <a href="%1$s" target="_blank">Sign up</a> for a Stripe account, and <a href="%2$s" target="_blank">get your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), 'https://dashboard.stripe.com/register', 'https://dashboard.stripe.com/account/apikeys'); |
|
112 | 112 | $this->has_fields = true; |
113 | 113 | $this->supports = array( |
114 | 114 | 'products', |
@@ -135,32 +135,32 @@ discard block |
||
135 | 135 | $this->init_settings(); |
136 | 136 | |
137 | 137 | // Get setting values. |
138 | - $this->title = $this->get_option( 'title' ); |
|
139 | - $this->description = $this->get_option( 'description' ); |
|
140 | - $this->enabled = $this->get_option( 'enabled' ); |
|
141 | - $this->testmode = 'yes' === $this->get_option( 'testmode' ); |
|
142 | - $this->inline_cc_form = 'yes' === $this->get_option( 'inline_cc_form' ); |
|
143 | - $this->capture = 'yes' === $this->get_option( 'capture', 'yes' ); |
|
144 | - $this->statement_descriptor = WC_Stripe_Helper::clean_statement_descriptor( $this->get_option( 'statement_descriptor' ) ); |
|
145 | - $this->three_d_secure = 'yes' === $this->get_option( 'three_d_secure' ); |
|
146 | - $this->stripe_checkout = 'yes' === $this->get_option( 'stripe_checkout' ); |
|
147 | - $this->stripe_checkout_image = $this->get_option( 'stripe_checkout_image', '' ); |
|
148 | - $this->saved_cards = 'yes' === $this->get_option( 'saved_cards' ); |
|
149 | - $this->secret_key = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' ); |
|
150 | - $this->publishable_key = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' ); |
|
151 | - $this->bitcoin = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' ); |
|
152 | - $this->payment_request = 'yes' === $this->get_option( 'payment_request', 'yes' ); |
|
153 | - |
|
154 | - if ( $this->stripe_checkout ) { |
|
155 | - $this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' ); |
|
138 | + $this->title = $this->get_option('title'); |
|
139 | + $this->description = $this->get_option('description'); |
|
140 | + $this->enabled = $this->get_option('enabled'); |
|
141 | + $this->testmode = 'yes' === $this->get_option('testmode'); |
|
142 | + $this->inline_cc_form = 'yes' === $this->get_option('inline_cc_form'); |
|
143 | + $this->capture = 'yes' === $this->get_option('capture', 'yes'); |
|
144 | + $this->statement_descriptor = WC_Stripe_Helper::clean_statement_descriptor($this->get_option('statement_descriptor')); |
|
145 | + $this->three_d_secure = 'yes' === $this->get_option('three_d_secure'); |
|
146 | + $this->stripe_checkout = 'yes' === $this->get_option('stripe_checkout'); |
|
147 | + $this->stripe_checkout_image = $this->get_option('stripe_checkout_image', ''); |
|
148 | + $this->saved_cards = 'yes' === $this->get_option('saved_cards'); |
|
149 | + $this->secret_key = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key'); |
|
150 | + $this->publishable_key = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key'); |
|
151 | + $this->bitcoin = 'USD' === strtoupper(get_woocommerce_currency()) && 'yes' === $this->get_option('stripe_bitcoin'); |
|
152 | + $this->payment_request = 'yes' === $this->get_option('payment_request', 'yes'); |
|
153 | + |
|
154 | + if ($this->stripe_checkout) { |
|
155 | + $this->order_button_text = __('Continue to payment', 'woocommerce-gateway-stripe'); |
|
156 | 156 | } |
157 | 157 | |
158 | - WC_Stripe_API::set_secret_key( $this->secret_key ); |
|
158 | + WC_Stripe_API::set_secret_key($this->secret_key); |
|
159 | 159 | |
160 | 160 | // Hooks. |
161 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
162 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); |
|
163 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
161 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
162 | + add_action('admin_enqueue_scripts', array($this, 'admin_scripts')); |
|
163 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @return bool |
171 | 171 | */ |
172 | 172 | public function are_keys_set() { |
173 | - if ( empty( $this->secret_key ) || empty( $this->publishable_key ) ) { |
|
173 | + if (empty($this->secret_key) || empty($this->publishable_key)) { |
|
174 | 174 | return false; |
175 | 175 | } |
176 | 176 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @since 4.0.2 |
184 | 184 | */ |
185 | 185 | public function is_available() { |
186 | - if ( is_add_payment_method_page() && ! $this->saved_cards ) { |
|
186 | + if (is_add_payment_method_page() && ! $this->saved_cards) { |
|
187 | 187 | return false; |
188 | 188 | } |
189 | 189 | |
@@ -206,24 +206,24 @@ discard block |
||
206 | 206 | $icons_str .= $icons['amex']; |
207 | 207 | $icons_str .= $icons['mastercard']; |
208 | 208 | |
209 | - if ( 'USD' === get_woocommerce_currency() ) { |
|
209 | + if ('USD' === get_woocommerce_currency()) { |
|
210 | 210 | $icons_str .= $icons['discover']; |
211 | 211 | $icons_str .= $icons['jcb']; |
212 | 212 | $icons_str .= $icons['diners']; |
213 | 213 | } |
214 | 214 | |
215 | - if ( $this->bitcoin && $this->stripe_checkout ) { |
|
215 | + if ($this->bitcoin && $this->stripe_checkout) { |
|
216 | 216 | $icons_str .= $icons['bitcoin']; |
217 | 217 | } |
218 | 218 | |
219 | - return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id ); |
|
219 | + return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Initialise Gateway Settings Form Fields |
224 | 224 | */ |
225 | 225 | public function init_form_fields() { |
226 | - $this->form_fields = require( dirname( __FILE__ ) . '/admin/stripe-settings.php' ); |
|
226 | + $this->form_fields = require(dirname(__FILE__) . '/admin/stripe-settings.php'); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -231,68 +231,68 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function payment_fields() { |
233 | 233 | $user = wp_get_current_user(); |
234 | - $display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards; |
|
234 | + $display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards; |
|
235 | 235 | $total = WC()->cart->total; |
236 | 236 | $user_email = ''; |
237 | 237 | |
238 | 238 | // If paying from order, we need to get total from order not cart. |
239 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
240 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
239 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
240 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
241 | 241 | $total = $order->get_total(); |
242 | 242 | $user_email = WC_Stripe_Helper::is_pre_30() ? $order->billing_email : $order->get_billing_email(); |
243 | 243 | } else { |
244 | - if ( $user->ID ) { |
|
245 | - $user_email = get_user_meta( $user->ID, 'billing_email', true ); |
|
244 | + if ($user->ID) { |
|
245 | + $user_email = get_user_meta($user->ID, 'billing_email', true); |
|
246 | 246 | $user_email = $user_email ? $user_email : $user->user_email; |
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | - if ( is_add_payment_method_page() ) { |
|
251 | - $pay_button_text = __( 'Add Card', 'woocommerce-gateway-stripe' ); |
|
252 | - $total = ''; |
|
250 | + if (is_add_payment_method_page()) { |
|
251 | + $pay_button_text = __('Add Card', 'woocommerce-gateway-stripe'); |
|
252 | + $total = ''; |
|
253 | 253 | } else { |
254 | 254 | $pay_button_text = ''; |
255 | 255 | } |
256 | 256 | |
257 | 257 | echo '<div |
258 | 258 | id="stripe-payment-data" |
259 | - data-panel-label="' . esc_attr( $pay_button_text ) . '" |
|
259 | + data-panel-label="' . esc_attr($pay_button_text) . '" |
|
260 | 260 | data-description="" |
261 | - data-email="' . esc_attr( $user_email ) . '" |
|
262 | - data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '" |
|
263 | - data-name="' . esc_attr( $this->statement_descriptor ) . '" |
|
264 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '" |
|
265 | - data-image="' . esc_attr( $this->stripe_checkout_image ) . '" |
|
266 | - data-bitcoin="' . esc_attr( ( $this->bitcoin && $this->capture ) ? 'true' : 'false' ) . '" |
|
267 | - data-locale="' . esc_attr( apply_filters( 'wc_stripe_checkout_locale', $this->get_locale() ) ) . '" |
|
268 | - data-three-d-secure="' . esc_attr( $this->three_d_secure ? 'true' : 'false' ) . '" |
|
269 | - data-allow-remember-me="' . esc_attr( $this->saved_cards ? 'true' : 'false' ) . '">'; |
|
270 | - |
|
271 | - if ( $this->description ) { |
|
272 | - if ( $this->testmode ) { |
|
261 | + data-email="' . esc_attr($user_email) . '" |
|
262 | + data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '" |
|
263 | + data-name="' . esc_attr($this->statement_descriptor) . '" |
|
264 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '" |
|
265 | + data-image="' . esc_attr($this->stripe_checkout_image) . '" |
|
266 | + data-bitcoin="' . esc_attr(($this->bitcoin && $this->capture) ? 'true' : 'false') . '" |
|
267 | + data-locale="' . esc_attr(apply_filters('wc_stripe_checkout_locale', $this->get_locale())) . '" |
|
268 | + data-three-d-secure="' . esc_attr($this->three_d_secure ? 'true' : 'false') . '" |
|
269 | + data-allow-remember-me="' . esc_attr($this->saved_cards ? 'true' : 'false') . '">'; |
|
270 | + |
|
271 | + if ($this->description) { |
|
272 | + if ($this->testmode) { |
|
273 | 273 | /* translators: link to Stripe testing page */ |
274 | - $this->description .= ' ' . sprintf( __( 'TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the documentation "<a href="%s" target="_blank">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' ); |
|
275 | - $this->description = trim( $this->description ); |
|
274 | + $this->description .= ' ' . sprintf(__('TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the documentation "<a href="%s" target="_blank">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe'), 'https://stripe.com/docs/testing'); |
|
275 | + $this->description = trim($this->description); |
|
276 | 276 | } |
277 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) ); |
|
277 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description))); |
|
278 | 278 | } |
279 | 279 | |
280 | - if ( $display_tokenization ) { |
|
280 | + if ($display_tokenization) { |
|
281 | 281 | $this->tokenization_script(); |
282 | 282 | $this->saved_payment_methods(); |
283 | 283 | } |
284 | 284 | |
285 | - if ( ! $this->stripe_checkout ) { |
|
286 | - if ( apply_filters( 'wc_stripe_use_elements_checkout_form', true ) ) { |
|
285 | + if ( ! $this->stripe_checkout) { |
|
286 | + if (apply_filters('wc_stripe_use_elements_checkout_form', true)) { |
|
287 | 287 | $this->elements_form(); |
288 | 288 | } else { |
289 | - WC_Stripe_Logger::log( 'DEPRECATED! Since version 4.0. Stripe Elements is used. This legacy credit card form will be removed by version 5.0!' ); |
|
289 | + WC_Stripe_Logger::log('DEPRECATED! Since version 4.0. Stripe Elements is used. This legacy credit card form will be removed by version 5.0!'); |
|
290 | 290 | $this->form(); |
291 | 291 | echo '<div class="stripe-source-errors" role="alert"></div>'; |
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
295 | - if ( apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) { |
|
295 | + if (apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) { |
|
296 | 296 | $this->save_payment_method_checkbox(); |
297 | 297 | } |
298 | 298 | |
@@ -307,12 +307,12 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public function elements_form() { |
309 | 309 | ?> |
310 | - <fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;"> |
|
311 | - <?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?> |
|
310 | + <fieldset id="wc-<?php echo esc_attr($this->id); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;"> |
|
311 | + <?php do_action('woocommerce_credit_card_form_start', $this->id); ?> |
|
312 | 312 | |
313 | - <?php if ( $this->inline_cc_form ) { ?> |
|
313 | + <?php if ($this->inline_cc_form) { ?> |
|
314 | 314 | <label for="card-element"> |
315 | - <?php esc_html_e( 'Credit or debit card', 'woocommerce-gateway-stripe' ); ?> |
|
315 | + <?php esc_html_e('Credit or debit card', 'woocommerce-gateway-stripe'); ?> |
|
316 | 316 | </label> |
317 | 317 | |
318 | 318 | <div id="stripe-card-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;"> |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | </div> |
321 | 321 | <?php } else { ?> |
322 | 322 | <div class="form-row form-row-wide"> |
323 | - <label><?php _e( 'Card Number', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label> |
|
323 | + <label><?php _e('Card Number', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label> |
|
324 | 324 | |
325 | 325 | <div id="stripe-card-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;"> |
326 | 326 | <!-- a Stripe Element will be inserted here. --> |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | </div> |
329 | 329 | |
330 | 330 | <div class="form-row form-row-first"> |
331 | - <label><?php _e( 'Expiry Date', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label> |
|
331 | + <label><?php _e('Expiry Date', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label> |
|
332 | 332 | |
333 | 333 | <div id="stripe-exp-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;"> |
334 | 334 | <!-- a Stripe Element will be inserted here. --> |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | </div> |
337 | 337 | |
338 | 338 | <div class="form-row form-row-last"> |
339 | - <label><?php _e( 'Card Code (CVC)', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label> |
|
339 | + <label><?php _e('Card Code (CVC)', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label> |
|
340 | 340 | <div id="stripe-cvc-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;"> |
341 | 341 | <!-- a Stripe Element will be inserted here. --> |
342 | 342 | </div> |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | |
347 | 347 | <!-- Used to display form errors --> |
348 | 348 | <div class="stripe-source-errors" role="alert"></div> |
349 | - <?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?> |
|
349 | + <?php do_action('woocommerce_credit_card_form_end', $this->id); ?> |
|
350 | 350 | <div class="clear"></div> |
351 | 351 | </fieldset> |
352 | 352 | <?php |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | * @version 3.1.0 |
360 | 360 | */ |
361 | 361 | public function admin_scripts() { |
362 | - if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) { |
|
362 | + if ('woocommerce_page_wc-settings' !== get_current_screen()->id) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
366 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
366 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
367 | 367 | |
368 | - wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true ); |
|
368 | + wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
@@ -377,46 +377,46 @@ discard block |
||
377 | 377 | * @version 4.0.0 |
378 | 378 | */ |
379 | 379 | public function payment_scripts() { |
380 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) { |
|
380 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) { |
|
381 | 381 | return; |
382 | 382 | } |
383 | 383 | |
384 | 384 | // If Stripe is not enabled bail. |
385 | - if ( 'no' === $this->enabled ) { |
|
385 | + if ('no' === $this->enabled) { |
|
386 | 386 | return; |
387 | 387 | } |
388 | 388 | |
389 | 389 | // If keys are not set bail. |
390 | - if ( ! $this->are_keys_set() ) { |
|
391 | - WC_Stripe_Logger::log( 'Keys are not set correctly.' ); |
|
390 | + if ( ! $this->are_keys_set()) { |
|
391 | + WC_Stripe_Logger::log('Keys are not set correctly.'); |
|
392 | 392 | return; |
393 | 393 | } |
394 | 394 | |
395 | 395 | // If no SSL bail. |
396 | - if ( ! $this->testmode && ! is_ssl() ) { |
|
397 | - WC_Stripe_Logger::log( 'Stripe requires SSL.' ); |
|
396 | + if ( ! $this->testmode && ! is_ssl()) { |
|
397 | + WC_Stripe_Logger::log('Stripe requires SSL.'); |
|
398 | 398 | return; |
399 | 399 | } |
400 | 400 | |
401 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
401 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
402 | 402 | |
403 | - wp_register_style( 'stripe_paymentfonts', plugins_url( 'assets/css/stripe-paymentfonts.css', WC_STRIPE_MAIN_FILE ), array(), '1.2.5' ); |
|
404 | - wp_enqueue_style( 'stripe_paymentfonts' ); |
|
405 | - wp_register_script( 'stripe_checkout', 'https://checkout.stripe.com/checkout.js', '', WC_STRIPE_VERSION, true ); |
|
406 | - wp_register_script( 'stripev2', 'https://js.stripe.com/v2/', '', '2.0', true ); |
|
407 | - wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true ); |
|
408 | - wp_register_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripev2', 'stripe' ), WC_STRIPE_VERSION, true ); |
|
403 | + wp_register_style('stripe_paymentfonts', plugins_url('assets/css/stripe-paymentfonts.css', WC_STRIPE_MAIN_FILE), array(), '1.2.5'); |
|
404 | + wp_enqueue_style('stripe_paymentfonts'); |
|
405 | + wp_register_script('stripe_checkout', 'https://checkout.stripe.com/checkout.js', '', WC_STRIPE_VERSION, true); |
|
406 | + wp_register_script('stripev2', 'https://js.stripe.com/v2/', '', '2.0', true); |
|
407 | + wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true); |
|
408 | + wp_register_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripev2', 'stripe'), WC_STRIPE_VERSION, true); |
|
409 | 409 | |
410 | 410 | $stripe_params = array( |
411 | 411 | 'key' => $this->publishable_key, |
412 | - 'i18n_terms' => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ), |
|
413 | - 'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ), |
|
412 | + 'i18n_terms' => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'), |
|
413 | + 'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'), |
|
414 | 414 | ); |
415 | 415 | |
416 | 416 | // If we're on the pay page we need to pass stripe.js the address of the order. |
417 | - if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) { |
|
418 | - $order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) ); |
|
419 | - $order = wc_get_order( $order_id ); |
|
417 | + if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) { |
|
418 | + $order_id = wc_get_order_id_by_order_key(urldecode($_GET['key'])); |
|
419 | + $order = wc_get_order($order_id); |
|
420 | 420 | |
421 | 421 | $stripe_params['billing_first_name'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_first_name : $order->get_billing_first_name(); |
422 | 422 | $stripe_params['billing_last_name'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_last_name : $order->get_billing_last_name(); |
@@ -428,39 +428,39 @@ discard block |
||
428 | 428 | $stripe_params['billing_country'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_country : $order->get_billing_country(); |
429 | 429 | } |
430 | 430 | |
431 | - $stripe_params['no_prepaid_card_msg'] = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe' ); |
|
432 | - $stripe_params['no_sepa_owner_msg'] = __( 'Please enter your IBAN account name.', 'woocommerce-gateway-stripe' ); |
|
433 | - $stripe_params['no_sepa_iban_msg'] = __( 'Please enter your IBAN account number.', 'woocommerce-gateway-stripe' ); |
|
434 | - $stripe_params['sepa_mandate_notification'] = apply_filters( 'wc_stripe_sepa_mandate_notification', 'email' ); |
|
435 | - $stripe_params['allow_prepaid_card'] = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no'; |
|
431 | + $stripe_params['no_prepaid_card_msg'] = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe'); |
|
432 | + $stripe_params['no_sepa_owner_msg'] = __('Please enter your IBAN account name.', 'woocommerce-gateway-stripe'); |
|
433 | + $stripe_params['no_sepa_iban_msg'] = __('Please enter your IBAN account number.', 'woocommerce-gateway-stripe'); |
|
434 | + $stripe_params['sepa_mandate_notification'] = apply_filters('wc_stripe_sepa_mandate_notification', 'email'); |
|
435 | + $stripe_params['allow_prepaid_card'] = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no'; |
|
436 | 436 | $stripe_params['inline_cc_form'] = $this->inline_cc_form ? 'yes' : 'no'; |
437 | - $stripe_params['stripe_checkout_require_billing_address'] = apply_filters( 'wc_stripe_checkout_require_billing_address', false ) ? 'yes' : 'no'; |
|
438 | - $stripe_params['is_checkout'] = ( is_checkout() && empty( $_GET['pay_for_order'] ) ) ? 'yes' : 'no'; |
|
437 | + $stripe_params['stripe_checkout_require_billing_address'] = apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'yes' : 'no'; |
|
438 | + $stripe_params['is_checkout'] = (is_checkout() && empty($_GET['pay_for_order'])) ? 'yes' : 'no'; |
|
439 | 439 | $stripe_params['return_url'] = $this->get_stripe_return_url(); |
440 | - $stripe_params['ajaxurl'] = WC_AJAX::get_endpoint( '%%endpoint%%' ); |
|
441 | - $stripe_params['stripe_nonce'] = wp_create_nonce( '_wc_stripe_nonce' ); |
|
440 | + $stripe_params['ajaxurl'] = WC_AJAX::get_endpoint('%%endpoint%%'); |
|
441 | + $stripe_params['stripe_nonce'] = wp_create_nonce('_wc_stripe_nonce'); |
|
442 | 442 | $stripe_params['statement_descriptor'] = $this->statement_descriptor; |
443 | - $stripe_params['use_elements'] = apply_filters( 'wc_stripe_use_elements_checkout_form', true ) ? 'yes' : 'no'; |
|
444 | - $stripe_params['elements_options'] = apply_filters( 'wc_stripe_elements_options', array() ); |
|
443 | + $stripe_params['use_elements'] = apply_filters('wc_stripe_use_elements_checkout_form', true) ? 'yes' : 'no'; |
|
444 | + $stripe_params['elements_options'] = apply_filters('wc_stripe_elements_options', array()); |
|
445 | 445 | $stripe_params['is_stripe_checkout'] = $this->stripe_checkout ? 'yes' : 'no'; |
446 | - $stripe_params['is_change_payment_page'] = isset( $_GET['change_payment_method'] ) ? 'yes' : 'no'; |
|
447 | - $stripe_params['is_pay_for_order_page'] = isset( $_GET['pay_for_order'] ) ? 'yes' : 'no'; |
|
448 | - $stripe_params['validate_modal_checkout'] = apply_filters( 'wc_stripe_validate_model_checkout', true ) ? 'yes' : 'no'; |
|
449 | - $stripe_params['elements_styling'] = apply_filters( 'wc_stripe_elements_styling', false ); |
|
450 | - $stripe_params['elements_classes'] = apply_filters( 'wc_stripe_elements_classes', false ); |
|
446 | + $stripe_params['is_change_payment_page'] = isset($_GET['change_payment_method']) ? 'yes' : 'no'; |
|
447 | + $stripe_params['is_pay_for_order_page'] = isset($_GET['pay_for_order']) ? 'yes' : 'no'; |
|
448 | + $stripe_params['validate_modal_checkout'] = apply_filters('wc_stripe_validate_model_checkout', true) ? 'yes' : 'no'; |
|
449 | + $stripe_params['elements_styling'] = apply_filters('wc_stripe_elements_styling', false); |
|
450 | + $stripe_params['elements_classes'] = apply_filters('wc_stripe_elements_classes', false); |
|
451 | 451 | |
452 | 452 | // merge localized messages to be use in JS |
453 | - $stripe_params = array_merge( $stripe_params, WC_Stripe_Helper::get_localized_messages() ); |
|
453 | + $stripe_params = array_merge($stripe_params, WC_Stripe_Helper::get_localized_messages()); |
|
454 | 454 | |
455 | - wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) ); |
|
456 | - wp_localize_script( 'woocommerce_stripe_checkout', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) ); |
|
455 | + wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params)); |
|
456 | + wp_localize_script('woocommerce_stripe_checkout', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params)); |
|
457 | 457 | |
458 | - if ( $this->stripe_checkout ) { |
|
459 | - wp_enqueue_script( 'stripe_checkout' ); |
|
458 | + if ($this->stripe_checkout) { |
|
459 | + wp_enqueue_script('stripe_checkout'); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | $this->tokenization_script(); |
463 | - wp_enqueue_script( 'woocommerce_stripe' ); |
|
463 | + wp_enqueue_script('woocommerce_stripe'); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -476,41 +476,41 @@ discard block |
||
476 | 476 | * |
477 | 477 | * @return array|void |
478 | 478 | */ |
479 | - public function process_payment( $order_id, $retry = true, $force_save_source = false ) { |
|
479 | + public function process_payment($order_id, $retry = true, $force_save_source = false) { |
|
480 | 480 | try { |
481 | - $order = wc_get_order( $order_id ); |
|
481 | + $order = wc_get_order($order_id); |
|
482 | 482 | |
483 | 483 | // This comes from the create account checkbox in the checkout page. |
484 | - $create_account = ! empty( $_POST['createaccount'] ) ? true : false; |
|
484 | + $create_account = ! empty($_POST['createaccount']) ? true : false; |
|
485 | 485 | |
486 | - if ( $create_account ) { |
|
486 | + if ($create_account) { |
|
487 | 487 | $new_customer_id = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(); |
488 | - $new_stripe_customer = new WC_Stripe_Customer( $new_customer_id ); |
|
488 | + $new_stripe_customer = new WC_Stripe_Customer($new_customer_id); |
|
489 | 489 | $new_stripe_customer->create_customer(); |
490 | 490 | } |
491 | 491 | |
492 | - $prepared_source = $this->prepare_source( get_current_user_id(), $force_save_source ); |
|
492 | + $prepared_source = $this->prepare_source(get_current_user_id(), $force_save_source); |
|
493 | 493 | $source_object = $prepared_source->source_object; |
494 | 494 | |
495 | 495 | // Check if we don't allow prepaid credit cards. |
496 | - if ( ! apply_filters( 'wc_stripe_allow_prepaid_card', true ) && $this->is_prepaid_card( $source_object ) ) { |
|
497 | - $localized_message = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe' ); |
|
498 | - throw new WC_Stripe_Exception( print_r( $source_object, true ), $localized_message ); |
|
496 | + if ( ! apply_filters('wc_stripe_allow_prepaid_card', true) && $this->is_prepaid_card($source_object)) { |
|
497 | + $localized_message = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe'); |
|
498 | + throw new WC_Stripe_Exception(print_r($source_object, true), $localized_message); |
|
499 | 499 | } |
500 | 500 | |
501 | - if ( empty( $prepared_source->source ) ) { |
|
502 | - $localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' ); |
|
503 | - throw new WC_Stripe_Exception( print_r( $prepared_source, true ), $localized_message ); |
|
501 | + if (empty($prepared_source->source)) { |
|
502 | + $localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe'); |
|
503 | + throw new WC_Stripe_Exception(print_r($prepared_source, true), $localized_message); |
|
504 | 504 | } |
505 | 505 | |
506 | - $this->save_source_to_order( $order, $prepared_source ); |
|
506 | + $this->save_source_to_order($order, $prepared_source); |
|
507 | 507 | |
508 | 508 | // Result from Stripe API request. |
509 | 509 | $response = null; |
510 | 510 | |
511 | - if ( $order->get_total() > 0 ) { |
|
511 | + if ($order->get_total() > 0) { |
|
512 | 512 | // This will throw exception if not valid. |
513 | - $this->validate_minimum_order_amount( $order ); |
|
513 | + $this->validate_minimum_order_amount($order); |
|
514 | 514 | |
515 | 515 | /* |
516 | 516 | * Check if card 3DS is required or optional with 3DS setting. |
@@ -519,117 +519,117 @@ discard block |
||
519 | 519 | * Note that if we need to save source, the original source must be first |
520 | 520 | * attached to a customer in Stripe before it can be charged. |
521 | 521 | */ |
522 | - if ( $this->is_3ds_required( $source_object ) ) { |
|
523 | - $response = $this->create_3ds_source( $order, $source_object ); |
|
522 | + if ($this->is_3ds_required($source_object)) { |
|
523 | + $response = $this->create_3ds_source($order, $source_object); |
|
524 | 524 | |
525 | - if ( ! empty( $response->error ) ) { |
|
525 | + if ( ! empty($response->error)) { |
|
526 | 526 | $localized_message = $response->error->message; |
527 | 527 | |
528 | - $order->add_order_note( $localized_message ); |
|
528 | + $order->add_order_note($localized_message); |
|
529 | 529 | |
530 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
530 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | // Update order meta with 3DS source. |
534 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
535 | - update_post_meta( $order_id, '_stripe_source_id', $response->id ); |
|
534 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
535 | + update_post_meta($order_id, '_stripe_source_id', $response->id); |
|
536 | 536 | } else { |
537 | - $order->update_meta_data( '_stripe_source_id', $response->id ); |
|
537 | + $order->update_meta_data('_stripe_source_id', $response->id); |
|
538 | 538 | $order->save(); |
539 | 539 | } |
540 | 540 | |
541 | - WC_Stripe_Logger::log( 'Info: Redirecting to 3DS...' ); |
|
541 | + WC_Stripe_Logger::log('Info: Redirecting to 3DS...'); |
|
542 | 542 | |
543 | 543 | return array( |
544 | 544 | 'result' => 'success', |
545 | - 'redirect' => esc_url_raw( $response->redirect->url ), |
|
545 | + 'redirect' => esc_url_raw($response->redirect->url), |
|
546 | 546 | ); |
547 | 547 | } |
548 | 548 | |
549 | - WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" ); |
|
549 | + WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}"); |
|
550 | 550 | |
551 | 551 | /* If we're doing a retry and source is chargeable, we need to pass |
552 | 552 | * a different idempotency key and retry for success. |
553 | 553 | */ |
554 | - if ( 1 < $this->retry_interval && ! empty( $source_object ) && 'chargeable' === $source_object->status ) { |
|
555 | - add_filter( 'wc_stripe_idempotency_key', array( $this, 'change_idempotency_key' ), 10, 2 ); |
|
554 | + if (1 < $this->retry_interval && ! empty($source_object) && 'chargeable' === $source_object->status) { |
|
555 | + add_filter('wc_stripe_idempotency_key', array($this, 'change_idempotency_key'), 10, 2); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | // Make the request. |
559 | - $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $prepared_source ) ); |
|
559 | + $response = WC_Stripe_API::request($this->generate_payment_request($order, $prepared_source)); |
|
560 | 560 | |
561 | - if ( ! empty( $response->error ) ) { |
|
561 | + if ( ! empty($response->error)) { |
|
562 | 562 | // If it is an API error such connection or server, let's retry. |
563 | - if ( 'api_connection_error' === $response->error->type || 'api_error' === $response->error->type ) { |
|
564 | - if ( $retry ) { |
|
565 | - sleep( 5 ); |
|
566 | - return $this->process_payment( $order_id, false, $force_save_source ); |
|
563 | + if ('api_connection_error' === $response->error->type || 'api_error' === $response->error->type) { |
|
564 | + if ($retry) { |
|
565 | + sleep(5); |
|
566 | + return $this->process_payment($order_id, false, $force_save_source); |
|
567 | 567 | } else { |
568 | 568 | $localized_message = 'API connection error and retries exhausted.'; |
569 | - $order->add_order_note( $localized_message ); |
|
570 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
569 | + $order->add_order_note($localized_message); |
|
570 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
571 | 571 | } |
572 | 572 | } |
573 | 573 | |
574 | 574 | // We want to retry. |
575 | - if ( $this->is_retryable_error( $response->error ) ) { |
|
576 | - if ( $retry ) { |
|
575 | + if ($this->is_retryable_error($response->error)) { |
|
576 | + if ($retry) { |
|
577 | 577 | // Don't do anymore retries after this. |
578 | - if ( 5 <= $this->retry_interval ) { |
|
578 | + if (5 <= $this->retry_interval) { |
|
579 | 579 | |
580 | - return $this->process_payment( $order_id, false, $force_save_source ); |
|
580 | + return $this->process_payment($order_id, false, $force_save_source); |
|
581 | 581 | } |
582 | 582 | |
583 | - sleep( $this->retry_interval ); |
|
583 | + sleep($this->retry_interval); |
|
584 | 584 | |
585 | 585 | $this->retry_interval++; |
586 | 586 | |
587 | - return $this->process_payment( $order_id, true, $force_save_source ); |
|
587 | + return $this->process_payment($order_id, true, $force_save_source); |
|
588 | 588 | } else { |
589 | - $localized_message = __( 'On going requests error and retries exhausted.', 'woocommerce-gateway-stripe' ); |
|
590 | - $order->add_order_note( $localized_message ); |
|
591 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
589 | + $localized_message = __('On going requests error and retries exhausted.', 'woocommerce-gateway-stripe'); |
|
590 | + $order->add_order_note($localized_message); |
|
591 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | 595 | // Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without. |
596 | - if ( preg_match( '/No such customer/i', $response->error->message ) && $retry ) { |
|
597 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
598 | - delete_user_meta( $order->customer_user, '_stripe_customer_id' ); |
|
599 | - delete_post_meta( $order_id, '_stripe_customer_id' ); |
|
596 | + if (preg_match('/No such customer/i', $response->error->message) && $retry) { |
|
597 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
598 | + delete_user_meta($order->customer_user, '_stripe_customer_id'); |
|
599 | + delete_post_meta($order_id, '_stripe_customer_id'); |
|
600 | 600 | } else { |
601 | - delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' ); |
|
602 | - $order->delete_meta_data( '_stripe_customer_id' ); |
|
601 | + delete_user_meta($order->get_customer_id(), '_stripe_customer_id'); |
|
602 | + $order->delete_meta_data('_stripe_customer_id'); |
|
603 | 603 | $order->save(); |
604 | 604 | } |
605 | 605 | |
606 | - return $this->process_payment( $order_id, false, $force_save_source ); |
|
607 | - } elseif ( preg_match( '/No such token/i', $response->error->message ) && $prepared_source->token_id ) { |
|
606 | + return $this->process_payment($order_id, false, $force_save_source); |
|
607 | + } elseif (preg_match('/No such token/i', $response->error->message) && $prepared_source->token_id) { |
|
608 | 608 | // Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message. |
609 | - $wc_token = WC_Payment_Tokens::get( $prepared_source->token_id ); |
|
609 | + $wc_token = WC_Payment_Tokens::get($prepared_source->token_id); |
|
610 | 610 | $wc_token->delete(); |
611 | - $localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' ); |
|
612 | - $order->add_order_note( $localized_message ); |
|
613 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
611 | + $localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe'); |
|
612 | + $order->add_order_note($localized_message); |
|
613 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | $localized_messages = WC_Stripe_Helper::get_localized_messages(); |
617 | 617 | |
618 | - if ( 'card_error' === $response->error->type ) { |
|
619 | - $localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message; |
|
618 | + if ('card_error' === $response->error->type) { |
|
619 | + $localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message; |
|
620 | 620 | } else { |
621 | - $localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message; |
|
621 | + $localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message; |
|
622 | 622 | } |
623 | 623 | |
624 | - $order->add_order_note( $localized_message ); |
|
624 | + $order->add_order_note($localized_message); |
|
625 | 625 | |
626 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
626 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
627 | 627 | } |
628 | 628 | |
629 | - do_action( 'wc_gateway_stripe_process_payment', $response, $order ); |
|
629 | + do_action('wc_gateway_stripe_process_payment', $response, $order); |
|
630 | 630 | |
631 | 631 | // Process valid response. |
632 | - $this->process_response( $response, $order ); |
|
632 | + $this->process_response($response, $order); |
|
633 | 633 | } else { |
634 | 634 | $order->payment_complete(); |
635 | 635 | } |
@@ -640,20 +640,20 @@ discard block |
||
640 | 640 | // Return thank you page redirect. |
641 | 641 | return array( |
642 | 642 | 'result' => 'success', |
643 | - 'redirect' => $this->get_return_url( $order ), |
|
643 | + 'redirect' => $this->get_return_url($order), |
|
644 | 644 | ); |
645 | 645 | |
646 | - } catch ( WC_Stripe_Exception $e ) { |
|
647 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
648 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
646 | + } catch (WC_Stripe_Exception $e) { |
|
647 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
648 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
649 | 649 | |
650 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
650 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
651 | 651 | |
652 | 652 | /* translators: error message */ |
653 | - $order->update_status( 'failed' ); |
|
653 | + $order->update_status('failed'); |
|
654 | 654 | |
655 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
656 | - $this->send_failed_order_email( $order_id ); |
|
655 | + if ($order->has_status(array('pending', 'failed'))) { |
|
656 | + $this->send_failed_order_email($order_id); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | return array( |