Completed
Push — master ( a3a03f...0f97be )
by Roy
05:13
created
includes/admin/stripe-settings.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,191 +1,191 @@
 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.', 'woocommerce-gateway-stripe' ),
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.', 'woocommerce-gateway-stripe'),
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_bitcoin' => array(
112
-			'title'       => __( 'Bitcoin Currency', 'woocommerce-gateway-stripe' ),
113
-			'label'       => __( 'Enable Bitcoin Currency', 'woocommerce-gateway-stripe' ),
112
+			'title'       => __('Bitcoin Currency', 'woocommerce-gateway-stripe'),
113
+			'label'       => __('Enable Bitcoin Currency', 'woocommerce-gateway-stripe'),
114 114
 			'type'        => 'checkbox',
115
-			'description' => __( 'If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe' ),
115
+			'description' => __('If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe'),
116 116
 			'default'     => 'no',
117 117
 			'desc_tip'    => true,
118 118
 		),
119 119
 		'stripe_checkout_image' => array(
120
-			'title'       => __( 'Stripe Checkout Image', 'woocommerce-gateway-stripe' ),
121
-			'description' => __( 'Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe' ),
120
+			'title'       => __('Stripe Checkout Image', 'woocommerce-gateway-stripe'),
121
+			'description' => __('Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe'),
122 122
 			'type'        => 'text',
123 123
 			'default'     => '',
124 124
 			'desc_tip'    => true,
125 125
 		),
126 126
 		'stripe_checkout_description' => array(
127
-			'title'       => __( 'Stripe Checkout Description', 'woocommerce-gateway-stripe' ),
127
+			'title'       => __('Stripe Checkout Description', 'woocommerce-gateway-stripe'),
128 128
 			'type'        => 'text',
129
-			'description' => __( 'Shows a description of your store on Stripe Modal Checkout.', 'woocommerce-gateway-stripe' ),
129
+			'description' => __('Shows a description of your store on Stripe Modal Checkout.', 'woocommerce-gateway-stripe'),
130 130
 			'default'     => '',
131 131
 			'desc_tip'    => true,
132 132
 		),
133 133
 		'payment_request' => array(
134
-			'title'       => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ),
134
+			'title'       => __('Payment Request Buttons', 'woocommerce-gateway-stripe'),
135 135
 			/* translators: 1) br tag 2) opening anchor tag 3) closing anchor tag */
136
-			'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>' ),
136
+			'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>'),
137 137
 			'type'        => 'checkbox',
138
-			'description' => __( 'If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe' ),
138
+			'description' => __('If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe'),
139 139
 			'default'     => 'yes',
140 140
 			'desc_tip'    => true,
141 141
 		),
142 142
 		'payment_request_button_type' => array(
143
-			'title'       => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ),
144
-			'label'       => __( 'Button Type', 'woocommerce-gateway-stripe' ),
143
+			'title'       => __('Payment Request Button Type', 'woocommerce-gateway-stripe'),
144
+			'label'       => __('Button Type', 'woocommerce-gateway-stripe'),
145 145
 			'type'        => 'select',
146
-			'description' => __( 'Select the button type you would like to show.', 'woocommerce-gateway-stripe' ),
146
+			'description' => __('Select the button type you would like to show.', 'woocommerce-gateway-stripe'),
147 147
 			'default'     => 'buy',
148 148
 			'desc_tip'    => true,
149 149
 			'options'     => array(
150
-				'default' => __( 'Default', 'woocommerce-gateway-stripe' ),
151
-				'buy'     => __( 'Buy', 'woocommerce-gateway-stripe' ),
152
-				'donate'  => __( 'Donate', 'woocommerce-gateway-stripe' ),
150
+				'default' => __('Default', 'woocommerce-gateway-stripe'),
151
+				'buy'     => __('Buy', 'woocommerce-gateway-stripe'),
152
+				'donate'  => __('Donate', 'woocommerce-gateway-stripe'),
153 153
 			),
154 154
 		),
155 155
 		'payment_request_button_theme' => array(
156
-			'title'       => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ),
157
-			'label'       => __( 'Button Theme', 'woocommerce-gateway-stripe' ),
156
+			'title'       => __('Payment Request Button Theme', 'woocommerce-gateway-stripe'),
157
+			'label'       => __('Button Theme', 'woocommerce-gateway-stripe'),
158 158
 			'type'        => 'select',
159
-			'description' => __( 'Select the button theme you would like to show.', 'woocommerce-gateway-stripe' ),
159
+			'description' => __('Select the button theme you would like to show.', 'woocommerce-gateway-stripe'),
160 160
 			'default'     => 'dark',
161 161
 			'desc_tip'    => true,
162 162
 			'options'     => array(
163
-				'dark'          => __( 'Dark', 'woocommerce-gateway-stripe' ),
164
-				'light'         => __( 'Light', 'woocommerce-gateway-stripe' ),
165
-				'light-outline' => __( 'Light-Outline', 'woocommerce-gateway-stripe' ),
163
+				'dark'          => __('Dark', 'woocommerce-gateway-stripe'),
164
+				'light'         => __('Light', 'woocommerce-gateway-stripe'),
165
+				'light-outline' => __('Light-Outline', 'woocommerce-gateway-stripe'),
166 166
 			),
167 167
 		),
168 168
 		'payment_request_button_height' => array(
169
-			'title'       => __( 'Payment Request Button Height', 'woocommerce-gateway-stripe' ),
170
-			'label'       => __( 'Button Height', 'woocommerce-gateway-stripe' ),
169
+			'title'       => __('Payment Request Button Height', 'woocommerce-gateway-stripe'),
170
+			'label'       => __('Button Height', 'woocommerce-gateway-stripe'),
171 171
 			'type'        => 'text',
172
-			'description' => __( 'Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe' ),
172
+			'description' => __('Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe'),
173 173
 			'default'     => '44',
174 174
 			'desc_tip'    => true,
175 175
 		),
176 176
 		'saved_cards' => array(
177
-			'title'       => __( 'Saved Cards', 'woocommerce-gateway-stripe' ),
178
-			'label'       => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ),
177
+			'title'       => __('Saved Cards', 'woocommerce-gateway-stripe'),
178
+			'label'       => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'),
179 179
 			'type'        => 'checkbox',
180
-			'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' ),
180
+			'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'),
181 181
 			'default'     => 'no',
182 182
 			'desc_tip'    => true,
183 183
 		),
184 184
 		'logging' => array(
185
-			'title'       => __( 'Logging', 'woocommerce-gateway-stripe' ),
186
-			'label'       => __( 'Log debug messages', 'woocommerce-gateway-stripe' ),
185
+			'title'       => __('Logging', 'woocommerce-gateway-stripe'),
186
+			'label'       => __('Log debug messages', 'woocommerce-gateway-stripe'),
187 187
 			'type'        => 'checkbox',
188
-			'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ),
188
+			'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'),
189 189
 			'default'     => 'no',
190 190
 			'desc_tip'    => true,
191 191
 		),
Please login to merge, or discard this patch.
includes/class-wc-gateway-stripe.php 1 patch
Spacing   +179 added lines, -179 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
 
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	public function __construct() {
114 114
 		$this->retry_interval       = 1;
115 115
 		$this->id                   = 'stripe';
116
-		$this->method_title         = __( 'Stripe', 'woocommerce-gateway-stripe' );
116
+		$this->method_title         = __('Stripe', 'woocommerce-gateway-stripe');
117 117
 		/* translators: 1) link to Stripe register page 2) link to Stripe api keys page */
118
-		$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' );
118
+		$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');
119 119
 		$this->has_fields           = true;
120 120
 		$this->supports             = array(
121 121
 			'products',
@@ -142,33 +142,33 @@  discard block
 block discarded – undo
142 142
 		$this->init_settings();
143 143
 
144 144
 		// Get setting values.
145
-		$this->title                       = $this->get_option( 'title' );
146
-		$this->description                 = $this->get_option( 'description' );
147
-		$this->enabled                     = $this->get_option( 'enabled' );
148
-		$this->testmode                    = 'yes' === $this->get_option( 'testmode' );
149
-		$this->inline_cc_form              = 'yes' === $this->get_option( 'inline_cc_form' );
150
-		$this->capture                     = 'yes' === $this->get_option( 'capture', 'yes' );
151
-		$this->statement_descriptor        = WC_Stripe_Helper::clean_statement_descriptor( $this->get_option( 'statement_descriptor' ) );
152
-		$this->three_d_secure              = 'yes' === $this->get_option( 'three_d_secure' );
153
-		$this->stripe_checkout             = 'yes' === $this->get_option( 'stripe_checkout' );
154
-		$this->stripe_checkout_image       = $this->get_option( 'stripe_checkout_image', '' );
155
-		$this->stripe_checkout_description = $this->get_option( 'stripe_checkout_description' );
156
-		$this->saved_cards                 = 'yes' === $this->get_option( 'saved_cards' );
157
-		$this->secret_key                  = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
158
-		$this->publishable_key             = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' );
159
-		$this->bitcoin                     = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' );
160
-		$this->payment_request             = 'yes' === $this->get_option( 'payment_request', 'yes' );
161
-
162
-		if ( $this->stripe_checkout ) {
163
-			$this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' );
145
+		$this->title                       = $this->get_option('title');
146
+		$this->description                 = $this->get_option('description');
147
+		$this->enabled                     = $this->get_option('enabled');
148
+		$this->testmode                    = 'yes' === $this->get_option('testmode');
149
+		$this->inline_cc_form              = 'yes' === $this->get_option('inline_cc_form');
150
+		$this->capture                     = 'yes' === $this->get_option('capture', 'yes');
151
+		$this->statement_descriptor        = WC_Stripe_Helper::clean_statement_descriptor($this->get_option('statement_descriptor'));
152
+		$this->three_d_secure              = 'yes' === $this->get_option('three_d_secure');
153
+		$this->stripe_checkout             = 'yes' === $this->get_option('stripe_checkout');
154
+		$this->stripe_checkout_image       = $this->get_option('stripe_checkout_image', '');
155
+		$this->stripe_checkout_description = $this->get_option('stripe_checkout_description');
156
+		$this->saved_cards                 = 'yes' === $this->get_option('saved_cards');
157
+		$this->secret_key                  = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
158
+		$this->publishable_key             = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key');
159
+		$this->bitcoin                     = 'USD' === strtoupper(get_woocommerce_currency()) && 'yes' === $this->get_option('stripe_bitcoin');
160
+		$this->payment_request             = 'yes' === $this->get_option('payment_request', 'yes');
161
+
162
+		if ($this->stripe_checkout) {
163
+			$this->order_button_text = __('Continue to payment', 'woocommerce-gateway-stripe');
164 164
 		}
165 165
 
166
-		WC_Stripe_API::set_secret_key( $this->secret_key );
166
+		WC_Stripe_API::set_secret_key($this->secret_key);
167 167
 
168 168
 		// Hooks.
169
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
170
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
171
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
169
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
170
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'));
171
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
172 172
 	}
173 173
 
174 174
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @return bool
179 179
 	 */
180 180
 	public function are_keys_set() {
181
-		if ( empty( $this->secret_key ) || empty( $this->publishable_key ) ) {
181
+		if (empty($this->secret_key) || empty($this->publishable_key)) {
182 182
 			return false;
183 183
 		}
184 184
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 * @since 4.0.2
192 192
 	 */
193 193
 	public function is_available() {
194
-		if ( is_add_payment_method_page() && ! $this->saved_cards ) {
194
+		if (is_add_payment_method_page() && ! $this->saved_cards) {
195 195
 			return false;
196 196
 		}
197 197
 
@@ -214,24 +214,24 @@  discard block
 block discarded – undo
214 214
 		$icons_str .= $icons['amex'];
215 215
 		$icons_str .= $icons['mastercard'];
216 216
 
217
-		if ( 'USD' === get_woocommerce_currency() ) {
217
+		if ('USD' === get_woocommerce_currency()) {
218 218
 			$icons_str .= $icons['discover'];
219 219
 			$icons_str .= $icons['jcb'];
220 220
 			$icons_str .= $icons['diners'];
221 221
 		}
222 222
 
223
-		if ( $this->bitcoin && $this->stripe_checkout ) {
223
+		if ($this->bitcoin && $this->stripe_checkout) {
224 224
 			$icons_str .= $icons['bitcoin'];
225 225
 		}
226 226
 
227
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
227
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
228 228
 	}
229 229
 
230 230
 	/**
231 231
 	 * Initialise Gateway Settings Form Fields
232 232
 	 */
233 233
 	public function init_form_fields() {
234
-		$this->form_fields = require( dirname( __FILE__ ) . '/admin/stripe-settings.php' );
234
+		$this->form_fields = require(dirname(__FILE__) . '/admin/stripe-settings.php');
235 235
 	}
236 236
 
237 237
 	/**
@@ -239,68 +239,68 @@  discard block
 block discarded – undo
239 239
 	 */
240 240
 	public function payment_fields() {
241 241
 		$user                 = wp_get_current_user();
242
-		$display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards;
242
+		$display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards;
243 243
 		$total                = WC()->cart->total;
244 244
 		$user_email           = '';
245 245
 
246 246
 		// If paying from order, we need to get total from order not cart.
247
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
248
-			$order      = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) );
247
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
248
+			$order      = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key'])));
249 249
 			$total      = $order->get_total();
250 250
 			$user_email = WC_Stripe_Helper::is_pre_30() ? $order->billing_email : $order->get_billing_email();
251 251
 		} else {
252
-			if ( $user->ID ) {
253
-				$user_email = get_user_meta( $user->ID, 'billing_email', true );
252
+			if ($user->ID) {
253
+				$user_email = get_user_meta($user->ID, 'billing_email', true);
254 254
 				$user_email = $user_email ? $user_email : $user->user_email;
255 255
 			}
256 256
 		}
257 257
 
258
-		if ( is_add_payment_method_page() ) {
259
-			$pay_button_text = __( 'Add Card', 'woocommerce-gateway-stripe' );
260
-			$total        = '';
258
+		if (is_add_payment_method_page()) {
259
+			$pay_button_text = __('Add Card', 'woocommerce-gateway-stripe');
260
+			$total = '';
261 261
 		} else {
262 262
 			$pay_button_text = '';
263 263
 		}
264 264
 
265 265
 		echo '<div
266 266
 			id="stripe-payment-data"
267
-			data-panel-label="' . esc_attr( $pay_button_text ) . '"
268
-			data-description="'. esc_attr( strip_tags( $this->stripe_checkout_description ) ) . '"
269
-			data-email="' . esc_attr( $user_email ) . '"
270
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
271
-			data-name="' . esc_attr( $this->statement_descriptor ) . '"
272
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '"
273
-			data-image="' . esc_attr( $this->stripe_checkout_image ) . '"
274
-			data-bitcoin="' . esc_attr( ( $this->bitcoin && $this->capture ) ? 'true' : 'false' ) . '"
275
-			data-locale="' . esc_attr( apply_filters( 'wc_stripe_checkout_locale', $this->get_locale() ) ) . '"
276
-			data-three-d-secure="' . esc_attr( $this->three_d_secure ? 'true' : 'false' ) . '"
277
-			data-allow-remember-me="' . esc_attr( $this->saved_cards ? 'true' : 'false' ) . '">';
278
-
279
-		if ( $this->description ) {
280
-			if ( $this->testmode ) {
267
+			data-panel-label="' . esc_attr($pay_button_text) . '"
268
+			data-description="'. esc_attr(strip_tags($this->stripe_checkout_description)) . '"
269
+			data-email="' . esc_attr($user_email) . '"
270
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
271
+			data-name="' . esc_attr($this->statement_descriptor) . '"
272
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '"
273
+			data-image="' . esc_attr($this->stripe_checkout_image) . '"
274
+			data-bitcoin="' . esc_attr(($this->bitcoin && $this->capture) ? 'true' : 'false') . '"
275
+			data-locale="' . esc_attr(apply_filters('wc_stripe_checkout_locale', $this->get_locale())) . '"
276
+			data-three-d-secure="' . esc_attr($this->three_d_secure ? 'true' : 'false') . '"
277
+			data-allow-remember-me="' . esc_attr($this->saved_cards ? 'true' : 'false') . '">';
278
+
279
+		if ($this->description) {
280
+			if ($this->testmode) {
281 281
 				/* translators: link to Stripe testing page */
282
-				$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' );
283
-				$this->description  = trim( $this->description );
282
+				$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');
283
+				$this->description  = trim($this->description);
284 284
 			}
285
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
285
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description)));
286 286
 		}
287 287
 
288
-		if ( $display_tokenization ) {
288
+		if ($display_tokenization) {
289 289
 			$this->tokenization_script();
290 290
 			$this->saved_payment_methods();
291 291
 		}
292 292
 
293
-		if ( ! $this->stripe_checkout ) {
294
-			if ( apply_filters( 'wc_stripe_use_elements_checkout_form', true ) ) {
293
+		if ( ! $this->stripe_checkout) {
294
+			if (apply_filters('wc_stripe_use_elements_checkout_form', true)) {
295 295
 				$this->elements_form();
296 296
 			} else {
297
-				WC_Stripe_Logger::log( 'DEPRECATED! Since version 4.0. Stripe Elements is used. This legacy credit card form will be removed by version 5.0!' );
297
+				WC_Stripe_Logger::log('DEPRECATED! Since version 4.0. Stripe Elements is used. This legacy credit card form will be removed by version 5.0!');
298 298
 				$this->form();
299 299
 				echo '<div class="stripe-source-errors" role="alert"></div>';
300 300
 			}
301 301
 		}
302 302
 
303
-		if ( apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) {
303
+		if (apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) {
304 304
 			$this->save_payment_method_checkbox();
305 305
 		}
306 306
 
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
 	 */
316 316
 	public function elements_form() {
317 317
 		?>
318
-		<fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
319
-			<?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?>
318
+		<fieldset id="wc-<?php echo esc_attr($this->id); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
319
+			<?php do_action('woocommerce_credit_card_form_start', $this->id); ?>
320 320
 
321
-			<?php if ( $this->inline_cc_form ) { ?>
321
+			<?php if ($this->inline_cc_form) { ?>
322 322
 				<label for="card-element">
323
-					<?php esc_html_e( 'Credit or debit card', 'woocommerce-gateway-stripe' ); ?>
323
+					<?php esc_html_e('Credit or debit card', 'woocommerce-gateway-stripe'); ?>
324 324
 				</label>
325 325
 
326 326
 				<div id="stripe-card-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;">
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 				</div>
329 329
 			<?php } else { ?>
330 330
 				<div class="form-row form-row-wide">
331
-					<label><?php _e( 'Card Number', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
331
+					<label><?php _e('Card Number', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
332 332
 
333 333
 					<div id="stripe-card-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;">
334 334
 					<!-- a Stripe Element will be inserted here. -->
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 				</div>
337 337
 
338 338
 				<div class="form-row form-row-first">
339
-					<label><?php _e( 'Expiry Date', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
339
+					<label><?php _e('Expiry Date', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
340 340
 
341 341
 					<div id="stripe-exp-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;">
342 342
 					<!-- a Stripe Element will be inserted here. -->
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 				</div>
345 345
 
346 346
 				<div class="form-row form-row-last">
347
-					<label><?php _e( 'Card Code (CVC)', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
347
+					<label><?php _e('Card Code (CVC)', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
348 348
 				<div id="stripe-cvc-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;">
349 349
 				<!-- a Stripe Element will be inserted here. -->
350 350
 				</div>
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 
355 355
 			<!-- Used to display form errors -->
356 356
 			<div class="stripe-source-errors" role="alert"></div>
357
-			<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
357
+			<?php do_action('woocommerce_credit_card_form_end', $this->id); ?>
358 358
 			<div class="clear"></div>
359 359
 		</fieldset>
360 360
 		<?php
@@ -367,13 +367,13 @@  discard block
 block discarded – undo
367 367
 	 * @version 3.1.0
368 368
 	 */
369 369
 	public function admin_scripts() {
370
-		if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) {
370
+		if ('woocommerce_page_wc-settings' !== get_current_screen()->id) {
371 371
 			return;
372 372
 		}
373 373
 
374
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
374
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
375 375
 
376
-		wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true );
376
+		wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true);
377 377
 	}
378 378
 
379 379
 	/**
@@ -385,46 +385,46 @@  discard block
 block discarded – undo
385 385
 	 * @version 4.0.0
386 386
 	 */
387 387
 	public function payment_scripts() {
388
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) {
388
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) {
389 389
 			return;
390 390
 		}
391 391
 
392 392
 		// If Stripe is not enabled bail.
393
-		if ( 'no' === $this->enabled ) {
393
+		if ('no' === $this->enabled) {
394 394
 			return;
395 395
 		}
396 396
 
397 397
 		// If keys are not set bail.
398
-		if ( ! $this->are_keys_set() ) {
399
-			WC_Stripe_Logger::log( 'Keys are not set correctly.' );
398
+		if ( ! $this->are_keys_set()) {
399
+			WC_Stripe_Logger::log('Keys are not set correctly.');
400 400
 			return;
401 401
 		}
402 402
 
403 403
 		// If no SSL bail.
404
-		if ( ! $this->testmode && ! is_ssl() ) {
405
-			WC_Stripe_Logger::log( 'Stripe requires SSL.' );
404
+		if ( ! $this->testmode && ! is_ssl()) {
405
+			WC_Stripe_Logger::log('Stripe requires SSL.');
406 406
 			return;
407 407
 		}
408 408
 
409
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
409
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
410 410
 
411
-		wp_register_style( 'stripe_paymentfonts', plugins_url( 'assets/css/stripe-paymentfonts.css', WC_STRIPE_MAIN_FILE ), array(), '1.2.5' );
412
-		wp_enqueue_style( 'stripe_paymentfonts' );
413
-		wp_register_script( 'stripe_checkout', 'https://checkout.stripe.com/checkout.js', '', WC_STRIPE_VERSION, true );
414
-		wp_register_script( 'stripev2', 'https://js.stripe.com/v2/', '', '2.0', true );
415
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
416
-		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 );
411
+		wp_register_style('stripe_paymentfonts', plugins_url('assets/css/stripe-paymentfonts.css', WC_STRIPE_MAIN_FILE), array(), '1.2.5');
412
+		wp_enqueue_style('stripe_paymentfonts');
413
+		wp_register_script('stripe_checkout', 'https://checkout.stripe.com/checkout.js', '', WC_STRIPE_VERSION, true);
414
+		wp_register_script('stripev2', 'https://js.stripe.com/v2/', '', '2.0', true);
415
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
416
+		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);
417 417
 
418 418
 		$stripe_params = array(
419 419
 			'key'                  => $this->publishable_key,
420
-			'i18n_terms'           => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ),
421
-			'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ),
420
+			'i18n_terms'           => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'),
421
+			'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'),
422 422
 		);
423 423
 
424 424
 		// If we're on the pay page we need to pass stripe.js the address of the order.
425
-		if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) {
426
-			$order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) );
427
-			$order    = wc_get_order( $order_id );
425
+		if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) {
426
+			$order_id = wc_get_order_id_by_order_key(urldecode($_GET['key']));
427
+			$order    = wc_get_order($order_id);
428 428
 
429 429
 			$stripe_params['billing_first_name'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_first_name : $order->get_billing_first_name();
430 430
 			$stripe_params['billing_last_name']  = WC_Stripe_Helper::is_pre_30() ? $order->billing_last_name : $order->get_billing_last_name();
@@ -436,39 +436,39 @@  discard block
 block discarded – undo
436 436
 			$stripe_params['billing_country']    = WC_Stripe_Helper::is_pre_30() ? $order->billing_country : $order->get_billing_country();
437 437
 		}
438 438
 
439
-		$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' );
440
-		$stripe_params['no_sepa_owner_msg']                       = __( 'Please enter your IBAN account name.', 'woocommerce-gateway-stripe' );
441
-		$stripe_params['no_sepa_iban_msg']                        = __( 'Please enter your IBAN account number.', 'woocommerce-gateway-stripe' );
442
-		$stripe_params['sepa_mandate_notification']               = apply_filters( 'wc_stripe_sepa_mandate_notification', 'email' );
443
-		$stripe_params['allow_prepaid_card']                      = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no';
439
+		$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');
440
+		$stripe_params['no_sepa_owner_msg']                       = __('Please enter your IBAN account name.', 'woocommerce-gateway-stripe');
441
+		$stripe_params['no_sepa_iban_msg']                        = __('Please enter your IBAN account number.', 'woocommerce-gateway-stripe');
442
+		$stripe_params['sepa_mandate_notification']               = apply_filters('wc_stripe_sepa_mandate_notification', 'email');
443
+		$stripe_params['allow_prepaid_card']                      = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no';
444 444
 		$stripe_params['inline_cc_form']                          = $this->inline_cc_form ? 'yes' : 'no';
445
-		$stripe_params['stripe_checkout_require_billing_address'] = apply_filters( 'wc_stripe_checkout_require_billing_address', false ) ? 'yes' : 'no';
446
-		$stripe_params['is_checkout']                             = ( is_checkout() && empty( $_GET['pay_for_order'] ) ) ? 'yes' : 'no';
445
+		$stripe_params['stripe_checkout_require_billing_address'] = apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'yes' : 'no';
446
+		$stripe_params['is_checkout']                             = (is_checkout() && empty($_GET['pay_for_order'])) ? 'yes' : 'no';
447 447
 		$stripe_params['return_url']                              = $this->get_stripe_return_url();
448
-		$stripe_params['ajaxurl']                                 = WC_AJAX::get_endpoint( '%%endpoint%%' );
449
-		$stripe_params['stripe_nonce']                            = wp_create_nonce( '_wc_stripe_nonce' );
448
+		$stripe_params['ajaxurl']                                 = WC_AJAX::get_endpoint('%%endpoint%%');
449
+		$stripe_params['stripe_nonce']                            = wp_create_nonce('_wc_stripe_nonce');
450 450
 		$stripe_params['statement_descriptor']                    = $this->statement_descriptor;
451
-		$stripe_params['use_elements']                            = apply_filters( 'wc_stripe_use_elements_checkout_form', true ) ? 'yes' : 'no';
452
-		$stripe_params['elements_options']                        = apply_filters( 'wc_stripe_elements_options', array() );
451
+		$stripe_params['use_elements']                            = apply_filters('wc_stripe_use_elements_checkout_form', true) ? 'yes' : 'no';
452
+		$stripe_params['elements_options']                        = apply_filters('wc_stripe_elements_options', array());
453 453
 		$stripe_params['is_stripe_checkout']                      = $this->stripe_checkout ? 'yes' : 'no';
454
-		$stripe_params['is_change_payment_page']                  = isset( $_GET['change_payment_method'] ) ? 'yes' : 'no';
455
-		$stripe_params['is_pay_for_order_page']                   = isset( $_GET['pay_for_order'] ) ? 'yes' : 'no';
456
-		$stripe_params['validate_modal_checkout']                 = apply_filters( 'wc_stripe_validate_modal_checkout', false ) ? 'yes' : 'no';
457
-		$stripe_params['elements_styling']                        = apply_filters( 'wc_stripe_elements_styling', false );
458
-		$stripe_params['elements_classes']                        = apply_filters( 'wc_stripe_elements_classes', false );
454
+		$stripe_params['is_change_payment_page']                  = isset($_GET['change_payment_method']) ? 'yes' : 'no';
455
+		$stripe_params['is_pay_for_order_page']                   = isset($_GET['pay_for_order']) ? 'yes' : 'no';
456
+		$stripe_params['validate_modal_checkout']                 = apply_filters('wc_stripe_validate_modal_checkout', false) ? 'yes' : 'no';
457
+		$stripe_params['elements_styling']                        = apply_filters('wc_stripe_elements_styling', false);
458
+		$stripe_params['elements_classes']                        = apply_filters('wc_stripe_elements_classes', false);
459 459
 
460 460
 		// merge localized messages to be use in JS
461
-		$stripe_params = array_merge( $stripe_params, WC_Stripe_Helper::get_localized_messages() );
461
+		$stripe_params = array_merge($stripe_params, WC_Stripe_Helper::get_localized_messages());
462 462
 
463
-		wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
464
-		wp_localize_script( 'woocommerce_stripe_checkout', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
463
+		wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
464
+		wp_localize_script('woocommerce_stripe_checkout', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
465 465
 
466
-		if ( $this->stripe_checkout ) {
467
-			wp_enqueue_script( 'stripe_checkout' );
466
+		if ($this->stripe_checkout) {
467
+			wp_enqueue_script('stripe_checkout');
468 468
 		}
469 469
 
470 470
 		$this->tokenization_script();
471
-		wp_enqueue_script( 'woocommerce_stripe' );
471
+		wp_enqueue_script('woocommerce_stripe');
472 472
 	}
473 473
 
474 474
 	/**
@@ -484,41 +484,41 @@  discard block
 block discarded – undo
484 484
 	 *
485 485
 	 * @return array|void
486 486
 	 */
487
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
487
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
488 488
 		try {
489
-			$order = wc_get_order( $order_id );
489
+			$order = wc_get_order($order_id);
490 490
 
491 491
 			// This comes from the create account checkbox in the checkout page.
492
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
492
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
493 493
 
494
-			if ( $create_account ) {
494
+			if ($create_account) {
495 495
 				$new_customer_id     = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id();
496
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
496
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
497 497
 				$new_stripe_customer->create_customer();
498 498
 			}
499 499
 
500
-			$prepared_source = $this->prepare_source( get_current_user_id(), $force_save_source );
500
+			$prepared_source = $this->prepare_source(get_current_user_id(), $force_save_source);
501 501
 			$source_object   = $prepared_source->source_object;
502 502
 
503 503
 			// Check if we don't allow prepaid credit cards.
504
-			if ( ! apply_filters( 'wc_stripe_allow_prepaid_card', true ) && $this->is_prepaid_card( $source_object ) ) {
505
-				$localized_message = __( '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' );
506
-				throw new WC_Stripe_Exception( print_r( $source_object, true ), $localized_message );
504
+			if ( ! apply_filters('wc_stripe_allow_prepaid_card', true) && $this->is_prepaid_card($source_object)) {
505
+				$localized_message = __('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');
506
+				throw new WC_Stripe_Exception(print_r($source_object, true), $localized_message);
507 507
 			}
508 508
 
509
-			if ( empty( $prepared_source->source ) ) {
510
-				$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
511
-				throw new WC_Stripe_Exception( print_r( $prepared_source, true ), $localized_message );
509
+			if (empty($prepared_source->source)) {
510
+				$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
511
+				throw new WC_Stripe_Exception(print_r($prepared_source, true), $localized_message);
512 512
 			}
513 513
 
514
-			$this->save_source_to_order( $order, $prepared_source );
514
+			$this->save_source_to_order($order, $prepared_source);
515 515
 
516 516
 			// Result from Stripe API request.
517 517
 			$response = null;
518 518
 
519
-			if ( $order->get_total() > 0 ) {
519
+			if ($order->get_total() > 0) {
520 520
 				// This will throw exception if not valid.
521
-				$this->validate_minimum_order_amount( $order );
521
+				$this->validate_minimum_order_amount($order);
522 522
 
523 523
 				/*
524 524
 				 * Check if card 3DS is required or optional with 3DS setting.
@@ -527,105 +527,105 @@  discard block
 block discarded – undo
527 527
 				 * Note that if we need to save source, the original source must be first
528 528
 				 * attached to a customer in Stripe before it can be charged.
529 529
 				 */
530
-				if ( $this->is_3ds_required( $source_object ) ) {
531
-					$response = $this->create_3ds_source( $order, $source_object );
530
+				if ($this->is_3ds_required($source_object)) {
531
+					$response = $this->create_3ds_source($order, $source_object);
532 532
 
533
-					if ( ! empty( $response->error ) ) {
533
+					if ( ! empty($response->error)) {
534 534
 						$localized_message = $response->error->message;
535 535
 
536
-						$order->add_order_note( $localized_message );
536
+						$order->add_order_note($localized_message);
537 537
 
538
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
538
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
539 539
 					}
540 540
 
541 541
 					// Update order meta with 3DS source.
542
-					if ( WC_Stripe_Helper::is_pre_30() ) {
543
-						update_post_meta( $order_id, '_stripe_source_id', $response->id );
542
+					if (WC_Stripe_Helper::is_pre_30()) {
543
+						update_post_meta($order_id, '_stripe_source_id', $response->id);
544 544
 					} else {
545
-						$order->update_meta_data( '_stripe_source_id', $response->id );
545
+						$order->update_meta_data('_stripe_source_id', $response->id);
546 546
 						$order->save();
547 547
 					}
548 548
 
549
-					WC_Stripe_Logger::log( 'Info: Redirecting to 3DS...' );
549
+					WC_Stripe_Logger::log('Info: Redirecting to 3DS...');
550 550
 
551 551
 					return array(
552 552
 						'result'   => 'success',
553
-						'redirect' => esc_url_raw( $response->redirect->url ),
553
+						'redirect' => esc_url_raw($response->redirect->url),
554 554
 					);
555 555
 				}
556 556
 
557
-				WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
557
+				WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
558 558
 
559 559
 				/* If we're doing a retry and source is chargeable, we need to pass
560 560
 				 * a different idempotency key and retry for success.
561 561
 				 */
562
-				if ( 1 < $this->retry_interval && ! empty( $source_object ) && 'chargeable' === $source_object->status ) {
563
-					add_filter( 'wc_stripe_idempotency_key', array( $this, 'change_idempotency_key' ), 10, 2 );
562
+				if (1 < $this->retry_interval && ! empty($source_object) && 'chargeable' === $source_object->status) {
563
+					add_filter('wc_stripe_idempotency_key', array($this, 'change_idempotency_key'), 10, 2);
564 564
 				}
565 565
 
566 566
 				// Make the request.
567
-				$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $prepared_source ) );
567
+				$response = WC_Stripe_API::request($this->generate_payment_request($order, $prepared_source));
568 568
 
569
-				if ( ! empty( $response->error ) ) {
569
+				if ( ! empty($response->error)) {
570 570
 					// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
571
-					if ( preg_match( '/No such customer/i', $response->error->message ) && $retry ) {
572
-						if ( WC_Stripe_Helper::is_pre_30() ) {
573
-							delete_user_meta( $order->customer_user, '_stripe_customer_id' );
574
-							delete_post_meta( $order_id, '_stripe_customer_id' );
571
+					if (preg_match('/No such customer/i', $response->error->message) && $retry) {
572
+						if (WC_Stripe_Helper::is_pre_30()) {
573
+							delete_user_meta($order->customer_user, '_stripe_customer_id');
574
+							delete_post_meta($order_id, '_stripe_customer_id');
575 575
 						} else {
576
-							delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' );
577
-							$order->delete_meta_data( '_stripe_customer_id' );
576
+							delete_user_meta($order->get_customer_id(), '_stripe_customer_id');
577
+							$order->delete_meta_data('_stripe_customer_id');
578 578
 							$order->save();
579 579
 						}
580 580
 
581
-						return $this->process_payment( $order_id, false, $force_save_source );
582
-					} elseif ( preg_match( '/No such token/i', $response->error->message ) && $prepared_source->token_id ) {
581
+						return $this->process_payment($order_id, false, $force_save_source);
582
+					} elseif (preg_match('/No such token/i', $response->error->message) && $prepared_source->token_id) {
583 583
 						// Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message.
584
-						$wc_token = WC_Payment_Tokens::get( $prepared_source->token_id );
584
+						$wc_token = WC_Payment_Tokens::get($prepared_source->token_id);
585 585
 						$wc_token->delete();
586
-						$localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' );
587
-						$order->add_order_note( $localized_message );
588
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
586
+						$localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe');
587
+						$order->add_order_note($localized_message);
588
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
589 589
 					}
590 590
 
591 591
 					// We want to retry.
592
-					if ( $this->is_retryable_error( $response->error ) ) {
593
-						if ( $retry ) {
592
+					if ($this->is_retryable_error($response->error)) {
593
+						if ($retry) {
594 594
 							// Don't do anymore retries after this.
595
-							if ( 5 <= $this->retry_interval ) {
595
+							if (5 <= $this->retry_interval) {
596 596
 
597
-								return $this->process_payment( $order_id, false, $force_save_source );
597
+								return $this->process_payment($order_id, false, $force_save_source);
598 598
 							}
599 599
 
600
-							sleep( $this->retry_interval );
600
+							sleep($this->retry_interval);
601 601
 
602 602
 							$this->retry_interval++;
603 603
 
604
-							return $this->process_payment( $order_id, true, $force_save_source );
604
+							return $this->process_payment($order_id, true, $force_save_source);
605 605
 						} else {
606
-							$localized_message = __( 'On going requests error and retries exhausted.', 'woocommerce-gateway-stripe' );
607
-							$order->add_order_note( $localized_message );
608
-							throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
606
+							$localized_message = __('On going requests error and retries exhausted.', 'woocommerce-gateway-stripe');
607
+							$order->add_order_note($localized_message);
608
+							throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
609 609
 						}
610 610
 					}
611 611
 
612 612
 					$localized_messages = WC_Stripe_Helper::get_localized_messages();
613 613
 
614
-					if ( 'card_error' === $response->error->type ) {
615
-						$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
614
+					if ('card_error' === $response->error->type) {
615
+						$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
616 616
 					} else {
617
-						$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
617
+						$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
618 618
 					}
619 619
 
620
-					$order->add_order_note( $localized_message );
620
+					$order->add_order_note($localized_message);
621 621
 
622
-					throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
622
+					throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
623 623
 				}
624 624
 
625
-				do_action( 'wc_gateway_stripe_process_payment', $response, $order );
625
+				do_action('wc_gateway_stripe_process_payment', $response, $order);
626 626
 
627 627
 				// Process valid response.
628
-				$this->process_response( $response, $order );
628
+				$this->process_response($response, $order);
629 629
 			} else {
630 630
 				$order->payment_complete();
631 631
 			}
@@ -636,20 +636,20 @@  discard block
 block discarded – undo
636 636
 			// Return thank you page redirect.
637 637
 			return array(
638 638
 				'result'   => 'success',
639
-				'redirect' => $this->get_return_url( $order ),
639
+				'redirect' => $this->get_return_url($order),
640 640
 			);
641 641
 
642
-		} catch ( WC_Stripe_Exception $e ) {
643
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
644
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
642
+		} catch (WC_Stripe_Exception $e) {
643
+			wc_add_notice($e->getLocalizedMessage(), 'error');
644
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
645 645
 
646
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
646
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
647 647
 
648 648
 			/* translators: error message */
649
-			$order->update_status( 'failed' );
649
+			$order->update_status('failed');
650 650
 
651
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
652
-				$this->send_failed_order_email( $order_id );
651
+			if ($order->has_status(array('pending', 'failed'))) {
652
+				$this->send_failed_order_email($order_id);
653 653
 			}
654 654
 
655 655
 			return array(
Please login to merge, or discard this patch.