@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 3.1.0 |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -42,30 +42,30 @@ discard block |
||
42 | 42 | * @version 4.0.0 |
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | - $this->stripe_settings = get_option( 'woocommerce_stripe_settings', array() ); |
|
45 | + $this->stripe_settings = get_option('woocommerce_stripe_settings', array()); |
|
46 | 46 | $this->publishable_key = $this->get_publishable_key(); |
47 | - $this->stripe_checkout_enabled = isset( $this->stripe_settings['stripe_checkout'] ) && 'yes' === $this->stripe_settings['stripe_checkout']; |
|
48 | - $this->total_label = ! empty( $this->stripe_settings['statement_descriptor'] ) ? WC_Stripe_Helper::clean_statement_descriptor( $this->stripe_settings['statement_descriptor'] ) : ''; |
|
47 | + $this->stripe_checkout_enabled = isset($this->stripe_settings['stripe_checkout']) && 'yes' === $this->stripe_settings['stripe_checkout']; |
|
48 | + $this->total_label = ! empty($this->stripe_settings['statement_descriptor']) ? WC_Stripe_Helper::clean_statement_descriptor($this->stripe_settings['statement_descriptor']) : ''; |
|
49 | 49 | |
50 | 50 | // If both site title and statement descriptor is not set. Fallback. |
51 | - if ( empty( $this->total_label ) ) { |
|
51 | + if (empty($this->total_label)) { |
|
52 | 52 | $this->total_label = $_SERVER['SERVER_NAME']; |
53 | 53 | } |
54 | 54 | |
55 | - $this->total_label = str_replace( "'", '', $this->total_label ) . apply_filters( 'wc_stripe_payment_request_total_label_suffix', ' (via WooCommerce)' ); |
|
55 | + $this->total_label = str_replace("'", '', $this->total_label) . apply_filters('wc_stripe_payment_request_total_label_suffix', ' (via WooCommerce)'); |
|
56 | 56 | |
57 | 57 | // Checks if Stripe Gateway is enabled. |
58 | - if ( empty( $this->stripe_settings ) || ( isset( $this->stripe_settings['enabled'] ) && 'yes' !== $this->stripe_settings['enabled'] ) ) { |
|
58 | + if (empty($this->stripe_settings) || (isset($this->stripe_settings['enabled']) && 'yes' !== $this->stripe_settings['enabled'])) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Checks if Payment Request is enabled. |
63 | - if ( ! isset( $this->stripe_settings['payment_request'] ) || 'yes' !== $this->stripe_settings['payment_request'] ) { |
|
63 | + if ( ! isset($this->stripe_settings['payment_request']) || 'yes' !== $this->stripe_settings['payment_request']) { |
|
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
67 | 67 | // Don't load for change payment method page. |
68 | - if ( isset( $_GET['change_payment_method'] ) ) { |
|
68 | + if (isset($_GET['change_payment_method'])) { |
|
69 | 69 | return; |
70 | 70 | } |
71 | 71 | |
@@ -79,43 +79,43 @@ discard block |
||
79 | 79 | * @version 4.0.0 |
80 | 80 | */ |
81 | 81 | protected function init() { |
82 | - add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ) ); |
|
83 | - add_action( 'wp', array( $this, 'set_session' ) ); |
|
82 | + add_action('wp_enqueue_scripts', array($this, 'scripts')); |
|
83 | + add_action('wp', array($this, 'set_session')); |
|
84 | 84 | |
85 | 85 | /* |
86 | 86 | * In order to display the Payment Request button in the correct position, |
87 | 87 | * a new hook was added to WooCommerce 3.0. In older versions of WooCommerce, |
88 | 88 | * CSS is used to position the button. |
89 | 89 | */ |
90 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
91 | - add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_html' ), 1 ); |
|
92 | - add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_separator_html' ), 2 ); |
|
90 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
91 | + add_action('woocommerce_after_add_to_cart_button', array($this, 'display_payment_request_button_html'), 1); |
|
92 | + add_action('woocommerce_after_add_to_cart_button', array($this, 'display_payment_request_button_separator_html'), 2); |
|
93 | 93 | } else { |
94 | - add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_html' ), 1 ); |
|
95 | - add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_separator_html' ), 2 ); |
|
94 | + add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_html'), 1); |
|
95 | + add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_separator_html'), 2); |
|
96 | 96 | } |
97 | 97 | |
98 | - add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_html' ), 1 ); |
|
99 | - add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_separator_html' ), 2 ); |
|
98 | + add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_html'), 1); |
|
99 | + add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_separator_html'), 2); |
|
100 | 100 | |
101 | - if ( apply_filters( 'wc_stripe_show_payment_request_on_checkout', false ) ) { |
|
102 | - add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_html' ), 1 ); |
|
103 | - add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_separator_html' ), 2 ); |
|
101 | + if (apply_filters('wc_stripe_show_payment_request_on_checkout', false)) { |
|
102 | + add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_html'), 1); |
|
103 | + add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_separator_html'), 2); |
|
104 | 104 | } |
105 | 105 | |
106 | - add_action( 'wc_ajax_wc_stripe_get_cart_details', array( $this, 'ajax_get_cart_details' ) ); |
|
107 | - add_action( 'wc_ajax_wc_stripe_get_shipping_options', array( $this, 'ajax_get_shipping_options' ) ); |
|
108 | - add_action( 'wc_ajax_wc_stripe_update_shipping_method', array( $this, 'ajax_update_shipping_method' ) ); |
|
109 | - add_action( 'wc_ajax_wc_stripe_create_order', array( $this, 'ajax_create_order' ) ); |
|
110 | - add_action( 'wc_ajax_wc_stripe_add_to_cart', array( $this, 'ajax_add_to_cart' ) ); |
|
111 | - add_action( 'wc_ajax_wc_stripe_get_selected_product_data', array( $this, 'ajax_get_selected_product_data' ) ); |
|
112 | - add_action( 'wc_ajax_wc_stripe_clear_cart', array( $this, 'ajax_clear_cart' ) ); |
|
113 | - add_action( 'wc_ajax_wc_stripe_log_errors', array( $this, 'ajax_log_errors' ) ); |
|
106 | + add_action('wc_ajax_wc_stripe_get_cart_details', array($this, 'ajax_get_cart_details')); |
|
107 | + add_action('wc_ajax_wc_stripe_get_shipping_options', array($this, 'ajax_get_shipping_options')); |
|
108 | + add_action('wc_ajax_wc_stripe_update_shipping_method', array($this, 'ajax_update_shipping_method')); |
|
109 | + add_action('wc_ajax_wc_stripe_create_order', array($this, 'ajax_create_order')); |
|
110 | + add_action('wc_ajax_wc_stripe_add_to_cart', array($this, 'ajax_add_to_cart')); |
|
111 | + add_action('wc_ajax_wc_stripe_get_selected_product_data', array($this, 'ajax_get_selected_product_data')); |
|
112 | + add_action('wc_ajax_wc_stripe_clear_cart', array($this, 'ajax_clear_cart')); |
|
113 | + add_action('wc_ajax_wc_stripe_log_errors', array($this, 'ajax_log_errors')); |
|
114 | 114 | |
115 | - add_filter( 'woocommerce_gateway_title', array( $this, 'filter_gateway_title' ), 10, 2 ); |
|
116 | - add_filter( 'woocommerce_validate_postcode', array( $this, 'postal_code_validation' ), 10, 3 ); |
|
115 | + add_filter('woocommerce_gateway_title', array($this, 'filter_gateway_title'), 10, 2); |
|
116 | + add_filter('woocommerce_validate_postcode', array($this, 'postal_code_validation'), 10, 3); |
|
117 | 117 | |
118 | - add_action( 'woocommerce_checkout_order_processed', array( $this, 'add_order_meta' ), 10, 3 ); |
|
118 | + add_action('woocommerce_checkout_order_processed', array($this, 'add_order_meta'), 10, 3); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | * @since 4.0.0 |
126 | 126 | */ |
127 | 127 | public function set_session() { |
128 | - if ( ! is_user_logged_in() ) { |
|
128 | + if ( ! is_user_logged_in()) { |
|
129 | 129 | $wc_session = new WC_Session_Handler(); |
130 | 130 | |
131 | - if ( ! $wc_session->has_session() ) { |
|
132 | - $wc_session->set_customer_session_cookie( true ); |
|
131 | + if ( ! $wc_session->has_session()) { |
|
132 | + $wc_session->set_customer_session_cookie(true); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
@@ -140,15 +140,15 @@ discard block |
||
140 | 140 | * @return string |
141 | 141 | */ |
142 | 142 | protected function get_publishable_key() { |
143 | - if ( empty( $this->stripe_settings ) ) { |
|
143 | + if (empty($this->stripe_settings)) { |
|
144 | 144 | return ''; |
145 | 145 | } |
146 | 146 | |
147 | - if ( empty( $this->stripe_settings['testmode'] ) ) { |
|
147 | + if (empty($this->stripe_settings['testmode'])) { |
|
148 | 148 | return ''; |
149 | 149 | } |
150 | 150 | |
151 | - if ( empty( $this->stripe_settings['test_publishable_key'] ) ) { |
|
151 | + if (empty($this->stripe_settings['test_publishable_key'])) { |
|
152 | 152 | return ''; |
153 | 153 | } |
154 | 154 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @return string |
164 | 164 | */ |
165 | 165 | public function get_button_type() { |
166 | - return isset( $this->stripe_settings['payment_request_button_type'] ) ? $this->stripe_settings['payment_request_button_type'] : 'default'; |
|
166 | + return isset($this->stripe_settings['payment_request_button_type']) ? $this->stripe_settings['payment_request_button_type'] : 'default'; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @return string |
175 | 175 | */ |
176 | 176 | public function get_button_theme() { |
177 | - return isset( $this->stripe_settings['payment_request_button_theme'] ) ? $this->stripe_settings['payment_request_button_theme'] : 'dark'; |
|
177 | + return isset($this->stripe_settings['payment_request_button_theme']) ? $this->stripe_settings['payment_request_button_theme'] : 'dark'; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @return string |
186 | 186 | */ |
187 | 187 | public function get_button_height() { |
188 | - return isset( $this->stripe_settings['payment_request_button_height'] ) ? str_replace( 'px', '', $this->stripe_settings['payment_request_button_height'] ) : '64'; |
|
188 | + return isset($this->stripe_settings['payment_request_button_height']) ? str_replace('px', '', $this->stripe_settings['payment_request_button_height']) : '64'; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -195,40 +195,40 @@ discard block |
||
195 | 195 | * @version 4.0.0 |
196 | 196 | */ |
197 | 197 | public function get_product_data() { |
198 | - if ( ! is_product() ) { |
|
198 | + if ( ! is_product()) { |
|
199 | 199 | return false; |
200 | 200 | } |
201 | 201 | |
202 | 202 | global $post; |
203 | 203 | |
204 | - $product = wc_get_product( $post->ID ); |
|
204 | + $product = wc_get_product($post->ID); |
|
205 | 205 | |
206 | 206 | $data = array(); |
207 | 207 | $items = array(); |
208 | 208 | |
209 | 209 | $items[] = array( |
210 | 210 | 'label' => WC_Stripe_Helper::is_pre_30() ? $product->name : $product->get_name(), |
211 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( WC_Stripe_Helper::is_pre_30() ? $product->price : $product->get_price() ), |
|
211 | + 'amount' => WC_Stripe_Helper::get_stripe_amount(WC_Stripe_Helper::is_pre_30() ? $product->price : $product->get_price()), |
|
212 | 212 | ); |
213 | 213 | |
214 | - if ( wc_tax_enabled() ) { |
|
214 | + if (wc_tax_enabled()) { |
|
215 | 215 | $items[] = array( |
216 | - 'label' => __( 'Tax', 'woocommerce-gateway-stripe' ), |
|
216 | + 'label' => __('Tax', 'woocommerce-gateway-stripe'), |
|
217 | 217 | 'amount' => 0, |
218 | 218 | 'pending' => true, |
219 | 219 | ); |
220 | 220 | } |
221 | 221 | |
222 | - if ( wc_shipping_enabled() && $product->needs_shipping() ) { |
|
222 | + if (wc_shipping_enabled() && $product->needs_shipping()) { |
|
223 | 223 | $items[] = array( |
224 | - 'label' => __( 'Shipping', 'woocommerce-gateway-stripe' ), |
|
224 | + 'label' => __('Shipping', 'woocommerce-gateway-stripe'), |
|
225 | 225 | 'amount' => 0, |
226 | 226 | 'pending' => true, |
227 | 227 | ); |
228 | 228 | |
229 | - $data['shippingOptions'] = array( |
|
229 | + $data['shippingOptions'] = array( |
|
230 | 230 | 'id' => 'pending', |
231 | - 'label' => __( 'Pending', 'woocommerce-gateway-stripe' ), |
|
231 | + 'label' => __('Pending', 'woocommerce-gateway-stripe'), |
|
232 | 232 | 'detail' => '', |
233 | 233 | 'amount' => 0, |
234 | 234 | ); |
@@ -237,13 +237,13 @@ discard block |
||
237 | 237 | $data['displayItems'] = $items; |
238 | 238 | $data['total'] = array( |
239 | 239 | 'label' => $this->total_label, |
240 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( WC_Stripe_Helper::is_pre_30() ? $product->price : $product->get_price() ), |
|
240 | + 'amount' => WC_Stripe_Helper::get_stripe_amount(WC_Stripe_Helper::is_pre_30() ? $product->price : $product->get_price()), |
|
241 | 241 | 'pending' => true, |
242 | 242 | ); |
243 | 243 | |
244 | - $data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() ); |
|
245 | - $data['currency'] = strtolower( get_woocommerce_currency() ); |
|
246 | - $data['country_code'] = substr( get_option( 'woocommerce_default_country' ), 0, 2 ); |
|
244 | + $data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping()); |
|
245 | + $data['currency'] = strtolower(get_woocommerce_currency()); |
|
246 | + $data['country_code'] = substr(get_option('woocommerce_default_country'), 0, 2); |
|
247 | 247 | |
248 | 248 | return $data; |
249 | 249 | } |
@@ -252,25 +252,25 @@ discard block |
||
252 | 252 | * Filters the gateway title to reflect Payment Request type |
253 | 253 | * |
254 | 254 | */ |
255 | - public function filter_gateway_title( $title, $id ) { |
|
255 | + public function filter_gateway_title($title, $id) { |
|
256 | 256 | global $post; |
257 | 257 | |
258 | - if ( ! is_object( $post ) ) { |
|
258 | + if ( ! is_object($post)) { |
|
259 | 259 | return $title; |
260 | 260 | } |
261 | 261 | |
262 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
263 | - $method_title = get_post_meta( $post->ID, '_payment_method_title', true ); |
|
262 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
263 | + $method_title = get_post_meta($post->ID, '_payment_method_title', true); |
|
264 | 264 | } else { |
265 | - $order = wc_get_order( $post->ID ); |
|
266 | - $method_title = is_object( $order ) ? $order->get_payment_method_title() : ''; |
|
265 | + $order = wc_get_order($post->ID); |
|
266 | + $method_title = is_object($order) ? $order->get_payment_method_title() : ''; |
|
267 | 267 | } |
268 | 268 | |
269 | - if ( 'stripe' === $id && ! empty( $method_title ) && 'Apple Pay (Stripe)' === $method_title ) { |
|
269 | + if ('stripe' === $id && ! empty($method_title) && 'Apple Pay (Stripe)' === $method_title) { |
|
270 | 270 | return $method_title; |
271 | 271 | } |
272 | 272 | |
273 | - if ( 'stripe' === $id && ! empty( $method_title ) && 'Chrome Payment Request (Stripe)' === $method_title ) { |
|
273 | + if ('stripe' === $id && ! empty($method_title) && 'Chrome Payment Request (Stripe)' === $method_title) { |
|
274 | 274 | return $method_title; |
275 | 275 | } |
276 | 276 | |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | * @since 3.1.4 |
284 | 284 | * @version 4.0.0 |
285 | 285 | */ |
286 | - public function postal_code_validation( $valid, $postcode, $country ) { |
|
286 | + public function postal_code_validation($valid, $postcode, $country) { |
|
287 | 287 | $gateways = WC()->payment_gateways->get_available_payment_gateways(); |
288 | 288 | |
289 | - if ( ! isset( $gateways['stripe'] ) ) { |
|
289 | + if ( ! isset($gateways['stripe'])) { |
|
290 | 290 | return $valid; |
291 | 291 | } |
292 | 292 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * the order and not let it go through. The remedy for now is just to remove this validation. |
297 | 297 | * Note that this only works with shipping providers that don't validate full postal codes. |
298 | 298 | */ |
299 | - if ( 'GB' === $country || 'CA' === $country ) { |
|
299 | + if ('GB' === $country || 'CA' === $country) { |
|
300 | 300 | return true; |
301 | 301 | } |
302 | 302 | |
@@ -312,27 +312,27 @@ discard block |
||
312 | 312 | * @param array $posted_data The posted data from checkout form. |
313 | 313 | * @param object $order |
314 | 314 | */ |
315 | - public function add_order_meta( $order_id, $posted_data, $order ) { |
|
316 | - if ( empty( $_POST['payment_request_type'] ) ) { |
|
315 | + public function add_order_meta($order_id, $posted_data, $order) { |
|
316 | + if (empty($_POST['payment_request_type'])) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
320 | - $payment_request_type = wc_clean( $_POST['payment_request_type'] ); |
|
320 | + $payment_request_type = wc_clean($_POST['payment_request_type']); |
|
321 | 321 | |
322 | - if ( 'apple_pay' === $payment_request_type ) { |
|
323 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
324 | - update_post_meta( $order_id, '_payment_method_title', 'Apple Pay (Stripe)' ); |
|
322 | + if ('apple_pay' === $payment_request_type) { |
|
323 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
324 | + update_post_meta($order_id, '_payment_method_title', 'Apple Pay (Stripe)'); |
|
325 | 325 | } else { |
326 | - $order->set_payment_method_title( 'Apple Pay (Stripe)' ); |
|
326 | + $order->set_payment_method_title('Apple Pay (Stripe)'); |
|
327 | 327 | $order->save(); |
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | - if ( 'payment_request_api' === $payment_request_type ) { |
|
332 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
333 | - update_post_meta( $order_id, '_payment_method_title', 'Chrome Payment Request (Stripe)' ); |
|
331 | + if ('payment_request_api' === $payment_request_type) { |
|
332 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
333 | + update_post_meta($order_id, '_payment_method_title', 'Chrome Payment Request (Stripe)'); |
|
334 | 334 | } else { |
335 | - $order->set_payment_method_title( 'Chrome Payment Request (Stripe)' ); |
|
335 | + $order->set_payment_method_title('Chrome Payment Request (Stripe)'); |
|
336 | 336 | $order->save(); |
337 | 337 | } |
338 | 338 | } |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | * @return array |
347 | 347 | */ |
348 | 348 | public function supported_product_types() { |
349 | - return apply_filters( 'wc_stripe_payment_request_supported_types', array( |
|
349 | + return apply_filters('wc_stripe_payment_request_supported_types', array( |
|
350 | 350 | 'simple', |
351 | 351 | 'variable', |
352 | 352 | 'variation', |
353 | - ) ); |
|
353 | + )); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -361,15 +361,15 @@ discard block |
||
361 | 361 | * @return bool |
362 | 362 | */ |
363 | 363 | public function allowed_items_in_cart() { |
364 | - foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { |
|
365 | - $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); |
|
364 | + foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { |
|
365 | + $_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key); |
|
366 | 366 | |
367 | - if ( ! in_array( ( WC_Stripe_Helper::is_pre_30() ? $_product->product_type : $_product->get_type() ), $this->supported_product_types() ) ) { |
|
367 | + if ( ! in_array((WC_Stripe_Helper::is_pre_30() ? $_product->product_type : $_product->get_type()), $this->supported_product_types())) { |
|
368 | 368 | return false; |
369 | 369 | } |
370 | 370 | |
371 | 371 | // Pre Orders compatbility where we don't support charge upon release. |
372 | - if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Cart::cart_contains_pre_order() && WC_Pre_Orders_Product::product_is_charged_upon_release( WC_Pre_Orders_Cart::get_pre_order_product() ) ) { |
|
372 | + if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Cart::cart_contains_pre_order() && WC_Pre_Orders_Product::product_is_charged_upon_release(WC_Pre_Orders_Cart::get_pre_order_product())) { |
|
373 | 373 | return false; |
374 | 374 | } |
375 | 375 | } |
@@ -384,71 +384,71 @@ discard block |
||
384 | 384 | * @version 4.0.0 |
385 | 385 | */ |
386 | 386 | public function scripts() { |
387 | - if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) ) { |
|
387 | + if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order'])) { |
|
388 | 388 | return; |
389 | 389 | } |
390 | 390 | |
391 | - if ( is_product() ) { |
|
391 | + if (is_product()) { |
|
392 | 392 | global $post; |
393 | 393 | |
394 | - $product = wc_get_product( $post->ID ); |
|
394 | + $product = wc_get_product($post->ID); |
|
395 | 395 | |
396 | - if ( ! is_object( $product ) || ! in_array( ( WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) { |
|
396 | + if ( ! is_object($product) || ! in_array((WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type()), $this->supported_product_types())) { |
|
397 | 397 | return; |
398 | 398 | } |
399 | 399 | |
400 | - if ( apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false ) ) { |
|
400 | + if (apply_filters('wc_stripe_hide_payment_request_on_product_page', false)) { |
|
401 | 401 | return; |
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
405 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
406 | 406 | |
407 | - wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true ); |
|
408 | - wp_register_script( 'wc_stripe_payment_request', plugins_url( 'assets/js/stripe-payment-request' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery', 'stripe' ), WC_STRIPE_VERSION, true ); |
|
407 | + wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true); |
|
408 | + wp_register_script('wc_stripe_payment_request', plugins_url('assets/js/stripe-payment-request' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery', 'stripe'), WC_STRIPE_VERSION, true); |
|
409 | 409 | |
410 | 410 | wp_localize_script( |
411 | 411 | 'wc_stripe_payment_request', |
412 | 412 | 'wc_stripe_payment_request_params', |
413 | 413 | array( |
414 | - 'ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ), |
|
414 | + 'ajax_url' => WC_AJAX::get_endpoint('%%endpoint%%'), |
|
415 | 415 | 'stripe' => array( |
416 | 416 | 'key' => $this->get_publishable_key(), |
417 | - 'allow_prepaid_card' => apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no', |
|
417 | + 'allow_prepaid_card' => apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no', |
|
418 | 418 | ), |
419 | 419 | 'nonce' => array( |
420 | - 'payment' => wp_create_nonce( 'wc-stripe-payment-request' ), |
|
421 | - 'shipping' => wp_create_nonce( 'wc-stripe-payment-request-shipping' ), |
|
422 | - 'update_shipping' => wp_create_nonce( 'wc-stripe-update-shipping-method' ), |
|
423 | - 'checkout' => wp_create_nonce( 'woocommerce-process_checkout' ), |
|
424 | - 'add_to_cart' => wp_create_nonce( 'wc-stripe-add-to-cart' ), |
|
425 | - 'get_selected_product_data' => wp_create_nonce( 'wc-stripe-get-selected-product-data' ), |
|
426 | - 'log_errors' => wp_create_nonce( 'wc-stripe-log-errors' ), |
|
427 | - 'clear_cart' => wp_create_nonce( 'wc-stripe-clear-cart' ), |
|
420 | + 'payment' => wp_create_nonce('wc-stripe-payment-request'), |
|
421 | + 'shipping' => wp_create_nonce('wc-stripe-payment-request-shipping'), |
|
422 | + 'update_shipping' => wp_create_nonce('wc-stripe-update-shipping-method'), |
|
423 | + 'checkout' => wp_create_nonce('woocommerce-process_checkout'), |
|
424 | + 'add_to_cart' => wp_create_nonce('wc-stripe-add-to-cart'), |
|
425 | + 'get_selected_product_data' => wp_create_nonce('wc-stripe-get-selected-product-data'), |
|
426 | + 'log_errors' => wp_create_nonce('wc-stripe-log-errors'), |
|
427 | + 'clear_cart' => wp_create_nonce('wc-stripe-clear-cart'), |
|
428 | 428 | ), |
429 | 429 | 'i18n' => array( |
430 | - 'no_prepaid_card' => __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' ), |
|
430 | + 'no_prepaid_card' => __('Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe'), |
|
431 | 431 | /* translators: Do not translate the [option] placeholder */ |
432 | - 'unknown_shipping' => __( 'Unknown shipping option "[option]".', 'woocommerce-gateway-stripe' ), |
|
432 | + 'unknown_shipping' => __('Unknown shipping option "[option]".', 'woocommerce-gateway-stripe'), |
|
433 | 433 | ), |
434 | 434 | 'checkout' => array( |
435 | 435 | 'url' => wc_get_checkout_url(), |
436 | - 'currency_code' => strtolower( get_woocommerce_currency() ), |
|
437 | - 'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ), |
|
436 | + 'currency_code' => strtolower(get_woocommerce_currency()), |
|
437 | + 'country_code' => substr(get_option('woocommerce_default_country'), 0, 2), |
|
438 | 438 | 'needs_shipping' => WC()->cart->needs_shipping() ? 'yes' : 'no', |
439 | 439 | ), |
440 | 440 | 'button' => array( |
441 | 441 | 'type' => $this->get_button_type(), |
442 | 442 | 'theme' => $this->get_button_theme(), |
443 | 443 | 'height' => $this->get_button_height(), |
444 | - 'locale' => substr( get_locale(), 0, 2 ), // Default format is en_US. |
|
444 | + 'locale' => substr(get_locale(), 0, 2), // Default format is en_US. |
|
445 | 445 | ), |
446 | 446 | 'is_product_page' => is_product(), |
447 | 447 | 'product' => $this->get_product_data(), |
448 | 448 | ) |
449 | 449 | ); |
450 | 450 | |
451 | - wp_enqueue_script( 'wc_stripe_payment_request' ); |
|
451 | + wp_enqueue_script('wc_stripe_payment_request'); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -460,35 +460,35 @@ discard block |
||
460 | 460 | public function display_payment_request_button_html() { |
461 | 461 | $gateways = WC()->payment_gateways->get_available_payment_gateways(); |
462 | 462 | |
463 | - if ( ! isset( $gateways['stripe'] ) ) { |
|
463 | + if ( ! isset($gateways['stripe'])) { |
|
464 | 464 | return; |
465 | 465 | } |
466 | 466 | |
467 | - if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) { |
|
467 | + if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset($_GET['pay_for_order'])) { |
|
468 | 468 | return; |
469 | 469 | } |
470 | 470 | |
471 | - if ( is_product() && apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false ) ) { |
|
471 | + if (is_product() && apply_filters('wc_stripe_hide_payment_request_on_product_page', false)) { |
|
472 | 472 | return; |
473 | 473 | } |
474 | 474 | |
475 | - if ( is_product() ) { |
|
475 | + if (is_product()) { |
|
476 | 476 | global $post; |
477 | 477 | |
478 | - $product = wc_get_product( $post->ID ); |
|
478 | + $product = wc_get_product($post->ID); |
|
479 | 479 | |
480 | - if ( ! is_object( $product ) || ! in_array( ( WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) { |
|
480 | + if ( ! is_object($product) || ! in_array((WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type()), $this->supported_product_types())) { |
|
481 | 481 | return; |
482 | 482 | } |
483 | 483 | |
484 | 484 | // Pre Orders charge upon release not supported. |
485 | - if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Product::product_is_charged_upon_release( $product ) ) { |
|
486 | - WC_Stripe_Logger::log( 'Pre Order charge upon release is not supported. ( Payment Request button disabled )' ); |
|
485 | + if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Product::product_is_charged_upon_release($product)) { |
|
486 | + WC_Stripe_Logger::log('Pre Order charge upon release is not supported. ( Payment Request button disabled )'); |
|
487 | 487 | return; |
488 | 488 | } |
489 | 489 | } else { |
490 | - if ( ! $this->allowed_items_in_cart() ) { |
|
491 | - WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' ); |
|
490 | + if ( ! $this->allowed_items_in_cart()) { |
|
491 | + WC_Stripe_Logger::log('Items in the cart has unsupported product type ( Payment Request button disabled )'); |
|
492 | 492 | return; |
493 | 493 | } |
494 | 494 | } |
@@ -510,40 +510,40 @@ discard block |
||
510 | 510 | public function display_payment_request_button_separator_html() { |
511 | 511 | $gateways = WC()->payment_gateways->get_available_payment_gateways(); |
512 | 512 | |
513 | - if ( ! isset( $gateways['stripe'] ) ) { |
|
513 | + if ( ! isset($gateways['stripe'])) { |
|
514 | 514 | return; |
515 | 515 | } |
516 | 516 | |
517 | - if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) { |
|
517 | + if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset($_GET['pay_for_order'])) { |
|
518 | 518 | return; |
519 | 519 | } |
520 | 520 | |
521 | - if ( is_product() && apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false ) ) { |
|
521 | + if (is_product() && apply_filters('wc_stripe_hide_payment_request_on_product_page', false)) { |
|
522 | 522 | return; |
523 | 523 | } |
524 | 524 | |
525 | - if ( is_product() ) { |
|
525 | + if (is_product()) { |
|
526 | 526 | global $post; |
527 | 527 | |
528 | - $product = wc_get_product( $post->ID ); |
|
528 | + $product = wc_get_product($post->ID); |
|
529 | 529 | |
530 | - if ( ! is_object( $product ) || ! in_array( ( WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) { |
|
530 | + if ( ! is_object($product) || ! in_array((WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type()), $this->supported_product_types())) { |
|
531 | 531 | return; |
532 | 532 | } |
533 | 533 | |
534 | 534 | // Pre Orders charge upon release not supported. |
535 | - if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Product::product_is_charged_upon_release( $product ) ) { |
|
536 | - WC_Stripe_Logger::log( 'Pre Order charge upon release is not supported. ( Payment Request button disabled )' ); |
|
535 | + if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Product::product_is_charged_upon_release($product)) { |
|
536 | + WC_Stripe_Logger::log('Pre Order charge upon release is not supported. ( Payment Request button disabled )'); |
|
537 | 537 | return; |
538 | 538 | } |
539 | 539 | } else { |
540 | - if ( ! $this->allowed_items_in_cart() ) { |
|
541 | - WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' ); |
|
540 | + if ( ! $this->allowed_items_in_cart()) { |
|
541 | + WC_Stripe_Logger::log('Items in the cart has unsupported product type ( Payment Request button disabled )'); |
|
542 | 542 | return; |
543 | 543 | } |
544 | 544 | } |
545 | 545 | ?> |
546 | - <p id="wc-stripe-payment-request-button-separator" style="margin-top:1.5em;text-align:center;display:none;">- <?php esc_html_e( 'OR', 'woocommerce-gateway-stripe' ); ?> -</p> |
|
546 | + <p id="wc-stripe-payment-request-button-separator" style="margin-top:1.5em;text-align:center;display:none;">- <?php esc_html_e('OR', 'woocommerce-gateway-stripe'); ?> -</p> |
|
547 | 547 | <?php |
548 | 548 | } |
549 | 549 | |
@@ -554,11 +554,11 @@ discard block |
||
554 | 554 | * @version 4.0.0 |
555 | 555 | */ |
556 | 556 | public function ajax_log_errors() { |
557 | - check_ajax_referer( 'wc-stripe-log-errors', 'security' ); |
|
557 | + check_ajax_referer('wc-stripe-log-errors', 'security'); |
|
558 | 558 | |
559 | - $errors = wc_clean( stripslashes( $_POST['errors'] ) ); |
|
559 | + $errors = wc_clean(stripslashes($_POST['errors'])); |
|
560 | 560 | |
561 | - WC_Stripe_Logger::log( $errors ); |
|
561 | + WC_Stripe_Logger::log($errors); |
|
562 | 562 | |
563 | 563 | exit; |
564 | 564 | } |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | * @version 4.0.0 |
571 | 571 | */ |
572 | 572 | public function ajax_clear_cart() { |
573 | - check_ajax_referer( 'wc-stripe-clear-cart', 'security' ); |
|
573 | + check_ajax_referer('wc-stripe-clear-cart', 'security'); |
|
574 | 574 | |
575 | 575 | WC()->cart->empty_cart(); |
576 | 576 | exit; |
@@ -580,10 +580,10 @@ discard block |
||
580 | 580 | * Get cart details. |
581 | 581 | */ |
582 | 582 | public function ajax_get_cart_details() { |
583 | - check_ajax_referer( 'wc-stripe-payment-request', 'security' ); |
|
583 | + check_ajax_referer('wc-stripe-payment-request', 'security'); |
|
584 | 584 | |
585 | - if ( ! defined( 'WOOCOMMERCE_CART' ) ) { |
|
586 | - define( 'WOOCOMMERCE_CART', true ); |
|
585 | + if ( ! defined('WOOCOMMERCE_CART')) { |
|
586 | + define('WOOCOMMERCE_CART', true); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | WC()->cart->calculate_totals(); |
@@ -594,14 +594,14 @@ discard block |
||
594 | 594 | $data = array( |
595 | 595 | 'shipping_required' => WC()->cart->needs_shipping(), |
596 | 596 | 'order_data' => array( |
597 | - 'currency' => strtolower( $currency ), |
|
598 | - 'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ), |
|
597 | + 'currency' => strtolower($currency), |
|
598 | + 'country_code' => substr(get_option('woocommerce_default_country'), 0, 2), |
|
599 | 599 | ), |
600 | 600 | ); |
601 | 601 | |
602 | 602 | $data['order_data'] += $this->build_display_items(); |
603 | 603 | |
604 | - wp_send_json( $data ); |
|
604 | + wp_send_json($data); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -612,47 +612,47 @@ discard block |
||
612 | 612 | * @see WC_Shipping::get_packages(). |
613 | 613 | */ |
614 | 614 | public function ajax_get_shipping_options() { |
615 | - check_ajax_referer( 'wc-stripe-payment-request-shipping', 'security' ); |
|
615 | + check_ajax_referer('wc-stripe-payment-request-shipping', 'security'); |
|
616 | 616 | |
617 | 617 | try { |
618 | 618 | // Set the shipping package. |
619 | - $posted = filter_input_array( INPUT_POST, array( |
|
619 | + $posted = filter_input_array(INPUT_POST, array( |
|
620 | 620 | 'country' => FILTER_SANITIZE_STRING, |
621 | 621 | 'state' => FILTER_SANITIZE_STRING, |
622 | 622 | 'postcode' => FILTER_SANITIZE_STRING, |
623 | 623 | 'city' => FILTER_SANITIZE_STRING, |
624 | 624 | 'address' => FILTER_SANITIZE_STRING, |
625 | 625 | 'address_2' => FILTER_SANITIZE_STRING, |
626 | - ) ); |
|
626 | + )); |
|
627 | 627 | |
628 | - $this->calculate_shipping( $posted ); |
|
628 | + $this->calculate_shipping($posted); |
|
629 | 629 | |
630 | 630 | // Set the shipping options. |
631 | 631 | $data = array(); |
632 | 632 | $packages = WC()->shipping->get_packages(); |
633 | 633 | |
634 | - if ( ! empty( $packages ) && WC()->customer->has_calculated_shipping() ) { |
|
635 | - foreach ( $packages as $package_key => $package ) { |
|
636 | - if ( empty( $package['rates'] ) ) { |
|
637 | - throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) ); |
|
634 | + if ( ! empty($packages) && WC()->customer->has_calculated_shipping()) { |
|
635 | + foreach ($packages as $package_key => $package) { |
|
636 | + if (empty($package['rates'])) { |
|
637 | + throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe')); |
|
638 | 638 | } |
639 | 639 | |
640 | - foreach ( $package['rates'] as $key => $rate ) { |
|
640 | + foreach ($package['rates'] as $key => $rate) { |
|
641 | 641 | $data['shipping_options'][] = array( |
642 | 642 | 'id' => $rate->id, |
643 | 643 | 'label' => $rate->label, |
644 | 644 | 'detail' => '', |
645 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( $rate->cost ), |
|
645 | + 'amount' => WC_Stripe_Helper::get_stripe_amount($rate->cost), |
|
646 | 646 | ); |
647 | 647 | } |
648 | 648 | } |
649 | 649 | } else { |
650 | - throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) ); |
|
650 | + throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe')); |
|
651 | 651 | } |
652 | 652 | |
653 | - if ( isset( $data[0] ) ) { |
|
653 | + if (isset($data[0])) { |
|
654 | 654 | // Auto select the first shipping method. |
655 | - WC()->session->set( 'chosen_shipping_methods', array( $data[0]['id'] ) ); |
|
655 | + WC()->session->set('chosen_shipping_methods', array($data[0]['id'])); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | WC()->cart->calculate_totals(); |
@@ -660,12 +660,12 @@ discard block |
||
660 | 660 | $data += $this->build_display_items(); |
661 | 661 | $data['result'] = 'success'; |
662 | 662 | |
663 | - wp_send_json( $data ); |
|
664 | - } catch ( Exception $e ) { |
|
663 | + wp_send_json($data); |
|
664 | + } catch (Exception $e) { |
|
665 | 665 | $data += $this->build_display_items(); |
666 | 666 | $data['result'] = 'invalid_shipping_address'; |
667 | 667 | |
668 | - wp_send_json( $data ); |
|
668 | + wp_send_json($data); |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | |
@@ -673,22 +673,22 @@ discard block |
||
673 | 673 | * Update shipping method. |
674 | 674 | */ |
675 | 675 | public function ajax_update_shipping_method() { |
676 | - check_ajax_referer( 'wc-stripe-update-shipping-method', 'security' ); |
|
676 | + check_ajax_referer('wc-stripe-update-shipping-method', 'security'); |
|
677 | 677 | |
678 | - if ( ! defined( 'WOOCOMMERCE_CART' ) ) { |
|
679 | - define( 'WOOCOMMERCE_CART', true ); |
|
678 | + if ( ! defined('WOOCOMMERCE_CART')) { |
|
679 | + define('WOOCOMMERCE_CART', true); |
|
680 | 680 | } |
681 | 681 | |
682 | - $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' ); |
|
683 | - $shipping_method = filter_input( INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
682 | + $chosen_shipping_methods = WC()->session->get('chosen_shipping_methods'); |
|
683 | + $shipping_method = filter_input(INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
684 | 684 | |
685 | - if ( is_array( $shipping_method ) ) { |
|
686 | - foreach ( $shipping_method as $i => $value ) { |
|
687 | - $chosen_shipping_methods[ $i ] = wc_clean( $value ); |
|
685 | + if (is_array($shipping_method)) { |
|
686 | + foreach ($shipping_method as $i => $value) { |
|
687 | + $chosen_shipping_methods[$i] = wc_clean($value); |
|
688 | 688 | } |
689 | 689 | } |
690 | 690 | |
691 | - WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods ); |
|
691 | + WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods); |
|
692 | 692 | |
693 | 693 | WC()->cart->calculate_totals(); |
694 | 694 | |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | $data += $this->build_display_items(); |
697 | 697 | $data['result'] = 'success'; |
698 | 698 | |
699 | - wp_send_json( $data ); |
|
699 | + wp_send_json($data); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | /** |
@@ -707,31 +707,31 @@ discard block |
||
707 | 707 | * @return array $data |
708 | 708 | */ |
709 | 709 | public function ajax_get_selected_product_data() { |
710 | - check_ajax_referer( 'wc-stripe-get-selected-product-data', 'security' ); |
|
710 | + check_ajax_referer('wc-stripe-get-selected-product-data', 'security'); |
|
711 | 711 | |
712 | - $product_id = absint( $_POST['product_id'] ); |
|
713 | - $qty = ! isset( $_POST['qty'] ) ? 1 : absint( $_POST['qty'] ); |
|
712 | + $product_id = absint($_POST['product_id']); |
|
713 | + $qty = ! isset($_POST['qty']) ? 1 : absint($_POST['qty']); |
|
714 | 714 | |
715 | - $product = wc_get_product( $product_id ); |
|
715 | + $product = wc_get_product($product_id); |
|
716 | 716 | |
717 | - if ( 'variable' === ( WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type() ) && isset( $_POST['attributes'] ) ) { |
|
718 | - $attributes = array_map( 'wc_clean', $_POST['attributes'] ); |
|
717 | + if ('variable' === (WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type()) && isset($_POST['attributes'])) { |
|
718 | + $attributes = array_map('wc_clean', $_POST['attributes']); |
|
719 | 719 | |
720 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
721 | - $variation_id = $product->get_matching_variation( $attributes ); |
|
720 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
721 | + $variation_id = $product->get_matching_variation($attributes); |
|
722 | 722 | } else { |
723 | - $data_store = WC_Data_Store::load( 'product' ); |
|
724 | - $variation_id = $data_store->find_matching_product_variation( $product, $attributes ); |
|
723 | + $data_store = WC_Data_Store::load('product'); |
|
724 | + $variation_id = $data_store->find_matching_product_variation($product, $attributes); |
|
725 | 725 | } |
726 | 726 | |
727 | - if ( ! empty( $variation_id ) ) { |
|
728 | - $product = wc_get_product( $variation_id ); |
|
727 | + if ( ! empty($variation_id)) { |
|
728 | + $product = wc_get_product($variation_id); |
|
729 | 729 | } |
730 | - } elseif ( 'simple' === ( WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type() ) ) { |
|
731 | - $product = wc_get_product( $product_id ); |
|
730 | + } elseif ('simple' === (WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type())) { |
|
731 | + $product = wc_get_product($product_id); |
|
732 | 732 | } |
733 | 733 | |
734 | - $total = $qty * ( WC_Stripe_Helper::is_pre_30() ? $product->price : $product->get_price() ); |
|
734 | + $total = $qty * (WC_Stripe_Helper::is_pre_30() ? $product->price : $product->get_price()); |
|
735 | 735 | |
736 | 736 | $quantity_label = 1 < $qty ? ' (x' . $qty . ')' : ''; |
737 | 737 | |
@@ -739,28 +739,28 @@ discard block |
||
739 | 739 | $items = array(); |
740 | 740 | |
741 | 741 | $items[] = array( |
742 | - 'label' => ( WC_Stripe_Helper::is_pre_30() ? $product->name : $product->get_name() ) . $quantity_label, |
|
743 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( $total ), |
|
742 | + 'label' => (WC_Stripe_Helper::is_pre_30() ? $product->name : $product->get_name()) . $quantity_label, |
|
743 | + 'amount' => WC_Stripe_Helper::get_stripe_amount($total), |
|
744 | 744 | ); |
745 | 745 | |
746 | - if ( wc_tax_enabled() ) { |
|
746 | + if (wc_tax_enabled()) { |
|
747 | 747 | $items[] = array( |
748 | - 'label' => __( 'Tax', 'woocommerce-gateway-stripe' ), |
|
748 | + 'label' => __('Tax', 'woocommerce-gateway-stripe'), |
|
749 | 749 | 'amount' => 0, |
750 | 750 | 'pending' => true, |
751 | 751 | ); |
752 | 752 | } |
753 | 753 | |
754 | - if ( wc_shipping_enabled() && $product->needs_shipping() ) { |
|
754 | + if (wc_shipping_enabled() && $product->needs_shipping()) { |
|
755 | 755 | $items[] = array( |
756 | - 'label' => __( 'Shipping', 'woocommerce-gateway-stripe' ), |
|
756 | + 'label' => __('Shipping', 'woocommerce-gateway-stripe'), |
|
757 | 757 | 'amount' => 0, |
758 | 758 | 'pending' => true, |
759 | 759 | ); |
760 | 760 | |
761 | - $data['shippingOptions'] = array( |
|
761 | + $data['shippingOptions'] = array( |
|
762 | 762 | 'id' => 'pending', |
763 | - 'label' => __( 'Pending', 'woocommerce-gateway-stripe' ), |
|
763 | + 'label' => __('Pending', 'woocommerce-gateway-stripe'), |
|
764 | 764 | 'detail' => '', |
765 | 765 | 'amount' => 0, |
766 | 766 | ); |
@@ -769,15 +769,15 @@ discard block |
||
769 | 769 | $data['displayItems'] = $items; |
770 | 770 | $data['total'] = array( |
771 | 771 | 'label' => $this->total_label, |
772 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( $total ), |
|
772 | + 'amount' => WC_Stripe_Helper::get_stripe_amount($total), |
|
773 | 773 | 'pending' => true, |
774 | 774 | ); |
775 | 775 | |
776 | - $data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() ); |
|
777 | - $data['currency'] = strtolower( get_woocommerce_currency() ); |
|
778 | - $data['country_code'] = substr( get_option( 'woocommerce_default_country' ), 0, 2 ); |
|
776 | + $data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping()); |
|
777 | + $data['currency'] = strtolower(get_woocommerce_currency()); |
|
778 | + $data['country_code'] = substr(get_option('woocommerce_default_country'), 0, 2); |
|
779 | 779 | |
780 | - wp_send_json( $data ); |
|
780 | + wp_send_json($data); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | /** |
@@ -788,37 +788,37 @@ discard block |
||
788 | 788 | * @return array $data |
789 | 789 | */ |
790 | 790 | public function ajax_add_to_cart() { |
791 | - check_ajax_referer( 'wc-stripe-add-to-cart', 'security' ); |
|
791 | + check_ajax_referer('wc-stripe-add-to-cart', 'security'); |
|
792 | 792 | |
793 | - if ( ! defined( 'WOOCOMMERCE_CART' ) ) { |
|
794 | - define( 'WOOCOMMERCE_CART', true ); |
|
793 | + if ( ! defined('WOOCOMMERCE_CART')) { |
|
794 | + define('WOOCOMMERCE_CART', true); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | WC()->shipping->reset_shipping(); |
798 | 798 | |
799 | - $product_id = absint( $_POST['product_id'] ); |
|
800 | - $qty = ! isset( $_POST['qty'] ) ? 1 : absint( $_POST['qty'] ); |
|
799 | + $product_id = absint($_POST['product_id']); |
|
800 | + $qty = ! isset($_POST['qty']) ? 1 : absint($_POST['qty']); |
|
801 | 801 | |
802 | - $product = wc_get_product( $product_id ); |
|
802 | + $product = wc_get_product($product_id); |
|
803 | 803 | |
804 | 804 | // First empty the cart to prevent wrong calculation. |
805 | 805 | WC()->cart->empty_cart(); |
806 | 806 | |
807 | - if ( 'variable' === ( WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type() ) && isset( $_POST['attributes'] ) ) { |
|
808 | - $attributes = array_map( 'wc_clean', $_POST['attributes'] ); |
|
807 | + if ('variable' === (WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type()) && isset($_POST['attributes'])) { |
|
808 | + $attributes = array_map('wc_clean', $_POST['attributes']); |
|
809 | 809 | |
810 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
811 | - $variation_id = $product->get_matching_variation( $attributes ); |
|
810 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
811 | + $variation_id = $product->get_matching_variation($attributes); |
|
812 | 812 | } else { |
813 | - $data_store = WC_Data_Store::load( 'product' ); |
|
814 | - $variation_id = $data_store->find_matching_product_variation( $product, $attributes ); |
|
813 | + $data_store = WC_Data_Store::load('product'); |
|
814 | + $variation_id = $data_store->find_matching_product_variation($product, $attributes); |
|
815 | 815 | } |
816 | 816 | |
817 | - WC()->cart->add_to_cart( $product->get_id(), $qty, $variation_id, $attributes ); |
|
817 | + WC()->cart->add_to_cart($product->get_id(), $qty, $variation_id, $attributes); |
|
818 | 818 | } |
819 | 819 | |
820 | - if ( 'simple' === ( WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type() ) ) { |
|
821 | - WC()->cart->add_to_cart( $product->get_id(), $qty ); |
|
820 | + if ('simple' === (WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type())) { |
|
821 | + WC()->cart->add_to_cart($product->get_id(), $qty); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | WC()->cart->calculate_totals(); |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | $data += $this->build_display_items(); |
828 | 828 | $data['result'] = 'success'; |
829 | 829 | |
830 | - wp_send_json( $data ); |
|
830 | + wp_send_json($data); |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | /** |
@@ -840,31 +840,31 @@ discard block |
||
840 | 840 | * @version 4.0.0 |
841 | 841 | */ |
842 | 842 | public function normalize_state() { |
843 | - $billing_country = ! empty( $_POST['billing_country'] ) ? wc_clean( $_POST['billing_country'] ) : ''; |
|
844 | - $shipping_country = ! empty( $_POST['shipping_country'] ) ? wc_clean( $_POST['shipping_country'] ) : ''; |
|
845 | - $billing_state = ! empty( $_POST['billing_state'] ) ? wc_clean( $_POST['billing_state'] ) : ''; |
|
846 | - $shipping_state = ! empty( $_POST['shipping_state'] ) ? wc_clean( $_POST['shipping_state'] ) : ''; |
|
843 | + $billing_country = ! empty($_POST['billing_country']) ? wc_clean($_POST['billing_country']) : ''; |
|
844 | + $shipping_country = ! empty($_POST['shipping_country']) ? wc_clean($_POST['shipping_country']) : ''; |
|
845 | + $billing_state = ! empty($_POST['billing_state']) ? wc_clean($_POST['billing_state']) : ''; |
|
846 | + $shipping_state = ! empty($_POST['shipping_state']) ? wc_clean($_POST['shipping_state']) : ''; |
|
847 | 847 | |
848 | - if ( $billing_state && $billing_country ) { |
|
849 | - $valid_states = WC()->countries->get_states( $billing_country ); |
|
848 | + if ($billing_state && $billing_country) { |
|
849 | + $valid_states = WC()->countries->get_states($billing_country); |
|
850 | 850 | |
851 | 851 | // Valid states found for country. |
852 | - if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) { |
|
853 | - foreach ( $valid_states as $state_abbr => $state ) { |
|
854 | - if ( preg_match( '/' . preg_quote( $state ) . '/i', $billing_state ) ) { |
|
852 | + if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) { |
|
853 | + foreach ($valid_states as $state_abbr => $state) { |
|
854 | + if (preg_match('/' . preg_quote($state) . '/i', $billing_state)) { |
|
855 | 855 | $_POST['billing_state'] = $state_abbr; |
856 | 856 | } |
857 | 857 | } |
858 | 858 | } |
859 | 859 | } |
860 | 860 | |
861 | - if ( $shipping_state && $shipping_country ) { |
|
862 | - $valid_states = WC()->countries->get_states( $shipping_country ); |
|
861 | + if ($shipping_state && $shipping_country) { |
|
862 | + $valid_states = WC()->countries->get_states($shipping_country); |
|
863 | 863 | |
864 | 864 | // Valid states found for country. |
865 | - if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) { |
|
866 | - foreach ( $valid_states as $state_abbr => $state ) { |
|
867 | - if ( preg_match( '/' . preg_quote( $state ) . '/i', $shipping_state ) ) { |
|
865 | + if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) { |
|
866 | + foreach ($valid_states as $state_abbr => $state) { |
|
867 | + if (preg_match('/' . preg_quote($state) . '/i', $shipping_state)) { |
|
868 | 868 | $_POST['shipping_state'] = $state_abbr; |
869 | 869 | } |
870 | 870 | } |
@@ -879,19 +879,19 @@ discard block |
||
879 | 879 | * @version 4.0.0 |
880 | 880 | */ |
881 | 881 | public function ajax_create_order() { |
882 | - if ( WC()->cart->is_empty() ) { |
|
883 | - wp_send_json_error( __( 'Empty cart', 'woocommerce-gateway-stripe' ) ); |
|
882 | + if (WC()->cart->is_empty()) { |
|
883 | + wp_send_json_error(__('Empty cart', 'woocommerce-gateway-stripe')); |
|
884 | 884 | } |
885 | 885 | |
886 | - if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) { |
|
887 | - define( 'WOOCOMMERCE_CHECKOUT', true ); |
|
886 | + if ( ! defined('WOOCOMMERCE_CHECKOUT')) { |
|
887 | + define('WOOCOMMERCE_CHECKOUT', true); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | $this->normalize_state(); |
891 | 891 | |
892 | 892 | WC()->checkout()->process_checkout(); |
893 | 893 | |
894 | - die( 0 ); |
|
894 | + die(0); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | /** |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | * @version 4.0.0 |
902 | 902 | * @param array $address |
903 | 903 | */ |
904 | - protected function calculate_shipping( $address = array() ) { |
|
904 | + protected function calculate_shipping($address = array()) { |
|
905 | 905 | global $states; |
906 | 906 | |
907 | 907 | $country = $address['country']; |
@@ -918,28 +918,28 @@ discard block |
||
918 | 918 | * In some versions of Chrome, state can be a full name. So we need |
919 | 919 | * to convert that to abbreviation as WC is expecting that. |
920 | 920 | */ |
921 | - if ( 2 < strlen( $state ) ) { |
|
922 | - $state = array_search( ucfirst( strtolower( $state ) ), $states[ $country ] ); |
|
921 | + if (2 < strlen($state)) { |
|
922 | + $state = array_search(ucfirst(strtolower($state)), $states[$country]); |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | WC()->shipping->reset_shipping(); |
926 | 926 | |
927 | - if ( $postcode && WC_Validation::is_postcode( $postcode, $country ) ) { |
|
928 | - $postcode = wc_format_postcode( $postcode, $country ); |
|
927 | + if ($postcode && WC_Validation::is_postcode($postcode, $country)) { |
|
928 | + $postcode = wc_format_postcode($postcode, $country); |
|
929 | 929 | } |
930 | 930 | |
931 | - if ( $country ) { |
|
932 | - WC()->customer->set_location( $country, $state, $postcode, $city ); |
|
933 | - WC()->customer->set_shipping_location( $country, $state, $postcode, $city ); |
|
931 | + if ($country) { |
|
932 | + WC()->customer->set_location($country, $state, $postcode, $city); |
|
933 | + WC()->customer->set_shipping_location($country, $state, $postcode, $city); |
|
934 | 934 | } else { |
935 | 935 | WC_Stripe_Helper::is_pre_30() ? WC()->customer->set_to_base() : WC()->customer->set_billing_address_to_base(); |
936 | 936 | WC_Stripe_Helper::is_pre_30() ? WC()->customer->set_shipping_to_base() : WC()->customer->set_shipping_address_to_base(); |
937 | 937 | } |
938 | 938 | |
939 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
940 | - WC()->customer->calculated_shipping( true ); |
|
939 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
940 | + WC()->customer->calculated_shipping(true); |
|
941 | 941 | } else { |
942 | - WC()->customer->set_calculated_shipping( true ); |
|
942 | + WC()->customer->set_calculated_shipping(true); |
|
943 | 943 | WC()->customer->save(); |
944 | 944 | } |
945 | 945 | |
@@ -956,17 +956,17 @@ discard block |
||
956 | 956 | $packages[0]['destination']['address'] = $address_1; |
957 | 957 | $packages[0]['destination']['address_2'] = $address_2; |
958 | 958 | |
959 | - foreach ( WC()->cart->get_cart() as $item ) { |
|
960 | - if ( $item['data']->needs_shipping() ) { |
|
961 | - if ( isset( $item['line_total'] ) ) { |
|
959 | + foreach (WC()->cart->get_cart() as $item) { |
|
960 | + if ($item['data']->needs_shipping()) { |
|
961 | + if (isset($item['line_total'])) { |
|
962 | 962 | $packages[0]['contents_cost'] += $item['line_total']; |
963 | 963 | } |
964 | 964 | } |
965 | 965 | } |
966 | 966 | |
967 | - $packages = apply_filters( 'woocommerce_cart_shipping_packages', $packages ); |
|
967 | + $packages = apply_filters('woocommerce_cart_shipping_packages', $packages); |
|
968 | 968 | |
969 | - WC()->shipping->calculate_shipping( $packages ); |
|
969 | + WC()->shipping->calculate_shipping($packages); |
|
970 | 970 | } |
971 | 971 | |
972 | 972 | /** |
@@ -975,19 +975,19 @@ discard block |
||
975 | 975 | * @since 3.1.0 |
976 | 976 | * @version 4.0.0 |
977 | 977 | */ |
978 | - protected function build_shipping_methods( $shipping_methods ) { |
|
979 | - if ( empty( $shipping_methods ) ) { |
|
978 | + protected function build_shipping_methods($shipping_methods) { |
|
979 | + if (empty($shipping_methods)) { |
|
980 | 980 | return array(); |
981 | 981 | } |
982 | 982 | |
983 | 983 | $shipping = array(); |
984 | 984 | |
985 | - foreach ( $shipping_methods as $method ) { |
|
985 | + foreach ($shipping_methods as $method) { |
|
986 | 986 | $shipping[] = array( |
987 | 987 | 'id' => $method['id'], |
988 | 988 | 'label' => $method['label'], |
989 | 989 | 'detail' => '', |
990 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( $method['amount']['value'] ), |
|
990 | + 'amount' => WC_Stripe_Helper::get_stripe_amount($method['amount']['value']), |
|
991 | 991 | ); |
992 | 992 | } |
993 | 993 | |
@@ -1001,69 +1001,69 @@ discard block |
||
1001 | 1001 | * @version 4.0.0 |
1002 | 1002 | */ |
1003 | 1003 | protected function build_display_items() { |
1004 | - if ( ! defined( 'WOOCOMMERCE_CART' ) ) { |
|
1005 | - define( 'WOOCOMMERCE_CART', true ); |
|
1004 | + if ( ! defined('WOOCOMMERCE_CART')) { |
|
1005 | + define('WOOCOMMERCE_CART', true); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | $items = array(); |
1009 | 1009 | $subtotal = 0; |
1010 | 1010 | |
1011 | 1011 | // Default show only subtotal instead of itemization. |
1012 | - if ( ! apply_filters( 'wc_stripe_payment_request_hide_itemization', true ) ) { |
|
1013 | - foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { |
|
1012 | + if ( ! apply_filters('wc_stripe_payment_request_hide_itemization', true)) { |
|
1013 | + foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { |
|
1014 | 1014 | $amount = $cart_item['line_subtotal']; |
1015 | - $subtotal += $cart_item['line_subtotal']; |
|
1015 | + $subtotal += $cart_item['line_subtotal']; |
|
1016 | 1016 | $quantity_label = 1 < $cart_item['quantity'] ? ' (x' . $cart_item['quantity'] . ')' : ''; |
1017 | 1017 | |
1018 | 1018 | $product_name = WC_Stripe_Helper::is_pre_30() ? $cart_item['data']->post->post_title : $cart_item['data']->get_name(); |
1019 | 1019 | |
1020 | 1020 | $item = array( |
1021 | 1021 | 'label' => $product_name . $quantity_label, |
1022 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( $amount ), |
|
1022 | + 'amount' => WC_Stripe_Helper::get_stripe_amount($amount), |
|
1023 | 1023 | ); |
1024 | 1024 | |
1025 | 1025 | $items[] = $item; |
1026 | 1026 | } |
1027 | 1027 | } |
1028 | 1028 | |
1029 | - $discounts = wc_format_decimal( WC()->cart->get_cart_discount_total(), WC()->cart->dp ); |
|
1030 | - $tax = wc_format_decimal( WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp ); |
|
1031 | - $shipping = wc_format_decimal( WC()->cart->shipping_total, WC()->cart->dp ); |
|
1032 | - $items_total = wc_format_decimal( WC()->cart->cart_contents_total, WC()->cart->dp ) + $discounts; |
|
1033 | - $order_total = wc_format_decimal( $items_total + $tax + $shipping - $discounts, WC()->cart->dp ); |
|
1029 | + $discounts = wc_format_decimal(WC()->cart->get_cart_discount_total(), WC()->cart->dp); |
|
1030 | + $tax = wc_format_decimal(WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp); |
|
1031 | + $shipping = wc_format_decimal(WC()->cart->shipping_total, WC()->cart->dp); |
|
1032 | + $items_total = wc_format_decimal(WC()->cart->cart_contents_total, WC()->cart->dp) + $discounts; |
|
1033 | + $order_total = wc_format_decimal($items_total + $tax + $shipping - $discounts, WC()->cart->dp); |
|
1034 | 1034 | |
1035 | - if ( wc_tax_enabled() ) { |
|
1035 | + if (wc_tax_enabled()) { |
|
1036 | 1036 | $items[] = array( |
1037 | - 'label' => esc_html( __( 'Tax', 'woocommerce-gateway-stripe' ) ), |
|
1038 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( $tax ), |
|
1037 | + 'label' => esc_html(__('Tax', 'woocommerce-gateway-stripe')), |
|
1038 | + 'amount' => WC_Stripe_Helper::get_stripe_amount($tax), |
|
1039 | 1039 | ); |
1040 | 1040 | } |
1041 | 1041 | |
1042 | - if ( WC()->cart->needs_shipping() ) { |
|
1042 | + if (WC()->cart->needs_shipping()) { |
|
1043 | 1043 | $items[] = array( |
1044 | - 'label' => esc_html( __( 'Shipping', 'woocommerce-gateway-stripe' ) ), |
|
1045 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( $shipping ), |
|
1044 | + 'label' => esc_html(__('Shipping', 'woocommerce-gateway-stripe')), |
|
1045 | + 'amount' => WC_Stripe_Helper::get_stripe_amount($shipping), |
|
1046 | 1046 | ); |
1047 | 1047 | } |
1048 | 1048 | |
1049 | - if ( WC()->cart->has_discount() ) { |
|
1049 | + if (WC()->cart->has_discount()) { |
|
1050 | 1050 | $items[] = array( |
1051 | - 'label' => esc_html( __( 'Discount', 'woocommerce-gateway-stripe' ) ), |
|
1052 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( $discounts ), |
|
1051 | + 'label' => esc_html(__('Discount', 'woocommerce-gateway-stripe')), |
|
1052 | + 'amount' => WC_Stripe_Helper::get_stripe_amount($discounts), |
|
1053 | 1053 | ); |
1054 | 1054 | } |
1055 | 1055 | |
1056 | - if ( version_compare( WC_VERSION, '3.2', '<' ) ) { |
|
1056 | + if (version_compare(WC_VERSION, '3.2', '<')) { |
|
1057 | 1057 | $cart_fees = WC()->cart->fees; |
1058 | 1058 | } else { |
1059 | 1059 | $cart_fees = WC()->cart->get_fees(); |
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | // Include fees and taxes as display items. |
1063 | - foreach ( $cart_fees as $key => $fee ) { |
|
1063 | + foreach ($cart_fees as $key => $fee) { |
|
1064 | 1064 | $items[] = array( |
1065 | 1065 | 'label' => $fee->name, |
1066 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( $fee->amount ), |
|
1066 | + 'amount' => WC_Stripe_Helper::get_stripe_amount($fee->amount), |
|
1067 | 1067 | ); |
1068 | 1068 | } |
1069 | 1069 | |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | 'displayItems' => $items, |
1072 | 1072 | 'total' => array( |
1073 | 1073 | 'label' => $this->total_label, |
1074 | - 'amount' => max( 0, apply_filters( 'woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount( $order_total ), $order_total, WC()->cart ) ), |
|
1074 | + 'amount' => max(0, apply_filters('woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount($order_total), $order_total, WC()->cart)), |
|
1075 | 1075 | 'pending' => false, |
1076 | 1076 | ), |
1077 | 1077 | ); |