@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function __construct() { |
59 | 59 | $this->id = 'stripe_giropay'; |
60 | - $this->method_title = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' ); |
|
60 | + $this->method_title = __('Stripe Giropay', 'woocommerce-gateway-stripe'); |
|
61 | 61 | /* translators: link */ |
62 | - $this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe' ) ); |
|
62 | + $this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout§ion=stripe')); |
|
63 | 63 | $this->supports = array( |
64 | 64 | 'products', |
65 | 65 | 'refunds', |
@@ -71,23 +71,23 @@ discard block |
||
71 | 71 | // Load the settings. |
72 | 72 | $this->init_settings(); |
73 | 73 | |
74 | - $main_settings = get_option( 'woocommerce_stripe_settings' ); |
|
75 | - $this->title = $this->get_option( 'title' ); |
|
76 | - $this->description = $this->get_option( 'description' ); |
|
77 | - $this->enabled = $this->get_option( 'enabled' ); |
|
78 | - $this->testmode = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false; |
|
79 | - $this->saved_cards = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false; |
|
80 | - $this->publishable_key = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : ''; |
|
81 | - $this->secret_key = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : ''; |
|
82 | - $this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : ''; |
|
83 | - |
|
84 | - if ( $this->testmode ) { |
|
85 | - $this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : ''; |
|
86 | - $this->secret_key = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : ''; |
|
74 | + $main_settings = get_option('woocommerce_stripe_settings'); |
|
75 | + $this->title = $this->get_option('title'); |
|
76 | + $this->description = $this->get_option('description'); |
|
77 | + $this->enabled = $this->get_option('enabled'); |
|
78 | + $this->testmode = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false; |
|
79 | + $this->saved_cards = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false; |
|
80 | + $this->publishable_key = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : ''; |
|
81 | + $this->secret_key = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : ''; |
|
82 | + $this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : ''; |
|
83 | + |
|
84 | + if ($this->testmode) { |
|
85 | + $this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : ''; |
|
86 | + $this->secret_key = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : ''; |
|
87 | 87 | } |
88 | 88 | |
89 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
90 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
89 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
90 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | public function is_available() { |
117 | - if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
117 | + if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | |
134 | 134 | $icons_str = ''; |
135 | 135 | |
136 | - $icons_str .= isset( $icons['giropay'] ) ? $icons['giropay'] : ''; |
|
136 | + $icons_str .= isset($icons['giropay']) ? $icons['giropay'] : ''; |
|
137 | 137 | |
138 | - return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id ); |
|
138 | + return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -146,19 +146,19 @@ discard block |
||
146 | 146 | * @access public |
147 | 147 | */ |
148 | 148 | public function payment_scripts() { |
149 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { |
|
149 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) { |
|
150 | 150 | return; |
151 | 151 | } |
152 | 152 | |
153 | - wp_enqueue_style( 'stripe_styles' ); |
|
154 | - wp_enqueue_script( 'woocommerce_stripe' ); |
|
153 | + wp_enqueue_style('stripe_styles'); |
|
154 | + wp_enqueue_script('woocommerce_stripe'); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Initialize Gateway Settings Form Fields. |
159 | 159 | */ |
160 | 160 | public function init_form_fields() { |
161 | - $this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-giropay-settings.php' ); |
|
161 | + $this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-giropay-settings.php'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | $description = $this->get_description(); |
171 | 171 | |
172 | 172 | // If paying from order, we need to get total from order not cart. |
173 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
174 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
173 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
174 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
175 | 175 | $total = $order->get_total(); |
176 | 176 | } |
177 | 177 | |
178 | - if ( is_add_payment_method_page() ) { |
|
179 | - $pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' ); |
|
178 | + if (is_add_payment_method_page()) { |
|
179 | + $pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe'); |
|
180 | 180 | $total = ''; |
181 | 181 | } else { |
182 | 182 | $pay_button_text = ''; |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | |
185 | 185 | echo '<div |
186 | 186 | id="stripe-giropay-payment-data" |
187 | - data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '" |
|
188 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">'; |
|
187 | + data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '" |
|
188 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">'; |
|
189 | 189 | |
190 | - if ( $description ) { |
|
191 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id ); |
|
190 | + if ($description) { |
|
191 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | echo '</div>'; |
@@ -202,24 +202,24 @@ discard block |
||
202 | 202 | * @param object $order |
203 | 203 | * @return mixed |
204 | 204 | */ |
205 | - public function create_source( $order ) { |
|
206 | - $currency = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency(); |
|
207 | - $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
208 | - $return_url = $this->get_stripe_return_url( $order ); |
|
205 | + public function create_source($order) { |
|
206 | + $currency = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency(); |
|
207 | + $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
208 | + $return_url = $this->get_stripe_return_url($order); |
|
209 | 209 | $post_data = array(); |
210 | - $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency ); |
|
211 | - $post_data['currency'] = strtolower( $currency ); |
|
210 | + $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency); |
|
211 | + $post_data['currency'] = strtolower($currency); |
|
212 | 212 | $post_data['type'] = 'giropay'; |
213 | - $post_data['owner'] = $this->get_owner_details( $order ); |
|
214 | - $post_data['redirect'] = array( 'return_url' => $return_url ); |
|
213 | + $post_data['owner'] = $this->get_owner_details($order); |
|
214 | + $post_data['redirect'] = array('return_url' => $return_url); |
|
215 | 215 | |
216 | - if ( ! empty( $this->statement_descriptor ) ) { |
|
217 | - $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor ); |
|
216 | + if ( ! empty($this->statement_descriptor)) { |
|
217 | + $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor); |
|
218 | 218 | } |
219 | 219 | |
220 | - WC_Stripe_Logger::log( 'Info: Begin creating Giropay source' ); |
|
220 | + WC_Stripe_Logger::log('Info: Begin creating Giropay source'); |
|
221 | 221 | |
222 | - return WC_Stripe_API::request( apply_filters( 'wc_stripe_giropay_source', $post_data, $order ), 'sources' ); |
|
222 | + return WC_Stripe_API::request(apply_filters('wc_stripe_giropay_source', $post_data, $order), 'sources'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -233,51 +233,51 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return array|void |
235 | 235 | */ |
236 | - public function process_payment( $order_id, $retry = true, $force_save_source = false ) { |
|
236 | + public function process_payment($order_id, $retry = true, $force_save_source = false) { |
|
237 | 237 | try { |
238 | - $order = wc_get_order( $order_id ); |
|
238 | + $order = wc_get_order($order_id); |
|
239 | 239 | |
240 | 240 | // This will throw exception if not valid. |
241 | - $this->validate_minimum_order_amount( $order ); |
|
241 | + $this->validate_minimum_order_amount($order); |
|
242 | 242 | |
243 | 243 | // This comes from the create account checkbox in the checkout page. |
244 | - $create_account = ! empty( $_POST['createaccount'] ) ? true : false; |
|
244 | + $create_account = ! empty($_POST['createaccount']) ? true : false; |
|
245 | 245 | |
246 | - if ( $create_account ) { |
|
247 | - $new_customer_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id(); |
|
248 | - $new_stripe_customer = new WC_Stripe_Customer( $new_customer_id ); |
|
246 | + if ($create_account) { |
|
247 | + $new_customer_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id(); |
|
248 | + $new_stripe_customer = new WC_Stripe_Customer($new_customer_id); |
|
249 | 249 | $new_stripe_customer->create_customer(); |
250 | 250 | } |
251 | 251 | |
252 | - $response = $this->create_source( $order ); |
|
252 | + $response = $this->create_source($order); |
|
253 | 253 | |
254 | - if ( ! empty( $response->error ) ) { |
|
255 | - $order->add_order_note( $response->error->message ); |
|
254 | + if ( ! empty($response->error)) { |
|
255 | + $order->add_order_note($response->error->message); |
|
256 | 256 | |
257 | - throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
257 | + throw new WC_Stripe_Exception(print_r($response, true), $response->error->message); |
|
258 | 258 | } |
259 | 259 | |
260 | - if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) { |
|
261 | - update_post_meta( $order_id, '_stripe_source_id', $response->id ); |
|
260 | + if (WC_Stripe_Helper::is_wc_lt('3.0')) { |
|
261 | + update_post_meta($order_id, '_stripe_source_id', $response->id); |
|
262 | 262 | } else { |
263 | - $order->update_meta_data( '_stripe_source_id', $response->id ); |
|
263 | + $order->update_meta_data('_stripe_source_id', $response->id); |
|
264 | 264 | $order->save(); |
265 | 265 | } |
266 | 266 | |
267 | - WC_Stripe_Logger::log( 'Info: Redirecting to Giropay...' ); |
|
267 | + WC_Stripe_Logger::log('Info: Redirecting to Giropay...'); |
|
268 | 268 | |
269 | 269 | return array( |
270 | 270 | 'result' => 'success', |
271 | - 'redirect' => esc_url_raw( $response->redirect->url ), |
|
271 | + 'redirect' => esc_url_raw($response->redirect->url), |
|
272 | 272 | ); |
273 | - } catch ( WC_Stripe_Exception $e ) { |
|
274 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
275 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
273 | + } catch (WC_Stripe_Exception $e) { |
|
274 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
275 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
276 | 276 | |
277 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
277 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
278 | 278 | |
279 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
280 | - $this->send_failed_order_email( $order_id ); |
|
279 | + if ($order->has_status(array('pending', 'failed'))) { |
|
280 | + $this->send_failed_order_email($order_id); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | return array( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function __construct() { |
59 | 59 | $this->id = 'stripe_bancontact'; |
60 | - $this->method_title = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' ); |
|
60 | + $this->method_title = __('Stripe Bancontact', 'woocommerce-gateway-stripe'); |
|
61 | 61 | /* translators: link */ |
62 | - $this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe' ) ); |
|
62 | + $this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout§ion=stripe')); |
|
63 | 63 | $this->supports = array( |
64 | 64 | 'products', |
65 | 65 | 'refunds', |
@@ -71,23 +71,23 @@ discard block |
||
71 | 71 | // Load the settings. |
72 | 72 | $this->init_settings(); |
73 | 73 | |
74 | - $main_settings = get_option( 'woocommerce_stripe_settings' ); |
|
75 | - $this->title = $this->get_option( 'title' ); |
|
76 | - $this->description = $this->get_option( 'description' ); |
|
77 | - $this->enabled = $this->get_option( 'enabled' ); |
|
78 | - $this->testmode = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false; |
|
79 | - $this->saved_cards = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false; |
|
80 | - $this->publishable_key = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : ''; |
|
81 | - $this->secret_key = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : ''; |
|
82 | - $this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : ''; |
|
83 | - |
|
84 | - if ( $this->testmode ) { |
|
85 | - $this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : ''; |
|
86 | - $this->secret_key = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : ''; |
|
74 | + $main_settings = get_option('woocommerce_stripe_settings'); |
|
75 | + $this->title = $this->get_option('title'); |
|
76 | + $this->description = $this->get_option('description'); |
|
77 | + $this->enabled = $this->get_option('enabled'); |
|
78 | + $this->testmode = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false; |
|
79 | + $this->saved_cards = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false; |
|
80 | + $this->publishable_key = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : ''; |
|
81 | + $this->secret_key = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : ''; |
|
82 | + $this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : ''; |
|
83 | + |
|
84 | + if ($this->testmode) { |
|
85 | + $this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : ''; |
|
86 | + $this->secret_key = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : ''; |
|
87 | 87 | } |
88 | 88 | |
89 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
90 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
89 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
90 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | public function is_available() { |
117 | - if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
117 | + if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | |
134 | 134 | $icons_str = ''; |
135 | 135 | |
136 | - $icons_str .= isset( $icons['bancontact'] ) ? $icons['bancontact'] : ''; |
|
136 | + $icons_str .= isset($icons['bancontact']) ? $icons['bancontact'] : ''; |
|
137 | 137 | |
138 | - return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id ); |
|
138 | + return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -146,19 +146,19 @@ discard block |
||
146 | 146 | * @access public |
147 | 147 | */ |
148 | 148 | public function payment_scripts() { |
149 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { |
|
149 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) { |
|
150 | 150 | return; |
151 | 151 | } |
152 | 152 | |
153 | - wp_enqueue_style( 'stripe_styles' ); |
|
154 | - wp_enqueue_script( 'woocommerce_stripe' ); |
|
153 | + wp_enqueue_style('stripe_styles'); |
|
154 | + wp_enqueue_script('woocommerce_stripe'); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Initialize Gateway Settings Form Fields. |
159 | 159 | */ |
160 | 160 | public function init_form_fields() { |
161 | - $this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-bancontact-settings.php' ); |
|
161 | + $this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-bancontact-settings.php'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | $description = $this->get_description(); |
171 | 171 | |
172 | 172 | // If paying from order, we need to get total from order not cart. |
173 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
174 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
173 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
174 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
175 | 175 | $total = $order->get_total(); |
176 | 176 | } |
177 | 177 | |
178 | - if ( is_add_payment_method_page() ) { |
|
179 | - $pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' ); |
|
178 | + if (is_add_payment_method_page()) { |
|
179 | + $pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe'); |
|
180 | 180 | $total = ''; |
181 | 181 | } else { |
182 | 182 | $pay_button_text = ''; |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | |
185 | 185 | echo '<div |
186 | 186 | id="stripe-bancontact-payment-data" |
187 | - data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '" |
|
188 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">'; |
|
187 | + data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '" |
|
188 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">'; |
|
189 | 189 | |
190 | - if ( $description ) { |
|
191 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id ); |
|
190 | + if ($description) { |
|
191 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | echo '</div>'; |
@@ -202,25 +202,25 @@ discard block |
||
202 | 202 | * @param object $order |
203 | 203 | * @return mixed |
204 | 204 | */ |
205 | - public function create_source( $order ) { |
|
206 | - $currency = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency(); |
|
207 | - $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
208 | - $return_url = $this->get_stripe_return_url( $order ); |
|
205 | + public function create_source($order) { |
|
206 | + $currency = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency(); |
|
207 | + $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
208 | + $return_url = $this->get_stripe_return_url($order); |
|
209 | 209 | $post_data = array(); |
210 | - $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency ); |
|
211 | - $post_data['currency'] = strtolower( $currency ); |
|
210 | + $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency); |
|
211 | + $post_data['currency'] = strtolower($currency); |
|
212 | 212 | $post_data['type'] = 'bancontact'; |
213 | - $post_data['owner'] = $this->get_owner_details( $order ); |
|
214 | - $post_data['redirect'] = array( 'return_url' => $return_url ); |
|
215 | - $post_data['bancontact'] = array( 'preferred_language' => $this->get_locale() ); |
|
213 | + $post_data['owner'] = $this->get_owner_details($order); |
|
214 | + $post_data['redirect'] = array('return_url' => $return_url); |
|
215 | + $post_data['bancontact'] = array('preferred_language' => $this->get_locale()); |
|
216 | 216 | |
217 | - if ( ! empty( $this->statement_descriptor ) ) { |
|
218 | - $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor ); |
|
217 | + if ( ! empty($this->statement_descriptor)) { |
|
218 | + $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor); |
|
219 | 219 | } |
220 | 220 | |
221 | - WC_Stripe_Logger::log( 'Info: Begin creating Bancontact source' ); |
|
221 | + WC_Stripe_Logger::log('Info: Begin creating Bancontact source'); |
|
222 | 222 | |
223 | - return WC_Stripe_API::request( apply_filters( 'wc_stripe_bancontact_source', $post_data, $order ), 'sources' ); |
|
223 | + return WC_Stripe_API::request(apply_filters('wc_stripe_bancontact_source', $post_data, $order), 'sources'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -234,51 +234,51 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return array|void |
236 | 236 | */ |
237 | - public function process_payment( $order_id, $retry = true, $force_save_source = false ) { |
|
237 | + public function process_payment($order_id, $retry = true, $force_save_source = false) { |
|
238 | 238 | try { |
239 | - $order = wc_get_order( $order_id ); |
|
239 | + $order = wc_get_order($order_id); |
|
240 | 240 | |
241 | 241 | // This will throw exception if not valid. |
242 | - $this->validate_minimum_order_amount( $order ); |
|
242 | + $this->validate_minimum_order_amount($order); |
|
243 | 243 | |
244 | 244 | // This comes from the create account checkbox in the checkout page. |
245 | - $create_account = ! empty( $_POST['createaccount'] ) ? true : false; |
|
245 | + $create_account = ! empty($_POST['createaccount']) ? true : false; |
|
246 | 246 | |
247 | - if ( $create_account ) { |
|
248 | - $new_customer_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id(); |
|
249 | - $new_stripe_customer = new WC_Stripe_Customer( $new_customer_id ); |
|
247 | + if ($create_account) { |
|
248 | + $new_customer_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id(); |
|
249 | + $new_stripe_customer = new WC_Stripe_Customer($new_customer_id); |
|
250 | 250 | $new_stripe_customer->create_customer(); |
251 | 251 | } |
252 | 252 | |
253 | - $response = $this->create_source( $order ); |
|
253 | + $response = $this->create_source($order); |
|
254 | 254 | |
255 | - if ( ! empty( $response->error ) ) { |
|
256 | - $order->add_order_note( $response->error->message ); |
|
255 | + if ( ! empty($response->error)) { |
|
256 | + $order->add_order_note($response->error->message); |
|
257 | 257 | |
258 | - throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
258 | + throw new WC_Stripe_Exception(print_r($response, true), $response->error->message); |
|
259 | 259 | } |
260 | 260 | |
261 | - if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) { |
|
262 | - update_post_meta( $order_id, '_stripe_source_id', $response->id ); |
|
261 | + if (WC_Stripe_Helper::is_wc_lt('3.0')) { |
|
262 | + update_post_meta($order_id, '_stripe_source_id', $response->id); |
|
263 | 263 | } else { |
264 | - $order->update_meta_data( '_stripe_source_id', $response->id ); |
|
264 | + $order->update_meta_data('_stripe_source_id', $response->id); |
|
265 | 265 | $order->save(); |
266 | 266 | } |
267 | 267 | |
268 | - WC_Stripe_Logger::log( 'Info: Redirecting to Bancontact...' ); |
|
268 | + WC_Stripe_Logger::log('Info: Redirecting to Bancontact...'); |
|
269 | 269 | |
270 | 270 | return array( |
271 | 271 | 'result' => 'success', |
272 | - 'redirect' => esc_url_raw( $response->redirect->url ), |
|
272 | + 'redirect' => esc_url_raw($response->redirect->url), |
|
273 | 273 | ); |
274 | - } catch ( WC_Stripe_Exception $e ) { |
|
275 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
276 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
274 | + } catch (WC_Stripe_Exception $e) { |
|
275 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
276 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
277 | 277 | |
278 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
278 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
279 | 279 | |
280 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
281 | - $this->send_failed_order_email( $order_id ); |
|
280 | + if ($order->has_status(array('pending', 'failed'))) { |
|
281 | + $this->send_failed_order_email($order_id); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return array( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function __construct() { |
59 | 59 | $this->id = 'stripe_sofort'; |
60 | - $this->method_title = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' ); |
|
60 | + $this->method_title = __('Stripe SOFORT', 'woocommerce-gateway-stripe'); |
|
61 | 61 | /* translators: link */ |
62 | - $this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe' ) ); |
|
62 | + $this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout§ion=stripe')); |
|
63 | 63 | $this->supports = array( |
64 | 64 | 'products', |
65 | 65 | 'refunds', |
@@ -71,23 +71,23 @@ discard block |
||
71 | 71 | // Load the settings. |
72 | 72 | $this->init_settings(); |
73 | 73 | |
74 | - $main_settings = get_option( 'woocommerce_stripe_settings' ); |
|
75 | - $this->title = $this->get_option( 'title' ); |
|
76 | - $this->description = $this->get_option( 'description' ); |
|
77 | - $this->enabled = $this->get_option( 'enabled' ); |
|
78 | - $this->testmode = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false; |
|
79 | - $this->saved_cards = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false; |
|
80 | - $this->publishable_key = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : ''; |
|
81 | - $this->secret_key = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : ''; |
|
82 | - $this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : ''; |
|
83 | - |
|
84 | - if ( $this->testmode ) { |
|
85 | - $this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : ''; |
|
86 | - $this->secret_key = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : ''; |
|
74 | + $main_settings = get_option('woocommerce_stripe_settings'); |
|
75 | + $this->title = $this->get_option('title'); |
|
76 | + $this->description = $this->get_option('description'); |
|
77 | + $this->enabled = $this->get_option('enabled'); |
|
78 | + $this->testmode = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false; |
|
79 | + $this->saved_cards = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false; |
|
80 | + $this->publishable_key = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : ''; |
|
81 | + $this->secret_key = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : ''; |
|
82 | + $this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : ''; |
|
83 | + |
|
84 | + if ($this->testmode) { |
|
85 | + $this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : ''; |
|
86 | + $this->secret_key = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : ''; |
|
87 | 87 | } |
88 | 88 | |
89 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
90 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
89 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
90 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | public function is_available() { |
117 | - if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
117 | + if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | |
134 | 134 | $icons_str = ''; |
135 | 135 | |
136 | - $icons_str .= isset( $icons['sofort'] ) ? $icons['sofort'] : ''; |
|
136 | + $icons_str .= isset($icons['sofort']) ? $icons['sofort'] : ''; |
|
137 | 137 | |
138 | - return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id ); |
|
138 | + return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -146,19 +146,19 @@ discard block |
||
146 | 146 | * @access public |
147 | 147 | */ |
148 | 148 | public function payment_scripts() { |
149 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { |
|
149 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) { |
|
150 | 150 | return; |
151 | 151 | } |
152 | 152 | |
153 | - wp_enqueue_style( 'stripe_styles' ); |
|
154 | - wp_enqueue_script( 'woocommerce_stripe' ); |
|
153 | + wp_enqueue_style('stripe_styles'); |
|
154 | + wp_enqueue_script('woocommerce_stripe'); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Initialize Gateway Settings Form Fields. |
159 | 159 | */ |
160 | 160 | public function init_form_fields() { |
161 | - $this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-sofort-settings.php' ); |
|
161 | + $this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-sofort-settings.php'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | $description = $this->get_description(); |
171 | 171 | |
172 | 172 | // If paying from order, we need to get total from order not cart. |
173 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
174 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
173 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
174 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
175 | 175 | $total = $order->get_total(); |
176 | 176 | } |
177 | 177 | |
178 | - if ( is_add_payment_method_page() ) { |
|
179 | - $pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' ); |
|
178 | + if (is_add_payment_method_page()) { |
|
179 | + $pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe'); |
|
180 | 180 | $total = ''; |
181 | 181 | } else { |
182 | 182 | $pay_button_text = ''; |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | |
185 | 185 | echo '<div |
186 | 186 | id="stripe-sofort-payment-data" |
187 | - data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '" |
|
188 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">'; |
|
187 | + data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '" |
|
188 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">'; |
|
189 | 189 | |
190 | - if ( $description ) { |
|
191 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id ); |
|
190 | + if ($description) { |
|
191 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | echo '</div>'; |
@@ -202,28 +202,28 @@ discard block |
||
202 | 202 | * @param object $order |
203 | 203 | * @return mixed |
204 | 204 | */ |
205 | - public function create_source( $order ) { |
|
206 | - $currency = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency(); |
|
207 | - $bank_country = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_country : $order->get_billing_country(); |
|
208 | - $return_url = $this->get_stripe_return_url( $order ); |
|
205 | + public function create_source($order) { |
|
206 | + $currency = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency(); |
|
207 | + $bank_country = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_country : $order->get_billing_country(); |
|
208 | + $return_url = $this->get_stripe_return_url($order); |
|
209 | 209 | $post_data = array(); |
210 | - $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency ); |
|
211 | - $post_data['currency'] = strtolower( $currency ); |
|
210 | + $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency); |
|
211 | + $post_data['currency'] = strtolower($currency); |
|
212 | 212 | $post_data['type'] = 'sofort'; |
213 | - $post_data['owner'] = $this->get_owner_details( $order ); |
|
214 | - $post_data['redirect'] = array( 'return_url' => $return_url ); |
|
213 | + $post_data['owner'] = $this->get_owner_details($order); |
|
214 | + $post_data['redirect'] = array('return_url' => $return_url); |
|
215 | 215 | $post_data['sofort'] = array( |
216 | 216 | 'country' => $bank_country, |
217 | 217 | 'preferred_language' => $this->get_locale(), |
218 | 218 | ); |
219 | 219 | |
220 | - if ( ! empty( $this->statement_descriptor ) ) { |
|
221 | - $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor ); |
|
220 | + if ( ! empty($this->statement_descriptor)) { |
|
221 | + $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor); |
|
222 | 222 | } |
223 | 223 | |
224 | - WC_Stripe_Logger::log( 'Info: Begin creating SOFORT source' ); |
|
224 | + WC_Stripe_Logger::log('Info: Begin creating SOFORT source'); |
|
225 | 225 | |
226 | - return WC_Stripe_API::request( apply_filters( 'wc_stripe_sofort_source', $post_data, $order ), 'sources' ); |
|
226 | + return WC_Stripe_API::request(apply_filters('wc_stripe_sofort_source', $post_data, $order), 'sources'); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -237,59 +237,59 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return array|void |
239 | 239 | */ |
240 | - public function process_payment( $order_id, $retry = true, $force_save_source = false ) { |
|
240 | + public function process_payment($order_id, $retry = true, $force_save_source = false) { |
|
241 | 241 | try { |
242 | - $order = wc_get_order( $order_id ); |
|
242 | + $order = wc_get_order($order_id); |
|
243 | 243 | |
244 | 244 | // This will throw exception if not valid. |
245 | - $this->validate_minimum_order_amount( $order ); |
|
245 | + $this->validate_minimum_order_amount($order); |
|
246 | 246 | |
247 | 247 | // This comes from the create account checkbox in the checkout page. |
248 | - $create_account = ! empty( $_POST['createaccount'] ) ? true : false; |
|
248 | + $create_account = ! empty($_POST['createaccount']) ? true : false; |
|
249 | 249 | |
250 | - if ( $create_account ) { |
|
251 | - $new_customer_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id(); |
|
252 | - $new_stripe_customer = new WC_Stripe_Customer( $new_customer_id ); |
|
250 | + if ($create_account) { |
|
251 | + $new_customer_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id(); |
|
252 | + $new_stripe_customer = new WC_Stripe_Customer($new_customer_id); |
|
253 | 253 | $new_stripe_customer->create_customer(); |
254 | 254 | } |
255 | 255 | |
256 | - $response = $this->create_source( $order ); |
|
256 | + $response = $this->create_source($order); |
|
257 | 257 | |
258 | - if ( ! empty( $response->error ) ) { |
|
259 | - $order->add_order_note( $response->error->message ); |
|
258 | + if ( ! empty($response->error)) { |
|
259 | + $order->add_order_note($response->error->message); |
|
260 | 260 | |
261 | 261 | $localized_messages = WC_Stripe_Helper::get_localized_messages(); |
262 | 262 | |
263 | - if ( 'invalid_sofort_country' === $response->error->code ) { |
|
264 | - $localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message; |
|
263 | + if ('invalid_sofort_country' === $response->error->code) { |
|
264 | + $localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message; |
|
265 | 265 | } else { |
266 | - $localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message; |
|
266 | + $localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message; |
|
267 | 267 | } |
268 | 268 | |
269 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
269 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
270 | 270 | } |
271 | 271 | |
272 | - if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) { |
|
273 | - update_post_meta( $order_id, '_stripe_source_id', $response->id ); |
|
272 | + if (WC_Stripe_Helper::is_wc_lt('3.0')) { |
|
273 | + update_post_meta($order_id, '_stripe_source_id', $response->id); |
|
274 | 274 | } else { |
275 | - $order->update_meta_data( '_stripe_source_id', $response->id ); |
|
275 | + $order->update_meta_data('_stripe_source_id', $response->id); |
|
276 | 276 | $order->save(); |
277 | 277 | } |
278 | 278 | |
279 | - WC_Stripe_Logger::log( 'Info: Redirecting to SOFORT...' ); |
|
279 | + WC_Stripe_Logger::log('Info: Redirecting to SOFORT...'); |
|
280 | 280 | |
281 | 281 | return array( |
282 | 282 | 'result' => 'success', |
283 | - 'redirect' => esc_url_raw( $response->redirect->url ), |
|
283 | + 'redirect' => esc_url_raw($response->redirect->url), |
|
284 | 284 | ); |
285 | - } catch ( WC_Stripe_Exception $e ) { |
|
286 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
287 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
285 | + } catch (WC_Stripe_Exception $e) { |
|
286 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
287 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
288 | 288 | |
289 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
289 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
290 | 290 | |
291 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
292 | - $this->send_failed_order_email( $order_id ); |
|
291 | + if ($order->has_status(array('pending', 'failed'))) { |
|
292 | + $this->send_failed_order_email($order_id); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | return array( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function __construct() { |
59 | 59 | $this->id = 'stripe_eps'; |
60 | - $this->method_title = __( 'Stripe EPS', 'woocommerce-gateway-stripe' ); |
|
60 | + $this->method_title = __('Stripe EPS', 'woocommerce-gateway-stripe'); |
|
61 | 61 | /* translators: link */ |
62 | - $this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe' ) ); |
|
62 | + $this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout§ion=stripe')); |
|
63 | 63 | $this->supports = array( |
64 | 64 | 'products', |
65 | 65 | 'refunds', |
@@ -71,23 +71,23 @@ discard block |
||
71 | 71 | // Load the settings. |
72 | 72 | $this->init_settings(); |
73 | 73 | |
74 | - $main_settings = get_option( 'woocommerce_stripe_settings' ); |
|
75 | - $this->title = $this->get_option( 'title' ); |
|
76 | - $this->description = $this->get_option( 'description' ); |
|
77 | - $this->enabled = $this->get_option( 'enabled' ); |
|
78 | - $this->testmode = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false; |
|
79 | - $this->saved_cards = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false; |
|
80 | - $this->publishable_key = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : ''; |
|
81 | - $this->secret_key = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : ''; |
|
82 | - $this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : ''; |
|
83 | - |
|
84 | - if ( $this->testmode ) { |
|
85 | - $this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : ''; |
|
86 | - $this->secret_key = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : ''; |
|
74 | + $main_settings = get_option('woocommerce_stripe_settings'); |
|
75 | + $this->title = $this->get_option('title'); |
|
76 | + $this->description = $this->get_option('description'); |
|
77 | + $this->enabled = $this->get_option('enabled'); |
|
78 | + $this->testmode = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false; |
|
79 | + $this->saved_cards = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false; |
|
80 | + $this->publishable_key = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : ''; |
|
81 | + $this->secret_key = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : ''; |
|
82 | + $this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : ''; |
|
83 | + |
|
84 | + if ($this->testmode) { |
|
85 | + $this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : ''; |
|
86 | + $this->secret_key = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : ''; |
|
87 | 87 | } |
88 | 88 | |
89 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
90 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
89 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
90 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | public function is_available() { |
117 | - if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
117 | + if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | |
134 | 134 | $icons_str = ''; |
135 | 135 | |
136 | - $icons_str .= isset( $icons['eps'] ) ? $icons['eps'] : ''; |
|
136 | + $icons_str .= isset($icons['eps']) ? $icons['eps'] : ''; |
|
137 | 137 | |
138 | - return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id ); |
|
138 | + return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -146,19 +146,19 @@ discard block |
||
146 | 146 | * @access public |
147 | 147 | */ |
148 | 148 | public function payment_scripts() { |
149 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { |
|
149 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) { |
|
150 | 150 | return; |
151 | 151 | } |
152 | 152 | |
153 | - wp_enqueue_style( 'stripe_styles' ); |
|
154 | - wp_enqueue_script( 'woocommerce_stripe' ); |
|
153 | + wp_enqueue_style('stripe_styles'); |
|
154 | + wp_enqueue_script('woocommerce_stripe'); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Initialize Gateway Settings Form Fields. |
159 | 159 | */ |
160 | 160 | public function init_form_fields() { |
161 | - $this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-eps-settings.php' ); |
|
161 | + $this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-eps-settings.php'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | $description = $this->get_description(); |
171 | 171 | |
172 | 172 | // If paying from order, we need to get total from order not cart. |
173 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
174 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
173 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
174 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
175 | 175 | $total = $order->get_total(); |
176 | 176 | } |
177 | 177 | |
178 | - if ( is_add_payment_method_page() ) { |
|
179 | - $pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' ); |
|
178 | + if (is_add_payment_method_page()) { |
|
179 | + $pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe'); |
|
180 | 180 | $total = ''; |
181 | 181 | } else { |
182 | 182 | $pay_button_text = ''; |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | |
185 | 185 | echo '<div |
186 | 186 | id="stripe-eps-payment-data" |
187 | - data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '" |
|
188 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">'; |
|
187 | + data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '" |
|
188 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">'; |
|
189 | 189 | |
190 | - if ( $description ) { |
|
191 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id ); |
|
190 | + if ($description) { |
|
191 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | echo '</div>'; |
@@ -202,24 +202,24 @@ discard block |
||
202 | 202 | * @param object $order |
203 | 203 | * @return mixed |
204 | 204 | */ |
205 | - public function create_source( $order ) { |
|
206 | - $currency = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency(); |
|
207 | - $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
208 | - $return_url = $this->get_stripe_return_url( $order ); |
|
205 | + public function create_source($order) { |
|
206 | + $currency = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency(); |
|
207 | + $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
208 | + $return_url = $this->get_stripe_return_url($order); |
|
209 | 209 | $post_data = array(); |
210 | - $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency ); |
|
211 | - $post_data['currency'] = strtolower( $currency ); |
|
210 | + $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency); |
|
211 | + $post_data['currency'] = strtolower($currency); |
|
212 | 212 | $post_data['type'] = 'eps'; |
213 | - $post_data['owner'] = $this->get_owner_details( $order ); |
|
214 | - $post_data['redirect'] = array( 'return_url' => $return_url ); |
|
213 | + $post_data['owner'] = $this->get_owner_details($order); |
|
214 | + $post_data['redirect'] = array('return_url' => $return_url); |
|
215 | 215 | |
216 | - if ( ! empty( $this->statement_descriptor ) ) { |
|
217 | - $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor ); |
|
216 | + if ( ! empty($this->statement_descriptor)) { |
|
217 | + $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor); |
|
218 | 218 | } |
219 | 219 | |
220 | - WC_Stripe_Logger::log( 'Info: Begin creating EPS source' ); |
|
220 | + WC_Stripe_Logger::log('Info: Begin creating EPS source'); |
|
221 | 221 | |
222 | - return WC_Stripe_API::request( $post_data, 'sources' ); |
|
222 | + return WC_Stripe_API::request($post_data, 'sources'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -233,51 +233,51 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return array|void |
235 | 235 | */ |
236 | - public function process_payment( $order_id, $retry = true, $force_save_source = false ) { |
|
236 | + public function process_payment($order_id, $retry = true, $force_save_source = false) { |
|
237 | 237 | try { |
238 | - $order = wc_get_order( $order_id ); |
|
238 | + $order = wc_get_order($order_id); |
|
239 | 239 | |
240 | 240 | // This will throw exception if not valid. |
241 | - $this->validate_minimum_order_amount( $order ); |
|
241 | + $this->validate_minimum_order_amount($order); |
|
242 | 242 | |
243 | 243 | // This comes from the create account checkbox in the checkout page. |
244 | - $create_account = ! empty( $_POST['createaccount'] ) ? true : false; |
|
244 | + $create_account = ! empty($_POST['createaccount']) ? true : false; |
|
245 | 245 | |
246 | - if ( $create_account ) { |
|
247 | - $new_customer_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id(); |
|
248 | - $new_stripe_customer = new WC_Stripe_Customer( $new_customer_id ); |
|
246 | + if ($create_account) { |
|
247 | + $new_customer_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id(); |
|
248 | + $new_stripe_customer = new WC_Stripe_Customer($new_customer_id); |
|
249 | 249 | $new_stripe_customer->create_customer(); |
250 | 250 | } |
251 | 251 | |
252 | - $response = $this->create_source( $order ); |
|
252 | + $response = $this->create_source($order); |
|
253 | 253 | |
254 | - if ( ! empty( $response->error ) ) { |
|
255 | - $order->add_order_note( $response->error->message ); |
|
254 | + if ( ! empty($response->error)) { |
|
255 | + $order->add_order_note($response->error->message); |
|
256 | 256 | |
257 | - throw new Exception( $response->error->message ); |
|
257 | + throw new Exception($response->error->message); |
|
258 | 258 | } |
259 | 259 | |
260 | - if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) { |
|
261 | - update_post_meta( $order_id, '_stripe_source_id', $response->id ); |
|
260 | + if (WC_Stripe_Helper::is_wc_lt('3.0')) { |
|
261 | + update_post_meta($order_id, '_stripe_source_id', $response->id); |
|
262 | 262 | } else { |
263 | - $order->update_meta_data( '_stripe_source_id', $response->id ); |
|
263 | + $order->update_meta_data('_stripe_source_id', $response->id); |
|
264 | 264 | $order->save(); |
265 | 265 | } |
266 | 266 | |
267 | - WC_Stripe_Logger::log( 'Info: Redirecting to EPS...' ); |
|
267 | + WC_Stripe_Logger::log('Info: Redirecting to EPS...'); |
|
268 | 268 | |
269 | 269 | return array( |
270 | 270 | 'result' => 'success', |
271 | - 'redirect' => esc_url_raw( $response->redirect->url ), |
|
271 | + 'redirect' => esc_url_raw($response->redirect->url), |
|
272 | 272 | ); |
273 | - } catch ( Exception $e ) { |
|
274 | - wc_add_notice( $e->getMessage(), 'error' ); |
|
275 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
273 | + } catch (Exception $e) { |
|
274 | + wc_add_notice($e->getMessage(), 'error'); |
|
275 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
276 | 276 | |
277 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
277 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
278 | 278 | |
279 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
280 | - $this->send_failed_order_email( $order_id ); |
|
279 | + if ($order->has_status(array('pending', 'failed'))) { |
|
280 | + $this->send_failed_order_email($order_id); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | return array( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | |
24 | 24 | $this->retry_interval = 1; |
25 | 25 | |
26 | - add_action( 'wp', array( $this, 'maybe_process_redirect_order' ) ); |
|
27 | - add_action( 'woocommerce_order_status_on-hold_to_processing', array( $this, 'capture_payment' ) ); |
|
28 | - add_action( 'woocommerce_order_status_on-hold_to_completed', array( $this, 'capture_payment' ) ); |
|
29 | - add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'cancel_payment' ) ); |
|
30 | - add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'cancel_payment' ) ); |
|
26 | + add_action('wp', array($this, 'maybe_process_redirect_order')); |
|
27 | + add_action('woocommerce_order_status_on-hold_to_processing', array($this, 'capture_payment')); |
|
28 | + add_action('woocommerce_order_status_on-hold_to_completed', array($this, 'capture_payment')); |
|
29 | + add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'cancel_payment')); |
|
30 | + add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'cancel_payment')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -51,25 +51,25 @@ discard block |
||
51 | 51 | * @param bool $retry |
52 | 52 | * @param mix $previous_error Any error message from previous request. |
53 | 53 | */ |
54 | - public function process_redirect_payment( $order_id, $retry = true, $previous_error = false ) { |
|
54 | + public function process_redirect_payment($order_id, $retry = true, $previous_error = false) { |
|
55 | 55 | try { |
56 | - $source = wc_clean( $_GET['source'] ); |
|
56 | + $source = wc_clean($_GET['source']); |
|
57 | 57 | |
58 | - if ( empty( $source ) ) { |
|
58 | + if (empty($source)) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | - if ( empty( $order_id ) ) { |
|
62 | + if (empty($order_id)) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | - $order = wc_get_order( $order_id ); |
|
66 | + $order = wc_get_order($order_id); |
|
67 | 67 | |
68 | - if ( ! is_object( $order ) ) { |
|
68 | + if ( ! is_object($order)) { |
|
69 | 69 | return; |
70 | 70 | } |
71 | 71 | |
72 | - if ( 'processing' === $order->get_status() || 'completed' === $order->get_status() || 'on-hold' === $order->get_status() ) { |
|
72 | + if ('processing' === $order->get_status() || 'completed' === $order->get_status() || 'on-hold' === $order->get_status()) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
@@ -77,124 +77,124 @@ discard block |
||
77 | 77 | $response = null; |
78 | 78 | |
79 | 79 | // This will throw exception if not valid. |
80 | - $this->validate_minimum_order_amount( $order ); |
|
80 | + $this->validate_minimum_order_amount($order); |
|
81 | 81 | |
82 | - WC_Stripe_Logger::log( "Info: (Redirect) Begin processing payment for order $order_id for the amount of {$order->get_total()}" ); |
|
82 | + WC_Stripe_Logger::log("Info: (Redirect) Begin processing payment for order $order_id for the amount of {$order->get_total()}"); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * First check if the source is chargeable at this time. If not, |
86 | 86 | * webhook will take care of it later. |
87 | 87 | */ |
88 | - $source_info = WC_Stripe_API::retrieve( 'sources/' . $source ); |
|
88 | + $source_info = WC_Stripe_API::retrieve('sources/' . $source); |
|
89 | 89 | |
90 | - if ( ! empty( $source_info->error ) ) { |
|
91 | - throw new WC_Stripe_Exception( print_r( $source_info, true ), $source_info->error->message ); |
|
90 | + if ( ! empty($source_info->error)) { |
|
91 | + throw new WC_Stripe_Exception(print_r($source_info, true), $source_info->error->message); |
|
92 | 92 | } |
93 | 93 | |
94 | - if ( 'failed' === $source_info->status || 'canceled' === $source_info->status ) { |
|
95 | - throw new WC_Stripe_Exception( print_r( $source_info, true ), __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ) ); |
|
94 | + if ('failed' === $source_info->status || 'canceled' === $source_info->status) { |
|
95 | + throw new WC_Stripe_Exception(print_r($source_info, true), __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe')); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // If already consumed, then ignore request. |
99 | - if ( 'consumed' === $source_info->status ) { |
|
99 | + if ('consumed' === $source_info->status) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | 103 | // If not chargeable, then ignore request. |
104 | - if ( 'chargeable' !== $source_info->status ) { |
|
104 | + if ('chargeable' !== $source_info->status) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | 108 | // Prep source object. |
109 | 109 | $source_object = new stdClass(); |
110 | 110 | $source_object->token_id = ''; |
111 | - $source_object->customer = $this->get_stripe_customer_id( $order ); |
|
111 | + $source_object->customer = $this->get_stripe_customer_id($order); |
|
112 | 112 | $source_object->source = $source_info->id; |
113 | 113 | $source_object->status = 'chargeable'; |
114 | 114 | |
115 | 115 | /* If we're doing a retry and source is chargeable, we need to pass |
116 | 116 | * a different idempotency key and retry for success. |
117 | 117 | */ |
118 | - if ( $this->need_update_idempotency_key( $source_object, $previous_error ) ) { |
|
119 | - add_filter( 'wc_stripe_idempotency_key', array( $this, 'change_idempotency_key' ), 10, 2 ); |
|
118 | + if ($this->need_update_idempotency_key($source_object, $previous_error)) { |
|
119 | + add_filter('wc_stripe_idempotency_key', array($this, 'change_idempotency_key'), 10, 2); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | // Make the request. |
123 | - $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source_object ), 'charges', 'POST', true ); |
|
123 | + $response = WC_Stripe_API::request($this->generate_payment_request($order, $source_object), 'charges', 'POST', true); |
|
124 | 124 | $headers = $response['headers']; |
125 | 125 | $response = $response['body']; |
126 | 126 | |
127 | - if ( ! empty( $response->error ) ) { |
|
127 | + if ( ! empty($response->error)) { |
|
128 | 128 | // Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without. |
129 | - if ( $this->is_no_such_customer_error( $response->error ) ) { |
|
130 | - if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) { |
|
131 | - delete_user_meta( $order->customer_user, '_stripe_customer_id' ); |
|
132 | - delete_post_meta( $order_id, '_stripe_customer_id' ); |
|
129 | + if ($this->is_no_such_customer_error($response->error)) { |
|
130 | + if (WC_Stripe_Helper::is_wc_lt('3.0')) { |
|
131 | + delete_user_meta($order->customer_user, '_stripe_customer_id'); |
|
132 | + delete_post_meta($order_id, '_stripe_customer_id'); |
|
133 | 133 | } else { |
134 | - delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' ); |
|
135 | - $order->delete_meta_data( '_stripe_customer_id' ); |
|
134 | + delete_user_meta($order->get_customer_id(), '_stripe_customer_id'); |
|
135 | + $order->delete_meta_data('_stripe_customer_id'); |
|
136 | 136 | $order->save(); |
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - if ( $this->is_no_such_token_error( $response->error ) && $prepared_source->token_id ) { |
|
140 | + if ($this->is_no_such_token_error($response->error) && $prepared_source->token_id) { |
|
141 | 141 | // Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message. |
142 | - $wc_token = WC_Payment_Tokens::get( $prepared_source->token_id ); |
|
142 | + $wc_token = WC_Payment_Tokens::get($prepared_source->token_id); |
|
143 | 143 | $wc_token->delete(); |
144 | - $localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' ); |
|
145 | - $order->add_order_note( $localized_message ); |
|
146 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
144 | + $localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe'); |
|
145 | + $order->add_order_note($localized_message); |
|
146 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // We want to retry. |
150 | - if ( $this->is_retryable_error( $response->error ) ) { |
|
151 | - if ( $retry ) { |
|
150 | + if ($this->is_retryable_error($response->error)) { |
|
151 | + if ($retry) { |
|
152 | 152 | // Don't do anymore retries after this. |
153 | - if ( 5 <= $this->retry_interval ) { |
|
154 | - return $this->process_redirect_payment( $order_id, false, $response->error ); |
|
153 | + if (5 <= $this->retry_interval) { |
|
154 | + return $this->process_redirect_payment($order_id, false, $response->error); |
|
155 | 155 | } |
156 | 156 | |
157 | - sleep( $this->retry_interval ); |
|
157 | + sleep($this->retry_interval); |
|
158 | 158 | |
159 | 159 | $this->retry_interval++; |
160 | - return $this->process_redirect_payment( $order_id, true, $response->error ); |
|
160 | + return $this->process_redirect_payment($order_id, true, $response->error); |
|
161 | 161 | } else { |
162 | - $localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' ); |
|
163 | - $order->add_order_note( $localized_message ); |
|
164 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
162 | + $localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe'); |
|
163 | + $order->add_order_note($localized_message); |
|
164 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | $localized_messages = WC_Stripe_Helper::get_localized_messages(); |
169 | 169 | |
170 | - if ( 'card_error' === $response->error->type ) { |
|
171 | - $message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message; |
|
170 | + if ('card_error' === $response->error->type) { |
|
171 | + $message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message; |
|
172 | 172 | } else { |
173 | - $message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message; |
|
173 | + $message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message; |
|
174 | 174 | } |
175 | 175 | |
176 | - throw new WC_Stripe_Exception( print_r( $response, true ), $message ); |
|
176 | + throw new WC_Stripe_Exception(print_r($response, true), $message); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | // To prevent double processing the order on WC side. |
180 | - if ( ! $this->is_original_request( $headers ) ) { |
|
180 | + if ( ! $this->is_original_request($headers)) { |
|
181 | 181 | return; |
182 | 182 | } |
183 | 183 | |
184 | - do_action( 'wc_gateway_stripe_process_redirect_payment', $response, $order ); |
|
184 | + do_action('wc_gateway_stripe_process_redirect_payment', $response, $order); |
|
185 | 185 | |
186 | - $this->process_response( $response, $order ); |
|
186 | + $this->process_response($response, $order); |
|
187 | 187 | |
188 | - } catch ( WC_Stripe_Exception $e ) { |
|
189 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
188 | + } catch (WC_Stripe_Exception $e) { |
|
189 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
190 | 190 | |
191 | - do_action( 'wc_gateway_stripe_process_redirect_payment_error', $e, $order ); |
|
191 | + do_action('wc_gateway_stripe_process_redirect_payment_error', $e, $order); |
|
192 | 192 | |
193 | 193 | /* translators: error message */ |
194 | - $order->update_status( 'failed', sprintf( __( 'Stripe payment failed: %s', 'woocommerce-gateway-stripe' ), $e->getLocalizedMessage() ) ); |
|
194 | + $order->update_status('failed', sprintf(__('Stripe payment failed: %s', 'woocommerce-gateway-stripe'), $e->getLocalizedMessage())); |
|
195 | 195 | |
196 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
197 | - wp_safe_redirect( wc_get_checkout_url() ); |
|
196 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
197 | + wp_safe_redirect(wc_get_checkout_url()); |
|
198 | 198 | exit; |
199 | 199 | } |
200 | 200 | } |
@@ -206,13 +206,13 @@ discard block |
||
206 | 206 | * @version 4.0.0 |
207 | 207 | */ |
208 | 208 | public function maybe_process_redirect_order() { |
209 | - if ( ! is_order_received_page() || empty( $_GET['client_secret'] ) || empty( $_GET['source'] ) ) { |
|
209 | + if ( ! is_order_received_page() || empty($_GET['client_secret']) || empty($_GET['source'])) { |
|
210 | 210 | return; |
211 | 211 | } |
212 | 212 | |
213 | - $order_id = wc_clean( $_GET['order_id'] ); |
|
213 | + $order_id = wc_clean($_GET['order_id']); |
|
214 | 214 | |
215 | - $this->process_redirect_payment( $order_id ); |
|
215 | + $this->process_redirect_payment($order_id); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -222,59 +222,59 @@ discard block |
||
222 | 222 | * @version 4.0.0 |
223 | 223 | * @param int $order_id |
224 | 224 | */ |
225 | - public function capture_payment( $order_id ) { |
|
226 | - $order = wc_get_order( $order_id ); |
|
225 | + public function capture_payment($order_id) { |
|
226 | + $order = wc_get_order($order_id); |
|
227 | 227 | |
228 | - if ( 'stripe' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method() ) ) { |
|
229 | - $charge = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_transaction_id', true ) : $order->get_transaction_id(); |
|
230 | - $captured = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_charge_captured', true ) : $order->get_meta( '_stripe_charge_captured', true ); |
|
228 | + if ('stripe' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method())) { |
|
229 | + $charge = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_transaction_id', true) : $order->get_transaction_id(); |
|
230 | + $captured = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_charge_captured', true) : $order->get_meta('_stripe_charge_captured', true); |
|
231 | 231 | $is_stripe_captured = false; |
232 | 232 | |
233 | - if ( $charge && 'no' === $captured ) { |
|
233 | + if ($charge && 'no' === $captured) { |
|
234 | 234 | $order_total = $order->get_total(); |
235 | 235 | |
236 | - if ( 0 < $order->get_total_refunded() ) { |
|
236 | + if (0 < $order->get_total_refunded()) { |
|
237 | 237 | $order_total = $order_total - $order->get_total_refunded(); |
238 | 238 | } |
239 | 239 | |
240 | 240 | // First retrieve charge to see if it has been captured. |
241 | - $result = WC_Stripe_API::retrieve( 'charges/' . $charge ); |
|
241 | + $result = WC_Stripe_API::retrieve('charges/' . $charge); |
|
242 | 242 | |
243 | - if ( ! empty( $result->error ) ) { |
|
243 | + if ( ! empty($result->error)) { |
|
244 | 244 | /* translators: error message */ |
245 | - $order->add_order_note( sprintf( __( 'Unable to capture charge! %s', 'woocommerce-gateway-stripe' ), $result->error->message ) ); |
|
246 | - } elseif ( false === $result->captured ) { |
|
245 | + $order->add_order_note(sprintf(__('Unable to capture charge! %s', 'woocommerce-gateway-stripe'), $result->error->message)); |
|
246 | + } elseif (false === $result->captured) { |
|
247 | 247 | $result = WC_Stripe_API::request( |
248 | 248 | array( |
249 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( $order_total ), |
|
249 | + 'amount' => WC_Stripe_Helper::get_stripe_amount($order_total), |
|
250 | 250 | 'expand[]' => 'balance_transaction', |
251 | 251 | ), |
252 | 252 | 'charges/' . $charge . '/capture' |
253 | 253 | ); |
254 | 254 | |
255 | - if ( ! empty( $result->error ) ) { |
|
255 | + if ( ! empty($result->error)) { |
|
256 | 256 | /* translators: error message */ |
257 | - $order->update_status( 'failed', sprintf( __( 'Unable to capture charge! %s', 'woocommerce-gateway-stripe' ), $result->error->message ) ); |
|
257 | + $order->update_status('failed', sprintf(__('Unable to capture charge! %s', 'woocommerce-gateway-stripe'), $result->error->message)); |
|
258 | 258 | } else { |
259 | 259 | $is_stripe_captured = true; |
260 | 260 | } |
261 | - } elseif ( true === $result->captured ) { |
|
261 | + } elseif (true === $result->captured) { |
|
262 | 262 | $is_stripe_captured = true; |
263 | 263 | } |
264 | 264 | |
265 | - if ( $is_stripe_captured ) { |
|
265 | + if ($is_stripe_captured) { |
|
266 | 266 | /* translators: transaction id */ |
267 | - $order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $result->id ) ); |
|
268 | - WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_charge_captured', 'yes' ) : $order->update_meta_data( '_stripe_charge_captured', 'yes' ); |
|
267 | + $order->add_order_note(sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $result->id)); |
|
268 | + WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_charge_captured', 'yes') : $order->update_meta_data('_stripe_charge_captured', 'yes'); |
|
269 | 269 | |
270 | 270 | // Store other data such as fees |
271 | - WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $result->id ) : $order->set_transaction_id( $result->id ); |
|
271 | + WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $result->id) : $order->set_transaction_id($result->id); |
|
272 | 272 | |
273 | - $this->update_fees( $order, $result->balance_transaction->id ); |
|
273 | + $this->update_fees($order, $result->balance_transaction->id); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | // This hook fires when admin manually changes order status to processing or completed. |
277 | - do_action( 'woocommerce_stripe_process_manual_capture', $order, $result ); |
|
277 | + do_action('woocommerce_stripe_process_manual_capture', $order, $result); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | } |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | * @version 4.0.0 |
287 | 287 | * @param int $order_id |
288 | 288 | */ |
289 | - public function cancel_payment( $order_id ) { |
|
290 | - $order = wc_get_order( $order_id ); |
|
289 | + public function cancel_payment($order_id) { |
|
290 | + $order = wc_get_order($order_id); |
|
291 | 291 | |
292 | - if ( 'stripe' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method() ) ) { |
|
293 | - $this->process_refund( $order_id ); |
|
292 | + if ('stripe' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method())) { |
|
293 | + $this->process_refund($order_id); |
|
294 | 294 | |
295 | 295 | // This hook fires when admin manually changes order status to cancel. |
296 | - do_action( 'woocommerce_stripe_process_manual_cancel', $order ); |
|
296 | + do_action('woocommerce_stripe_process_manual_cancel', $order); |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
6 | 6 | // if uninstall not called from WordPress exit |
7 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
7 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | |
@@ -13,31 +13,31 @@ discard block |
||
13 | 13 | * wp-config.php. This is to prevent data loss when deleting the plugin from the backend |
14 | 14 | * and to ensure only the site owner can perform this action. |
15 | 15 | */ |
16 | -if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) { |
|
16 | +if (defined('WC_REMOVE_ALL_DATA') && true === WC_REMOVE_ALL_DATA) { |
|
17 | 17 | // Delete options. |
18 | - delete_option( 'woocommerce_stripe_settings' ); |
|
19 | - delete_option( 'wc_stripe_show_styles_notice' ); |
|
20 | - delete_option( 'wc_stripe_show_request_api_notice' ); |
|
21 | - delete_option( 'wc_stripe_show_apple_pay_notice' ); |
|
22 | - delete_option( 'wc_stripe_show_ssl_notice' ); |
|
23 | - delete_option( 'wc_stripe_show_keys_notice' ); |
|
24 | - delete_option( 'wc_stripe_show_alipay_notice' ); |
|
25 | - delete_option( 'wc_stripe_show_bancontact_notice' ); |
|
26 | - delete_option( 'wc_stripe_show_bitcoin_notice' ); |
|
27 | - delete_option( 'wc_stripe_show_eps_notice' ); |
|
28 | - delete_option( 'wc_stripe_show_giropay_notice' ); |
|
29 | - delete_option( 'wc_stripe_show_ideal_notice' ); |
|
30 | - delete_option( 'wc_stripe_show_multibanco_notice' ); |
|
31 | - delete_option( 'wc_stripe_show_p24_notice' ); |
|
32 | - delete_option( 'wc_stripe_show_sepa_notice' ); |
|
33 | - delete_option( 'wc_stripe_show_sofort_notice' ); |
|
34 | - delete_option( 'wc_stripe_version' ); |
|
35 | - delete_option( 'woocommerce_stripe_bancontact_settings' ); |
|
36 | - delete_option( 'woocommerce_stripe_alipay_settings' ); |
|
37 | - delete_option( 'woocommerce_stripe_bitcoin_settings' ); |
|
38 | - delete_option( 'woocommerce_stripe_ideal_settings' ); |
|
39 | - delete_option( 'woocommerce_stripe_p24_settings' ); |
|
40 | - delete_option( 'woocommerce_stripe_giropay_settings' ); |
|
41 | - delete_option( 'woocommerce_stripe_sepa_settings' ); |
|
42 | - delete_option( 'woocommerce_stripe_sofort_settings' ); |
|
18 | + delete_option('woocommerce_stripe_settings'); |
|
19 | + delete_option('wc_stripe_show_styles_notice'); |
|
20 | + delete_option('wc_stripe_show_request_api_notice'); |
|
21 | + delete_option('wc_stripe_show_apple_pay_notice'); |
|
22 | + delete_option('wc_stripe_show_ssl_notice'); |
|
23 | + delete_option('wc_stripe_show_keys_notice'); |
|
24 | + delete_option('wc_stripe_show_alipay_notice'); |
|
25 | + delete_option('wc_stripe_show_bancontact_notice'); |
|
26 | + delete_option('wc_stripe_show_bitcoin_notice'); |
|
27 | + delete_option('wc_stripe_show_eps_notice'); |
|
28 | + delete_option('wc_stripe_show_giropay_notice'); |
|
29 | + delete_option('wc_stripe_show_ideal_notice'); |
|
30 | + delete_option('wc_stripe_show_multibanco_notice'); |
|
31 | + delete_option('wc_stripe_show_p24_notice'); |
|
32 | + delete_option('wc_stripe_show_sepa_notice'); |
|
33 | + delete_option('wc_stripe_show_sofort_notice'); |
|
34 | + delete_option('wc_stripe_version'); |
|
35 | + delete_option('woocommerce_stripe_bancontact_settings'); |
|
36 | + delete_option('woocommerce_stripe_alipay_settings'); |
|
37 | + delete_option('woocommerce_stripe_bitcoin_settings'); |
|
38 | + delete_option('woocommerce_stripe_ideal_settings'); |
|
39 | + delete_option('woocommerce_stripe_p24_settings'); |
|
40 | + delete_option('woocommerce_stripe_giropay_settings'); |
|
41 | + delete_option('woocommerce_stripe_sepa_settings'); |
|
42 | + delete_option('woocommerce_stripe_sofort_settings'); |
|
43 | 43 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -113,9 +113,9 @@ discard block |
||
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,42 +142,42 @@ discard block |
||
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->payment_request = 'yes' === $this->get_option( 'payment_request', 'yes' ); |
|
160 | - |
|
161 | - if ( $this->stripe_checkout ) { |
|
162 | - $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->payment_request = 'yes' === $this->get_option('payment_request', 'yes'); |
|
160 | + |
|
161 | + if ($this->stripe_checkout) { |
|
162 | + $this->order_button_text = __('Continue to payment', 'woocommerce-gateway-stripe'); |
|
163 | 163 | } |
164 | 164 | |
165 | - WC_Stripe_API::set_secret_key( $this->secret_key ); |
|
165 | + WC_Stripe_API::set_secret_key($this->secret_key); |
|
166 | 166 | |
167 | 167 | // Hooks. |
168 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
169 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); |
|
170 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
171 | - add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_fee' ) ); |
|
172 | - add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_payout' ), 20 ); |
|
173 | - add_action( 'woocommerce_customer_save_address', array( $this, 'show_update_card_notice' ), 10, 2 ); |
|
174 | - add_action( 'woocommerce_receipt_stripe', array( $this, 'stripe_checkout_receipt_page' ) ); |
|
175 | - add_action( 'woocommerce_api_' . strtolower( get_class( $this ) ), array( $this, 'stripe_checkout_return_handler' ) ); |
|
176 | - |
|
177 | - if ( WC_Stripe_Helper::is_pre_orders_exists() ) { |
|
168 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
169 | + add_action('admin_enqueue_scripts', array($this, 'admin_scripts')); |
|
170 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
171 | + add_action('woocommerce_admin_order_totals_after_total', array($this, 'display_order_fee')); |
|
172 | + add_action('woocommerce_admin_order_totals_after_total', array($this, 'display_order_payout'), 20); |
|
173 | + add_action('woocommerce_customer_save_address', array($this, 'show_update_card_notice'), 10, 2); |
|
174 | + add_action('woocommerce_receipt_stripe', array($this, 'stripe_checkout_receipt_page')); |
|
175 | + add_action('woocommerce_api_' . strtolower(get_class($this)), array($this, 'stripe_checkout_return_handler')); |
|
176 | + |
|
177 | + if (WC_Stripe_Helper::is_pre_orders_exists()) { |
|
178 | 178 | $this->pre_orders = new WC_Stripe_Pre_Orders_Compat(); |
179 | 179 | |
180 | - add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this->pre_orders, 'process_pre_order_release_payment' ) ); |
|
180 | + add_action('wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array($this->pre_orders, 'process_pre_order_release_payment')); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @return bool |
189 | 189 | */ |
190 | 190 | public function are_keys_set() { |
191 | - if ( empty( $this->secret_key ) || empty( $this->publishable_key ) ) { |
|
191 | + if (empty($this->secret_key) || empty($this->publishable_key)) { |
|
192 | 192 | return false; |
193 | 193 | } |
194 | 194 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @since 4.0.2 |
202 | 202 | */ |
203 | 203 | public function is_available() { |
204 | - if ( is_add_payment_method_page() && ! $this->saved_cards ) { |
|
204 | + if (is_add_payment_method_page() && ! $this->saved_cards) { |
|
205 | 205 | return false; |
206 | 206 | } |
207 | 207 | |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | * @param int $user_id |
216 | 216 | * @param array $load_address |
217 | 217 | */ |
218 | - public function show_update_card_notice( $user_id, $load_address ) { |
|
219 | - if ( ! $this->saved_cards || ! WC_Stripe_Payment_Tokens::customer_has_saved_methods( $user_id ) || 'billing' !== $load_address ) { |
|
218 | + public function show_update_card_notice($user_id, $load_address) { |
|
219 | + if ( ! $this->saved_cards || ! WC_Stripe_Payment_Tokens::customer_has_saved_methods($user_id) || 'billing' !== $load_address) { |
|
220 | 220 | return; |
221 | 221 | } |
222 | 222 | |
223 | 223 | /* translators: 1) Opening anchor tag 2) closing anchor tag */ |
224 | - wc_add_notice( sprintf( __( 'If your billing address has been changed for saved payment methods, be sure to remove any %1$ssaved payment methods%2$s on file and re-add them.', 'woocommerce-gateway-stripe' ), '<a href="' . esc_url( wc_get_endpoint_url( 'payment-methods' ) ) . '" class="wc-stripe-update-card-notice" style="text-decoration:underline;">', '</a>' ), 'notice' ); |
|
224 | + wc_add_notice(sprintf(__('If your billing address has been changed for saved payment methods, be sure to remove any %1$ssaved payment methods%2$s on file and re-add them.', 'woocommerce-gateway-stripe'), '<a href="' . esc_url(wc_get_endpoint_url('payment-methods')) . '" class="wc-stripe-update-card-notice" style="text-decoration:underline;">', '</a>'), 'notice'); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -236,24 +236,24 @@ discard block |
||
236 | 236 | |
237 | 237 | $icons_str = ''; |
238 | 238 | |
239 | - $icons_str .= isset( $icons['visa'] ) ? $icons['visa'] : ''; |
|
240 | - $icons_str .= isset( $icons['amex'] ) ? $icons['amex'] : ''; |
|
241 | - $icons_str .= isset( $icons['mastercard'] ) ? $icons['mastercard'] : ''; |
|
239 | + $icons_str .= isset($icons['visa']) ? $icons['visa'] : ''; |
|
240 | + $icons_str .= isset($icons['amex']) ? $icons['amex'] : ''; |
|
241 | + $icons_str .= isset($icons['mastercard']) ? $icons['mastercard'] : ''; |
|
242 | 242 | |
243 | - if ( 'USD' === get_woocommerce_currency() ) { |
|
244 | - $icons_str .= isset( $icons['discover'] ) ? $icons['discover'] : ''; |
|
245 | - $icons_str .= isset( $icons['jcb'] ) ? $icons['jcb'] : ''; |
|
246 | - $icons_str .= isset( $icons['diners'] ) ? $icons['diners'] : ''; |
|
243 | + if ('USD' === get_woocommerce_currency()) { |
|
244 | + $icons_str .= isset($icons['discover']) ? $icons['discover'] : ''; |
|
245 | + $icons_str .= isset($icons['jcb']) ? $icons['jcb'] : ''; |
|
246 | + $icons_str .= isset($icons['diners']) ? $icons['diners'] : ''; |
|
247 | 247 | } |
248 | 248 | |
249 | - return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id ); |
|
249 | + return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Initialise Gateway Settings Form Fields |
254 | 254 | */ |
255 | 255 | public function init_form_fields() { |
256 | - $this->form_fields = require( dirname( __FILE__ ) . '/admin/stripe-settings.php' ); |
|
256 | + $this->form_fields = require(dirname(__FILE__) . '/admin/stripe-settings.php'); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -261,34 +261,34 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function payment_fields() { |
263 | 263 | $user = wp_get_current_user(); |
264 | - $display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards; |
|
264 | + $display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards; |
|
265 | 265 | $total = WC()->cart->total; |
266 | 266 | $user_email = ''; |
267 | 267 | $description = $this->get_description(); |
268 | - $description = ! empty( $description ) ? $description : ''; |
|
268 | + $description = ! empty($description) ? $description : ''; |
|
269 | 269 | $firstname = ''; |
270 | 270 | $lastname = ''; |
271 | 271 | |
272 | 272 | // If paying from order, we need to get total from order not cart. |
273 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
274 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
273 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
274 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
275 | 275 | $total = $order->get_total(); |
276 | - $user_email = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_email : $order->get_billing_email(); |
|
276 | + $user_email = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_email : $order->get_billing_email(); |
|
277 | 277 | } else { |
278 | - if ( $user->ID ) { |
|
279 | - $user_email = get_user_meta( $user->ID, 'billing_email', true ); |
|
278 | + if ($user->ID) { |
|
279 | + $user_email = get_user_meta($user->ID, 'billing_email', true); |
|
280 | 280 | $user_email = $user_email ? $user_email : $user->user_email; |
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
284 | - if ( is_add_payment_method_page() ) { |
|
285 | - $pay_button_text = __( 'Add Card', 'woocommerce-gateway-stripe' ); |
|
284 | + if (is_add_payment_method_page()) { |
|
285 | + $pay_button_text = __('Add Card', 'woocommerce-gateway-stripe'); |
|
286 | 286 | $total = ''; |
287 | 287 | $firstname = $user->user_firstname; |
288 | 288 | $lastname = $user->user_lastname; |
289 | 289 | |
290 | - } elseif ( function_exists( 'wcs_order_contains_subscription' ) && isset( $_GET['change_payment_method'] ) ) { |
|
291 | - $pay_button_text = __( 'Change Payment Method', 'woocommerce-gateway-stripe' ); |
|
290 | + } elseif (function_exists('wcs_order_contains_subscription') && isset($_GET['change_payment_method'])) { |
|
291 | + $pay_button_text = __('Change Payment Method', 'woocommerce-gateway-stripe'); |
|
292 | 292 | $total = ''; |
293 | 293 | } else { |
294 | 294 | $pay_button_text = ''; |
@@ -298,49 +298,49 @@ discard block |
||
298 | 298 | |
299 | 299 | echo '<div |
300 | 300 | id="stripe-payment-data" |
301 | - data-panel-label="' . esc_attr( $pay_button_text ) . '" |
|
302 | - data-description="' . esc_attr( wp_strip_all_tags( $this->stripe_checkout_description ) ) . '" |
|
303 | - data-email="' . esc_attr( $user_email ) . '" |
|
304 | - data-verify-zip="' . esc_attr( apply_filters( 'wc_stripe_checkout_verify_zip', false ) ? 'true' : 'false' ) . '" |
|
305 | - data-billing-address="' . esc_attr( apply_filters( 'wc_stripe_checkout_require_billing_address', false ) ? 'true' : 'false' ) . '" |
|
306 | - data-shipping-address="' . esc_attr( apply_filters( 'wc_stripe_checkout_require_shipping_address', false ) ? 'true' : 'false' ) . '" |
|
307 | - data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '" |
|
308 | - data-name="' . esc_attr( $this->statement_descriptor ) . '" |
|
309 | - data-full-name="' . esc_attr( $firstname . ' ' . $lastname ) . '" |
|
310 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '" |
|
311 | - data-image="' . esc_attr( $this->stripe_checkout_image ) . '" |
|
312 | - data-locale="' . esc_attr( apply_filters( 'wc_stripe_checkout_locale', $this->get_locale() ) ) . '" |
|
313 | - data-three-d-secure="' . esc_attr( $this->three_d_secure ? 'true' : 'false' ) . '" |
|
314 | - data-allow-remember-me="' . esc_attr( apply_filters( 'wc_stripe_allow_remember_me', true ) ? 'true' : 'false' ) . '">'; |
|
315 | - |
|
316 | - if ( $this->testmode ) { |
|
301 | + data-panel-label="' . esc_attr($pay_button_text) . '" |
|
302 | + data-description="' . esc_attr(wp_strip_all_tags($this->stripe_checkout_description)) . '" |
|
303 | + data-email="' . esc_attr($user_email) . '" |
|
304 | + data-verify-zip="' . esc_attr(apply_filters('wc_stripe_checkout_verify_zip', false) ? 'true' : 'false') . '" |
|
305 | + data-billing-address="' . esc_attr(apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'true' : 'false') . '" |
|
306 | + data-shipping-address="' . esc_attr(apply_filters('wc_stripe_checkout_require_shipping_address', false) ? 'true' : 'false') . '" |
|
307 | + data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '" |
|
308 | + data-name="' . esc_attr($this->statement_descriptor) . '" |
|
309 | + data-full-name="' . esc_attr($firstname . ' ' . $lastname) . '" |
|
310 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '" |
|
311 | + data-image="' . esc_attr($this->stripe_checkout_image) . '" |
|
312 | + data-locale="' . esc_attr(apply_filters('wc_stripe_checkout_locale', $this->get_locale())) . '" |
|
313 | + data-three-d-secure="' . esc_attr($this->three_d_secure ? 'true' : 'false') . '" |
|
314 | + data-allow-remember-me="' . esc_attr(apply_filters('wc_stripe_allow_remember_me', true) ? 'true' : 'false') . '">'; |
|
315 | + |
|
316 | + if ($this->testmode) { |
|
317 | 317 | /* translators: link to Stripe testing page */ |
318 | - $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 <a href="%s" target="_blank">Testing Stripe documentation</a> for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' ); |
|
318 | + $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 <a href="%s" target="_blank">Testing Stripe documentation</a> for more card numbers.', 'woocommerce-gateway-stripe'), 'https://stripe.com/docs/testing'); |
|
319 | 319 | } |
320 | 320 | |
321 | - $description = trim( $description ); |
|
321 | + $description = trim($description); |
|
322 | 322 | |
323 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id ); |
|
323 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id); |
|
324 | 324 | |
325 | - if ( $display_tokenization ) { |
|
325 | + if ($display_tokenization) { |
|
326 | 326 | $this->tokenization_script(); |
327 | 327 | $this->saved_payment_methods(); |
328 | 328 | } |
329 | 329 | |
330 | - if ( ! $this->stripe_checkout ) { |
|
330 | + if ( ! $this->stripe_checkout) { |
|
331 | 331 | $this->elements_form(); |
332 | 332 | } |
333 | 333 | |
334 | - if ( apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) { |
|
334 | + if (apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) { |
|
335 | 335 | |
336 | - if ( ! $this->stripe_checkout ) { |
|
336 | + if ( ! $this->stripe_checkout) { |
|
337 | 337 | $this->save_payment_method_checkbox(); |
338 | - } elseif ( $this->stripe_checkout && isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
338 | + } elseif ($this->stripe_checkout && isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
339 | 339 | $this->save_payment_method_checkbox(); |
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | - do_action( 'wc_stripe_cards_payment_fields', $this->id ); |
|
343 | + do_action('wc_stripe_cards_payment_fields', $this->id); |
|
344 | 344 | |
345 | 345 | echo '</div>'; |
346 | 346 | |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public function elements_form() { |
357 | 357 | ?> |
358 | - <fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;"> |
|
359 | - <?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?> |
|
358 | + <fieldset id="wc-<?php echo esc_attr($this->id); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;"> |
|
359 | + <?php do_action('woocommerce_credit_card_form_start', $this->id); ?> |
|
360 | 360 | |
361 | - <?php if ( $this->inline_cc_form ) { ?> |
|
361 | + <?php if ($this->inline_cc_form) { ?> |
|
362 | 362 | <label for="card-element"> |
363 | - <?php esc_html_e( 'Credit or debit card', 'woocommerce-gateway-stripe' ); ?> |
|
363 | + <?php esc_html_e('Credit or debit card', 'woocommerce-gateway-stripe'); ?> |
|
364 | 364 | </label> |
365 | 365 | |
366 | 366 | <div id="stripe-card-element" class="wc-stripe-elements-field"> |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | </div> |
369 | 369 | <?php } else { ?> |
370 | 370 | <div class="form-row form-row-wide"> |
371 | - <label for="stripe-card-element"><?php esc_html_e( 'Card Number', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label> |
|
371 | + <label for="stripe-card-element"><?php esc_html_e('Card Number', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label> |
|
372 | 372 | <div class="stripe-card-group"> |
373 | 373 | <div id="stripe-card-element" class="wc-stripe-elements-field"> |
374 | 374 | <!-- a Stripe Element will be inserted here. --> |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | </div> |
380 | 380 | |
381 | 381 | <div class="form-row form-row-first"> |
382 | - <label for="stripe-exp-element"><?php esc_html_e( 'Expiry Date', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label> |
|
382 | + <label for="stripe-exp-element"><?php esc_html_e('Expiry Date', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label> |
|
383 | 383 | |
384 | 384 | <div id="stripe-exp-element" class="wc-stripe-elements-field"> |
385 | 385 | <!-- a Stripe Element will be inserted here. --> |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | </div> |
388 | 388 | |
389 | 389 | <div class="form-row form-row-last"> |
390 | - <label for="stripe-cvc-element"><?php esc_html_e( 'Card Code (CVC)', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label> |
|
390 | + <label for="stripe-cvc-element"><?php esc_html_e('Card Code (CVC)', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label> |
|
391 | 391 | <div id="stripe-cvc-element" class="wc-stripe-elements-field"> |
392 | 392 | <!-- a Stripe Element will be inserted here. --> |
393 | 393 | </div> |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | <!-- Used to display form errors --> |
399 | 399 | <div class="stripe-source-errors" role="alert"></div> |
400 | 400 | <br /> |
401 | - <?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?> |
|
401 | + <?php do_action('woocommerce_credit_card_form_end', $this->id); ?> |
|
402 | 402 | <div class="clear"></div> |
403 | 403 | </fieldset> |
404 | 404 | <?php |
@@ -411,13 +411,13 @@ discard block |
||
411 | 411 | * @version 3.1.0 |
412 | 412 | */ |
413 | 413 | public function admin_scripts() { |
414 | - if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) { |
|
414 | + if ('woocommerce_page_wc-settings' !== get_current_screen()->id) { |
|
415 | 415 | return; |
416 | 416 | } |
417 | 417 | |
418 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
418 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
419 | 419 | |
420 | - wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true ); |
|
420 | + wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -429,101 +429,101 @@ discard block |
||
429 | 429 | * @version 4.0.0 |
430 | 430 | */ |
431 | 431 | public function payment_scripts() { |
432 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) { |
|
432 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) { |
|
433 | 433 | return; |
434 | 434 | } |
435 | 435 | |
436 | 436 | // If Stripe is not enabled bail. |
437 | - if ( 'no' === $this->enabled ) { |
|
437 | + if ('no' === $this->enabled) { |
|
438 | 438 | return; |
439 | 439 | } |
440 | 440 | |
441 | 441 | // If keys are not set bail. |
442 | - if ( ! $this->are_keys_set() ) { |
|
443 | - WC_Stripe_Logger::log( 'Keys are not set correctly.' ); |
|
442 | + if ( ! $this->are_keys_set()) { |
|
443 | + WC_Stripe_Logger::log('Keys are not set correctly.'); |
|
444 | 444 | return; |
445 | 445 | } |
446 | 446 | |
447 | 447 | // If no SSL bail. |
448 | - if ( ! $this->testmode && ! is_ssl() ) { |
|
449 | - WC_Stripe_Logger::log( 'Stripe live mode requires SSL.' ); |
|
448 | + if ( ! $this->testmode && ! is_ssl()) { |
|
449 | + WC_Stripe_Logger::log('Stripe live mode requires SSL.'); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | $current_theme = wp_get_theme(); |
453 | 453 | |
454 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
454 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
455 | 455 | |
456 | - wp_register_style( 'stripe_styles', plugins_url( 'assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION ); |
|
457 | - wp_enqueue_style( 'stripe_styles' ); |
|
456 | + wp_register_style('stripe_styles', plugins_url('assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION); |
|
457 | + wp_enqueue_style('stripe_styles'); |
|
458 | 458 | |
459 | - wp_register_script( 'stripe_checkout', 'https://checkout.stripe.com/checkout.js', '', WC_STRIPE_VERSION, true ); |
|
460 | - wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true ); |
|
461 | - wp_register_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripe' ), WC_STRIPE_VERSION, true ); |
|
459 | + wp_register_script('stripe_checkout', 'https://checkout.stripe.com/checkout.js', '', WC_STRIPE_VERSION, true); |
|
460 | + wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true); |
|
461 | + wp_register_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true); |
|
462 | 462 | |
463 | 463 | $stripe_params = array( |
464 | 464 | 'key' => $this->publishable_key, |
465 | - 'i18n_terms' => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ), |
|
466 | - 'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ), |
|
465 | + 'i18n_terms' => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'), |
|
466 | + 'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'), |
|
467 | 467 | ); |
468 | 468 | |
469 | 469 | // If we're on the pay page we need to pass stripe.js the address of the order. |
470 | - if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) { |
|
471 | - $order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) ); |
|
472 | - $order = wc_get_order( $order_id ); |
|
473 | - |
|
474 | - if ( is_a( $order, 'WC_Order' ) ) { |
|
475 | - $stripe_params['billing_first_name'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_first_name : $order->get_billing_first_name(); |
|
476 | - $stripe_params['billing_last_name'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_last_name : $order->get_billing_last_name(); |
|
477 | - $stripe_params['billing_address_1'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_address_1 : $order->get_billing_address_1(); |
|
478 | - $stripe_params['billing_address_2'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_address_2 : $order->get_billing_address_2(); |
|
479 | - $stripe_params['billing_state'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_state : $order->get_billing_state(); |
|
480 | - $stripe_params['billing_city'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_city : $order->get_billing_city(); |
|
481 | - $stripe_params['billing_postcode'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_postcode : $order->get_billing_postcode(); |
|
482 | - $stripe_params['billing_country'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_country : $order->get_billing_country(); |
|
470 | + if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) { |
|
471 | + $order_id = wc_get_order_id_by_order_key(urldecode($_GET['key'])); |
|
472 | + $order = wc_get_order($order_id); |
|
473 | + |
|
474 | + if (is_a($order, 'WC_Order')) { |
|
475 | + $stripe_params['billing_first_name'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_first_name : $order->get_billing_first_name(); |
|
476 | + $stripe_params['billing_last_name'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_last_name : $order->get_billing_last_name(); |
|
477 | + $stripe_params['billing_address_1'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_address_1 : $order->get_billing_address_1(); |
|
478 | + $stripe_params['billing_address_2'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_address_2 : $order->get_billing_address_2(); |
|
479 | + $stripe_params['billing_state'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_state : $order->get_billing_state(); |
|
480 | + $stripe_params['billing_city'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_city : $order->get_billing_city(); |
|
481 | + $stripe_params['billing_postcode'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_postcode : $order->get_billing_postcode(); |
|
482 | + $stripe_params['billing_country'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_country : $order->get_billing_country(); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
486 | - $stripe_params['no_prepaid_card_msg'] = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe' ); |
|
487 | - $stripe_params['no_sepa_owner_msg'] = __( 'Please enter your IBAN account name.', 'woocommerce-gateway-stripe' ); |
|
488 | - $stripe_params['no_sepa_iban_msg'] = __( 'Please enter your IBAN account number.', 'woocommerce-gateway-stripe' ); |
|
489 | - $stripe_params['sepa_mandate_notification'] = apply_filters( 'wc_stripe_sepa_mandate_notification', 'email' ); |
|
490 | - $stripe_params['allow_prepaid_card'] = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no'; |
|
486 | + $stripe_params['no_prepaid_card_msg'] = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe'); |
|
487 | + $stripe_params['no_sepa_owner_msg'] = __('Please enter your IBAN account name.', 'woocommerce-gateway-stripe'); |
|
488 | + $stripe_params['no_sepa_iban_msg'] = __('Please enter your IBAN account number.', 'woocommerce-gateway-stripe'); |
|
489 | + $stripe_params['sepa_mandate_notification'] = apply_filters('wc_stripe_sepa_mandate_notification', 'email'); |
|
490 | + $stripe_params['allow_prepaid_card'] = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no'; |
|
491 | 491 | $stripe_params['inline_cc_form'] = $this->inline_cc_form ? 'yes' : 'no'; |
492 | - $stripe_params['stripe_checkout_require_billing_address'] = apply_filters( 'wc_stripe_checkout_require_billing_address', false ) ? 'yes' : 'no'; |
|
493 | - $stripe_params['is_checkout'] = ( is_checkout() && empty( $_GET['pay_for_order'] ) ) ? 'yes' : 'no'; |
|
492 | + $stripe_params['stripe_checkout_require_billing_address'] = apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'yes' : 'no'; |
|
493 | + $stripe_params['is_checkout'] = (is_checkout() && empty($_GET['pay_for_order'])) ? 'yes' : 'no'; |
|
494 | 494 | $stripe_params['return_url'] = $this->get_stripe_return_url(); |
495 | - $stripe_params['ajaxurl'] = WC_AJAX::get_endpoint( '%%endpoint%%' ); |
|
496 | - $stripe_params['stripe_nonce'] = wp_create_nonce( '_wc_stripe_nonce' ); |
|
495 | + $stripe_params['ajaxurl'] = WC_AJAX::get_endpoint('%%endpoint%%'); |
|
496 | + $stripe_params['stripe_nonce'] = wp_create_nonce('_wc_stripe_nonce'); |
|
497 | 497 | $stripe_params['statement_descriptor'] = $this->statement_descriptor; |
498 | - $stripe_params['elements_options'] = apply_filters( 'wc_stripe_elements_options', array() ); |
|
498 | + $stripe_params['elements_options'] = apply_filters('wc_stripe_elements_options', array()); |
|
499 | 499 | $stripe_params['sepa_elements_options'] = apply_filters( |
500 | 500 | 'wc_stripe_sepa_elements_options', |
501 | 501 | array( |
502 | - 'supportedCountries' => array( 'SEPA' ), |
|
502 | + 'supportedCountries' => array('SEPA'), |
|
503 | 503 | 'placeholderCountry' => WC()->countries->get_base_country(), |
504 | - 'style' => array( 'base' => array( 'fontSize' => '15px' ) ), |
|
504 | + 'style' => array('base' => array('fontSize' => '15px')), |
|
505 | 505 | ) |
506 | 506 | ); |
507 | - $stripe_params['invalid_owner_name'] = __( 'Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe' ); |
|
507 | + $stripe_params['invalid_owner_name'] = __('Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe'); |
|
508 | 508 | $stripe_params['is_stripe_checkout'] = $this->stripe_checkout ? 'yes' : 'no'; |
509 | - $stripe_params['is_change_payment_page'] = isset( $_GET['change_payment_method'] ) ? 'yes' : 'no'; |
|
510 | - $stripe_params['is_add_payment_page'] = is_wc_endpoint_url( 'add-payment-method' ) ? 'yes' : 'no'; |
|
511 | - $stripe_params['is_pay_for_order_page'] = is_wc_endpoint_url( 'order-pay' ) ? 'yes' : 'no'; |
|
512 | - $stripe_params['elements_styling'] = apply_filters( 'wc_stripe_elements_styling', false ); |
|
513 | - $stripe_params['elements_classes'] = apply_filters( 'wc_stripe_elements_classes', false ); |
|
509 | + $stripe_params['is_change_payment_page'] = isset($_GET['change_payment_method']) ? 'yes' : 'no'; |
|
510 | + $stripe_params['is_add_payment_page'] = is_wc_endpoint_url('add-payment-method') ? 'yes' : 'no'; |
|
511 | + $stripe_params['is_pay_for_order_page'] = is_wc_endpoint_url('order-pay') ? 'yes' : 'no'; |
|
512 | + $stripe_params['elements_styling'] = apply_filters('wc_stripe_elements_styling', false); |
|
513 | + $stripe_params['elements_classes'] = apply_filters('wc_stripe_elements_classes', false); |
|
514 | 514 | |
515 | 515 | // merge localized messages to be use in JS |
516 | - $stripe_params = array_merge( $stripe_params, WC_Stripe_Helper::get_localized_messages() ); |
|
516 | + $stripe_params = array_merge($stripe_params, WC_Stripe_Helper::get_localized_messages()); |
|
517 | 517 | |
518 | - wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) ); |
|
519 | - wp_localize_script( 'woocommerce_stripe_checkout', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) ); |
|
518 | + wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params)); |
|
519 | + wp_localize_script('woocommerce_stripe_checkout', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params)); |
|
520 | 520 | |
521 | - if ( $this->stripe_checkout ) { |
|
522 | - wp_enqueue_script( 'stripe_checkout' ); |
|
521 | + if ($this->stripe_checkout) { |
|
522 | + wp_enqueue_script('stripe_checkout'); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | $this->tokenization_script(); |
526 | - wp_enqueue_script( 'woocommerce_stripe' ); |
|
526 | + wp_enqueue_script('woocommerce_stripe'); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -531,70 +531,70 @@ discard block |
||
531 | 531 | * |
532 | 532 | * @since 4.1.0 |
533 | 533 | */ |
534 | - public function stripe_checkout_receipt_page( $order_id ) { |
|
535 | - if ( ! $this->stripe_checkout ) { |
|
534 | + public function stripe_checkout_receipt_page($order_id) { |
|
535 | + if ( ! $this->stripe_checkout) { |
|
536 | 536 | return; |
537 | 537 | } |
538 | 538 | |
539 | 539 | $user = wp_get_current_user(); |
540 | 540 | $total = WC()->cart->total; |
541 | 541 | $user_email = ''; |
542 | - $display_tokenization = $this->supports( 'tokenization' ) && $this->saved_cards; |
|
542 | + $display_tokenization = $this->supports('tokenization') && $this->saved_cards; |
|
543 | 543 | |
544 | 544 | // If paying from order, we need to get total from order not cart. |
545 | - if ( ! empty( $_GET['key'] ) ) { |
|
546 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
545 | + if ( ! empty($_GET['key'])) { |
|
546 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
547 | 547 | $total = $order->get_total(); |
548 | - $user_email = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_email : $order->get_billing_email(); |
|
548 | + $user_email = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_email : $order->get_billing_email(); |
|
549 | 549 | } else { |
550 | - if ( $user->ID ) { |
|
551 | - $user_email = get_user_meta( $user->ID, 'billing_email', true ); |
|
550 | + if ($user->ID) { |
|
551 | + $user_email = get_user_meta($user->ID, 'billing_email', true); |
|
552 | 552 | $user_email = $user_email ? $user_email : $user->user_email; |
553 | 553 | } |
554 | 554 | } |
555 | 555 | |
556 | 556 | ob_start(); |
557 | 557 | |
558 | - do_action( 'wc_stripe_checkout_receipt_page_before_form' ); |
|
558 | + do_action('wc_stripe_checkout_receipt_page_before_form'); |
|
559 | 559 | |
560 | - echo '<form method="post" class="woocommerce-checkout" action="' . WC()->api_request_url( get_class( $this ) ) . '">'; |
|
560 | + echo '<form method="post" class="woocommerce-checkout" action="' . WC()->api_request_url(get_class($this)) . '">'; |
|
561 | 561 | echo '<div |
562 | 562 | id="stripe-payment-data" |
563 | - data-panel-label="' . esc_attr( apply_filters( 'wc_stripe_checkout_label', '' ) ) . '" |
|
564 | - data-description="' . esc_attr( wp_strip_all_tags( $this->stripe_checkout_description ) ) . '" |
|
565 | - data-email="' . esc_attr( $user_email ) . '" |
|
566 | - data-verify-zip="' . esc_attr( apply_filters( 'wc_stripe_checkout_verify_zip', false ) ? 'true' : 'false' ) . '" |
|
567 | - data-billing-address="' . esc_attr( apply_filters( 'wc_stripe_checkout_require_billing_address', false ) ? 'true' : 'false' ) . '" |
|
568 | - data-shipping-address="' . esc_attr( apply_filters( 'wc_stripe_checkout_require_shipping_address', false ) ? 'true' : 'false' ) . '" |
|
569 | - data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '" |
|
570 | - data-name="' . esc_attr( $this->statement_descriptor ) . '" |
|
571 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '" |
|
572 | - data-image="' . esc_attr( $this->stripe_checkout_image ) . '" |
|
573 | - data-locale="' . esc_attr( apply_filters( 'wc_stripe_checkout_locale', $this->get_locale() ) ) . '" |
|
574 | - data-three-d-secure="' . esc_attr( $this->three_d_secure ? 'true' : 'false' ) . '" |
|
575 | - data-allow-remember-me="' . esc_attr( apply_filters( 'wc_stripe_allow_remember_me', true ) ? 'true' : 'false' ) . '">'; |
|
576 | - echo '<input type="hidden" name="order_id" value="' . esc_attr( $order_id ) . '" />'; |
|
563 | + data-panel-label="' . esc_attr(apply_filters('wc_stripe_checkout_label', '')) . '" |
|
564 | + data-description="' . esc_attr(wp_strip_all_tags($this->stripe_checkout_description)) . '" |
|
565 | + data-email="' . esc_attr($user_email) . '" |
|
566 | + data-verify-zip="' . esc_attr(apply_filters('wc_stripe_checkout_verify_zip', false) ? 'true' : 'false') . '" |
|
567 | + data-billing-address="' . esc_attr(apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'true' : 'false') . '" |
|
568 | + data-shipping-address="' . esc_attr(apply_filters('wc_stripe_checkout_require_shipping_address', false) ? 'true' : 'false') . '" |
|
569 | + data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '" |
|
570 | + data-name="' . esc_attr($this->statement_descriptor) . '" |
|
571 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '" |
|
572 | + data-image="' . esc_attr($this->stripe_checkout_image) . '" |
|
573 | + data-locale="' . esc_attr(apply_filters('wc_stripe_checkout_locale', $this->get_locale())) . '" |
|
574 | + data-three-d-secure="' . esc_attr($this->three_d_secure ? 'true' : 'false') . '" |
|
575 | + data-allow-remember-me="' . esc_attr(apply_filters('wc_stripe_allow_remember_me', true) ? 'true' : 'false') . '">'; |
|
576 | + echo '<input type="hidden" name="order_id" value="' . esc_attr($order_id) . '" />'; |
|
577 | 577 | echo '<input type="hidden" name="stripe_checkout_order" value="yes" />'; |
578 | 578 | |
579 | 579 | if ( |
580 | - apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && |
|
581 | - ( ! function_exists( 'wcs_order_contains_subscription' ) || ( function_exists( 'wcs_order_contains_subscription' ) && ! WC_Subscriptions_Cart::cart_contains_subscription() ) ) && |
|
582 | - ( ! WC_Stripe_Helper::is_pre_orders_exists() || ( WC_Stripe_Helper::is_pre_orders_exists() && ! $this->pre_orders->is_pre_order( $order_id ) ) ) |
|
580 | + apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && |
|
581 | + ( ! function_exists('wcs_order_contains_subscription') || (function_exists('wcs_order_contains_subscription') && ! WC_Subscriptions_Cart::cart_contains_subscription())) && |
|
582 | + ( ! WC_Stripe_Helper::is_pre_orders_exists() || (WC_Stripe_Helper::is_pre_orders_exists() && ! $this->pre_orders->is_pre_order($order_id))) |
|
583 | 583 | ) { |
584 | 584 | $this->save_payment_method_checkbox(); |
585 | 585 | } |
586 | 586 | |
587 | - wp_nonce_field( 'stripe-checkout-process', 'stripe_checkout_process_nonce' ); |
|
587 | + wp_nonce_field('stripe-checkout-process', 'stripe_checkout_process_nonce'); |
|
588 | 588 | |
589 | - do_action( 'wc_stripe_checkout_receipt_page_before_form_submit' ); |
|
589 | + do_action('wc_stripe_checkout_receipt_page_before_form_submit'); |
|
590 | 590 | |
591 | - echo '<button type="submit" class="wc-stripe-checkout-button">' . __( 'Place Order', 'woocommerce-gateway-stripe' ) . '</button>'; |
|
591 | + echo '<button type="submit" class="wc-stripe-checkout-button">' . __('Place Order', 'woocommerce-gateway-stripe') . '</button>'; |
|
592 | 592 | |
593 | - do_action( 'wc_stripe_checkout_receipt_page_after_form_submit' ); |
|
593 | + do_action('wc_stripe_checkout_receipt_page_after_form_submit'); |
|
594 | 594 | |
595 | 595 | echo '</form>'; |
596 | 596 | |
597 | - do_action( 'wc_stripe_checkout_receipt_page_after_form' ); |
|
597 | + do_action('wc_stripe_checkout_receipt_page_after_form'); |
|
598 | 598 | |
599 | 599 | echo '</div>'; |
600 | 600 | |
@@ -607,32 +607,32 @@ discard block |
||
607 | 607 | * @since 4.1.0 |
608 | 608 | */ |
609 | 609 | public function stripe_checkout_return_handler() { |
610 | - if ( ! $this->stripe_checkout ) { |
|
610 | + if ( ! $this->stripe_checkout) { |
|
611 | 611 | return; |
612 | 612 | } |
613 | 613 | |
614 | - if ( ! wp_verify_nonce( $_POST['stripe_checkout_process_nonce'], 'stripe-checkout-process' ) ) { |
|
614 | + if ( ! wp_verify_nonce($_POST['stripe_checkout_process_nonce'], 'stripe-checkout-process')) { |
|
615 | 615 | return; |
616 | 616 | } |
617 | 617 | |
618 | - $order_id = wc_clean( $_POST['order_id'] ); |
|
619 | - $order = wc_get_order( $order_id ); |
|
618 | + $order_id = wc_clean($_POST['order_id']); |
|
619 | + $order = wc_get_order($order_id); |
|
620 | 620 | |
621 | - do_action( 'wc_stripe_checkout_return_handler', $order ); |
|
621 | + do_action('wc_stripe_checkout_return_handler', $order); |
|
622 | 622 | |
623 | - if ( WC_Stripe_Helper::is_pre_orders_exists() && $this->pre_orders->is_pre_order( $order_id ) && WC_Pre_Orders_Order::order_requires_payment_tokenization( $order_id ) ) { |
|
624 | - $result = $this->pre_orders->process_pre_order( $order_id ); |
|
623 | + if (WC_Stripe_Helper::is_pre_orders_exists() && $this->pre_orders->is_pre_order($order_id) && WC_Pre_Orders_Order::order_requires_payment_tokenization($order_id)) { |
|
624 | + $result = $this->pre_orders->process_pre_order($order_id); |
|
625 | 625 | } else { |
626 | - $result = $this->process_payment( $order_id ); |
|
626 | + $result = $this->process_payment($order_id); |
|
627 | 627 | } |
628 | 628 | |
629 | - if ( 'success' === $result['result'] ) { |
|
630 | - wp_redirect( $result['redirect'] ); |
|
629 | + if ('success' === $result['result']) { |
|
630 | + wp_redirect($result['redirect']); |
|
631 | 631 | exit; |
632 | 632 | } |
633 | 633 | |
634 | 634 | // Redirects back to pay order page. |
635 | - wp_safe_redirect( $order->get_checkout_payment_url( true ) ); |
|
635 | + wp_safe_redirect($order->get_checkout_payment_url(true)); |
|
636 | 636 | exit; |
637 | 637 | } |
638 | 638 | |
@@ -643,13 +643,13 @@ discard block |
||
643 | 643 | * @return bool |
644 | 644 | */ |
645 | 645 | public function maybe_redirect_stripe_checkout() { |
646 | - $is_payment_request = ( isset( $_POST ) && isset( $_POST['payment_request_type'] ) ); |
|
646 | + $is_payment_request = (isset($_POST) && isset($_POST['payment_request_type'])); |
|
647 | 647 | |
648 | 648 | return ( |
649 | 649 | $this->stripe_checkout && |
650 | - ! isset( $_POST['stripe_checkout_order'] ) && |
|
650 | + ! isset($_POST['stripe_checkout_order']) && |
|
651 | 651 | ! $this->is_using_saved_payment_method() && |
652 | - ! is_wc_endpoint_url( 'order-pay' ) && |
|
652 | + ! is_wc_endpoint_url('order-pay') && |
|
653 | 653 | ! $is_payment_request |
654 | 654 | ); |
655 | 655 | } |
@@ -668,53 +668,53 @@ discard block |
||
668 | 668 | * |
669 | 669 | * @return array|void |
670 | 670 | */ |
671 | - public function process_payment( $order_id, $retry = true, $force_save_source = false, $previous_error = false ) { |
|
671 | + public function process_payment($order_id, $retry = true, $force_save_source = false, $previous_error = false) { |
|
672 | 672 | try { |
673 | - $order = wc_get_order( $order_id ); |
|
673 | + $order = wc_get_order($order_id); |
|
674 | 674 | |
675 | - if ( $this->maybe_redirect_stripe_checkout() ) { |
|
676 | - WC_Stripe_Logger::log( sprintf( 'Redirecting to Stripe Checkout page for order %s', $order_id ) ); |
|
675 | + if ($this->maybe_redirect_stripe_checkout()) { |
|
676 | + WC_Stripe_Logger::log(sprintf('Redirecting to Stripe Checkout page for order %s', $order_id)); |
|
677 | 677 | |
678 | 678 | return array( |
679 | 679 | 'result' => 'success', |
680 | - 'redirect' => $order->get_checkout_payment_url( true ), |
|
680 | + 'redirect' => $order->get_checkout_payment_url(true), |
|
681 | 681 | ); |
682 | 682 | } |
683 | 683 | |
684 | - if ( $this->maybe_process_pre_orders( $order_id ) ) { |
|
685 | - return $this->pre_orders->process_pre_order( $order_id ); |
|
684 | + if ($this->maybe_process_pre_orders($order_id)) { |
|
685 | + return $this->pre_orders->process_pre_order($order_id); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | // This comes from the create account checkbox in the checkout page. |
689 | - $create_account = ! empty( $_POST['createaccount'] ) ? true : false; |
|
689 | + $create_account = ! empty($_POST['createaccount']) ? true : false; |
|
690 | 690 | |
691 | - if ( $create_account ) { |
|
692 | - $new_customer_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id(); |
|
693 | - $new_stripe_customer = new WC_Stripe_Customer( $new_customer_id ); |
|
691 | + if ($create_account) { |
|
692 | + $new_customer_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id(); |
|
693 | + $new_stripe_customer = new WC_Stripe_Customer($new_customer_id); |
|
694 | 694 | $new_stripe_customer->create_customer(); |
695 | 695 | } |
696 | 696 | |
697 | - $prepared_source = $this->prepare_source( get_current_user_id(), $force_save_source ); |
|
697 | + $prepared_source = $this->prepare_source(get_current_user_id(), $force_save_source); |
|
698 | 698 | |
699 | 699 | // Check if we don't allow prepaid credit cards. |
700 | - if ( ! apply_filters( 'wc_stripe_allow_prepaid_card', true ) && $this->is_prepaid_card( $prepared_source->source_object ) ) { |
|
701 | - $localized_message = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe' ); |
|
702 | - throw new WC_Stripe_Exception( print_r( $prepared_source->source_object, true ), $localized_message ); |
|
700 | + if ( ! apply_filters('wc_stripe_allow_prepaid_card', true) && $this->is_prepaid_card($prepared_source->source_object)) { |
|
701 | + $localized_message = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe'); |
|
702 | + throw new WC_Stripe_Exception(print_r($prepared_source->source_object, true), $localized_message); |
|
703 | 703 | } |
704 | 704 | |
705 | - if ( empty( $prepared_source->source ) ) { |
|
706 | - $localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' ); |
|
707 | - throw new WC_Stripe_Exception( print_r( $prepared_source, true ), $localized_message ); |
|
705 | + if (empty($prepared_source->source)) { |
|
706 | + $localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe'); |
|
707 | + throw new WC_Stripe_Exception(print_r($prepared_source, true), $localized_message); |
|
708 | 708 | } |
709 | 709 | |
710 | - $this->save_source_to_order( $order, $prepared_source ); |
|
710 | + $this->save_source_to_order($order, $prepared_source); |
|
711 | 711 | |
712 | 712 | // Result from Stripe API request. |
713 | 713 | $response = null; |
714 | 714 | |
715 | - if ( $order->get_total() > 0 ) { |
|
715 | + if ($order->get_total() > 0) { |
|
716 | 716 | // This will throw exception if not valid. |
717 | - $this->validate_minimum_order_amount( $order ); |
|
717 | + $this->validate_minimum_order_amount($order); |
|
718 | 718 | |
719 | 719 | /* |
720 | 720 | * Check if card 3DS is required or optional with 3DS setting. |
@@ -723,22 +723,22 @@ discard block |
||
723 | 723 | * Note that if we need to save source, the original source must be first |
724 | 724 | * attached to a customer in Stripe before it can be charged. |
725 | 725 | */ |
726 | - if ( $this->is_3ds_required( $prepared_source->source_object ) ) { |
|
727 | - $response = $this->create_3ds_source( $order, $prepared_source->source_object ); |
|
726 | + if ($this->is_3ds_required($prepared_source->source_object)) { |
|
727 | + $response = $this->create_3ds_source($order, $prepared_source->source_object); |
|
728 | 728 | |
729 | - if ( ! empty( $response->error ) ) { |
|
729 | + if ( ! empty($response->error)) { |
|
730 | 730 | $localized_message = $response->error->message; |
731 | 731 | |
732 | - $order->add_order_note( $localized_message ); |
|
732 | + $order->add_order_note($localized_message); |
|
733 | 733 | |
734 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
734 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | // Update order meta with 3DS source. |
738 | - if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) { |
|
739 | - update_post_meta( $order_id, '_stripe_source_id', $response->id ); |
|
738 | + if (WC_Stripe_Helper::is_wc_lt('3.0')) { |
|
739 | + update_post_meta($order_id, '_stripe_source_id', $response->id); |
|
740 | 740 | } else { |
741 | - $order->update_meta_data( '_stripe_source_id', $response->id ); |
|
741 | + $order->update_meta_data('_stripe_source_id', $response->id); |
|
742 | 742 | $order->save(); |
743 | 743 | } |
744 | 744 | |
@@ -746,91 +746,91 @@ discard block |
||
746 | 746 | * Make sure after creating 3DS object it is in pending status |
747 | 747 | * before redirecting. |
748 | 748 | */ |
749 | - if ( 'pending' === $response->redirect->status ) { |
|
750 | - WC_Stripe_Logger::log( 'Info: Redirecting to 3DS...' ); |
|
749 | + if ('pending' === $response->redirect->status) { |
|
750 | + WC_Stripe_Logger::log('Info: Redirecting to 3DS...'); |
|
751 | 751 | |
752 | 752 | return array( |
753 | 753 | 'result' => 'success', |
754 | - 'redirect' => esc_url_raw( $response->redirect->url ), |
|
754 | + 'redirect' => esc_url_raw($response->redirect->url), |
|
755 | 755 | ); |
756 | - } elseif ( 'not_required' === $response->redirect->status && 'chargeable' === $response->status ) { |
|
756 | + } elseif ('not_required' === $response->redirect->status && 'chargeable' === $response->status) { |
|
757 | 757 | // Override the original source object with 3DS. |
758 | 758 | $prepared_source->source_object = $response; |
759 | 759 | $prepared_source->source = $response->id; |
760 | 760 | } |
761 | 761 | } |
762 | 762 | |
763 | - WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" ); |
|
763 | + WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}"); |
|
764 | 764 | |
765 | 765 | /* If we're doing a retry and source is chargeable, we need to pass |
766 | 766 | * a different idempotency key and retry for success. |
767 | 767 | */ |
768 | - if ( $this->need_update_idempotency_key( $prepared_source->source_object, $previous_error ) ) { |
|
769 | - add_filter( 'wc_stripe_idempotency_key', array( $this, 'change_idempotency_key' ), 10, 2 ); |
|
768 | + if ($this->need_update_idempotency_key($prepared_source->source_object, $previous_error)) { |
|
769 | + add_filter('wc_stripe_idempotency_key', array($this, 'change_idempotency_key'), 10, 2); |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | // Make the request. |
773 | - $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $prepared_source ) ); |
|
773 | + $response = WC_Stripe_API::request($this->generate_payment_request($order, $prepared_source)); |
|
774 | 774 | |
775 | - if ( ! empty( $response->error ) ) { |
|
775 | + if ( ! empty($response->error)) { |
|
776 | 776 | // Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without. |
777 | - if ( $this->is_no_such_customer_error( $response->error ) ) { |
|
778 | - if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) { |
|
779 | - delete_user_meta( $order->customer_user, '_stripe_customer_id' ); |
|
780 | - delete_post_meta( $order_id, '_stripe_customer_id' ); |
|
777 | + if ($this->is_no_such_customer_error($response->error)) { |
|
778 | + if (WC_Stripe_Helper::is_wc_lt('3.0')) { |
|
779 | + delete_user_meta($order->customer_user, '_stripe_customer_id'); |
|
780 | + delete_post_meta($order_id, '_stripe_customer_id'); |
|
781 | 781 | } else { |
782 | - delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' ); |
|
783 | - $order->delete_meta_data( '_stripe_customer_id' ); |
|
782 | + delete_user_meta($order->get_customer_id(), '_stripe_customer_id'); |
|
783 | + $order->delete_meta_data('_stripe_customer_id'); |
|
784 | 784 | $order->save(); |
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
788 | - if ( $this->is_no_such_token_error( $response->error ) && $prepared_source->token_id ) { |
|
788 | + if ($this->is_no_such_token_error($response->error) && $prepared_source->token_id) { |
|
789 | 789 | // Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message. |
790 | - $wc_token = WC_Payment_Tokens::get( $prepared_source->token_id ); |
|
790 | + $wc_token = WC_Payment_Tokens::get($prepared_source->token_id); |
|
791 | 791 | $wc_token->delete(); |
792 | - $localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' ); |
|
793 | - $order->add_order_note( $localized_message ); |
|
794 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
792 | + $localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe'); |
|
793 | + $order->add_order_note($localized_message); |
|
794 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | // We want to retry. |
798 | - if ( $this->is_retryable_error( $response->error ) ) { |
|
799 | - if ( $retry ) { |
|
798 | + if ($this->is_retryable_error($response->error)) { |
|
799 | + if ($retry) { |
|
800 | 800 | // Don't do anymore retries after this. |
801 | - if ( 5 <= $this->retry_interval ) { |
|
802 | - return $this->process_payment( $order_id, false, $force_save_source, $response->error ); |
|
801 | + if (5 <= $this->retry_interval) { |
|
802 | + return $this->process_payment($order_id, false, $force_save_source, $response->error); |
|
803 | 803 | } |
804 | 804 | |
805 | - sleep( $this->retry_interval ); |
|
805 | + sleep($this->retry_interval); |
|
806 | 806 | |
807 | 807 | $this->retry_interval++; |
808 | 808 | |
809 | - return $this->process_payment( $order_id, true, $force_save_source, $response->error ); |
|
809 | + return $this->process_payment($order_id, true, $force_save_source, $response->error); |
|
810 | 810 | } else { |
811 | - $localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' ); |
|
812 | - $order->add_order_note( $localized_message ); |
|
813 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
811 | + $localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe'); |
|
812 | + $order->add_order_note($localized_message); |
|
813 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
814 | 814 | } |
815 | 815 | } |
816 | 816 | |
817 | 817 | $localized_messages = WC_Stripe_Helper::get_localized_messages(); |
818 | 818 | |
819 | - if ( 'card_error' === $response->error->type ) { |
|
820 | - $localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message; |
|
819 | + if ('card_error' === $response->error->type) { |
|
820 | + $localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message; |
|
821 | 821 | } else { |
822 | - $localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message; |
|
822 | + $localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message; |
|
823 | 823 | } |
824 | 824 | |
825 | - $order->add_order_note( $localized_message ); |
|
825 | + $order->add_order_note($localized_message); |
|
826 | 826 | |
827 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
827 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
828 | 828 | } |
829 | 829 | |
830 | - do_action( 'wc_gateway_stripe_process_payment', $response, $order ); |
|
830 | + do_action('wc_gateway_stripe_process_payment', $response, $order); |
|
831 | 831 | |
832 | 832 | // Process valid response. |
833 | - $this->process_response( $response, $order ); |
|
833 | + $this->process_response($response, $order); |
|
834 | 834 | } else { |
835 | 835 | $order->payment_complete(); |
836 | 836 | } |
@@ -841,17 +841,17 @@ discard block |
||
841 | 841 | // Return thank you page redirect. |
842 | 842 | return array( |
843 | 843 | 'result' => 'success', |
844 | - 'redirect' => $this->get_return_url( $order ), |
|
844 | + 'redirect' => $this->get_return_url($order), |
|
845 | 845 | ); |
846 | 846 | |
847 | - } catch ( WC_Stripe_Exception $e ) { |
|
848 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
849 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
847 | + } catch (WC_Stripe_Exception $e) { |
|
848 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
849 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
850 | 850 | |
851 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
851 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
852 | 852 | |
853 | 853 | /* translators: error message */ |
854 | - $order->update_status( 'failed' ); |
|
854 | + $order->update_status('failed'); |
|
855 | 855 | |
856 | 856 | return array( |
857 | 857 | 'result' => 'fail', |
@@ -867,17 +867,17 @@ discard block |
||
867 | 867 | * |
868 | 868 | * @param int $order_id |
869 | 869 | */ |
870 | - public function display_order_fee( $order_id ) { |
|
871 | - if ( apply_filters( 'wc_stripe_hide_display_order_fee', false, $order_id ) ) { |
|
870 | + public function display_order_fee($order_id) { |
|
871 | + if (apply_filters('wc_stripe_hide_display_order_fee', false, $order_id)) { |
|
872 | 872 | return; |
873 | 873 | } |
874 | 874 | |
875 | - $order = wc_get_order( $order_id ); |
|
875 | + $order = wc_get_order($order_id); |
|
876 | 876 | |
877 | - $fee = WC_Stripe_Helper::get_stripe_fee( $order ); |
|
878 | - $currency = WC_Stripe_Helper::get_stripe_currency( $order ); |
|
877 | + $fee = WC_Stripe_Helper::get_stripe_fee($order); |
|
878 | + $currency = WC_Stripe_Helper::get_stripe_currency($order); |
|
879 | 879 | |
880 | - if ( ! $fee || ! $currency ) { |
|
880 | + if ( ! $fee || ! $currency) { |
|
881 | 881 | return; |
882 | 882 | } |
883 | 883 | |
@@ -885,12 +885,12 @@ discard block |
||
885 | 885 | |
886 | 886 | <tr> |
887 | 887 | <td class="label stripe-fee"> |
888 | - <?php echo wc_help_tip( __( 'This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe' ) ); ?> |
|
889 | - <?php esc_html_e( 'Stripe Fee:', 'woocommerce-gateway-stripe' ); ?> |
|
888 | + <?php echo wc_help_tip(__('This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe')); ?> |
|
889 | + <?php esc_html_e('Stripe Fee:', 'woocommerce-gateway-stripe'); ?> |
|
890 | 890 | </td> |
891 | 891 | <td width="1%"></td> |
892 | 892 | <td class="total"> |
893 | - - <?php echo wc_price( $fee, array( 'currency' => $currency ) ); ?> |
|
893 | + - <?php echo wc_price($fee, array('currency' => $currency)); ?> |
|
894 | 894 | </td> |
895 | 895 | </tr> |
896 | 896 | |
@@ -904,17 +904,17 @@ discard block |
||
904 | 904 | * |
905 | 905 | * @param int $order_id |
906 | 906 | */ |
907 | - public function display_order_payout( $order_id ) { |
|
908 | - if ( apply_filters( 'wc_stripe_hide_display_order_payout', false, $order_id ) ) { |
|
907 | + public function display_order_payout($order_id) { |
|
908 | + if (apply_filters('wc_stripe_hide_display_order_payout', false, $order_id)) { |
|
909 | 909 | return; |
910 | 910 | } |
911 | 911 | |
912 | - $order = wc_get_order( $order_id ); |
|
912 | + $order = wc_get_order($order_id); |
|
913 | 913 | |
914 | - $net = WC_Stripe_Helper::get_stripe_net( $order ); |
|
915 | - $currency = WC_Stripe_Helper::get_stripe_currency( $order ); |
|
914 | + $net = WC_Stripe_Helper::get_stripe_net($order); |
|
915 | + $currency = WC_Stripe_Helper::get_stripe_currency($order); |
|
916 | 916 | |
917 | - if ( ! $net || ! $currency ) { |
|
917 | + if ( ! $net || ! $currency) { |
|
918 | 918 | return; |
919 | 919 | } |
920 | 920 | |
@@ -922,12 +922,12 @@ discard block |
||
922 | 922 | |
923 | 923 | <tr> |
924 | 924 | <td class="label stripe-payout"> |
925 | - <?php echo wc_help_tip( __( 'This represents the net total that will be credited to your Stripe bank account. This may be in the currency that is set in your Stripe account.', 'woocommerce-gateway-stripe' ) ); ?> |
|
926 | - <?php esc_html_e( 'Stripe Payout:', 'woocommerce-gateway-stripe' ); ?> |
|
925 | + <?php echo wc_help_tip(__('This represents the net total that will be credited to your Stripe bank account. This may be in the currency that is set in your Stripe account.', 'woocommerce-gateway-stripe')); ?> |
|
926 | + <?php esc_html_e('Stripe Payout:', 'woocommerce-gateway-stripe'); ?> |
|
927 | 927 | </td> |
928 | 928 | <td width="1%"></td> |
929 | 929 | <td class="total"> |
930 | - <?php echo wc_price( $net, array( 'currency' => $currency ) ); ?> |
|
930 | + <?php echo wc_price($net, array('currency' => $currency)); ?> |
|
931 | 931 | </td> |
932 | 932 | </tr> |
933 | 933 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * @since 4.1.0 |
22 | 22 | */ |
23 | 23 | public function __construct() { |
24 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
25 | - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
24 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
25 | + add_action('wp_loaded', array($this, 'hide_notices')); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | * @since 1.0.0 |
32 | 32 | * @version 4.0.0 |
33 | 33 | */ |
34 | - public function add_admin_notice( $slug, $class, $message, $dismissible = false ) { |
|
35 | - $this->notices[ $slug ] = array( |
|
34 | + public function add_admin_notice($slug, $class, $message, $dismissible = false) { |
|
35 | + $this->notices[$slug] = array( |
|
36 | 36 | 'class' => $class, |
37 | 37 | 'message' => $message, |
38 | 38 | 'dismissible' => $dismissible, |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @version 4.0.0 |
47 | 47 | */ |
48 | 48 | public function admin_notices() { |
49 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
49 | + if ( ! current_user_can('manage_woocommerce')) { |
|
50 | 50 | return; |
51 | 51 | } |
52 | 52 | |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | // All other payment methods. |
57 | 57 | $this->payment_methods_check_environment(); |
58 | 58 | |
59 | - foreach ( (array) $this->notices as $notice_key => $notice ) { |
|
60 | - echo '<div class="' . esc_attr( $notice['class'] ) . '" style="position:relative;">'; |
|
59 | + foreach ((array) $this->notices as $notice_key => $notice) { |
|
60 | + echo '<div class="' . esc_attr($notice['class']) . '" style="position:relative;">'; |
|
61 | 61 | |
62 | - if ( $notice['dismissible'] ) { |
|
62 | + if ($notice['dismissible']) { |
|
63 | 63 | ?> |
64 | - <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-stripe-hide-notice', $notice_key ), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce' ) ); ?>" class="woocommerce-message-close notice-dismiss" style="position:relative;float:right;padding:9px 0px 9px 9px 9px;text-decoration:none;"></a> |
|
64 | + <a href="<?php echo esc_url(wp_nonce_url(add_query_arg('wc-stripe-hide-notice', $notice_key), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce')); ?>" class="woocommerce-message-close notice-dismiss" style="position:relative;float:right;padding:9px 0px 9px 9px 9px;text-decoration:none;"></a> |
|
65 | 65 | <?php |
66 | 66 | } |
67 | 67 | |
68 | 68 | echo '<p>'; |
69 | - echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) ); |
|
69 | + echo wp_kses($notice['message'], array('a' => array('href' => array()))); |
|
70 | 70 | echo '</p></div>'; |
71 | 71 | } |
72 | 72 | } |
@@ -99,93 +99,93 @@ discard block |
||
99 | 99 | * @version 4.0.0 |
100 | 100 | */ |
101 | 101 | public function stripe_check_environment() { |
102 | - $show_style_notice = get_option( 'wc_stripe_show_style_notice' ); |
|
103 | - $show_ssl_notice = get_option( 'wc_stripe_show_ssl_notice' ); |
|
104 | - $show_keys_notice = get_option( 'wc_stripe_show_keys_notice' ); |
|
105 | - $show_phpver_notice = get_option( 'wc_stripe_show_phpver_notice' ); |
|
106 | - $show_wcver_notice = get_option( 'wc_stripe_show_wcver_notice' ); |
|
107 | - $show_curl_notice = get_option( 'wc_stripe_show_curl_notice' ); |
|
108 | - $options = get_option( 'woocommerce_stripe_settings' ); |
|
109 | - $testmode = ( isset( $options['testmode'] ) && 'yes' === $options['testmode'] ) ? true : false; |
|
110 | - $test_pub_key = isset( $options['test_publishable_key'] ) ? $options['test_publishable_key'] : ''; |
|
111 | - $test_secret_key = isset( $options['test_secret_key'] ) ? $options['test_secret_key'] : ''; |
|
112 | - $live_pub_key = isset( $options['publishable_key'] ) ? $options['publishable_key'] : ''; |
|
113 | - $live_secret_key = isset( $options['secret_key'] ) ? $options['secret_key'] : ''; |
|
114 | - |
|
115 | - if ( isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) { |
|
116 | - if ( empty( $show_style_notice ) ) { |
|
102 | + $show_style_notice = get_option('wc_stripe_show_style_notice'); |
|
103 | + $show_ssl_notice = get_option('wc_stripe_show_ssl_notice'); |
|
104 | + $show_keys_notice = get_option('wc_stripe_show_keys_notice'); |
|
105 | + $show_phpver_notice = get_option('wc_stripe_show_phpver_notice'); |
|
106 | + $show_wcver_notice = get_option('wc_stripe_show_wcver_notice'); |
|
107 | + $show_curl_notice = get_option('wc_stripe_show_curl_notice'); |
|
108 | + $options = get_option('woocommerce_stripe_settings'); |
|
109 | + $testmode = (isset($options['testmode']) && 'yes' === $options['testmode']) ? true : false; |
|
110 | + $test_pub_key = isset($options['test_publishable_key']) ? $options['test_publishable_key'] : ''; |
|
111 | + $test_secret_key = isset($options['test_secret_key']) ? $options['test_secret_key'] : ''; |
|
112 | + $live_pub_key = isset($options['publishable_key']) ? $options['publishable_key'] : ''; |
|
113 | + $live_secret_key = isset($options['secret_key']) ? $options['secret_key'] : ''; |
|
114 | + |
|
115 | + if (isset($options['enabled']) && 'yes' === $options['enabled']) { |
|
116 | + if (empty($show_style_notice)) { |
|
117 | 117 | /* translators: 1) int version 2) int version */ |
118 | - $message = __( 'WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#section-45" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe' ); |
|
118 | + $message = __('WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#section-45" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe'); |
|
119 | 119 | |
120 | - $this->add_admin_notice( 'style', 'error', $message, true ); |
|
120 | + $this->add_admin_notice('style', 'error', $message, true); |
|
121 | 121 | |
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | - if ( empty( $show_phpver_notice ) ) { |
|
126 | - if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) { |
|
125 | + if (empty($show_phpver_notice)) { |
|
126 | + if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) { |
|
127 | 127 | /* translators: 1) int version 2) int version */ |
128 | - $message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
128 | + $message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
129 | 129 | |
130 | - $this->add_admin_notice( 'phpver', 'error', sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() ), true ); |
|
130 | + $this->add_admin_notice('phpver', 'error', sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion()), true); |
|
131 | 131 | |
132 | 132 | return; |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | - if ( empty( $show_wcver_notice ) ) { |
|
137 | - if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) { |
|
136 | + if (empty($show_wcver_notice)) { |
|
137 | + if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) { |
|
138 | 138 | /* translators: 1) int version 2) int version */ |
139 | - $message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
139 | + $message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
140 | 140 | |
141 | - $this->add_admin_notice( 'wcver', 'notice notice-warning', sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION ), true ); |
|
141 | + $this->add_admin_notice('wcver', 'notice notice-warning', sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION), true); |
|
142 | 142 | |
143 | 143 | return; |
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - if ( empty( $show_curl_notice ) ) { |
|
148 | - if ( ! function_exists( 'curl_init' ) ) { |
|
149 | - $this->add_admin_notice( 'curl', 'notice notice-warning', __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ), true ); |
|
147 | + if (empty($show_curl_notice)) { |
|
148 | + if ( ! function_exists('curl_init')) { |
|
149 | + $this->add_admin_notice('curl', 'notice notice-warning', __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe'), true); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | - if ( empty( $show_keys_notice ) ) { |
|
153 | + if (empty($show_keys_notice)) { |
|
154 | 154 | $secret = WC_Stripe_API::get_secret_key(); |
155 | 155 | |
156 | - if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) { |
|
156 | + if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) { |
|
157 | 157 | $setting_link = $this->get_setting_link(); |
158 | 158 | /* translators: 1) link */ |
159 | - $this->add_admin_notice( 'keys', 'notice notice-warning', sprintf( __( 'Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true ); |
|
159 | + $this->add_admin_notice('keys', 'notice notice-warning', sprintf(__('Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // Check if keys are entered properly per live/test mode. |
163 | - if ( $testmode ) { |
|
163 | + if ($testmode) { |
|
164 | 164 | if ( |
165 | - ! empty( $test_pub_key ) && ! preg_match( '/^pk_test_/', $test_pub_key ) |
|
166 | - || ( ! empty( $test_secret_key ) && ! preg_match( '/^sk_test_/', $test_secret_key ) |
|
167 | - && ! empty( $test_secret_key ) && ! preg_match( '/^rk_test_/', $test_secret_key ) ) ) { |
|
165 | + ! empty($test_pub_key) && ! preg_match('/^pk_test_/', $test_pub_key) |
|
166 | + || ( ! empty($test_secret_key) && ! preg_match('/^sk_test_/', $test_secret_key) |
|
167 | + && ! empty($test_secret_key) && ! preg_match('/^rk_test_/', $test_secret_key)) ) { |
|
168 | 168 | $setting_link = $this->get_setting_link(); |
169 | 169 | /* translators: 1) link */ |
170 | - $this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true ); |
|
170 | + $this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true); |
|
171 | 171 | } |
172 | 172 | } else { |
173 | 173 | if ( |
174 | - ! empty( $live_pub_key ) && ! preg_match( '/^pk_live_/', $live_pub_key ) |
|
175 | - || ( ! empty( $live_secret_key ) && ! preg_match( '/^sk_live_/', $live_secret_key ) |
|
176 | - && ! empty( $live_secret_key ) && ! preg_match( '/^rk_live_/', $live_secret_key ) ) ) { |
|
174 | + ! empty($live_pub_key) && ! preg_match('/^pk_live_/', $live_pub_key) |
|
175 | + || ( ! empty($live_secret_key) && ! preg_match('/^sk_live_/', $live_secret_key) |
|
176 | + && ! empty($live_secret_key) && ! preg_match('/^rk_live_/', $live_secret_key)) ) { |
|
177 | 177 | $setting_link = $this->get_setting_link(); |
178 | 178 | /* translators: 1) link */ |
179 | - $this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in live mode however your test keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true ); |
|
179 | + $this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in live mode however your test keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - if ( empty( $show_ssl_notice ) ) { |
|
184 | + if (empty($show_ssl_notice)) { |
|
185 | 185 | // Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected. |
186 | - if ( ! wc_checkout_is_https() ) { |
|
186 | + if ( ! wc_checkout_is_https()) { |
|
187 | 187 | /* translators: 1) link */ |
188 | - $this->add_admin_notice( 'ssl', 'notice notice-warning', sprintf( __( 'Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe' ), 'https://en.wikipedia.org/wiki/Transport_Layer_Security' ), true ); |
|
188 | + $this->add_admin_notice('ssl', 'notice notice-warning', sprintf(__('Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe'), 'https://en.wikipedia.org/wiki/Transport_Layer_Security'), true); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | public function payment_methods_check_environment() { |
200 | 200 | $payment_methods = $this->get_payment_methods(); |
201 | 201 | |
202 | - foreach ( $payment_methods as $method => $class ) { |
|
203 | - $show_notice = get_option( 'wc_stripe_show_' . strtolower( $method ) . '_notice' ); |
|
202 | + foreach ($payment_methods as $method => $class) { |
|
203 | + $show_notice = get_option('wc_stripe_show_' . strtolower($method) . '_notice'); |
|
204 | 204 | $gateway = new $class(); |
205 | 205 | |
206 | - if ( 'yes' !== $gateway->enabled || 'no' === $show_notice ) { |
|
206 | + if ('yes' !== $gateway->enabled || 'no' === $show_notice) { |
|
207 | 207 | continue; |
208 | 208 | } |
209 | 209 | |
210 | - if ( ! in_array( get_woocommerce_currency(), $gateway->get_supported_currency() ) ) { |
|
210 | + if ( ! in_array(get_woocommerce_currency(), $gateway->get_supported_currency())) { |
|
211 | 211 | /* translators: %1$s Payment method, %2$s List of supported currencies */ |
212 | - $this->add_admin_notice( $method, 'notice notice-error', sprintf( __( '%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe' ), $method, implode( ', ', $gateway->get_supported_currency() ) ), true ); |
|
212 | + $this->add_admin_notice($method, 'notice notice-error', sprintf(__('%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe'), $method, implode(', ', $gateway->get_supported_currency())), true); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | } |
@@ -221,62 +221,62 @@ discard block |
||
221 | 221 | * @version 4.0.0 |
222 | 222 | */ |
223 | 223 | public function hide_notices() { |
224 | - if ( isset( $_GET['wc-stripe-hide-notice'] ) && isset( $_GET['_wc_stripe_notice_nonce'] ) ) { |
|
225 | - if ( ! wp_verify_nonce( $_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce' ) ) { |
|
226 | - wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe' ) ); |
|
224 | + if (isset($_GET['wc-stripe-hide-notice']) && isset($_GET['_wc_stripe_notice_nonce'])) { |
|
225 | + if ( ! wp_verify_nonce($_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce')) { |
|
226 | + wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe')); |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
230 | - wp_die( __( 'Cheatin’ huh?', 'woocommerce-gateway-stripe' ) ); |
|
229 | + if ( ! current_user_can('manage_woocommerce')) { |
|
230 | + wp_die(__('Cheatin’ huh?', 'woocommerce-gateway-stripe')); |
|
231 | 231 | } |
232 | 232 | |
233 | - $notice = wc_clean( $_GET['wc-stripe-hide-notice'] ); |
|
233 | + $notice = wc_clean($_GET['wc-stripe-hide-notice']); |
|
234 | 234 | |
235 | - switch ( $notice ) { |
|
235 | + switch ($notice) { |
|
236 | 236 | case 'style': |
237 | - update_option( 'wc_stripe_show_style_notice', 'no' ); |
|
237 | + update_option('wc_stripe_show_style_notice', 'no'); |
|
238 | 238 | break; |
239 | 239 | case 'phpver': |
240 | - update_option( 'wc_stripe_show_phpver_notice', 'no' ); |
|
240 | + update_option('wc_stripe_show_phpver_notice', 'no'); |
|
241 | 241 | break; |
242 | 242 | case 'wcver': |
243 | - update_option( 'wc_stripe_show_wcver_notice', 'no' ); |
|
243 | + update_option('wc_stripe_show_wcver_notice', 'no'); |
|
244 | 244 | break; |
245 | 245 | case 'curl': |
246 | - update_option( 'wc_stripe_show_curl_notice', 'no' ); |
|
246 | + update_option('wc_stripe_show_curl_notice', 'no'); |
|
247 | 247 | break; |
248 | 248 | case 'ssl': |
249 | - update_option( 'wc_stripe_show_ssl_notice', 'no' ); |
|
249 | + update_option('wc_stripe_show_ssl_notice', 'no'); |
|
250 | 250 | break; |
251 | 251 | case 'keys': |
252 | - update_option( 'wc_stripe_show_keys_notice', 'no' ); |
|
252 | + update_option('wc_stripe_show_keys_notice', 'no'); |
|
253 | 253 | break; |
254 | 254 | case 'Alipay': |
255 | - update_option( 'wc_stripe_show_alipay_notice', 'no' ); |
|
255 | + update_option('wc_stripe_show_alipay_notice', 'no'); |
|
256 | 256 | break; |
257 | 257 | case 'Bancontact': |
258 | - update_option( 'wc_stripe_show_bancontact_notice', 'no' ); |
|
258 | + update_option('wc_stripe_show_bancontact_notice', 'no'); |
|
259 | 259 | break; |
260 | 260 | case 'EPS': |
261 | - update_option( 'wc_stripe_show_eps_notice', 'no' ); |
|
261 | + update_option('wc_stripe_show_eps_notice', 'no'); |
|
262 | 262 | break; |
263 | 263 | case 'Giropay': |
264 | - update_option( 'wc_stripe_show_giropay_notice', 'no' ); |
|
264 | + update_option('wc_stripe_show_giropay_notice', 'no'); |
|
265 | 265 | break; |
266 | 266 | case 'iDeal': |
267 | - update_option( 'wc_stripe_show_ideal_notice', 'no' ); |
|
267 | + update_option('wc_stripe_show_ideal_notice', 'no'); |
|
268 | 268 | break; |
269 | 269 | case 'Multibanco': |
270 | - update_option( 'wc_stripe_show_multibanco_notice', 'no' ); |
|
270 | + update_option('wc_stripe_show_multibanco_notice', 'no'); |
|
271 | 271 | break; |
272 | 272 | case 'P24': |
273 | - update_option( 'wc_stripe_show_p24_notice', 'no' ); |
|
273 | + update_option('wc_stripe_show_p24_notice', 'no'); |
|
274 | 274 | break; |
275 | 275 | case 'SEPA': |
276 | - update_option( 'wc_stripe_show_sepa_notice', 'no' ); |
|
276 | + update_option('wc_stripe_show_sepa_notice', 'no'); |
|
277 | 277 | break; |
278 | 278 | case 'SOFORT': |
279 | - update_option( 'wc_stripe_show_sofort_notice', 'no' ); |
|
279 | + update_option('wc_stripe_show_sofort_notice', 'no'); |
|
280 | 280 | break; |
281 | 281 | } |
282 | 282 | } |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | * @return string Setting link |
291 | 291 | */ |
292 | 292 | public function get_setting_link() { |
293 | - $use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false; |
|
293 | + $use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false; |
|
294 | 294 | |
295 | - $section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' ); |
|
295 | + $section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe'); |
|
296 | 296 | |
297 | - return admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug ); |
|
297 | + return admin_url('admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug); |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! class_exists( 'WC_Abstract_Privacy' ) ) { |
|
2 | +if ( ! class_exists('WC_Abstract_Privacy')) { |
|
3 | 3 | return; |
4 | 4 | } |
5 | 5 | |
@@ -9,20 +9,20 @@ discard block |
||
9 | 9 | * |
10 | 10 | */ |
11 | 11 | public function __construct() { |
12 | - parent::__construct( __( 'Stripe', 'woocommerce-gateway-stripe' ) ); |
|
12 | + parent::__construct(__('Stripe', 'woocommerce-gateway-stripe')); |
|
13 | 13 | |
14 | - $this->add_exporter( 'woocommerce-gateway-stripe-order-data', __( 'WooCommerce Stripe Order Data', 'woocommerce-gateway-stripe' ), array( $this, 'order_data_exporter' ) ); |
|
14 | + $this->add_exporter('woocommerce-gateway-stripe-order-data', __('WooCommerce Stripe Order Data', 'woocommerce-gateway-stripe'), array($this, 'order_data_exporter')); |
|
15 | 15 | |
16 | - if ( function_exists( 'wcs_get_subscriptions' ) ) { |
|
17 | - $this->add_exporter( 'woocommerce-gateway-stripe-subscriptions-data', __( 'WooCommerce Stripe Subscriptions Data', 'woocommerce-gateway-stripe' ), array( $this, 'subscriptions_data_exporter' ) ); |
|
16 | + if (function_exists('wcs_get_subscriptions')) { |
|
17 | + $this->add_exporter('woocommerce-gateway-stripe-subscriptions-data', __('WooCommerce Stripe Subscriptions Data', 'woocommerce-gateway-stripe'), array($this, 'subscriptions_data_exporter')); |
|
18 | 18 | } |
19 | 19 | |
20 | - $this->add_exporter( 'woocommerce-gateway-stripe-customer-data', __( 'WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe' ), array( $this, 'customer_data_exporter' ) ); |
|
20 | + $this->add_exporter('woocommerce-gateway-stripe-customer-data', __('WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe'), array($this, 'customer_data_exporter')); |
|
21 | 21 | |
22 | - $this->add_eraser( 'woocommerce-gateway-stripe-customer-data', __( 'WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe' ), array( $this, 'customer_data_eraser' ) ); |
|
23 | - $this->add_eraser( 'woocommerce-gateway-stripe-order-data', __( 'WooCommerce Stripe Data', 'woocommerce-gateway-stripe' ), array( $this, 'order_data_eraser' ) ); |
|
22 | + $this->add_eraser('woocommerce-gateway-stripe-customer-data', __('WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe'), array($this, 'customer_data_eraser')); |
|
23 | + $this->add_eraser('woocommerce-gateway-stripe-order-data', __('WooCommerce Stripe Data', 'woocommerce-gateway-stripe'), array($this, 'order_data_eraser')); |
|
24 | 24 | |
25 | - add_filter( 'woocommerce_get_settings_account', array( $this, 'account_settings' ) ); |
|
25 | + add_filter('woocommerce_get_settings_account', array($this, 'account_settings')); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | * @param array $settings |
32 | 32 | * @return array $settings Updated |
33 | 33 | */ |
34 | - public function account_settings( $settings ) { |
|
34 | + public function account_settings($settings) { |
|
35 | 35 | $insert_setting = array( |
36 | 36 | array( |
37 | - 'title' => __( 'Retain Stripe Data', 'woocommerce-gateway-stripe' ), |
|
38 | - 'desc_tip' => __( 'Retains any Stripe data such as Stripe customer ID, source ID.', 'woocommerce-gateway-stripe' ), |
|
37 | + 'title' => __('Retain Stripe Data', 'woocommerce-gateway-stripe'), |
|
38 | + 'desc_tip' => __('Retains any Stripe data such as Stripe customer ID, source ID.', 'woocommerce-gateway-stripe'), |
|
39 | 39 | 'id' => 'woocommerce_gateway_stripe_retention', |
40 | 40 | 'type' => 'relative_date_selector', |
41 | - 'placeholder' => __( 'N/A', 'woocommerce-gateway-stripe' ), |
|
41 | + 'placeholder' => __('N/A', 'woocommerce-gateway-stripe'), |
|
42 | 42 | 'default' => '', |
43 | 43 | 'autoload' => false, |
44 | 44 | ), |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | |
47 | 47 | $index = null; |
48 | 48 | |
49 | - foreach ( $settings as $key => $value) { |
|
50 | - if ( 'sectionend' === $value[ 'type' ] && 'personal_data_retention' === $value[ 'id' ] ) { |
|
49 | + foreach ($settings as $key => $value) { |
|
50 | + if ('sectionend' === $value['type'] && 'personal_data_retention' === $value['id']) { |
|
51 | 51 | $index = $key; |
52 | 52 | break; |
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - if ( ! is_null( $index ) ) { |
|
57 | - array_splice( $settings, $index, 0, $insert_setting ); |
|
56 | + if ( ! is_null($index)) { |
|
57 | + array_splice($settings, $index, 0, $insert_setting); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return $settings; |
@@ -68,22 +68,22 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return array WP_Post |
70 | 70 | */ |
71 | - protected function get_stripe_orders( $email_address, $page ) { |
|
72 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
71 | + protected function get_stripe_orders($email_address, $page) { |
|
72 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
73 | 73 | |
74 | 74 | $order_query = array( |
75 | - 'payment_method' => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ), |
|
75 | + 'payment_method' => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'), |
|
76 | 76 | 'limit' => 10, |
77 | 77 | 'page' => $page, |
78 | 78 | ); |
79 | 79 | |
80 | - if ( $user instanceof WP_User ) { |
|
80 | + if ($user instanceof WP_User) { |
|
81 | 81 | $order_query['customer_id'] = (int) $user->ID; |
82 | 82 | } else { |
83 | 83 | $order_query['billing_email'] = $email_address; |
84 | 84 | } |
85 | 85 | |
86 | - return wc_get_orders( $order_query ); |
|
86 | + return wc_get_orders($order_query); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function get_privacy_message() { |
94 | 94 | /* translators: %s URL to docs */ |
95 | - return wpautop( sprintf( __( 'By using this extension, you may be storing personal data or sharing data with an external service. <a href="%s" target="_blank">Learn more about how this works, including what you may want to include in your privacy policy.</a>', 'woocommerce-gateway-stripe' ), 'https://docs.woocommerce.com/document/privacy-payments/#woocommerce-gateway-stripe' ) ); |
|
95 | + return wpautop(sprintf(__('By using this extension, you may be storing personal data or sharing data with an external service. <a href="%s" target="_blank">Learn more about how this works, including what you may want to include in your privacy policy.</a>', 'woocommerce-gateway-stripe'), 'https://docs.woocommerce.com/document/privacy-payments/#woocommerce-gateway-stripe')); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -103,34 +103,34 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return array |
105 | 105 | */ |
106 | - public function order_data_exporter( $email_address, $page = 1 ) { |
|
106 | + public function order_data_exporter($email_address, $page = 1) { |
|
107 | 107 | $done = false; |
108 | 108 | $data_to_export = array(); |
109 | 109 | |
110 | - $orders = $this->get_stripe_orders( $email_address, (int) $page ); |
|
110 | + $orders = $this->get_stripe_orders($email_address, (int) $page); |
|
111 | 111 | |
112 | 112 | $done = true; |
113 | 113 | |
114 | - if ( 0 < count( $orders ) ) { |
|
115 | - foreach ( $orders as $order ) { |
|
114 | + if (0 < count($orders)) { |
|
115 | + foreach ($orders as $order) { |
|
116 | 116 | $data_to_export[] = array( |
117 | 117 | 'group_id' => 'woocommerce_orders', |
118 | - 'group_label' => __( 'Orders', 'woocommerce-gateway-stripe' ), |
|
118 | + 'group_label' => __('Orders', 'woocommerce-gateway-stripe'), |
|
119 | 119 | 'item_id' => 'order-' . $order->get_id(), |
120 | 120 | 'data' => array( |
121 | 121 | array( |
122 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
123 | - 'value' => get_post_meta( $order->get_id(), '_stripe_source_id', true ), |
|
122 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
123 | + 'value' => get_post_meta($order->get_id(), '_stripe_source_id', true), |
|
124 | 124 | ), |
125 | 125 | array( |
126 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
127 | - 'value' => get_post_meta( $order->get_id(), '_stripe_customer_id', true ), |
|
126 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
127 | + 'value' => get_post_meta($order->get_id(), '_stripe_customer_id', true), |
|
128 | 128 | ), |
129 | 129 | ), |
130 | 130 | ); |
131 | 131 | } |
132 | 132 | |
133 | - $done = 10 > count( $orders ); |
|
133 | + $done = 10 > count($orders); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | return array( |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return array |
149 | 149 | */ |
150 | - public function subscriptions_data_exporter( $email_address, $page = 1 ) { |
|
150 | + public function subscriptions_data_exporter($email_address, $page = 1) { |
|
151 | 151 | $done = false; |
152 | 152 | $page = (int) $page; |
153 | 153 | $data_to_export = array(); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'relation' => 'AND', |
157 | 157 | array( |
158 | 158 | 'key' => '_payment_method', |
159 | - 'value' => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ), |
|
159 | + 'value' => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'), |
|
160 | 160 | 'compare' => 'IN', |
161 | 161 | ), |
162 | 162 | array( |
@@ -172,30 +172,30 @@ discard block |
||
172 | 172 | 'meta_query' => $meta_query, |
173 | 173 | ); |
174 | 174 | |
175 | - $subscriptions = wcs_get_subscriptions( $subscription_query ); |
|
175 | + $subscriptions = wcs_get_subscriptions($subscription_query); |
|
176 | 176 | |
177 | 177 | $done = true; |
178 | 178 | |
179 | - if ( 0 < count( $subscriptions ) ) { |
|
180 | - foreach ( $subscriptions as $subscription ) { |
|
179 | + if (0 < count($subscriptions)) { |
|
180 | + foreach ($subscriptions as $subscription) { |
|
181 | 181 | $data_to_export[] = array( |
182 | 182 | 'group_id' => 'woocommerce_subscriptions', |
183 | - 'group_label' => __( 'Subscriptions', 'woocommerce-gateway-stripe' ), |
|
183 | + 'group_label' => __('Subscriptions', 'woocommerce-gateway-stripe'), |
|
184 | 184 | 'item_id' => 'subscription-' . $subscription->get_id(), |
185 | 185 | 'data' => array( |
186 | 186 | array( |
187 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
188 | - 'value' => get_post_meta( $subscription->get_id(), '_stripe_source_id', true ), |
|
187 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
188 | + 'value' => get_post_meta($subscription->get_id(), '_stripe_source_id', true), |
|
189 | 189 | ), |
190 | 190 | array( |
191 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
192 | - 'value' => get_post_meta( $subscription->get_id(), '_stripe_customer_id', true ), |
|
191 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
192 | + 'value' => get_post_meta($subscription->get_id(), '_stripe_customer_id', true), |
|
193 | 193 | ), |
194 | 194 | ), |
195 | 195 | ); |
196 | 196 | } |
197 | 197 | |
198 | - $done = 10 > count( $subscriptions ); |
|
198 | + $done = 10 > count($subscriptions); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | return array( |
@@ -211,24 +211,24 @@ discard block |
||
211 | 211 | * @param int $page Page. |
212 | 212 | * @return array An array of personal data in name value pairs |
213 | 213 | */ |
214 | - public function customer_data_exporter( $email_address, $page ) { |
|
215 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
214 | + public function customer_data_exporter($email_address, $page) { |
|
215 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
216 | 216 | $data_to_export = array(); |
217 | 217 | |
218 | - if ( $user instanceof WP_User ) { |
|
219 | - $stripe_user = new WC_Stripe_Customer( $user->ID ); |
|
218 | + if ($user instanceof WP_User) { |
|
219 | + $stripe_user = new WC_Stripe_Customer($user->ID); |
|
220 | 220 | |
221 | 221 | $data_to_export[] = array( |
222 | 222 | 'group_id' => 'woocommerce_customer', |
223 | - 'group_label' => __( 'Customer Data', 'woocommerce-gateway-stripe' ), |
|
223 | + 'group_label' => __('Customer Data', 'woocommerce-gateway-stripe'), |
|
224 | 224 | 'item_id' => 'user', |
225 | 225 | 'data' => array( |
226 | 226 | array( |
227 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
228 | - 'value' => get_user_meta( $user->ID, '_stripe_source_id', true ), |
|
227 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
228 | + 'value' => get_user_meta($user->ID, '_stripe_source_id', true), |
|
229 | 229 | ), |
230 | 230 | array( |
231 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
231 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
232 | 232 | 'value' => $stripe_user->get_id(), |
233 | 233 | ), |
234 | 234 | ), |
@@ -248,25 +248,25 @@ discard block |
||
248 | 248 | * @param int $page Page. |
249 | 249 | * @return array An array of personal data in name value pairs |
250 | 250 | */ |
251 | - public function customer_data_eraser( $email_address, $page ) { |
|
251 | + public function customer_data_eraser($email_address, $page) { |
|
252 | 252 | $page = (int) $page; |
253 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
253 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
254 | 254 | $stripe_customer_id = ''; |
255 | 255 | $stripe_source_id = ''; |
256 | 256 | |
257 | - if ( $user instanceof WP_User ) { |
|
258 | - $stripe_customer_id = get_user_meta( $user->ID, '_stripe_customer_id', true ); |
|
259 | - $stripe_source_id = get_user_meta( $user->ID, '_stripe_source_id', true ); |
|
257 | + if ($user instanceof WP_User) { |
|
258 | + $stripe_customer_id = get_user_meta($user->ID, '_stripe_customer_id', true); |
|
259 | + $stripe_source_id = get_user_meta($user->ID, '_stripe_source_id', true); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | $items_removed = false; |
263 | 263 | $messages = array(); |
264 | 264 | |
265 | - if ( ! empty( $stripe_customer_id ) || ! empty( $stripe_source_id ) ) { |
|
265 | + if ( ! empty($stripe_customer_id) || ! empty($stripe_source_id)) { |
|
266 | 266 | $items_removed = true; |
267 | - delete_user_meta( $user->ID, '_stripe_customer_id' ); |
|
268 | - delete_user_meta( $user->ID, '_stripe_source_id' ); |
|
269 | - $messages[] = __( 'Stripe User Data Erased.', 'woocommerce-gateway-stripe' ); |
|
267 | + delete_user_meta($user->ID, '_stripe_customer_id'); |
|
268 | + delete_user_meta($user->ID, '_stripe_source_id'); |
|
269 | + $messages[] = __('Stripe User Data Erased.', 'woocommerce-gateway-stripe'); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | return array( |
@@ -284,29 +284,29 @@ discard block |
||
284 | 284 | * @param int $page Page. |
285 | 285 | * @return array An array of personal data in name value pairs |
286 | 286 | */ |
287 | - public function order_data_eraser( $email_address, $page ) { |
|
288 | - $orders = $this->get_stripe_orders( $email_address, (int) $page ); |
|
287 | + public function order_data_eraser($email_address, $page) { |
|
288 | + $orders = $this->get_stripe_orders($email_address, (int) $page); |
|
289 | 289 | |
290 | 290 | $items_removed = false; |
291 | 291 | $items_retained = false; |
292 | 292 | $messages = array(); |
293 | 293 | |
294 | - foreach ( (array) $orders as $order ) { |
|
295 | - $order = wc_get_order( $order->get_id() ); |
|
294 | + foreach ((array) $orders as $order) { |
|
295 | + $order = wc_get_order($order->get_id()); |
|
296 | 296 | |
297 | - list( $removed, $retained, $msgs ) = $this->maybe_handle_order( $order ); |
|
297 | + list($removed, $retained, $msgs) = $this->maybe_handle_order($order); |
|
298 | 298 | $items_removed |= $removed; |
299 | 299 | $items_retained |= $retained; |
300 | - $messages = array_merge( $messages, $msgs ); |
|
300 | + $messages = array_merge($messages, $msgs); |
|
301 | 301 | |
302 | - list( $removed, $retained, $msgs ) = $this->maybe_handle_subscription( $order ); |
|
302 | + list($removed, $retained, $msgs) = $this->maybe_handle_subscription($order); |
|
303 | 303 | $items_removed |= $removed; |
304 | 304 | $items_retained |= $retained; |
305 | - $messages = array_merge( $messages, $msgs ); |
|
305 | + $messages = array_merge($messages, $msgs); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | // Tell core if we have more orders to work on still |
309 | - $done = count( $orders ) < 10; |
|
309 | + $done = count($orders) < 10; |
|
310 | 310 | |
311 | 311 | return array( |
312 | 312 | 'items_removed' => $items_removed, |
@@ -322,47 +322,47 @@ discard block |
||
322 | 322 | * @param WC_Order $order |
323 | 323 | * @return array |
324 | 324 | */ |
325 | - protected function maybe_handle_subscription( $order ) { |
|
326 | - if ( ! class_exists( 'WC_Subscriptions' ) ) { |
|
327 | - return array( false, false, array() ); |
|
325 | + protected function maybe_handle_subscription($order) { |
|
326 | + if ( ! class_exists('WC_Subscriptions')) { |
|
327 | + return array(false, false, array()); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( ! wcs_order_contains_subscription( $order ) ) { |
|
331 | - return array( false, false, array() ); |
|
330 | + if ( ! wcs_order_contains_subscription($order)) { |
|
331 | + return array(false, false, array()); |
|
332 | 332 | } |
333 | 333 | |
334 | - $subscription = current( wcs_get_subscriptions_for_order( $order->get_id() ) ); |
|
334 | + $subscription = current(wcs_get_subscriptions_for_order($order->get_id())); |
|
335 | 335 | $subscription_id = $subscription->get_id(); |
336 | 336 | |
337 | - $stripe_source_id = get_post_meta( $subscription_id, '_stripe_source_id', true ); |
|
337 | + $stripe_source_id = get_post_meta($subscription_id, '_stripe_source_id', true); |
|
338 | 338 | |
339 | - if ( empty( $stripe_source_id ) ) { |
|
340 | - return array( false, false, array() ); |
|
339 | + if (empty($stripe_source_id)) { |
|
340 | + return array(false, false, array()); |
|
341 | 341 | } |
342 | 342 | |
343 | - if ( ! $this->is_retention_expired( $order->get_date_created()->getTimestamp() ) ) { |
|
343 | + if ( ! $this->is_retention_expired($order->get_date_created()->getTimestamp())) { |
|
344 | 344 | /* translators: %d Order ID */ |
345 | - return array( false, true, array( sprintf( __( 'Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) ); |
|
345 | + return array(false, true, array(sprintf(__('Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id()))); |
|
346 | 346 | } |
347 | 347 | |
348 | - if ( $subscription->has_status( apply_filters( 'wc_stripe_privacy_eraser_subs_statuses', array( 'on-hold', 'active' ) ) ) ) { |
|
348 | + if ($subscription->has_status(apply_filters('wc_stripe_privacy_eraser_subs_statuses', array('on-hold', 'active')))) { |
|
349 | 349 | /* translators: %d Order ID */ |
350 | - return array( false, true, array( sprintf( __( 'Order ID %d contains an active Subscription. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) ); |
|
350 | + return array(false, true, array(sprintf(__('Order ID %d contains an active Subscription. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id()))); |
|
351 | 351 | } |
352 | 352 | |
353 | - $renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders( $order->get_id() ); |
|
353 | + $renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders($order->get_id()); |
|
354 | 354 | |
355 | - foreach ( $renewal_orders as $renewal_order_id ) { |
|
356 | - delete_post_meta( $renewal_order_id, '_stripe_source_id' ); |
|
357 | - delete_post_meta( $renewal_order_id, '_stripe_refund_id' ); |
|
358 | - delete_post_meta( $renewal_order_id, '_stripe_customer_id' ); |
|
355 | + foreach ($renewal_orders as $renewal_order_id) { |
|
356 | + delete_post_meta($renewal_order_id, '_stripe_source_id'); |
|
357 | + delete_post_meta($renewal_order_id, '_stripe_refund_id'); |
|
358 | + delete_post_meta($renewal_order_id, '_stripe_customer_id'); |
|
359 | 359 | } |
360 | 360 | |
361 | - delete_post_meta( $subscription_id, '_stripe_source_id' ); |
|
362 | - delete_post_meta( $subscription_id, '_stripe_refund_id' ); |
|
363 | - delete_post_meta( $subscription_id, '_stripe_customer_id' ); |
|
361 | + delete_post_meta($subscription_id, '_stripe_source_id'); |
|
362 | + delete_post_meta($subscription_id, '_stripe_refund_id'); |
|
363 | + delete_post_meta($subscription_id, '_stripe_customer_id'); |
|
364 | 364 | |
365 | - return array( true, false, array( __( 'Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe' ) ) ); |
|
365 | + return array(true, false, array(__('Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe'))); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -371,61 +371,61 @@ discard block |
||
371 | 371 | * @param WC_Order $order |
372 | 372 | * @return array |
373 | 373 | */ |
374 | - protected function maybe_handle_order( $order ) { |
|
374 | + protected function maybe_handle_order($order) { |
|
375 | 375 | $order_id = $order->get_id(); |
376 | - $stripe_source_id = get_post_meta( $order_id, '_stripe_source_id', true ); |
|
377 | - $stripe_refund_id = get_post_meta( $order_id, '_stripe_refund_id', true ); |
|
378 | - $stripe_customer_id = get_post_meta( $order_id, '_stripe_customer_id', true ); |
|
376 | + $stripe_source_id = get_post_meta($order_id, '_stripe_source_id', true); |
|
377 | + $stripe_refund_id = get_post_meta($order_id, '_stripe_refund_id', true); |
|
378 | + $stripe_customer_id = get_post_meta($order_id, '_stripe_customer_id', true); |
|
379 | 379 | |
380 | - if ( ! $this->is_retention_expired( $order->get_date_created()->getTimestamp() ) ) { |
|
380 | + if ( ! $this->is_retention_expired($order->get_date_created()->getTimestamp())) { |
|
381 | 381 | /* translators: %d Order ID */ |
382 | - return array( false, true, array( sprintf( __( 'Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) ); |
|
382 | + return array(false, true, array(sprintf(__('Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id()))); |
|
383 | 383 | } |
384 | 384 | |
385 | - if ( empty( $stripe_source_id ) && empty( $stripe_refund_id ) && empty( $stripe_customer_id ) ) { |
|
386 | - return array( false, false, array() ); |
|
385 | + if (empty($stripe_source_id) && empty($stripe_refund_id) && empty($stripe_customer_id)) { |
|
386 | + return array(false, false, array()); |
|
387 | 387 | } |
388 | 388 | |
389 | - delete_post_meta( $order_id, '_stripe_source_id' ); |
|
390 | - delete_post_meta( $order_id, '_stripe_refund_id' ); |
|
391 | - delete_post_meta( $order_id, '_stripe_customer_id' ); |
|
389 | + delete_post_meta($order_id, '_stripe_source_id'); |
|
390 | + delete_post_meta($order_id, '_stripe_refund_id'); |
|
391 | + delete_post_meta($order_id, '_stripe_customer_id'); |
|
392 | 392 | |
393 | - return array( true, false, array( __( 'Stripe personal data erased.', 'woocommerce-gateway-stripe' ) ) ); |
|
393 | + return array(true, false, array(__('Stripe personal data erased.', 'woocommerce-gateway-stripe'))); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Checks if create date is passed retention duration. |
398 | 398 | * |
399 | 399 | */ |
400 | - public function is_retention_expired( $created_date ) { |
|
401 | - $retention = wc_parse_relative_date_option( get_option( 'woocommerce_gateway_stripe_retention' ) ); |
|
400 | + public function is_retention_expired($created_date) { |
|
401 | + $retention = wc_parse_relative_date_option(get_option('woocommerce_gateway_stripe_retention')); |
|
402 | 402 | $is_expired = false; |
403 | - $time_span = time() - strtotime( $created_date ); |
|
404 | - if ( empty( $retention ) || empty( $created_date ) ) { |
|
403 | + $time_span = time() - strtotime($created_date); |
|
404 | + if (empty($retention) || empty($created_date)) { |
|
405 | 405 | return false; |
406 | 406 | } |
407 | - switch ( $retention['unit'] ) { |
|
407 | + switch ($retention['unit']) { |
|
408 | 408 | case 'days': |
409 | 409 | $retention = $retention['number'] * DAY_IN_SECONDS; |
410 | - if ( $time_span > $retention ) { |
|
410 | + if ($time_span > $retention) { |
|
411 | 411 | $is_expired = true; |
412 | 412 | } |
413 | 413 | break; |
414 | 414 | case 'weeks': |
415 | 415 | $retention = $retention['number'] * WEEK_IN_SECONDS; |
416 | - if ( $time_span > $retention ) { |
|
416 | + if ($time_span > $retention) { |
|
417 | 417 | $is_expired = true; |
418 | 418 | } |
419 | 419 | break; |
420 | 420 | case 'months': |
421 | 421 | $retention = $retention['number'] * MONTH_IN_SECONDS; |
422 | - if ( $time_span > $retention ) { |
|
422 | + if ($time_span > $retention) { |
|
423 | 423 | $is_expired = true; |
424 | 424 | } |
425 | 425 | break; |
426 | 426 | case 'years': |
427 | 427 | $retention = $retention['number'] * YEAR_IN_SECONDS; |
428 | - if ( $time_span > $retention ) { |
|
428 | + if ($time_span > $retention) { |
|
429 | 429 | $is_expired = true; |
430 | 430 | } |
431 | 431 | break; |