Completed
Push — master ( d7ca42...131557 )
by Roy
06:35
created
includes/admin/stripe-settings.php 1 patch
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -1,207 +1,207 @@
 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_settings',
8
+return apply_filters('wc_stripe_settings',
9 9
 	array(
10 10
 		'enabled' => array(
11
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
12
-			'label'       => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ),
11
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
12
+			'label'       => __('Enable Stripe', 'woocommerce-gateway-stripe'),
13 13
 			'type'        => 'checkbox',
14 14
 			'description' => '',
15 15
 			'default'     => 'no',
16 16
 		),
17 17
 		'title' => array(
18
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
18
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
19 19
 			'type'        => 'text',
20
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
21
-			'default'     => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ),
20
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
21
+			'default'     => __('Credit Card (Stripe)', 'woocommerce-gateway-stripe'),
22 22
 			'desc_tip'    => true,
23 23
 		),
24 24
 		'description' => array(
25
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
25
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
26 26
 			'type'        => 'text',
27
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
28
-			'default'     => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe' ),
27
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
28
+			'default'     => __('Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'),
29 29
 			'desc_tip'    => true,
30 30
 		),
31 31
 		'webhook' => array(
32
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
32
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
33 33
 			'type'        => 'title',
34 34
 			/* translators: webhook URL */
35
-			'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 ),
35
+			'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),
36 36
 		),
37 37
 		'testmode' => array(
38
-			'title'       => __( 'Test mode', 'woocommerce-gateway-stripe' ),
39
-			'label'       => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ),
38
+			'title'       => __('Test mode', 'woocommerce-gateway-stripe'),
39
+			'label'       => __('Enable Test Mode', 'woocommerce-gateway-stripe'),
40 40
 			'type'        => 'checkbox',
41
-			'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ),
41
+			'description' => __('Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe'),
42 42
 			'default'     => 'yes',
43 43
 			'desc_tip'    => true,
44 44
 		),
45 45
 		'test_publishable_key' => array(
46
-			'title'       => __( 'Test Publishable Key', 'woocommerce-gateway-stripe' ),
46
+			'title'       => __('Test Publishable Key', 'woocommerce-gateway-stripe'),
47 47
 			'type'        => 'password',
48
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
48
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
49 49
 			'default'     => '',
50 50
 			'desc_tip'    => true,
51 51
 		),
52 52
 		'test_secret_key' => array(
53
-			'title'       => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ),
53
+			'title'       => __('Test Secret Key', 'woocommerce-gateway-stripe'),
54 54
 			'type'        => 'password',
55
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
55
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
56 56
 			'default'     => '',
57 57
 			'desc_tip'    => true,
58 58
 		),
59 59
 		'publishable_key' => array(
60
-			'title'       => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ),
60
+			'title'       => __('Live Publishable Key', 'woocommerce-gateway-stripe'),
61 61
 			'type'        => 'password',
62
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
62
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
63 63
 			'default'     => '',
64 64
 			'desc_tip'    => true,
65 65
 		),
66 66
 		'secret_key' => array(
67
-			'title'       => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ),
67
+			'title'       => __('Live Secret Key', 'woocommerce-gateway-stripe'),
68 68
 			'type'        => 'password',
69
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
69
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
70 70
 			'default'     => '',
71 71
 			'desc_tip'    => true,
72 72
 		),
73 73
 		'inline_cc_form' => array(
74
-			'title'       => __( 'Inline Credit Card Form', 'woocommerce-gateway-stripe' ),
74
+			'title'       => __('Inline Credit Card Form', 'woocommerce-gateway-stripe'),
75 75
 			'type'        => 'checkbox',
76
-			'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' ),
76
+			'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'),
77 77
 			'default'     => 'no',
78 78
 			'desc_tip'    => true,
79 79
 		),
80 80
 		'statement_descriptor' => array(
81
-			'title'       => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ),
81
+			'title'       => __('Statement Descriptor', 'woocommerce-gateway-stripe'),
82 82
 			'type'        => 'text',
83
-			'description' => __( 'This may be up to 22 characters. The statement description must contain at least one letter, may not include ><"\' characters, and will appear on your customer\'s statement in capital letters.' ),
83
+			'description' => __('This may be up to 22 characters. The statement description must contain at least one letter, may not include ><"\' characters, and will appear on your customer\'s statement in capital letters.'),
84 84
 			'default'     => '',
85 85
 			'desc_tip'    => true,
86 86
 		),
87 87
 		'capture' => array(
88
-			'title'       => __( 'Capture', 'woocommerce-gateway-stripe' ),
89
-			'label'       => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ),
88
+			'title'       => __('Capture', 'woocommerce-gateway-stripe'),
89
+			'label'       => __('Capture charge immediately', 'woocommerce-gateway-stripe'),
90 90
 			'type'        => 'checkbox',
91
-			'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' ),
91
+			'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'),
92 92
 			'default'     => 'yes',
93 93
 			'desc_tip'    => true,
94 94
 		),
95 95
 		'three_d_secure' => array(
96
-			'title'       => __( '3D Secure', 'woocommerce-gateway-stripe' ),
97
-			'label'       => __( 'Require 3D Secure when applicable', 'woocommerce-gateway-stripe' ),
96
+			'title'       => __('3D Secure', 'woocommerce-gateway-stripe'),
97
+			'label'       => __('Require 3D Secure when applicable', 'woocommerce-gateway-stripe'),
98 98
 			'type'        => 'checkbox',
99
-			'description' => __( 'Some payment methods have 3D Secure feature. This is an extra security layer for your store. Choose how to handle payments when 3D Secure is optional. Enabling would require customers to use 3D Secure when optional.', 'woocommerce-gateway-stripe' ),
99
+			'description' => __('Some payment methods have 3D Secure feature. This is an extra security layer for your store. Choose how to handle payments when 3D Secure is optional. Enabling would require customers to use 3D Secure when optional.', 'woocommerce-gateway-stripe'),
100 100
 			'default'     => 'no',
101 101
 			'desc_tip'    => true,
102 102
 		),
103 103
 		'stripe_checkout' => array(
104
-			'title'       => __( 'Stripe Checkout', 'woocommerce-gateway-stripe' ),
105
-			'label'       => __( 'Enable Stripe Checkout', 'woocommerce-gateway-stripe' ),
104
+			'title'       => __('Stripe Checkout', 'woocommerce-gateway-stripe'),
105
+			'label'       => __('Enable Stripe Checkout', 'woocommerce-gateway-stripe'),
106 106
 			'type'        => 'checkbox',
107
-			'description' => __( 'If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page.', 'woocommerce-gateway-stripe' ),
107
+			'description' => __('If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page.', 'woocommerce-gateway-stripe'),
108 108
 			'default'     => 'no',
109 109
 			'desc_tip'    => true,
110 110
 		),
111 111
 		'stripe_checkout_locale' => array(
112
-			'title'       => __( 'Stripe Checkout locale', 'woocommerce-gateway-stripe' ),
112
+			'title'       => __('Stripe Checkout locale', 'woocommerce-gateway-stripe'),
113 113
 			'type'        => 'select',
114 114
 			'class'       => 'wc-enhanced-select',
115
-			'description' => __( 'Language to display in Stripe Checkout modal. Specify Auto to display Checkout in the user\'s preferred language, if available. English will be used by default.', 'woocommerce-gateway-stripe' ),
115
+			'description' => __('Language to display in Stripe Checkout modal. Specify Auto to display Checkout in the user\'s preferred language, if available. English will be used by default.', 'woocommerce-gateway-stripe'),
116 116
 			'default'     => 'en',
117 117
 			'desc_tip'    => true,
118 118
 			'options'     => array(
119
-				'auto' => __( 'Auto', 'woocommerce-gateway-stripe' ),
120
-				'zh'   => __( 'Simplified Chinese', 'woocommerce-gateway-stripe' ),
121
-				'da'   => __( 'Danish', 'woocommerce-gateway-stripe' ),
122
-				'nl'   => __( 'Dutch', 'woocommerce-gateway-stripe' ),
123
-				'en'   => __( 'English', 'woocommerce-gateway-stripe' ),
124
-				'fi'   => __( 'Finnish', 'woocommerce-gateway-stripe' ),
125
-				'fr'   => __( 'French', 'woocommerce-gateway-stripe' ),
126
-				'de'   => __( 'German', 'woocommerce-gateway-stripe' ),
127
-				'it'   => __( 'Italian', 'woocommerce-gateway-stripe' ),
128
-				'ja'   => __( 'Japanese', 'woocommerce-gateway-stripe' ),
129
-				'no'   => __( 'Norwegian', 'woocommerce-gateway-stripe' ),
130
-				'es'   => __( 'Spanish', 'woocommerce-gateway-stripe' ),
131
-				'sv'   => __( 'Swedish', 'woocommerce-gateway-stripe' ),
119
+				'auto' => __('Auto', 'woocommerce-gateway-stripe'),
120
+				'zh'   => __('Simplified Chinese', 'woocommerce-gateway-stripe'),
121
+				'da'   => __('Danish', 'woocommerce-gateway-stripe'),
122
+				'nl'   => __('Dutch', 'woocommerce-gateway-stripe'),
123
+				'en'   => __('English', 'woocommerce-gateway-stripe'),
124
+				'fi'   => __('Finnish', 'woocommerce-gateway-stripe'),
125
+				'fr'   => __('French', 'woocommerce-gateway-stripe'),
126
+				'de'   => __('German', 'woocommerce-gateway-stripe'),
127
+				'it'   => __('Italian', 'woocommerce-gateway-stripe'),
128
+				'ja'   => __('Japanese', 'woocommerce-gateway-stripe'),
129
+				'no'   => __('Norwegian', 'woocommerce-gateway-stripe'),
130
+				'es'   => __('Spanish', 'woocommerce-gateway-stripe'),
131
+				'sv'   => __('Swedish', 'woocommerce-gateway-stripe'),
132 132
 			),
133 133
 		),
134 134
 		'stripe_bitcoin' => array(
135
-			'title'       => __( 'Bitcoin Currency', 'woocommerce-gateway-stripe' ),
136
-			'label'       => __( 'Enable Bitcoin Currency', 'woocommerce-gateway-stripe' ),
135
+			'title'       => __('Bitcoin Currency', 'woocommerce-gateway-stripe'),
136
+			'label'       => __('Enable Bitcoin Currency', 'woocommerce-gateway-stripe'),
137 137
 			'type'        => 'checkbox',
138
-			'description' => __( 'If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe' ),
138
+			'description' => __('If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe'),
139 139
 			'default'     => 'no',
140 140
 			'desc_tip'    => true,
141 141
 		),
142 142
 		'stripe_checkout_image' => array(
143
-			'title'       => __( 'Stripe Checkout Image', 'woocommerce-gateway-stripe' ),
144
-			'description' => __( 'Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe' ),
143
+			'title'       => __('Stripe Checkout Image', 'woocommerce-gateway-stripe'),
144
+			'description' => __('Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe'),
145 145
 			'type'        => 'text',
146 146
 			'default'     => '',
147 147
 			'desc_tip'    => true,
148 148
 		),
149 149
 		'payment_request' => array(
150
-			'title'       => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ),
150
+			'title'       => __('Payment Request Buttons', 'woocommerce-gateway-stripe'),
151 151
 			/* translators: 1) br tag 2) opening anchor tag 3) closing anchor tag */
152
-			'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>' ),
152
+			'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>'),
153 153
 			'type'        => 'checkbox',
154
-			'description' => __( 'If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe' ),
154
+			'description' => __('If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe'),
155 155
 			'default'     => 'yes',
156 156
 			'desc_tip'    => true,
157 157
 		),
158 158
 		'payment_request_button_type' => array(
159
-			'title'       => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ),
160
-			'label'       => __( 'Button Type', 'woocommerce-gateway-stripe' ),
159
+			'title'       => __('Payment Request Button Type', 'woocommerce-gateway-stripe'),
160
+			'label'       => __('Button Type', 'woocommerce-gateway-stripe'),
161 161
 			'type'        => 'select',
162
-			'description' => __( 'Select the button type you would like to show.', 'woocommerce-gateway-stripe' ),
162
+			'description' => __('Select the button type you would like to show.', 'woocommerce-gateway-stripe'),
163 163
 			'default'     => 'buy',
164 164
 			'desc_tip'    => true,
165 165
 			'options'     => array(
166
-				'default' => __( 'Default', 'woocommerce-gateway-stripe' ),
167
-				'buy'     => __( 'Buy', 'woocommerce-gateway-stripe' ),
168
-				'donate'  => __( 'Donate', 'woocommerce-gateway-stripe' ),
166
+				'default' => __('Default', 'woocommerce-gateway-stripe'),
167
+				'buy'     => __('Buy', 'woocommerce-gateway-stripe'),
168
+				'donate'  => __('Donate', 'woocommerce-gateway-stripe'),
169 169
 			),
170 170
 		),
171 171
 		'payment_request_button_theme' => array(
172
-			'title'       => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ),
173
-			'label'       => __( 'Button Theme', 'woocommerce-gateway-stripe' ),
172
+			'title'       => __('Payment Request Button Theme', 'woocommerce-gateway-stripe'),
173
+			'label'       => __('Button Theme', 'woocommerce-gateway-stripe'),
174 174
 			'type'        => 'select',
175
-			'description' => __( 'Select the button theme you would like to show.', 'woocommerce-gateway-stripe' ),
175
+			'description' => __('Select the button theme you would like to show.', 'woocommerce-gateway-stripe'),
176 176
 			'default'     => 'default',
177 177
 			'desc_tip'    => true,
178 178
 			'options'     => array(
179
-				'dark'          => __( 'Dark', 'woocommerce-gateway-stripe' ),
180
-				'light'         => __( 'Light', 'woocommerce-gateway-stripe' ),
181
-				'light-outline' => __( 'Light-Outline', 'woocommerce-gateway-stripe' ),
179
+				'dark'          => __('Dark', 'woocommerce-gateway-stripe'),
180
+				'light'         => __('Light', 'woocommerce-gateway-stripe'),
181
+				'light-outline' => __('Light-Outline', 'woocommerce-gateway-stripe'),
182 182
 			),
183 183
 		),
184 184
 		'payment_request_button_height' => array(
185
-			'title'       => __( 'Payment Request Button Height', 'woocommerce-gateway-stripe' ),
186
-			'label'       => __( 'Button Height', 'woocommerce-gateway-stripe' ),
185
+			'title'       => __('Payment Request Button Height', 'woocommerce-gateway-stripe'),
186
+			'label'       => __('Button Height', 'woocommerce-gateway-stripe'),
187 187
 			'type'        => 'text',
188
-			'description' => __( 'Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe' ),
188
+			'description' => __('Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe'),
189 189
 			'default'     => '44',
190 190
 			'desc_tip'    => true,
191 191
 		),
192 192
 		'saved_cards' => array(
193
-			'title'       => __( 'Saved Cards', 'woocommerce-gateway-stripe' ),
194
-			'label'       => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ),
193
+			'title'       => __('Saved Cards', 'woocommerce-gateway-stripe'),
194
+			'label'       => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'),
195 195
 			'type'        => 'checkbox',
196
-			'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' ),
196
+			'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'),
197 197
 			'default'     => 'no',
198 198
 			'desc_tip'    => true,
199 199
 		),
200 200
 		'logging' => array(
201
-			'title'       => __( 'Logging', 'woocommerce-gateway-stripe' ),
202
-			'label'       => __( 'Log debug messages', 'woocommerce-gateway-stripe' ),
201
+			'title'       => __('Logging', 'woocommerce-gateway-stripe'),
202
+			'label'       => __('Log debug messages', 'woocommerce-gateway-stripe'),
203 203
 			'type'        => 'checkbox',
204
-			'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ),
204
+			'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'),
205 205
 			'default'     => 'no',
206 206
 			'desc_tip'    => true,
207 207
 		),
Please login to merge, or discard this patch.
includes/admin/stripe-bancontact-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_bancontact_settings',
8
+return apply_filters('wc_stripe_bancontact_settings',
9 9
 	array(
10 10
 		'geo_target' => array(
11
-			'description' => __( 'Relevant Payer Geography: Belgium', 'woocommerce-gateway-stripe' ),
11
+			'description' => __('Relevant Payer Geography: Belgium', 'woocommerce-gateway-stripe'),
12 12
 			'type'        => 'title',
13 13
 		),
14 14
 		'guide' => array(
15
-			'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#bancontact" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ),
15
+			'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#bancontact" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe'),
16 16
 			'type'        => 'title',
17 17
 		),
18 18
 		'activation' => array(
19
-			'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ),
19
+			'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'),
20 20
 			'type'   => 'title',
21 21
 		),
22 22
 		'enabled' => array(
23
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
24
-			'label'       => __( 'Enable Stripe Bancontact', 'woocommerce-gateway-stripe' ),
23
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
24
+			'label'       => __('Enable Stripe Bancontact', 'woocommerce-gateway-stripe'),
25 25
 			'type'        => 'checkbox',
26 26
 			'description' => '',
27 27
 			'default'     => 'no',
28 28
 		),
29 29
 		'title' => array(
30
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
30
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
31 31
 			'type'        => 'text',
32
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
33
-			'default'     => __( 'Bancontact', 'woocommerce-gateway-stripe' ),
32
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
33
+			'default'     => __('Bancontact', 'woocommerce-gateway-stripe'),
34 34
 			'desc_tip'    => true,
35 35
 		),
36 36
 		'description' => array(
37
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
37
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
38 38
 			'type'        => 'text',
39
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
40
-			'default'     => __( 'You will be redirected to Bancontact.', 'woocommerce-gateway-stripe' ),
39
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
40
+			'default'     => __('You will be redirected to Bancontact.', 'woocommerce-gateway-stripe'),
41 41
 			'desc_tip'    => true,
42 42
 		),
43 43
 		'webhook' => array(
44
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
44
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
45 45
 			'type'        => 'title',
46 46
 			/* translators: webhook URL */
47
-			'description' => sprintf( __( 'You must add the webhook endpoint <strong style="background-color:#ddd;">&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-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.
includes/class-wc-gateway-stripe.php 1 patch
Spacing   +201 added lines, -201 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
 
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function __construct() {
121 121
 		$this->id                   = 'stripe';
122
-		$this->method_title         = __( 'Stripe', 'woocommerce-gateway-stripe' );
122
+		$this->method_title         = __('Stripe', 'woocommerce-gateway-stripe');
123 123
 		/* translators: 1) link to Stripe register page 2) link to Stripe api keys page */
124
-		$this->method_description   = sprintf( __( 'Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification. <a href="%1$s" target="_blank">Sign up</a> for a Stripe account, and <a href="%2$s" target="_blank">get your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), 'https://dashboard.stripe.com/register', 'https://dashboard.stripe.com/account/apikeys' );
124
+		$this->method_description   = sprintf(__('Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification. <a href="%1$s" target="_blank">Sign up</a> for a Stripe account, and <a href="%2$s" target="_blank">get your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), 'https://dashboard.stripe.com/register', 'https://dashboard.stripe.com/account/apikeys');
125 125
 		$this->has_fields           = true;
126 126
 		$this->supports             = array(
127 127
 			'products',
@@ -148,38 +148,38 @@  discard block
 block discarded – undo
148 148
 		$this->init_settings();
149 149
 
150 150
 		// Get setting values.
151
-		$this->title                   = $this->get_option( 'title' );
152
-		$this->description             = $this->get_option( 'description' );
153
-		$this->enabled                 = $this->get_option( 'enabled' );
154
-		$this->testmode                = 'yes' === $this->get_option( 'testmode' );
155
-		$this->inline_cc_form          = 'yes' === $this->get_option( 'inline_cc_form' );
156
-		$this->capture                 = 'yes' === $this->get_option( 'capture', 'yes' );
157
-		$this->statement_descriptor    = WC_Stripe_Helper::clean_statement_descriptor( $this->get_option( 'statement_descriptor' ) );
158
-		$this->three_d_secure          = 'yes' === $this->get_option( 'three_d_secure' );
159
-		$this->stripe_checkout         = 'yes' === $this->get_option( 'stripe_checkout' );
160
-		$this->stripe_checkout_locale  = $this->get_option( 'stripe_checkout_locale' );
161
-		$this->stripe_checkout_image   = $this->get_option( 'stripe_checkout_image', '' );
162
-		$this->saved_cards             = 'yes' === $this->get_option( 'saved_cards' );
163
-		$this->secret_key              = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
164
-		$this->publishable_key         = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' );
165
-		$this->bitcoin                 = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' );
166
-		$this->payment_request         = 'yes' === $this->get_option( 'payment_request', 'yes' );
167
-		$this->apple_pay_domain_set    = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' );
151
+		$this->title                   = $this->get_option('title');
152
+		$this->description             = $this->get_option('description');
153
+		$this->enabled                 = $this->get_option('enabled');
154
+		$this->testmode                = 'yes' === $this->get_option('testmode');
155
+		$this->inline_cc_form          = 'yes' === $this->get_option('inline_cc_form');
156
+		$this->capture                 = 'yes' === $this->get_option('capture', 'yes');
157
+		$this->statement_descriptor    = WC_Stripe_Helper::clean_statement_descriptor($this->get_option('statement_descriptor'));
158
+		$this->three_d_secure          = 'yes' === $this->get_option('three_d_secure');
159
+		$this->stripe_checkout         = 'yes' === $this->get_option('stripe_checkout');
160
+		$this->stripe_checkout_locale  = $this->get_option('stripe_checkout_locale');
161
+		$this->stripe_checkout_image   = $this->get_option('stripe_checkout_image', '');
162
+		$this->saved_cards             = 'yes' === $this->get_option('saved_cards');
163
+		$this->secret_key              = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
164
+		$this->publishable_key         = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key');
165
+		$this->bitcoin                 = 'USD' === strtoupper(get_woocommerce_currency()) && 'yes' === $this->get_option('stripe_bitcoin');
166
+		$this->payment_request         = 'yes' === $this->get_option('payment_request', 'yes');
167
+		$this->apple_pay_domain_set    = 'yes' === $this->get_option('apple_pay_domain_set', 'no');
168 168
 		$this->apple_pay_verify_notice = '';
169 169
 
170
-		if ( $this->stripe_checkout ) {
171
-			$this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' );
170
+		if ($this->stripe_checkout) {
171
+			$this->order_button_text = __('Continue to payment', 'woocommerce-gateway-stripe');
172 172
 		}
173 173
 
174
-		WC_Stripe_API::set_secret_key( $this->secret_key );
174
+		WC_Stripe_API::set_secret_key($this->secret_key);
175 175
 
176 176
 		$this->init_apple_pay();
177 177
 
178 178
 		// Hooks.
179
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
180
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
181
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
182
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
179
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
180
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'));
181
+		add_action('admin_notices', array($this, 'admin_notices'));
182
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
183 183
 	}
184 184
 
185 185
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @return array
191 191
 	 */
192 192
 	public function payment_icons() {
193
-		return apply_filters( 'wc_stripe_payment_icons', array(
193
+		return apply_filters('wc_stripe_payment_icons', array(
194 194
 			'visa'       => '<i class="stripe-pf stripe-pf-visa stripe-pf-right" alt="Visa" aria-hidden="true"></i>',
195 195
 			'amex'       => '<i class="stripe-pf stripe-pf-american-express stripe-pf-right" alt="Amex" aria-hidden="true"></i>',
196 196
 			'mastercard' => '<i class="stripe-pf stripe-pf-mastercard stripe-pf-right" alt="Mastercard" aria-hidden="true"></i>',
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			'eps'        => '<i class="stripe-pf stripe-pf-eps stripe-pf-right" alt="EPS" aria-hidden="true"></i>',
208 208
 			'sofort'     => '<i class="stripe-pf stripe-pf-sofort stripe-pf-right" alt="SOFORT" aria-hidden="true"></i>',
209 209
 			'sepa'       => '<i class="stripe-pf stripe-pf-sepa stripe-pf-right" alt="SEPA" aria-hidden="true"></i>',
210
-		) );
210
+		));
211 211
 	}
212 212
 
213 213
 	/**
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 		$icons_str .= $icons['amex'];
227 227
 		$icons_str .= $icons['mastercard'];
228 228
 
229
-		if ( 'USD' === get_woocommerce_currency() ) {
229
+		if ('USD' === get_woocommerce_currency()) {
230 230
 			$icons_str .= $icons['discover'];
231 231
 			$icons_str .= $icons['jcb'];
232 232
 			$icons_str .= $icons['diners'];
233 233
 		}
234 234
 
235
-		if ( $this->bitcoin && $this->stripe_checkout ) {
235
+		if ($this->bitcoin && $this->stripe_checkout) {
236 236
 			$icons_str .= $icons['bitcoin'];
237 237
 		}
238 238
 
239
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
239
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
240 240
 	}
241 241
 
242 242
 	/**
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	public function init_apple_pay() {
249 249
 		if (
250 250
 			is_admin() &&
251
-			isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] &&
252
-			isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] &&
253
-			isset( $_GET['section'] ) && 'stripe' === $_GET['section'] &&
251
+			isset($_GET['page']) && 'wc-settings' === $_GET['page'] &&
252
+			isset($_GET['tab']) && 'checkout' === $_GET['tab'] &&
253
+			isset($_GET['section']) && 'stripe' === $_GET['section'] &&
254 254
 			$this->payment_request
255 255
 		) {
256 256
 			$this->process_apple_pay_verification();
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
 	 * @version 3.1.0
265 265
 	 * @param string $secret_key
266 266
 	 */
267
-	private function register_apple_pay_domain( $secret_key = '' ) {
268
-		if ( empty( $secret_key ) ) {
269
-			throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) );
267
+	private function register_apple_pay_domain($secret_key = '') {
268
+		if (empty($secret_key)) {
269
+			throw new Exception(__('Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe'));
270 270
 		}
271 271
 
272 272
 		$endpoint = 'https://api.stripe.com/v1/apple_pay/domains';
@@ -280,23 +280,23 @@  discard block
 block discarded – undo
280 280
 			'Authorization' => 'Bearer ' . $secret_key,
281 281
 		);
282 282
 
283
-		$response = wp_remote_post( $endpoint, array(
283
+		$response = wp_remote_post($endpoint, array(
284 284
 			'headers' => $headers,
285
-			'body'    => http_build_query( $data ),
286
-		) );
285
+			'body'    => http_build_query($data),
286
+		));
287 287
 
288
-		if ( is_wp_error( $response ) ) {
288
+		if (is_wp_error($response)) {
289 289
 			/* translators: error message */
290
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) );
290
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $response->get_error_message()));
291 291
 		}
292 292
 
293
-		if ( 200 !== $response['response']['code'] ) {
294
-			$parsed_response = json_decode( $response['body'] );
293
+		if (200 !== $response['response']['code']) {
294
+			$parsed_response = json_decode($response['body']);
295 295
 
296 296
 			$this->apple_pay_verify_notice = $parsed_response->error->message;
297 297
 
298 298
 			/* translators: error message */
299
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $parsed_response->error->message ) );
299
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $parsed_response->error->message));
300 300
 		}
301 301
 	}
302 302
 
@@ -307,48 +307,48 @@  discard block
 block discarded – undo
307 307
 	 * @version 3.1.0
308 308
 	 */
309 309
 	public function process_apple_pay_verification() {
310
-		$gateway_settings = get_option( 'woocommerce_stripe_settings', array() );
310
+		$gateway_settings = get_option('woocommerce_stripe_settings', array());
311 311
 
312 312
 		try {
313
-			$path     = untrailingslashit( $_SERVER['DOCUMENT_ROOT'] );
313
+			$path     = untrailingslashit($_SERVER['DOCUMENT_ROOT']);
314 314
 			$dir      = '.well-known';
315 315
 			$file     = 'apple-developer-merchantid-domain-association';
316 316
 			$fullpath = $path . '/' . $dir . '/' . $file;
317 317
 
318
-			if ( ! empty( $gateway_settings['apple_pay_domain_set'] ) && 'yes' === $gateway_settings['apple_pay_domain_set'] && file_exists( $fullpath ) ) {
318
+			if ( ! empty($gateway_settings['apple_pay_domain_set']) && 'yes' === $gateway_settings['apple_pay_domain_set'] && file_exists($fullpath)) {
319 319
 				return;
320 320
 			}
321 321
 
322
-			if ( ! file_exists( $path . '/' . $dir ) ) {
323
-				if ( ! @mkdir( $path . '/' . $dir, 0755 ) ) {
324
-					throw new Exception( __( 'Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe' ) );
322
+			if ( ! file_exists($path . '/' . $dir)) {
323
+				if ( ! @mkdir($path . '/' . $dir, 0755)) {
324
+					throw new Exception(__('Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe'));
325 325
 				}
326 326
 			}
327 327
 
328
-			if ( ! file_exists( $fullpath ) ) {
329
-				if ( ! @copy( WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath ) ) {
330
-					throw new Exception( __( 'Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe' ) );
328
+			if ( ! file_exists($fullpath)) {
329
+				if ( ! @copy(WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath)) {
330
+					throw new Exception(__('Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe'));
331 331
 				}
332 332
 			}
333 333
 
334 334
 			// At this point then the domain association folder and file should be available.
335 335
 			// Proceed to verify/and or verify again.
336
-			$this->register_apple_pay_domain( $this->secret_key );
336
+			$this->register_apple_pay_domain($this->secret_key);
337 337
 
338 338
 			// No errors to this point, verification success!
339 339
 			$gateway_settings['apple_pay_domain_set'] = 'yes';
340 340
 			$this->apple_pay_domain_set = true;
341 341
 
342
-			update_option( 'woocommerce_stripe_settings', $gateway_settings );
342
+			update_option('woocommerce_stripe_settings', $gateway_settings);
343 343
 
344
-			WC_Stripe_Logger::log( 'Your domain has been verified with Apple Pay!' );
344
+			WC_Stripe_Logger::log('Your domain has been verified with Apple Pay!');
345 345
 
346
-		} catch ( Exception $e ) {
346
+		} catch (Exception $e) {
347 347
 			$gateway_settings['apple_pay_domain_set'] = 'no';
348 348
 
349
-			update_option( 'woocommerce_stripe_settings', $gateway_settings );
349
+			update_option('woocommerce_stripe_settings', $gateway_settings);
350 350
 
351
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
351
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
352 352
 		}
353 353
 	}
354 354
 
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 	 * Check if SSL is enabled and notify the user
357 357
 	 */
358 358
 	public function admin_notices() {
359
-		if ( 'no' === $this->enabled ) {
359
+		if ('no' === $this->enabled) {
360 360
 			return;
361 361
 		}
362 362
 
363
-		if ( $this->payment_request && ! empty( $this->apple_pay_verify_notice ) ) {
363
+		if ($this->payment_request && ! empty($this->apple_pay_verify_notice)) {
364 364
 			$allowed_html = array(
365 365
 				'a' => array(
366 366
 					'href' => array(),
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 				),
369 369
 			);
370 370
 
371
-			echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses( make_clickable( $this->apple_pay_verify_notice ), $allowed_html ) . '</p></div>';
371
+			echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses(make_clickable($this->apple_pay_verify_notice), $allowed_html) . '</p></div>';
372 372
 		}
373 373
 
374 374
 		/**
@@ -376,9 +376,9 @@  discard block
 block discarded – undo
376 376
 		 * when setting screen is displayed. So if domain verification is not set,
377 377
 		 * something went wrong so lets notify user.
378 378
 		 */
379
-		if ( ! empty( $this->secret_key ) && $this->payment_request && ! $this->apple_pay_domain_set ) {
379
+		if ( ! empty($this->secret_key) && $this->payment_request && ! $this->apple_pay_domain_set) {
380 380
 			/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
381
-			echo '<div class="error stripe-apple-pay-message"><p>' . sprintf( __( 'Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe' ), '<a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">', '</a>' ) . '</p></div>';
381
+			echo '<div class="error stripe-apple-pay-message"><p>' . sprintf(__('Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe'), '<a href="' . admin_url('admin.php?page=wc-status&tab=logs') . '">', '</a>') . '</p></div>';
382 382
 		}
383 383
 	}
384 384
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 	 * Initialise Gateway Settings Form Fields
387 387
 	 */
388 388
 	public function init_form_fields() {
389
-		$this->form_fields = require( dirname( __FILE__ ) . '/admin/stripe-settings.php' );
389
+		$this->form_fields = require(dirname(__FILE__) . '/admin/stripe-settings.php');
390 390
 	}
391 391
 
392 392
 	/**
@@ -394,59 +394,59 @@  discard block
 block discarded – undo
394 394
 	 */
395 395
 	public function payment_fields() {
396 396
 		$user                 = wp_get_current_user();
397
-		$display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards;
397
+		$display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards;
398 398
 		$total                = WC()->cart->total;
399 399
 		$user_email           = '';
400 400
 
401 401
 		// If paying from order, we need to get total from order not cart.
402
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
403
-			$order      = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) );
402
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
403
+			$order      = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key'])));
404 404
 			$total      = $order->get_total();
405 405
 			$user_email = WC_Stripe_Helper::is_pre_30() ? $order->billing_email : $order->get_billing_email();
406 406
 		} else {
407
-			if ( $user->ID ) {
408
-				$user_email = get_user_meta( $user->ID, 'billing_email', true );
407
+			if ($user->ID) {
408
+				$user_email = get_user_meta($user->ID, 'billing_email', true);
409 409
 				$user_email = $user_email ? $user_email : $user->user_email;
410 410
 			}
411 411
 		}
412 412
 
413
-		if ( is_add_payment_method_page() ) {
414
-			$pay_button_text = __( 'Add Card', 'woocommerce-gateway-stripe' );
415
-			$total        = '';
413
+		if (is_add_payment_method_page()) {
414
+			$pay_button_text = __('Add Card', 'woocommerce-gateway-stripe');
415
+			$total = '';
416 416
 		} else {
417 417
 			$pay_button_text = '';
418 418
 		}
419 419
 
420 420
 		echo '<div
421 421
 			id="stripe-payment-data"
422
-			data-panel-label="' . esc_attr( $pay_button_text ) . '"
422
+			data-panel-label="' . esc_attr($pay_button_text) . '"
423 423
 			data-description=""
424
-			data-email="' . esc_attr( $user_email ) . '"
425
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
426
-			data-name="' . esc_attr( $this->statement_descriptor ) . '"
427
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '"
428
-			data-image="' . esc_attr( $this->stripe_checkout_image ) . '"
429
-			data-bitcoin="' . esc_attr( $this->bitcoin ? 'true' : 'false' ) . '"
430
-			data-locale="' . esc_attr( $this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en' ) . '"
431
-			data-three-d-secure="' . esc_attr( $this->three_d_secure ? 'true' : 'false' ) . '"
432
-			data-allow-remember-me="' . esc_attr( $this->saved_cards ? 'true' : 'false' ) . '">';
433
-
434
-		if ( $this->description ) {
435
-			if ( $this->testmode ) {
424
+			data-email="' . esc_attr($user_email) . '"
425
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
426
+			data-name="' . esc_attr($this->statement_descriptor) . '"
427
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '"
428
+			data-image="' . esc_attr($this->stripe_checkout_image) . '"
429
+			data-bitcoin="' . esc_attr($this->bitcoin ? 'true' : 'false') . '"
430
+			data-locale="' . esc_attr($this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en') . '"
431
+			data-three-d-secure="' . esc_attr($this->three_d_secure ? 'true' : 'false') . '"
432
+			data-allow-remember-me="' . esc_attr($this->saved_cards ? 'true' : 'false') . '">';
433
+
434
+		if ($this->description) {
435
+			if ($this->testmode) {
436 436
 				/* translators: link to Stripe testing page */
437
-				$this->description .= ' ' . sprintf( __( 'TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the documentation "<a href="%s" target="_blank">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' );
438
-				$this->description  = trim( $this->description );
437
+				$this->description .= ' ' . sprintf(__('TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the documentation "<a href="%s" target="_blank">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe'), 'https://stripe.com/docs/testing');
438
+				$this->description  = trim($this->description);
439 439
 			}
440
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
440
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description)));
441 441
 		}
442 442
 
443
-		if ( $display_tokenization ) {
443
+		if ($display_tokenization) {
444 444
 			$this->tokenization_script();
445 445
 			$this->saved_payment_methods();
446 446
 		}
447 447
 
448
-		if ( ! $this->stripe_checkout ) {
449
-			if ( apply_filters( 'wc_stripe_use_elements_checkout_form', true ) ) {
448
+		if ( ! $this->stripe_checkout) {
449
+			if (apply_filters('wc_stripe_use_elements_checkout_form', true)) {
450 450
 				$this->elements_form();
451 451
 			} else {
452 452
 				$this->form();
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 			}
455 455
 		}
456 456
 
457
-		if ( apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) {
457
+		if (apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) {
458 458
 			$this->save_payment_method_checkbox();
459 459
 		}
460 460
 
@@ -469,13 +469,13 @@  discard block
 block discarded – undo
469 469
 	 */
470 470
 	public function elements_form() {
471 471
 		?>
472
-		<fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
473
-			<?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?>
472
+		<fieldset id="wc-<?php echo esc_attr($this->id); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
473
+			<?php do_action('woocommerce_credit_card_form_start', $this->id); ?>
474 474
 			<label for="card-element">
475
-				<?php esc_html_e( 'Credit or debit card', 'woocommerce-gateway-stripe' ); ?>
475
+				<?php esc_html_e('Credit or debit card', 'woocommerce-gateway-stripe'); ?>
476 476
 			</label>
477 477
 
478
-			<?php if ( $this->inline_cc_form ) { ?>
478
+			<?php if ($this->inline_cc_form) { ?>
479 479
 				<div id="stripe-card-element" style="background:#f2f2f2;padding:0 1em;box-shadow:inset 0 1px 1px rgba(0,0,0,.125);margin:5px 0;padding:10px 5px;">
480 480
 				<!-- a Stripe Element will be inserted here. -->
481 481
 				</div>
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 
495 495
 			<!-- Used to display form errors -->
496 496
 			<div class="stripe-source-errors" role="alert"></div>
497
-			<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
497
+			<?php do_action('woocommerce_credit_card_form_end', $this->id); ?>
498 498
 			<div class="clear"></div>
499 499
 		</fieldset>
500 500
 		<?php
@@ -507,13 +507,13 @@  discard block
 block discarded – undo
507 507
 	 * @version 3.1.0
508 508
 	 */
509 509
 	public function admin_scripts() {
510
-		if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) {
510
+		if ('woocommerce_page_wc-settings' !== get_current_screen()->id) {
511 511
 			return;
512 512
 		}
513 513
 
514
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
514
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
515 515
 
516
-		wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true );
516
+		wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true);
517 517
 	}
518 518
 
519 519
 	/**
@@ -525,29 +525,29 @@  discard block
 block discarded – undo
525 525
 	 * @version 4.0.0
526 526
 	 */
527 527
 	public function payment_scripts() {
528
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) {
528
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) {
529 529
 			return;
530 530
 		}
531 531
 
532
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
532
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
533 533
 
534
-		wp_register_style( 'stripe_paymentfonts', plugins_url( 'assets/css/stripe-paymentfonts.css', WC_STRIPE_MAIN_FILE ), array(), '1.2.5' );
535
-		wp_enqueue_style( 'stripe_paymentfonts' );
536
-		wp_register_script( 'stripe_checkout', 'https://checkout.stripe.com/checkout.js', '', WC_STRIPE_VERSION, true );
537
-		wp_register_script( 'stripev2', 'https://js.stripe.com/v2/', '', '2.0', true );
538
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
539
-		wp_register_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripev2', 'stripe' ), WC_STRIPE_VERSION, true );
534
+		wp_register_style('stripe_paymentfonts', plugins_url('assets/css/stripe-paymentfonts.css', WC_STRIPE_MAIN_FILE), array(), '1.2.5');
535
+		wp_enqueue_style('stripe_paymentfonts');
536
+		wp_register_script('stripe_checkout', 'https://checkout.stripe.com/checkout.js', '', WC_STRIPE_VERSION, true);
537
+		wp_register_script('stripev2', 'https://js.stripe.com/v2/', '', '2.0', true);
538
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
539
+		wp_register_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripev2', 'stripe'), WC_STRIPE_VERSION, true);
540 540
 
541 541
 		$stripe_params = array(
542 542
 			'key'                  => $this->publishable_key,
543
-			'i18n_terms'           => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ),
544
-			'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ),
543
+			'i18n_terms'           => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'),
544
+			'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'),
545 545
 		);
546 546
 
547 547
 		// If we're on the pay page we need to pass stripe.js the address of the order.
548
-		if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) {
549
-			$order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) );
550
-			$order    = wc_get_order( $order_id );
548
+		if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) {
549
+			$order_id = wc_get_order_id_by_order_key(urldecode($_GET['key']));
550
+			$order    = wc_get_order($order_id);
551 551
 
552 552
 			$stripe_params['billing_first_name'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_first_name : $order->get_billing_first_name();
553 553
 			$stripe_params['billing_last_name']  = WC_Stripe_Helper::is_pre_30() ? $order->billing_last_name : $order->get_billing_last_name();
@@ -559,37 +559,37 @@  discard block
 block discarded – undo
559 559
 			$stripe_params['billing_country']    = WC_Stripe_Helper::is_pre_30() ? $order->billing_country : $order->get_billing_country();
560 560
 		}
561 561
 
562
-		$stripe_params['no_prepaid_card_msg']                     = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
563
-		$stripe_params['no_bank_country_msg']                     = __( 'Please select a country for your bank.', 'woocommerce-gateway-stripe' );
564
-		$stripe_params['no_sepa_owner_msg']                       = __( 'Please enter your IBAN account name.', 'woocommerce-gateway-stripe' );
565
-		$stripe_params['no_sepa_iban_msg']                        = __( 'Please enter your IBAN account number.', 'woocommerce-gateway-stripe' );
566
-		$stripe_params['allow_prepaid_card']                      = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no';
562
+		$stripe_params['no_prepaid_card_msg']                     = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
563
+		$stripe_params['no_bank_country_msg']                     = __('Please select a country for your bank.', 'woocommerce-gateway-stripe');
564
+		$stripe_params['no_sepa_owner_msg']                       = __('Please enter your IBAN account name.', 'woocommerce-gateway-stripe');
565
+		$stripe_params['no_sepa_iban_msg']                        = __('Please enter your IBAN account number.', 'woocommerce-gateway-stripe');
566
+		$stripe_params['allow_prepaid_card']                      = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no';
567 567
 		$stripe_params['inline_cc_form']                          = $this->inline_cc_form ? 'yes' : 'no';
568
-		$stripe_params['stripe_checkout_require_billing_address'] = apply_filters( 'wc_stripe_checkout_require_billing_address', false ) ? 'yes' : 'no';
569
-		$stripe_params['is_checkout']                             = ( is_checkout() && empty( $_GET['pay_for_order'] ) );
568
+		$stripe_params['stripe_checkout_require_billing_address'] = apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'yes' : 'no';
569
+		$stripe_params['is_checkout']                             = (is_checkout() && empty($_GET['pay_for_order']));
570 570
 		$stripe_params['return_url']                              = $this->get_stripe_return_url();
571
-		$stripe_params['ajaxurl']                                 = WC_AJAX::get_endpoint( '%%endpoint%%' );
572
-		$stripe_params['stripe_nonce']                            = wp_create_nonce( '_wc_stripe_nonce' );
571
+		$stripe_params['ajaxurl']                                 = WC_AJAX::get_endpoint('%%endpoint%%');
572
+		$stripe_params['stripe_nonce']                            = wp_create_nonce('_wc_stripe_nonce');
573 573
 		$stripe_params['statement_descriptor']                    = $this->statement_descriptor;
574
-		$stripe_params['use_elements']                            = apply_filters( 'wc_stripe_use_elements_checkout_form', true ) ? 'yes' : 'no';
574
+		$stripe_params['use_elements']                            = apply_filters('wc_stripe_use_elements_checkout_form', true) ? 'yes' : 'no';
575 575
 		$stripe_params['is_stripe_checkout']                      = $this->stripe_checkout ? 'yes' : 'no';
576
-		$stripe_params['is_change_payment_page']                  = ( isset( $_GET['pay_for_order'] ) || isset( $_GET['change_payment_method'] ) ) ? 'yes' : 'no';
576
+		$stripe_params['is_change_payment_page']                  = (isset($_GET['pay_for_order']) || isset($_GET['change_payment_method'])) ? 'yes' : 'no';
577 577
 		$stripe_params['is_add_payment_method_page']              = is_add_payment_method_page() ? 'yes' : 'no';
578
-		$stripe_params['elements_styling']                        = apply_filters( 'wc_stripe_elements_styling', false );
579
-		$stripe_params['elements_classes']                        = apply_filters( 'wc_stripe_elements_classes', false );
578
+		$stripe_params['elements_styling']                        = apply_filters('wc_stripe_elements_styling', false);
579
+		$stripe_params['elements_classes']                        = apply_filters('wc_stripe_elements_classes', false);
580 580
 
581 581
 		// merge localized messages to be use in JS
582
-		$stripe_params = array_merge( $stripe_params, WC_Stripe_Helper::get_localized_messages() );
582
+		$stripe_params = array_merge($stripe_params, WC_Stripe_Helper::get_localized_messages());
583 583
 
584
-		wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
585
-		wp_localize_script( 'woocommerce_stripe_checkout', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
584
+		wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
585
+		wp_localize_script('woocommerce_stripe_checkout', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
586 586
 
587
-		if ( $this->stripe_checkout ) {
588
-			wp_enqueue_script( 'stripe_checkout' );
587
+		if ($this->stripe_checkout) {
588
+			wp_enqueue_script('stripe_checkout');
589 589
 		}
590 590
 
591 591
 		$this->tokenization_script();
592
-		wp_enqueue_script( 'woocommerce_stripe' );
592
+		wp_enqueue_script('woocommerce_stripe');
593 593
 	}
594 594
 
595 595
 	/**
@@ -601,22 +601,22 @@  discard block
 block discarded – undo
601 601
 	 * @param object $source_object
602 602
 	 * @return mixed
603 603
 	 */
604
-	public function create_3ds_source( $order, $source_object ) {
604
+	public function create_3ds_source($order, $source_object) {
605 605
 		$currency                    = WC_Stripe_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency();
606 606
 		$order_id                    = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
607
-		$return_url                  = $this->get_stripe_return_url( $order );
607
+		$return_url                  = $this->get_stripe_return_url($order);
608 608
 
609 609
 		$post_data                   = array();
610
-		$post_data['amount']         = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency );
611
-		$post_data['currency']       = strtolower( $currency );
610
+		$post_data['amount']         = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency);
611
+		$post_data['currency']       = strtolower($currency);
612 612
 		$post_data['type']           = 'three_d_secure';
613
-		$post_data['owner']          = $this->get_owner_details( $order );
614
-		$post_data['three_d_secure'] = array( 'card' => $source_object->id );
615
-		$post_data['redirect']       = array( 'return_url' => $return_url );
613
+		$post_data['owner']          = $this->get_owner_details($order);
614
+		$post_data['three_d_secure'] = array('card' => $source_object->id);
615
+		$post_data['redirect']       = array('return_url' => $return_url);
616 616
 
617
-		WC_Stripe_Logger::log( 'Info: Begin creating 3DS source' );
617
+		WC_Stripe_Logger::log('Info: Begin creating 3DS source');
618 618
 
619
-		return WC_Stripe_API::request( $post_data, 'sources' );
619
+		return WC_Stripe_API::request($post_data, 'sources');
620 620
 	}
621 621
 
622 622
 	/**
@@ -632,46 +632,46 @@  discard block
 block discarded – undo
632 632
 	 *
633 633
 	 * @return array|void
634 634
 	 */
635
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
635
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
636 636
 		try {
637
-			$order          = wc_get_order( $order_id );
638
-			$source_object  = ! empty( $_POST['stripe_source'] ) ? json_decode( wc_clean( stripslashes( $_POST['stripe_source'] ) ) ) : false;
637
+			$order          = wc_get_order($order_id);
638
+			$source_object  = ! empty($_POST['stripe_source']) ? json_decode(wc_clean(stripslashes($_POST['stripe_source']))) : false;
639 639
 
640 640
 			// This comes from the create account checkbox in the checkout page.
641
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
641
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
642 642
 
643
-			if ( $create_account ) {
643
+			if ($create_account) {
644 644
 				$new_customer_id     = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id();
645
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
645
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
646 646
 				$new_stripe_customer->create_customer();
647 647
 			}
648 648
 
649
-			$prepared_source = $this->prepare_source( get_current_user_id(), $force_save_source );
649
+			$prepared_source = $this->prepare_source(get_current_user_id(), $force_save_source);
650 650
 
651 651
 			// Check if we don't allow prepaid credit cards.
652
-			if ( ! apply_filters( 'wc_stripe_allow_prepaid_card', true ) ) {
653
-				$stripe_checkout_object = ! empty( $_POST['stripe_checkout_object'] ) ? json_decode( wc_clean( stripslashes( $_POST['stripe_checkout_object'] ) ) ) : false;
652
+			if ( ! apply_filters('wc_stripe_allow_prepaid_card', true)) {
653
+				$stripe_checkout_object = ! empty($_POST['stripe_checkout_object']) ? json_decode(wc_clean(stripslashes($_POST['stripe_checkout_object']))) : false;
654 654
 
655
-				if ( $stripe_checkout_object && 'token' === $stripe_checkout_object->object && 'prepaid' === $stripe_checkout_object->card->funding ) {
656
-					$error_msg = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
657
-					throw new Exception( $error_msg );
655
+				if ($stripe_checkout_object && 'token' === $stripe_checkout_object->object && 'prepaid' === $stripe_checkout_object->card->funding) {
656
+					$error_msg = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
657
+					throw new Exception($error_msg);
658 658
 				}
659 659
 			}
660 660
 
661
-			if ( empty( $prepared_source->source ) ) {
662
-				$error_msg = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
663
-				throw new Exception( $error_msg );
661
+			if (empty($prepared_source->source)) {
662
+				$error_msg = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
663
+				throw new Exception($error_msg);
664 664
 			}
665 665
 
666 666
 			// Store source to order meta.
667
-			$this->save_source( $order, $prepared_source );
667
+			$this->save_source($order, $prepared_source);
668 668
 
669 669
 			// Result from Stripe API request.
670 670
 			$response = null;
671 671
 
672
-			if ( $order->get_total() > 0 ) {
672
+			if ($order->get_total() > 0) {
673 673
 				// This will throw exception if not valid.
674
-				$this->validate_minimum_order_amount( $order );
674
+				$this->validate_minimum_order_amount($order);
675 675
 
676 676
 				/**
677 677
 				 * Check if card 3DS is required or optional with 3DS setting.
@@ -680,79 +680,79 @@  discard block
 block discarded – undo
680 680
 				 * Note that if we need to save source, the original source must be first
681 681
 				 * attached to a customer in Stripe before it can be charged.
682 682
 				 */
683
-				if ( $source_object && ( 'card' === $source_object->type && 'required' === $source_object->card->three_d_secure || ( $this->three_d_secure && 'optional' === $source_object->card->three_d_secure ) ) ) {
683
+				if ($source_object && ('card' === $source_object->type && 'required' === $source_object->card->three_d_secure || ($this->three_d_secure && 'optional' === $source_object->card->three_d_secure))) {
684 684
 
685
-					$response = $this->create_3ds_source( $order, $source_object );
685
+					$response = $this->create_3ds_source($order, $source_object);
686 686
 
687
-					if ( ! empty( $response->error ) ) {
687
+					if ( ! empty($response->error)) {
688 688
 						$message = $response->error->message;
689 689
 
690
-						$order->add_order_note( $message );
690
+						$order->add_order_note($message);
691 691
 
692
-						throw new Exception( $message );
692
+						throw new Exception($message);
693 693
 					}
694 694
 
695 695
 					// Update order meta with 3DS source.
696
-					if ( WC_Stripe_Helper::is_pre_30() ) {
697
-						update_post_meta( $order_id, '_stripe_source_id', $response->id );
696
+					if (WC_Stripe_Helper::is_pre_30()) {
697
+						update_post_meta($order_id, '_stripe_source_id', $response->id);
698 698
 					} else {
699
-						$order->update_meta_data( '_stripe_source_id', $response->id );
699
+						$order->update_meta_data('_stripe_source_id', $response->id);
700 700
 						$order->save();
701 701
 					}
702 702
 
703
-					WC_Stripe_Logger::log( 'Info: Redirecting to 3DS...' );
703
+					WC_Stripe_Logger::log('Info: Redirecting to 3DS...');
704 704
 
705 705
 					return array(
706 706
 						'result'   => 'success',
707
-						'redirect' => esc_url_raw( $response->redirect->url ),
707
+						'redirect' => esc_url_raw($response->redirect->url),
708 708
 					);
709 709
 				}
710 710
 
711
-				WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
711
+				WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
712 712
 
713 713
 				// Make the request.
714
-				$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $prepared_source ) );
714
+				$response = WC_Stripe_API::request($this->generate_payment_request($order, $prepared_source));
715 715
 
716
-				if ( ! empty( $response->error ) ) {
716
+				if ( ! empty($response->error)) {
717 717
 					// If it is an API error such connection or server, let's retry.
718
-					if ( 'api_connection_error' === $response->error->type || 'api_error' === $response->error->type ) {
719
-						if ( $retry ) {
720
-							sleep( 5 );
721
-							return $this->process_payment( $order_id, false, $force_save_source );
718
+					if ('api_connection_error' === $response->error->type || 'api_error' === $response->error->type) {
719
+						if ($retry) {
720
+							sleep(5);
721
+							return $this->process_payment($order_id, false, $force_save_source);
722 722
 						} else {
723 723
 							$message = 'API connection error and retries exhausted.';
724
-							$order->add_order_note( $message );
725
-							throw new Exception( $message );
724
+							$order->add_order_note($message);
725
+							throw new Exception($message);
726 726
 						}
727 727
 					}
728 728
 
729 729
 					// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
730
-					if ( preg_match( '/No such customer/i', $response->error->message ) && $retry ) {
731
-						delete_user_meta( WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(), '_stripe_customer_id' );
730
+					if (preg_match('/No such customer/i', $response->error->message) && $retry) {
731
+						delete_user_meta(WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(), '_stripe_customer_id');
732 732
 
733
-						return $this->process_payment( $order_id, false, $force_save_source );
734
-					} elseif ( preg_match( '/No such token/i', $response->error->message ) && $prepared_source->token_id ) {
733
+						return $this->process_payment($order_id, false, $force_save_source);
734
+					} elseif (preg_match('/No such token/i', $response->error->message) && $prepared_source->token_id) {
735 735
 						// Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message.
736
-						$wc_token = WC_Payment_Tokens::get( $prepared_source->token_id );
736
+						$wc_token = WC_Payment_Tokens::get($prepared_source->token_id);
737 737
 						$wc_token->delete();
738
-						$message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' );
739
-						$order->add_order_note( $message );
740
-						throw new Exception( $message );
738
+						$message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe');
739
+						$order->add_order_note($message);
740
+						throw new Exception($message);
741 741
 					}
742 742
 
743 743
 					$localized_messages = WC_Stripe_Helper::get_localized_messages();
744 744
 
745
-					$message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
745
+					$message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
746 746
 
747
-					$order->add_order_note( $message );
747
+					$order->add_order_note($message);
748 748
 
749
-					throw new Exception( $message );
749
+					throw new Exception($message);
750 750
 				}
751 751
 
752
-				do_action( 'wc_gateway_stripe_process_payment', $response, $order );
752
+				do_action('wc_gateway_stripe_process_payment', $response, $order);
753 753
 
754 754
 				// Process valid response.
755
-				$this->process_response( $response, $order );
755
+				$this->process_response($response, $order);
756 756
 			} else {
757 757
 				$order->payment_complete();
758 758
 			}
@@ -763,17 +763,17 @@  discard block
 block discarded – undo
763 763
 			// Return thank you page redirect.
764 764
 			return array(
765 765
 				'result'   => 'success',
766
-				'redirect' => $this->get_return_url( $order ),
766
+				'redirect' => $this->get_return_url($order),
767 767
 			);
768 768
 
769
-		} catch ( Exception $e ) {
770
-			wc_add_notice( $e->getMessage(), 'error' );
771
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
769
+		} catch (Exception $e) {
770
+			wc_add_notice($e->getMessage(), 'error');
771
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
772 772
 
773
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
773
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
774 774
 
775
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
776
-				$this->send_failed_order_email( $order_id );
775
+			if ($order->has_status(array('pending', 'failed'))) {
776
+				$this->send_failed_order_email($order_id);
777 777
 			}
778 778
 
779 779
 			return array(
Please login to merge, or discard this patch.
includes/class-wc-stripe-order-handler.php 1 patch
Spacing   +167 added lines, -167 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
 
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 	public function __construct() {
21 21
 		self::$_this = $this;
22 22
 
23
-		add_action( 'wp', array( $this, 'maybe_process_redirect_order' ) );
24
-		add_action( 'woocommerce_order_status_on-hold_to_processing', array( $this, 'capture_payment' ) );
25
-		add_action( 'woocommerce_order_status_on-hold_to_completed', array( $this, 'capture_payment' ) );
26
-		add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'cancel_payment' ) );
27
-		add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'cancel_payment' ) );
28
-		add_action( 'wc_ajax_wc_stripe_validate_checkout', array( $this, 'validate_checkout' ) );
23
+		add_action('wp', array($this, 'maybe_process_redirect_order'));
24
+		add_action('woocommerce_order_status_on-hold_to_processing', array($this, 'capture_payment'));
25
+		add_action('woocommerce_order_status_on-hold_to_completed', array($this, 'capture_payment'));
26
+		add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'cancel_payment'));
27
+		add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'cancel_payment'));
28
+		add_action('wc_ajax_wc_stripe_validate_checkout', array($this, 'validate_checkout'));
29 29
 	}
30 30
 
31 31
 	/**
@@ -46,25 +46,25 @@  discard block
 block discarded – undo
46 46
 	 * @since 4.0.0
47 47
 	 * @version 4.0.0
48 48
 	 */
49
-	public function process_redirect_payment( $order_id, $retry = true ) {
49
+	public function process_redirect_payment($order_id, $retry = true) {
50 50
 		try {
51
-			$source = wc_clean( $_GET['source'] );
51
+			$source = wc_clean($_GET['source']);
52 52
 
53
-			if ( empty( $source ) ) {
53
+			if (empty($source)) {
54 54
 				return;
55 55
 			}
56 56
 
57
-			if ( empty( $order_id ) ) {
57
+			if (empty($order_id)) {
58 58
 				return;
59 59
 			}
60 60
 
61
-			$order = wc_get_order( $order_id );
61
+			$order = wc_get_order($order_id);
62 62
 
63
-			if ( ! is_object( $order ) ) {
63
+			if ( ! is_object($order)) {
64 64
 				return;
65 65
 			}
66 66
 
67
-			if ( 'processing' === $order->get_status() || 'completed' === $order->get_status() || 'on-hold' === $order->get_status() ) {
67
+			if ('processing' === $order->get_status() || 'completed' === $order->get_status() || 'on-hold' === $order->get_status()) {
68 68
 				return;
69 69
 			}
70 70
 
@@ -72,97 +72,97 @@  discard block
 block discarded – undo
72 72
 			$response = null;
73 73
 
74 74
 			// This will throw exception if not valid.
75
-			$this->validate_minimum_order_amount( $order );
75
+			$this->validate_minimum_order_amount($order);
76 76
 
77
-			WC_Stripe_Logger::log( "Info: (Redirect) Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
77
+			WC_Stripe_Logger::log("Info: (Redirect) Begin processing payment for order $order_id for the amount of {$order->get_total()}");
78 78
 
79 79
 			// Prep source object.
80 80
 			$source_object           = new stdClass();
81 81
 			$source_object->token_id = '';
82
-			$source_object->customer = $this->get_stripe_customer_id( $order );
82
+			$source_object->customer = $this->get_stripe_customer_id($order);
83 83
 			$source_object->source   = $source;
84 84
 
85 85
 			/**
86 86
 			 * First check if the source is chargeable at this time. If not,
87 87
 			 * webhook will take care of it later.
88 88
 			 */
89
-			$source_info = WC_Stripe_API::retrieve( 'sources/' . $source );
89
+			$source_info = WC_Stripe_API::retrieve('sources/' . $source);
90 90
 
91
-			if ( ! empty( $source_info->error ) ) {
92
-				throw new Exception( $source_info->error->message );
91
+			if ( ! empty($source_info->error)) {
92
+				throw new Exception($source_info->error->message);
93 93
 			}
94 94
 
95
-			if ( 'failed' === $source_info->status || 'canceled' === $source_info->status ) {
96
-				throw new Exception( __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ) );
95
+			if ('failed' === $source_info->status || 'canceled' === $source_info->status) {
96
+				throw new Exception(__('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe'));
97 97
 			}
98 98
 
99 99
 			// If already consumed, then ignore request.
100
-			if ( 'consumed' === $source_info->status ) {
100
+			if ('consumed' === $source_info->status) {
101 101
 				return;
102 102
 			}
103 103
 
104 104
 			// If not chargeable, then ignore request.
105
-			if ( 'chargeable' !== $source_info->status ) {
105
+			if ('chargeable' !== $source_info->status) {
106 106
 				return;
107 107
 			}
108 108
 
109 109
 			// Make the request.
110
-			$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source_object ) );
110
+			$response = WC_Stripe_API::request($this->generate_payment_request($order, $source_object));
111 111
 
112
-			if ( ! empty( $response->error ) ) {
112
+			if ( ! empty($response->error)) {
113 113
 				// If it is an API error such connection or server, let's retry.
114
-				if ( 'api_connection_error' === $response->error->type || 'api_error' === $response->error->type ) {
115
-					if ( $retry ) {
116
-						sleep( 5 );
117
-						return $this->process_redirect_payment( $order_id, false );
114
+				if ('api_connection_error' === $response->error->type || 'api_error' === $response->error->type) {
115
+					if ($retry) {
116
+						sleep(5);
117
+						return $this->process_redirect_payment($order_id, false);
118 118
 					} else {
119 119
 						$message = 'API connection error and retries exhausted.';
120
-						$order->add_order_note( $message );
121
-						throw new Exception( $message );
120
+						$order->add_order_note($message);
121
+						throw new Exception($message);
122 122
 					}
123 123
 				}
124 124
 
125 125
 				// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
126
-				if ( preg_match( '/No such customer/i', $response->error->message ) && $retry ) {
127
-					delete_user_meta( WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(), '_stripe_customer_id' );
126
+				if (preg_match('/No such customer/i', $response->error->message) && $retry) {
127
+					delete_user_meta(WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(), '_stripe_customer_id');
128 128
 
129
-					return $this->process_redirect_payment( $order_id, false );
129
+					return $this->process_redirect_payment($order_id, false);
130 130
 
131
-				} elseif ( preg_match( '/No such token/i', $response->error->message ) && $source_object->token_id ) {
131
+				} elseif (preg_match('/No such token/i', $response->error->message) && $source_object->token_id) {
132 132
 					// Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message.
133 133
 
134
-					$wc_token = WC_Payment_Tokens::get( $source_object->token_id );
134
+					$wc_token = WC_Payment_Tokens::get($source_object->token_id);
135 135
 					$wc_token->delete();
136
-					$message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' );
137
-					$order->add_order_note( $message );
138
-					throw new Exception( $message );
136
+					$message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe');
137
+					$order->add_order_note($message);
138
+					throw new Exception($message);
139 139
 				}
140 140
 
141 141
 				$localized_messages = WC_Stripe_Helper::get_localized_messages();
142 142
 
143
-				$message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
143
+				$message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
144 144
 
145
-				throw new Exception( $message );
145
+				throw new Exception($message);
146 146
 			}
147 147
 
148
-			do_action( 'wc_gateway_stripe_process_redirect_payment', $response, $order );
148
+			do_action('wc_gateway_stripe_process_redirect_payment', $response, $order);
149 149
 
150
-			$this->process_response( $response, $order );
150
+			$this->process_response($response, $order);
151 151
 
152
-		} catch ( Exception $e ) {
153
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
152
+		} catch (Exception $e) {
153
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
154 154
 
155
-			do_action( 'wc_gateway_stripe_process_redirect_payment_error', $e, $order );
155
+			do_action('wc_gateway_stripe_process_redirect_payment_error', $e, $order);
156 156
 
157 157
 			/* translators: error message */
158
-			$order->update_status( 'failed', sprintf( __( 'Stripe payment failed: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) );
158
+			$order->update_status('failed', sprintf(__('Stripe payment failed: %s', 'woocommerce-gateway-stripe'), $e->getMessage()));
159 159
 
160
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
161
-				$this->send_failed_order_email( $order_id );
160
+			if ($order->has_status(array('pending', 'failed'))) {
161
+				$this->send_failed_order_email($order_id);
162 162
 			}
163 163
 
164
-			wc_add_notice( $e->getMessage(), 'error' );
165
-			wp_safe_redirect( wc_get_checkout_url() );
164
+			wc_add_notice($e->getMessage(), 'error');
165
+			wp_safe_redirect(wc_get_checkout_url());
166 166
 			exit;
167 167
 		}
168 168
 	}
@@ -174,13 +174,13 @@  discard block
 block discarded – undo
174 174
 	 * @version 4.0.0
175 175
 	 */
176 176
 	public function maybe_process_redirect_order() {
177
-		if ( ! is_order_received_page() || empty( $_GET['client_secret'] ) || empty( $_GET['source'] ) ) {
177
+		if ( ! is_order_received_page() || empty($_GET['client_secret']) || empty($_GET['source'])) {
178 178
 			return;
179 179
 		}
180 180
 
181
-		$order_id = wc_clean( $_GET['order_id'] );
181
+		$order_id = wc_clean($_GET['order_id']);
182 182
 
183
-		$this->process_redirect_payment( $order_id );
183
+		$this->process_redirect_payment($order_id);
184 184
 	}
185 185
 
186 186
 	/**
@@ -190,52 +190,52 @@  discard block
 block discarded – undo
190 190
 	 * @version 4.0.0
191 191
 	 * @param  int $order_id
192 192
 	 */
193
-	public function capture_payment( $order_id ) {
194
-		$order = wc_get_order( $order_id );
193
+	public function capture_payment($order_id) {
194
+		$order = wc_get_order($order_id);
195 195
 
196
-		if ( 'stripe' === ( WC_Stripe_Helper::is_pre_30() ? $order->payment_method : $order->get_payment_method() ) ) {
197
-			$charge   = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, '_transaction_id', true ) : $order->get_transaction_id();
198
-			$captured = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, '_stripe_charge_captured', true ) : $order->get_meta( '_stripe_charge_captured', true );
196
+		if ('stripe' === (WC_Stripe_Helper::is_pre_30() ? $order->payment_method : $order->get_payment_method())) {
197
+			$charge   = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, '_transaction_id', true) : $order->get_transaction_id();
198
+			$captured = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, '_stripe_charge_captured', true) : $order->get_meta('_stripe_charge_captured', true);
199 199
 
200
-			if ( $charge && 'no' === $captured ) {
200
+			if ($charge && 'no' === $captured) {
201 201
 				$order_total = $order->get_total();
202 202
 
203
-				if ( 0 < $order->get_total_refunded() ) {
203
+				if (0 < $order->get_total_refunded()) {
204 204
 					$order_total = $order_total - $order->get_total_refunded();
205 205
 				}
206 206
 
207
-				$result = WC_Stripe_API::request( array(
208
-					'amount'   => WC_Stripe_Helper::get_stripe_amount( $order_total ),
207
+				$result = WC_Stripe_API::request(array(
208
+					'amount'   => WC_Stripe_Helper::get_stripe_amount($order_total),
209 209
 					'expand[]' => 'balance_transaction',
210
-				), 'charges/' . $charge . '/capture' );
210
+				), 'charges/' . $charge . '/capture');
211 211
 
212
-				if ( ! empty( $result->error ) ) {
212
+				if ( ! empty($result->error)) {
213 213
 					/* translators: error message */
214
-					$order->update_status( 'failed', sprintf( __( 'Unable to capture charge! %s', 'woocommerce-gateway-stripe' ), $result->error->message ) );
214
+					$order->update_status('failed', sprintf(__('Unable to capture charge! %s', 'woocommerce-gateway-stripe'), $result->error->message));
215 215
 				} else {
216 216
 					/* translators: transaction id */
217
-					$order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $result->id ) );
218
-					WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, '_stripe_charge_captured', 'yes' ) : $order->update_meta_data( '_stripe_charge_captured', 'yes' );
217
+					$order->add_order_note(sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $result->id));
218
+					WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, '_stripe_charge_captured', 'yes') : $order->update_meta_data('_stripe_charge_captured', 'yes');
219 219
 
220 220
 					// Store other data such as fees
221
-					WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, '_transaction_id', $result->id ) : $order->set_transaction_id( $result->id );
221
+					WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, '_transaction_id', $result->id) : $order->set_transaction_id($result->id);
222 222
 
223
-					if ( isset( $result->balance_transaction ) && isset( $result->balance_transaction->fee ) ) {
223
+					if (isset($result->balance_transaction) && isset($result->balance_transaction->fee)) {
224 224
 						// Fees and Net needs to both come from Stripe to be accurate as the returned
225 225
 						// values are in the local currency of the Stripe account, not from WC.
226
-						$fee = ! empty( $result->balance_transaction->fee ) ? WC_Stripe_Helper::format_balance_fee( $result->balance_transaction, 'fee' ) : 0;
227
-						$net = ! empty( $result->balance_transaction->net ) ? WC_Stripe_Helper::format_balance_fee( $result->balance_transaction, 'net' ) : 0;
228
-						WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, parent::META_NAME_FEE, $fee ) : $order->update_meta_data( parent::META_NAME_FEE, $fee );
229
-						WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, parent::META_NAME_NET, $net ) : $order->update_meta_data( parent::META_NAME_NET, $net );
226
+						$fee = ! empty($result->balance_transaction->fee) ? WC_Stripe_Helper::format_balance_fee($result->balance_transaction, 'fee') : 0;
227
+						$net = ! empty($result->balance_transaction->net) ? WC_Stripe_Helper::format_balance_fee($result->balance_transaction, 'net') : 0;
228
+						WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, parent::META_NAME_FEE, $fee) : $order->update_meta_data(parent::META_NAME_FEE, $fee);
229
+						WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, parent::META_NAME_NET, $net) : $order->update_meta_data(parent::META_NAME_NET, $net);
230 230
 					}
231 231
 
232
-					if ( is_callable( array( $order, 'save' ) ) ) {
232
+					if (is_callable(array($order, 'save'))) {
233 233
 						$order->save();
234 234
 					}
235 235
 				}
236 236
 
237 237
 				// This hook fires when admin manually changes order status to processing or completed.
238
-				do_action( 'woocommerce_stripe_process_manual_capture', $order, $result );
238
+				do_action('woocommerce_stripe_process_manual_capture', $order, $result);
239 239
 			}
240 240
 		}
241 241
 	}
@@ -247,32 +247,32 @@  discard block
 block discarded – undo
247 247
 	 * @version 4.0.0
248 248
 	 * @param  int $order_id
249 249
 	 */
250
-	public function cancel_payment( $order_id ) {
251
-		$order = wc_get_order( $order_id );
250
+	public function cancel_payment($order_id) {
251
+		$order = wc_get_order($order_id);
252 252
 
253
-		if ( 'stripe' === ( WC_Stripe_Helper::is_pre_30() ? $order->payment_method : $order->get_payment_method() ) ) {
254
-			$charge_id = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, '_transaction_id', true ) : $order->get_transaction_id();
253
+		if ('stripe' === (WC_Stripe_Helper::is_pre_30() ? $order->payment_method : $order->get_payment_method())) {
254
+			$charge_id = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, '_transaction_id', true) : $order->get_transaction_id();
255 255
 
256
-			if ( $charge_id ) {
257
-				$result = WC_Stripe_API::request( array(
258
-					'amount' => WC_Stripe_Helper::get_stripe_amount( $order->get_total() ),
259
-				), 'charges/' . $charge_id . '/refund' );
256
+			if ($charge_id) {
257
+				$result = WC_Stripe_API::request(array(
258
+					'amount' => WC_Stripe_Helper::get_stripe_amount($order->get_total()),
259
+				), 'charges/' . $charge_id . '/refund');
260 260
 
261
-				if ( ! empty( $result->error ) ) {
262
-					$order->add_order_note( __( 'Unable to refund charge!', 'woocommerce-gateway-stripe' ) . ' ' . $result->error->message );
261
+				if ( ! empty($result->error)) {
262
+					$order->add_order_note(__('Unable to refund charge!', 'woocommerce-gateway-stripe') . ' ' . $result->error->message);
263 263
 				} else {
264 264
 					/* translators: transaction id */
265
-					$order->add_order_note( sprintf( __( 'Stripe charge refunded (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $result->id ) );
266
-					WC_Stripe_Helper::is_pre_30() ? delete_post_meta( $order_id, '_stripe_charge_captured' ) : $order->delete_meta_data( '_stripe_charge_captured' );
267
-					WC_Stripe_Helper::is_pre_30() ? delete_post_meta( $order_id, '_transaction_id' ) : $order->delete_meta_data( '_stripe_transaction_id' );
265
+					$order->add_order_note(sprintf(__('Stripe charge refunded (Charge ID: %s)', 'woocommerce-gateway-stripe'), $result->id));
266
+					WC_Stripe_Helper::is_pre_30() ? delete_post_meta($order_id, '_stripe_charge_captured') : $order->delete_meta_data('_stripe_charge_captured');
267
+					WC_Stripe_Helper::is_pre_30() ? delete_post_meta($order_id, '_transaction_id') : $order->delete_meta_data('_stripe_transaction_id');
268 268
 
269
-					if ( is_callable( array( $order, 'save' ) ) ) {
269
+					if (is_callable(array($order, 'save'))) {
270 270
 						$order->save();
271 271
 					}
272 272
 				}
273 273
 
274 274
 				// This hook fires when admin manually changes order status to cancel.
275
-				do_action( 'woocommerce_stripe_process_manual_cancel', $order, $result );
275
+				do_action('woocommerce_stripe_process_manual_cancel', $order, $result);
276 276
 			}
277 277
 		}
278 278
 	}
@@ -285,17 +285,17 @@  discard block
 block discarded – undo
285 285
 	 * @param string $field
286 286
 	 * @return string $error_field
287 287
 	 */
288
-	public function normalize_field( $field ) {
288
+	public function normalize_field($field) {
289 289
 		$checkout_fields = WC()->checkout->get_checkout_fields();
290 290
 		$org_str         = array();
291 291
 		$replace_str     = array();
292 292
 
293
-		if ( array_key_exists( $field, $checkout_fields['billing'] ) ) {
294
-			$error_field = $checkout_fields['billing'][ $field ]['label'];
295
-		} elseif ( array_key_exists( $field, $checkout_fields['shipping'] ) ) {
296
-			$error_field = $checkout_fields['shipping'][ $field ]['label'];
293
+		if (array_key_exists($field, $checkout_fields['billing'])) {
294
+			$error_field = $checkout_fields['billing'][$field]['label'];
295
+		} elseif (array_key_exists($field, $checkout_fields['shipping'])) {
296
+			$error_field = $checkout_fields['shipping'][$field]['label'];
297 297
 		} else {
298
-			$error_field = str_replace( '_', ' ', $field );
298
+			$error_field = str_replace('_', ' ', $field);
299 299
 
300 300
 			$org_str[]     = 'stripe';
301 301
 			$replace_str[] = '';
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
 			$replace_str[] = 'SOFORT';
311 311
 
312 312
 			$org_str[]     = 'owner';
313
-			$replace_str[] = __( 'Owner', 'woocommerce-gateway-stripe' );
313
+			$replace_str[] = __('Owner', 'woocommerce-gateway-stripe');
314 314
 
315
-			$error_field   = str_replace( $org_str, $replace_str, $error_field );
315
+			$error_field   = str_replace($org_str, $replace_str, $error_field);
316 316
 		}
317 317
 
318 318
 		return $error_field;
@@ -325,154 +325,154 @@  discard block
 block discarded – undo
325 325
 	 * @version 4.0.0
326 326
 	 */
327 327
 	public function validate_checkout() {
328
-		if ( ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_nonce' ) ) {
329
-			wp_die( __( 'Cheatin&#8217; huh?', 'woocommerce-gateway-stripe' ) );
328
+		if ( ! wp_verify_nonce($_POST['nonce'], '_wc_stripe_nonce')) {
329
+			wp_die(__('Cheatin&#8217; huh?', 'woocommerce-gateway-stripe'));
330 330
 		}
331 331
 
332 332
 		$errors = new WP_Error();
333
-		parse_str( $_POST['required_fields'], $required_fields );
334
-		parse_str( $_POST['all_fields'], $all_fields );
335
-		$source_type = isset( $_POST['source_type'] ) ? wc_clean( $_POST['source_type'] ) : '';
333
+		parse_str($_POST['required_fields'], $required_fields);
334
+		parse_str($_POST['all_fields'], $all_fields);
335
+		$source_type = isset($_POST['source_type']) ? wc_clean($_POST['source_type']) : '';
336 336
 		$validate_shipping_fields = false;
337 337
 		$create_account = false;
338 338
 
339
-		array_walk_recursive( $required_fields, 'wc_clean' );
340
-		array_walk_recursive( $all_fields, 'wc_clean' );
339
+		array_walk_recursive($required_fields, 'wc_clean');
340
+		array_walk_recursive($all_fields, 'wc_clean');
341 341
 
342 342
 		// Remove unneeded required fields depending on source type.
343
-		if ( 'stripe_sepa' !== $source_type ) {
344
-			unset( $required_fields['stripe_sepa_owner'] );
345
-			unset( $required_fields['stripe_sepa_iban'] );
343
+		if ('stripe_sepa' !== $source_type) {
344
+			unset($required_fields['stripe_sepa_owner']);
345
+			unset($required_fields['stripe_sepa_iban']);
346 346
 		}
347 347
 
348
-		if ( 'stripe_sofort' !== $source_type ) {
349
-			unset( $required_fields['stripe_sofort_bank_country'] );
348
+		if ('stripe_sofort' !== $source_type) {
349
+			unset($required_fields['stripe_sofort_bank_country']);
350 350
 		}
351 351
 
352 352
 		/**
353 353
 		 * If ship to different address checkbox is checked then we need
354 354
 		 * to validate shipping fields too.
355 355
 		 */
356
-		if ( isset( $all_fields['ship_to_different_address'] ) ) {
356
+		if (isset($all_fields['ship_to_different_address'])) {
357 357
 			$validate_shipping_fields = true;
358 358
 		}
359 359
 
360 360
 		// Check if createaccount is checked.
361
-		if ( isset( $all_fields['createaccount'] ) ) {
361
+		if (isset($all_fields['createaccount'])) {
362 362
 			$create_account = true;
363 363
 		}
364 364
 
365 365
 		// Check if required fields are empty.
366
-		foreach ( $required_fields as $field => $field_value ) {
366
+		foreach ($required_fields as $field => $field_value) {
367 367
 			// Check for shipping field.
368
-			if ( preg_match( '/^shipping_/', $field ) && ! $validate_shipping_fields ) {
368
+			if (preg_match('/^shipping_/', $field) && ! $validate_shipping_fields) {
369 369
 				continue;
370 370
 			}
371 371
 
372 372
 			// Check create account name.
373
-			if ( 'account_username' === $field && ! $create_account ) {
373
+			if ('account_username' === $field && ! $create_account) {
374 374
 				continue;
375 375
 			}
376 376
 
377 377
 			// Check create account password.
378
-			if ( 'account_password' === $field && ! $create_account ) {
378
+			if ('account_password' === $field && ! $create_account) {
379 379
 				continue;
380 380
 			}
381 381
 
382 382
 			// Check if is SEPA.
383
-			if ( 'stripe_sepa' !== $source_type && 'stripe_sepa_owner' === $field ) {
383
+			if ('stripe_sepa' !== $source_type && 'stripe_sepa_owner' === $field) {
384 384
 				continue;
385 385
 			}
386 386
 
387
-			if ( 'stripe_sepa' !== $source_type && 'stripe_sepa_iban' === $field ) {
387
+			if ('stripe_sepa' !== $source_type && 'stripe_sepa_iban' === $field) {
388 388
 				$continue;
389 389
 			}
390 390
 
391
-			if ( empty( $field_value ) || '-1' === $field_value ) {
392
-				$error_field = $this->normalize_field( $field );
391
+			if (empty($field_value) || '-1' === $field_value) {
392
+				$error_field = $this->normalize_field($field);
393 393
 				/* translators: error field name */
394
-				$errors->add( 'validation', sprintf( __( '%s cannot be empty', 'woocommerce-gateway-stripe' ), $error_field ) );
394
+				$errors->add('validation', sprintf(__('%s cannot be empty', 'woocommerce-gateway-stripe'), $error_field));
395 395
 			}
396 396
 		}
397 397
 
398 398
 		// Check if email is valid format.
399
-		if ( ! empty( $required_fields['billing_email'] ) && ! is_email( $required_fields['billing_email'] ) ) {
400
-			$errors->add( 'validation', __( 'Email is not valid', 'woocommerce-gateway-stripe' ) );
399
+		if ( ! empty($required_fields['billing_email']) && ! is_email($required_fields['billing_email'])) {
400
+			$errors->add('validation', __('Email is not valid', 'woocommerce-gateway-stripe'));
401 401
 		}
402 402
 
403 403
 		// Check if phone number is valid format.
404
-		if ( ! empty( $required_fields['billing_phone'] ) ) {
405
-			$phone = wc_format_phone_number( $required_fields['billing_phone'] );
404
+		if ( ! empty($required_fields['billing_phone'])) {
405
+			$phone = wc_format_phone_number($required_fields['billing_phone']);
406 406
 
407
-			if ( '' !== $phone && ! WC_Validation::is_phone( $phone ) ) {
407
+			if ('' !== $phone && ! WC_Validation::is_phone($phone)) {
408 408
 				/* translators: %s: phone number */
409
-				$errors->add( 'validation', __( 'Please enter a valid phone number.', 'woocommerce-gateway-stripe' ) );
409
+				$errors->add('validation', __('Please enter a valid phone number.', 'woocommerce-gateway-stripe'));
410 410
 			}
411 411
 		}
412 412
 
413 413
 		// Check if postal code is valid format.
414
-		if ( ! empty( $required_fields['billing_postcode'] ) ) {
415
-			$country = isset( $required_fields['billing_country'] ) ? $required_fields['billing_country'] : WC()->customer->get_billing_country();
416
-			$postcode = wc_format_postcode( $required_fields['billing_postcode'], $country );
414
+		if ( ! empty($required_fields['billing_postcode'])) {
415
+			$country = isset($required_fields['billing_country']) ? $required_fields['billing_country'] : WC()->customer->get_billing_country();
416
+			$postcode = wc_format_postcode($required_fields['billing_postcode'], $country);
417 417
 
418
-			if ( '' !== $required_fields['billing_postcode'] && ! WC_Validation::is_postcode( $postcode, $country ) ) {
419
-				$errors->add( 'validation', __( 'Please enter a valid billing postcode / ZIP.', 'woocommerce-gateway-stripe' ) );
418
+			if ('' !== $required_fields['billing_postcode'] && ! WC_Validation::is_postcode($postcode, $country)) {
419
+				$errors->add('validation', __('Please enter a valid billing postcode / ZIP.', 'woocommerce-gateway-stripe'));
420 420
 			}
421 421
 		}
422 422
 
423 423
 		// Don't check this on add payment method page.
424
-		if ( ( isset( $_POST['is_add_payment_page'] ) && 'no' === $_POST['is_add_payment_page'] ) ) {
425
-			if ( empty( $all_fields['woocommerce_checkout_update_totals'] ) && empty( $all_fields['terms'] ) && apply_filters( 'woocommerce_checkout_show_terms', wc_get_page_id( 'terms' ) > 0 ) ) {
426
-				$errors->add( 'terms', __( 'You must accept our Terms &amp; Conditions.', 'woocommerce-gateway-stripe' ) );
424
+		if ((isset($_POST['is_add_payment_page']) && 'no' === $_POST['is_add_payment_page'])) {
425
+			if (empty($all_fields['woocommerce_checkout_update_totals']) && empty($all_fields['terms']) && apply_filters('woocommerce_checkout_show_terms', wc_get_page_id('terms') > 0)) {
426
+				$errors->add('terms', __('You must accept our Terms &amp; Conditions.', 'woocommerce-gateway-stripe'));
427 427
 			}
428 428
 		}
429 429
 
430
-		if ( WC()->cart->needs_shipping() && $validate_shipping_fields ) {
430
+		if (WC()->cart->needs_shipping() && $validate_shipping_fields) {
431 431
 			// Check if postal code is valid format.
432
-			if ( ! empty( $required_fields['shipping_postcode'] ) ) {
433
-				$country = isset( $required_fields['shipping_country'] ) ? $required_fields['shipping_country'] : WC()->customer->get_shipping_country();
434
-				$postcode = wc_format_postcode( $required_fields['shipping_postcode'], $country );
432
+			if ( ! empty($required_fields['shipping_postcode'])) {
433
+				$country = isset($required_fields['shipping_country']) ? $required_fields['shipping_country'] : WC()->customer->get_shipping_country();
434
+				$postcode = wc_format_postcode($required_fields['shipping_postcode'], $country);
435 435
 
436
-				if ( '' !== $required_fields['shipping_postcode'] && ! WC_Validation::is_postcode( $postcode, $country ) ) {
437
-					$errors->add( 'validation', __( 'Please enter a valid shipping postcode / ZIP.', 'woocommerce-gateway-stripe' ) );
436
+				if ('' !== $required_fields['shipping_postcode'] && ! WC_Validation::is_postcode($postcode, $country)) {
437
+					$errors->add('validation', __('Please enter a valid shipping postcode / ZIP.', 'woocommerce-gateway-stripe'));
438 438
 				}
439 439
 			}
440 440
 		}
441 441
 
442
-		if ( WC()->cart->needs_shipping() ) {
442
+		if (WC()->cart->needs_shipping()) {
443 443
 			$shipping_country = WC()->customer->get_shipping_country();
444 444
 
445
-			if ( empty( $shipping_country ) ) {
446
-				$errors->add( 'shipping', __( 'Please enter an address to continue.', 'woocommerce-gateway-stripe' ) );
447
-			} elseif ( ! in_array( WC()->customer->get_shipping_country(), array_keys( WC()->countries->get_shipping_countries() ) ) ) {
445
+			if (empty($shipping_country)) {
446
+				$errors->add('shipping', __('Please enter an address to continue.', 'woocommerce-gateway-stripe'));
447
+			} elseif ( ! in_array(WC()->customer->get_shipping_country(), array_keys(WC()->countries->get_shipping_countries()))) {
448 448
 				/* translators: country name */
449
-				$errors->add( 'shipping', sprintf( __( 'Unfortunately <strong>we do not ship %s</strong>. Please enter an alternative shipping address.', 'woocommerce-gateway-stripe' ), WC()->countries->shipping_to_prefix() . ' ' . WC()->customer->get_shipping_country() ) );
449
+				$errors->add('shipping', sprintf(__('Unfortunately <strong>we do not ship %s</strong>. Please enter an alternative shipping address.', 'woocommerce-gateway-stripe'), WC()->countries->shipping_to_prefix() . ' ' . WC()->customer->get_shipping_country()));
450 450
 			} else {
451
-				$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
451
+				$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
452 452
 
453
-				foreach ( WC()->shipping->get_packages() as $i => $package ) {
454
-					if ( ! isset( $chosen_shipping_methods[ $i ], $package['rates'][ $chosen_shipping_methods[ $i ] ] ) ) {
455
-						$errors->add( 'shipping', __( 'No shipping method has been selected. Please double check your address, or contact us if you need any help.', 'woocommerce-gateway-stripe' ) );
453
+				foreach (WC()->shipping->get_packages() as $i => $package) {
454
+					if ( ! isset($chosen_shipping_methods[$i], $package['rates'][$chosen_shipping_methods[$i]])) {
455
+						$errors->add('shipping', __('No shipping method has been selected. Please double check your address, or contact us if you need any help.', 'woocommerce-gateway-stripe'));
456 456
 					}
457 457
 				}
458 458
 			}
459 459
 		}
460 460
 
461
-		if ( WC()->cart->needs_payment() ) {
461
+		if (WC()->cart->needs_payment()) {
462 462
 			$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
463 463
 
464
-			if ( ! isset( $available_gateways[ $all_fields['payment_method'] ] ) ) {
465
-				$errors->add( 'payment', __( 'Invalid payment method.', 'woocommerce-gateway-stripe' ) );
464
+			if ( ! isset($available_gateways[$all_fields['payment_method']])) {
465
+				$errors->add('payment', __('Invalid payment method.', 'woocommerce-gateway-stripe'));
466 466
 			} else {
467
-				$available_gateways[ $all_fields['payment_method'] ]->validate_fields();
467
+				$available_gateways[$all_fields['payment_method']]->validate_fields();
468 468
 			}
469 469
 		}
470 470
 
471
-		if ( 0 === count( $errors->errors ) ) {
472
-			wp_send_json( 'success' );
471
+		if (0 === count($errors->errors)) {
472
+			wp_send_json('success');
473 473
 		} else {
474
-			foreach ( $errors->get_error_messages() as $message ) {
475
-				wc_add_notice( $message, 'error' );
474
+			foreach ($errors->get_error_messages() as $message) {
475
+				wc_add_notice($message, 'error');
476 476
 			}
477 477
 
478 478
 			$this->send_ajax_failure_response();
@@ -486,9 +486,9 @@  discard block
 block discarded – undo
486 486
 	 * @version 4.0.0
487 487
 	 */
488 488
 	public function send_ajax_failure_response() {
489
-		if ( is_ajax() ) {
489
+		if (is_ajax()) {
490 490
 			// only print notices if not reloading the checkout, otherwise they're lost in the page reload.
491
-			if ( ! isset( WC()->session->reload_checkout ) ) {
491
+			if ( ! isset(WC()->session->reload_checkout)) {
492 492
 				ob_start();
493 493
 				wc_print_notices();
494 494
 				$messages = ob_get_clean();
@@ -496,14 +496,14 @@  discard block
 block discarded – undo
496 496
 
497 497
 			$response = array(
498 498
 				'result'   => 'failure',
499
-				'messages' => isset( $messages ) ? $messages : '',
500
-				'refresh'  => isset( WC()->session->refresh_totals ),
501
-				'reload'   => isset( WC()->session->reload_checkout ),
499
+				'messages' => isset($messages) ? $messages : '',
500
+				'refresh'  => isset(WC()->session->refresh_totals),
501
+				'reload'   => isset(WC()->session->reload_checkout),
502 502
 			);
503 503
 
504
-			unset( WC()->session->refresh_totals, WC()->session->reload_checkout );
504
+			unset(WC()->session->refresh_totals, WC()->session->reload_checkout);
505 505
 
506
-			wp_send_json( $response );
506
+			wp_send_json($response);
507 507
 		}
508 508
 	}
509 509
 }
Please login to merge, or discard this patch.