@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if ( ! defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function __construct() { |
| 129 | 129 | $this->id = 'stripe'; |
| 130 | - $this->method_title = __( 'Stripe', 'woocommerce-gateway-stripe' ); |
|
| 131 | - $this->method_description = __( 'Stripe works by adding credit card fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe' ); |
|
| 130 | + $this->method_title = __('Stripe', 'woocommerce-gateway-stripe'); |
|
| 131 | + $this->method_description = __('Stripe works by adding credit card fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe'); |
|
| 132 | 132 | $this->has_fields = true; |
| 133 | 133 | $this->view_transaction_url = 'https://dashboard.stripe.com/payments/%s'; |
| 134 | 134 | $this->supports = array( |
@@ -156,44 +156,44 @@ discard block |
||
| 156 | 156 | $this->init_settings(); |
| 157 | 157 | |
| 158 | 158 | // Get setting values. |
| 159 | - $this->title = $this->get_option( 'title' ); |
|
| 160 | - $this->description = $this->get_option( 'description' ); |
|
| 161 | - $this->enabled = $this->get_option( 'enabled' ); |
|
| 162 | - $this->testmode = 'yes' === $this->get_option( 'testmode' ); |
|
| 163 | - $this->capture = 'yes' === $this->get_option( 'capture', 'yes' ); |
|
| 164 | - $this->statement_descriptor = $this->get_option( 'statement_descriptor', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
| 165 | - $this->stripe_checkout = 'yes' === $this->get_option( 'stripe_checkout' ); |
|
| 166 | - $this->stripe_checkout_locale = $this->get_option( 'stripe_checkout_locale' ); |
|
| 167 | - $this->stripe_checkout_image = $this->get_option( 'stripe_checkout_image', '' ); |
|
| 168 | - $this->saved_cards = 'yes' === $this->get_option( 'saved_cards' ); |
|
| 169 | - $this->always_save_cards = 'yes' === $this->get_option( 'always_save_cards' ); |
|
| 170 | - $this->secret_key = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' ); |
|
| 171 | - $this->publishable_key = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' ); |
|
| 172 | - $this->bitcoin = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' ); |
|
| 173 | - $this->apple_pay = 'yes' === $this->get_option( 'apple_pay', 'yes' ); |
|
| 174 | - $this->apple_pay_domain_set = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' ); |
|
| 175 | - $this->apple_pay_button = $this->get_option( 'apple_pay_button', 'black' ); |
|
| 176 | - $this->logging = 'yes' === $this->get_option( 'logging' ); |
|
| 159 | + $this->title = $this->get_option('title'); |
|
| 160 | + $this->description = $this->get_option('description'); |
|
| 161 | + $this->enabled = $this->get_option('enabled'); |
|
| 162 | + $this->testmode = 'yes' === $this->get_option('testmode'); |
|
| 163 | + $this->capture = 'yes' === $this->get_option('capture', 'yes'); |
|
| 164 | + $this->statement_descriptor = $this->get_option('statement_descriptor', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
| 165 | + $this->stripe_checkout = 'yes' === $this->get_option('stripe_checkout'); |
|
| 166 | + $this->stripe_checkout_locale = $this->get_option('stripe_checkout_locale'); |
|
| 167 | + $this->stripe_checkout_image = $this->get_option('stripe_checkout_image', ''); |
|
| 168 | + $this->saved_cards = 'yes' === $this->get_option('saved_cards'); |
|
| 169 | + $this->always_save_cards = 'yes' === $this->get_option('always_save_cards'); |
|
| 170 | + $this->secret_key = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key'); |
|
| 171 | + $this->publishable_key = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key'); |
|
| 172 | + $this->bitcoin = 'USD' === strtoupper(get_woocommerce_currency()) && 'yes' === $this->get_option('stripe_bitcoin'); |
|
| 173 | + $this->apple_pay = 'yes' === $this->get_option('apple_pay', 'yes'); |
|
| 174 | + $this->apple_pay_domain_set = 'yes' === $this->get_option('apple_pay_domain_set', 'no'); |
|
| 175 | + $this->apple_pay_button = $this->get_option('apple_pay_button', 'black'); |
|
| 176 | + $this->logging = 'yes' === $this->get_option('logging'); |
|
| 177 | 177 | $this->apple_pay_verify_notice = ''; |
| 178 | 178 | |
| 179 | - if ( $this->stripe_checkout ) { |
|
| 180 | - $this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' ); |
|
| 179 | + if ($this->stripe_checkout) { |
|
| 180 | + $this->order_button_text = __('Continue to payment', 'woocommerce-gateway-stripe'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( $this->testmode ) { |
|
| 184 | - $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">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' ); |
|
| 185 | - $this->description = trim( $this->description ); |
|
| 183 | + if ($this->testmode) { |
|
| 184 | + $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">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe'), 'https://stripe.com/docs/testing'); |
|
| 185 | + $this->description = trim($this->description); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - WC_Stripe_API::set_secret_key( $this->secret_key ); |
|
| 188 | + WC_Stripe_API::set_secret_key($this->secret_key); |
|
| 189 | 189 | |
| 190 | 190 | $this->init_apple_pay(); |
| 191 | 191 | |
| 192 | 192 | // Hooks. |
| 193 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
| 194 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); |
|
| 195 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 196 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
| 193 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
| 194 | + add_action('admin_enqueue_scripts', array($this, 'admin_scripts')); |
|
| 195 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
| 196 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -203,26 +203,26 @@ discard block |
||
| 203 | 203 | * @return string |
| 204 | 204 | */ |
| 205 | 205 | public function get_icon() { |
| 206 | - $ext = version_compare( WC()->version, '2.6', '>=' ) ? '.svg' : '.png'; |
|
| 207 | - $style = version_compare( WC()->version, '2.6', '>=' ) ? 'style="margin-left: 0.3em"' : ''; |
|
| 206 | + $ext = version_compare(WC()->version, '2.6', '>=') ? '.svg' : '.png'; |
|
| 207 | + $style = version_compare(WC()->version, '2.6', '>=') ? 'style="margin-left: 0.3em"' : ''; |
|
| 208 | 208 | |
| 209 | - $icon = '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/visa' . $ext ) . '" alt="Visa" width="32" ' . $style . ' />'; |
|
| 210 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard' . $ext ) . '" alt="Mastercard" width="32" ' . $style . ' />'; |
|
| 211 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/amex' . $ext ) . '" alt="Amex" width="32" ' . $style . ' />'; |
|
| 209 | + $icon = '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/visa' . $ext) . '" alt="Visa" width="32" ' . $style . ' />'; |
|
| 210 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard' . $ext) . '" alt="Mastercard" width="32" ' . $style . ' />'; |
|
| 211 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/amex' . $ext) . '" alt="Amex" width="32" ' . $style . ' />'; |
|
| 212 | 212 | |
| 213 | 213 | $base_location = wc_get_base_location(); |
| 214 | 214 | |
| 215 | - if ( 'US' === $base_location['country'] ) { |
|
| 216 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/discover' . $ext ) . '" alt="Discover" width="32" ' . $style . ' />'; |
|
| 217 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb' . $ext ) . '" alt="JCB" width="32" ' . $style . ' />'; |
|
| 218 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/diners' . $ext ) . '" alt="Diners" width="32" ' . $style . ' />'; |
|
| 215 | + if ('US' === $base_location['country']) { |
|
| 216 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/discover' . $ext) . '" alt="Discover" width="32" ' . $style . ' />'; |
|
| 217 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb' . $ext) . '" alt="JCB" width="32" ' . $style . ' />'; |
|
| 218 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/diners' . $ext) . '" alt="Diners" width="32" ' . $style . ' />'; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if ( $this->bitcoin && $this->stripe_checkout ) { |
|
| 222 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( plugins_url( '/assets/images/bitcoin' . $ext, WC_STRIPE_MAIN_FILE ) ) . '" alt="Bitcoin" width="24" ' . $style . ' />'; |
|
| 221 | + if ($this->bitcoin && $this->stripe_checkout) { |
|
| 222 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(plugins_url('/assets/images/bitcoin' . $ext, WC_STRIPE_MAIN_FILE)) . '" alt="Bitcoin" width="24" ' . $style . ' />'; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id ); |
|
| 225 | + return apply_filters('woocommerce_gateway_icon', $icon, $this->id); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -233,11 +233,11 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @return float|int |
| 235 | 235 | */ |
| 236 | - public function get_stripe_amount( $total, $currency = '' ) { |
|
| 237 | - if ( ! $currency ) { |
|
| 236 | + public function get_stripe_amount($total, $currency = '') { |
|
| 237 | + if ( ! $currency) { |
|
| 238 | 238 | $currency = get_woocommerce_currency(); |
| 239 | 239 | } |
| 240 | - switch ( strtoupper( $currency ) ) { |
|
| 240 | + switch (strtoupper($currency)) { |
|
| 241 | 241 | // Zero decimal currencies. |
| 242 | 242 | case 'BIF' : |
| 243 | 243 | case 'CLP' : |
@@ -254,10 +254,10 @@ discard block |
||
| 254 | 254 | case 'XAF' : |
| 255 | 255 | case 'XOF' : |
| 256 | 256 | case 'XPF' : |
| 257 | - $total = absint( $total ); |
|
| 257 | + $total = absint($total); |
|
| 258 | 258 | break; |
| 259 | 259 | default : |
| 260 | - $total = round( $total, 2 ) * 100; // In cents. |
|
| 260 | + $total = round($total, 2) * 100; // In cents. |
|
| 261 | 261 | break; |
| 262 | 262 | } |
| 263 | 263 | return $total; |
@@ -272,9 +272,9 @@ discard block |
||
| 272 | 272 | public function init_apple_pay() { |
| 273 | 273 | if ( |
| 274 | 274 | is_admin() && |
| 275 | - isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] && |
|
| 276 | - isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] && |
|
| 277 | - isset( $_GET['section'] ) && 'stripe' === $_GET['section'] |
|
| 275 | + isset($_GET['page']) && 'wc-settings' === $_GET['page'] && |
|
| 276 | + isset($_GET['tab']) && 'checkout' === $_GET['tab'] && |
|
| 277 | + isset($_GET['section']) && 'stripe' === $_GET['section'] |
|
| 278 | 278 | ) { |
| 279 | 279 | $this->process_apple_pay_verification(); |
| 280 | 280 | } |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | * @version 3.1.0 |
| 288 | 288 | * @param string $secret_key |
| 289 | 289 | */ |
| 290 | - private function register_apple_pay_domain( $secret_key = '' ) { |
|
| 291 | - if ( empty( $secret_key ) ) { |
|
| 292 | - throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) ); |
|
| 290 | + private function register_apple_pay_domain($secret_key = '') { |
|
| 291 | + if (empty($secret_key)) { |
|
| 292 | + throw new Exception(__('Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe')); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | $endpoint = 'https://api.stripe.com/v1/apple_pay/domains'; |
@@ -303,21 +303,21 @@ discard block |
||
| 303 | 303 | 'Authorization' => 'Bearer ' . $secret_key, |
| 304 | 304 | ); |
| 305 | 305 | |
| 306 | - $response = wp_remote_post( $endpoint, array( |
|
| 306 | + $response = wp_remote_post($endpoint, array( |
|
| 307 | 307 | 'headers' => $headers, |
| 308 | - 'body' => http_build_query( $data ), |
|
| 309 | - ) ); |
|
| 308 | + 'body' => http_build_query($data), |
|
| 309 | + )); |
|
| 310 | 310 | |
| 311 | - if ( is_wp_error( $response ) ) { |
|
| 312 | - throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) ); |
|
| 311 | + if (is_wp_error($response)) { |
|
| 312 | + throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $response->get_error_message())); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - if ( 200 !== $response['response']['code'] ) { |
|
| 316 | - $parsed_response = json_decode( $response['body'] ); |
|
| 315 | + if (200 !== $response['response']['code']) { |
|
| 316 | + $parsed_response = json_decode($response['body']); |
|
| 317 | 317 | |
| 318 | 318 | $this->apple_pay_verify_notice = $parsed_response->error->message; |
| 319 | 319 | |
| 320 | - throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $parsed_response->error->message ) ); |
|
| 320 | + throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $parsed_response->error->message)); |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | |
@@ -328,48 +328,48 @@ discard block |
||
| 328 | 328 | * @version 3.1.0 |
| 329 | 329 | */ |
| 330 | 330 | public function process_apple_pay_verification() { |
| 331 | - $gateway_settings = get_option( 'woocommerce_stripe_settings', '' ); |
|
| 331 | + $gateway_settings = get_option('woocommerce_stripe_settings', ''); |
|
| 332 | 332 | |
| 333 | 333 | try { |
| 334 | - $path = untrailingslashit( preg_replace( "!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME'] ) ); |
|
| 334 | + $path = untrailingslashit(preg_replace("!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME'])); |
|
| 335 | 335 | $dir = '.well-known'; |
| 336 | 336 | $file = 'apple-developer-merchantid-domain-association'; |
| 337 | 337 | $fullpath = $path . '/' . $dir . '/' . $file; |
| 338 | 338 | |
| 339 | - if ( ! empty( $gateway_settings['apple_pay_domain_set'] ) && 'yes' === $gateway_settings['apple_pay_domain_set'] && file_exists( $fullpath ) ) { |
|
| 339 | + if ( ! empty($gateway_settings['apple_pay_domain_set']) && 'yes' === $gateway_settings['apple_pay_domain_set'] && file_exists($fullpath)) { |
|
| 340 | 340 | return; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if ( ! file_exists( $path . '/' . $dir ) ) { |
|
| 344 | - if ( ! @mkdir( $path . '/' . $dir, 0755 ) ) { |
|
| 345 | - throw new Exception( __( 'Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe' ) ); |
|
| 343 | + if ( ! file_exists($path . '/' . $dir)) { |
|
| 344 | + if ( ! @mkdir($path . '/' . $dir, 0755)) { |
|
| 345 | + throw new Exception(__('Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe')); |
|
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - if ( ! file_exists( $fullpath ) ) { |
|
| 350 | - if ( ! @copy( WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath ) ) { |
|
| 351 | - throw new Exception( __( 'Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe' ) ); |
|
| 349 | + if ( ! file_exists($fullpath)) { |
|
| 350 | + if ( ! @copy(WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath)) { |
|
| 351 | + throw new Exception(__('Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe')); |
|
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | // At this point then the domain association folder and file should be available. |
| 356 | 356 | // Proceed to verify/and or verify again. |
| 357 | - $this->register_apple_pay_domain( $this->secret_key ); |
|
| 357 | + $this->register_apple_pay_domain($this->secret_key); |
|
| 358 | 358 | |
| 359 | 359 | // No errors to this point, verification success! |
| 360 | 360 | $gateway_settings['apple_pay_domain_set'] = 'yes'; |
| 361 | 361 | $this->apple_pay_domain_set = true; |
| 362 | 362 | |
| 363 | - update_option( 'woocommerce_stripe_settings', $gateway_settings ); |
|
| 363 | + update_option('woocommerce_stripe_settings', $gateway_settings); |
|
| 364 | 364 | |
| 365 | - $this->log( __( 'Your domain has been verified with Apple Pay!', 'woocommerce-gateway-stripe' ) ); |
|
| 365 | + $this->log(__('Your domain has been verified with Apple Pay!', 'woocommerce-gateway-stripe')); |
|
| 366 | 366 | |
| 367 | - } catch ( Exception $e ) { |
|
| 367 | + } catch (Exception $e) { |
|
| 368 | 368 | $gateway_settings['apple_pay_domain_set'] = 'no'; |
| 369 | 369 | |
| 370 | - update_option( 'woocommerce_stripe_settings', $gateway_settings ); |
|
| 370 | + update_option('woocommerce_stripe_settings', $gateway_settings); |
|
| 371 | 371 | |
| 372 | - $this->log( sprintf( __( 'Error: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) ); |
|
| 372 | + $this->log(sprintf(__('Error: %s', 'woocommerce-gateway-stripe'), $e->getMessage())); |
|
| 373 | 373 | } |
| 374 | 374 | } |
| 375 | 375 | |
@@ -377,11 +377,11 @@ discard block |
||
| 377 | 377 | * Check if SSL is enabled and notify the user |
| 378 | 378 | */ |
| 379 | 379 | public function admin_notices() { |
| 380 | - if ( 'no' === $this->enabled ) { |
|
| 380 | + if ('no' === $this->enabled) { |
|
| 381 | 381 | return; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - if ( $this->apple_pay && ! empty( $this->apple_pay_verify_notice ) ) { |
|
| 384 | + if ($this->apple_pay && ! empty($this->apple_pay_verify_notice)) { |
|
| 385 | 385 | $allowed_html = array( |
| 386 | 386 | 'a' => array( |
| 387 | 387 | 'href' => array(), |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | ), |
| 390 | 390 | ); |
| 391 | 391 | |
| 392 | - echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses( make_clickable( $this->apple_pay_verify_notice ), $allowed_html ) . '</p></div>'; |
|
| 392 | + echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses(make_clickable($this->apple_pay_verify_notice), $allowed_html) . '</p></div>'; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -397,13 +397,13 @@ discard block |
||
| 397 | 397 | * when setting screen is displayed. So if domain verification is not set, |
| 398 | 398 | * something went wrong so lets notify user. |
| 399 | 399 | */ |
| 400 | - if ( ! empty( $this->secret_key ) && $this->apple_pay && ! $this->apple_pay_domain_set ) { |
|
| 401 | - echo '<div class="error stripe-apple-pay-message"><p>' . sprintf( __( 'Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe' ), '<a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">', '</a>' ) . '</p></div>'; |
|
| 400 | + if ( ! empty($this->secret_key) && $this->apple_pay && ! $this->apple_pay_domain_set) { |
|
| 401 | + echo '<div class="error stripe-apple-pay-message"><p>' . sprintf(__('Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe'), '<a href="' . admin_url('admin.php?page=wc-status&tab=logs') . '">', '</a>') . '</p></div>'; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | // Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected. |
| 405 | - if ( ( function_exists( 'wc_site_is_https' ) && ! wc_site_is_https() ) && ( 'no' === get_option( 'woocommerce_force_ssl_checkout' ) && ! class_exists( 'WordPressHTTPS' ) ) ) { |
|
| 406 | - echo '<div class="error stripe-ssl-message"><p>' . sprintf( __( 'Stripe is enabled, but the <a href="%s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - Stripe will only work in test mode.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout' ) ) . '</p></div>'; |
|
| 405 | + if ((function_exists('wc_site_is_https') && ! wc_site_is_https()) && ('no' === get_option('woocommerce_force_ssl_checkout') && ! class_exists('WordPressHTTPS'))) { |
|
| 406 | + echo '<div class="error stripe-ssl-message"><p>' . sprintf(__('Stripe is enabled, but the <a href="%s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - Stripe will only work in test mode.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout')) . '</p></div>'; |
|
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | |
@@ -411,11 +411,11 @@ discard block |
||
| 411 | 411 | * Check if this gateway is enabled |
| 412 | 412 | */ |
| 413 | 413 | public function is_available() { |
| 414 | - if ( 'yes' === $this->enabled ) { |
|
| 415 | - if ( ! $this->testmode && is_checkout() && ! is_ssl() ) { |
|
| 414 | + if ('yes' === $this->enabled) { |
|
| 415 | + if ( ! $this->testmode && is_checkout() && ! is_ssl()) { |
|
| 416 | 416 | return false; |
| 417 | 417 | } |
| 418 | - if ( ! $this->secret_key || ! $this->publishable_key ) { |
|
| 418 | + if ( ! $this->secret_key || ! $this->publishable_key) { |
|
| 419 | 419 | return false; |
| 420 | 420 | } |
| 421 | 421 | return true; |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | * Initialise Gateway Settings Form Fields |
| 428 | 428 | */ |
| 429 | 429 | public function init_form_fields() { |
| 430 | - $this->form_fields = include( 'settings-stripe.php' ); |
|
| 430 | + $this->form_fields = include('settings-stripe.php'); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -435,54 +435,54 @@ discard block |
||
| 435 | 435 | */ |
| 436 | 436 | public function payment_fields() { |
| 437 | 437 | $user = wp_get_current_user(); |
| 438 | - $display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards; |
|
| 438 | + $display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards; |
|
| 439 | 439 | $total = WC()->cart->total; |
| 440 | 440 | |
| 441 | 441 | // If paying from order, we need to get total from order not cart. |
| 442 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
| 443 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
| 442 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
| 443 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
| 444 | 444 | $total = $order->get_total(); |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - if ( $user->ID ) { |
|
| 448 | - $user_email = get_user_meta( $user->ID, 'billing_email', true ); |
|
| 447 | + if ($user->ID) { |
|
| 448 | + $user_email = get_user_meta($user->ID, 'billing_email', true); |
|
| 449 | 449 | $user_email = $user_email ? $user_email : $user->user_email; |
| 450 | 450 | } else { |
| 451 | 451 | $user_email = ''; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - if ( is_add_payment_method_page() ) { |
|
| 455 | - $pay_button_text = __( 'Add Card', 'woocommerce-gateway-stripe' ); |
|
| 454 | + if (is_add_payment_method_page()) { |
|
| 455 | + $pay_button_text = __('Add Card', 'woocommerce-gateway-stripe'); |
|
| 456 | 456 | } else { |
| 457 | 457 | $pay_button_text = ''; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | echo '<div |
| 461 | 461 | id="stripe-payment-data" |
| 462 | - data-panel-label="' . esc_attr( $pay_button_text ) . '" |
|
| 462 | + data-panel-label="' . esc_attr($pay_button_text) . '" |
|
| 463 | 463 | data-description="" |
| 464 | - data-email="' . esc_attr( $user_email ) . '" |
|
| 465 | - data-amount="' . esc_attr( $this->get_stripe_amount( $total ) ) . '" |
|
| 466 | - data-name="' . esc_attr( $this->statement_descriptor ) . '" |
|
| 467 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '" |
|
| 468 | - data-image="' . esc_attr( $this->stripe_checkout_image ) . '" |
|
| 469 | - data-bitcoin="' . esc_attr( $this->bitcoin ? 'true' : 'false' ) . '" |
|
| 470 | - data-locale="' . esc_attr( $this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en' ) . '" |
|
| 471 | - data-allow-remember-me="' . esc_attr( $this->saved_cards ? 'true' : 'false' ) . '">'; |
|
| 464 | + data-email="' . esc_attr($user_email) . '" |
|
| 465 | + data-amount="' . esc_attr($this->get_stripe_amount($total)) . '" |
|
| 466 | + data-name="' . esc_attr($this->statement_descriptor) . '" |
|
| 467 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '" |
|
| 468 | + data-image="' . esc_attr($this->stripe_checkout_image) . '" |
|
| 469 | + data-bitcoin="' . esc_attr($this->bitcoin ? 'true' : 'false') . '" |
|
| 470 | + data-locale="' . esc_attr($this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en') . '" |
|
| 471 | + data-allow-remember-me="' . esc_attr($this->saved_cards ? 'true' : 'false') . '">'; |
|
| 472 | 472 | |
| 473 | - if ( $this->description ) { |
|
| 474 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) ); |
|
| 473 | + if ($this->description) { |
|
| 474 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description))); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | - if ( $display_tokenization ) { |
|
| 477 | + if ($display_tokenization) { |
|
| 478 | 478 | $this->tokenization_script(); |
| 479 | 479 | $this->saved_payment_methods(); |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - if ( ! $this->stripe_checkout ) { |
|
| 482 | + if ( ! $this->stripe_checkout) { |
|
| 483 | 483 | $this->form(); |
| 484 | 484 | |
| 485 | - if ( $display_tokenization && ! $this->always_save_cards ) { |
|
| 485 | + if ($display_tokenization && ! $this->always_save_cards) { |
|
| 486 | 486 | $this->save_payment_method_checkbox(); |
| 487 | 487 | } |
| 488 | 488 | } |
@@ -498,20 +498,20 @@ discard block |
||
| 498 | 498 | * @return array |
| 499 | 499 | */ |
| 500 | 500 | public function get_localized_messages() { |
| 501 | - return apply_filters( 'wc_stripe_localized_messages', array( |
|
| 502 | - 'invalid_number' => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ), |
|
| 503 | - 'invalid_expiry_month' => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 504 | - 'invalid_expiry_year' => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 505 | - 'invalid_cvc' => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 506 | - 'incorrect_number' => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ), |
|
| 507 | - 'expired_card' => __( 'The card has expired.', 'woocommerce-gateway-stripe' ), |
|
| 508 | - 'incorrect_cvc' => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ), |
|
| 509 | - 'incorrect_zip' => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ), |
|
| 510 | - 'card_declined' => __( 'The card was declined.', 'woocommerce-gateway-stripe' ), |
|
| 511 | - 'missing' => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ), |
|
| 512 | - 'processing_error' => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ), |
|
| 513 | - 'invalid_request_error' => __( 'Could not find payment information.', 'woocommerce-gateway-stripe' ), |
|
| 514 | - ) ); |
|
| 501 | + return apply_filters('wc_stripe_localized_messages', array( |
|
| 502 | + 'invalid_number' => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'), |
|
| 503 | + 'invalid_expiry_month' => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'), |
|
| 504 | + 'invalid_expiry_year' => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'), |
|
| 505 | + 'invalid_cvc' => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'), |
|
| 506 | + 'incorrect_number' => __('The card number is incorrect.', 'woocommerce-gateway-stripe'), |
|
| 507 | + 'expired_card' => __('The card has expired.', 'woocommerce-gateway-stripe'), |
|
| 508 | + 'incorrect_cvc' => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'), |
|
| 509 | + 'incorrect_zip' => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'), |
|
| 510 | + 'card_declined' => __('The card was declined.', 'woocommerce-gateway-stripe'), |
|
| 511 | + 'missing' => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'), |
|
| 512 | + 'processing_error' => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'), |
|
| 513 | + 'invalid_request_error' => __('Could not find payment information.', 'woocommerce-gateway-stripe'), |
|
| 514 | + )); |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
@@ -521,28 +521,28 @@ discard block |
||
| 521 | 521 | * @version 3.1.0 |
| 522 | 522 | */ |
| 523 | 523 | public function admin_scripts() { |
| 524 | - if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) { |
|
| 524 | + if ('woocommerce_page_wc-settings' !== get_current_screen()->id) { |
|
| 525 | 525 | return; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 528 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 529 | 529 | |
| 530 | - wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true ); |
|
| 530 | + wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true); |
|
| 531 | 531 | |
| 532 | 532 | $stripe_admin_params = array( |
| 533 | 533 | 'localized_messages' => array( |
| 534 | - 'not_valid_live_key_msg' => __( 'This is not a valid live key. Live keys start with "sk_live_" and "pk_live_".', 'woocommerce-gateway-stripe' ), |
|
| 535 | - 'not_valid_test_key_msg' => __( 'This is not a valid test key. Test keys start with "sk_test_" and "pk_test_".', 'woocommerce-gateway-stripe' ), |
|
| 536 | - 're_verify_button_text' => __( 'Re-verify Domain', 'woocommerce-gateway-stripe' ), |
|
| 537 | - 'missing_secret_key' => __( 'Missing Secret Key. Please set the secret key field above and re-try.', 'woocommerce-gateway-stripe' ), |
|
| 534 | + 'not_valid_live_key_msg' => __('This is not a valid live key. Live keys start with "sk_live_" and "pk_live_".', 'woocommerce-gateway-stripe'), |
|
| 535 | + 'not_valid_test_key_msg' => __('This is not a valid test key. Test keys start with "sk_test_" and "pk_test_".', 'woocommerce-gateway-stripe'), |
|
| 536 | + 're_verify_button_text' => __('Re-verify Domain', 'woocommerce-gateway-stripe'), |
|
| 537 | + 'missing_secret_key' => __('Missing Secret Key. Please set the secret key field above and re-try.', 'woocommerce-gateway-stripe'), |
|
| 538 | 538 | ), |
| 539 | - 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
| 539 | + 'ajaxurl' => admin_url('admin-ajax.php'), |
|
| 540 | 540 | 'nonce' => array( |
| 541 | - 'apple_pay_domain_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_domain_nonce' ), |
|
| 541 | + 'apple_pay_domain_nonce' => wp_create_nonce('_wc_stripe_apple_pay_domain_nonce'), |
|
| 542 | 542 | ), |
| 543 | 543 | ); |
| 544 | 544 | |
| 545 | - wp_localize_script( 'woocommerce_stripe_admin', 'wc_stripe_admin_params', apply_filters( 'wc_stripe_admin_params', $stripe_admin_params ) ); |
|
| 545 | + wp_localize_script('woocommerce_stripe_admin', 'wc_stripe_admin_params', apply_filters('wc_stripe_admin_params', $stripe_admin_params)); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | /** |
@@ -553,49 +553,49 @@ discard block |
||
| 553 | 553 | * @access public |
| 554 | 554 | */ |
| 555 | 555 | public function payment_scripts() { |
| 556 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { |
|
| 556 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) { |
|
| 557 | 557 | return; |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 560 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 561 | 561 | |
| 562 | - if ( $this->stripe_checkout ) { |
|
| 563 | - wp_enqueue_script( 'stripe_checkout', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true ); |
|
| 564 | - wp_enqueue_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe-checkout' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'stripe_checkout' ), WC_STRIPE_VERSION, true ); |
|
| 562 | + if ($this->stripe_checkout) { |
|
| 563 | + wp_enqueue_script('stripe_checkout', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true); |
|
| 564 | + wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe-checkout' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('stripe_checkout'), WC_STRIPE_VERSION, true); |
|
| 565 | 565 | } else { |
| 566 | - wp_enqueue_script( 'stripe', 'https://js.stripe.com/v2/', '', '1.0', true ); |
|
| 567 | - wp_enqueue_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripe' ), WC_STRIPE_VERSION, true ); |
|
| 566 | + wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', '', '1.0', true); |
|
| 567 | + wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | $stripe_params = array( |
| 571 | 571 | 'key' => $this->publishable_key, |
| 572 | - 'i18n_terms' => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ), |
|
| 573 | - 'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ), |
|
| 572 | + 'i18n_terms' => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'), |
|
| 573 | + 'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'), |
|
| 574 | 574 | ); |
| 575 | 575 | |
| 576 | 576 | // If we're on the pay page we need to pass stripe.js the address of the order. |
| 577 | - if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) { |
|
| 578 | - $order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) ); |
|
| 579 | - $order = wc_get_order( $order_id ); |
|
| 577 | + if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) { |
|
| 578 | + $order_id = wc_get_order_id_by_order_key(urldecode($_GET['key'])); |
|
| 579 | + $order = wc_get_order($order_id); |
|
| 580 | 580 | |
| 581 | - $stripe_params['billing_first_name'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_first_name : $order->get_billing_first_name(); |
|
| 582 | - $stripe_params['billing_last_name'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_last_name : $order->get_billing_last_name(); |
|
| 583 | - $stripe_params['billing_address_1'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_address_1 : $order->get_billing_address_1(); |
|
| 584 | - $stripe_params['billing_address_2'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_address_2 : $order->get_billing_address_2(); |
|
| 585 | - $stripe_params['billing_state'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_state : $order->get_billing_state(); |
|
| 586 | - $stripe_params['billing_city'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_city : $order->get_billing_city(); |
|
| 587 | - $stripe_params['billing_postcode'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_postcode : $order->get_billing_postcode(); |
|
| 588 | - $stripe_params['billing_country'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_country : $order->get_billing_country(); |
|
| 581 | + $stripe_params['billing_first_name'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_first_name : $order->get_billing_first_name(); |
|
| 582 | + $stripe_params['billing_last_name'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_last_name : $order->get_billing_last_name(); |
|
| 583 | + $stripe_params['billing_address_1'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_address_1 : $order->get_billing_address_1(); |
|
| 584 | + $stripe_params['billing_address_2'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_address_2 : $order->get_billing_address_2(); |
|
| 585 | + $stripe_params['billing_state'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_state : $order->get_billing_state(); |
|
| 586 | + $stripe_params['billing_city'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_city : $order->get_billing_city(); |
|
| 587 | + $stripe_params['billing_postcode'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_postcode : $order->get_billing_postcode(); |
|
| 588 | + $stripe_params['billing_country'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_country : $order->get_billing_country(); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - $stripe_params['no_prepaid_card_msg'] = __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' ); |
|
| 592 | - $stripe_params['allow_prepaid_card'] = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no'; |
|
| 593 | - $stripe_params['stripe_checkout_require_billing_address'] = apply_filters( 'wc_stripe_checkout_require_billing_address', false ) ? 'yes' : 'no'; |
|
| 591 | + $stripe_params['no_prepaid_card_msg'] = __('Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe'); |
|
| 592 | + $stripe_params['allow_prepaid_card'] = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no'; |
|
| 593 | + $stripe_params['stripe_checkout_require_billing_address'] = apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'yes' : 'no'; |
|
| 594 | 594 | |
| 595 | 595 | // merge localized messages to be use in JS |
| 596 | - $stripe_params = array_merge( $stripe_params, $this->get_localized_messages() ); |
|
| 596 | + $stripe_params = array_merge($stripe_params, $this->get_localized_messages()); |
|
| 597 | 597 | |
| 598 | - wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) ); |
|
| 598 | + wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params)); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** |
@@ -604,35 +604,35 @@ discard block |
||
| 604 | 604 | * @param object $source |
| 605 | 605 | * @return array() |
| 606 | 606 | */ |
| 607 | - protected function generate_payment_request( $order, $source ) { |
|
| 607 | + protected function generate_payment_request($order, $source) { |
|
| 608 | 608 | $post_data = array(); |
| 609 | - $post_data['currency'] = strtolower( version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->get_order_currency() : $order->get_currency() ); |
|
| 610 | - $post_data['amount'] = $this->get_stripe_amount( $order->get_total(), $post_data['currency'] ); |
|
| 611 | - $post_data['description'] = sprintf( __( '%1$s - Order %2$s', 'woocommerce-gateway-stripe' ), $this->statement_descriptor, $order->get_order_number() ); |
|
| 609 | + $post_data['currency'] = strtolower(version_compare(WC_VERSION, '3.0.0', '<') ? $order->get_order_currency() : $order->get_currency()); |
|
| 610 | + $post_data['amount'] = $this->get_stripe_amount($order->get_total(), $post_data['currency']); |
|
| 611 | + $post_data['description'] = sprintf(__('%1$s - Order %2$s', 'woocommerce-gateway-stripe'), $this->statement_descriptor, $order->get_order_number()); |
|
| 612 | 612 | $post_data['capture'] = $this->capture ? 'true' : 'false'; |
| 613 | 613 | |
| 614 | - $billing_email = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_email : $order->get_billing_email(); |
|
| 615 | - $billing_first_name = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_first_name : $order->get_billing_first_name(); |
|
| 616 | - $billing_last_name = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_last_name : $order->get_billing_last_name(); |
|
| 614 | + $billing_email = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_email : $order->get_billing_email(); |
|
| 615 | + $billing_first_name = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_first_name : $order->get_billing_first_name(); |
|
| 616 | + $billing_last_name = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_last_name : $order->get_billing_last_name(); |
|
| 617 | 617 | |
| 618 | - if ( ! empty( $billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) { |
|
| 618 | + if ( ! empty($billing_email) && apply_filters('wc_stripe_send_stripe_receipt', false)) { |
|
| 619 | 619 | $post_data['receipt_email'] = $billing_email; |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - $post_data['expand[]'] = 'balance_transaction'; |
|
| 622 | + $post_data['expand[]'] = 'balance_transaction'; |
|
| 623 | 623 | |
| 624 | 624 | $metadata = array( |
| 625 | - __( 'Customer Name', 'woocommerce-gateway-stripe' ) => sanitize_text_field( $billing_first_name ) . ' ' . sanitize_text_field( $billing_last_name ), |
|
| 626 | - __( 'Customer Email', 'woocommerce-gateway-stripe' ) => sanitize_email( $billing_email ), |
|
| 625 | + __('Customer Name', 'woocommerce-gateway-stripe') => sanitize_text_field($billing_first_name) . ' ' . sanitize_text_field($billing_last_name), |
|
| 626 | + __('Customer Email', 'woocommerce-gateway-stripe') => sanitize_email($billing_email), |
|
| 627 | 627 | ); |
| 628 | 628 | |
| 629 | - $post_data['metadata'] = apply_filters( 'wc_stripe_payment_metadata', $metadata, $order, $source ); |
|
| 629 | + $post_data['metadata'] = apply_filters('wc_stripe_payment_metadata', $metadata, $order, $source); |
|
| 630 | 630 | |
| 631 | - if ( $source->customer ) { |
|
| 631 | + if ($source->customer) { |
|
| 632 | 632 | $post_data['customer'] = $source->customer; |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | - if ( $source->source ) { |
|
| 635 | + if ($source->source) { |
|
| 636 | 636 | $post_data['source'] = $source->source; |
| 637 | 637 | } |
| 638 | 638 | |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | * @param WC_Order $order |
| 645 | 645 | * @param object $source |
| 646 | 646 | */ |
| 647 | - return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $source ); |
|
| 647 | + return apply_filters('wc_stripe_generate_payment_request', $post_data, $order, $source); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | /** |
@@ -656,37 +656,37 @@ discard block |
||
| 656 | 656 | * @throws Exception When card was not added or for and invalid card. |
| 657 | 657 | * @return object |
| 658 | 658 | */ |
| 659 | - protected function get_source( $user_id, $force_customer = false ) { |
|
| 660 | - $stripe_customer = new WC_Stripe_Customer( $user_id ); |
|
| 659 | + protected function get_source($user_id, $force_customer = false) { |
|
| 660 | + $stripe_customer = new WC_Stripe_Customer($user_id); |
|
| 661 | 661 | $stripe_source = false; |
| 662 | 662 | $token_id = false; |
| 663 | 663 | |
| 664 | 664 | // New CC info was entered and we have a new token to process |
| 665 | - if ( isset( $_POST['stripe_token'] ) ) { |
|
| 666 | - $stripe_token = wc_clean( $_POST['stripe_token'] ); |
|
| 667 | - $maybe_saved_card = $this->always_save_cards || ( isset( $_POST['wc-stripe-new-payment-method'] ) && ! empty( $_POST['wc-stripe-new-payment-method'] ) ); |
|
| 665 | + if (isset($_POST['stripe_token'])) { |
|
| 666 | + $stripe_token = wc_clean($_POST['stripe_token']); |
|
| 667 | + $maybe_saved_card = $this->always_save_cards || (isset($_POST['wc-stripe-new-payment-method']) && ! empty($_POST['wc-stripe-new-payment-method'])); |
|
| 668 | 668 | |
| 669 | 669 | // This is true if the user wants to store the card to their account or if the option to always save cards is enabled. |
| 670 | - if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_customer ) { |
|
| 671 | - $stripe_source = $stripe_customer->add_card( $stripe_token ); |
|
| 670 | + if (($user_id && $this->saved_cards && $maybe_saved_card) || $force_customer) { |
|
| 671 | + $stripe_source = $stripe_customer->add_card($stripe_token); |
|
| 672 | 672 | |
| 673 | - if ( is_wp_error( $stripe_source ) ) { |
|
| 674 | - throw new Exception( $stripe_source->get_error_message() ); |
|
| 673 | + if (is_wp_error($stripe_source)) { |
|
| 674 | + throw new Exception($stripe_source->get_error_message()); |
|
| 675 | 675 | } |
| 676 | 676 | } else { |
| 677 | 677 | // Not saving token, so don't define customer either. |
| 678 | 678 | $stripe_source = $stripe_token; |
| 679 | 679 | $stripe_customer = false; |
| 680 | 680 | } |
| 681 | - } elseif ( isset( $_POST['wc-stripe-payment-token'] ) && 'new' !== $_POST['wc-stripe-payment-token'] ) { |
|
| 681 | + } elseif (isset($_POST['wc-stripe-payment-token']) && 'new' !== $_POST['wc-stripe-payment-token']) { |
|
| 682 | 682 | // Use an existing token, and then process the payment |
| 683 | 683 | |
| 684 | - $token_id = wc_clean( $_POST['wc-stripe-payment-token'] ); |
|
| 685 | - $token = WC_Payment_Tokens::get( $token_id ); |
|
| 684 | + $token_id = wc_clean($_POST['wc-stripe-payment-token']); |
|
| 685 | + $token = WC_Payment_Tokens::get($token_id); |
|
| 686 | 686 | |
| 687 | - if ( ! $token || $token->get_user_id() !== get_current_user_id() ) { |
|
| 688 | - WC()->session->set( 'refresh_totals', true ); |
|
| 689 | - throw new Exception( __( 'Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe' ) ); |
|
| 687 | + if ( ! $token || $token->get_user_id() !== get_current_user_id()) { |
|
| 688 | + WC()->session->set('refresh_totals', true); |
|
| 689 | + throw new Exception(__('Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe')); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | $stripe_source = $token->get_token(); |
@@ -710,19 +710,19 @@ discard block |
||
| 710 | 710 | * @param object $order |
| 711 | 711 | * @return object |
| 712 | 712 | */ |
| 713 | - protected function get_order_source( $order = null ) { |
|
| 713 | + protected function get_order_source($order = null) { |
|
| 714 | 714 | $stripe_customer = new WC_Stripe_Customer(); |
| 715 | 715 | $stripe_source = false; |
| 716 | 716 | $token_id = false; |
| 717 | 717 | |
| 718 | - if ( $order ) { |
|
| 719 | - $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id(); |
|
| 718 | + if ($order) { |
|
| 719 | + $order_id = version_compare(WC_VERSION, '3.0.0', '<') ? $order->id : $order->get_id(); |
|
| 720 | 720 | |
| 721 | - if ( $meta_value = get_post_meta( $order_id, '_stripe_customer_id', true ) ) { |
|
| 722 | - $stripe_customer->set_id( $meta_value ); |
|
| 721 | + if ($meta_value = get_post_meta($order_id, '_stripe_customer_id', true)) { |
|
| 722 | + $stripe_customer->set_id($meta_value); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | - if ( $meta_value = get_post_meta( $order_id, '_stripe_card_id', true ) ) { |
|
| 725 | + if ($meta_value = get_post_meta($order_id, '_stripe_card_id', true)) { |
|
| 726 | 726 | $stripe_source = $meta_value; |
| 727 | 727 | } |
| 728 | 728 | } |
@@ -745,60 +745,60 @@ discard block |
||
| 745 | 745 | * |
| 746 | 746 | * @return array|void |
| 747 | 747 | */ |
| 748 | - public function process_payment( $order_id, $retry = true, $force_customer = false ) { |
|
| 748 | + public function process_payment($order_id, $retry = true, $force_customer = false) { |
|
| 749 | 749 | try { |
| 750 | - $order = wc_get_order( $order_id ); |
|
| 751 | - $source = $this->get_source( get_current_user_id(), $force_customer ); |
|
| 750 | + $order = wc_get_order($order_id); |
|
| 751 | + $source = $this->get_source(get_current_user_id(), $force_customer); |
|
| 752 | 752 | |
| 753 | - if ( empty( $source->source ) && empty( $source->customer ) ) { |
|
| 754 | - $error_msg = __( 'Please enter your card details to make a payment.', 'woocommerce-gateway-stripe' ); |
|
| 755 | - $error_msg .= ' ' . __( 'Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce-gateway-stripe' ); |
|
| 756 | - throw new Exception( $error_msg ); |
|
| 753 | + if (empty($source->source) && empty($source->customer)) { |
|
| 754 | + $error_msg = __('Please enter your card details to make a payment.', 'woocommerce-gateway-stripe'); |
|
| 755 | + $error_msg .= ' ' . __('Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce-gateway-stripe'); |
|
| 756 | + throw new Exception($error_msg); |
|
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | // Store source to order meta. |
| 760 | - $this->save_source( $order, $source ); |
|
| 760 | + $this->save_source($order, $source); |
|
| 761 | 761 | |
| 762 | 762 | // Result from Stripe API request. |
| 763 | 763 | $response = null; |
| 764 | 764 | |
| 765 | 765 | // Handle payment. |
| 766 | - if ( $order->get_total() > 0 ) { |
|
| 766 | + if ($order->get_total() > 0) { |
|
| 767 | 767 | |
| 768 | - if ( $order->get_total() * 100 < WC_Stripe::get_minimum_amount() ) { |
|
| 769 | - throw new Exception( sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe::get_minimum_amount() / 100 ) ) ); |
|
| 768 | + if ($order->get_total() * 100 < WC_Stripe::get_minimum_amount()) { |
|
| 769 | + throw new Exception(sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe::get_minimum_amount() / 100))); |
|
| 770 | 770 | } |
| 771 | 771 | |
| 772 | - $this->log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" ); |
|
| 772 | + $this->log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}"); |
|
| 773 | 773 | |
| 774 | 774 | // Make the request. |
| 775 | - $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source ) ); |
|
| 775 | + $response = WC_Stripe_API::request($this->generate_payment_request($order, $source)); |
|
| 776 | 776 | |
| 777 | - if ( is_wp_error( $response ) ) { |
|
| 777 | + if (is_wp_error($response)) { |
|
| 778 | 778 | // Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without. |
| 779 | - if ( 'customer' === $response->get_error_code() && $retry ) { |
|
| 780 | - delete_user_meta( get_current_user_id(), '_stripe_customer_id' ); |
|
| 781 | - return $this->process_payment( $order_id, false, $force_customer ); |
|
| 779 | + if ('customer' === $response->get_error_code() && $retry) { |
|
| 780 | + delete_user_meta(get_current_user_id(), '_stripe_customer_id'); |
|
| 781 | + return $this->process_payment($order_id, false, $force_customer); |
|
| 782 | 782 | // Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message. |
| 783 | - } elseif ( 'source' === $response->get_error_code() && $source->token_id ) { |
|
| 784 | - $token = WC_Payment_Tokens::get( $source->token_id ); |
|
| 783 | + } elseif ('source' === $response->get_error_code() && $source->token_id) { |
|
| 784 | + $token = WC_Payment_Tokens::get($source->token_id); |
|
| 785 | 785 | $token->delete(); |
| 786 | - $message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' ); |
|
| 787 | - $order->add_order_note( $message ); |
|
| 788 | - throw new Exception( $message ); |
|
| 786 | + $message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe'); |
|
| 787 | + $order->add_order_note($message); |
|
| 788 | + throw new Exception($message); |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | $localized_messages = $this->get_localized_messages(); |
| 792 | 792 | |
| 793 | - $message = isset( $localized_messages[ $response->get_error_code() ] ) ? $localized_messages[ $response->get_error_code() ] : $response->get_error_message(); |
|
| 793 | + $message = isset($localized_messages[$response->get_error_code()]) ? $localized_messages[$response->get_error_code()] : $response->get_error_message(); |
|
| 794 | 794 | |
| 795 | - $order->add_order_note( $message ); |
|
| 795 | + $order->add_order_note($message); |
|
| 796 | 796 | |
| 797 | - throw new Exception( $message ); |
|
| 797 | + throw new Exception($message); |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | // Process valid response. |
| 801 | - $this->process_response( $response, $order ); |
|
| 801 | + $this->process_response($response, $order); |
|
| 802 | 802 | } else { |
| 803 | 803 | $order->payment_complete(); |
| 804 | 804 | } |
@@ -806,23 +806,23 @@ discard block |
||
| 806 | 806 | // Remove cart. |
| 807 | 807 | WC()->cart->empty_cart(); |
| 808 | 808 | |
| 809 | - do_action( 'wc_gateway_stripe_process_payment', $response, $order ); |
|
| 809 | + do_action('wc_gateway_stripe_process_payment', $response, $order); |
|
| 810 | 810 | |
| 811 | 811 | // Return thank you page redirect. |
| 812 | 812 | return array( |
| 813 | 813 | 'result' => 'success', |
| 814 | - 'redirect' => $this->get_return_url( $order ), |
|
| 814 | + 'redirect' => $this->get_return_url($order), |
|
| 815 | 815 | ); |
| 816 | 816 | |
| 817 | - } catch ( Exception $e ) { |
|
| 818 | - wc_add_notice( $e->getMessage(), 'error' ); |
|
| 819 | - $this->log( sprintf( __( 'Error: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) ); |
|
| 817 | + } catch (Exception $e) { |
|
| 818 | + wc_add_notice($e->getMessage(), 'error'); |
|
| 819 | + $this->log(sprintf(__('Error: %s', 'woocommerce-gateway-stripe'), $e->getMessage())); |
|
| 820 | 820 | |
| 821 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
| 822 | - $this->send_failed_order_email( $order_id ); |
|
| 821 | + if ($order->has_status(array('pending', 'failed'))) { |
|
| 822 | + $this->send_failed_order_email($order_id); |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
| 825 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
| 826 | 826 | |
| 827 | 827 | return array( |
| 828 | 828 | 'result' => 'fail', |
@@ -837,56 +837,56 @@ discard block |
||
| 837 | 837 | * @param WC_Order $order For to which the source applies. |
| 838 | 838 | * @param stdClass $source Source information. |
| 839 | 839 | */ |
| 840 | - protected function save_source( $order, $source ) { |
|
| 841 | - $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id(); |
|
| 840 | + protected function save_source($order, $source) { |
|
| 841 | + $order_id = version_compare(WC_VERSION, '3.0.0', '<') ? $order->id : $order->get_id(); |
|
| 842 | 842 | |
| 843 | 843 | // Store source in the order. |
| 844 | - if ( $source->customer ) { |
|
| 845 | - update_post_meta( $order_id, '_stripe_customer_id', $source->customer ); |
|
| 844 | + if ($source->customer) { |
|
| 845 | + update_post_meta($order_id, '_stripe_customer_id', $source->customer); |
|
| 846 | 846 | } |
| 847 | - if ( $source->source ) { |
|
| 848 | - update_post_meta( $order_id, '_stripe_card_id', $source->source ); |
|
| 847 | + if ($source->source) { |
|
| 848 | + update_post_meta($order_id, '_stripe_card_id', $source->source); |
|
| 849 | 849 | } |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | /** |
| 853 | 853 | * Store extra meta data for an order from a Stripe Response. |
| 854 | 854 | */ |
| 855 | - public function process_response( $response, $order ) { |
|
| 856 | - $this->log( 'Processing response: ' . print_r( $response, true ) ); |
|
| 855 | + public function process_response($response, $order) { |
|
| 856 | + $this->log('Processing response: ' . print_r($response, true)); |
|
| 857 | 857 | |
| 858 | - $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id(); |
|
| 858 | + $order_id = version_compare(WC_VERSION, '3.0.0', '<') ? $order->id : $order->get_id(); |
|
| 859 | 859 | |
| 860 | 860 | // Store charge data |
| 861 | - update_post_meta( $order_id, '_stripe_charge_id', $response->id ); |
|
| 862 | - update_post_meta( $order_id, '_stripe_charge_captured', $response->captured ? 'yes' : 'no' ); |
|
| 861 | + update_post_meta($order_id, '_stripe_charge_id', $response->id); |
|
| 862 | + update_post_meta($order_id, '_stripe_charge_captured', $response->captured ? 'yes' : 'no'); |
|
| 863 | 863 | |
| 864 | 864 | // Store other data such as fees |
| 865 | - if ( isset( $response->balance_transaction ) && isset( $response->balance_transaction->fee ) ) { |
|
| 865 | + if (isset($response->balance_transaction) && isset($response->balance_transaction->fee)) { |
|
| 866 | 866 | // Fees and Net needs to both come from Stripe to be accurate as the returned |
| 867 | 867 | // values are in the local currency of the Stripe account, not from WC. |
| 868 | - $fee = ! empty( $response->balance_transaction->fee ) ? WC_Stripe::format_number( $response->balance_transaction, 'fee' ) : 0; |
|
| 869 | - $net = ! empty( $response->balance_transaction->net ) ? WC_Stripe::format_number( $response->balance_transaction, 'net' ) : 0; |
|
| 870 | - update_post_meta( $order_id, 'Stripe Fee', $fee ); |
|
| 871 | - update_post_meta( $order_id, 'Net Revenue From Stripe', $net ); |
|
| 868 | + $fee = ! empty($response->balance_transaction->fee) ? WC_Stripe::format_number($response->balance_transaction, 'fee') : 0; |
|
| 869 | + $net = ! empty($response->balance_transaction->net) ? WC_Stripe::format_number($response->balance_transaction, 'net') : 0; |
|
| 870 | + update_post_meta($order_id, 'Stripe Fee', $fee); |
|
| 871 | + update_post_meta($order_id, 'Net Revenue From Stripe', $net); |
|
| 872 | 872 | } |
| 873 | 873 | |
| 874 | - if ( $response->captured ) { |
|
| 875 | - $order->payment_complete( $response->id ); |
|
| 874 | + if ($response->captured) { |
|
| 875 | + $order->payment_complete($response->id); |
|
| 876 | 876 | |
| 877 | - $message = sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $response->id ); |
|
| 878 | - $order->add_order_note( $message ); |
|
| 879 | - $this->log( 'Success: ' . $message ); |
|
| 877 | + $message = sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $response->id); |
|
| 878 | + $order->add_order_note($message); |
|
| 879 | + $this->log('Success: ' . $message); |
|
| 880 | 880 | |
| 881 | 881 | } else { |
| 882 | - add_post_meta( $order_id, '_transaction_id', $response->id, true ); |
|
| 882 | + add_post_meta($order_id, '_transaction_id', $response->id, true); |
|
| 883 | 883 | |
| 884 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
| 885 | - version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->reduce_order_stock() : wc_reduce_stock_levels( $order_id ); |
|
| 884 | + if ($order->has_status(array('pending', 'failed'))) { |
|
| 885 | + version_compare(WC_VERSION, '3.0.0', '<') ? $order->reduce_order_stock() : wc_reduce_stock_levels($order_id); |
|
| 886 | 886 | } |
| 887 | 887 | |
| 888 | - $order->update_status( 'on-hold', sprintf( __( 'Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe' ), $response->id ) ); |
|
| 889 | - $this->log( "Successful auth: $response->id" ); |
|
| 888 | + $order->update_status('on-hold', sprintf(__('Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe'), $response->id)); |
|
| 889 | + $this->log("Successful auth: $response->id"); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | return $response; |
@@ -898,32 +898,32 @@ discard block |
||
| 898 | 898 | * @since 3.0.0 |
| 899 | 899 | */ |
| 900 | 900 | public function add_payment_method() { |
| 901 | - if ( empty( $_POST['stripe_token'] ) || ! is_user_logged_in() ) { |
|
| 902 | - wc_add_notice( __( 'There was a problem adding the card.', 'woocommerce-gateway-stripe' ), 'error' ); |
|
| 901 | + if (empty($_POST['stripe_token']) || ! is_user_logged_in()) { |
|
| 902 | + wc_add_notice(__('There was a problem adding the card.', 'woocommerce-gateway-stripe'), 'error'); |
|
| 903 | 903 | return; |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | - $stripe_customer = new WC_Stripe_Customer( get_current_user_id() ); |
|
| 907 | - $card = $stripe_customer->add_card( wc_clean( $_POST['stripe_token'] ) ); |
|
| 906 | + $stripe_customer = new WC_Stripe_Customer(get_current_user_id()); |
|
| 907 | + $card = $stripe_customer->add_card(wc_clean($_POST['stripe_token'])); |
|
| 908 | 908 | |
| 909 | - if ( is_wp_error( $card ) ) { |
|
| 909 | + if (is_wp_error($card)) { |
|
| 910 | 910 | $localized_messages = $this->get_localized_messages(); |
| 911 | - $error_msg = __( 'There was a problem adding the card.', 'woocommerce-gateway-stripe' ); |
|
| 911 | + $error_msg = __('There was a problem adding the card.', 'woocommerce-gateway-stripe'); |
|
| 912 | 912 | |
| 913 | 913 | // loop through the errors to find matching localized message |
| 914 | - foreach ( $card->errors as $error => $msg ) { |
|
| 915 | - if ( isset( $localized_messages[ $error ] ) ) { |
|
| 916 | - $error_msg = $localized_messages[ $error ]; |
|
| 914 | + foreach ($card->errors as $error => $msg) { |
|
| 915 | + if (isset($localized_messages[$error])) { |
|
| 916 | + $error_msg = $localized_messages[$error]; |
|
| 917 | 917 | } |
| 918 | 918 | } |
| 919 | 919 | |
| 920 | - wc_add_notice( $error_msg, 'error' ); |
|
| 920 | + wc_add_notice($error_msg, 'error'); |
|
| 921 | 921 | return; |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | 924 | return array( |
| 925 | 925 | 'result' => 'success', |
| 926 | - 'redirect' => wc_get_endpoint_url( 'payment-methods' ), |
|
| 926 | + 'redirect' => wc_get_endpoint_url('payment-methods'), |
|
| 927 | 927 | ); |
| 928 | 928 | } |
| 929 | 929 | |
@@ -933,36 +933,36 @@ discard block |
||
| 933 | 933 | * @param float $amount |
| 934 | 934 | * @return bool |
| 935 | 935 | */ |
| 936 | - public function process_refund( $order_id, $amount = null, $reason = '' ) { |
|
| 937 | - $order = wc_get_order( $order_id ); |
|
| 936 | + public function process_refund($order_id, $amount = null, $reason = '') { |
|
| 937 | + $order = wc_get_order($order_id); |
|
| 938 | 938 | |
| 939 | - if ( ! $order || ! $order->get_transaction_id() ) { |
|
| 939 | + if ( ! $order || ! $order->get_transaction_id()) { |
|
| 940 | 940 | return false; |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | $body = array(); |
| 944 | 944 | |
| 945 | - if ( ! is_null( $amount ) ) { |
|
| 946 | - $body['amount'] = $this->get_stripe_amount( $amount ); |
|
| 945 | + if ( ! is_null($amount)) { |
|
| 946 | + $body['amount'] = $this->get_stripe_amount($amount); |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | - if ( $reason ) { |
|
| 949 | + if ($reason) { |
|
| 950 | 950 | $body['metadata'] = array( |
| 951 | 951 | 'reason' => $reason, |
| 952 | 952 | ); |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | - $this->log( "Info: Beginning refund for order $order_id for the amount of {$amount}" ); |
|
| 955 | + $this->log("Info: Beginning refund for order $order_id for the amount of {$amount}"); |
|
| 956 | 956 | |
| 957 | - $response = WC_Stripe_API::request( $body, 'charges/' . $order->get_transaction_id() . '/refunds' ); |
|
| 957 | + $response = WC_Stripe_API::request($body, 'charges/' . $order->get_transaction_id() . '/refunds'); |
|
| 958 | 958 | |
| 959 | - if ( is_wp_error( $response ) ) { |
|
| 960 | - $this->log( 'Error: ' . $response->get_error_message() ); |
|
| 959 | + if (is_wp_error($response)) { |
|
| 960 | + $this->log('Error: ' . $response->get_error_message()); |
|
| 961 | 961 | return $response; |
| 962 | - } elseif ( ! empty( $response->id ) ) { |
|
| 963 | - $refund_message = sprintf( __( 'Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe' ), wc_price( $response->amount / 100 ), $response->id, $reason ); |
|
| 964 | - $order->add_order_note( $refund_message ); |
|
| 965 | - $this->log( 'Success: ' . html_entity_decode( strip_tags( $refund_message ) ) ); |
|
| 962 | + } elseif ( ! empty($response->id)) { |
|
| 963 | + $refund_message = sprintf(__('Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe'), wc_price($response->amount / 100), $response->id, $reason); |
|
| 964 | + $order->add_order_note($refund_message); |
|
| 965 | + $this->log('Success: ' . html_entity_decode(strip_tags($refund_message))); |
|
| 966 | 966 | return true; |
| 967 | 967 | } |
| 968 | 968 | } |
@@ -975,10 +975,10 @@ discard block |
||
| 975 | 975 | * @param int $order_id |
| 976 | 976 | * @return null |
| 977 | 977 | */ |
| 978 | - public function send_failed_order_email( $order_id ) { |
|
| 978 | + public function send_failed_order_email($order_id) { |
|
| 979 | 979 | $emails = WC()->mailer()->get_emails(); |
| 980 | - if ( ! empty( $emails ) && ! empty( $order_id ) ) { |
|
| 981 | - $emails['WC_Email_Failed_Order']->trigger( $order_id ); |
|
| 980 | + if ( ! empty($emails) && ! empty($order_id)) { |
|
| 981 | + $emails['WC_Email_Failed_Order']->trigger($order_id); |
|
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | 984 | |
@@ -990,9 +990,9 @@ discard block |
||
| 990 | 990 | * |
| 991 | 991 | * @param string $message |
| 992 | 992 | */ |
| 993 | - public function log( $message ) { |
|
| 994 | - if ( $this->logging ) { |
|
| 995 | - WC_Stripe::log( $message ); |
|
| 993 | + public function log($message) { |
|
| 994 | + if ($this->logging) { |
|
| 995 | + WC_Stripe::log($message); |
|
| 996 | 996 | } |
| 997 | 997 | } |
| 998 | 998 | } |
@@ -1,184 +1,184 @@ |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if ( ! defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | -return apply_filters( 'wc_stripe_settings', |
|
| 6 | +return apply_filters('wc_stripe_settings', |
|
| 7 | 7 | array( |
| 8 | 8 | 'enabled' => array( |
| 9 | - 'title' => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ), |
|
| 10 | - 'label' => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ), |
|
| 9 | + 'title' => __('Enable/Disable', 'woocommerce-gateway-stripe'), |
|
| 10 | + 'label' => __('Enable Stripe', 'woocommerce-gateway-stripe'), |
|
| 11 | 11 | 'type' => 'checkbox', |
| 12 | 12 | 'description' => '', |
| 13 | 13 | 'default' => 'no', |
| 14 | 14 | ), |
| 15 | 15 | 'title' => array( |
| 16 | - 'title' => __( 'Title', 'woocommerce-gateway-stripe' ), |
|
| 16 | + 'title' => __('Title', 'woocommerce-gateway-stripe'), |
|
| 17 | 17 | 'type' => 'text', |
| 18 | - 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
| 19 | - 'default' => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ), |
|
| 18 | + 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
| 19 | + 'default' => __('Credit Card (Stripe)', 'woocommerce-gateway-stripe'), |
|
| 20 | 20 | 'desc_tip' => true, |
| 21 | 21 | ), |
| 22 | 22 | 'description' => array( |
| 23 | - 'title' => __( 'Description', 'woocommerce-gateway-stripe' ), |
|
| 23 | + 'title' => __('Description', 'woocommerce-gateway-stripe'), |
|
| 24 | 24 | 'type' => 'text', |
| 25 | - 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
| 26 | - 'default' => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe' ), |
|
| 25 | + 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
| 26 | + 'default' => __('Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'), |
|
| 27 | 27 | 'desc_tip' => true, |
| 28 | 28 | ), |
| 29 | 29 | 'testmode' => array( |
| 30 | - 'title' => __( 'Test mode', 'woocommerce-gateway-stripe' ), |
|
| 31 | - 'label' => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ), |
|
| 30 | + 'title' => __('Test mode', 'woocommerce-gateway-stripe'), |
|
| 31 | + 'label' => __('Enable Test Mode', 'woocommerce-gateway-stripe'), |
|
| 32 | 32 | 'type' => 'checkbox', |
| 33 | - 'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ), |
|
| 33 | + 'description' => __('Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe'), |
|
| 34 | 34 | 'default' => 'yes', |
| 35 | 35 | 'desc_tip' => true, |
| 36 | 36 | ), |
| 37 | 37 | 'test_secret_key' => array( |
| 38 | - 'title' => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ), |
|
| 38 | + 'title' => __('Test Secret Key', 'woocommerce-gateway-stripe'), |
|
| 39 | 39 | 'type' => 'text', |
| 40 | - 'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ), |
|
| 40 | + 'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'), |
|
| 41 | 41 | 'default' => '', |
| 42 | 42 | 'desc_tip' => true, |
| 43 | 43 | ), |
| 44 | 44 | 'test_publishable_key' => array( |
| 45 | - 'title' => __( 'Test Publishable Key', 'woocommerce-gateway-stripe' ), |
|
| 45 | + 'title' => __('Test Publishable Key', 'woocommerce-gateway-stripe'), |
|
| 46 | 46 | 'type' => 'text', |
| 47 | - 'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ), |
|
| 47 | + 'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'), |
|
| 48 | 48 | 'default' => '', |
| 49 | 49 | 'desc_tip' => true, |
| 50 | 50 | ), |
| 51 | 51 | 'secret_key' => array( |
| 52 | - 'title' => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ), |
|
| 52 | + 'title' => __('Live Secret Key', 'woocommerce-gateway-stripe'), |
|
| 53 | 53 | 'type' => 'text', |
| 54 | - 'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ), |
|
| 54 | + 'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'), |
|
| 55 | 55 | 'default' => '', |
| 56 | 56 | 'desc_tip' => true, |
| 57 | 57 | ), |
| 58 | 58 | 'publishable_key' => array( |
| 59 | - 'title' => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ), |
|
| 59 | + 'title' => __('Live Publishable Key', 'woocommerce-gateway-stripe'), |
|
| 60 | 60 | 'type' => 'text', |
| 61 | - 'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ), |
|
| 61 | + 'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'), |
|
| 62 | 62 | 'default' => '', |
| 63 | 63 | 'desc_tip' => true, |
| 64 | 64 | ), |
| 65 | 65 | 'statement_descriptor' => array( |
| 66 | - 'title' => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ), |
|
| 66 | + 'title' => __('Statement Descriptor', 'woocommerce-gateway-stripe'), |
|
| 67 | 67 | 'type' => 'text', |
| 68 | - 'description' => __( 'Extra information about a charge. This will appear on your customer’s credit card statement.', 'woocommerce-gateway-stripe' ), |
|
| 68 | + 'description' => __('Extra information about a charge. This will appear on your customer’s credit card statement.', 'woocommerce-gateway-stripe'), |
|
| 69 | 69 | 'default' => '', |
| 70 | 70 | 'desc_tip' => true, |
| 71 | 71 | ), |
| 72 | 72 | 'capture' => array( |
| 73 | - 'title' => __( 'Capture', 'woocommerce-gateway-stripe' ), |
|
| 74 | - 'label' => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ), |
|
| 73 | + 'title' => __('Capture', 'woocommerce-gateway-stripe'), |
|
| 74 | + 'label' => __('Capture charge immediately', 'woocommerce-gateway-stripe'), |
|
| 75 | 75 | 'type' => 'checkbox', |
| 76 | - 'description' => __( 'Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe' ), |
|
| 76 | + 'description' => __('Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe'), |
|
| 77 | 77 | 'default' => 'yes', |
| 78 | 78 | 'desc_tip' => true, |
| 79 | 79 | ), |
| 80 | 80 | 'stripe_checkout' => array( |
| 81 | - 'title' => __( 'Stripe Checkout', 'woocommerce-gateway-stripe' ), |
|
| 82 | - 'label' => __( 'Enable Stripe Checkout', 'woocommerce-gateway-stripe' ), |
|
| 81 | + 'title' => __('Stripe Checkout', 'woocommerce-gateway-stripe'), |
|
| 82 | + 'label' => __('Enable Stripe Checkout', 'woocommerce-gateway-stripe'), |
|
| 83 | 83 | 'type' => 'checkbox', |
| 84 | - 'description' => __( 'If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page.', 'woocommerce-gateway-stripe' ), |
|
| 84 | + 'description' => __('If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page.', 'woocommerce-gateway-stripe'), |
|
| 85 | 85 | 'default' => 'no', |
| 86 | 86 | 'desc_tip' => true, |
| 87 | 87 | ), |
| 88 | 88 | 'stripe_checkout_locale' => array( |
| 89 | - 'title' => __( 'Stripe Checkout locale', 'woocommerce-gateway-stripe' ), |
|
| 89 | + 'title' => __('Stripe Checkout locale', 'woocommerce-gateway-stripe'), |
|
| 90 | 90 | 'type' => 'select', |
| 91 | 91 | 'class' => 'wc-enhanced-select', |
| 92 | - 'description' => __( 'Language to display in Stripe Checkout modal. Specify Auto to display Checkout in the user\'s preferred language, if available. English will be used by default.', 'woocommerce-gateway-stripe' ), |
|
| 92 | + 'description' => __('Language to display in Stripe Checkout modal. Specify Auto to display Checkout in the user\'s preferred language, if available. English will be used by default.', 'woocommerce-gateway-stripe'), |
|
| 93 | 93 | 'default' => 'en', |
| 94 | 94 | 'desc_tip' => true, |
| 95 | 95 | 'options' => array( |
| 96 | - 'auto' => __( 'Auto', 'woocommerce-gateway-stripe' ), |
|
| 97 | - 'zh' => __( 'Simplified Chinese', 'woocommerce-gateway-stripe' ), |
|
| 98 | - 'da' => __( 'Danish', 'woocommerce-gateway-stripe' ), |
|
| 99 | - 'nl' => __( 'Dutch', 'woocommerce-gateway-stripe' ), |
|
| 100 | - 'en' => __( 'English', 'woocommerce-gateway-stripe' ), |
|
| 101 | - 'fi' => __( 'Finnish', 'woocommerce-gateway-stripe' ), |
|
| 102 | - 'fr' => __( 'French', 'woocommerce-gateway-stripe' ), |
|
| 103 | - 'de' => __( 'German', 'woocommerce-gateway-stripe' ), |
|
| 104 | - 'it' => __( 'Italian', 'woocommerce-gateway-stripe' ), |
|
| 105 | - 'ja' => __( 'Japanese', 'woocommerce-gateway-stripe' ), |
|
| 106 | - 'no' => __( 'Norwegian', 'woocommerce-gateway-stripe' ), |
|
| 107 | - 'es' => __( 'Spanish', 'woocommerce-gateway-stripe' ), |
|
| 108 | - 'sv' => __( 'Swedish', 'woocommerce-gateway-stripe' ), |
|
| 96 | + 'auto' => __('Auto', 'woocommerce-gateway-stripe'), |
|
| 97 | + 'zh' => __('Simplified Chinese', 'woocommerce-gateway-stripe'), |
|
| 98 | + 'da' => __('Danish', 'woocommerce-gateway-stripe'), |
|
| 99 | + 'nl' => __('Dutch', 'woocommerce-gateway-stripe'), |
|
| 100 | + 'en' => __('English', 'woocommerce-gateway-stripe'), |
|
| 101 | + 'fi' => __('Finnish', 'woocommerce-gateway-stripe'), |
|
| 102 | + 'fr' => __('French', 'woocommerce-gateway-stripe'), |
|
| 103 | + 'de' => __('German', 'woocommerce-gateway-stripe'), |
|
| 104 | + 'it' => __('Italian', 'woocommerce-gateway-stripe'), |
|
| 105 | + 'ja' => __('Japanese', 'woocommerce-gateway-stripe'), |
|
| 106 | + 'no' => __('Norwegian', 'woocommerce-gateway-stripe'), |
|
| 107 | + 'es' => __('Spanish', 'woocommerce-gateway-stripe'), |
|
| 108 | + 'sv' => __('Swedish', 'woocommerce-gateway-stripe'), |
|
| 109 | 109 | ), |
| 110 | 110 | ), |
| 111 | 111 | 'stripe_bitcoin' => array( |
| 112 | - 'title' => __( 'Bitcoin Currency', 'woocommerce-gateway-stripe' ), |
|
| 113 | - 'label' => __( 'Enable Bitcoin Currency', 'woocommerce-gateway-stripe' ), |
|
| 112 | + 'title' => __('Bitcoin Currency', 'woocommerce-gateway-stripe'), |
|
| 113 | + 'label' => __('Enable Bitcoin Currency', 'woocommerce-gateway-stripe'), |
|
| 114 | 114 | 'type' => 'checkbox', |
| 115 | - 'description' => __( 'If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe' ), |
|
| 115 | + 'description' => __('If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe'), |
|
| 116 | 116 | 'default' => 'no', |
| 117 | 117 | 'desc_tip' => true, |
| 118 | 118 | ), |
| 119 | 119 | 'stripe_checkout_image' => array( |
| 120 | - 'title' => __( 'Stripe Checkout Image', 'woocommerce-gateway-stripe' ), |
|
| 121 | - 'description' => __( 'Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe' ), |
|
| 120 | + 'title' => __('Stripe Checkout Image', 'woocommerce-gateway-stripe'), |
|
| 121 | + 'description' => __('Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe'), |
|
| 122 | 122 | 'type' => 'text', |
| 123 | 123 | 'default' => '', |
| 124 | 124 | 'desc_tip' => true, |
| 125 | 125 | ), |
| 126 | 126 | 'request_payment_api' => array( |
| 127 | - 'title' => __( 'Payment Request API', 'woocommerce-gateway-stripe' ), |
|
| 128 | - 'label' => __( 'Enable Payment Request API', 'woocommerce-gateway-stripe' ), |
|
| 127 | + 'title' => __('Payment Request API', 'woocommerce-gateway-stripe'), |
|
| 128 | + 'label' => __('Enable Payment Request API', 'woocommerce-gateway-stripe'), |
|
| 129 | 129 | 'type' => 'checkbox', |
| 130 | - 'description' => __( 'If enabled, users will be able to pay using the Payment Request API if supported by the browser.', 'woocommerce-gateway-stripe' ), |
|
| 130 | + 'description' => __('If enabled, users will be able to pay using the Payment Request API if supported by the browser.', 'woocommerce-gateway-stripe'), |
|
| 131 | 131 | 'default' => 'no', |
| 132 | 132 | 'desc_tip' => true, |
| 133 | 133 | ), |
| 134 | 134 | 'apple_pay' => array( |
| 135 | - 'title' => __( 'Apple Pay', 'woocommerce-gateway-stripe' ), |
|
| 136 | - 'label' => sprintf( __( 'Enable Apple Pay. %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe' ), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>' ), |
|
| 135 | + 'title' => __('Apple Pay', 'woocommerce-gateway-stripe'), |
|
| 136 | + 'label' => sprintf(__('Enable Apple Pay. %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe'), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>'), |
|
| 137 | 137 | 'type' => 'checkbox', |
| 138 | - 'description' => __( 'If enabled, users will be able to pay with Apple Pay.', 'woocommerce-gateway-stripe' ), |
|
| 138 | + 'description' => __('If enabled, users will be able to pay with Apple Pay.', 'woocommerce-gateway-stripe'), |
|
| 139 | 139 | 'default' => 'yes', |
| 140 | 140 | 'desc_tip' => true, |
| 141 | 141 | ), |
| 142 | 142 | 'apple_pay_button' => array( |
| 143 | - 'title' => __( 'Apple Pay Button Style', 'woocommerce-gateway-stripe' ), |
|
| 144 | - 'label' => __( 'Button Style', 'woocommerce-gateway-stripe' ), |
|
| 143 | + 'title' => __('Apple Pay Button Style', 'woocommerce-gateway-stripe'), |
|
| 144 | + 'label' => __('Button Style', 'woocommerce-gateway-stripe'), |
|
| 145 | 145 | 'type' => 'select', |
| 146 | - 'description' => __( 'Select the button style you would like to show.', 'woocommerce-gateway-stripe' ), |
|
| 146 | + 'description' => __('Select the button style you would like to show.', 'woocommerce-gateway-stripe'), |
|
| 147 | 147 | 'default' => 'black', |
| 148 | 148 | 'desc_tip' => true, |
| 149 | 149 | 'options' => array( |
| 150 | - 'black' => __( 'Black', 'woocommerce-gateway-stripe' ), |
|
| 151 | - 'white' => __( 'White', 'woocommerce-gateway-stripe' ), |
|
| 150 | + 'black' => __('Black', 'woocommerce-gateway-stripe'), |
|
| 151 | + 'white' => __('White', 'woocommerce-gateway-stripe'), |
|
| 152 | 152 | ), |
| 153 | 153 | ), |
| 154 | 154 | 'apple_pay_button_lang' => array( |
| 155 | - 'title' => __( 'Apple Pay Button Language', 'woocommerce-gateway-stripe' ), |
|
| 156 | - 'description' => __( 'Enter the 2 letter ISO code for the language you would like your Apple Pay Button to display in. Reference available ISO codes here <code>http://www.w3schools.com/tags/ref_language_codes.asp</code>', 'woocommerce-gateway-stripe' ), |
|
| 155 | + 'title' => __('Apple Pay Button Language', 'woocommerce-gateway-stripe'), |
|
| 156 | + 'description' => __('Enter the 2 letter ISO code for the language you would like your Apple Pay Button to display in. Reference available ISO codes here <code>http://www.w3schools.com/tags/ref_language_codes.asp</code>', 'woocommerce-gateway-stripe'), |
|
| 157 | 157 | 'type' => 'text', |
| 158 | 158 | 'default' => 'en', |
| 159 | 159 | 'desc_tip' => false, |
| 160 | 160 | ), |
| 161 | 161 | 'saved_cards' => array( |
| 162 | - 'title' => __( 'Saved Cards', 'woocommerce-gateway-stripe' ), |
|
| 163 | - 'label' => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ), |
|
| 162 | + 'title' => __('Saved Cards', 'woocommerce-gateway-stripe'), |
|
| 163 | + 'label' => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'), |
|
| 164 | 164 | 'type' => 'checkbox', |
| 165 | - 'description' => __( 'If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe' ), |
|
| 165 | + 'description' => __('If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe'), |
|
| 166 | 166 | 'default' => 'no', |
| 167 | 167 | 'desc_tip' => true, |
| 168 | 168 | ), |
| 169 | 169 | 'always_save_cards' => array( |
| 170 | - 'title' => __( 'Always Save Cards', 'woocommerce-gateway-stripe' ), |
|
| 171 | - 'label' => __( 'Save cards without asking the user', 'woocommerce-gateway-stripe' ), |
|
| 170 | + 'title' => __('Always Save Cards', 'woocommerce-gateway-stripe'), |
|
| 171 | + 'label' => __('Save cards without asking the user', 'woocommerce-gateway-stripe'), |
|
| 172 | 172 | 'type' => 'checkbox', |
| 173 | - 'description' => __( 'If enabled, whenever a customer uses a credit card it will be saved without first asking. When this option is not enabled, the default behavior is to ask the user by showing a checkbox during checkout.', 'woocommerce-gateway-stripe' ), |
|
| 173 | + 'description' => __('If enabled, whenever a customer uses a credit card it will be saved without first asking. When this option is not enabled, the default behavior is to ask the user by showing a checkbox during checkout.', 'woocommerce-gateway-stripe'), |
|
| 174 | 174 | 'default' => 'no', |
| 175 | 175 | 'desc_tip' => true, |
| 176 | 176 | ), |
| 177 | 177 | 'logging' => array( |
| 178 | - 'title' => __( 'Logging', 'woocommerce-gateway-stripe' ), |
|
| 179 | - 'label' => __( 'Log debug messages', 'woocommerce-gateway-stripe' ), |
|
| 178 | + 'title' => __('Logging', 'woocommerce-gateway-stripe'), |
|
| 179 | + 'label' => __('Log debug messages', 'woocommerce-gateway-stripe'), |
|
| 180 | 180 | 'type' => 'checkbox', |
| 181 | - 'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ), |
|
| 181 | + 'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'), |
|
| 182 | 182 | 'default' => 'no', |
| 183 | 183 | 'desc_tip' => true, |
| 184 | 184 | ), |