Completed
Push — master ( 2515df...302e86 )
by Roy
02:08
created
includes/admin/stripe-alipay-settings.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,50 +1,50 @@
 block discarded – undo
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;">&nbsp;&nbsp;%s&nbsp;&nbsp;</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;">&nbsp;&nbsp;%s&nbsp;&nbsp;</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
 );
Please login to merge, or discard this patch.
includes/admin/stripe-p24-settings.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,46 +1,46 @@
 block discarded – undo
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;">&nbsp;&nbsp;%s&nbsp;&nbsp;</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;">&nbsp;&nbsp;%s&nbsp;&nbsp;</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
 );
Please login to merge, or discard this patch.
tests/phpunit/test-wc-stripe.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 
3 3
 class WC_Stripe_Test extends WP_UnitTestCase {
4 4
 	public function test_constants_defined() {
5
-		$this->assertTrue( defined( 'WC_STRIPE_VERSION' ) );
6
-		$this->assertTrue( defined( 'WC_STRIPE_MIN_PHP_VER' ) );
7
-		$this->assertTrue( defined( 'WC_STRIPE_MIN_WC_VER' ) );
8
-		$this->assertTrue( defined( 'WC_STRIPE_MAIN_FILE' ) );
9
-		$this->assertTrue( defined( 'WC_STRIPE_PLUGIN_URL' ) );
10
-		$this->assertTrue( defined( 'WC_STRIPE_PLUGIN_PATH' ) );
5
+		$this->assertTrue(defined('WC_STRIPE_VERSION'));
6
+		$this->assertTrue(defined('WC_STRIPE_MIN_PHP_VER'));
7
+		$this->assertTrue(defined('WC_STRIPE_MIN_WC_VER'));
8
+		$this->assertTrue(defined('WC_STRIPE_MAIN_FILE'));
9
+		$this->assertTrue(defined('WC_STRIPE_PLUGIN_URL'));
10
+		$this->assertTrue(defined('WC_STRIPE_PLUGIN_PATH'));
11 11
 	}
12 12
 
13 13
 	/**
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 	 * This test will see if we're indeed converting the price correctly.
16 16
 	 */
17 17
 	public function test_price_conversion_before_send_to_stripe() {
18
-		$this->assertEquals( 10050, WC_Stripe_Helper::get_stripe_amount( 100.50, 'USD' ) );
19
-		$this->assertEquals( 10050, WC_Stripe_Helper::get_stripe_amount( 10050, 'JPY' ) );
20
-		$this->assertEquals( 100, WC_Stripe_Helper::get_stripe_amount( 100.50, 'JPY' ) );
21
-		$this->assertEquals( 10050, WC_Stripe_Helper::get_stripe_amount( 100.50 ) );
22
-		$this->assertInternalType( 'int', WC_Stripe_Helper::get_stripe_amount( 100.50, 'USD' ) );
18
+		$this->assertEquals(10050, WC_Stripe_Helper::get_stripe_amount(100.50, 'USD'));
19
+		$this->assertEquals(10050, WC_Stripe_Helper::get_stripe_amount(10050, 'JPY'));
20
+		$this->assertEquals(100, WC_Stripe_Helper::get_stripe_amount(100.50, 'JPY'));
21
+		$this->assertEquals(10050, WC_Stripe_Helper::get_stripe_amount(100.50));
22
+		$this->assertInternalType('int', WC_Stripe_Helper::get_stripe_amount(100.50, 'USD'));
23 23
 	}
24 24
 
25 25
 	/**
@@ -33,37 +33,37 @@  discard block
 block discarded – undo
33 33
 		$balance_fee1->net = 10000;
34 34
 		$balance_fee1->currency = 'USD';
35 35
 
36
-		$this->assertEquals( 105.00, WC_Stripe_Helper::format_balance_fee( $balance_fee1, 'fee' ) );
36
+		$this->assertEquals(105.00, WC_Stripe_Helper::format_balance_fee($balance_fee1, 'fee'));
37 37
 
38 38
 		$balance_fee2 = new stdClass();
39 39
 		$balance_fee2->fee = 10500;
40 40
 		$balance_fee2->net = 10000;
41 41
 		$balance_fee2->currency = 'JPY';
42 42
 
43
-		$this->assertEquals( 10500, WC_Stripe_Helper::format_balance_fee( $balance_fee2, 'fee' ) );
43
+		$this->assertEquals(10500, WC_Stripe_Helper::format_balance_fee($balance_fee2, 'fee'));
44 44
 
45 45
 		$balance_fee3 = new stdClass();
46 46
 		$balance_fee3->fee = 10500;
47 47
 		$balance_fee3->net = 10000;
48 48
 		$balance_fee3->currency = 'USD';
49 49
 
50
-		$this->assertEquals( 100.00, WC_Stripe_Helper::format_balance_fee( $balance_fee3, 'net' ) );
50
+		$this->assertEquals(100.00, WC_Stripe_Helper::format_balance_fee($balance_fee3, 'net'));
51 51
 
52 52
 		$balance_fee4 = new stdClass();
53 53
 		$balance_fee4->fee = 10500;
54 54
 		$balance_fee4->net = 10000;
55 55
 		$balance_fee4->currency = 'JPY';
56 56
 
57
-		$this->assertEquals( 10000, WC_Stripe_Helper::format_balance_fee( $balance_fee4, 'net' ) );
57
+		$this->assertEquals(10000, WC_Stripe_Helper::format_balance_fee($balance_fee4, 'net'));
58 58
 
59 59
 		$balance_fee5 = new stdClass();
60 60
 		$balance_fee5->fee = 10500;
61 61
 		$balance_fee5->net = 10000;
62 62
 		$balance_fee5->currency = 'USD';
63 63
 
64
-		$this->assertEquals( 105.00, WC_Stripe_Helper::format_balance_fee( $balance_fee5 ) );
64
+		$this->assertEquals(105.00, WC_Stripe_Helper::format_balance_fee($balance_fee5));
65 65
 
66
-		$this->assertInternalType( 'string', WC_Stripe_Helper::format_balance_fee( $balance_fee5 ) );
66
+		$this->assertInternalType('string', WC_Stripe_Helper::format_balance_fee($balance_fee5));
67 67
 	}
68 68
 
69 69
 	/**
@@ -76,27 +76,27 @@  discard block
 block discarded – undo
76 76
 			'expected' => 'Tests Store',
77 77
 		);
78 78
 
79
-		$this->assertEquals( $statement_descriptor1['expected'], WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor1['actual'] ) );
79
+		$this->assertEquals($statement_descriptor1['expected'], WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor1['actual']));
80 80
 
81 81
 		$statement_descriptor2 = array(
82 82
 			'actual'   => 'Test\'s Store > Driving Course Range',
83 83
 			'expected' => 'Tests Store  Driving C',
84 84
 		);
85 85
 
86
-		$this->assertEquals( $statement_descriptor2['expected'], WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor2['actual'] ) );
86
+		$this->assertEquals($statement_descriptor2['expected'], WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor2['actual']));
87 87
 
88 88
 		$statement_descriptor3 = array(
89 89
 			'actual'   => 'Test\'s Store < Driving Course Range',
90 90
 			'expected' => 'Tests Store  Driving C',
91 91
 		);
92 92
 
93
-		$this->assertEquals( $statement_descriptor3['expected'], WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor3['actual'] ) );
93
+		$this->assertEquals($statement_descriptor3['expected'], WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor3['actual']));
94 94
 
95 95
 		$statement_descriptor4 = array(
96 96
 			'actual'   => 'Test\'s Store " Driving Course Range',
97 97
 			'expected' => 'Tests Store  Driving C',
98 98
 		);
99 99
 
100
-		$this->assertEquals( $statement_descriptor4['expected'], WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor4['actual'] ) );
100
+		$this->assertEquals($statement_descriptor4['expected'], WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor4['actual']));
101 101
 	}
102 102
 }
Please login to merge, or discard this patch.
tests/phpunit/bootstrap.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-$_tests_dir = getenv( 'WP_TESTS_DIR' );
4
-if ( ! $_tests_dir ) {
3
+$_tests_dir = getenv('WP_TESTS_DIR');
4
+if ( ! $_tests_dir) {
5 5
 	$_tests_dir = '/tmp/wordpress-tests-lib';
6 6
 }
7 7
 
8 8
 require_once $_tests_dir . '/includes/functions.php';
9 9
 
10 10
 function _manually_load_plugin() {
11
-	$plugin_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/';
11
+	$plugin_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/';
12 12
 	require $plugin_dir . 'woocommerce-gateway-stripe/woocommerce-gateway-stripe.php';
13 13
 	require $plugin_dir . 'woocommerce/woocommerce.php';
14 14
 }
@@ -17,20 +17,20 @@  discard block
 block discarded – undo
17 17
 	return true;
18 18
 }
19 19
 
20
-function woothemes_queue_update( $file, $file_id, $product_id ) {
20
+function woothemes_queue_update($file, $file_id, $product_id) {
21 21
 	return true;
22 22
 }
23 23
 
24
-tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
24
+tests_add_filter('muplugins_loaded', '_manually_load_plugin');
25 25
 
26 26
 require $_tests_dir . '/includes/bootstrap.php';
27 27
 
28
-$wc_tests_framework_base_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/woocommerce/tests/framework/';
29
-require_once( $wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php' );
30
-require_once( $wc_tests_framework_base_dir . 'class-wc-unit-test-case.php' );
31
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php' );
32
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php' );
33
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php' );
34
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php' );
35
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php' );
36
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php' );
28
+$wc_tests_framework_base_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/woocommerce/tests/framework/';
29
+require_once($wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php');
30
+require_once($wc_tests_framework_base_dir . 'class-wc-unit-test-case.php');
31
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php');
32
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php');
33
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php');
34
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php');
35
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php');
36
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php');
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
woocommerce-gateway-stripe.php 1 patch
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -14,20 +14,20 @@  discard block
 block discarded – undo
14 14
  *
15 15
  */
16 16
 
17
-if ( ! defined( 'ABSPATH' ) ) {
17
+if ( ! defined('ABSPATH')) {
18 18
 	exit;
19 19
 }
20 20
 
21
-if ( ! class_exists( 'WC_Stripe' ) ) :
21
+if ( ! class_exists('WC_Stripe')) :
22 22
 	/**
23 23
 	 * Required minimums and constants
24 24
 	 */
25
-	define( 'WC_STRIPE_VERSION', '4.0.1' );
26
-	define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
27
-	define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' );
28
-	define( 'WC_STRIPE_MAIN_FILE', __FILE__ );
29
-	define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
30
-	define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
25
+	define('WC_STRIPE_VERSION', '4.0.1');
26
+	define('WC_STRIPE_MIN_PHP_VER', '5.6.0');
27
+	define('WC_STRIPE_MIN_WC_VER', '2.6.0');
28
+	define('WC_STRIPE_MAIN_FILE', __FILE__);
29
+	define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__))));
30
+	define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__)));
31 31
 
32 32
 	class WC_Stripe {
33 33
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		 * @return Singleton The *Singleton* instance.
48 48
 		 */
49 49
 		public static function get_instance() {
50
-			if ( null === self::$instance ) {
50
+			if (null === self::$instance) {
51 51
 				self::$instance = new self();
52 52
 			}
53 53
 			return self::$instance;
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 		 * *Singleton* via the `new` operator from outside of this class.
81 81
 		 */
82 82
 		private function __construct() {
83
-			add_action( 'admin_init', array( $this, 'check_environment' ) );
84
-			add_action( 'admin_notices', array( $this, 'admin_notices' ), 15 );
85
-			add_action( 'plugins_loaded', array( $this, 'init' ) );
86
-			add_action( 'wp_loaded', array( $this, 'hide_notices' ) );
83
+			add_action('admin_init', array($this, 'check_environment'));
84
+			add_action('admin_notices', array($this, 'admin_notices'), 15);
85
+			add_action('plugins_loaded', array($this, 'init'));
86
+			add_action('wp_loaded', array($this, 'hide_notices'));
87 87
 		}
88 88
 
89 89
 		/**
@@ -93,42 +93,42 @@  discard block
 block discarded – undo
93 93
 		 * @version 4.0.0
94 94
 		 */
95 95
 		public function init() {
96
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php' );
97
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php' );
98
-			include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php' );
96
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-logger.php');
97
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-helper.php');
98
+			include_once(dirname(__FILE__) . '/includes/class-wc-stripe-api.php');
99 99
 
100 100
 			// Don't hook anything else in the plugin if we're in an incompatible environment
101
-			if ( self::get_environment_warning() ) {
101
+			if (self::get_environment_warning()) {
102 102
 				return;
103 103
 			}
104 104
 
105
-			load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
106
-
107
-			require_once( dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php' );
108
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php' );
109
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php' );
110
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php' );
111
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php' );
112
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php' );
113
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php' );
114
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php' );
115
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php' );
116
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php' );
117
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php' );
118
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bitcoin.php' );
119
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php' );
120
-			require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-compat.php' );
121
-			require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-compat.php' );
122
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php' );
123
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php' );
124
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php' );
105
+			load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages');
106
+
107
+			require_once(dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php');
108
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php');
109
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php');
110
+			require_once(dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php');
111
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php');
112
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php');
113
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php');
114
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php');
115
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php');
116
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php');
117
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php');
118
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bitcoin.php');
119
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php');
120
+			require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-compat.php');
121
+			require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-compat.php');
122
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php');
123
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php');
124
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-customer.php');
125 125
 
126 126
 			// REMOVE IN THE FUTURE.
127
-			require_once( dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php' );
127
+			require_once(dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php');
128 128
 
129
-			add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) );
130
-			add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
131
-			add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) );
129
+			add_filter('woocommerce_payment_gateways', array($this, 'add_gateways'));
130
+			add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
131
+			add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin'));
132 132
 		}
133 133
 
134 134
 		/**
@@ -138,23 +138,23 @@  discard block
 block discarded – undo
138 138
 		 * @version 4.0.0
139 139
 		 */
140 140
 		public function hide_notices() {
141
-			if ( isset( $_GET['wc-stripe-hide-notice'] ) && isset( $_GET['_wc_stripe_notice_nonce'] ) ) {
142
-				if ( ! wp_verify_nonce( $_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce' ) ) {
143
-					wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe' ) );
141
+			if (isset($_GET['wc-stripe-hide-notice']) && isset($_GET['_wc_stripe_notice_nonce'])) {
142
+				if ( ! wp_verify_nonce($_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce')) {
143
+					wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe'));
144 144
 				}
145 145
 
146
-				if ( ! current_user_can( 'manage_woocommerce' ) ) {
147
-					wp_die( __( 'Cheatin&#8217; huh?', 'woocommerce-gateway-stripe' ) );
146
+				if ( ! current_user_can('manage_woocommerce')) {
147
+					wp_die(__('Cheatin&#8217; huh?', 'woocommerce-gateway-stripe'));
148 148
 				}
149 149
 
150
-				$notice = wc_clean( $_GET['wc-stripe-hide-notice'] );
150
+				$notice = wc_clean($_GET['wc-stripe-hide-notice']);
151 151
 
152
-				switch ( $notice ) {
152
+				switch ($notice) {
153 153
 					case 'ssl':
154
-						update_option( 'wc_stripe_show_ssl_notice', 'no' );
154
+						update_option('wc_stripe_show_ssl_notice', 'no');
155 155
 						break;
156 156
 					case 'keys':
157
-						update_option( 'wc_stripe_show_keys_notice', 'no' );
157
+						update_option('wc_stripe_show_keys_notice', 'no');
158 158
 						break;
159 159
 				}
160 160
 			}
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 		 * @since 1.0.0
167 167
 		 * @version 4.0.0
168 168
 		 */
169
-		public function add_admin_notice( $slug, $class, $message, $dismissible = false ) {
170
-			$this->notices[ $slug ] = array(
169
+		public function add_admin_notice($slug, $class, $message, $dismissible = false) {
170
+			$this->notices[$slug] = array(
171 171
 				'class'       => $class,
172 172
 				'message'     => $message,
173 173
 				'dismissible' => $dismissible,
@@ -181,21 +181,21 @@  discard block
 block discarded – undo
181 181
 		 * @version 4.0.0
182 182
 		 */
183 183
 		public function admin_notices() {
184
-			if ( ! current_user_can( 'manage_woocommerce' ) ) {
184
+			if ( ! current_user_can('manage_woocommerce')) {
185 185
 				return;
186 186
 			}
187 187
 
188
-			foreach ( (array) $this->notices as $notice_key => $notice ) {
189
-				echo '<div class="' . esc_attr( $notice['class'] ) . '" style="position:relative;">';
188
+			foreach ((array) $this->notices as $notice_key => $notice) {
189
+				echo '<div class="' . esc_attr($notice['class']) . '" style="position:relative;">';
190 190
 
191
-				if ( $notice['dismissible'] ) {
191
+				if ($notice['dismissible']) {
192 192
 				?>
193
-					<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-stripe-hide-notice', $notice_key ), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce' ) ); ?>" class="woocommerce-message-close notice-dismiss" style="position:absolute;right:1px;padding:9px;text-decoration:none;"></a>
193
+					<a href="<?php echo esc_url(wp_nonce_url(add_query_arg('wc-stripe-hide-notice', $notice_key), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce')); ?>" class="woocommerce-message-close notice-dismiss" style="position:absolute;right:1px;padding:9px;text-decoration:none;"></a>
194 194
 				<?php
195 195
 				}
196 196
 
197 197
 				echo '<p>';
198
-				echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) );
198
+				echo wp_kses($notice['message'], array('a' => array('href' => array())));
199 199
 				echo '</p></div>';
200 200
 			}
201 201
 		}
@@ -208,26 +208,26 @@  discard block
 block discarded – undo
208 208
 		 * @version 4.0.0
209 209
 		 */
210 210
 		public function get_environment_warning() {
211
-			if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) {
211
+			if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) {
212 212
 				/* translators: 1) int version 2) int version */
213
-				$message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
213
+				$message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe');
214 214
 
215
-				return sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() );
215
+				return sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion());
216 216
 			}
217 217
 
218
-			if ( ! defined( 'WC_VERSION' ) ) {
219
-				return __( 'WooCommerce Stripe requires WooCommerce to be activated to work.', 'woocommerce-gateway-stripe' );
218
+			if ( ! defined('WC_VERSION')) {
219
+				return __('WooCommerce Stripe requires WooCommerce to be activated to work.', 'woocommerce-gateway-stripe');
220 220
 			}
221 221
 
222
-			if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) {
222
+			if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) {
223 223
 				/* translators: 1) int version 2) int version */
224
-				$message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
224
+				$message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe');
225 225
 
226
-				return sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION );
226
+				return sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION);
227 227
 			}
228 228
 
229
-			if ( ! function_exists( 'curl_init' ) ) {
230
-				return __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' );
229
+			if ( ! function_exists('curl_init')) {
230
+				return __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe');
231 231
 			}
232 232
 
233 233
 			return false;
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 		 * @return string Setting link
242 242
 		 */
243 243
 		public function get_setting_link() {
244
-			$use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false;
244
+			$use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false;
245 245
 
246
-			$section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' );
246
+			$section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe');
247 247
 
248
-			return admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . $section_slug );
248
+			return admin_url('admin.php?page=wc-settings&tab=checkout&section=' . $section_slug);
249 249
 		}
250 250
 
251 251
 		/**
@@ -256,37 +256,37 @@  discard block
 block discarded – undo
256 256
 		 * @version 4.0.0
257 257
 		 */
258 258
 		public function check_environment() {
259
-			if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) {
259
+			if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) {
260 260
 				$this->install();
261 261
 
262
-				do_action( 'woocommerce_stripe_updated' );
262
+				do_action('woocommerce_stripe_updated');
263 263
 			}
264 264
 
265 265
 			$environment_warning = $this->get_environment_warning();
266 266
 
267
-			if ( $environment_warning && is_plugin_active( plugin_basename( __FILE__ ) ) ) {
268
-				$this->add_admin_notice( 'bad_environment', 'error', $environment_warning );
267
+			if ($environment_warning && is_plugin_active(plugin_basename(__FILE__))) {
268
+				$this->add_admin_notice('bad_environment', 'error', $environment_warning);
269 269
 			}
270 270
 
271
-			$show_ssl_notice  = get_option( 'wc_stripe_show_ssl_notice' );
272
-			$show_keys_notice = get_option( 'wc_stripe_show_keys_notice' );
273
-			$options          = get_option( 'woocommerce_stripe_settings' );
271
+			$show_ssl_notice  = get_option('wc_stripe_show_ssl_notice');
272
+			$show_keys_notice = get_option('wc_stripe_show_keys_notice');
273
+			$options          = get_option('woocommerce_stripe_settings');
274 274
 
275
-			if ( isset( $options['enabled'] ) && 'yes' === $options['enabled'] && empty( $show_keys_notice ) ) {
276
-				$secret  = WC_Stripe_API::get_secret_key();
275
+			if (isset($options['enabled']) && 'yes' === $options['enabled'] && empty($show_keys_notice)) {
276
+				$secret = WC_Stripe_API::get_secret_key();
277 277
 
278
-				if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) {
278
+				if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) {
279 279
 					$setting_link = $this->get_setting_link();
280 280
 					/* translators: 1) link */
281
-					$this->add_admin_notice( 'keys', 'notice notice-warning', sprintf( __( 'Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
281
+					$this->add_admin_notice('keys', 'notice notice-warning', sprintf(__('Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
282 282
 				}
283 283
 			}
284 284
 
285
-			if ( empty( $show_ssl_notice ) && isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) {
285
+			if (empty($show_ssl_notice) && isset($options['enabled']) && 'yes' === $options['enabled']) {
286 286
 				// Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected.
287
-				if ( ( function_exists( 'wc_site_is_https' ) && ! wc_site_is_https() ) && ( 'no' === get_option( 'woocommerce_force_ssl_checkout' ) && ! class_exists( 'WordPressHTTPS' ) ) ) {
287
+				if ((function_exists('wc_site_is_https') && ! wc_site_is_https()) && ('no' === get_option('woocommerce_force_ssl_checkout') && ! class_exists('WordPressHTTPS'))) {
288 288
 					/* translators: 1) link 2) link */
289
-					$this->add_admin_notice( 'ssl', 'notice notice-warning', sprintf( __( 'Stripe is enabled, but the <a href="%1$s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid <a href="%2$s" target="_blank">SSL certificate</a> - Stripe will only work in test mode.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout' ), 'https://en.wikipedia.org/wiki/Transport_Layer_Security' ), true );
289
+					$this->add_admin_notice('ssl', 'notice notice-warning', sprintf(__('Stripe is enabled, but the <a href="%1$s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid <a href="%2$s" target="_blank">SSL certificate</a> - Stripe will only work in test mode.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout'), 'https://en.wikipedia.org/wiki/Transport_Layer_Security'), true);
290 290
 				}
291 291
 			}
292 292
 		}
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 		 * @version 4.0.0
299 299
 		 */
300 300
 		public function update_plugin_version() {
301
-			delete_option( 'wc_stripe_version' );
302
-			update_option( 'wc_stripe_version', WC_STRIPE_VERSION );
301
+			delete_option('wc_stripe_version');
302
+			update_option('wc_stripe_version', WC_STRIPE_VERSION);
303 303
 		}
304 304
 
305 305
 		/**
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
 		 * @version 3.1.0
310 310
 		 */
311 311
 		public function install() {
312
-			if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) {
313
-				define( 'WC_STRIPE_INSTALLING', true );
312
+			if ( ! defined('WC_STRIPE_INSTALLING')) {
313
+				define('WC_STRIPE_INSTALLING', true);
314 314
 			}
315 315
 
316 316
 			$this->update_plugin_version();
@@ -322,13 +322,13 @@  discard block
 block discarded – undo
322 322
 		 * @since 1.0.0
323 323
 		 * @version 4.0.0
324 324
 		 */
325
-		public function plugin_action_links( $links ) {
325
+		public function plugin_action_links($links) {
326 326
 			$plugin_links = array(
327
-				'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
328
-				'<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>',
329
-				'<a href="https://woocommerce.com/contact-us/">' . esc_html__( 'Support', 'woocommerce-gateway-stripe' ) . '</a>',
327
+				'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>',
328
+				'<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__('Docs', 'woocommerce-gateway-stripe') . '</a>',
329
+				'<a href="https://woocommerce.com/contact-us/">' . esc_html__('Support', 'woocommerce-gateway-stripe') . '</a>',
330 330
 			);
331
-			return array_merge( $plugin_links, $links );
331
+			return array_merge($plugin_links, $links);
332 332
 		}
333 333
 
334 334
 		/**
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 		 * @since 1.0.0
338 338
 		 * @version 4.0.0
339 339
 		 */
340
-		public function add_gateways( $methods ) {
341
-			if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) || class_exists( 'WC_Pre_Orders_Order' ) ) {
340
+		public function add_gateways($methods) {
341
+			if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order') || class_exists('WC_Pre_Orders_Order')) {
342 342
 				$methods[] = 'WC_Stripe_Compat';
343 343
 				$methods[] = 'WC_Stripe_Sepa_Compat';
344 344
 			} else {
@@ -363,26 +363,26 @@  discard block
 block discarded – undo
363 363
 		 * @since 4.0.0
364 364
 		 * @version 4.0.0
365 365
 		 */
366
-		public function filter_gateway_order_admin( $sections ) {
367
-			unset( $sections['stripe'] );
368
-			unset( $sections['stripe_bancontact'] );
369
-			unset( $sections['stripe_sofort'] );
370
-			unset( $sections['stripe_giropay'] );
371
-			unset( $sections['stripe_ideal'] );
372
-			unset( $sections['stripe_p24'] );
373
-			unset( $sections['stripe_alipay'] );
374
-			unset( $sections['stripe_sepa'] );
375
-			unset( $sections['stripe_bitcoin'] );
366
+		public function filter_gateway_order_admin($sections) {
367
+			unset($sections['stripe']);
368
+			unset($sections['stripe_bancontact']);
369
+			unset($sections['stripe_sofort']);
370
+			unset($sections['stripe_giropay']);
371
+			unset($sections['stripe_ideal']);
372
+			unset($sections['stripe_p24']);
373
+			unset($sections['stripe_alipay']);
374
+			unset($sections['stripe_sepa']);
375
+			unset($sections['stripe_bitcoin']);
376 376
 
377 377
 			$sections['stripe']            = 'Stripe';
378
-			$sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' );
379
-			$sections['stripe_sofort']     = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' );
380
-			$sections['stripe_giropay']    = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' );
381
-			$sections['stripe_ideal']      = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' );
382
-			$sections['stripe_p24']        = __( 'Stripe P24', 'woocommerce-gateway-stripe' );
383
-			$sections['stripe_alipay']     = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
384
-			$sections['stripe_sepa']       = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' );
385
-			$sections['stripe_bitcoin']    = __( 'Stripe Bitcoin', 'woocommerce-gateway-stripe' );
378
+			$sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe');
379
+			$sections['stripe_sofort']     = __('Stripe SOFORT', 'woocommerce-gateway-stripe');
380
+			$sections['stripe_giropay']    = __('Stripe Giropay', 'woocommerce-gateway-stripe');
381
+			$sections['stripe_ideal']      = __('Stripe iDeal', 'woocommerce-gateway-stripe');
382
+			$sections['stripe_p24']        = __('Stripe P24', 'woocommerce-gateway-stripe');
383
+			$sections['stripe_alipay']     = __('Stripe Alipay', 'woocommerce-gateway-stripe');
384
+			$sections['stripe_sepa']       = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe');
385
+			$sections['stripe_bitcoin']    = __('Stripe Bitcoin', 'woocommerce-gateway-stripe');
386 386
 
387 387
 			return $sections;
388 388
 		}
Please login to merge, or discard this patch.
includes/deprecated/class-wc-stripe-apple-pay.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6 6
 /**
7 7
  * DEPRECATED DO NOT USE!!
8 8
  */
9
-if ( ! class_exists( 'WC_Stripe_Apple_Pay' ) ) {
9
+if ( ! class_exists('WC_Stripe_Apple_Pay')) {
10 10
 	class WC_Stripe_Apple_Pay {
11 11
 		/**
12 12
 		 * This Instance.
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		}
22 22
 
23 23
 		public static function instance() {
24
-			WC_Stripe_Logger::log( "DEPRECATED! WC_Stripe_Apple_Pay class has been hard deprecated. Please remove any code that references this class or instance." );
24
+			WC_Stripe_Logger::log("DEPRECATED! WC_Stripe_Apple_Pay class has been hard deprecated. Please remove any code that references this class or instance.");
25 25
 			return self::$_this;
26 26
 		}	
27 27
 	}
Please login to merge, or discard this patch.
includes/compat/class-wc-stripe-sepa-compat.php 1 patch
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 	public function __construct() {
16 16
 		parent::__construct();
17 17
 
18
-		if ( class_exists( 'WC_Subscriptions_Order' ) ) {
19
-			add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 );
20
-			add_action( 'wcs_resubscribe_order_created', array( $this, 'delete_resubscribe_meta' ), 10 );
21
-			add_action( 'wcs_renewal_order_created', array( $this, 'delete_renewal_meta' ), 10 );
22
-			add_action( 'woocommerce_subscription_failing_payment_method_updated_stripe', array( $this, 'update_failing_payment_method' ), 10, 2 );
18
+		if (class_exists('WC_Subscriptions_Order')) {
19
+			add_action('woocommerce_scheduled_subscription_payment_' . $this->id, array($this, 'scheduled_subscription_payment'), 10, 2);
20
+			add_action('wcs_resubscribe_order_created', array($this, 'delete_resubscribe_meta'), 10);
21
+			add_action('wcs_renewal_order_created', array($this, 'delete_renewal_meta'), 10);
22
+			add_action('woocommerce_subscription_failing_payment_method_updated_stripe', array($this, 'update_failing_payment_method'), 10, 2);
23 23
 
24 24
 			// display the credit card used for a subscription in the "My Subscriptions" table
25
-			add_filter( 'woocommerce_my_subscriptions_payment_method', array( $this, 'maybe_render_subscription_payment_method' ), 10, 2 );
25
+			add_filter('woocommerce_my_subscriptions_payment_method', array($this, 'maybe_render_subscription_payment_method'), 10, 2);
26 26
 
27 27
 			// allow store managers to manually set Stripe as the payment method on a subscription
28
-			add_filter( 'woocommerce_subscription_payment_meta', array( $this, 'add_subscription_payment_meta' ), 10, 2 );
29
-			add_filter( 'woocommerce_subscription_validate_payment_meta', array( $this, 'validate_subscription_payment_meta' ), 10, 2 );
30
-			add_filter( 'wc_stripe_display_save_payment_method_checkbox', array( $this, 'maybe_hide_save_checkbox' ) );
31
-			add_filter( 'wc_stripe_payment_metadata', array( $this, 'add_subscription_meta_data' ), 10, 2 );
28
+			add_filter('woocommerce_subscription_payment_meta', array($this, 'add_subscription_payment_meta'), 10, 2);
29
+			add_filter('woocommerce_subscription_validate_payment_meta', array($this, 'validate_subscription_payment_meta'), 10, 2);
30
+			add_filter('wc_stripe_display_save_payment_method_checkbox', array($this, 'maybe_hide_save_checkbox'));
31
+			add_filter('wc_stripe_payment_metadata', array($this, 'add_subscription_meta_data'), 10, 2);
32 32
 		}
33 33
 
34
-		if ( class_exists( 'WC_Pre_Orders_Order' ) ) {
35
-			add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_release_payment' ) );
34
+		if (class_exists('WC_Pre_Orders_Order')) {
35
+			add_action('wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array($this, 'process_pre_order_release_payment'));
36 36
 		}
37 37
 	}
38 38
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * @since 4.0.0
44 44
 	 * @version 4.0.0
45 45
 	 */
46
-	public function maybe_hide_save_checkbox( $display_tokenization ) {
47
-		if ( WC_Subscriptions_Cart::cart_contains_subscription() ) {
46
+	public function maybe_hide_save_checkbox($display_tokenization) {
47
+		if (WC_Subscriptions_Cart::cart_contains_subscription()) {
48 48
 			return false;
49 49
 		}
50 50
 
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param  int  $order_id
57 57
 	 * @return boolean
58 58
 	 */
59
-	public function has_subscription( $order_id ) {
60
-		return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) );
59
+	public function has_subscription($order_id) {
60
+		return (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order_id) || wcs_is_subscription($order_id) || wcs_order_contains_renewal($order_id)));
61 61
 	}
62 62
 
63 63
 	/**
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 	 * @param  int  $order_id
66 66
 	 * @return boolean
67 67
 	 */
68
-	protected function is_pre_order( $order_id ) {
69
-		return ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Order::order_contains_pre_order( $order_id ) );
68
+	protected function is_pre_order($order_id) {
69
+		return (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Order::order_contains_pre_order($order_id));
70 70
 	}
71 71
 
72 72
 	/**
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	 * @param  int $order_id
75 75
 	 * @return array
76 76
 	 */
77
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
78
-		if ( $this->has_subscription( $order_id ) ) {
77
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
78
+		if ($this->has_subscription($order_id)) {
79 79
 			// Regular payment with force customer enabled
80
-			return parent::process_payment( $order_id, true, true );
81
-		} elseif ( $this->is_pre_order( $order_id ) ) {
82
-			return $this->process_pre_order( $order_id, $retry, $force_save_source );
80
+			return parent::process_payment($order_id, true, true);
81
+		} elseif ($this->is_pre_order($order_id)) {
82
+			return $this->process_pre_order($order_id, $retry, $force_save_source);
83 83
 		} else {
84
-			return parent::process_payment( $order_id, $retry, $force_save_source );
84
+			return parent::process_payment($order_id, $retry, $force_save_source);
85 85
 		}
86 86
 	}
87 87
 
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
 	 * @param array $metadata
93 93
 	 * @param object $order
94 94
 	 */
95
-	public function add_subscription_meta_data( $metadata, $order ) {
96
-		if ( ! $this->has_subscription( $order->get_id() ) ) {
95
+	public function add_subscription_meta_data($metadata, $order) {
96
+		if ( ! $this->has_subscription($order->get_id())) {
97 97
 			return $metadata;
98 98
 		}
99 99
 
100 100
 		return $metadata += array(
101 101
 			'payment_type'   => 'recurring',
102
-			'site_url'       => esc_url( get_site_url() ),
102
+			'site_url'       => esc_url(get_site_url()),
103 103
 		);
104 104
 	}
105 105
 
@@ -109,24 +109,24 @@  discard block
 block discarded – undo
109 109
 	 * @since 3.1.0
110 110
 	 * @version 4.0.0
111 111
 	 */
112
-	public function save_source( $order, $source ) {
113
-		parent::save_source( $order, $source );
112
+	public function save_source($order, $source) {
113
+		parent::save_source($order, $source);
114 114
 
115
-		$order_id  = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
115
+		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
116 116
 
117 117
 		// Also store it on the subscriptions being purchased or paid for in the order
118
-		if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
119
-			$subscriptions = wcs_get_subscriptions_for_order( $order_id );
120
-		} elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) {
121
-			$subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
118
+		if (function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($order_id)) {
119
+			$subscriptions = wcs_get_subscriptions_for_order($order_id);
120
+		} elseif (function_exists('wcs_order_contains_renewal') && wcs_order_contains_renewal($order_id)) {
121
+			$subscriptions = wcs_get_subscriptions_for_renewal_order($order_id);
122 122
 		} else {
123 123
 			$subscriptions = array();
124 124
 		}
125 125
 
126
-		foreach ( $subscriptions as $subscription ) {
126
+		foreach ($subscriptions as $subscription) {
127 127
 			$subscription_id = WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id();
128
-			update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer );
129
-			update_post_meta( $subscription_id, '_stripe_source_id', $source->source );
128
+			update_post_meta($subscription_id, '_stripe_customer_id', $source->customer);
129
+			update_post_meta($subscription_id, '_stripe_source_id', $source->source);
130 130
 		}
131 131
 	}
132 132
 
@@ -137,37 +137,37 @@  discard block
 block discarded – undo
137 137
 	 * @param string $stripe_token (default: '')
138 138
 	 * @param  bool initial_payment
139 139
 	 */
140
-	public function process_subscription_payment( $order = '', $amount = 0 ) {
141
-		if ( $amount * 100 < WC_Stripe_Helper::get_minimum_amount() ) {
140
+	public function process_subscription_payment($order = '', $amount = 0) {
141
+		if ($amount * 100 < WC_Stripe_Helper::get_minimum_amount()) {
142 142
 			/* translators: minimum amount */
143
-			return new WP_Error( 'stripe_error', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe_Helper::get_minimum_amount() / 100 ) ) );
143
+			return new WP_Error('stripe_error', sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe_Helper::get_minimum_amount() / 100)));
144 144
 		}
145 145
 
146 146
 		$customer_id = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id();
147 147
 		$order_id    = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
148 148
 
149 149
 		// Get source from order
150
-		$prepared_source = $this->prepare_order_source( $order );
150
+		$prepared_source = $this->prepare_order_source($order);
151 151
 
152 152
 		// Or fail :(
153
-		if ( ! $prepared_source->customer ) {
154
-			return new WP_Error( 'stripe_error', __( 'Customer not found', 'woocommerce-gateway-stripe' ) );
153
+		if ( ! $prepared_source->customer) {
154
+			return new WP_Error('stripe_error', __('Customer not found', 'woocommerce-gateway-stripe'));
155 155
 		}
156 156
 
157
-		WC_Stripe_Logger::log( "Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}" );
157
+		WC_Stripe_Logger::log("Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}");
158 158
 
159 159
 		// Make the request
160
-		$request             = $this->generate_payment_request( $order, $prepared_source );
160
+		$request             = $this->generate_payment_request($order, $prepared_source);
161 161
 		$request['capture']  = 'true';
162
-		$request['amount']   = WC_Stripe_Helper::get_stripe_amount( $amount, $request['currency'] );
163
-		$response            = WC_Stripe_API::request( $request );
162
+		$request['amount']   = WC_Stripe_Helper::get_stripe_amount($amount, $request['currency']);
163
+		$response            = WC_Stripe_API::request($request);
164 164
 
165 165
 		// Process valid response
166
-		if ( ! empty( $response->error ) ) {
166
+		if ( ! empty($response->error)) {
167 167
 			return $response; // Default catch all errors.
168 168
 		}
169 169
 
170
-		$this->process_response( $response, $order );
170
+		$this->process_response($response, $order);
171 171
 
172 172
 		return $response;
173 173
 	}
@@ -176,21 +176,21 @@  discard block
 block discarded – undo
176 176
 	 * Don't transfer Stripe customer/token meta to resubscribe orders.
177 177
 	 * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
178 178
 	 */
179
-	public function delete_resubscribe_meta( $resubscribe_order ) {
180
-		delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_customer_id' );
181
-		delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_source_id' );
179
+	public function delete_resubscribe_meta($resubscribe_order) {
180
+		delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_customer_id');
181
+		delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_source_id');
182 182
 		// For BW compat will remove in future
183
-		delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_card_id' );
184
-		$this->delete_renewal_meta( $resubscribe_order );
183
+		delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_card_id');
184
+		$this->delete_renewal_meta($resubscribe_order);
185 185
 	}
186 186
 
187 187
 	/**
188 188
 	 * Don't transfer Stripe fee/ID meta to renewal orders.
189 189
 	 * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
190 190
 	 */
191
-	public function delete_renewal_meta( $renewal_order ) {
192
-		delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id() ), 'Stripe Fee' );
193
-		delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id() ), 'Net Revenue From Stripe' );
191
+	public function delete_renewal_meta($renewal_order) {
192
+		delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id()), 'Stripe Fee');
193
+		delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id()), 'Net Revenue From Stripe');
194 194
 		return $renewal_order;
195 195
 	}
196 196
 
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 	 * @param $amount_to_charge float The amount to charge.
201 201
 	 * @param $renewal_order WC_Order A WC_Order object created to record the renewal payment.
202 202
 	 */
203
-	public function scheduled_subscription_payment( $amount_to_charge, $renewal_order ) {
204
-		$response = $this->process_subscription_payment( $renewal_order, $amount_to_charge );
203
+	public function scheduled_subscription_payment($amount_to_charge, $renewal_order) {
204
+		$response = $this->process_subscription_payment($renewal_order, $amount_to_charge);
205 205
 
206
-		if ( is_wp_error( $response ) ) {
206
+		if (is_wp_error($response)) {
207 207
 			/* translators: error message */
208
-			$renewal_order->update_status( 'failed', sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) );
208
+			$renewal_order->update_status('failed', sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $response->get_error_message()));
209 209
 		}
210 210
 
211
-		if ( ! empty( $response->error ) ) {
211
+		if ( ! empty($response->error)) {
212 212
 			/* translators: error message */
213
-			$renewal_order->update_status( 'failed', sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $response->error->message ) );
213
+			$renewal_order->update_status('failed', sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $response->error->message));
214 214
 		}
215 215
 	}
216 216
 
@@ -218,20 +218,20 @@  discard block
 block discarded – undo
218 218
 	 * Remove order meta
219 219
 	 * @param  object $order
220 220
 	 */
221
-	public function remove_order_source_before_retry( $order ) {
221
+	public function remove_order_source_before_retry($order) {
222 222
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
223
-		delete_post_meta( $order_id, '_stripe_source_id' );
223
+		delete_post_meta($order_id, '_stripe_source_id');
224 224
 		// For BW compat will remove in the future.
225
-		delete_post_meta( $order_id, '_stripe_card_id' );
225
+		delete_post_meta($order_id, '_stripe_card_id');
226 226
 	}
227 227
 
228 228
 	/**
229 229
 	 * Remove order meta
230 230
 	 * @param  object $order
231 231
 	 */
232
-	public function remove_order_customer_before_retry( $order ) {
232
+	public function remove_order_customer_before_retry($order) {
233 233
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
234
-		delete_post_meta( $order_id, '_stripe_customer_id' );
234
+		delete_post_meta($order_id, '_stripe_customer_id');
235 235
 	}
236 236
 
237 237
 	/**
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
 	 * @param WC_Order $renewal_order The order which recorded the successful payment (to make up for the failed automatic payment).
244 244
 	 * @return void
245 245
 	 */
246
-	public function update_failing_payment_method( $subscription, $renewal_order ) {
247
-		if ( WC_Stripe_Helper::is_pre_30() ) {
248
-			update_post_meta( $subscription->id, '_stripe_customer_id', $renewal_order->stripe_customer_id );
249
-			update_post_meta( $subscription->id, '_stripe_source_id', $renewal_order->stripe_source_id );
246
+	public function update_failing_payment_method($subscription, $renewal_order) {
247
+		if (WC_Stripe_Helper::is_pre_30()) {
248
+			update_post_meta($subscription->id, '_stripe_customer_id', $renewal_order->stripe_customer_id);
249
+			update_post_meta($subscription->id, '_stripe_source_id', $renewal_order->stripe_source_id);
250 250
 
251 251
 		} else {
252
-			update_post_meta( $subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta( '_stripe_customer_id', true ) );
253
-			update_post_meta( $subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta( '_stripe_source_id', true ) );
252
+			update_post_meta($subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta('_stripe_customer_id', true));
253
+			update_post_meta($subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta('_stripe_source_id', true));
254 254
 		}
255 255
 	}
256 256
 
@@ -263,21 +263,21 @@  discard block
 block discarded – undo
263 263
 	 * @param WC_Subscription $subscription An instance of a subscription object
264 264
 	 * @return array
265 265
 	 */
266
-	public function add_subscription_payment_meta( $payment_meta, $subscription ) {
267
-		$source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_source_id', true );
266
+	public function add_subscription_payment_meta($payment_meta, $subscription) {
267
+		$source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_source_id', true);
268 268
 
269 269
 		// For BW compat will remove in future.
270
-		if ( empty( $source_id ) ) {
271
-			$source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true );
270
+		if (empty($source_id)) {
271
+			$source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_card_id', true);
272 272
 
273 273
 			// Take this opportunity to update the key name.
274
-			WC_Stripe_Helper::is_pre_30() ? update_post_meta( $subscription->id, '_stripe_source_id', $source_id ) : update_post_meta( $subscription->get_id(), '_stripe_source_id', $source_id );
274
+			WC_Stripe_Helper::is_pre_30() ? update_post_meta($subscription->id, '_stripe_source_id', $source_id) : update_post_meta($subscription->get_id(), '_stripe_source_id', $source_id);
275 275
 		}
276 276
 
277
-		$payment_meta[ $this->id ] = array(
277
+		$payment_meta[$this->id] = array(
278 278
 			'post_meta' => array(
279 279
 				'_stripe_customer_id' => array(
280
-					'value' => get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true ),
280
+					'value' => get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_customer_id', true),
281 281
 					'label' => 'Stripe Customer ID',
282 282
 				),
283 283
 				'_stripe_source_id' => array(
@@ -298,17 +298,17 @@  discard block
 block discarded – undo
298 298
 	 * @param array $payment_meta associative array of meta data required for automatic payments
299 299
 	 * @return array
300 300
 	 */
301
-	public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) {
302
-		if ( $this->id === $payment_method_id ) {
301
+	public function validate_subscription_payment_meta($payment_method_id, $payment_meta) {
302
+		if ($this->id === $payment_method_id) {
303 303
 
304
-			if ( ! isset( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) ) {
305
-				throw new Exception( 'A "_stripe_customer_id" value is required.' );
306
-			} elseif ( 0 !== strpos( $payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_' ) ) {
307
-				throw new Exception( 'Invalid customer ID. A valid "_stripe_customer_id" must begin with "cus_".' );
304
+			if ( ! isset($payment_meta['post_meta']['_stripe_customer_id']['value']) || empty($payment_meta['post_meta']['_stripe_customer_id']['value'])) {
305
+				throw new Exception('A "_stripe_customer_id" value is required.');
306
+			} elseif (0 !== strpos($payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_')) {
307
+				throw new Exception('Invalid customer ID. A valid "_stripe_customer_id" must begin with "cus_".');
308 308
 			}
309 309
 
310
-			if ( ! isset( $payment_meta['post_meta']['_stripe_source_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) ) {
311
-				throw new Exception( 'A "_stripe_source_id" value is required.' );
310
+			if ( ! isset($payment_meta['post_meta']['_stripe_source_id']['value']) || empty($payment_meta['post_meta']['_stripe_source_id']['value'])) {
311
+				throw new Exception('A "_stripe_source_id" value is required.');
312 312
 			}
313 313
 		}
314 314
 	}
@@ -321,89 +321,89 @@  discard block
 block discarded – undo
321 321
 	 * @param WC_Subscription $subscription the subscription details
322 322
 	 * @return string the subscription payment method
323 323
 	 */
324
-	public function maybe_render_subscription_payment_method( $payment_method_to_display, $subscription ) {
324
+	public function maybe_render_subscription_payment_method($payment_method_to_display, $subscription) {
325 325
 		$customer_user = WC_Stripe_Helper::is_pre_30() ? $subscription->customer_user : $subscription->get_customer_id();
326 326
 
327 327
 		// bail for other payment methods
328
-		if ( ( WC_Stripe_Helper::is_pre_30() ? $subscription->payment_method : $subscription->get_payment_method() ) !== $this->id || ! $customer_user ) {
328
+		if ((WC_Stripe_Helper::is_pre_30() ? $subscription->payment_method : $subscription->get_payment_method()) !== $this->id || ! $customer_user) {
329 329
 			return $payment_method_to_display;
330 330
 		}
331 331
 
332
-		$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_source_id', true );
332
+		$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_source_id', true);
333 333
 
334 334
 		// For BW compat will remove in future.
335
-		if ( empty( $stripe_source_id ) ) {
336
-			$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true );
335
+		if (empty($stripe_source_id)) {
336
+			$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_card_id', true);
337 337
 
338 338
 			// Take this opportunity to update the key name.
339
-			WC_Stripe_Helper::is_pre_30() ? update_post_meta( $subscription->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_id(), '_stripe_source_id', $stripe_source_id );
339
+			WC_Stripe_Helper::is_pre_30() ? update_post_meta($subscription->id, '_stripe_source_id', $stripe_source_id) : update_post_meta($subscription->get_id(), '_stripe_source_id', $stripe_source_id);
340 340
 		}
341 341
 
342 342
 		$stripe_customer    = new WC_Stripe_Customer();
343
-		$stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true );
343
+		$stripe_customer_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_customer_id', true);
344 344
 
345 345
 		// If we couldn't find a Stripe customer linked to the subscription, fallback to the user meta data.
346
-		if ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) {
346
+		if ( ! $stripe_customer_id || ! is_string($stripe_customer_id)) {
347 347
 			$user_id            = $customer_user;
348
-			$stripe_customer_id = get_user_meta( $user_id, '_stripe_customer_id', true );
349
-			$stripe_source_id   = get_user_meta( $user_id, '_stripe_source_id', true );
348
+			$stripe_customer_id = get_user_meta($user_id, '_stripe_customer_id', true);
349
+			$stripe_source_id   = get_user_meta($user_id, '_stripe_source_id', true);
350 350
 
351 351
 			// For BW compat will remove in future.
352
-			if ( empty( $stripe_source_id ) ) {
353
-				$stripe_source_id = get_user_meta( $user_id, '_stripe_card_id', true );
352
+			if (empty($stripe_source_id)) {
353
+				$stripe_source_id = get_user_meta($user_id, '_stripe_card_id', true);
354 354
 
355 355
 				// Take this opportunity to update the key name.
356
-				update_user_meta( $user_id, '_stripe_source_id', $stripe_source_id );
356
+				update_user_meta($user_id, '_stripe_source_id', $stripe_source_id);
357 357
 			}
358 358
 		}
359 359
 
360 360
 		// If we couldn't find a Stripe customer linked to the account, fallback to the order meta data.
361
-		if ( ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) && false !== $subscription->order ) {
362
-			$stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_customer_id', true );
363
-			$stripe_source_id   = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_source_id', true );
361
+		if (( ! $stripe_customer_id || ! is_string($stripe_customer_id)) && false !== $subscription->order) {
362
+			$stripe_customer_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_customer_id', true);
363
+			$stripe_source_id   = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_source_id', true);
364 364
 
365 365
 			// For BW compat will remove in future.
366
-			if ( empty( $stripe_source_id ) ) {
367
-				$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_card_id', true );
366
+			if (empty($stripe_source_id)) {
367
+				$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_card_id', true);
368 368
 
369 369
 				// Take this opportunity to update the key name.
370
-				WC_Stripe_Helper::is_pre_30() ? update_post_meta( $subscription->order->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id );
370
+				WC_Stripe_Helper::is_pre_30() ? update_post_meta($subscription->order->id, '_stripe_source_id', $stripe_source_id) : update_post_meta($subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id);
371 371
 			}
372 372
 		}
373 373
 
374
-		$stripe_customer->set_id( $stripe_customer_id );
374
+		$stripe_customer->set_id($stripe_customer_id);
375 375
 		$sources = $stripe_customer->get_sources();
376 376
 
377
-		if ( $sources ) {
377
+		if ($sources) {
378 378
 			$found_source = false;
379
-			foreach ( $sources as $source ) {
380
-				if ( isset( $source->type ) && 'card' === $source->type ) {
379
+			foreach ($sources as $source) {
380
+				if (isset($source->type) && 'card' === $source->type) {
381 381
 					$card = $source->card;
382 382
 				}
383 383
 
384
-				if ( $source->id === $stripe_source_id ) {
384
+				if ($source->id === $stripe_source_id) {
385 385
 					$found_source = true;
386 386
 
387
-					if ( $card ) {
387
+					if ($card) {
388 388
 						/* translators: 1) card brand 2) last 4 digits */
389
-						$payment_method_to_display = sprintf( __( 'Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe' ), ( isset( $card->brand ) ? $card->brand : __( 'N/A', 'woocommerce-gateway-stripe' ) ), $card->last4 );
389
+						$payment_method_to_display = sprintf(__('Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe'), (isset($card->brand) ? $card->brand : __('N/A', 'woocommerce-gateway-stripe')), $card->last4);
390 390
 					} else {
391
-						$payment_method_to_display = __( 'N/A', 'woocommerce-gateway-stripe' );
391
+						$payment_method_to_display = __('N/A', 'woocommerce-gateway-stripe');
392 392
 					}
393 393
 					break;
394 394
 				}
395 395
 			}
396 396
 
397
-			if ( ! $found_source ) {
398
-				if ( 'card' === $sources[0]->type ) {
397
+			if ( ! $found_source) {
398
+				if ('card' === $sources[0]->type) {
399 399
 					$card = $sources[0]->card;
400 400
 				}
401 401
 
402
-				if ( $card ) {
402
+				if ($card) {
403 403
 					/* translators: 1) card brand 2) last 4 digits */
404
-					$payment_method_to_display = sprintf( __( 'Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe' ), ( isset( $card->brand ) ? $card->brand : __( 'N/A', 'woocommerce-gateway-stripe' ) ), $card->last4 );
404
+					$payment_method_to_display = sprintf(__('Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe'), (isset($card->brand) ? $card->brand : __('N/A', 'woocommerce-gateway-stripe')), $card->last4);
405 405
 				} else {
406
-					$payment_method_to_display = __( 'N/A', 'woocommerce-gateway-stripe' );
406
+					$payment_method_to_display = __('N/A', 'woocommerce-gateway-stripe');
407 407
 				}
408 408
 			}
409 409
 		}
@@ -416,43 +416,43 @@  discard block
 block discarded – undo
416 416
 	 * @param int $order_id
417 417
 	 * @return array
418 418
 	 */
419
-	public function process_pre_order( $order_id, $retry, $force_save_source ) {
420
-		if ( WC_Pre_Orders_Order::order_requires_payment_tokenization( $order_id ) ) {
419
+	public function process_pre_order($order_id, $retry, $force_save_source) {
420
+		if (WC_Pre_Orders_Order::order_requires_payment_tokenization($order_id)) {
421 421
 			try {
422
-				$order = wc_get_order( $order_id );
422
+				$order = wc_get_order($order_id);
423 423
 
424
-				if ( $order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount() ) {
424
+				if ($order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount()) {
425 425
 					/* translators: minimum amount */
426
-					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_Helper::get_minimum_amount() / 100 ) ) );
426
+					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_Helper::get_minimum_amount() / 100)));
427 427
 				}
428 428
 
429
-				$source = $this->prepare_source( get_current_user_id(), true );
429
+				$source = $this->prepare_source(get_current_user_id(), true);
430 430
 
431 431
 				// We need a source on file to continue.
432
-				if ( empty( $source->customer ) || empty( $source->source ) ) {
433
-					throw new Exception( __( 'Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe' ) );
432
+				if (empty($source->customer) || empty($source->source)) {
433
+					throw new Exception(__('Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe'));
434 434
 				}
435 435
 
436 436
 				// Store source to order meta
437
-				$this->save_source( $order, $source );
437
+				$this->save_source($order, $source);
438 438
 
439 439
 				// Remove cart
440 440
 				WC()->cart->empty_cart();
441 441
 
442 442
 				// Is pre ordered!
443
-				WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order );
443
+				WC_Pre_Orders_Order::mark_order_as_pre_ordered($order);
444 444
 
445 445
 				// Return thank you page redirect
446 446
 				return array(
447 447
 					'result'   => 'success',
448
-					'redirect' => $this->get_return_url( $order ),
448
+					'redirect' => $this->get_return_url($order),
449 449
 				);
450
-			} catch ( Exception $e ) {
451
-				wc_add_notice( $e->getMessage(), 'error' );
450
+			} catch (Exception $e) {
451
+				wc_add_notice($e->getMessage(), 'error');
452 452
 				return;
453 453
 			}
454 454
 		} else {
455
-			return parent::process_payment( $order_id, $retry, $force_save_source );
455
+			return parent::process_payment($order_id, $retry, $force_save_source);
456 456
 		}
457 457
 	}
458 458
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	 * @param WC_Order $order
462 462
 	 * @return void
463 463
 	 */
464
-	public function process_pre_order_release_payment( $order ) {
464
+	public function process_pre_order_release_payment($order) {
465 465
 		try {
466 466
 			// Define some callbacks if the first attempt fails.
467 467
 			$retry_callbacks = array(
@@ -469,33 +469,33 @@  discard block
 block discarded – undo
469 469
 				'remove_order_customer_before_retry',
470 470
 			);
471 471
 
472
-			while ( 1 ) {
473
-				$source   = $this->prepare_order_source( $order );
474
-				$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source ) );
472
+			while (1) {
473
+				$source   = $this->prepare_order_source($order);
474
+				$response = WC_Stripe_API::request($this->generate_payment_request($order, $source));
475 475
 
476
-				if ( ! empty( $response->error ) ) {
477
-					if ( 0 === sizeof( $retry_callbacks ) ) {
478
-						throw new Exception( $response->error->message );
476
+				if ( ! empty($response->error)) {
477
+					if (0 === sizeof($retry_callbacks)) {
478
+						throw new Exception($response->error->message);
479 479
 					} else {
480
-						$retry_callback = array_shift( $retry_callbacks );
481
-						call_user_func( array( $this, $retry_callback ), $order );
480
+						$retry_callback = array_shift($retry_callbacks);
481
+						call_user_func(array($this, $retry_callback), $order);
482 482
 					}
483 483
 				} else {
484 484
 					// Successful
485
-					$this->process_response( $response, $order );
485
+					$this->process_response($response, $order);
486 486
 					break;
487 487
 				}
488 488
 			}
489
-		} catch ( Exception $e ) {
489
+		} catch (Exception $e) {
490 490
 			/* translators: error message */
491
-			$order_note = sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $e->getMessage() );
491
+			$order_note = sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $e->getMessage());
492 492
 
493 493
 			// Mark order as failed if not already set,
494 494
 			// otherwise, make sure we add the order note so we can detect when someone fails to check out multiple times
495
-			if ( ! $order->has_status( 'failed' ) ) {
496
-				$order->update_status( 'failed', $order_note );
495
+			if ( ! $order->has_status('failed')) {
496
+				$order->update_status('failed', $order_note);
497 497
 			} else {
498
-				$order->add_order_note( $order_note );
498
+				$order->add_order_note($order_note);
499 499
 			}
500 500
 		}
501 501
 	}
Please login to merge, or discard this patch.
includes/compat/class-wc-stripe-compat.php 1 patch
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 	public function __construct() {
16 16
 		parent::__construct();
17 17
 
18
-		if ( class_exists( 'WC_Subscriptions_Order' ) ) {
19
-			add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 );
20
-			add_action( 'wcs_resubscribe_order_created', array( $this, 'delete_resubscribe_meta' ), 10 );
21
-			add_action( 'wcs_renewal_order_created', array( $this, 'delete_renewal_meta' ), 10 );
22
-			add_action( 'woocommerce_subscription_failing_payment_method_updated_stripe', array( $this, 'update_failing_payment_method' ), 10, 2 );
18
+		if (class_exists('WC_Subscriptions_Order')) {
19
+			add_action('woocommerce_scheduled_subscription_payment_' . $this->id, array($this, 'scheduled_subscription_payment'), 10, 2);
20
+			add_action('wcs_resubscribe_order_created', array($this, 'delete_resubscribe_meta'), 10);
21
+			add_action('wcs_renewal_order_created', array($this, 'delete_renewal_meta'), 10);
22
+			add_action('woocommerce_subscription_failing_payment_method_updated_stripe', array($this, 'update_failing_payment_method'), 10, 2);
23 23
 
24 24
 			// display the credit card used for a subscription in the "My Subscriptions" table
25
-			add_filter( 'woocommerce_my_subscriptions_payment_method', array( $this, 'maybe_render_subscription_payment_method' ), 10, 2 );
25
+			add_filter('woocommerce_my_subscriptions_payment_method', array($this, 'maybe_render_subscription_payment_method'), 10, 2);
26 26
 
27 27
 			// allow store managers to manually set Stripe as the payment method on a subscription
28
-			add_filter( 'woocommerce_subscription_payment_meta', array( $this, 'add_subscription_payment_meta' ), 10, 2 );
29
-			add_filter( 'woocommerce_subscription_validate_payment_meta', array( $this, 'validate_subscription_payment_meta' ), 10, 2 );
30
-			add_filter( 'wc_stripe_display_save_payment_method_checkbox', array( $this, 'maybe_hide_save_checkbox' ) );
31
-			add_filter( 'wc_stripe_payment_metadata', array( $this, 'add_subscription_meta_data' ), 10, 2 );
28
+			add_filter('woocommerce_subscription_payment_meta', array($this, 'add_subscription_payment_meta'), 10, 2);
29
+			add_filter('woocommerce_subscription_validate_payment_meta', array($this, 'validate_subscription_payment_meta'), 10, 2);
30
+			add_filter('wc_stripe_display_save_payment_method_checkbox', array($this, 'maybe_hide_save_checkbox'));
31
+			add_filter('wc_stripe_payment_metadata', array($this, 'add_subscription_meta_data'), 10, 2);
32 32
 		}
33 33
 
34
-		if ( class_exists( 'WC_Pre_Orders_Order' ) ) {
35
-			add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_release_payment' ) );
34
+		if (class_exists('WC_Pre_Orders_Order')) {
35
+			add_action('wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array($this, 'process_pre_order_release_payment'));
36 36
 		}
37 37
 	}
38 38
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * @since 4.0.0
44 44
 	 * @version 4.0.0
45 45
 	 */
46
-	public function maybe_hide_save_checkbox( $display_tokenization ) {
47
-		if ( WC_Subscriptions_Cart::cart_contains_subscription() ) {
46
+	public function maybe_hide_save_checkbox($display_tokenization) {
47
+		if (WC_Subscriptions_Cart::cart_contains_subscription()) {
48 48
 			return false;
49 49
 		}
50 50
 
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param  int  $order_id
57 57
 	 * @return boolean
58 58
 	 */
59
-	public function has_subscription( $order_id ) {
60
-		return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) );
59
+	public function has_subscription($order_id) {
60
+		return (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order_id) || wcs_is_subscription($order_id) || wcs_order_contains_renewal($order_id)));
61 61
 	}
62 62
 
63 63
 	/**
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 	 * @param  int  $order_id
66 66
 	 * @return boolean
67 67
 	 */
68
-	protected function is_pre_order( $order_id ) {
69
-		return ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Order::order_contains_pre_order( $order_id ) );
68
+	protected function is_pre_order($order_id) {
69
+		return (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Order::order_contains_pre_order($order_id));
70 70
 	}
71 71
 
72 72
 	/**
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	 * @param  int $order_id
75 75
 	 * @return array
76 76
 	 */
77
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
78
-		if ( $this->has_subscription( $order_id ) ) {
77
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
78
+		if ($this->has_subscription($order_id)) {
79 79
 			// Regular payment with force customer enabled
80
-			return parent::process_payment( $order_id, true, true );
81
-		} elseif ( $this->is_pre_order( $order_id ) ) {
82
-			return $this->process_pre_order( $order_id, $retry, $force_save_source );
80
+			return parent::process_payment($order_id, true, true);
81
+		} elseif ($this->is_pre_order($order_id)) {
82
+			return $this->process_pre_order($order_id, $retry, $force_save_source);
83 83
 		} else {
84
-			return parent::process_payment( $order_id, $retry, $force_save_source );
84
+			return parent::process_payment($order_id, $retry, $force_save_source);
85 85
 		}
86 86
 	}
87 87
 
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
 	 * @param array $metadata
93 93
 	 * @param object $order
94 94
 	 */
95
-	public function add_subscription_meta_data( $metadata, $order ) {
96
-		if ( ! $this->has_subscription( $order->get_id() ) ) {
95
+	public function add_subscription_meta_data($metadata, $order) {
96
+		if ( ! $this->has_subscription($order->get_id())) {
97 97
 			return $metadata;
98 98
 		}
99 99
 
100 100
 		return $metadata += array(
101 101
 			'payment_type'   => 'recurring',
102
-			'site_url'       => esc_url( get_site_url() ),
102
+			'site_url'       => esc_url(get_site_url()),
103 103
 		);
104 104
 	}
105 105
 
@@ -109,24 +109,24 @@  discard block
 block discarded – undo
109 109
 	 * @since 3.1.0
110 110
 	 * @version 4.0.0
111 111
 	 */
112
-	public function save_source( $order, $source ) {
113
-		parent::save_source( $order, $source );
112
+	public function save_source($order, $source) {
113
+		parent::save_source($order, $source);
114 114
 
115
-		$order_id  = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
115
+		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
116 116
 
117 117
 		// Also store it on the subscriptions being purchased or paid for in the order
118
-		if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
119
-			$subscriptions = wcs_get_subscriptions_for_order( $order_id );
120
-		} elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) {
121
-			$subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
118
+		if (function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($order_id)) {
119
+			$subscriptions = wcs_get_subscriptions_for_order($order_id);
120
+		} elseif (function_exists('wcs_order_contains_renewal') && wcs_order_contains_renewal($order_id)) {
121
+			$subscriptions = wcs_get_subscriptions_for_renewal_order($order_id);
122 122
 		} else {
123 123
 			$subscriptions = array();
124 124
 		}
125 125
 
126
-		foreach ( $subscriptions as $subscription ) {
126
+		foreach ($subscriptions as $subscription) {
127 127
 			$subscription_id = WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id();
128
-			update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer );
129
-			update_post_meta( $subscription_id, '_stripe_source_id', $source->source );
128
+			update_post_meta($subscription_id, '_stripe_customer_id', $source->customer);
129
+			update_post_meta($subscription_id, '_stripe_source_id', $source->source);
130 130
 		}
131 131
 	}
132 132
 
@@ -137,37 +137,37 @@  discard block
 block discarded – undo
137 137
 	 * @param string $stripe_token (default: '')
138 138
 	 * @param  bool initial_payment
139 139
 	 */
140
-	public function process_subscription_payment( $order = '', $amount = 0 ) {
141
-		if ( $amount * 100 < WC_Stripe_Helper::get_minimum_amount() ) {
140
+	public function process_subscription_payment($order = '', $amount = 0) {
141
+		if ($amount * 100 < WC_Stripe_Helper::get_minimum_amount()) {
142 142
 			/* translators: minimum amount */
143
-			return new WP_Error( 'stripe_error', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe_Helper::get_minimum_amount() / 100 ) ) );
143
+			return new WP_Error('stripe_error', sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe_Helper::get_minimum_amount() / 100)));
144 144
 		}
145 145
 
146 146
 		$customer_id = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id();
147 147
 		$order_id    = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
148 148
 
149 149
 		// Get source from order
150
-		$prepared_source = $this->prepare_order_source( $order );
150
+		$prepared_source = $this->prepare_order_source($order);
151 151
 
152 152
 		// Or fail :(
153
-		if ( ! $prepared_source->customer ) {
154
-			return new WP_Error( 'stripe_error', __( 'Customer not found', 'woocommerce-gateway-stripe' ) );
153
+		if ( ! $prepared_source->customer) {
154
+			return new WP_Error('stripe_error', __('Customer not found', 'woocommerce-gateway-stripe'));
155 155
 		}
156 156
 
157
-		WC_Stripe_Logger::log( "Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}" );
157
+		WC_Stripe_Logger::log("Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}");
158 158
 
159 159
 		// Make the request
160
-		$request             = $this->generate_payment_request( $order, $prepared_source );
160
+		$request             = $this->generate_payment_request($order, $prepared_source);
161 161
 		$request['capture']  = 'true';
162
-		$request['amount']   = WC_Stripe_Helper::get_stripe_amount( $amount, $request['currency'] );
163
-		$response            = WC_Stripe_API::request( $request );
162
+		$request['amount']   = WC_Stripe_Helper::get_stripe_amount($amount, $request['currency']);
163
+		$response            = WC_Stripe_API::request($request);
164 164
 
165 165
 		// Process valid response
166
-		if ( ! empty( $response->error ) ) {
166
+		if ( ! empty($response->error)) {
167 167
 			return $response; // Default catch all errors.
168 168
 		}
169 169
 
170
-		$this->process_response( $response, $order );
170
+		$this->process_response($response, $order);
171 171
 
172 172
 		return $response;
173 173
 	}
@@ -176,21 +176,21 @@  discard block
 block discarded – undo
176 176
 	 * Don't transfer Stripe customer/token meta to resubscribe orders.
177 177
 	 * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
178 178
 	 */
179
-	public function delete_resubscribe_meta( $resubscribe_order ) {
180
-		delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_customer_id' );
181
-		delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_source_id' );
179
+	public function delete_resubscribe_meta($resubscribe_order) {
180
+		delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_customer_id');
181
+		delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_source_id');
182 182
 		// For BW compat will remove in future
183
-		delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_card_id' );
184
-		$this->delete_renewal_meta( $resubscribe_order );
183
+		delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_card_id');
184
+		$this->delete_renewal_meta($resubscribe_order);
185 185
 	}
186 186
 
187 187
 	/**
188 188
 	 * Don't transfer Stripe fee/ID meta to renewal orders.
189 189
 	 * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
190 190
 	 */
191
-	public function delete_renewal_meta( $renewal_order ) {
192
-		delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id() ), 'Stripe Fee' );
193
-		delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id() ), 'Net Revenue From Stripe' );
191
+	public function delete_renewal_meta($renewal_order) {
192
+		delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id()), 'Stripe Fee');
193
+		delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id()), 'Net Revenue From Stripe');
194 194
 		return $renewal_order;
195 195
 	}
196 196
 
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 	 * @param $amount_to_charge float The amount to charge.
201 201
 	 * @param $renewal_order WC_Order A WC_Order object created to record the renewal payment.
202 202
 	 */
203
-	public function scheduled_subscription_payment( $amount_to_charge, $renewal_order ) {
204
-		$response = $this->process_subscription_payment( $renewal_order, $amount_to_charge );
203
+	public function scheduled_subscription_payment($amount_to_charge, $renewal_order) {
204
+		$response = $this->process_subscription_payment($renewal_order, $amount_to_charge);
205 205
 
206
-		if ( is_wp_error( $response ) ) {
206
+		if (is_wp_error($response)) {
207 207
 			/* translators: error message */
208
-			$renewal_order->update_status( 'failed', sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) );
208
+			$renewal_order->update_status('failed', sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $response->get_error_message()));
209 209
 		}
210 210
 
211
-		if ( ! empty( $response->error ) ) {
211
+		if ( ! empty($response->error)) {
212 212
 			/* translators: error message */
213
-			$renewal_order->update_status( 'failed', sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $response->error->message ) );
213
+			$renewal_order->update_status('failed', sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $response->error->message));
214 214
 		}
215 215
 	}
216 216
 
@@ -218,20 +218,20 @@  discard block
 block discarded – undo
218 218
 	 * Remove order meta
219 219
 	 * @param  object $order
220 220
 	 */
221
-	public function remove_order_source_before_retry( $order ) {
221
+	public function remove_order_source_before_retry($order) {
222 222
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
223
-		delete_post_meta( $order_id, '_stripe_source_id' );
223
+		delete_post_meta($order_id, '_stripe_source_id');
224 224
 		// For BW compat will remove in the future.
225
-		delete_post_meta( $order_id, '_stripe_card_id' );
225
+		delete_post_meta($order_id, '_stripe_card_id');
226 226
 	}
227 227
 
228 228
 	/**
229 229
 	 * Remove order meta
230 230
 	 * @param  object $order
231 231
 	 */
232
-	public function remove_order_customer_before_retry( $order ) {
232
+	public function remove_order_customer_before_retry($order) {
233 233
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
234
-		delete_post_meta( $order_id, '_stripe_customer_id' );
234
+		delete_post_meta($order_id, '_stripe_customer_id');
235 235
 	}
236 236
 
237 237
 	/**
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
 	 * @param WC_Order $renewal_order The order which recorded the successful payment (to make up for the failed automatic payment).
244 244
 	 * @return void
245 245
 	 */
246
-	public function update_failing_payment_method( $subscription, $renewal_order ) {
247
-		if ( WC_Stripe_Helper::is_pre_30() ) {
248
-			update_post_meta( $subscription->id, '_stripe_customer_id', $renewal_order->stripe_customer_id );
249
-			update_post_meta( $subscription->id, '_stripe_source_id', $renewal_order->stripe_source_id );
246
+	public function update_failing_payment_method($subscription, $renewal_order) {
247
+		if (WC_Stripe_Helper::is_pre_30()) {
248
+			update_post_meta($subscription->id, '_stripe_customer_id', $renewal_order->stripe_customer_id);
249
+			update_post_meta($subscription->id, '_stripe_source_id', $renewal_order->stripe_source_id);
250 250
 
251 251
 		} else {
252
-			update_post_meta( $subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta( '_stripe_customer_id', true ) );
253
-			update_post_meta( $subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta( '_stripe_source_id', true ) );
252
+			update_post_meta($subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta('_stripe_customer_id', true));
253
+			update_post_meta($subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta('_stripe_source_id', true));
254 254
 		}
255 255
 	}
256 256
 
@@ -263,21 +263,21 @@  discard block
 block discarded – undo
263 263
 	 * @param WC_Subscription $subscription An instance of a subscription object
264 264
 	 * @return array
265 265
 	 */
266
-	public function add_subscription_payment_meta( $payment_meta, $subscription ) {
267
-		$source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_source_id', true );
266
+	public function add_subscription_payment_meta($payment_meta, $subscription) {
267
+		$source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_source_id', true);
268 268
 
269 269
 		// For BW compat will remove in future.
270
-		if ( empty( $source_id ) ) {
271
-			$source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true );
270
+		if (empty($source_id)) {
271
+			$source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_card_id', true);
272 272
 
273 273
 			// Take this opportunity to update the key name.
274
-			WC_Stripe_Helper::is_pre_30() ? update_post_meta( $subscription->id, '_stripe_source_id', $source_id ) : update_post_meta( $subscription->get_id(), '_stripe_source_id', $source_id );
274
+			WC_Stripe_Helper::is_pre_30() ? update_post_meta($subscription->id, '_stripe_source_id', $source_id) : update_post_meta($subscription->get_id(), '_stripe_source_id', $source_id);
275 275
 		}
276 276
 
277
-		$payment_meta[ $this->id ] = array(
277
+		$payment_meta[$this->id] = array(
278 278
 			'post_meta' => array(
279 279
 				'_stripe_customer_id' => array(
280
-					'value' => get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true ),
280
+					'value' => get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_customer_id', true),
281 281
 					'label' => 'Stripe Customer ID',
282 282
 				),
283 283
 				'_stripe_source_id' => array(
@@ -298,17 +298,17 @@  discard block
 block discarded – undo
298 298
 	 * @param array $payment_meta associative array of meta data required for automatic payments
299 299
 	 * @return array
300 300
 	 */
301
-	public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) {
302
-		if ( $this->id === $payment_method_id ) {
301
+	public function validate_subscription_payment_meta($payment_method_id, $payment_meta) {
302
+		if ($this->id === $payment_method_id) {
303 303
 
304
-			if ( ! isset( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) ) {
305
-				throw new Exception( 'A "_stripe_customer_id" value is required.' );
306
-			} elseif ( 0 !== strpos( $payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_' ) ) {
307
-				throw new Exception( 'Invalid customer ID. A valid "_stripe_customer_id" must begin with "cus_".' );
304
+			if ( ! isset($payment_meta['post_meta']['_stripe_customer_id']['value']) || empty($payment_meta['post_meta']['_stripe_customer_id']['value'])) {
305
+				throw new Exception('A "_stripe_customer_id" value is required.');
306
+			} elseif (0 !== strpos($payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_')) {
307
+				throw new Exception('Invalid customer ID. A valid "_stripe_customer_id" must begin with "cus_".');
308 308
 			}
309 309
 
310
-			if ( ! isset( $payment_meta['post_meta']['_stripe_source_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) ) {
311
-				throw new Exception( 'A "_stripe_source_id" value is required.' );
310
+			if ( ! isset($payment_meta['post_meta']['_stripe_source_id']['value']) || empty($payment_meta['post_meta']['_stripe_source_id']['value'])) {
311
+				throw new Exception('A "_stripe_source_id" value is required.');
312 312
 			}
313 313
 		}
314 314
 	}
@@ -321,89 +321,89 @@  discard block
 block discarded – undo
321 321
 	 * @param WC_Subscription $subscription the subscription details
322 322
 	 * @return string the subscription payment method
323 323
 	 */
324
-	public function maybe_render_subscription_payment_method( $payment_method_to_display, $subscription ) {
324
+	public function maybe_render_subscription_payment_method($payment_method_to_display, $subscription) {
325 325
 		$customer_user = WC_Stripe_Helper::is_pre_30() ? $subscription->customer_user : $subscription->get_customer_id();
326 326
 
327 327
 		// bail for other payment methods
328
-		if ( ( WC_Stripe_Helper::is_pre_30() ? $subscription->payment_method : $subscription->get_payment_method() ) !== $this->id || ! $customer_user ) {
328
+		if ((WC_Stripe_Helper::is_pre_30() ? $subscription->payment_method : $subscription->get_payment_method()) !== $this->id || ! $customer_user) {
329 329
 			return $payment_method_to_display;
330 330
 		}
331 331
 
332
-		$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_source_id', true );
332
+		$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_source_id', true);
333 333
 
334 334
 		// For BW compat will remove in future.
335
-		if ( empty( $stripe_source_id ) ) {
336
-			$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true );
335
+		if (empty($stripe_source_id)) {
336
+			$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_card_id', true);
337 337
 
338 338
 			// Take this opportunity to update the key name.
339
-			WC_Stripe_Helper::is_pre_30() ? update_post_meta( $subscription->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_id(), '_stripe_source_id', $stripe_source_id );
339
+			WC_Stripe_Helper::is_pre_30() ? update_post_meta($subscription->id, '_stripe_source_id', $stripe_source_id) : update_post_meta($subscription->get_id(), '_stripe_source_id', $stripe_source_id);
340 340
 		}
341 341
 
342 342
 		$stripe_customer    = new WC_Stripe_Customer();
343
-		$stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true );
343
+		$stripe_customer_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_customer_id', true);
344 344
 
345 345
 		// If we couldn't find a Stripe customer linked to the subscription, fallback to the user meta data.
346
-		if ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) {
346
+		if ( ! $stripe_customer_id || ! is_string($stripe_customer_id)) {
347 347
 			$user_id            = $customer_user;
348
-			$stripe_customer_id = get_user_meta( $user_id, '_stripe_customer_id', true );
349
-			$stripe_source_id   = get_user_meta( $user_id, '_stripe_source_id', true );
348
+			$stripe_customer_id = get_user_meta($user_id, '_stripe_customer_id', true);
349
+			$stripe_source_id   = get_user_meta($user_id, '_stripe_source_id', true);
350 350
 
351 351
 			// For BW compat will remove in future.
352
-			if ( empty( $stripe_source_id ) ) {
353
-				$stripe_source_id = get_user_meta( $user_id, '_stripe_card_id', true );
352
+			if (empty($stripe_source_id)) {
353
+				$stripe_source_id = get_user_meta($user_id, '_stripe_card_id', true);
354 354
 
355 355
 				// Take this opportunity to update the key name.
356
-				update_user_meta( $user_id, '_stripe_source_id', $stripe_source_id );
356
+				update_user_meta($user_id, '_stripe_source_id', $stripe_source_id);
357 357
 			}
358 358
 		}
359 359
 
360 360
 		// If we couldn't find a Stripe customer linked to the account, fallback to the order meta data.
361
-		if ( ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) && false !== $subscription->order ) {
362
-			$stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_customer_id', true );
363
-			$stripe_source_id   = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_source_id', true );
361
+		if (( ! $stripe_customer_id || ! is_string($stripe_customer_id)) && false !== $subscription->order) {
362
+			$stripe_customer_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_customer_id', true);
363
+			$stripe_source_id   = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_source_id', true);
364 364
 
365 365
 			// For BW compat will remove in future.
366
-			if ( empty( $stripe_source_id ) ) {
367
-				$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_card_id', true );
366
+			if (empty($stripe_source_id)) {
367
+				$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_card_id', true);
368 368
 
369 369
 				// Take this opportunity to update the key name.
370
-				WC_Stripe_Helper::is_pre_30() ? update_post_meta( $subscription->order->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id );
370
+				WC_Stripe_Helper::is_pre_30() ? update_post_meta($subscription->order->id, '_stripe_source_id', $stripe_source_id) : update_post_meta($subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id);
371 371
 			}
372 372
 		}
373 373
 
374
-		$stripe_customer->set_id( $stripe_customer_id );
374
+		$stripe_customer->set_id($stripe_customer_id);
375 375
 		$sources = $stripe_customer->get_sources();
376 376
 
377
-		if ( $sources ) {
377
+		if ($sources) {
378 378
 			$found_source = false;
379
-			foreach ( $sources as $source ) {
380
-				if ( isset( $source->type ) && 'card' === $source->type ) {
379
+			foreach ($sources as $source) {
380
+				if (isset($source->type) && 'card' === $source->type) {
381 381
 					$card = $source->card;
382 382
 				}
383 383
 
384
-				if ( $source->id === $stripe_source_id ) {
384
+				if ($source->id === $stripe_source_id) {
385 385
 					$found_source = true;
386 386
 
387
-					if ( $card ) {
387
+					if ($card) {
388 388
 						/* translators: 1) card brand 2) last 4 digits */
389
-						$payment_method_to_display = sprintf( __( 'Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe' ), ( isset( $card->brand ) ? $card->brand : __( 'N/A', 'woocommerce-gateway-stripe' ) ), $card->last4 );
389
+						$payment_method_to_display = sprintf(__('Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe'), (isset($card->brand) ? $card->brand : __('N/A', 'woocommerce-gateway-stripe')), $card->last4);
390 390
 					} else {
391
-						$payment_method_to_display = __( 'N/A', 'woocommerce-gateway-stripe' );
391
+						$payment_method_to_display = __('N/A', 'woocommerce-gateway-stripe');
392 392
 					}
393 393
 					break;
394 394
 				}
395 395
 			}
396 396
 
397
-			if ( ! $found_source ) {
398
-				if ( 'card' === $sources[0]->type ) {
397
+			if ( ! $found_source) {
398
+				if ('card' === $sources[0]->type) {
399 399
 					$card = $sources[0]->card;
400 400
 				}
401 401
 
402
-				if ( $card ) {
402
+				if ($card) {
403 403
 					/* translators: 1) card brand 2) last 4 digits */
404
-					$payment_method_to_display = sprintf( __( 'Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe' ), ( isset( $card->brand ) ? $card->brand : __( 'N/A', 'woocommerce-gateway-stripe' ) ), $card->last4 );
404
+					$payment_method_to_display = sprintf(__('Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe'), (isset($card->brand) ? $card->brand : __('N/A', 'woocommerce-gateway-stripe')), $card->last4);
405 405
 				} else {
406
-					$payment_method_to_display = __( 'N/A', 'woocommerce-gateway-stripe' );
406
+					$payment_method_to_display = __('N/A', 'woocommerce-gateway-stripe');
407 407
 				}
408 408
 			}
409 409
 		}
@@ -416,43 +416,43 @@  discard block
 block discarded – undo
416 416
 	 * @param int $order_id
417 417
 	 * @return array
418 418
 	 */
419
-	public function process_pre_order( $order_id, $retry, $force_save_source ) {
420
-		if ( WC_Pre_Orders_Order::order_requires_payment_tokenization( $order_id ) ) {
419
+	public function process_pre_order($order_id, $retry, $force_save_source) {
420
+		if (WC_Pre_Orders_Order::order_requires_payment_tokenization($order_id)) {
421 421
 			try {
422
-				$order = wc_get_order( $order_id );
422
+				$order = wc_get_order($order_id);
423 423
 
424
-				if ( $order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount() ) {
424
+				if ($order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount()) {
425 425
 					/* translators: minimum amount */
426
-					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_Helper::get_minimum_amount() / 100 ) ) );
426
+					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_Helper::get_minimum_amount() / 100)));
427 427
 				}
428 428
 
429
-				$source = $this->prepare_source( get_current_user_id(), true );
429
+				$source = $this->prepare_source(get_current_user_id(), true);
430 430
 
431 431
 				// We need a source on file to continue.
432
-				if ( empty( $source->customer ) || empty( $source->source ) ) {
433
-					throw new Exception( __( 'Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe' ) );
432
+				if (empty($source->customer) || empty($source->source)) {
433
+					throw new Exception(__('Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe'));
434 434
 				}
435 435
 
436 436
 				// Store source to order meta
437
-				$this->save_source( $order, $source );
437
+				$this->save_source($order, $source);
438 438
 
439 439
 				// Remove cart
440 440
 				WC()->cart->empty_cart();
441 441
 
442 442
 				// Is pre ordered!
443
-				WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order );
443
+				WC_Pre_Orders_Order::mark_order_as_pre_ordered($order);
444 444
 
445 445
 				// Return thank you page redirect
446 446
 				return array(
447 447
 					'result'   => 'success',
448
-					'redirect' => $this->get_return_url( $order ),
448
+					'redirect' => $this->get_return_url($order),
449 449
 				);
450
-			} catch ( Exception $e ) {
451
-				wc_add_notice( $e->getMessage(), 'error' );
450
+			} catch (Exception $e) {
451
+				wc_add_notice($e->getMessage(), 'error');
452 452
 				return;
453 453
 			}
454 454
 		} else {
455
-			return parent::process_payment( $order_id, $retry, $force_save_source );
455
+			return parent::process_payment($order_id, $retry, $force_save_source);
456 456
 		}
457 457
 	}
458 458
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	 * @param WC_Order $order
462 462
 	 * @return void
463 463
 	 */
464
-	public function process_pre_order_release_payment( $order ) {
464
+	public function process_pre_order_release_payment($order) {
465 465
 		try {
466 466
 			// Define some callbacks if the first attempt fails.
467 467
 			$retry_callbacks = array(
@@ -469,33 +469,33 @@  discard block
 block discarded – undo
469 469
 				'remove_order_customer_before_retry',
470 470
 			);
471 471
 
472
-			while ( 1 ) {
473
-				$source   = $this->prepare_order_source( $order );
474
-				$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source ) );
472
+			while (1) {
473
+				$source   = $this->prepare_order_source($order);
474
+				$response = WC_Stripe_API::request($this->generate_payment_request($order, $source));
475 475
 
476
-				if ( ! empty( $response->error ) ) {
477
-					if ( 0 === sizeof( $retry_callbacks ) ) {
478
-						throw new Exception( $response->error->message );
476
+				if ( ! empty($response->error)) {
477
+					if (0 === sizeof($retry_callbacks)) {
478
+						throw new Exception($response->error->message);
479 479
 					} else {
480
-						$retry_callback = array_shift( $retry_callbacks );
481
-						call_user_func( array( $this, $retry_callback ), $order );
480
+						$retry_callback = array_shift($retry_callbacks);
481
+						call_user_func(array($this, $retry_callback), $order);
482 482
 					}
483 483
 				} else {
484 484
 					// Successful
485
-					$this->process_response( $response, $order );
485
+					$this->process_response($response, $order);
486 486
 					break;
487 487
 				}
488 488
 			}
489
-		} catch ( Exception $e ) {
489
+		} catch (Exception $e) {
490 490
 			/* translators: error message */
491
-			$order_note = sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $e->getMessage() );
491
+			$order_note = sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $e->getMessage());
492 492
 
493 493
 			// Mark order as failed if not already set,
494 494
 			// otherwise, make sure we add the order note so we can detect when someone fails to check out multiple times
495
-			if ( ! $order->has_status( 'failed' ) ) {
496
-				$order->update_status( 'failed', $order_note );
495
+			if ( ! $order->has_status('failed')) {
496
+				$order->update_status('failed', $order_note);
497 497
 			} else {
498
-				$order->add_order_note( $order_note );
498
+				$order->add_order_note($order_note);
499 499
 			}
500 500
 		}
501 501
 	}
Please login to merge, or discard this patch.