@@ -1,50 +1,50 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
6 | 6 | $webhook_url = WC_Stripe_Helper::get_webhook_url(); |
7 | 7 | |
8 | -return apply_filters( 'wc_stripe_bancontact_settings', |
|
8 | +return apply_filters('wc_stripe_bancontact_settings', |
|
9 | 9 | array( |
10 | 10 | 'geo_target' => array( |
11 | - 'description' => __( 'Relevant Payer Geography: Belgium', 'woocommerce-gateway-stripe' ), |
|
11 | + 'description' => __('Relevant Payer Geography: Belgium', 'woocommerce-gateway-stripe'), |
|
12 | 12 | 'type' => 'title', |
13 | 13 | ), |
14 | 14 | 'guide' => array( |
15 | - 'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#bancontact" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ), |
|
15 | + 'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#bancontact" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe'), |
|
16 | 16 | 'type' => 'title', |
17 | 17 | ), |
18 | 18 | 'activation' => array( |
19 | - 'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ), |
|
19 | + 'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'), |
|
20 | 20 | 'type' => 'title', |
21 | 21 | ), |
22 | 22 | 'enabled' => array( |
23 | - 'title' => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ), |
|
24 | - 'label' => __( 'Enable Stripe Bancontact', 'woocommerce-gateway-stripe' ), |
|
23 | + 'title' => __('Enable/Disable', 'woocommerce-gateway-stripe'), |
|
24 | + 'label' => __('Enable Stripe Bancontact', 'woocommerce-gateway-stripe'), |
|
25 | 25 | 'type' => 'checkbox', |
26 | 26 | 'description' => '', |
27 | 27 | 'default' => 'no', |
28 | 28 | ), |
29 | 29 | 'title' => array( |
30 | - 'title' => __( 'Title', 'woocommerce-gateway-stripe' ), |
|
30 | + 'title' => __('Title', 'woocommerce-gateway-stripe'), |
|
31 | 31 | 'type' => 'text', |
32 | - 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
33 | - 'default' => __( 'Bancontact', 'woocommerce-gateway-stripe' ), |
|
32 | + 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
33 | + 'default' => __('Bancontact', 'woocommerce-gateway-stripe'), |
|
34 | 34 | 'desc_tip' => true, |
35 | 35 | ), |
36 | 36 | 'description' => array( |
37 | - 'title' => __( 'Description', 'woocommerce-gateway-stripe' ), |
|
37 | + 'title' => __('Description', 'woocommerce-gateway-stripe'), |
|
38 | 38 | 'type' => 'text', |
39 | - 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
40 | - 'default' => __( 'You will be redirected to Bancontact.', 'woocommerce-gateway-stripe' ), |
|
39 | + 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
40 | + 'default' => __('You will be redirected to Bancontact.', 'woocommerce-gateway-stripe'), |
|
41 | 41 | 'desc_tip' => true, |
42 | 42 | ), |
43 | 43 | 'webhook' => array( |
44 | - 'title' => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ), |
|
44 | + 'title' => __('Webhook Endpoints', 'woocommerce-gateway-stripe'), |
|
45 | 45 | 'type' => 'title', |
46 | 46 | /* translators: webhook URL */ |
47 | - 'description' => sprintf( __( 'You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe' ), $webhook_url ), |
|
47 | + 'description' => sprintf(__('You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe'), $webhook_url), |
|
48 | 48 | ), |
49 | 49 | ) |
50 | 50 | ); |
@@ -1,50 +1,50 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
6 | 6 | $webhook_url = WC_Stripe_Helper::get_webhook_url(); |
7 | 7 | |
8 | -return apply_filters( 'wc_stripe_alipay_settings', |
|
8 | +return apply_filters('wc_stripe_alipay_settings', |
|
9 | 9 | array( |
10 | 10 | 'geo_target' => array( |
11 | - 'description' => __( 'Relevant Payer Geography: China', 'woocommerce-gateway-stripe' ), |
|
11 | + 'description' => __('Relevant Payer Geography: China', 'woocommerce-gateway-stripe'), |
|
12 | 12 | 'type' => 'title', |
13 | 13 | ), |
14 | 14 | 'guide' => array( |
15 | - 'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#alipay" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ), |
|
15 | + 'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#alipay" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe'), |
|
16 | 16 | 'type' => 'title', |
17 | 17 | ), |
18 | 18 | 'activation' => array( |
19 | - 'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ), |
|
19 | + 'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'), |
|
20 | 20 | 'type' => 'title', |
21 | 21 | ), |
22 | 22 | 'enabled' => array( |
23 | - 'title' => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ), |
|
24 | - 'label' => __( 'Enable Stripe Alipay', 'woocommerce-gateway-stripe' ), |
|
23 | + 'title' => __('Enable/Disable', 'woocommerce-gateway-stripe'), |
|
24 | + 'label' => __('Enable Stripe Alipay', 'woocommerce-gateway-stripe'), |
|
25 | 25 | 'type' => 'checkbox', |
26 | 26 | 'description' => '', |
27 | 27 | 'default' => 'no', |
28 | 28 | ), |
29 | 29 | 'title' => array( |
30 | - 'title' => __( 'Title', 'woocommerce-gateway-stripe' ), |
|
30 | + 'title' => __('Title', 'woocommerce-gateway-stripe'), |
|
31 | 31 | 'type' => 'text', |
32 | - 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
33 | - 'default' => __( 'Alipay', 'woocommerce-gateway-stripe' ), |
|
32 | + 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
33 | + 'default' => __('Alipay', 'woocommerce-gateway-stripe'), |
|
34 | 34 | 'desc_tip' => true, |
35 | 35 | ), |
36 | 36 | 'description' => array( |
37 | - 'title' => __( 'Description', 'woocommerce-gateway-stripe' ), |
|
37 | + 'title' => __('Description', 'woocommerce-gateway-stripe'), |
|
38 | 38 | 'type' => 'text', |
39 | - 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
40 | - 'default' => __( 'You will be redirected to Alipay.', 'woocommerce-gateway-stripe' ), |
|
39 | + 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
40 | + 'default' => __('You will be redirected to Alipay.', 'woocommerce-gateway-stripe'), |
|
41 | 41 | 'desc_tip' => true, |
42 | 42 | ), |
43 | 43 | 'webhook' => array( |
44 | - 'title' => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ), |
|
44 | + 'title' => __('Webhook Endpoints', 'woocommerce-gateway-stripe'), |
|
45 | 45 | 'type' => 'title', |
46 | 46 | /* translators: webhook URL */ |
47 | - 'description' => sprintf( __( 'You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe' ), $webhook_url ), |
|
47 | + 'description' => sprintf(__('You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe'), $webhook_url), |
|
48 | 48 | ), |
49 | 49 | ) |
50 | 50 | ); |
@@ -1,46 +1,46 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
6 | 6 | $webhook_url = WC_Stripe_Helper::get_webhook_url(); |
7 | 7 | |
8 | -return apply_filters( 'wc_stripe_p24_settings', |
|
8 | +return apply_filters('wc_stripe_p24_settings', |
|
9 | 9 | array( |
10 | 10 | 'geo_target' => array( |
11 | - 'description' => __( 'Relevant Payer Geography: Poland', 'woocommerce-gateway-stripe' ), |
|
11 | + 'description' => __('Relevant Payer Geography: Poland', 'woocommerce-gateway-stripe'), |
|
12 | 12 | 'type' => 'title', |
13 | 13 | ), |
14 | 14 | 'activation' => array( |
15 | - 'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ), |
|
15 | + 'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'), |
|
16 | 16 | 'type' => 'title', |
17 | 17 | ), |
18 | 18 | 'enabled' => array( |
19 | - 'title' => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ), |
|
20 | - 'label' => __( 'Enable Stripe P24', 'woocommerce-gateway-stripe' ), |
|
19 | + 'title' => __('Enable/Disable', 'woocommerce-gateway-stripe'), |
|
20 | + 'label' => __('Enable Stripe P24', 'woocommerce-gateway-stripe'), |
|
21 | 21 | 'type' => 'checkbox', |
22 | 22 | 'description' => '', |
23 | 23 | 'default' => 'no', |
24 | 24 | ), |
25 | 25 | 'title' => array( |
26 | - 'title' => __( 'Title', 'woocommerce-gateway-stripe' ), |
|
26 | + 'title' => __('Title', 'woocommerce-gateway-stripe'), |
|
27 | 27 | 'type' => 'text', |
28 | - 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
29 | - 'default' => __( 'Przelewy24 (P24)', 'woocommerce-gateway-stripe' ), |
|
28 | + 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
29 | + 'default' => __('Przelewy24 (P24)', 'woocommerce-gateway-stripe'), |
|
30 | 30 | 'desc_tip' => true, |
31 | 31 | ), |
32 | 32 | 'description' => array( |
33 | - 'title' => __( 'Description', 'woocommerce-gateway-stripe' ), |
|
33 | + 'title' => __('Description', 'woocommerce-gateway-stripe'), |
|
34 | 34 | 'type' => 'text', |
35 | - 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
36 | - 'default' => __( 'You will be redirected to P24.', 'woocommerce-gateway-stripe' ), |
|
35 | + 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
36 | + 'default' => __('You will be redirected to P24.', 'woocommerce-gateway-stripe'), |
|
37 | 37 | 'desc_tip' => true, |
38 | 38 | ), |
39 | 39 | 'webhook' => array( |
40 | - 'title' => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ), |
|
40 | + 'title' => __('Webhook Endpoints', 'woocommerce-gateway-stripe'), |
|
41 | 41 | 'type' => 'title', |
42 | 42 | /* translators: webhook URL */ |
43 | - 'description' => sprintf( __( 'You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe' ), $webhook_url ), |
|
43 | + 'description' => sprintf(__('You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe'), $webhook_url), |
|
44 | 44 | ), |
45 | 45 | ) |
46 | 46 | ); |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
6 | 6 | // if uninstall not called from WordPress exit |
7 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
7 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | |
@@ -13,20 +13,20 @@ discard block |
||
13 | 13 | * wp-config.php. This is to prevent data loss when deleting the plugin from the backend |
14 | 14 | * and to ensure only the site owner can perform this action. |
15 | 15 | */ |
16 | -if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) { |
|
16 | +if (defined('WC_REMOVE_ALL_DATA') && true === WC_REMOVE_ALL_DATA) { |
|
17 | 17 | // Delete options. |
18 | - delete_option( 'woocommerce_stripe_settings' ); |
|
19 | - delete_option( 'wc_stripe_show_request_api_notice' ); |
|
20 | - delete_option( 'wc_stripe_show_apple_pay_notice' ); |
|
21 | - delete_option( 'wc_stripe_show_ssl_notice' ); |
|
22 | - delete_option( 'wc_stripe_show_keys_notice' ); |
|
23 | - delete_option( 'wc_stripe_version' ); |
|
24 | - delete_option( 'woocommerce_stripe_bancontact_settings' ); |
|
25 | - delete_option( 'woocommerce_stripe_alipay_settings' ); |
|
26 | - delete_option( 'woocommerce_stripe_bitcoin_settings' ); |
|
27 | - delete_option( 'woocommerce_stripe_ideal_settings' ); |
|
28 | - delete_option( 'woocommerce_stripe_p24_settings' ); |
|
29 | - delete_option( 'woocommerce_stripe_giropay_settings' ); |
|
30 | - delete_option( 'woocommerce_stripe_sepa_settings' ); |
|
31 | - delete_option( 'woocommerce_stripe_sofort_settings' ); |
|
18 | + delete_option('woocommerce_stripe_settings'); |
|
19 | + delete_option('wc_stripe_show_request_api_notice'); |
|
20 | + delete_option('wc_stripe_show_apple_pay_notice'); |
|
21 | + delete_option('wc_stripe_show_ssl_notice'); |
|
22 | + delete_option('wc_stripe_show_keys_notice'); |
|
23 | + delete_option('wc_stripe_version'); |
|
24 | + delete_option('woocommerce_stripe_bancontact_settings'); |
|
25 | + delete_option('woocommerce_stripe_alipay_settings'); |
|
26 | + delete_option('woocommerce_stripe_bitcoin_settings'); |
|
27 | + delete_option('woocommerce_stripe_ideal_settings'); |
|
28 | + delete_option('woocommerce_stripe_p24_settings'); |
|
29 | + delete_option('woocommerce_stripe_giropay_settings'); |
|
30 | + delete_option('woocommerce_stripe_sepa_settings'); |
|
31 | + delete_option('woocommerce_stripe_sofort_settings'); |
|
32 | 32 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since 4.0.2 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | * @param string $error_message Full response |
24 | 24 | * @param string $localized_message user-friendly translated error message |
25 | 25 | */ |
26 | - public function __construct( $error_message = '', $localized_message = '' ) { |
|
26 | + public function __construct($error_message = '', $localized_message = '') { |
|
27 | 27 | $this->localized_message = $localized_message; |
28 | - parent::__construct( $error_message ); |
|
28 | + parent::__construct($error_message); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -17,15 +17,15 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @return float|int |
19 | 19 | */ |
20 | - public static function get_stripe_amount( $total, $currency = '' ) { |
|
21 | - if ( ! $currency ) { |
|
20 | + public static function get_stripe_amount($total, $currency = '') { |
|
21 | + if ( ! $currency) { |
|
22 | 22 | $currency = get_woocommerce_currency(); |
23 | 23 | } |
24 | 24 | |
25 | - if ( in_array( strtolower( $currency ), self::no_decimal_currencies() ) ) { |
|
26 | - return absint( $total ); |
|
25 | + if (in_array(strtolower($currency), self::no_decimal_currencies())) { |
|
26 | + return absint($total); |
|
27 | 27 | } else { |
28 | - return absint( wc_format_decimal( ( (float) $total * 100 ), wc_get_price_decimals() ) ); // In cents. |
|
28 | + return absint(wc_format_decimal(((float) $total * 100), wc_get_price_decimals())); // In cents. |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
@@ -37,25 +37,25 @@ discard block |
||
37 | 37 | * @return array |
38 | 38 | */ |
39 | 39 | public static function get_localized_messages() { |
40 | - return apply_filters( 'wc_stripe_localized_messages', array( |
|
41 | - 'invalid_number' => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ), |
|
42 | - 'invalid_expiry_month' => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ), |
|
43 | - 'invalid_expiry_year' => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ), |
|
44 | - 'invalid_cvc' => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ), |
|
45 | - 'incorrect_number' => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ), |
|
46 | - 'incomplete_number' => __( 'The card number is incomplete.', 'woocommerce-gateway-stripe' ), |
|
47 | - 'incomplete_cvc' => __( 'The card\'s security code is incomplete.', 'woocommerce-gateway-stripe' ), |
|
48 | - 'incomplete_expiry' => __( 'The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe' ), |
|
49 | - 'expired_card' => __( 'The card has expired.', 'woocommerce-gateway-stripe' ), |
|
50 | - 'incorrect_cvc' => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ), |
|
51 | - 'incorrect_zip' => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ), |
|
52 | - 'invalid_expiry_year_past' => __( 'The card\'s expiration year is in the past', 'woocommerce-gateway-stripe' ), |
|
53 | - 'card_declined' => __( 'The card was declined.', 'woocommerce-gateway-stripe' ), |
|
54 | - 'missing' => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ), |
|
55 | - 'processing_error' => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ), |
|
56 | - 'invalid_request_error' => __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ), |
|
57 | - 'invalid_sofort_country' => __( 'The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe' ), |
|
58 | - ) ); |
|
40 | + return apply_filters('wc_stripe_localized_messages', array( |
|
41 | + 'invalid_number' => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'), |
|
42 | + 'invalid_expiry_month' => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'), |
|
43 | + 'invalid_expiry_year' => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'), |
|
44 | + 'invalid_cvc' => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'), |
|
45 | + 'incorrect_number' => __('The card number is incorrect.', 'woocommerce-gateway-stripe'), |
|
46 | + 'incomplete_number' => __('The card number is incomplete.', 'woocommerce-gateway-stripe'), |
|
47 | + 'incomplete_cvc' => __('The card\'s security code is incomplete.', 'woocommerce-gateway-stripe'), |
|
48 | + 'incomplete_expiry' => __('The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe'), |
|
49 | + 'expired_card' => __('The card has expired.', 'woocommerce-gateway-stripe'), |
|
50 | + 'incorrect_cvc' => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'), |
|
51 | + 'incorrect_zip' => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'), |
|
52 | + 'invalid_expiry_year_past' => __('The card\'s expiration year is in the past', 'woocommerce-gateway-stripe'), |
|
53 | + 'card_declined' => __('The card was declined.', 'woocommerce-gateway-stripe'), |
|
54 | + 'missing' => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'), |
|
55 | + 'processing_error' => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'), |
|
56 | + 'invalid_request_error' => __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe'), |
|
57 | + 'invalid_sofort_country' => __('The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe'), |
|
58 | + )); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -92,24 +92,24 @@ discard block |
||
92 | 92 | * @param string $type Type of number to format |
93 | 93 | * @return string |
94 | 94 | */ |
95 | - public static function format_balance_fee( $balance_transaction, $type = 'fee' ) { |
|
96 | - if ( ! is_object( $balance_transaction ) ) { |
|
95 | + public static function format_balance_fee($balance_transaction, $type = 'fee') { |
|
96 | + if ( ! is_object($balance_transaction)) { |
|
97 | 97 | return; |
98 | 98 | } |
99 | 99 | |
100 | - if ( in_array( strtolower( $balance_transaction->currency ), self::no_decimal_currencies() ) ) { |
|
101 | - if ( 'fee' === $type ) { |
|
100 | + if (in_array(strtolower($balance_transaction->currency), self::no_decimal_currencies())) { |
|
101 | + if ('fee' === $type) { |
|
102 | 102 | return $balance_transaction->fee; |
103 | 103 | } |
104 | 104 | |
105 | 105 | return $balance_transaction->net; |
106 | 106 | } |
107 | 107 | |
108 | - if ( 'fee' === $type ) { |
|
109 | - return number_format( $balance_transaction->fee / 100, 2, '.', '' ); |
|
108 | + if ('fee' === $type) { |
|
109 | + return number_format($balance_transaction->fee / 100, 2, '.', ''); |
|
110 | 110 | } |
111 | 111 | |
112 | - return number_format( $balance_transaction->net / 100, 2, '.', '' ); |
|
112 | + return number_format($balance_transaction->net / 100, 2, '.', ''); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public static function get_minimum_amount() { |
119 | 119 | // Check order amount |
120 | - switch ( get_woocommerce_currency() ) { |
|
120 | + switch (get_woocommerce_currency()) { |
|
121 | 121 | case 'USD': |
122 | 122 | case 'CAD': |
123 | 123 | case 'EUR': |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | * @param string $method The payment method to get the settings from. |
163 | 163 | * @param string $setting The name of the setting to get. |
164 | 164 | */ |
165 | - public static function get_settings( $method = null, $setting = null ) { |
|
166 | - $all_settings = null === $method ? get_option( 'woocommerce_stripe_settings', array() ) : get_option( 'woocommerce_stripe_' . $method . '_settings', array() ); |
|
165 | + public static function get_settings($method = null, $setting = null) { |
|
166 | + $all_settings = null === $method ? get_option('woocommerce_stripe_settings', array()) : get_option('woocommerce_stripe_' . $method . '_settings', array()); |
|
167 | 167 | |
168 | - if ( null === $setting ) { |
|
168 | + if (null === $setting) { |
|
169 | 169 | return $all_settings; |
170 | 170 | } |
171 | 171 | |
172 | - return isset( $all_settings[ $setting ] ) ? $all_settings[ $setting ] : ''; |
|
172 | + return isset($all_settings[$setting]) ? $all_settings[$setting] : ''; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @return bool |
181 | 181 | */ |
182 | 182 | public static function is_pre_30() { |
183 | - return version_compare( WC_VERSION, '3.0.0', '<' ); |
|
183 | + return version_compare(WC_VERSION, '3.0.0', '<'); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @return string |
194 | 194 | */ |
195 | 195 | public static function get_webhook_url() { |
196 | - return add_query_arg( 'wc-api', 'wc_stripe', trailingslashit( get_home_url() ) ); |
|
196 | + return add_query_arg('wc-api', 'wc_stripe', trailingslashit(get_home_url())); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | * @version 4.0.0 |
204 | 204 | * @param string $source_id |
205 | 205 | */ |
206 | - public static function get_order_by_source_id( $source_id ) { |
|
206 | + public static function get_order_by_source_id($source_id) { |
|
207 | 207 | global $wpdb; |
208 | 208 | |
209 | - $order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s", $source_id ) ); |
|
209 | + $order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s", $source_id)); |
|
210 | 210 | |
211 | - if ( ! empty( $order_id ) ) { |
|
212 | - return wc_get_order( $order_id ); |
|
211 | + if ( ! empty($order_id)) { |
|
212 | + return wc_get_order($order_id); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | return false; |
@@ -222,13 +222,13 @@ discard block |
||
222 | 222 | * @version 4.0.0 |
223 | 223 | * @param string $charge_id |
224 | 224 | */ |
225 | - public static function get_order_by_charge_id( $charge_id ) { |
|
225 | + public static function get_order_by_charge_id($charge_id) { |
|
226 | 226 | global $wpdb; |
227 | 227 | |
228 | - $order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s", $charge_id ) ); |
|
228 | + $order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s", $charge_id)); |
|
229 | 229 | |
230 | - if ( ! empty( $order_id ) ) { |
|
231 | - return wc_get_order( $order_id ); |
|
230 | + if ( ! empty($order_id)) { |
|
231 | + return wc_get_order($order_id); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | return false; |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | * @param string $statement_descriptor |
245 | 245 | * @return string $statement_descriptor Sanitized statement descriptor |
246 | 246 | */ |
247 | - public static function clean_statement_descriptor( $statement_descriptor = '' ) { |
|
248 | - $disallowed_characters = array( '<', '>', '"', "'" ); |
|
247 | + public static function clean_statement_descriptor($statement_descriptor = '') { |
|
248 | + $disallowed_characters = array('<', '>', '"', "'"); |
|
249 | 249 | |
250 | 250 | // Remove special characters. |
251 | - $statement_descriptor = str_replace( $disallowed_characters, '', $statement_descriptor ); |
|
251 | + $statement_descriptor = str_replace($disallowed_characters, '', $statement_descriptor); |
|
252 | 252 | |
253 | - $statement_descriptor = substr( trim( $statement_descriptor ), 0, 22 ); |
|
253 | + $statement_descriptor = substr(trim($statement_descriptor), 0, 22); |
|
254 | 254 | |
255 | 255 | return $statement_descriptor; |
256 | 256 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function __construct() { |
59 | 59 | $this->id = 'stripe_p24'; |
60 | - $this->method_title = __( 'Stripe P24', 'woocommerce-gateway-stripe' ); |
|
60 | + $this->method_title = __('Stripe P24', 'woocommerce-gateway-stripe'); |
|
61 | 61 | /* translators: link */ |
62 | - $this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe' ) ); |
|
62 | + $this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout§ion=stripe')); |
|
63 | 63 | $this->supports = array( |
64 | 64 | 'products', |
65 | 65 | 'refunds', |
@@ -71,25 +71,25 @@ discard block |
||
71 | 71 | // Load the settings. |
72 | 72 | $this->init_settings(); |
73 | 73 | |
74 | - $main_settings = get_option( 'woocommerce_stripe_settings' ); |
|
75 | - $this->title = $this->get_option( 'title' ); |
|
76 | - $this->description = $this->get_option( 'description' ); |
|
77 | - $this->enabled = $this->get_option( 'enabled' ); |
|
78 | - $this->testmode = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false; |
|
79 | - $this->saved_cards = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false; |
|
80 | - $this->publishable_key = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : ''; |
|
81 | - $this->secret_key = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : ''; |
|
82 | - $this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : ''; |
|
83 | - |
|
84 | - if ( $this->testmode ) { |
|
85 | - $this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : ''; |
|
86 | - $this->secret_key = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : ''; |
|
74 | + $main_settings = get_option('woocommerce_stripe_settings'); |
|
75 | + $this->title = $this->get_option('title'); |
|
76 | + $this->description = $this->get_option('description'); |
|
77 | + $this->enabled = $this->get_option('enabled'); |
|
78 | + $this->testmode = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false; |
|
79 | + $this->saved_cards = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false; |
|
80 | + $this->publishable_key = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : ''; |
|
81 | + $this->secret_key = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : ''; |
|
82 | + $this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : ''; |
|
83 | + |
|
84 | + if ($this->testmode) { |
|
85 | + $this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : ''; |
|
86 | + $this->secret_key = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : ''; |
|
87 | 87 | } |
88 | 88 | |
89 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
90 | - add_action( 'admin_notices', array( $this, 'check_environment' ) ); |
|
91 | - add_action( 'admin_head', array( $this, 'remove_admin_notice' ) ); |
|
92 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
89 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
90 | + add_action('admin_notices', array($this, 'check_environment')); |
|
91 | + add_action('admin_head', array($this, 'remove_admin_notice')); |
|
92 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | * @version 4.0.0 |
100 | 100 | */ |
101 | 101 | public function check_environment() { |
102 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
102 | + if ( ! current_user_can('manage_woocommerce')) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $environment_warning = $this->get_environment_warning(); |
107 | 107 | |
108 | - if ( $environment_warning ) { |
|
109 | - $this->add_admin_notice( 'bad_environment', 'error', $environment_warning ); |
|
108 | + if ($environment_warning) { |
|
109 | + $this->add_admin_notice('bad_environment', 'error', $environment_warning); |
|
110 | 110 | } |
111 | 111 | |
112 | - foreach ( (array) $this->notices as $notice_key => $notice ) { |
|
113 | - echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>"; |
|
114 | - echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) ); |
|
112 | + foreach ((array) $this->notices as $notice_key => $notice) { |
|
113 | + echo "<div class='" . esc_attr($notice['class']) . "'><p>"; |
|
114 | + echo wp_kses($notice['message'], array('a' => array('href' => array()))); |
|
115 | 115 | echo '</p></div>'; |
116 | 116 | } |
117 | 117 | } |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @version 4.0.0 |
125 | 125 | */ |
126 | 126 | public function get_environment_warning() { |
127 | - if ( 'yes' === $this->enabled && ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
128 | - $message = __( 'P24 is enabled - it requires store currency to be set to Euros or Polish Zloty.', 'woocommerce-gateway-stripe' ); |
|
127 | + if ('yes' === $this->enabled && ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
128 | + $message = __('P24 is enabled - it requires store currency to be set to Euros or Polish Zloty.', 'woocommerce-gateway-stripe'); |
|
129 | 129 | |
130 | 130 | return $message; |
131 | 131 | } |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | * @return array |
142 | 142 | */ |
143 | 143 | public function get_supported_currency() { |
144 | - return apply_filters( 'wc_stripe_p24_supported_currencies', array( |
|
144 | + return apply_filters('wc_stripe_p24_supported_currencies', array( |
|
145 | 145 | 'EUR', |
146 | 146 | 'PLN', |
147 | - ) ); |
|
147 | + )); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @return bool |
156 | 156 | */ |
157 | 157 | public function is_available() { |
158 | - if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
158 | + if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
159 | 159 | return false; |
160 | 160 | } |
161 | 161 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | $icons_str .= $icons['p24']; |
178 | 178 | |
179 | - return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id ); |
|
179 | + return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -187,19 +187,19 @@ discard block |
||
187 | 187 | * @access public |
188 | 188 | */ |
189 | 189 | public function payment_scripts() { |
190 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { |
|
190 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
194 | - wp_enqueue_style( 'stripe_paymentfonts' ); |
|
195 | - wp_enqueue_script( 'woocommerce_stripe' ); |
|
194 | + wp_enqueue_style('stripe_paymentfonts'); |
|
195 | + wp_enqueue_script('woocommerce_stripe'); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
199 | 199 | * Initialize Gateway Settings Form Fields. |
200 | 200 | */ |
201 | 201 | public function init_form_fields() { |
202 | - $this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-p24-settings.php' ); |
|
202 | + $this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-p24-settings.php'); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -210,25 +210,25 @@ discard block |
||
210 | 210 | $total = WC()->cart->total; |
211 | 211 | |
212 | 212 | // If paying from order, we need to get total from order not cart. |
213 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
214 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
213 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
214 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
215 | 215 | $total = $order->get_total(); |
216 | 216 | } |
217 | 217 | |
218 | - if ( is_add_payment_method_page() ) { |
|
219 | - $pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' ); |
|
220 | - $total = ''; |
|
218 | + if (is_add_payment_method_page()) { |
|
219 | + $pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe'); |
|
220 | + $total = ''; |
|
221 | 221 | } else { |
222 | 222 | $pay_button_text = ''; |
223 | 223 | } |
224 | 224 | |
225 | 225 | echo '<div |
226 | 226 | id="stripe-p24-payment-data" |
227 | - data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '" |
|
228 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">'; |
|
227 | + data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '" |
|
228 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">'; |
|
229 | 229 | |
230 | - if ( $this->description ) { |
|
231 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) ); |
|
230 | + if ($this->description) { |
|
231 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description))); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | echo '</div>'; |
@@ -242,20 +242,20 @@ discard block |
||
242 | 242 | * @param object $order |
243 | 243 | * @return mixed |
244 | 244 | */ |
245 | - public function create_source( $order ) { |
|
245 | + public function create_source($order) { |
|
246 | 246 | $currency = WC_Stripe_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency(); |
247 | 247 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
248 | - $return_url = $this->get_stripe_return_url( $order ); |
|
248 | + $return_url = $this->get_stripe_return_url($order); |
|
249 | 249 | $post_data = array(); |
250 | - $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency ); |
|
251 | - $post_data['currency'] = strtolower( $currency ); |
|
250 | + $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency); |
|
251 | + $post_data['currency'] = strtolower($currency); |
|
252 | 252 | $post_data['type'] = 'p24'; |
253 | - $post_data['owner'] = $this->get_owner_details( $order ); |
|
254 | - $post_data['redirect'] = array( 'return_url' => $return_url ); |
|
253 | + $post_data['owner'] = $this->get_owner_details($order); |
|
254 | + $post_data['redirect'] = array('return_url' => $return_url); |
|
255 | 255 | |
256 | - WC_Stripe_Logger::log( 'Info: Begin creating P24 source' ); |
|
256 | + WC_Stripe_Logger::log('Info: Begin creating P24 source'); |
|
257 | 257 | |
258 | - return WC_Stripe_API::request( apply_filters( 'wc_stripe_p24_source', $post_data, $order ), 'sources' ); |
|
258 | + return WC_Stripe_API::request(apply_filters('wc_stripe_p24_source', $post_data, $order), 'sources'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -269,51 +269,51 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return array|void |
271 | 271 | */ |
272 | - public function process_payment( $order_id, $retry = true, $force_save_source = false ) { |
|
272 | + public function process_payment($order_id, $retry = true, $force_save_source = false) { |
|
273 | 273 | try { |
274 | - $order = wc_get_order( $order_id ); |
|
274 | + $order = wc_get_order($order_id); |
|
275 | 275 | |
276 | 276 | // This will throw exception if not valid. |
277 | - $this->validate_minimum_order_amount( $order ); |
|
277 | + $this->validate_minimum_order_amount($order); |
|
278 | 278 | |
279 | 279 | // This comes from the create account checkbox in the checkout page. |
280 | - $create_account = ! empty( $_POST['createaccount'] ) ? true : false; |
|
280 | + $create_account = ! empty($_POST['createaccount']) ? true : false; |
|
281 | 281 | |
282 | - if ( $create_account ) { |
|
282 | + if ($create_account) { |
|
283 | 283 | $new_customer_id = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(); |
284 | - $new_stripe_customer = new WC_Stripe_Customer( $new_customer_id ); |
|
284 | + $new_stripe_customer = new WC_Stripe_Customer($new_customer_id); |
|
285 | 285 | $new_stripe_customer->create_customer(); |
286 | 286 | } |
287 | 287 | |
288 | - $response = $this->create_source( $order ); |
|
288 | + $response = $this->create_source($order); |
|
289 | 289 | |
290 | - if ( ! empty( $response->error ) ) { |
|
291 | - $order->add_order_note( $response->error->message ); |
|
290 | + if ( ! empty($response->error)) { |
|
291 | + $order->add_order_note($response->error->message); |
|
292 | 292 | |
293 | - throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
293 | + throw new WC_Stripe_Exception(print_r($response, true), $response->error->message); |
|
294 | 294 | } |
295 | 295 | |
296 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
297 | - update_post_meta( $order_id, '_stripe_source_id', $response->id ); |
|
296 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
297 | + update_post_meta($order_id, '_stripe_source_id', $response->id); |
|
298 | 298 | } else { |
299 | - $order->update_meta_data( '_stripe_source_id', $response->id ); |
|
299 | + $order->update_meta_data('_stripe_source_id', $response->id); |
|
300 | 300 | $order->save(); |
301 | 301 | } |
302 | 302 | |
303 | - WC_Stripe_Logger::log( 'Info: Redirecting to P24...' ); |
|
303 | + WC_Stripe_Logger::log('Info: Redirecting to P24...'); |
|
304 | 304 | |
305 | 305 | return array( |
306 | 306 | 'result' => 'success', |
307 | - 'redirect' => esc_url_raw( $response->redirect->url ), |
|
307 | + 'redirect' => esc_url_raw($response->redirect->url), |
|
308 | 308 | ); |
309 | - } catch ( WC_Stripe_Exception $e ) { |
|
310 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
311 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
309 | + } catch (WC_Stripe_Exception $e) { |
|
310 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
311 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
312 | 312 | |
313 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
313 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
314 | 314 | |
315 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
316 | - $this->send_failed_order_email( $order_id ); |
|
315 | + if ($order->has_status(array('pending', 'failed'))) { |
|
316 | + $this->send_failed_order_email($order_id); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | return array( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function __construct() { |
59 | 59 | $this->id = 'stripe_giropay'; |
60 | - $this->method_title = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' ); |
|
60 | + $this->method_title = __('Stripe Giropay', 'woocommerce-gateway-stripe'); |
|
61 | 61 | /* translators: link */ |
62 | - $this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe' ) ); |
|
62 | + $this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout§ion=stripe')); |
|
63 | 63 | $this->supports = array( |
64 | 64 | 'products', |
65 | 65 | 'refunds', |
@@ -71,25 +71,25 @@ discard block |
||
71 | 71 | // Load the settings. |
72 | 72 | $this->init_settings(); |
73 | 73 | |
74 | - $main_settings = get_option( 'woocommerce_stripe_settings' ); |
|
75 | - $this->title = $this->get_option( 'title' ); |
|
76 | - $this->description = $this->get_option( 'description' ); |
|
77 | - $this->enabled = $this->get_option( 'enabled' ); |
|
78 | - $this->testmode = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false; |
|
79 | - $this->saved_cards = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false; |
|
80 | - $this->publishable_key = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : ''; |
|
81 | - $this->secret_key = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : ''; |
|
82 | - $this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : ''; |
|
83 | - |
|
84 | - if ( $this->testmode ) { |
|
85 | - $this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : ''; |
|
86 | - $this->secret_key = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : ''; |
|
74 | + $main_settings = get_option('woocommerce_stripe_settings'); |
|
75 | + $this->title = $this->get_option('title'); |
|
76 | + $this->description = $this->get_option('description'); |
|
77 | + $this->enabled = $this->get_option('enabled'); |
|
78 | + $this->testmode = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false; |
|
79 | + $this->saved_cards = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false; |
|
80 | + $this->publishable_key = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : ''; |
|
81 | + $this->secret_key = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : ''; |
|
82 | + $this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : ''; |
|
83 | + |
|
84 | + if ($this->testmode) { |
|
85 | + $this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : ''; |
|
86 | + $this->secret_key = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : ''; |
|
87 | 87 | } |
88 | 88 | |
89 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
90 | - add_action( 'admin_notices', array( $this, 'check_environment' ) ); |
|
91 | - add_action( 'admin_head', array( $this, 'remove_admin_notice' ) ); |
|
92 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
89 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
90 | + add_action('admin_notices', array($this, 'check_environment')); |
|
91 | + add_action('admin_head', array($this, 'remove_admin_notice')); |
|
92 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | * @version 4.0.0 |
100 | 100 | */ |
101 | 101 | public function check_environment() { |
102 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
102 | + if ( ! current_user_can('manage_woocommerce')) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $environment_warning = $this->get_environment_warning(); |
107 | 107 | |
108 | - if ( $environment_warning ) { |
|
109 | - $this->add_admin_notice( 'bad_environment', 'error', $environment_warning ); |
|
108 | + if ($environment_warning) { |
|
109 | + $this->add_admin_notice('bad_environment', 'error', $environment_warning); |
|
110 | 110 | } |
111 | 111 | |
112 | - foreach ( (array) $this->notices as $notice_key => $notice ) { |
|
113 | - echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>"; |
|
114 | - echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) ); |
|
112 | + foreach ((array) $this->notices as $notice_key => $notice) { |
|
113 | + echo "<div class='" . esc_attr($notice['class']) . "'><p>"; |
|
114 | + echo wp_kses($notice['message'], array('a' => array('href' => array()))); |
|
115 | 115 | echo '</p></div>'; |
116 | 116 | } |
117 | 117 | } |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @version 4.0.0 |
125 | 125 | */ |
126 | 126 | public function get_environment_warning() { |
127 | - if ( 'yes' === $this->enabled && ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
128 | - $message = __( 'Giropay is enabled - it requires store currency to be set to Euros.', 'woocommerce-gateway-stripe' ); |
|
127 | + if ('yes' === $this->enabled && ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
128 | + $message = __('Giropay is enabled - it requires store currency to be set to Euros.', 'woocommerce-gateway-stripe'); |
|
129 | 129 | |
130 | 130 | return $message; |
131 | 131 | } |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | * @return array |
142 | 142 | */ |
143 | 143 | public function get_supported_currency() { |
144 | - return apply_filters( 'wc_stripe_giropay_supported_currencies', array( |
|
144 | + return apply_filters('wc_stripe_giropay_supported_currencies', array( |
|
145 | 145 | 'EUR', |
146 | - ) ); |
|
146 | + )); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return bool |
155 | 155 | */ |
156 | 156 | public function is_available() { |
157 | - if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
157 | + if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | $icons_str .= $icons['giropay']; |
177 | 177 | |
178 | - return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id ); |
|
178 | + return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -186,19 +186,19 @@ discard block |
||
186 | 186 | * @access public |
187 | 187 | */ |
188 | 188 | public function payment_scripts() { |
189 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { |
|
189 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) { |
|
190 | 190 | return; |
191 | 191 | } |
192 | 192 | |
193 | - wp_enqueue_style( 'stripe_paymentfonts' ); |
|
194 | - wp_enqueue_script( 'woocommerce_stripe' ); |
|
193 | + wp_enqueue_style('stripe_paymentfonts'); |
|
194 | + wp_enqueue_script('woocommerce_stripe'); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Initialize Gateway Settings Form Fields. |
199 | 199 | */ |
200 | 200 | public function init_form_fields() { |
201 | - $this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-giropay-settings.php' ); |
|
201 | + $this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-giropay-settings.php'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -209,25 +209,25 @@ discard block |
||
209 | 209 | $total = WC()->cart->total; |
210 | 210 | |
211 | 211 | // If paying from order, we need to get total from order not cart. |
212 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
213 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
212 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
213 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
214 | 214 | $total = $order->get_total(); |
215 | 215 | } |
216 | 216 | |
217 | - if ( is_add_payment_method_page() ) { |
|
218 | - $pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' ); |
|
219 | - $total = ''; |
|
217 | + if (is_add_payment_method_page()) { |
|
218 | + $pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe'); |
|
219 | + $total = ''; |
|
220 | 220 | } else { |
221 | 221 | $pay_button_text = ''; |
222 | 222 | } |
223 | 223 | |
224 | 224 | echo '<div |
225 | 225 | id="stripe-giropay-payment-data" |
226 | - data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '" |
|
227 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">'; |
|
226 | + data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '" |
|
227 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">'; |
|
228 | 228 | |
229 | - if ( $this->description ) { |
|
230 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) ); |
|
229 | + if ($this->description) { |
|
230 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description))); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | echo '</div>'; |
@@ -241,24 +241,24 @@ discard block |
||
241 | 241 | * @param object $order |
242 | 242 | * @return mixed |
243 | 243 | */ |
244 | - public function create_source( $order ) { |
|
244 | + public function create_source($order) { |
|
245 | 245 | $currency = WC_Stripe_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency(); |
246 | 246 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
247 | - $return_url = $this->get_stripe_return_url( $order ); |
|
247 | + $return_url = $this->get_stripe_return_url($order); |
|
248 | 248 | $post_data = array(); |
249 | - $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency ); |
|
250 | - $post_data['currency'] = strtolower( $currency ); |
|
249 | + $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency); |
|
250 | + $post_data['currency'] = strtolower($currency); |
|
251 | 251 | $post_data['type'] = 'giropay'; |
252 | - $post_data['owner'] = $this->get_owner_details( $order ); |
|
253 | - $post_data['redirect'] = array( 'return_url' => $return_url ); |
|
252 | + $post_data['owner'] = $this->get_owner_details($order); |
|
253 | + $post_data['redirect'] = array('return_url' => $return_url); |
|
254 | 254 | |
255 | - if ( ! empty( $this->statement_descriptor ) ) { |
|
256 | - $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor ); |
|
255 | + if ( ! empty($this->statement_descriptor)) { |
|
256 | + $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor); |
|
257 | 257 | } |
258 | 258 | |
259 | - WC_Stripe_Logger::log( 'Info: Begin creating Giropay source' ); |
|
259 | + WC_Stripe_Logger::log('Info: Begin creating Giropay source'); |
|
260 | 260 | |
261 | - return WC_Stripe_API::request( apply_filters( 'wc_stripe_giropay_source', $post_data, $order ), 'sources' ); |
|
261 | + return WC_Stripe_API::request(apply_filters('wc_stripe_giropay_source', $post_data, $order), 'sources'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -272,51 +272,51 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return array|void |
274 | 274 | */ |
275 | - public function process_payment( $order_id, $retry = true, $force_save_source = false ) { |
|
275 | + public function process_payment($order_id, $retry = true, $force_save_source = false) { |
|
276 | 276 | try { |
277 | - $order = wc_get_order( $order_id ); |
|
277 | + $order = wc_get_order($order_id); |
|
278 | 278 | |
279 | 279 | // This will throw exception if not valid. |
280 | - $this->validate_minimum_order_amount( $order ); |
|
280 | + $this->validate_minimum_order_amount($order); |
|
281 | 281 | |
282 | 282 | // This comes from the create account checkbox in the checkout page. |
283 | - $create_account = ! empty( $_POST['createaccount'] ) ? true : false; |
|
283 | + $create_account = ! empty($_POST['createaccount']) ? true : false; |
|
284 | 284 | |
285 | - if ( $create_account ) { |
|
285 | + if ($create_account) { |
|
286 | 286 | $new_customer_id = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(); |
287 | - $new_stripe_customer = new WC_Stripe_Customer( $new_customer_id ); |
|
287 | + $new_stripe_customer = new WC_Stripe_Customer($new_customer_id); |
|
288 | 288 | $new_stripe_customer->create_customer(); |
289 | 289 | } |
290 | 290 | |
291 | - $response = $this->create_source( $order ); |
|
291 | + $response = $this->create_source($order); |
|
292 | 292 | |
293 | - if ( ! empty( $response->error ) ) { |
|
294 | - $order->add_order_note( $response->error->message ); |
|
293 | + if ( ! empty($response->error)) { |
|
294 | + $order->add_order_note($response->error->message); |
|
295 | 295 | |
296 | - throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
296 | + throw new WC_Stripe_Exception(print_r($response, true), $response->error->message); |
|
297 | 297 | } |
298 | 298 | |
299 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
300 | - update_post_meta( $order_id, '_stripe_source_id', $response->id ); |
|
299 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
300 | + update_post_meta($order_id, '_stripe_source_id', $response->id); |
|
301 | 301 | } else { |
302 | - $order->update_meta_data( '_stripe_source_id', $response->id ); |
|
302 | + $order->update_meta_data('_stripe_source_id', $response->id); |
|
303 | 303 | $order->save(); |
304 | 304 | } |
305 | 305 | |
306 | - WC_Stripe_Logger::log( 'Info: Redirecting to Giropay...' ); |
|
306 | + WC_Stripe_Logger::log('Info: Redirecting to Giropay...'); |
|
307 | 307 | |
308 | 308 | return array( |
309 | 309 | 'result' => 'success', |
310 | - 'redirect' => esc_url_raw( $response->redirect->url ), |
|
310 | + 'redirect' => esc_url_raw($response->redirect->url), |
|
311 | 311 | ); |
312 | - } catch ( WC_Stripe_Exception $e ) { |
|
313 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
314 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
312 | + } catch (WC_Stripe_Exception $e) { |
|
313 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
314 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
315 | 315 | |
316 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
316 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
317 | 317 | |
318 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
319 | - $this->send_failed_order_email( $order_id ); |
|
318 | + if ($order->has_status(array('pending', 'failed'))) { |
|
319 | + $this->send_failed_order_email($order_id); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | return array( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function __construct() { |
59 | 59 | $this->id = 'stripe_ideal'; |
60 | - $this->method_title = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' ); |
|
60 | + $this->method_title = __('Stripe iDeal', 'woocommerce-gateway-stripe'); |
|
61 | 61 | /* translators: link */ |
62 | - $this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe' ) ); |
|
62 | + $this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout§ion=stripe')); |
|
63 | 63 | $this->supports = array( |
64 | 64 | 'products', |
65 | 65 | 'refunds', |
@@ -71,25 +71,25 @@ discard block |
||
71 | 71 | // Load the settings. |
72 | 72 | $this->init_settings(); |
73 | 73 | |
74 | - $main_settings = get_option( 'woocommerce_stripe_settings' ); |
|
75 | - $this->title = $this->get_option( 'title' ); |
|
76 | - $this->description = $this->get_option( 'description' ); |
|
77 | - $this->enabled = $this->get_option( 'enabled' ); |
|
78 | - $this->testmode = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false; |
|
79 | - $this->saved_cards = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false; |
|
80 | - $this->publishable_key = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : ''; |
|
81 | - $this->secret_key = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : ''; |
|
82 | - $this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : ''; |
|
83 | - |
|
84 | - if ( $this->testmode ) { |
|
85 | - $this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : ''; |
|
86 | - $this->secret_key = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : ''; |
|
74 | + $main_settings = get_option('woocommerce_stripe_settings'); |
|
75 | + $this->title = $this->get_option('title'); |
|
76 | + $this->description = $this->get_option('description'); |
|
77 | + $this->enabled = $this->get_option('enabled'); |
|
78 | + $this->testmode = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false; |
|
79 | + $this->saved_cards = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false; |
|
80 | + $this->publishable_key = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : ''; |
|
81 | + $this->secret_key = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : ''; |
|
82 | + $this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : ''; |
|
83 | + |
|
84 | + if ($this->testmode) { |
|
85 | + $this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : ''; |
|
86 | + $this->secret_key = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : ''; |
|
87 | 87 | } |
88 | 88 | |
89 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
90 | - add_action( 'admin_notices', array( $this, 'check_environment' ) ); |
|
91 | - add_action( 'admin_head', array( $this, 'remove_admin_notice' ) ); |
|
92 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
89 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
90 | + add_action('admin_notices', array($this, 'check_environment')); |
|
91 | + add_action('admin_head', array($this, 'remove_admin_notice')); |
|
92 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | * @version 4.0.0 |
100 | 100 | */ |
101 | 101 | public function check_environment() { |
102 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
102 | + if ( ! current_user_can('manage_woocommerce')) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $environment_warning = $this->get_environment_warning(); |
107 | 107 | |
108 | - if ( $environment_warning ) { |
|
109 | - $this->add_admin_notice( 'bad_environment', 'error', $environment_warning ); |
|
108 | + if ($environment_warning) { |
|
109 | + $this->add_admin_notice('bad_environment', 'error', $environment_warning); |
|
110 | 110 | } |
111 | 111 | |
112 | - foreach ( (array) $this->notices as $notice_key => $notice ) { |
|
113 | - echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>"; |
|
114 | - echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) ); |
|
112 | + foreach ((array) $this->notices as $notice_key => $notice) { |
|
113 | + echo "<div class='" . esc_attr($notice['class']) . "'><p>"; |
|
114 | + echo wp_kses($notice['message'], array('a' => array('href' => array()))); |
|
115 | 115 | echo '</p></div>'; |
116 | 116 | } |
117 | 117 | } |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @version 4.0.0 |
125 | 125 | */ |
126 | 126 | public function get_environment_warning() { |
127 | - if ( 'yes' === $this->enabled && ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
128 | - $message = __( 'iDeal is enabled - it requires store currency to be set to Euros.', 'woocommerce-gateway-stripe' ); |
|
127 | + if ('yes' === $this->enabled && ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
128 | + $message = __('iDeal is enabled - it requires store currency to be set to Euros.', 'woocommerce-gateway-stripe'); |
|
129 | 129 | |
130 | 130 | return $message; |
131 | 131 | } |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | * @return array |
142 | 142 | */ |
143 | 143 | public function get_supported_currency() { |
144 | - return apply_filters( 'wc_stripe_ideal_supported_currencies', array( |
|
144 | + return apply_filters('wc_stripe_ideal_supported_currencies', array( |
|
145 | 145 | 'EUR', |
146 | - ) ); |
|
146 | + )); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return bool |
155 | 155 | */ |
156 | 156 | public function is_available() { |
157 | - if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
157 | + if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | $icons_str .= $icons['ideal']; |
177 | 177 | |
178 | - return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id ); |
|
178 | + return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -186,19 +186,19 @@ discard block |
||
186 | 186 | * @access public |
187 | 187 | */ |
188 | 188 | public function payment_scripts() { |
189 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { |
|
189 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) { |
|
190 | 190 | return; |
191 | 191 | } |
192 | 192 | |
193 | - wp_enqueue_style( 'stripe_paymentfonts' ); |
|
194 | - wp_enqueue_script( 'woocommerce_stripe' ); |
|
193 | + wp_enqueue_style('stripe_paymentfonts'); |
|
194 | + wp_enqueue_script('woocommerce_stripe'); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Initialize Gateway Settings Form Fields. |
199 | 199 | */ |
200 | 200 | public function init_form_fields() { |
201 | - $this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-ideal-settings.php' ); |
|
201 | + $this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-ideal-settings.php'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -209,25 +209,25 @@ discard block |
||
209 | 209 | $total = WC()->cart->total; |
210 | 210 | |
211 | 211 | // If paying from order, we need to get total from order not cart. |
212 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
213 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
212 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
213 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
214 | 214 | $total = $order->get_total(); |
215 | 215 | } |
216 | 216 | |
217 | - if ( is_add_payment_method_page() ) { |
|
218 | - $pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' ); |
|
219 | - $total = ''; |
|
217 | + if (is_add_payment_method_page()) { |
|
218 | + $pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe'); |
|
219 | + $total = ''; |
|
220 | 220 | } else { |
221 | 221 | $pay_button_text = ''; |
222 | 222 | } |
223 | 223 | |
224 | 224 | echo '<div |
225 | 225 | id="stripe-ideal-payment-data" |
226 | - data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '" |
|
227 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">'; |
|
226 | + data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '" |
|
227 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">'; |
|
228 | 228 | |
229 | - if ( $this->description ) { |
|
230 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) ); |
|
229 | + if ($this->description) { |
|
230 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description))); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | echo '</div>'; |
@@ -241,24 +241,24 @@ discard block |
||
241 | 241 | * @param object $order |
242 | 242 | * @return mixed |
243 | 243 | */ |
244 | - public function create_source( $order ) { |
|
244 | + public function create_source($order) { |
|
245 | 245 | $currency = WC_Stripe_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency(); |
246 | 246 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
247 | - $return_url = $this->get_stripe_return_url( $order ); |
|
247 | + $return_url = $this->get_stripe_return_url($order); |
|
248 | 248 | $post_data = array(); |
249 | - $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency ); |
|
250 | - $post_data['currency'] = strtolower( $currency ); |
|
249 | + $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency); |
|
250 | + $post_data['currency'] = strtolower($currency); |
|
251 | 251 | $post_data['type'] = 'ideal'; |
252 | - $post_data['owner'] = $this->get_owner_details( $order ); |
|
253 | - $post_data['redirect'] = array( 'return_url' => $return_url ); |
|
252 | + $post_data['owner'] = $this->get_owner_details($order); |
|
253 | + $post_data['redirect'] = array('return_url' => $return_url); |
|
254 | 254 | |
255 | - if ( ! empty( $this->statement_descriptor ) ) { |
|
256 | - $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor ); |
|
255 | + if ( ! empty($this->statement_descriptor)) { |
|
256 | + $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor); |
|
257 | 257 | } |
258 | 258 | |
259 | - WC_Stripe_Logger::log( 'Info: Begin creating iDeal source' ); |
|
259 | + WC_Stripe_Logger::log('Info: Begin creating iDeal source'); |
|
260 | 260 | |
261 | - return WC_Stripe_API::request( apply_filters( 'wc_stripe_ideal_source', $post_data, $order ), 'sources' ); |
|
261 | + return WC_Stripe_API::request(apply_filters('wc_stripe_ideal_source', $post_data, $order), 'sources'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -272,51 +272,51 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return array|void |
274 | 274 | */ |
275 | - public function process_payment( $order_id, $retry = true, $force_save_source = false ) { |
|
275 | + public function process_payment($order_id, $retry = true, $force_save_source = false) { |
|
276 | 276 | try { |
277 | - $order = wc_get_order( $order_id ); |
|
277 | + $order = wc_get_order($order_id); |
|
278 | 278 | |
279 | 279 | // This will throw exception if not valid. |
280 | - $this->validate_minimum_order_amount( $order ); |
|
280 | + $this->validate_minimum_order_amount($order); |
|
281 | 281 | |
282 | 282 | // This comes from the create account checkbox in the checkout page. |
283 | - $create_account = ! empty( $_POST['createaccount'] ) ? true : false; |
|
283 | + $create_account = ! empty($_POST['createaccount']) ? true : false; |
|
284 | 284 | |
285 | - if ( $create_account ) { |
|
285 | + if ($create_account) { |
|
286 | 286 | $new_customer_id = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(); |
287 | - $new_stripe_customer = new WC_Stripe_Customer( $new_customer_id ); |
|
287 | + $new_stripe_customer = new WC_Stripe_Customer($new_customer_id); |
|
288 | 288 | $new_stripe_customer->create_customer(); |
289 | 289 | } |
290 | 290 | |
291 | - $response = $this->create_source( $order ); |
|
291 | + $response = $this->create_source($order); |
|
292 | 292 | |
293 | - if ( ! empty( $response->error ) ) { |
|
294 | - $order->add_order_note( $response->error->message ); |
|
293 | + if ( ! empty($response->error)) { |
|
294 | + $order->add_order_note($response->error->message); |
|
295 | 295 | |
296 | - throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
296 | + throw new WC_Stripe_Exception(print_r($response, true), $response->error->message); |
|
297 | 297 | } |
298 | 298 | |
299 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
300 | - update_post_meta( $order_id, '_stripe_source_id', $response->id ); |
|
299 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
300 | + update_post_meta($order_id, '_stripe_source_id', $response->id); |
|
301 | 301 | } else { |
302 | - $order->update_meta_data( '_stripe_source_id', $response->id ); |
|
302 | + $order->update_meta_data('_stripe_source_id', $response->id); |
|
303 | 303 | $order->save(); |
304 | 304 | } |
305 | 305 | |
306 | - WC_Stripe_Logger::log( 'Info: Redirecting to iDeal...' ); |
|
306 | + WC_Stripe_Logger::log('Info: Redirecting to iDeal...'); |
|
307 | 307 | |
308 | 308 | return array( |
309 | 309 | 'result' => 'success', |
310 | - 'redirect' => esc_url_raw( $response->redirect->url ), |
|
310 | + 'redirect' => esc_url_raw($response->redirect->url), |
|
311 | 311 | ); |
312 | - } catch ( WC_Stripe_Exception $e ) { |
|
313 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
314 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
312 | + } catch (WC_Stripe_Exception $e) { |
|
313 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
314 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
315 | 315 | |
316 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
316 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
317 | 317 | |
318 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
319 | - $this->send_failed_order_email( $order_id ); |
|
318 | + if ($order->has_status(array('pending', 'failed'))) { |
|
319 | + $this->send_failed_order_email($order_id); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | return array( |