Completed
Push — master ( 7e2fd1...fa960d )
by
unknown
18s queued 12s
created
includes/admin/stripe-settings.php 1 patch
Spacing   +67 added lines, -67 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
 
@@ -7,182 +7,182 @@  discard block
 block discarded – undo
7 7
 	'wc_stripe_settings',
8 8
 	array(
9 9
 		'enabled'                       => array(
10
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
11
-			'label'       => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ),
10
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
11
+			'label'       => __('Enable Stripe', 'woocommerce-gateway-stripe'),
12 12
 			'type'        => 'checkbox',
13 13
 			'description' => '',
14 14
 			'default'     => 'no',
15 15
 		),
16 16
 		'title'                         => array(
17
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
17
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
18 18
 			'type'        => 'text',
19
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
20
-			'default'     => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ),
19
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
20
+			'default'     => __('Credit Card (Stripe)', 'woocommerce-gateway-stripe'),
21 21
 			'desc_tip'    => true,
22 22
 		),
23 23
 		'description'                   => array(
24
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
24
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
25 25
 			'type'        => 'text',
26
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
27
-			'default'     => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe' ),
26
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
27
+			'default'     => __('Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'),
28 28
 			'desc_tip'    => true,
29 29
 		),
30 30
 		'webhook'                       => array(
31
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
31
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
32 32
 			'type'        => 'title',
33 33
 			/* translators: webhook URL */
34 34
 			'description' => $this->display_admin_settings_webhook_description(),
35 35
 		),
36 36
 		'testmode'                      => array(
37
-			'title'       => __( 'Test mode', 'woocommerce-gateway-stripe' ),
38
-			'label'       => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ),
37
+			'title'       => __('Test mode', 'woocommerce-gateway-stripe'),
38
+			'label'       => __('Enable Test Mode', 'woocommerce-gateway-stripe'),
39 39
 			'type'        => 'checkbox',
40
-			'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ),
40
+			'description' => __('Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe'),
41 41
 			'default'     => 'yes',
42 42
 			'desc_tip'    => true,
43 43
 		),
44 44
 		'test_publishable_key'          => array(
45
-			'title'       => __( 'Test Publishable Key', 'woocommerce-gateway-stripe' ),
45
+			'title'       => __('Test Publishable Key', 'woocommerce-gateway-stripe'),
46 46
 			'type'        => 'text',
47
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_test_" will be saved.', 'woocommerce-gateway-stripe' ),
47
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_test_" will be saved.', 'woocommerce-gateway-stripe'),
48 48
 			'default'     => '',
49 49
 			'desc_tip'    => true,
50 50
 		),
51 51
 		'test_secret_key'               => array(
52
-			'title'       => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ),
52
+			'title'       => __('Test Secret Key', 'woocommerce-gateway-stripe'),
53 53
 			'type'        => 'password',
54
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_test_" or "rk_test_" will be saved.', 'woocommerce-gateway-stripe' ),
54
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_test_" or "rk_test_" will be saved.', 'woocommerce-gateway-stripe'),
55 55
 			'default'     => '',
56 56
 			'desc_tip'    => true,
57 57
 		),
58 58
 		'test_webhook_secret'           => array(
59
-			'title'       => __( 'Test Webhook Secret', 'woocommerce-gateway-stripe' ),
59
+			'title'       => __('Test Webhook Secret', 'woocommerce-gateway-stripe'),
60 60
 			'type'        => 'password',
61
-			'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ),
61
+			'description' => __('Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe'),
62 62
 			'default'     => '',
63 63
 			'desc_tip'    => true,
64 64
 		),
65 65
 		'publishable_key'               => array(
66
-			'title'       => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ),
66
+			'title'       => __('Live Publishable Key', 'woocommerce-gateway-stripe'),
67 67
 			'type'        => 'text',
68
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_live_" will be saved.', 'woocommerce-gateway-stripe' ),
68
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_live_" will be saved.', 'woocommerce-gateway-stripe'),
69 69
 			'default'     => '',
70 70
 			'desc_tip'    => true,
71 71
 		),
72 72
 		'secret_key'                    => array(
73
-			'title'       => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ),
73
+			'title'       => __('Live Secret Key', 'woocommerce-gateway-stripe'),
74 74
 			'type'        => 'password',
75
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_live_" or "rk_live_" will be saved.', 'woocommerce-gateway-stripe' ),
75
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_live_" or "rk_live_" will be saved.', 'woocommerce-gateway-stripe'),
76 76
 			'default'     => '',
77 77
 			'desc_tip'    => true,
78 78
 		),
79 79
 		'webhook_secret'               => array(
80
-			'title'       => __( 'Webhook Secret', 'woocommerce-gateway-stripe' ),
80
+			'title'       => __('Webhook Secret', 'woocommerce-gateway-stripe'),
81 81
 			'type'        => 'password',
82
-			'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ),
82
+			'description' => __('Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe'),
83 83
 			'default'     => '',
84 84
 			'desc_tip'    => true,
85 85
 		),
86 86
 		'inline_cc_form'                => array(
87
-			'title'       => __( 'Inline Credit Card Form', 'woocommerce-gateway-stripe' ),
87
+			'title'       => __('Inline Credit Card Form', 'woocommerce-gateway-stripe'),
88 88
 			'type'        => 'checkbox',
89
-			'description' => __( 'Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe' ),
89
+			'description' => __('Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe'),
90 90
 			'default'     => 'no',
91 91
 			'desc_tip'    => true,
92 92
 		),
93 93
 		'statement_descriptor'          => array(
94
-			'title'       => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ),
94
+			'title'       => __('Statement Descriptor', 'woocommerce-gateway-stripe'),
95 95
 			'type'        => 'text',
96
-			'description' => __( 'Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe' ),
96
+			'description' => __('Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe'),
97 97
 			'default'     => '',
98 98
 			'desc_tip'    => true,
99 99
 		),
100 100
 		'capture'                       => array(
101
-			'title'       => __( 'Capture', 'woocommerce-gateway-stripe' ),
102
-			'label'       => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ),
101
+			'title'       => __('Capture', 'woocommerce-gateway-stripe'),
102
+			'label'       => __('Capture charge immediately', 'woocommerce-gateway-stripe'),
103 103
 			'type'        => 'checkbox',
104
-			'description' => __( 'Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe' ),
104
+			'description' => __('Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe'),
105 105
 			'default'     => 'yes',
106 106
 			'desc_tip'    => true,
107 107
 		),
108 108
 		'payment_request'               => array(
109
-			'title'       => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ),
109
+			'title'       => __('Payment Request Buttons', 'woocommerce-gateway-stripe'),
110 110
 			/* translators: 1) br tag 2) opening anchor tag 3) closing anchor tag */
111
-			'label'       => sprintf( __( 'Enable Payment Request Buttons. (Apple Pay/Chrome Payment Request API) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe' ), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>' ),
111
+			'label'       => sprintf(__('Enable Payment Request Buttons. (Apple Pay/Chrome Payment Request API) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe'), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>'),
112 112
 			'type'        => 'checkbox',
113
-			'description' => __( 'If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe' ),
113
+			'description' => __('If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe'),
114 114
 			'default'     => 'yes',
115 115
 			'desc_tip'    => true,
116 116
 		),
117 117
 		'payment_request_button_type'   => array(
118
-			'title'       => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ),
119
-			'label'       => __( 'Button Type', 'woocommerce-gateway-stripe' ),
118
+			'title'       => __('Payment Request Button Type', 'woocommerce-gateway-stripe'),
119
+			'label'       => __('Button Type', 'woocommerce-gateway-stripe'),
120 120
 			'type'        => 'select',
121
-			'description' => __( 'Select the button type you would like to show.', 'woocommerce-gateway-stripe' ),
121
+			'description' => __('Select the button type you would like to show.', 'woocommerce-gateway-stripe'),
122 122
 			'default'     => 'buy',
123 123
 			'desc_tip'    => true,
124 124
 			'options'     => array(
125
-				'default' => __( 'Default', 'woocommerce-gateway-stripe' ),
126
-				'buy'     => __( 'Buy', 'woocommerce-gateway-stripe' ),
127
-				'donate'  => __( 'Donate', 'woocommerce-gateway-stripe' ),
128
-				'branded' => __( 'Branded', 'woocommerce-gateway-stripe' ),
129
-				'custom'  => __( 'Custom', 'woocommerce-gateway-stripe' ),
125
+				'default' => __('Default', 'woocommerce-gateway-stripe'),
126
+				'buy'     => __('Buy', 'woocommerce-gateway-stripe'),
127
+				'donate'  => __('Donate', 'woocommerce-gateway-stripe'),
128
+				'branded' => __('Branded', 'woocommerce-gateway-stripe'),
129
+				'custom'  => __('Custom', 'woocommerce-gateway-stripe'),
130 130
 			),
131 131
 		),
132 132
 		'payment_request_button_theme'  => array(
133
-			'title'       => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ),
134
-			'label'       => __( 'Button Theme', 'woocommerce-gateway-stripe' ),
133
+			'title'       => __('Payment Request Button Theme', 'woocommerce-gateway-stripe'),
134
+			'label'       => __('Button Theme', 'woocommerce-gateway-stripe'),
135 135
 			'type'        => 'select',
136
-			'description' => __( 'Select the button theme you would like to show.', 'woocommerce-gateway-stripe' ),
136
+			'description' => __('Select the button theme you would like to show.', 'woocommerce-gateway-stripe'),
137 137
 			'default'     => 'dark',
138 138
 			'desc_tip'    => true,
139 139
 			'options'     => array(
140
-				'dark'          => __( 'Dark', 'woocommerce-gateway-stripe' ),
141
-				'light'         => __( 'Light', 'woocommerce-gateway-stripe' ),
142
-				'light-outline' => __( 'Light-Outline', 'woocommerce-gateway-stripe' ),
140
+				'dark'          => __('Dark', 'woocommerce-gateway-stripe'),
141
+				'light'         => __('Light', 'woocommerce-gateway-stripe'),
142
+				'light-outline' => __('Light-Outline', 'woocommerce-gateway-stripe'),
143 143
 			),
144 144
 		),
145 145
 		'payment_request_button_height' => array(
146
-			'title'       => __( 'Payment Request Button Height', 'woocommerce-gateway-stripe' ),
147
-			'label'       => __( 'Button Height', 'woocommerce-gateway-stripe' ),
146
+			'title'       => __('Payment Request Button Height', 'woocommerce-gateway-stripe'),
147
+			'label'       => __('Button Height', 'woocommerce-gateway-stripe'),
148 148
 			'type'        => 'text',
149
-			'description' => __( 'Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe' ),
149
+			'description' => __('Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe'),
150 150
 			'default'     => '44',
151 151
 			'desc_tip'    => true,
152 152
 		),
153 153
 		'payment_request_button_label' => array(
154
-			'title'       => __( 'Payment Request Button Label', 'woocommerce-gateway-stripe' ),
155
-			'label'       => __( 'Button Label', 'woocommerce-gateway-stripe' ),
154
+			'title'       => __('Payment Request Button Label', 'woocommerce-gateway-stripe'),
155
+			'label'       => __('Button Label', 'woocommerce-gateway-stripe'),
156 156
 			'type'        => 'text',
157
-			'description' => __( 'Enter the custom text you would like the button to have.', 'woocommerce-gateway-stripe' ),
158
-			'default'     => __( 'Buy now', 'woocommerce-gateway-stripe' ),
157
+			'description' => __('Enter the custom text you would like the button to have.', 'woocommerce-gateway-stripe'),
158
+			'default'     => __('Buy now', 'woocommerce-gateway-stripe'),
159 159
 			'desc_tip'    => true,
160 160
 		),
161 161
 		'payment_request_button_branded_type' => array(
162
-			'title'       => __( 'Payment Request Branded Button Label Format', 'woocommerce-gateway-stripe' ),
163
-			'label'       => __( 'Branded Button Label Format', 'woocommerce-gateway-stripe' ),
162
+			'title'       => __('Payment Request Branded Button Label Format', 'woocommerce-gateway-stripe'),
163
+			'label'       => __('Branded Button Label Format', 'woocommerce-gateway-stripe'),
164 164
 			'type'        => 'select',
165
-			'description' => __( 'Select the branded button label format.', 'woocommerce-gateway-stripe' ),
165
+			'description' => __('Select the branded button label format.', 'woocommerce-gateway-stripe'),
166 166
 			'default'     => 'long',
167 167
 			'desc_tip'    => true,
168 168
 			'options'     => array(
169
-				'short' => __( 'Logo only', 'woocommerce-gateway-stripe' ),
170
-				'long'  => __( 'Text and logo', 'woocommerce-gateway-stripe' ),
169
+				'short' => __('Logo only', 'woocommerce-gateway-stripe'),
170
+				'long'  => __('Text and logo', 'woocommerce-gateway-stripe'),
171 171
 			),
172 172
 		),
173 173
 		'saved_cards'                   => array(
174
-			'title'       => __( 'Saved Cards', 'woocommerce-gateway-stripe' ),
175
-			'label'       => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ),
174
+			'title'       => __('Saved Cards', 'woocommerce-gateway-stripe'),
175
+			'label'       => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'),
176 176
 			'type'        => 'checkbox',
177
-			'description' => __( 'If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe' ),
177
+			'description' => __('If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe'),
178 178
 			'default'     => 'yes',
179 179
 			'desc_tip'    => true,
180 180
 		),
181 181
 		'logging'                       => array(
182
-			'title'       => __( 'Logging', 'woocommerce-gateway-stripe' ),
183
-			'label'       => __( 'Log debug messages', 'woocommerce-gateway-stripe' ),
182
+			'title'       => __('Logging', 'woocommerce-gateway-stripe'),
183
+			'label'       => __('Log debug messages', 'woocommerce-gateway-stripe'),
184 184
 			'type'        => 'checkbox',
185
-			'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ),
185
+			'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'),
186 186
 			'default'     => 'no',
187 187
 			'desc_tip'    => true,
188 188
 		),
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-stripe-payment-request.php 1 patch
Spacing   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   4.0.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
@@ -64,41 +64,41 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function __construct() {
66 66
 		self::$_this            = $this;
67
-		$this->stripe_settings  = get_option( 'woocommerce_stripe_settings', array() );
68
-		$this->testmode         = ( ! empty( $this->stripe_settings['testmode'] ) && 'yes' === $this->stripe_settings['testmode'] ) ? true : false;
69
-		$this->publishable_key  = ! empty( $this->stripe_settings['publishable_key'] ) ? $this->stripe_settings['publishable_key'] : '';
70
-		$this->secret_key       = ! empty( $this->stripe_settings['secret_key'] ) ? $this->stripe_settings['secret_key'] : '';
71
-		$this->total_label      = ! empty( $this->stripe_settings['statement_descriptor'] ) ? WC_Stripe_Helper::clean_statement_descriptor( $this->stripe_settings['statement_descriptor'] ) : '';
67
+		$this->stripe_settings  = get_option('woocommerce_stripe_settings', array());
68
+		$this->testmode         = ( ! empty($this->stripe_settings['testmode']) && 'yes' === $this->stripe_settings['testmode']) ? true : false;
69
+		$this->publishable_key  = ! empty($this->stripe_settings['publishable_key']) ? $this->stripe_settings['publishable_key'] : '';
70
+		$this->secret_key       = ! empty($this->stripe_settings['secret_key']) ? $this->stripe_settings['secret_key'] : '';
71
+		$this->total_label      = ! empty($this->stripe_settings['statement_descriptor']) ? WC_Stripe_Helper::clean_statement_descriptor($this->stripe_settings['statement_descriptor']) : '';
72 72
 
73
-		if ( $this->testmode ) {
74
-			$this->publishable_key = ! empty( $this->stripe_settings['test_publishable_key'] ) ? $this->stripe_settings['test_publishable_key'] : '';
75
-			$this->secret_key      = ! empty( $this->stripe_settings['test_secret_key'] ) ? $this->stripe_settings['test_secret_key'] : '';
73
+		if ($this->testmode) {
74
+			$this->publishable_key = ! empty($this->stripe_settings['test_publishable_key']) ? $this->stripe_settings['test_publishable_key'] : '';
75
+			$this->secret_key      = ! empty($this->stripe_settings['test_secret_key']) ? $this->stripe_settings['test_secret_key'] : '';
76 76
 		}
77 77
 
78
-		$this->total_label = str_replace( "'", '', $this->total_label ) . apply_filters( 'wc_stripe_payment_request_total_label_suffix', ' (via WooCommerce)' );
78
+		$this->total_label = str_replace("'", '', $this->total_label) . apply_filters('wc_stripe_payment_request_total_label_suffix', ' (via WooCommerce)');
79 79
 
80 80
 		// Checks if Stripe Gateway is enabled.
81
-		if ( empty( $this->stripe_settings ) || ( isset( $this->stripe_settings['enabled'] ) && 'yes' !== $this->stripe_settings['enabled'] ) ) {
81
+		if (empty($this->stripe_settings) || (isset($this->stripe_settings['enabled']) && 'yes' !== $this->stripe_settings['enabled'])) {
82 82
 			return;
83 83
 		}
84 84
 
85 85
 		// Checks if Payment Request is enabled.
86
-		if ( ! isset( $this->stripe_settings['payment_request'] ) || 'yes' !== $this->stripe_settings['payment_request'] ) {
86
+		if ( ! isset($this->stripe_settings['payment_request']) || 'yes' !== $this->stripe_settings['payment_request']) {
87 87
 			return;
88 88
 		}
89 89
 
90 90
 		// Don't load for change payment method page.
91
-		if ( isset( $_GET['change_payment_method'] ) ) {
91
+		if (isset($_GET['change_payment_method'])) {
92 92
 			return;
93 93
 		}
94 94
 
95
-		$wc_default_country = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
95
+		$wc_default_country = substr(get_option('woocommerce_default_country'), 0, 2);
96 96
 
97
-		if ( ! in_array( $wc_default_country, $this->get_stripe_supported_countries() ) ) {
97
+		if ( ! in_array($wc_default_country, $this->get_stripe_supported_countries())) {
98 98
 			return;
99 99
 		}
100 100
 
101
-		add_action( 'template_redirect', array( $this, 'set_session' ) );
101
+		add_action('template_redirect', array($this, 'set_session'));
102 102
 		$this->init();
103 103
 	}
104 104
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return array The list of countries.
110 110
 	 */
111 111
 	public function get_stripe_supported_countries() {
112
-		return apply_filters( 'wc_stripe_supported_countries', array( 'AT', 'AU', 'BE', 'BR', 'CA', 'CH', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'HK', 'IE', 'IN', 'IT', 'JP', 'LT', 'LU', 'LV', 'MX', 'NL', 'NZ', 'NO', 'PH', 'PL', 'PR', 'PT', 'RO', 'SE', 'SG', 'SK', 'US' ) );
112
+		return apply_filters('wc_stripe_supported_countries', array('AT', 'AU', 'BE', 'BR', 'CA', 'CH', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'HK', 'IE', 'IN', 'IT', 'JP', 'LT', 'LU', 'LV', 'MX', 'NL', 'NZ', 'NO', 'PH', 'PL', 'PR', 'PT', 'RO', 'SE', 'SG', 'SK', 'US'));
113 113
 	}
114 114
 
115 115
 	/**
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 	public function are_keys_set() {
122 122
 		// NOTE: updates to this function should be added to are_keys_set()
123 123
 		// in includes/abstracts/abstract-wc-stripe-payment-gateway.php
124
-		if ( $this->testmode ) {
125
-			return preg_match( '/^pk_test_/', $this->publishable_key )
126
-			       && preg_match( '/^[rs]k_test_/', $this->secret_key );
124
+		if ($this->testmode) {
125
+			return preg_match('/^pk_test_/', $this->publishable_key)
126
+			       && preg_match('/^[rs]k_test_/', $this->secret_key);
127 127
 		} else {
128
-			return preg_match( '/^pk_live_/', $this->publishable_key )
129
-			       && preg_match( '/^[rs]k_live_/', $this->secret_key );
128
+			return preg_match('/^pk_live_/', $this->publishable_key)
129
+			       && preg_match('/^[rs]k_live_/', $this->secret_key);
130 130
 		}
131 131
 	}
132 132
 
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 	 * @since 4.0.0
148 148
 	 */
149 149
 	public function set_session() {
150
-		if ( ! is_product() || ( isset( WC()->session ) && WC()->session->has_session() ) ) {
150
+		if ( ! is_product() || (isset(WC()->session) && WC()->session->has_session())) {
151 151
 			return;
152 152
 		}
153 153
 
154
-		WC()->session->set_customer_session_cookie( true );
154
+		WC()->session->set_customer_session_cookie(true);
155 155
 	}
156 156
 
157 157
 	/**
@@ -161,30 +161,30 @@  discard block
 block discarded – undo
161 161
 	 * @version 4.0.0
162 162
 	 */
163 163
 	public function init() {
164
-		add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ) );
164
+		add_action('wp_enqueue_scripts', array($this, 'scripts'));
165 165
 
166
-		add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_html' ), 1 );
167
-		add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_separator_html' ), 2 );
166
+		add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_html'), 1);
167
+		add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_separator_html'), 2);
168 168
 
169
-		add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_html' ), 1 );
170
-		add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_separator_html' ), 2 );
169
+		add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_html'), 1);
170
+		add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_separator_html'), 2);
171 171
 
172
-		add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_html' ), 1 );
173
-		add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_separator_html' ), 2 );
172
+		add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_html'), 1);
173
+		add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_separator_html'), 2);
174 174
 
175
-		add_action( 'wc_ajax_wc_stripe_get_cart_details', array( $this, 'ajax_get_cart_details' ) );
176
-		add_action( 'wc_ajax_wc_stripe_get_shipping_options', array( $this, 'ajax_get_shipping_options' ) );
177
-		add_action( 'wc_ajax_wc_stripe_update_shipping_method', array( $this, 'ajax_update_shipping_method' ) );
178
-		add_action( 'wc_ajax_wc_stripe_create_order', array( $this, 'ajax_create_order' ) );
179
-		add_action( 'wc_ajax_wc_stripe_add_to_cart', array( $this, 'ajax_add_to_cart' ) );
180
-		add_action( 'wc_ajax_wc_stripe_get_selected_product_data', array( $this, 'ajax_get_selected_product_data' ) );
181
-		add_action( 'wc_ajax_wc_stripe_clear_cart', array( $this, 'ajax_clear_cart' ) );
182
-		add_action( 'wc_ajax_wc_stripe_log_errors', array( $this, 'ajax_log_errors' ) );
175
+		add_action('wc_ajax_wc_stripe_get_cart_details', array($this, 'ajax_get_cart_details'));
176
+		add_action('wc_ajax_wc_stripe_get_shipping_options', array($this, 'ajax_get_shipping_options'));
177
+		add_action('wc_ajax_wc_stripe_update_shipping_method', array($this, 'ajax_update_shipping_method'));
178
+		add_action('wc_ajax_wc_stripe_create_order', array($this, 'ajax_create_order'));
179
+		add_action('wc_ajax_wc_stripe_add_to_cart', array($this, 'ajax_add_to_cart'));
180
+		add_action('wc_ajax_wc_stripe_get_selected_product_data', array($this, 'ajax_get_selected_product_data'));
181
+		add_action('wc_ajax_wc_stripe_clear_cart', array($this, 'ajax_clear_cart'));
182
+		add_action('wc_ajax_wc_stripe_log_errors', array($this, 'ajax_log_errors'));
183 183
 
184
-		add_filter( 'woocommerce_gateway_title', array( $this, 'filter_gateway_title' ), 10, 2 );
185
-		add_filter( 'woocommerce_validate_postcode', array( $this, 'postal_code_validation' ), 10, 3 );
184
+		add_filter('woocommerce_gateway_title', array($this, 'filter_gateway_title'), 10, 2);
185
+		add_filter('woocommerce_validate_postcode', array($this, 'postal_code_validation'), 10, 3);
186 186
 
187
-		add_action( 'woocommerce_checkout_order_processed', array( $this, 'add_order_meta' ), 10, 2 );
187
+		add_action('woocommerce_checkout_order_processed', array($this, 'add_order_meta'), 10, 2);
188 188
 	}
189 189
 
190 190
 	/**
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @return string
196 196
 	 */
197 197
 	public function get_button_type() {
198
-		return isset( $this->stripe_settings['payment_request_button_type'] ) ? $this->stripe_settings['payment_request_button_type'] : 'default';
198
+		return isset($this->stripe_settings['payment_request_button_type']) ? $this->stripe_settings['payment_request_button_type'] : 'default';
199 199
 	}
200 200
 
201 201
 	/**
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 * @return string
207 207
 	 */
208 208
 	public function get_button_theme() {
209
-		return isset( $this->stripe_settings['payment_request_button_theme'] ) ? $this->stripe_settings['payment_request_button_theme'] : 'dark';
209
+		return isset($this->stripe_settings['payment_request_button_theme']) ? $this->stripe_settings['payment_request_button_theme'] : 'dark';
210 210
 	}
211 211
 
212 212
 	/**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 * @return string
218 218
 	 */
219 219
 	public function get_button_height() {
220
-		return isset( $this->stripe_settings['payment_request_button_height'] ) ? str_replace( 'px', '', $this->stripe_settings['payment_request_button_height'] ) : '64';
220
+		return isset($this->stripe_settings['payment_request_button_height']) ? str_replace('px', '', $this->stripe_settings['payment_request_button_height']) : '64';
221 221
 	}
222 222
 
223 223
 	/**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * @return string
240 240
 	 */
241 241
 	public function get_button_branded_type() {
242
-		return isset( $this->stripe_settings['payment_request_button_branded_type'] ) ? $this->stripe_settings['payment_request_button_branded_type'] : 'default';
242
+		return isset($this->stripe_settings['payment_request_button_branded_type']) ? $this->stripe_settings['payment_request_button_branded_type'] : 'default';
243 243
 	}
244 244
 
245 245
 	/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @return string
273 273
 	 */
274 274
 	public function get_button_label() {
275
-		return isset( $this->stripe_settings['payment_request_button_label'] ) ? $this->stripe_settings['payment_request_button_label'] : 'Buy now';
275
+		return isset($this->stripe_settings['payment_request_button_label']) ? $this->stripe_settings['payment_request_button_label'] : 'Buy now';
276 276
 	}
277 277
 
278 278
 	/**
@@ -282,22 +282,22 @@  discard block
 block discarded – undo
282 282
 	 * @version 4.0.0
283 283
 	 */
284 284
 	public function get_product_data() {
285
-		if ( ! is_product() ) {
285
+		if ( ! is_product()) {
286 286
 			return false;
287 287
 		}
288 288
 
289 289
 		global $post;
290 290
 
291
-		$product = wc_get_product( $post->ID );
291
+		$product = wc_get_product($post->ID);
292 292
 
293
-		if ( 'variable' === $product->get_type() ) {
294
-			$attributes = wc_clean( wp_unslash( $_GET ) );
293
+		if ('variable' === $product->get_type()) {
294
+			$attributes = wc_clean(wp_unslash($_GET));
295 295
 
296
-			$data_store   = WC_Data_Store::load( 'product' );
297
-			$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
296
+			$data_store   = WC_Data_Store::load('product');
297
+			$variation_id = $data_store->find_matching_product_variation($product, $attributes);
298 298
 
299
-			if ( ! empty( $variation_id ) ) {
300
-				$product = wc_get_product( $variation_id );
299
+			if ( ! empty($variation_id)) {
300
+				$product = wc_get_product($variation_id);
301 301
 			}
302 302
 		}
303 303
 
@@ -306,27 +306,27 @@  discard block
 block discarded – undo
306 306
 
307 307
 		$items[] = array(
308 308
 			'label'  => $product->get_name(),
309
-			'amount' => WC_Stripe_Helper::get_stripe_amount( $product->get_price() ),
309
+			'amount' => WC_Stripe_Helper::get_stripe_amount($product->get_price()),
310 310
 		);
311 311
 
312
-		if ( wc_tax_enabled() ) {
312
+		if (wc_tax_enabled()) {
313 313
 			$items[] = array(
314
-				'label'   => __( 'Tax', 'woocommerce-gateway-stripe' ),
314
+				'label'   => __('Tax', 'woocommerce-gateway-stripe'),
315 315
 				'amount'  => 0,
316 316
 				'pending' => true,
317 317
 			);
318 318
 		}
319 319
 
320
-		if ( wc_shipping_enabled() && $product->needs_shipping() ) {
320
+		if (wc_shipping_enabled() && $product->needs_shipping()) {
321 321
 			$items[] = array(
322
-				'label'   => __( 'Shipping', 'woocommerce-gateway-stripe' ),
322
+				'label'   => __('Shipping', 'woocommerce-gateway-stripe'),
323 323
 				'amount'  => 0,
324 324
 				'pending' => true,
325 325
 			);
326 326
 
327 327
 			$data['shippingOptions'] = array(
328 328
 				'id'     => 'pending',
329
-				'label'  => __( 'Pending', 'woocommerce-gateway-stripe' ),
329
+				'label'  => __('Pending', 'woocommerce-gateway-stripe'),
330 330
 				'detail' => '',
331 331
 				'amount' => 0,
332 332
 			);
@@ -334,37 +334,37 @@  discard block
 block discarded – undo
334 334
 
335 335
 		$data['displayItems'] = $items;
336 336
 		$data['total']        = array(
337
-			'label'   => apply_filters( 'wc_stripe_payment_request_total_label', $this->total_label ),
338
-			'amount'  => WC_Stripe_Helper::get_stripe_amount( $product->get_price() ),
337
+			'label'   => apply_filters('wc_stripe_payment_request_total_label', $this->total_label),
338
+			'amount'  => WC_Stripe_Helper::get_stripe_amount($product->get_price()),
339 339
 			'pending' => true,
340 340
 		);
341 341
 
342
-		$data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() );
343
-		$data['currency']        = strtolower( get_woocommerce_currency() );
344
-		$data['country_code']    = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
342
+		$data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping());
343
+		$data['currency']        = strtolower(get_woocommerce_currency());
344
+		$data['country_code']    = substr(get_option('woocommerce_default_country'), 0, 2);
345 345
 
346
-		return apply_filters( 'wc_stripe_payment_request_product_data', $data, $product );
346
+		return apply_filters('wc_stripe_payment_request_product_data', $data, $product);
347 347
 	}
348 348
 
349 349
 	/**
350 350
 	 * Filters the gateway title to reflect Payment Request type
351 351
 	 *
352 352
 	 */
353
-	public function filter_gateway_title( $title, $id ) {
353
+	public function filter_gateway_title($title, $id) {
354 354
 		global $post;
355 355
 
356
-		if ( ! is_object( $post ) ) {
356
+		if ( ! is_object($post)) {
357 357
 			return $title;
358 358
 		}
359 359
 
360
-		$order        = wc_get_order( $post->ID );
361
-		$method_title = is_object( $order ) ? $order->get_payment_method_title() : '';
360
+		$order        = wc_get_order($post->ID);
361
+		$method_title = is_object($order) ? $order->get_payment_method_title() : '';
362 362
 
363
-		if ( 'stripe' === $id && ! empty( $method_title ) && 'Apple Pay (Stripe)' === $method_title ) {
363
+		if ('stripe' === $id && ! empty($method_title) && 'Apple Pay (Stripe)' === $method_title) {
364 364
 			return $method_title;
365 365
 		}
366 366
 
367
-		if ( 'stripe' === $id && ! empty( $method_title ) && 'Chrome Payment Request (Stripe)' === $method_title ) {
367
+		if ('stripe' === $id && ! empty($method_title) && 'Chrome Payment Request (Stripe)' === $method_title) {
368 368
 			return $method_title;
369 369
 		}
370 370
 
@@ -377,16 +377,16 @@  discard block
 block discarded – undo
377 377
 	 * @since 3.1.4
378 378
 	 * @version 4.0.0
379 379
 	 */
380
-	public function postal_code_validation( $valid, $postcode, $country ) {
380
+	public function postal_code_validation($valid, $postcode, $country) {
381 381
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
382 382
 
383
-		if ( ! isset( $gateways['stripe'] ) ) {
383
+		if ( ! isset($gateways['stripe'])) {
384 384
 			return $valid;
385 385
 		}
386 386
 
387
-		$payment_request_type = isset( $_POST['payment_request_type'] ) ? wc_clean( $_POST['payment_request_type'] ) : '';
387
+		$payment_request_type = isset($_POST['payment_request_type']) ? wc_clean($_POST['payment_request_type']) : '';
388 388
 
389
-		if ( 'apple_pay' !== $payment_request_type ) {
389
+		if ('apple_pay' !== $payment_request_type) {
390 390
 			return $valid;
391 391
 		}
392 392
 
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 		 * the order and not let it go through. The remedy for now is just to remove this validation.
397 397
 		 * Note that this only works with shipping providers that don't validate full postal codes.
398 398
 		 */
399
-		if ( 'GB' === $country || 'CA' === $country ) {
399
+		if ('GB' === $country || 'CA' === $country) {
400 400
 			return true;
401 401
 		}
402 402
 
@@ -411,22 +411,22 @@  discard block
 block discarded – undo
411 411
 	 * @param int $order_id
412 412
 	 * @param array $posted_data The posted data from checkout form.
413 413
 	 */
414
-	public function add_order_meta( $order_id, $posted_data ) {
415
-		if ( empty( $_POST['payment_request_type'] ) ) {
414
+	public function add_order_meta($order_id, $posted_data) {
415
+		if (empty($_POST['payment_request_type'])) {
416 416
 			return;
417 417
 		}
418 418
 
419
-		$order = wc_get_order( $order_id );
419
+		$order = wc_get_order($order_id);
420 420
 
421
-		$payment_request_type = wc_clean( $_POST['payment_request_type'] );
421
+		$payment_request_type = wc_clean($_POST['payment_request_type']);
422 422
 
423
-		if ( 'apple_pay' === $payment_request_type ) {
424
-			$order->set_payment_method_title( 'Apple Pay (Stripe)' );
423
+		if ('apple_pay' === $payment_request_type) {
424
+			$order->set_payment_method_title('Apple Pay (Stripe)');
425 425
 			$order->save();
426 426
 		}
427 427
 
428
-		if ( 'payment_request_api' === $payment_request_type ) {
429
-			$order->set_payment_method_title( 'Chrome Payment Request (Stripe)' );
428
+		if ('payment_request_api' === $payment_request_type) {
429
+			$order->set_payment_method_title('Chrome Payment Request (Stripe)');
430 430
 			$order->save();
431 431
 		}
432 432
 	}
@@ -464,20 +464,20 @@  discard block
 block discarded – undo
464 464
 	 * @return bool
465 465
 	 */
466 466
 	public function allowed_items_in_cart() {
467
-		foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
468
-			$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
467
+		foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
468
+			$_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
469 469
 
470
-			if ( ! in_array( $_product->get_type(), $this->supported_product_types() ) ) {
470
+			if ( ! in_array($_product->get_type(), $this->supported_product_types())) {
471 471
 				return false;
472 472
 			}
473 473
 
474 474
 			// Trial subscriptions with shipping are not supported
475
-			if ( class_exists( 'WC_Subscriptions_Order' ) && WC_Subscriptions_Cart::cart_contains_subscription() && $_product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $_product ) > 0 ) {
475
+			if (class_exists('WC_Subscriptions_Order') && WC_Subscriptions_Cart::cart_contains_subscription() && $_product->needs_shipping() && WC_Subscriptions_Product::get_trial_length($_product) > 0) {
476 476
 				return false;
477 477
 			}
478 478
 
479 479
 			// Pre Orders compatbility where we don't support charge upon release.
480
-			if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Cart::cart_contains_pre_order() && WC_Pre_Orders_Product::product_is_charged_upon_release( WC_Pre_Orders_Cart::get_pre_order_product() ) ) {
480
+			if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Cart::cart_contains_pre_order() && WC_Pre_Orders_Product::product_is_charged_upon_release(WC_Pre_Orders_Cart::get_pre_order_product())) {
481 481
 				return false;
482 482
 			}
483 483
 		}
@@ -493,59 +493,59 @@  discard block
 block discarded – undo
493 493
 	 */
494 494
 	public function scripts() {
495 495
 		// If keys are not set bail.
496
-		if ( ! $this->are_keys_set() ) {
497
-			WC_Stripe_Logger::log( 'Keys are not set correctly.' );
496
+		if ( ! $this->are_keys_set()) {
497
+			WC_Stripe_Logger::log('Keys are not set correctly.');
498 498
 			return;
499 499
 		}
500 500
 
501 501
 		// If no SSL bail.
502
-		if ( ! $this->testmode && ! is_ssl() ) {
503
-			WC_Stripe_Logger::log( 'Stripe Payment Request live mode requires SSL.' );
502
+		if ( ! $this->testmode && ! is_ssl()) {
503
+			WC_Stripe_Logger::log('Stripe Payment Request live mode requires SSL.');
504 504
 			return;
505 505
 		}
506 506
 
507
-		if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) ) {
507
+		if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order'])) {
508 508
 			return;
509 509
 		}
510 510
 
511
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
511
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
512 512
 			return;
513 513
 		}
514 514
 
515
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
515
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
516 516
 
517 517
 		$stripe_params = array(
518
-			'ajax_url'        => WC_AJAX::get_endpoint( '%%endpoint%%' ),
518
+			'ajax_url'        => WC_AJAX::get_endpoint('%%endpoint%%'),
519 519
 			'stripe'          => array(
520 520
 				'key'                => $this->publishable_key,
521
-				'allow_prepaid_card' => apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no',
521
+				'allow_prepaid_card' => apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no',
522 522
 			),
523 523
 			'nonce'           => array(
524
-				'payment'                   => wp_create_nonce( 'wc-stripe-payment-request' ),
525
-				'shipping'                  => wp_create_nonce( 'wc-stripe-payment-request-shipping' ),
526
-				'update_shipping'           => wp_create_nonce( 'wc-stripe-update-shipping-method' ),
527
-				'checkout'                  => wp_create_nonce( 'woocommerce-process_checkout' ),
528
-				'add_to_cart'               => wp_create_nonce( 'wc-stripe-add-to-cart' ),
529
-				'get_selected_product_data' => wp_create_nonce( 'wc-stripe-get-selected-product-data' ),
530
-				'log_errors'                => wp_create_nonce( 'wc-stripe-log-errors' ),
531
-				'clear_cart'                => wp_create_nonce( 'wc-stripe-clear-cart' ),
524
+				'payment'                   => wp_create_nonce('wc-stripe-payment-request'),
525
+				'shipping'                  => wp_create_nonce('wc-stripe-payment-request-shipping'),
526
+				'update_shipping'           => wp_create_nonce('wc-stripe-update-shipping-method'),
527
+				'checkout'                  => wp_create_nonce('woocommerce-process_checkout'),
528
+				'add_to_cart'               => wp_create_nonce('wc-stripe-add-to-cart'),
529
+				'get_selected_product_data' => wp_create_nonce('wc-stripe-get-selected-product-data'),
530
+				'log_errors'                => wp_create_nonce('wc-stripe-log-errors'),
531
+				'clear_cart'                => wp_create_nonce('wc-stripe-clear-cart'),
532 532
 			),
533 533
 			'i18n'            => array(
534
-				'no_prepaid_card'  => __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' ),
534
+				'no_prepaid_card'  => __('Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe'),
535 535
 				/* translators: Do not translate the [option] placeholder */
536
-				'unknown_shipping' => __( 'Unknown shipping option "[option]".', 'woocommerce-gateway-stripe' ),
536
+				'unknown_shipping' => __('Unknown shipping option "[option]".', 'woocommerce-gateway-stripe'),
537 537
 			),
538 538
 			'checkout'        => array(
539 539
 				'url'            => wc_get_checkout_url(),
540
-				'currency_code'  => strtolower( get_woocommerce_currency() ),
541
-				'country_code'   => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
540
+				'currency_code'  => strtolower(get_woocommerce_currency()),
541
+				'country_code'   => substr(get_option('woocommerce_default_country'), 0, 2),
542 542
 				'needs_shipping' => WC()->cart->needs_shipping() ? 'yes' : 'no',
543 543
 			),
544 544
 			'button'          => array(
545 545
 				'type'         => $this->get_button_type(),
546 546
 				'theme'        => $this->get_button_theme(),
547 547
 				'height'       => $this->get_button_height(),
548
-				'locale'       => apply_filters( 'wc_stripe_payment_request_button_locale', substr( get_locale(), 0, 2 ) ), // Default format is en_US.
548
+				'locale'       => apply_filters('wc_stripe_payment_request_button_locale', substr(get_locale(), 0, 2)), // Default format is en_US.
549 549
 				'is_custom'    => $this->is_custom_button(),
550 550
 				'is_branded'   => $this->is_branded_button(),
551 551
 				'css_selector' => $this->custom_button_selector(),
@@ -555,15 +555,15 @@  discard block
 block discarded – undo
555 555
 			'product'         => $this->get_product_data(),
556 556
 		);
557 557
 
558
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
559
-		wp_register_script( 'wc_stripe_payment_request', plugins_url( 'assets/js/stripe-payment-request' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery', 'stripe' ), WC_STRIPE_VERSION, true );
558
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
559
+		wp_register_script('wc_stripe_payment_request', plugins_url('assets/js/stripe-payment-request' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery', 'stripe'), WC_STRIPE_VERSION, true);
560 560
 
561
-		wp_localize_script( 'wc_stripe_payment_request', 'wc_stripe_payment_request_params', apply_filters( 'wc_stripe_payment_request_params', $stripe_params ) );
561
+		wp_localize_script('wc_stripe_payment_request', 'wc_stripe_payment_request_params', apply_filters('wc_stripe_payment_request_params', $stripe_params));
562 562
 
563
-		wp_enqueue_script( 'wc_stripe_payment_request' );
563
+		wp_enqueue_script('wc_stripe_payment_request');
564 564
 
565 565
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
566
-		if ( isset( $gateways['stripe'] ) ) {
566
+		if (isset($gateways['stripe'])) {
567 567
 			$gateways['stripe']->payment_scripts();
568 568
 		}
569 569
 	}
@@ -579,23 +579,23 @@  discard block
 block discarded – undo
579 579
 
580 580
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
581 581
 
582
-		if ( ! isset( $gateways['stripe'] ) ) {
582
+		if ( ! isset($gateways['stripe'])) {
583 583
 			return;
584 584
 		}
585 585
 
586
-		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) {
586
+		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset($_GET['pay_for_order'])) {
587 587
 			return;
588 588
 		}
589 589
 
590
-		if ( is_checkout() && ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', false, $post ) ) {
590
+		if (is_checkout() && ! apply_filters('wc_stripe_show_payment_request_on_checkout', false, $post)) {
591 591
 			return;
592 592
 		}
593 593
 
594
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
594
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
595 595
 			return;
596 596
 		} else {
597
-			if ( ! $this->allowed_items_in_cart() ) {
598
-				WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' );
597
+			if ( ! $this->allowed_items_in_cart()) {
598
+				WC_Stripe_Logger::log('Items in the cart has unsupported product type ( Payment Request button disabled )');
599 599
 				return;
600 600
 			}
601 601
 		}
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
 		<div id="wc-stripe-payment-request-wrapper" style="clear:both;padding-top:1.5em;display:none;">
604 604
 			<div id="wc-stripe-payment-request-button">
605 605
 				<?php
606
-					if ( $this->is_custom_button() ) {
607
-						$label = esc_html( $this->get_button_label() );
608
-						$class_name = esc_attr( 'button ' .  $this->get_button_theme() );
609
-						$style = esc_attr( 'height:' . $this->get_button_height() . 'px;' );
606
+					if ($this->is_custom_button()) {
607
+						$label = esc_html($this->get_button_label());
608
+						$class_name = esc_attr('button ' . $this->get_button_theme());
609
+						$style = esc_attr('height:' . $this->get_button_height() . 'px;');
610 610
 						echo "<button id=\"wc-stripe-custom-button\" class=\"$class_name\" style=\"$style\"> $label </button>";
611 611
 					}
612 612
 				?>
@@ -627,28 +627,28 @@  discard block
 block discarded – undo
627 627
 
628 628
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
629 629
 
630
-		if ( ! isset( $gateways['stripe'] ) ) {
630
+		if ( ! isset($gateways['stripe'])) {
631 631
 			return;
632 632
 		}
633 633
 
634
-		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) {
634
+		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset($_GET['pay_for_order'])) {
635 635
 			return;
636 636
 		}
637 637
 
638
-		if ( is_checkout() && ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', false, $post ) ) {
638
+		if (is_checkout() && ! apply_filters('wc_stripe_show_payment_request_on_checkout', false, $post)) {
639 639
 			return;
640 640
 		}
641 641
 
642
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
642
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
643 643
 			return;
644 644
 		} else {
645
-			if ( ! $this->allowed_items_in_cart() ) {
646
-				WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' );
645
+			if ( ! $this->allowed_items_in_cart()) {
646
+				WC_Stripe_Logger::log('Items in the cart has unsupported product type ( Payment Request button disabled )');
647 647
 				return;
648 648
 			}
649 649
 		}
650 650
 		?>
651
-		<p id="wc-stripe-payment-request-button-separator" style="margin-top:1.5em;text-align:center;display:none;">&mdash; <?php esc_html_e( 'OR', 'woocommerce-gateway-stripe' ); ?> &mdash;</p>
651
+		<p id="wc-stripe-payment-request-button-separator" style="margin-top:1.5em;text-align:center;display:none;">&mdash; <?php esc_html_e('OR', 'woocommerce-gateway-stripe'); ?> &mdash;</p>
652 652
 		<?php
653 653
 	}
654 654
 
@@ -664,32 +664,32 @@  discard block
 block discarded – undo
664 664
 	private function should_show_payment_button_on_product_page() {
665 665
 		global $post;
666 666
 
667
-		$product = wc_get_product( $post->ID );
667
+		$product = wc_get_product($post->ID);
668 668
 
669
-		if ( apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false, $post ) ) {
669
+		if (apply_filters('wc_stripe_hide_payment_request_on_product_page', false, $post)) {
670 670
 			return false;
671 671
 		}
672 672
 
673
-		if ( ! is_object( $product ) || ! in_array( $product->get_type(), $this->supported_product_types() ) ) {
673
+		if ( ! is_object($product) || ! in_array($product->get_type(), $this->supported_product_types())) {
674 674
 			return false;
675 675
 		}
676 676
 
677 677
 		// Trial subscriptions with shipping are not supported
678
-		if ( class_exists( 'WC_Subscriptions_Order' ) && $product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $product ) > 0 ) {
678
+		if (class_exists('WC_Subscriptions_Order') && $product->needs_shipping() && WC_Subscriptions_Product::get_trial_length($product) > 0) {
679 679
 			return false;
680 680
 		}
681 681
 
682 682
 		// Pre Orders charge upon release not supported.
683
-		if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Product::product_is_charged_upon_release( $product ) ) {
684
-			WC_Stripe_Logger::log( 'Pre Order charge upon release is not supported. ( Payment Request button disabled )' );
683
+		if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Product::product_is_charged_upon_release($product)) {
684
+			WC_Stripe_Logger::log('Pre Order charge upon release is not supported. ( Payment Request button disabled )');
685 685
 			return false;
686 686
 		}
687 687
 
688 688
 		// File upload addon not supported
689
-		if ( class_exists( 'WC_Product_Addons_Helper' ) ) {
690
-			$product_addons = WC_Product_Addons_Helper::get_product_addons( $product->get_id() );
691
-			foreach ( $product_addons as $addon ) {
692
-				if ( 'file_upload' === $addon['type'] ) {
689
+		if (class_exists('WC_Product_Addons_Helper')) {
690
+			$product_addons = WC_Product_Addons_Helper::get_product_addons($product->get_id());
691
+			foreach ($product_addons as $addon) {
692
+				if ('file_upload' === $addon['type']) {
693 693
 					return false;
694 694
 				}
695 695
 			}
@@ -705,11 +705,11 @@  discard block
 block discarded – undo
705 705
 	 * @version 4.0.0
706 706
 	 */
707 707
 	public function ajax_log_errors() {
708
-		check_ajax_referer( 'wc-stripe-log-errors', 'security' );
708
+		check_ajax_referer('wc-stripe-log-errors', 'security');
709 709
 
710
-		$errors = wc_clean( stripslashes( $_POST['errors'] ) );
710
+		$errors = wc_clean(stripslashes($_POST['errors']));
711 711
 
712
-		WC_Stripe_Logger::log( $errors );
712
+		WC_Stripe_Logger::log($errors);
713 713
 
714 714
 		exit;
715 715
 	}
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	 * @version 4.0.0
722 722
 	 */
723 723
 	public function ajax_clear_cart() {
724
-		check_ajax_referer( 'wc-stripe-clear-cart', 'security' );
724
+		check_ajax_referer('wc-stripe-clear-cart', 'security');
725 725
 
726 726
 		WC()->cart->empty_cart();
727 727
 		exit;
@@ -731,10 +731,10 @@  discard block
 block discarded – undo
731 731
 	 * Get cart details.
732 732
 	 */
733 733
 	public function ajax_get_cart_details() {
734
-		check_ajax_referer( 'wc-stripe-payment-request', 'security' );
734
+		check_ajax_referer('wc-stripe-payment-request', 'security');
735 735
 
736
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
737
-			define( 'WOOCOMMERCE_CART', true );
736
+		if ( ! defined('WOOCOMMERCE_CART')) {
737
+			define('WOOCOMMERCE_CART', true);
738 738
 		}
739 739
 
740 740
 		WC()->cart->calculate_totals();
@@ -745,14 +745,14 @@  discard block
 block discarded – undo
745 745
 		$data = array(
746 746
 			'shipping_required' => WC()->cart->needs_shipping(),
747 747
 			'order_data'        => array(
748
-				'currency'     => strtolower( $currency ),
749
-				'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
748
+				'currency'     => strtolower($currency),
749
+				'country_code' => substr(get_option('woocommerce_default_country'), 0, 2),
750 750
 			),
751 751
 		);
752 752
 
753 753
 		$data['order_data'] += $this->build_display_items();
754 754
 
755
-		wp_send_json( $data );
755
+		wp_send_json($data);
756 756
 	}
757 757
 
758 758
 	/**
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 	 * @see WC_Shipping::get_packages().
764 764
 	 */
765 765
 	public function ajax_get_shipping_options() {
766
-		check_ajax_referer( 'wc-stripe-payment-request-shipping', 'security' );
766
+		check_ajax_referer('wc-stripe-payment-request-shipping', 'security');
767 767
 
768 768
 		$shipping_address = filter_input_array(
769 769
 			INPUT_POST,
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 			)
778 778
 		);
779 779
 
780
-		$data = $this->get_shipping_options( $shipping_address );
781
-		wp_send_json( $data );
780
+		$data = $this->get_shipping_options($shipping_address);
781
+		wp_send_json($data);
782 782
 	}
783 783
 
784 784
 	/**
@@ -789,65 +789,65 @@  discard block
 block discarded – undo
789 789
 	 * @return array Shipping options data.
790 790
 	 * phpcs:ignore Squiz.Commenting.FunctionCommentThrowTag
791 791
 	 */
792
-	public function get_shipping_options( $shipping_address ) {
792
+	public function get_shipping_options($shipping_address) {
793 793
 		try {
794 794
 			// Set the shipping options.
795 795
 			$data = array();
796 796
 
797 797
 			// Remember current shipping method before resetting.
798
-			$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
799
-			$this->calculate_shipping( apply_filters( 'wc_stripe_payment_request_shipping_posted_values', $shipping_address ) );
798
+			$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
799
+			$this->calculate_shipping(apply_filters('wc_stripe_payment_request_shipping_posted_values', $shipping_address));
800 800
 
801 801
 			$packages = WC()->shipping->get_packages();
802 802
 
803
-			if ( ! empty( $packages ) && WC()->customer->has_calculated_shipping() ) {
804
-				foreach ( $packages as $package_key => $package ) {
805
-					if ( empty( $package['rates'] ) ) {
806
-						throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) );
803
+			if ( ! empty($packages) && WC()->customer->has_calculated_shipping()) {
804
+				foreach ($packages as $package_key => $package) {
805
+					if (empty($package['rates'])) {
806
+						throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe'));
807 807
 					}
808 808
 
809
-					foreach ( $package['rates'] as $key => $rate ) {
809
+					foreach ($package['rates'] as $key => $rate) {
810 810
 						$data['shipping_options'][] = array(
811 811
 							'id'     => $rate->id,
812 812
 							'label'  => $rate->label,
813 813
 							'detail' => '',
814
-							'amount' => WC_Stripe_Helper::get_stripe_amount( $rate->cost ),
814
+							'amount' => WC_Stripe_Helper::get_stripe_amount($rate->cost),
815 815
 						);
816 816
 					}
817 817
 				}
818 818
 			} else {
819
-				throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) );
819
+				throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe'));
820 820
 			}
821 821
 
822 822
 			// The first shipping option is automatically applied on the client.
823 823
 			// Keep chosen shipping method by sorting shipping options if the method still available for new address.
824 824
 			// Fallback to the first available shipping method.
825
-			if ( isset( $data['shipping_options'][0] ) ) {
826
-				if ( isset( $chosen_shipping_methods[0] ) ) {
825
+			if (isset($data['shipping_options'][0])) {
826
+				if (isset($chosen_shipping_methods[0])) {
827 827
 					$chosen_method_id         = $chosen_shipping_methods[0];
828
-					$compare_shipping_options = function ( $a, $b ) use ( $chosen_method_id ) {
829
-						if ( $a['id'] === $chosen_method_id ) {
828
+					$compare_shipping_options = function($a, $b) use ($chosen_method_id) {
829
+						if ($a['id'] === $chosen_method_id) {
830 830
 							return -1;
831 831
 						}
832 832
 
833
-						if ( $b['id'] === $chosen_method_id ) {
833
+						if ($b['id'] === $chosen_method_id) {
834 834
 							return 1;
835 835
 						}
836 836
 
837 837
 						return 0;
838 838
 					};
839
-					usort( $data['shipping_options'], $compare_shipping_options );
839
+					usort($data['shipping_options'], $compare_shipping_options);
840 840
 				}
841 841
 
842 842
 				$first_shipping_method_id = $data['shipping_options'][0]['id'];
843
-				$this->update_shipping_method( [ $first_shipping_method_id ] );
843
+				$this->update_shipping_method([$first_shipping_method_id]);
844 844
 			}
845 845
 
846 846
 			WC()->cart->calculate_totals();
847 847
 
848 848
 			$data          += $this->build_display_items();
849 849
 			$data['result'] = 'success';
850
-		} catch ( Exception $e ) {
850
+		} catch (Exception $e) {
851 851
 			$data          += $this->build_display_items();
852 852
 			$data['result'] = 'invalid_shipping_address';
853 853
 		}
@@ -859,14 +859,14 @@  discard block
 block discarded – undo
859 859
 	 * Update shipping method.
860 860
 	 */
861 861
 	public function ajax_update_shipping_method() {
862
-		check_ajax_referer( 'wc-stripe-update-shipping-method', 'security' );
862
+		check_ajax_referer('wc-stripe-update-shipping-method', 'security');
863 863
 
864
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
865
-			define( 'WOOCOMMERCE_CART', true );
864
+		if ( ! defined('WOOCOMMERCE_CART')) {
865
+			define('WOOCOMMERCE_CART', true);
866 866
 		}
867 867
 
868
-		$shipping_methods = filter_input( INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
869
-		$this->update_shipping_method( $shipping_methods );
868
+		$shipping_methods = filter_input(INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
869
+		$this->update_shipping_method($shipping_methods);
870 870
 
871 871
 		WC()->cart->calculate_totals();
872 872
 
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 		$data          += $this->build_display_items();
875 875
 		$data['result'] = 'success';
876 876
 
877
-		wp_send_json( $data );
877
+		wp_send_json($data);
878 878
 	}
879 879
 
880 880
 	/**
@@ -882,16 +882,16 @@  discard block
 block discarded – undo
882 882
 	 *
883 883
 	 * @param array $shipping_methods Array of selected shipping methods ids.
884 884
 	 */
885
-	public function update_shipping_method( $shipping_methods ) {
886
-		$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
885
+	public function update_shipping_method($shipping_methods) {
886
+		$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
887 887
 
888
-		if ( is_array( $shipping_methods ) ) {
889
-			foreach ( $shipping_methods as $i => $value ) {
890
-				$chosen_shipping_methods[ $i ] = wc_clean( $value );
888
+		if (is_array($shipping_methods)) {
889
+			foreach ($shipping_methods as $i => $value) {
890
+				$chosen_shipping_methods[$i] = wc_clean($value);
891 891
 			}
892 892
 		}
893 893
 
894
-		WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods );
894
+		WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
895 895
 	}
896 896
 
897 897
 	/**
@@ -902,38 +902,38 @@  discard block
 block discarded – undo
902 902
 	 * @return array $data
903 903
 	 */
904 904
 	public function ajax_get_selected_product_data() {
905
-		check_ajax_referer( 'wc-stripe-get-selected-product-data', 'security' );
905
+		check_ajax_referer('wc-stripe-get-selected-product-data', 'security');
906 906
 
907 907
 		try {
908
-			$product_id   = absint( $_POST['product_id'] );
909
-			$qty          = ! isset( $_POST['qty'] ) ? 1 : apply_filters( 'woocommerce_add_to_cart_quantity', absint( $_POST['qty'] ), $product_id );
910
-			$addon_value  = isset( $_POST['addon_value'] ) ? max( floatval( $_POST['addon_value'] ), 0 ) : 0;
911
-			$product      = wc_get_product( $product_id );
908
+			$product_id   = absint($_POST['product_id']);
909
+			$qty          = ! isset($_POST['qty']) ? 1 : apply_filters('woocommerce_add_to_cart_quantity', absint($_POST['qty']), $product_id);
910
+			$addon_value  = isset($_POST['addon_value']) ? max(floatval($_POST['addon_value']), 0) : 0;
911
+			$product      = wc_get_product($product_id);
912 912
 			$variation_id = null;
913 913
 
914
-			if ( ! is_a( $product, 'WC_Product' ) ) {
915
-				throw new Exception( sprintf( __( 'Product with the ID (%d) cannot be found.', 'woocommerce-gateway-stripe' ), $product_id ) );
914
+			if ( ! is_a($product, 'WC_Product')) {
915
+				throw new Exception(sprintf(__('Product with the ID (%d) cannot be found.', 'woocommerce-gateway-stripe'), $product_id));
916 916
 			}
917 917
 
918
-			if ( 'variable' === $product->get_type() && isset( $_POST['attributes'] ) ) {
919
-				$attributes = wc_clean( wp_unslash( $_POST['attributes'] ) );
918
+			if ('variable' === $product->get_type() && isset($_POST['attributes'])) {
919
+				$attributes = wc_clean(wp_unslash($_POST['attributes']));
920 920
 
921
-				$data_store   = WC_Data_Store::load( 'product' );
922
-				$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
921
+				$data_store   = WC_Data_Store::load('product');
922
+				$variation_id = $data_store->find_matching_product_variation($product, $attributes);
923 923
 
924
-				if ( ! empty( $variation_id ) ) {
925
-					$product = wc_get_product( $variation_id );
924
+				if ( ! empty($variation_id)) {
925
+					$product = wc_get_product($variation_id);
926 926
 				}
927 927
 			}
928 928
 
929 929
 			// Force quantity to 1 if sold individually and check for existing item in cart.
930
-			if ( $product->is_sold_individually() ) {
931
-				$qty = apply_filters( 'wc_stripe_payment_request_add_to_cart_sold_individually_quantity', 1, $qty, $product_id, $variation_id );
930
+			if ($product->is_sold_individually()) {
931
+				$qty = apply_filters('wc_stripe_payment_request_add_to_cart_sold_individually_quantity', 1, $qty, $product_id, $variation_id);
932 932
 			}
933 933
 
934
-			if ( ! $product->has_enough_stock( $qty ) ) {
934
+			if ( ! $product->has_enough_stock($qty)) {
935 935
 				/* translators: 1: product name 2: quantity in stock */
936
-				throw new Exception( sprintf( __( 'You cannot add that amount of "%1$s"; to the cart because there is not enough stock (%2$s remaining).', 'woocommerce-gateway-stripe' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity(), $product ) ) );
936
+				throw new Exception(sprintf(__('You cannot add that amount of "%1$s"; to the cart because there is not enough stock (%2$s remaining).', 'woocommerce-gateway-stripe'), $product->get_name(), wc_format_stock_quantity_for_display($product->get_stock_quantity(), $product)));
937 937
 			}
938 938
 
939 939
 			$total = $qty * $product->get_price() + $addon_value;
@@ -945,27 +945,27 @@  discard block
 block discarded – undo
945 945
 
946 946
 			$items[] = array(
947 947
 				'label'  => $product->get_name() . $quantity_label,
948
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $total ),
948
+				'amount' => WC_Stripe_Helper::get_stripe_amount($total),
949 949
 			);
950 950
 
951
-			if ( wc_tax_enabled() ) {
951
+			if (wc_tax_enabled()) {
952 952
 				$items[] = array(
953
-					'label'   => __( 'Tax', 'woocommerce-gateway-stripe' ),
953
+					'label'   => __('Tax', 'woocommerce-gateway-stripe'),
954 954
 					'amount'  => 0,
955 955
 					'pending' => true,
956 956
 				);
957 957
 			}
958 958
 
959
-			if ( wc_shipping_enabled() && $product->needs_shipping() ) {
959
+			if (wc_shipping_enabled() && $product->needs_shipping()) {
960 960
 				$items[] = array(
961
-					'label'   => __( 'Shipping', 'woocommerce-gateway-stripe' ),
961
+					'label'   => __('Shipping', 'woocommerce-gateway-stripe'),
962 962
 					'amount'  => 0,
963 963
 					'pending' => true,
964 964
 				);
965 965
 
966 966
 				$data['shippingOptions'] = array(
967 967
 					'id'     => 'pending',
968
-					'label'  => __( 'Pending', 'woocommerce-gateway-stripe' ),
968
+					'label'  => __('Pending', 'woocommerce-gateway-stripe'),
969 969
 					'detail' => '',
970 970
 					'amount' => 0,
971 971
 				);
@@ -974,17 +974,17 @@  discard block
 block discarded – undo
974 974
 			$data['displayItems'] = $items;
975 975
 			$data['total']        = array(
976 976
 				'label'   => $this->total_label,
977
-				'amount'  => WC_Stripe_Helper::get_stripe_amount( $total ),
977
+				'amount'  => WC_Stripe_Helper::get_stripe_amount($total),
978 978
 				'pending' => true,
979 979
 			);
980 980
 
981
-			$data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() );
982
-			$data['currency']        = strtolower( get_woocommerce_currency() );
983
-			$data['country_code']    = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
981
+			$data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping());
982
+			$data['currency']        = strtolower(get_woocommerce_currency());
983
+			$data['country_code']    = substr(get_option('woocommerce_default_country'), 0, 2);
984 984
 
985
-			wp_send_json( $data );
986
-		} catch ( Exception $e ) {
987
-			wp_send_json( array( 'error' => wp_strip_all_tags( $e->getMessage() ) ) );
985
+			wp_send_json($data);
986
+		} catch (Exception $e) {
987
+			wp_send_json(array('error' => wp_strip_all_tags($e->getMessage())));
988 988
 		}
989 989
 	}
990 990
 
@@ -996,33 +996,33 @@  discard block
 block discarded – undo
996 996
 	 * @return array $data
997 997
 	 */
998 998
 	public function ajax_add_to_cart() {
999
-		check_ajax_referer( 'wc-stripe-add-to-cart', 'security' );
999
+		check_ajax_referer('wc-stripe-add-to-cart', 'security');
1000 1000
 
1001
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
1002
-			define( 'WOOCOMMERCE_CART', true );
1001
+		if ( ! defined('WOOCOMMERCE_CART')) {
1002
+			define('WOOCOMMERCE_CART', true);
1003 1003
 		}
1004 1004
 
1005 1005
 		WC()->shipping->reset_shipping();
1006 1006
 
1007
-		$product_id   = absint( $_POST['product_id'] );
1008
-		$qty          = ! isset( $_POST['qty'] ) ? 1 : absint( $_POST['qty'] );
1009
-		$product      = wc_get_product( $product_id );
1007
+		$product_id   = absint($_POST['product_id']);
1008
+		$qty          = ! isset($_POST['qty']) ? 1 : absint($_POST['qty']);
1009
+		$product      = wc_get_product($product_id);
1010 1010
 		$product_type = $product->get_type();
1011 1011
 
1012 1012
 		// First empty the cart to prevent wrong calculation.
1013 1013
 		WC()->cart->empty_cart();
1014 1014
 
1015
-		if ( ( 'variable' === $product_type || 'variable-subscription' === $product_type ) && isset( $_POST['attributes'] ) ) {
1016
-			$attributes = wc_clean( wp_unslash( $_POST['attributes'] ) );
1015
+		if (('variable' === $product_type || 'variable-subscription' === $product_type) && isset($_POST['attributes'])) {
1016
+			$attributes = wc_clean(wp_unslash($_POST['attributes']));
1017 1017
 
1018
-			$data_store   = WC_Data_Store::load( 'product' );
1019
-			$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
1018
+			$data_store   = WC_Data_Store::load('product');
1019
+			$variation_id = $data_store->find_matching_product_variation($product, $attributes);
1020 1020
 
1021
-			WC()->cart->add_to_cart( $product->get_id(), $qty, $variation_id, $attributes );
1021
+			WC()->cart->add_to_cart($product->get_id(), $qty, $variation_id, $attributes);
1022 1022
 		}
1023 1023
 
1024
-		if ( 'simple' === $product_type || 'subscription' === $product_type ) {
1025
-			WC()->cart->add_to_cart( $product->get_id(), $qty );
1024
+		if ('simple' === $product_type || 'subscription' === $product_type) {
1025
+			WC()->cart->add_to_cart($product->get_id(), $qty);
1026 1026
 		}
1027 1027
 
1028 1028
 		WC()->cart->calculate_totals();
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 		$data          += $this->build_display_items();
1032 1032
 		$data['result'] = 'success';
1033 1033
 
1034
-		wp_send_json( $data );
1034
+		wp_send_json($data);
1035 1035
 	}
1036 1036
 
1037 1037
 	/**
@@ -1044,31 +1044,31 @@  discard block
 block discarded – undo
1044 1044
 	 * @version 4.0.0
1045 1045
 	 */
1046 1046
 	public function normalize_state() {
1047
-		$billing_country  = ! empty( $_POST['billing_country'] ) ? wc_clean( $_POST['billing_country'] ) : '';
1048
-		$shipping_country = ! empty( $_POST['shipping_country'] ) ? wc_clean( $_POST['shipping_country'] ) : '';
1049
-		$billing_state    = ! empty( $_POST['billing_state'] ) ? wc_clean( $_POST['billing_state'] ) : '';
1050
-		$shipping_state   = ! empty( $_POST['shipping_state'] ) ? wc_clean( $_POST['shipping_state'] ) : '';
1047
+		$billing_country  = ! empty($_POST['billing_country']) ? wc_clean($_POST['billing_country']) : '';
1048
+		$shipping_country = ! empty($_POST['shipping_country']) ? wc_clean($_POST['shipping_country']) : '';
1049
+		$billing_state    = ! empty($_POST['billing_state']) ? wc_clean($_POST['billing_state']) : '';
1050
+		$shipping_state   = ! empty($_POST['shipping_state']) ? wc_clean($_POST['shipping_state']) : '';
1051 1051
 
1052
-		if ( $billing_state && $billing_country ) {
1053
-			$valid_states = WC()->countries->get_states( $billing_country );
1052
+		if ($billing_state && $billing_country) {
1053
+			$valid_states = WC()->countries->get_states($billing_country);
1054 1054
 
1055 1055
 			// Valid states found for country.
1056
-			if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) {
1057
-				foreach ( $valid_states as $state_abbr => $state ) {
1058
-					if ( preg_match( '/' . preg_quote( $state ) . '/i', $billing_state ) ) {
1056
+			if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) {
1057
+				foreach ($valid_states as $state_abbr => $state) {
1058
+					if (preg_match('/' . preg_quote($state) . '/i', $billing_state)) {
1059 1059
 						$_POST['billing_state'] = $state_abbr;
1060 1060
 					}
1061 1061
 				}
1062 1062
 			}
1063 1063
 		}
1064 1064
 
1065
-		if ( $shipping_state && $shipping_country ) {
1066
-			$valid_states = WC()->countries->get_states( $shipping_country );
1065
+		if ($shipping_state && $shipping_country) {
1066
+			$valid_states = WC()->countries->get_states($shipping_country);
1067 1067
 
1068 1068
 			// Valid states found for country.
1069
-			if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) {
1070
-				foreach ( $valid_states as $state_abbr => $state ) {
1071
-					if ( preg_match( '/' . preg_quote( $state ) . '/i', $shipping_state ) ) {
1069
+			if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) {
1070
+				foreach ($valid_states as $state_abbr => $state) {
1071
+					if (preg_match('/' . preg_quote($state) . '/i', $shipping_state)) {
1072 1072
 						$_POST['shipping_state'] = $state_abbr;
1073 1073
 					}
1074 1074
 				}
@@ -1083,19 +1083,19 @@  discard block
 block discarded – undo
1083 1083
 	 * @version 4.0.0
1084 1084
 	 */
1085 1085
 	public function ajax_create_order() {
1086
-		if ( WC()->cart->is_empty() ) {
1087
-			wp_send_json_error( __( 'Empty cart', 'woocommerce-gateway-stripe' ) );
1086
+		if (WC()->cart->is_empty()) {
1087
+			wp_send_json_error(__('Empty cart', 'woocommerce-gateway-stripe'));
1088 1088
 		}
1089 1089
 
1090
-		if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) {
1091
-			define( 'WOOCOMMERCE_CHECKOUT', true );
1090
+		if ( ! defined('WOOCOMMERCE_CHECKOUT')) {
1091
+			define('WOOCOMMERCE_CHECKOUT', true);
1092 1092
 		}
1093 1093
 
1094 1094
 		$this->normalize_state();
1095 1095
 
1096 1096
 		WC()->checkout()->process_checkout();
1097 1097
 
1098
-		die( 0 );
1098
+		die(0);
1099 1099
 	}
1100 1100
 
1101 1101
 	/**
@@ -1105,38 +1105,38 @@  discard block
 block discarded – undo
1105 1105
 	 * @version 4.0.0
1106 1106
 	 * @param array $address
1107 1107
 	 */
1108
-	protected function calculate_shipping( $address = array() ) {
1108
+	protected function calculate_shipping($address = array()) {
1109 1109
 		$country   = $address['country'];
1110 1110
 		$state     = $address['state'];
1111 1111
 		$postcode  = $address['postcode'];
1112 1112
 		$city      = $address['city'];
1113 1113
 		$address_1 = $address['address'];
1114 1114
 		$address_2 = $address['address_2'];
1115
-		$wc_states = WC()->countries->get_states( $country );
1115
+		$wc_states = WC()->countries->get_states($country);
1116 1116
 
1117 1117
 		/**
1118 1118
 		 * In some versions of Chrome, state can be a full name. So we need
1119 1119
 		 * to convert that to abbreviation as WC is expecting that.
1120 1120
 		 */
1121
-		if ( 2 < strlen( $state ) && ! empty( $wc_states ) && ! isset( $wc_states[ $state ] ) ) {
1122
-			$state = array_search( ucwords( strtolower( $state ) ), $wc_states, true );
1121
+		if (2 < strlen($state) && ! empty($wc_states) && ! isset($wc_states[$state])) {
1122
+			$state = array_search(ucwords(strtolower($state)), $wc_states, true);
1123 1123
 		}
1124 1124
 
1125 1125
 		WC()->shipping->reset_shipping();
1126 1126
 
1127
-		if ( $postcode && WC_Validation::is_postcode( $postcode, $country ) ) {
1128
-			$postcode = wc_format_postcode( $postcode, $country );
1127
+		if ($postcode && WC_Validation::is_postcode($postcode, $country)) {
1128
+			$postcode = wc_format_postcode($postcode, $country);
1129 1129
 		}
1130 1130
 
1131
-		if ( $country ) {
1132
-			WC()->customer->set_location( $country, $state, $postcode, $city );
1133
-			WC()->customer->set_shipping_location( $country, $state, $postcode, $city );
1131
+		if ($country) {
1132
+			WC()->customer->set_location($country, $state, $postcode, $city);
1133
+			WC()->customer->set_shipping_location($country, $state, $postcode, $city);
1134 1134
 		} else {
1135 1135
 			WC()->customer->set_billing_address_to_base();
1136 1136
 			WC()->customer->set_shipping_address_to_base();
1137 1137
 		}
1138 1138
 
1139
-		WC()->customer->set_calculated_shipping( true );
1139
+		WC()->customer->set_calculated_shipping(true);
1140 1140
 		WC()->customer->save();
1141 1141
 
1142 1142
 		$packages = array();
@@ -1152,17 +1152,17 @@  discard block
 block discarded – undo
1152 1152
 		$packages[0]['destination']['address']   = $address_1;
1153 1153
 		$packages[0]['destination']['address_2'] = $address_2;
1154 1154
 
1155
-		foreach ( WC()->cart->get_cart() as $item ) {
1156
-			if ( $item['data']->needs_shipping() ) {
1157
-				if ( isset( $item['line_total'] ) ) {
1155
+		foreach (WC()->cart->get_cart() as $item) {
1156
+			if ($item['data']->needs_shipping()) {
1157
+				if (isset($item['line_total'])) {
1158 1158
 					$packages[0]['contents_cost'] += $item['line_total'];
1159 1159
 				}
1160 1160
 			}
1161 1161
 		}
1162 1162
 
1163
-		$packages = apply_filters( 'woocommerce_cart_shipping_packages', $packages );
1163
+		$packages = apply_filters('woocommerce_cart_shipping_packages', $packages);
1164 1164
 
1165
-		WC()->shipping->calculate_shipping( $packages );
1165
+		WC()->shipping->calculate_shipping($packages);
1166 1166
 	}
1167 1167
 
1168 1168
 	/**
@@ -1171,19 +1171,19 @@  discard block
 block discarded – undo
1171 1171
 	 * @since 3.1.0
1172 1172
 	 * @version 4.0.0
1173 1173
 	 */
1174
-	protected function build_shipping_methods( $shipping_methods ) {
1175
-		if ( empty( $shipping_methods ) ) {
1174
+	protected function build_shipping_methods($shipping_methods) {
1175
+		if (empty($shipping_methods)) {
1176 1176
 			return array();
1177 1177
 		}
1178 1178
 
1179 1179
 		$shipping = array();
1180 1180
 
1181
-		foreach ( $shipping_methods as $method ) {
1181
+		foreach ($shipping_methods as $method) {
1182 1182
 			$shipping[] = array(
1183 1183
 				'id'     => $method['id'],
1184 1184
 				'label'  => $method['label'],
1185 1185
 				'detail' => '',
1186
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $method['amount']['value'] ),
1186
+				'amount' => WC_Stripe_Helper::get_stripe_amount($method['amount']['value']),
1187 1187
 			);
1188 1188
 		}
1189 1189
 
@@ -1197,8 +1197,8 @@  discard block
 block discarded – undo
1197 1197
 	 * @version 4.0.0
1198 1198
 	 */
1199 1199
 	protected function build_display_items() {
1200
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
1201
-			define( 'WOOCOMMERCE_CART', true );
1200
+		if ( ! defined('WOOCOMMERCE_CART')) {
1201
+			define('WOOCOMMERCE_CART', true);
1202 1202
 		}
1203 1203
 
1204 1204
 		$items     = array();
@@ -1206,8 +1206,8 @@  discard block
 block discarded – undo
1206 1206
 		$discounts = 0;
1207 1207
 
1208 1208
 		// Default show only subtotal instead of itemization.
1209
-		if ( ! apply_filters( 'wc_stripe_payment_request_hide_itemization', true ) ) {
1210
-			foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
1209
+		if ( ! apply_filters('wc_stripe_payment_request_hide_itemization', true)) {
1210
+			foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
1211 1211
 				$amount         = $cart_item['line_subtotal'];
1212 1212
 				$subtotal      += $cart_item['line_subtotal'];
1213 1213
 				$quantity_label = 1 < $cart_item['quantity'] ? ' (x' . $cart_item['quantity'] . ')' : '';
@@ -1216,61 +1216,61 @@  discard block
 block discarded – undo
1216 1216
 
1217 1217
 				$item = array(
1218 1218
 					'label'  => $product_name . $quantity_label,
1219
-					'amount' => WC_Stripe_Helper::get_stripe_amount( $amount ),
1219
+					'amount' => WC_Stripe_Helper::get_stripe_amount($amount),
1220 1220
 				);
1221 1221
 
1222 1222
 				$items[] = $item;
1223 1223
 			}
1224 1224
 		}
1225 1225
 
1226
-		if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
1227
-			$discounts = wc_format_decimal( WC()->cart->get_cart_discount_total(), WC()->cart->dp );
1226
+		if (version_compare(WC_VERSION, '3.2', '<')) {
1227
+			$discounts = wc_format_decimal(WC()->cart->get_cart_discount_total(), WC()->cart->dp);
1228 1228
 		} else {
1229
-			$applied_coupons = array_values( WC()->cart->get_coupon_discount_totals() );
1229
+			$applied_coupons = array_values(WC()->cart->get_coupon_discount_totals());
1230 1230
 
1231
-			foreach ( $applied_coupons as $amount ) {
1231
+			foreach ($applied_coupons as $amount) {
1232 1232
 				$discounts += (float) $amount;
1233 1233
 			}
1234 1234
 		}
1235 1235
 
1236
-		$discounts   = wc_format_decimal( $discounts, WC()->cart->dp );
1237
-		$tax         = wc_format_decimal( WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp );
1238
-		$shipping    = wc_format_decimal( WC()->cart->shipping_total, WC()->cart->dp );
1239
-		$items_total = wc_format_decimal( WC()->cart->cart_contents_total, WC()->cart->dp ) + $discounts;
1240
-		$order_total = version_compare( WC_VERSION, '3.2', '<' ) ? wc_format_decimal( $items_total + $tax + $shipping - $discounts, WC()->cart->dp ) : WC()->cart->get_total( false );
1236
+		$discounts   = wc_format_decimal($discounts, WC()->cart->dp);
1237
+		$tax         = wc_format_decimal(WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp);
1238
+		$shipping    = wc_format_decimal(WC()->cart->shipping_total, WC()->cart->dp);
1239
+		$items_total = wc_format_decimal(WC()->cart->cart_contents_total, WC()->cart->dp) + $discounts;
1240
+		$order_total = version_compare(WC_VERSION, '3.2', '<') ? wc_format_decimal($items_total + $tax + $shipping - $discounts, WC()->cart->dp) : WC()->cart->get_total(false);
1241 1241
 
1242
-		if ( wc_tax_enabled() ) {
1242
+		if (wc_tax_enabled()) {
1243 1243
 			$items[] = array(
1244
-				'label'  => esc_html( __( 'Tax', 'woocommerce-gateway-stripe' ) ),
1245
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $tax ),
1244
+				'label'  => esc_html(__('Tax', 'woocommerce-gateway-stripe')),
1245
+				'amount' => WC_Stripe_Helper::get_stripe_amount($tax),
1246 1246
 			);
1247 1247
 		}
1248 1248
 
1249
-		if ( WC()->cart->needs_shipping() ) {
1249
+		if (WC()->cart->needs_shipping()) {
1250 1250
 			$items[] = array(
1251
-				'label'  => esc_html( __( 'Shipping', 'woocommerce-gateway-stripe' ) ),
1252
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $shipping ),
1251
+				'label'  => esc_html(__('Shipping', 'woocommerce-gateway-stripe')),
1252
+				'amount' => WC_Stripe_Helper::get_stripe_amount($shipping),
1253 1253
 			);
1254 1254
 		}
1255 1255
 
1256
-		if ( WC()->cart->has_discount() ) {
1256
+		if (WC()->cart->has_discount()) {
1257 1257
 			$items[] = array(
1258
-				'label'  => esc_html( __( 'Discount', 'woocommerce-gateway-stripe' ) ),
1259
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $discounts ),
1258
+				'label'  => esc_html(__('Discount', 'woocommerce-gateway-stripe')),
1259
+				'amount' => WC_Stripe_Helper::get_stripe_amount($discounts),
1260 1260
 			);
1261 1261
 		}
1262 1262
 
1263
-		if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
1263
+		if (version_compare(WC_VERSION, '3.2', '<')) {
1264 1264
 			$cart_fees = WC()->cart->fees;
1265 1265
 		} else {
1266 1266
 			$cart_fees = WC()->cart->get_fees();
1267 1267
 		}
1268 1268
 
1269 1269
 		// Include fees and taxes as display items.
1270
-		foreach ( $cart_fees as $key => $fee ) {
1270
+		foreach ($cart_fees as $key => $fee) {
1271 1271
 			$items[] = array(
1272 1272
 				'label'  => $fee->name,
1273
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $fee->amount ),
1273
+				'amount' => WC_Stripe_Helper::get_stripe_amount($fee->amount),
1274 1274
 			);
1275 1275
 		}
1276 1276
 
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 			'displayItems' => $items,
1279 1279
 			'total'        => array(
1280 1280
 				'label'   => $this->total_label,
1281
-				'amount'  => max( 0, apply_filters( 'woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount( $order_total ), $order_total, WC()->cart ) ),
1281
+				'amount'  => max(0, apply_filters('woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount($order_total), $order_total, WC()->cart)),
1282 1282
 				'pending' => false,
1283 1283
 			),
1284 1284
 		);
Please login to merge, or discard this patch.